69981bdffe8d611da25b40af35600316fe8c7e65
[platform/upstream/gobject-introspection.git] / gir / glib-2.0.c
1 /************************************************************/
2 /* THIS FILE IS GENERATED DO NOT EDIT */
3 /************************************************************/
4
5 /**
6  * ABS:
7  * @a: a numeric value
8  *
9  * Calculates the absolute value of @a.
10  * The absolute value is simply the number with any negative sign taken away.
11  *
12  * For example,
13  * - ABS(-10) is 10.
14  * - ABS(10) is also 10.
15  *
16  * Returns: the absolute value of @a.
17  */
18
19
20 /**
21  * CLAMP:
22  * @x: the value to clamp
23  * @low: the minimum value allowed
24  * @high: the maximum value allowed
25  *
26  * Ensures that @x is between the limits set by @low and @high. If @low is
27  * greater than @high the result is undefined.
28  *
29  * For example,
30  * - CLAMP(5, 10, 15) is 10.
31  * - CLAMP(15, 5, 10) is 10.
32  * - CLAMP(20, 15, 25) is 20.
33  *
34  * Returns: the value of @x clamped to the range between @low and @high
35  */
36
37
38 /**
39  * C_:
40  * @Context: a message context, must be a string literal
41  * @String: a message id, must be a string literal
42  *
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
46  * they are used.
47  * |[
48  * label1 = C_("Navigation", "Back");
49  * label2 = C_("Body part", "Back");
50  * ]|
51  *
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>
56  *
57  * Returns: the translated message
58  * Since: 2.16
59  */
60
61
62 /**
63  * FALSE:
64  *
65  * Defines the %FALSE value for the #gboolean type.
66  */
67
68
69 /**
70  * GArray:
71  * @data: a pointer to the element data. The data may be moved as
72  *        elements are added to the #GArray.
73  * @len: the number of elements in the #GArray not including the
74  *       possible terminating zero element.
75  *
76  * Contains the public fields of an <link linkend="glib-Arrays">Array</link>.
77  */
78
79
80 /**
81  * GAsyncQueue:
82  *
83  * The GAsyncQueue struct is an opaque data structure which represents
84  * an asynchronous queue. It should only be accessed through the
85  * <function>g_async_queue_*</function> functions.
86  */
87
88
89 /**
90  * GByteArray:
91  * @data: a pointer to the element data. The data may be moved as
92  *        elements are added to the #GByteArray.
93  * @len: the number of elements in the #GByteArray.
94  *
95  * The <structname>GByteArray</structname> struct allows access to the
96  * public fields of a <structname>GByteArray</structname>.
97  */
98
99
100 /**
101  * GBytes:
102  *
103  * A simple refcounted data type representing an immutable byte sequence
104  * from an unspecified origin.
105  *
106  * The purpose of a #GBytes is to keep the memory region that it holds
107  * alive for as long as anyone holds a reference to the bytes.  When
108  * the last reference count is dropped, the memory is released. Multiple
109  * unrelated callers can use byte data in the #GBytes without coordinating
110  * their activities, resting assured that the byte data will not change or
111  * move while they hold a reference.
112  *
113  * A #GBytes can come from many different origins that may have
114  * different procedures for freeing the memory region.  Examples are
115  * memory from g_malloc(), from memory slices, from a #GMappedFile or
116  * memory from other allocators.
117  *
118  * #GBytes work well as keys in #GHashTable. Use g_bytes_equal() and
119  * g_bytes_hash() as parameters to g_hash_table_new() or g_hash_table_new_full().
120  * #GBytes can also be used as keys in a #GTree by passing the g_bytes_compare()
121  * function to g_tree_new().
122  *
123  * The data pointed to by this bytes must not be modified. For a mutable
124  * array of bytes see #GByteArray. Use g_bytes_unref_to_array() to create a
125  * mutable array for a #GBytes sequence. To create an immutable #GBytes from
126  * a mutable #GByteArray, use the g_byte_array_free_to_bytes() function.
127  *
128  * Since: 2.32
129  */
130
131
132 /**
133  * GCompareDataFunc:
134  * @a: a value.
135  * @b: a value to compare with.
136  * @user_data: user data to pass to comparison function.
137  *
138  * Specifies the type of a comparison function used to compare two
139  * values.  The function should return a negative integer if the first
140  * value comes before the second, 0 if they are equal, or a positive
141  * integer if the first value comes after the second.
142  *
143  * Returns: negative value if @a &lt; @b; zero if @a = @b; positive
144  *          value if @a > @b.
145  */
146
147
148 /**
149  * GCompareFunc:
150  * @a: a value.
151  * @b: a value to compare with.
152  *
153  * Specifies the type of a comparison function used to compare two
154  * values.  The function should return a negative integer if the first
155  * value comes before the second, 0 if they are equal, or a positive
156  * integer if the first value comes after the second.
157  *
158  * Returns: negative value if @a &lt; @b; zero if @a = @b; positive
159  *          value if @a > @b.
160  */
161
162
163 /**
164  * GCond:
165  *
166  * The #GCond struct is an opaque data structure that represents a
167  * condition. Threads can block on a #GCond if they find a certain
168  * condition to be false. If other threads change the state of this
169  * condition they signal the #GCond, and that causes the waiting
170  * threads to be woken up.
171  *
172  * Consider the following example of a shared variable.  One or more
173  * threads can wait for data to be published to the variable and when
174  * another thread publishes the data, it can signal one of the waiting
175  * threads to wake up to collect the data.
176  *
177  * <example>
178  *  <title>
179  *   Using GCond to block a thread until a condition is satisfied
180  *  </title>
181  *  <programlisting>
182  *   gpointer current_data = NULL;
183  *   GMutex data_mutex;
184  *   GCond data_cond;
185  *
186  *   void
187  *   push_data (gpointer data)
188  *   {
189  *     g_mutex_lock (&data_mutex);
190  *     current_data = data;
191  *     g_cond_signal (&data_cond);
192  *     g_mutex_unlock (&data_mutex);
193  *   }
194  *
195  *   gpointer
196  *   pop_data (void)
197  *   {
198  *     gpointer data;
199  *
200  *     g_mutex_lock (&data_mutex);
201  *     while (!current_data)
202  *       g_cond_wait (&data_cond, &data_mutex);
203  *     data = current_data;
204  *     current_data = NULL;
205  *     g_mutex_unlock (&data_mutex);
206  *
207  *     return data;
208  *   }
209  *  </programlisting>
210  * </example>
211  *
212  * Whenever a thread calls pop_data() now, it will wait until
213  * current_data is non-%NULL, i.e. until some other thread
214  * has called push_data().
215  *
216  * The example shows that use of a condition variable must always be
217  * paired with a mutex.  Without the use of a mutex, there would be a
218  * race between the check of <varname>current_data</varname> by the
219  * while loop in <function>pop_data</function> and waiting.
220  * Specifically, another thread could set <varname>pop_data</varname>
221  * after the check, and signal the cond (with nobody waiting on it)
222  * before the first thread goes to sleep.  #GCond is specifically useful
223  * for its ability to release the mutex and go to sleep atomically.
224  *
225  * It is also important to use the g_cond_wait() and g_cond_wait_until()
226  * functions only inside a loop which checks for the condition to be
227  * true.  See g_cond_wait() for an explanation of why the condition may
228  * not be true even after it returns.
229  *
230  * If a #GCond is allocated in static storage then it can be used
231  * without initialisation.  Otherwise, you should call g_cond_init() on
232  * it and g_cond_clear() when done.
233  *
234  * A #GCond should only be accessed via the <function>g_cond_</function>
235  * functions.
236  */
237
238
239 /**
240  * GData:
241  *
242  * The #GData struct is an opaque data structure to represent a <link
243  * linkend="glib-Keyed-Data-Lists">Keyed Data List</link>. It should
244  * only be accessed via the following functions.
245  */
246
247
248 /**
249  * GDataForeachFunc:
250  * @key_id: the #GQuark id to identifying the data element.
251  * @data: the data element.
252  * @user_data: user data passed to g_dataset_foreach().
253  *
254  * Specifies the type of function passed to g_dataset_foreach(). It is
255  * called with each #GQuark id and associated data element, together
256  * with the @user_data parameter supplied to g_dataset_foreach().
257  */
258
259
260 /**
261  * GDate:
262  * @julian_days: the Julian representation of the date
263  * @julian: this bit is set if @julian_days is valid
264  * @dmy: this is set if @day, @month and @year are valid
265  * @day: the day of the day-month-year representation of the date,
266  *     as a number between 1 and 31
267  * @month: the day of the day-month-year representation of the date,
268  *     as a number between 1 and 12
269  * @year: the day of the day-month-year representation of the date
270  *
271  * Represents a day between January 1, Year 1 and a few thousand years in
272  * the future. None of its members should be accessed directly. If the
273  * <structname>GDate</structname> is obtained from g_date_new(), it will
274  * be safe to mutate but invalid and thus not safe for calendrical
275  * computations. If it's declared on the stack, it will contain garbage
276  * so must be initialized with g_date_clear(). g_date_clear() makes the
277  * date invalid but sane. An invalid date doesn't represent a day, it's
278  * "empty." A date becomes valid after you set it to a Julian day or you
279  * set a day, month, and year.
280  */
281
282
283 /**
284  * GDateDMY:
285  * @G_DATE_DAY: a day
286  * @G_DATE_MONTH: a month
287  * @G_DATE_YEAR: a year
288  *
289  * This enumeration isn't used in the API, but may be useful if you need
290  * to mark a number as a day, month, or year.
291  */
292
293
294 /**
295  * GDateDay:
296  *
297  * Integer representing a day of the month; between 1 and
298  * 31. #G_DATE_BAD_DAY represents an invalid day of the month.
299  */
300
301
302 /**
303  * GDateMonth:
304  * @G_DATE_BAD_MONTH: invalid value
305  * @G_DATE_JANUARY: January
306  * @G_DATE_FEBRUARY: February
307  * @G_DATE_MARCH: March
308  * @G_DATE_APRIL: April
309  * @G_DATE_MAY: May
310  * @G_DATE_JUNE: June
311  * @G_DATE_JULY: July
312  * @G_DATE_AUGUST: August
313  * @G_DATE_SEPTEMBER: September
314  * @G_DATE_OCTOBER: October
315  * @G_DATE_NOVEMBER: November
316  * @G_DATE_DECEMBER: December
317  *
318  * Enumeration representing a month; values are #G_DATE_JANUARY,
319  * #G_DATE_FEBRUARY, etc. #G_DATE_BAD_MONTH is the invalid value.
320  */
321
322
323 /**
324  * GDateWeekday:
325  * @G_DATE_BAD_WEEKDAY: invalid value
326  * @G_DATE_MONDAY: Monday
327  * @G_DATE_TUESDAY: Tuesday
328  * @G_DATE_WEDNESDAY: Wednesday
329  * @G_DATE_THURSDAY: Thursday
330  * @G_DATE_FRIDAY: Friday
331  * @G_DATE_SATURDAY: Saturday
332  * @G_DATE_SUNDAY: Sunday
333  *
334  * Enumeration representing a day of the week; #G_DATE_MONDAY,
335  * #G_DATE_TUESDAY, etc. #G_DATE_BAD_WEEKDAY is an invalid weekday.
336  */
337
338
339 /**
340  * GDateYear:
341  *
342  * Integer representing a year; #G_DATE_BAD_YEAR is the invalid
343  * value. The year must be 1 or higher; negative (BC) years are not
344  * allowed. The year is represented with four digits.
345  */
346
347
348 /**
349  * GDestroyNotify:
350  * @data: the data element.
351  *
352  * Specifies the type of function which is called when a data element
353  * is destroyed. It is passed the pointer to the data element and
354  * should free any memory and resources allocated for it.
355  */
356
357
358 /**
359  * GDir:
360  *
361  * An opaque structure representing an opened directory.
362  */
363
364
365 /**
366  * GDoubleIEEE754:
367  * @v_double: the double value
368  *
369  * The #GFloatIEEE754 and #GDoubleIEEE754 unions are used to access the sign,
370  * mantissa and exponent of IEEE floats and doubles. These unions are defined
371  * as appropriate for a given platform. IEEE floats and doubles are supported
372  * (used for storage) by at least Intel, PPC and Sparc.
373  */
374
375
376 /**
377  * GDuplicateFunc:
378  * @data: the data to duplicate
379  * @user_data: user data that was specified in g_datalist_id_dup_data()
380  *
381  * The type of functions that are used to 'duplicate' an object.
382  * What this means depends on the context, it could just be
383  * incrementing the reference count, if @data is a ref-counted
384  * object.
385  *
386  * Returns: a duplicate of data
387  */
388
389
390 /**
391  * GEqualFunc:
392  * @a: a value
393  * @b: a value to compare with
394  *
395  * Specifies the type of a function used to test two values for
396  * equality. The function should return %TRUE if both values are equal
397  * and %FALSE otherwise.
398  *
399  * Returns: %TRUE if @a = @b; %FALSE otherwise
400  */
401
402
403 /**
404  * GErrorType:
405  * @G_ERR_UNKNOWN: unknown error
406  * @G_ERR_UNEXP_EOF: unexpected end of file
407  * @G_ERR_UNEXP_EOF_IN_STRING: unterminated string constant
408  * @G_ERR_UNEXP_EOF_IN_COMMENT: unterminated comment
409  * @G_ERR_NON_DIGIT_IN_CONST: non-digit character in a number
410  * @G_ERR_DIGIT_RADIX: digit beyond radix in a number
411  * @G_ERR_FLOAT_RADIX: non-decimal floating point number
412  * @G_ERR_FLOAT_MALFORMED: malformed floating point number
413  *
414  * The possible errors, used in the @v_error field
415  * of #GTokenValue, when the token is a %G_TOKEN_ERROR.
416  */
417
418
419 /**
420  * GFileError:
421  * @G_FILE_ERROR_EXIST: Operation not permitted; only the owner of
422  *     the file (or other resource) or processes with special privileges
423  *     can perform the operation.
424  * @G_FILE_ERROR_ISDIR: File is a directory; you cannot open a directory
425  *     for writing, or create or remove hard links to it.
426  * @G_FILE_ERROR_ACCES: Permission denied; the file permissions do not
427  *     allow the attempted operation.
428  * @G_FILE_ERROR_NAMETOOLONG: Filename too long.
429  * @G_FILE_ERROR_NOENT: No such file or directory. This is a "file
430  *     doesn't exist" error for ordinary files that are referenced in
431  *     contexts where they are expected to already exist.
432  * @G_FILE_ERROR_NOTDIR: A file that isn't a directory was specified when
433  *     a directory is required.
434  * @G_FILE_ERROR_NXIO: No such device or address. The system tried to
435  *     use the device represented by a file you specified, and it
436  *     couldn't find the device. This can mean that the device file was
437  *     installed incorrectly, or that the physical device is missing or
438  *     not correctly attached to the computer.
439  * @G_FILE_ERROR_NODEV: The underlying file system of the specified file
440  *     does not support memory mapping.
441  * @G_FILE_ERROR_ROFS: The directory containing the new link can't be
442  *     modified because it's on a read-only file system.
443  * @G_FILE_ERROR_TXTBSY: Text file busy.
444  * @G_FILE_ERROR_FAULT: You passed in a pointer to bad memory.
445  *     (GLib won't reliably return this, don't pass in pointers to bad
446  *     memory.)
447  * @G_FILE_ERROR_LOOP: Too many levels of symbolic links were encountered
448  *     in looking up a file name. This often indicates a cycle of symbolic
449  *     links.
450  * @G_FILE_ERROR_NOSPC: No space left on device; write operation on a
451  *     file failed because the disk is full.
452  * @G_FILE_ERROR_NOMEM: No memory available. The system cannot allocate
453  *     more virtual memory because its capacity is full.
454  * @G_FILE_ERROR_MFILE: The current process has too many files open and
455  *     can't open any more. Duplicate descriptors do count toward this
456  *     limit.
457  * @G_FILE_ERROR_NFILE: There are too many distinct file openings in the
458  *     entire system.
459  * @G_FILE_ERROR_BADF: Bad file descriptor; for example, I/O on a
460  *     descriptor that has been closed or reading from a descriptor open
461  *     only for writing (or vice versa).
462  * @G_FILE_ERROR_INVAL: Invalid argument. This is used to indicate
463  *     various kinds of problems with passing the wrong argument to a
464  *     library function.
465  * @G_FILE_ERROR_PIPE: Broken pipe; there is no process reading from the
466  *     other end of a pipe. Every library function that returns this
467  *     error code also generates a 'SIGPIPE' signal; this signal
468  *     terminates the program if not handled or blocked. Thus, your
469  *     program will never actually see this code unless it has handled
470  *     or blocked 'SIGPIPE'.
471  * @G_FILE_ERROR_AGAIN: Resource temporarily unavailable; the call might
472  *     work if you try again later.
473  * @G_FILE_ERROR_INTR: Interrupted function call; an asynchronous signal
474  *     occurred and prevented completion of the call. When this
475  *     happens, you should try the call again.
476  * @G_FILE_ERROR_IO: Input/output error; usually used for physical read
477  *    or write errors. i.e. the disk or other physical device hardware
478  *    is returning errors.
479  * @G_FILE_ERROR_PERM: Operation not permitted; only the owner of the
480  *    file (or other resource) or processes with special privileges can
481  *    perform the operation.
482  * @G_FILE_ERROR_NOSYS: Function not implemented; this indicates that
483  *    the system is missing some functionality.
484  * @G_FILE_ERROR_FAILED: Does not correspond to a UNIX error code; this
485  *    is the standard "failed for unspecified reason" error code present
486  *    in all #GError error code enumerations. Returned if no specific
487  *    code applies.
488  *
489  * Values corresponding to @errno codes returned from file operations
490  * on UNIX. Unlike @errno codes, GFileError values are available on
491  * all systems, even Windows. The exact meaning of each code depends
492  * on what sort of file operation you were performing; the UNIX
493  * documentation gives more details. The following error code descriptions
494  * come from the GNU C Library manual, and are under the copyright
495  * of that manual.
496  *
497  * It's not very portable to make detailed assumptions about exactly
498  * which errors will be returned from a given operation. Some errors
499  * don't occur on some systems, etc., sometimes there are subtle
500  * differences in when a system will report a given error, etc.
501  */
502
503
504 /**
505  * GFileTest:
506  * @G_FILE_TEST_IS_REGULAR: %TRUE if the file is a regular file
507  *     (not a directory). Note that this test will also return %TRUE
508  *     if the tested file is a symlink to a regular file.
509  * @G_FILE_TEST_IS_SYMLINK: %TRUE if the file is a symlink.
510  * @G_FILE_TEST_IS_DIR: %TRUE if the file is a directory.
511  * @G_FILE_TEST_IS_EXECUTABLE: %TRUE if the file is executable.
512  * @G_FILE_TEST_EXISTS: %TRUE if the file exists. It may or may not
513  *     be a regular file.
514  *
515  * A test to perform on a file using g_file_test().
516  */
517
518
519 /**
520  * GFloatIEEE754:
521  * @v_float: the double value
522  *
523  * The #GFloatIEEE754 and #GDoubleIEEE754 unions are used to access the sign,
524  * mantissa and exponent of IEEE floats and doubles. These unions are defined
525  * as appropriate for a given platform. IEEE floats and doubles are supported
526  * (used for storage) by at least Intel, PPC and Sparc.
527  */
528
529
530 /**
531  * GFormatSizeFlags:
532  * @G_FORMAT_SIZE_DEFAULT: behave the same as g_format_size()
533  * @G_FORMAT_SIZE_LONG_FORMAT: include the exact number of bytes as part
534  *     of the returned string.  For example, "45.6 kB (45,612 bytes)".
535  * @G_FORMAT_SIZE_IEC_UNITS: use IEC (base 1024) units with "KiB"-style
536  *     suffixes. IEC units should only be used for reporting things with
537  *     a strong "power of 2" basis, like RAM sizes or RAID stripe sizes.
538  *     Network and storage sizes should be reported in the normal SI units.
539  *
540  * Flags to modify the format of the string returned by g_format_size_full().
541  */
542
543
544 /**
545  * GFunc:
546  * @data: the element's data.
547  * @user_data: user data passed to g_list_foreach() or
548  *             g_slist_foreach().
549  *
550  * Specifies the type of functions passed to g_list_foreach() and
551  * g_slist_foreach().
552  */
553
554
555 /**
556  * GHFunc:
557  * @key: a key
558  * @value: the value corresponding to the key
559  * @user_data: user data passed to g_hash_table_foreach()
560  *
561  * Specifies the type of the function passed to g_hash_table_foreach().
562  * It is called with each key/value pair, together with the @user_data
563  * parameter which is passed to g_hash_table_foreach().
564  */
565
566
567 /**
568  * GHRFunc:
569  * @key: a key
570  * @value: the value associated with the key
571  * @user_data: user data passed to g_hash_table_remove()
572  *
573  * Specifies the type of the function passed to
574  * g_hash_table_foreach_remove(). It is called with each key/value
575  * pair, together with the @user_data parameter passed to
576  * g_hash_table_foreach_remove(). It should return %TRUE if the
577  * key/value pair should be removed from the #GHashTable.
578  *
579  * Returns: %TRUE if the key/value pair should be removed from the
580  *     #GHashTable
581  */
582
583
584 /**
585  * GHashFunc:
586  * @key: a key
587  *
588  * Specifies the type of the hash function which is passed to
589  * g_hash_table_new() when a #GHashTable is created.
590  *
591  * The function is passed a key and should return a #guint hash value.
592  * The functions g_direct_hash(), g_int_hash() and g_str_hash() provide
593  * hash functions which can be used when the key is a #gpointer, #gint*,
594  * and #gchar* respectively.
595  *
596  * g_direct_hash() is also the appropriate hash function for keys
597  * of the form <literal>GINT_TO_POINTER (n)</literal> (or similar macros).
598  *
599  * <!-- FIXME: Need more here. --> A good hash functions should produce
600  * hash values that are evenly distributed over a fairly large range.
601  * The modulus is taken with the hash table size (a prime number) to
602  * find the 'bucket' to place each key into. The function should also
603  * be very fast, since it is called for each key lookup.
604  *
605  * Note that the hash functions provided by GLib have these qualities,
606  * but are not particularly robust against manufactured keys that
607  * cause hash collisions. Therefore, you should consider choosing
608  * a more secure hash function when using a GHashTable with keys
609  * that originate in untrusted data (such as HTTP requests).
610  * Using g_str_hash() in that situation might make your application
611  * vulerable to <ulink url="https://lwn.net/Articles/474912/">Algorithmic Complexity Attacks</ulink>.
612  *
613  * The key to choosing a good hash is unpredictability.  Even
614  * cryptographic hashes are very easy to find collisions for when the
615  * remainder is taken modulo a somewhat predictable prime number.  There
616  * must be an element of randomness that an attacker is unable to guess.
617  *
618  * Returns: the hash value corresponding to the key
619  */
620
621
622 /**
623  * GHashTable:
624  *
625  * The #GHashTable struct is an opaque data structure to represent a
626  * <link linkend="glib-Hash-Tables">Hash Table</link>. It should only be
627  * accessed via the following functions.
628  */
629
630
631 /**
632  * GHashTableIter:
633  *
634  * A GHashTableIter structure represents an iterator that can be used
635  * to iterate over the elements of a #GHashTable. GHashTableIter
636  * structures are typically allocated on the stack and then initialized
637  * with g_hash_table_iter_init().
638  */
639
640
641 /**
642  * GHook:
643  * @data: data which is passed to func when this hook is invoked
644  * @next: pointer to the next hook in the list
645  * @prev: pointer to the previous hook in the list
646  * @ref_count: the reference count of this hook
647  * @hook_id: the id of this hook, which is unique within its list
648  * @flags: flags which are set for this hook. See #GHookFlagMask for
649  *     predefined flags
650  * @func: the function to call when this hook is invoked. The possible
651  *     signatures for this function are #GHookFunc and #GHookCheckFunc
652  * @destroy: the default @finalize_hook function of a #GHookList calls
653  *     this member of the hook that is being finalized
654  *
655  * The <structname>GHook</structname> struct represents a single hook
656  * function in a #GHookList.
657  */
658
659
660 /**
661  * GHookCheckFunc:
662  * @data: the data field of the #GHook is passed to the hook function here
663  *
664  * Defines the type of a hook function that can be invoked
665  * by g_hook_list_invoke_check().
666  *
667  * Returns: %FALSE if the #GHook should be destroyed
668  */
669
670
671 /**
672  * GHookCheckMarshaller:
673  * @hook: a #GHook
674  * @marshal_data: user data
675  *
676  * Defines the type of function used by g_hook_list_marshal_check().
677  *
678  * Returns: %FALSE if @hook should be destroyed
679  */
680
681
682 /**
683  * GHookCompareFunc:
684  * @new_hook: the #GHook being inserted
685  * @sibling: the #GHook to compare with @new_hook
686  *
687  * Defines the type of function used to compare #GHook elements in
688  * g_hook_insert_sorted().
689  *
690  * Returns: a value &lt;= 0 if @new_hook should be before @sibling
691  */
692
693
694 /**
695  * GHookFinalizeFunc:
696  * @hook_list: a #GHookList
697  * @hook: the hook in @hook_list that gets finalized
698  *
699  * Defines the type of function to be called when a hook in a
700  * list of hooks gets finalized.
701  */
702
703
704 /**
705  * GHookFindFunc:
706  * @hook: a #GHook
707  * @data: user data passed to g_hook_find_func()
708  *
709  * Defines the type of the function passed to g_hook_find().
710  *
711  * Returns: %TRUE if the required #GHook has been found
712  */
713
714
715 /**
716  * GHookFlagMask:
717  * @G_HOOK_FLAG_ACTIVE: set if the hook has not been destroyed
718  * @G_HOOK_FLAG_IN_CALL: set if the hook is currently being run
719  * @G_HOOK_FLAG_MASK: A mask covering all bits reserved for
720  *   hook flags; see %G_HOOK_FLAG_USER_SHIFT
721  *
722  * Flags used internally in the #GHook implementation.
723  */
724
725
726 /**
727  * GHookFunc:
728  * @data: the data field of the #GHook is passed to the hook function here
729  *
730  * Defines the type of a hook function that can be invoked
731  * by g_hook_list_invoke().
732  */
733
734
735 /**
736  * GHookList:
737  * @seq_id: the next free #GHook id
738  * @hook_size: the size of the #GHookList elements, in bytes
739  * @is_setup: 1 if the #GHookList has been initialized
740  * @hooks: the first #GHook element in the list
741  * @dummy3: unused
742  * @finalize_hook: the function to call to finalize a #GHook element.
743  *     The default behaviour is to call the hooks @destroy function
744  * @dummy: unused
745  *
746  * The <structname>GHookList</structname> struct represents a
747  * list of hook functions.
748  */
749
750
751 /**
752  * GHookMarshaller:
753  * @hook: a #GHook
754  * @marshal_data: user data
755  *
756  * Defines the type of function used by g_hook_list_marshal().
757  */
758
759
760 /**
761  * GINT16_FROM_BE:
762  * @val: a #gint16 value in big-endian byte order
763  *
764  * Converts a #gint16 value from big-endian to host byte order.
765  *
766  * Returns: @val converted to host byte order
767  */
768
769
770 /**
771  * GINT16_FROM_LE:
772  * @val: a #gint16 value in little-endian byte order
773  *
774  * Converts a #gint16 value from little-endian to host byte order.
775  *
776  * Returns: @val converted to host byte order
777  */
778
779
780 /**
781  * GINT16_TO_BE:
782  * @val: a #gint16 value in host byte order
783  *
784  * Converts a #gint16 value from host byte order to big-endian.
785  *
786  * Returns: @val converted to big-endian
787  */
788
789
790 /**
791  * GINT16_TO_LE:
792  * @val: a #gint16 value in host byte order
793  *
794  * Converts a #gint16 value from host byte order to little-endian.
795  *
796  * Returns: @val converted to little-endian
797  */
798
799
800 /**
801  * GINT32_FROM_BE:
802  * @val: a #gint32 value in big-endian byte order
803  *
804  * Converts a #gint32 value from big-endian to host byte order.
805  *
806  * Returns: @val converted to host byte order
807  */
808
809
810 /**
811  * GINT32_FROM_LE:
812  * @val: a #gint32 value in little-endian byte order
813  *
814  * Converts a #gint32 value from little-endian to host byte order.
815  *
816  * Returns: @val converted to host byte order
817  */
818
819
820 /**
821  * GINT32_TO_BE:
822  * @val: a #gint32 value in host byte order
823  *
824  * Converts a #gint32 value from host byte order to big-endian.
825  *
826  * Returns: @val converted to big-endian
827  */
828
829
830 /**
831  * GINT32_TO_LE:
832  * @val: a #gint32 value in host byte order
833  *
834  * Converts a #gint32 value from host byte order to little-endian.
835  *
836  * Returns: @val converted to little-endian
837  */
838
839
840 /**
841  * GINT64_FROM_BE:
842  * @val: a #gint64 value in big-endian byte order
843  *
844  * Converts a #gint64 value from big-endian to host byte order.
845  *
846  * Returns: @val converted to host byte order
847  */
848
849
850 /**
851  * GINT64_FROM_LE:
852  * @val: a #gint64 value in little-endian byte order
853  *
854  * Converts a #gint64 value from little-endian to host byte order.
855  *
856  * Returns: @val converted to host byte order
857  */
858
859
860 /**
861  * GINT64_TO_BE:
862  * @val: a #gint64 value in host byte order
863  *
864  * Converts a #gint64 value from host byte order to big-endian.
865  *
866  * Returns: @val converted to big-endian
867  */
868
869
870 /**
871  * GINT64_TO_LE:
872  * @val: a #gint64 value in host byte order
873  *
874  * Converts a #gint64 value from host byte order to little-endian.
875  *
876  * Returns: @val converted to little-endian
877  */
878
879
880 /**
881  * GINT_FROM_BE:
882  * @val: a #gint value in big-endian byte order
883  *
884  * Converts a #gint value from big-endian to host byte order.
885  *
886  * Returns: @val converted to host byte order
887  */
888
889
890 /**
891  * GINT_FROM_LE:
892  * @val: a #gint value in little-endian byte order
893  *
894  * Converts a #gint value from little-endian to host byte order.
895  *
896  * Returns: @val converted to host byte order
897  */
898
899
900 /**
901  * GINT_TO_BE:
902  * @val: a #gint value in host byte order
903  *
904  * Converts a #gint value from host byte order to big-endian.
905  *
906  * Returns: @val converted to big-endian byte order
907  */
908
909
910 /**
911  * GINT_TO_LE:
912  * @val: a #gint value in host byte order
913  *
914  * Converts a #gint value from host byte order to little-endian.
915  *
916  * Returns: @val converted to little-endian byte order
917  */
918
919
920 /**
921  * GINT_TO_POINTER:
922  * @i: integer to stuff into a pointer
923  *
924  * Stuffs an integer into a pointer type.
925  *
926  * Remember, you may not store pointers in integers. This is not portable
927  * in any way, shape or form. These macros <emphasis>only</emphasis> allow
928  * storing integers in pointers, and only preserve 32 bits of the
929  * integer; values outside the range of a 32-bit integer will be mangled.
930  */
931
932
933 /**
934  * GIOChannel:
935  *
936  * A data structure representing an IO Channel. The fields should be
937  * considered private and should only be accessed with the following
938  * functions.
939  */
940
941
942 /**
943  * GIOChannelError:
944  * @G_IO_CHANNEL_ERROR_FBIG: File too large.
945  * @G_IO_CHANNEL_ERROR_INVAL: Invalid argument.
946  * @G_IO_CHANNEL_ERROR_IO: IO error.
947  * @G_IO_CHANNEL_ERROR_ISDIR: File is a directory.
948  * @G_IO_CHANNEL_ERROR_NOSPC: No space left on device.
949  * @G_IO_CHANNEL_ERROR_NXIO: No such device or address.
950  * @G_IO_CHANNEL_ERROR_OVERFLOW: Value too large for defined datatype.
951  * @G_IO_CHANNEL_ERROR_PIPE: Broken pipe.
952  * @G_IO_CHANNEL_ERROR_FAILED: Some other error.
953  *
954  * Error codes returned by #GIOChannel operations.
955  */
956
957
958 /**
959  * GIOCondition:
960  * @G_IO_IN: There is data to read.
961  * @G_IO_OUT: Data can be written (without blocking).
962  * @G_IO_PRI: There is urgent data to read.
963  * @G_IO_ERR: Error condition.
964  * @G_IO_HUP: Hung up (the connection has been broken, usually for
965  *            pipes and sockets).
966  * @G_IO_NVAL: Invalid request. The file descriptor is not open.
967  *
968  * A bitwise combination representing a condition to watch for on an
969  * event source.
970  */
971
972
973 /**
974  * GIOError:
975  * @G_IO_ERROR_NONE: no error
976  * @G_IO_ERROR_AGAIN: an EAGAIN error occurred
977  * @G_IO_ERROR_INVAL: an EINVAL error occurred
978  * @G_IO_ERROR_UNKNOWN: another error occurred
979  *
980  * #GIOError is only used by the deprecated functions
981  * g_io_channel_read(), g_io_channel_write(), and g_io_channel_seek().
982  */
983
984
985 /**
986  * GIOFlags:
987  * @G_IO_FLAG_APPEND: turns on append mode, corresponds to <literal>O_APPEND</literal>
988  *                    (see the documentation of the UNIX open()
989  *                    syscall).
990  * @G_IO_FLAG_NONBLOCK: turns on nonblocking mode, corresponds to
991  *                      <literal>O_NONBLOCK</literal>/<literal>O_NDELAY</literal>
992  *                      (see the documentation of the UNIX open() syscall).
993  * @G_IO_FLAG_IS_READABLE: indicates that the io channel is readable.
994  *                         This flag cannot be changed.
995  * @G_IO_FLAG_IS_WRITABLE: indicates that the io channel is writable.
996  *                          This flag cannot be changed.
997  * @G_IO_FLAG_IS_SEEKABLE: indicates that the io channel is seekable,
998  *                         i.e. that g_io_channel_seek_position() can
999  *                         be used on it.  This flag cannot be changed.
1000  * @G_IO_FLAG_MASK: the mask that specifies all the valid flags.
1001  * @G_IO_FLAG_GET_MASK: the mask of the flags that are returned from
1002  *                      g_io_channel_get_flags().
1003  * @G_IO_FLAG_SET_MASK: the mask of the flags that the user can modify
1004  *                      with g_io_channel_set_flags().
1005  *
1006  * Specifies properties of a #GIOChannel. Some of the flags can only be
1007  * read with g_io_channel_get_flags(), but not changed with
1008  * g_io_channel_set_flags().
1009  */
1010
1011
1012 /**
1013  * GIOFunc:
1014  * @source: the #GIOChannel event source
1015  * @condition: the condition which has been satisfied
1016  * @data: user data set in g_io_add_watch() or g_io_add_watch_full()
1017  *
1018  * Specifies the type of function passed to g_io_add_watch() or
1019  * g_io_add_watch_full(), which is called when the requested condition
1020  * on a #GIOChannel is satisfied.
1021  *
1022  * Returns: the function should return %FALSE if the event source
1023  *          should be removed
1024  */
1025
1026
1027 /**
1028  * GIOFuncs:
1029  * @io_read: reads raw bytes from the channel.  This is called from
1030  *           various functions such as g_io_channel_read_chars() to
1031  *           read raw bytes from the channel.  Encoding and buffering
1032  *           issues are dealt with at a higher level.
1033  * @io_write: writes raw bytes to the channel.  This is called from
1034  *            various functions such as g_io_channel_write_chars() to
1035  *            write raw bytes to the channel.  Encoding and buffering
1036  *            issues are dealt with at a higher level.
1037  * @io_seek: &lpar;optional&rpar; seeks the channel.  This is called from
1038  *           g_io_channel_seek() on channels that support it.
1039  * @io_close: closes the channel.  This is called from
1040  *            g_io_channel_close() after flushing the buffers.
1041  * @io_create_watch: creates a watch on the channel.  This call
1042  *                   corresponds directly to g_io_create_watch().
1043  * @io_free: called from g_io_channel_unref() when the channel needs to
1044  *           be freed.  This function must free the memory associated
1045  *           with the channel, including freeing the #GIOChannel
1046  *           structure itself.  The channel buffers have been flushed
1047  *           and possibly @io_close has been called by the time this
1048  *           function is called.
1049  * @io_set_flags: sets the #GIOFlags on the channel.  This is called
1050  *                from g_io_channel_set_flags() with all flags except
1051  *                for %G_IO_FLAG_APPEND and %G_IO_FLAG_NONBLOCK masked
1052  *                out.
1053  * @io_get_flags: gets the #GIOFlags for the channel.  This function
1054  *                need only return the %G_IO_FLAG_APPEND and
1055  *                %G_IO_FLAG_NONBLOCK flags; g_io_channel_get_flags()
1056  *                automatically adds the others as appropriate.
1057  *
1058  * A table of functions used to handle different types of #GIOChannel
1059  * in a generic way.
1060  */
1061
1062
1063 /**
1064  * GIOStatus:
1065  * @G_IO_STATUS_ERROR: An error occurred.
1066  * @G_IO_STATUS_NORMAL: Success.
1067  * @G_IO_STATUS_EOF: End of file.
1068  * @G_IO_STATUS_AGAIN: Resource temporarily unavailable.
1069  *
1070  * Stati returned by most of the #GIOFuncs functions.
1071  */
1072
1073
1074 /**
1075  * GKeyFile:
1076  *
1077  * The GKeyFile struct contains only private data
1078  * and should not be accessed directly.
1079  */
1080
1081
1082 /**
1083  * GKeyFileError:
1084  * @G_KEY_FILE_ERROR_UNKNOWN_ENCODING: the text being parsed was in
1085  *     an unknown encoding
1086  * @G_KEY_FILE_ERROR_PARSE: document was ill-formed
1087  * @G_KEY_FILE_ERROR_NOT_FOUND: the file was not found
1088  * @G_KEY_FILE_ERROR_KEY_NOT_FOUND: a requested key was not found
1089  * @G_KEY_FILE_ERROR_GROUP_NOT_FOUND: a requested group was not found
1090  * @G_KEY_FILE_ERROR_INVALID_VALUE: a value could not be parsed
1091  *
1092  * Error codes returned by key file parsing.
1093  */
1094
1095
1096 /**
1097  * GKeyFileFlags:
1098  * @G_KEY_FILE_NONE: No flags, default behaviour
1099  * @G_KEY_FILE_KEEP_COMMENTS: Use this flag if you plan to write the
1100  *     (possibly modified) contents of the key file back to a file;
1101  *     otherwise all comments will be lost when the key file is
1102  *     written back.
1103  * @G_KEY_FILE_KEEP_TRANSLATIONS: Use this flag if you plan to write the
1104  *     (possibly modified) contents of the key file back to a file;
1105  *     otherwise only the translations for the current language will be
1106  *     written back.
1107  *
1108  * Flags which influence the parsing.
1109  */
1110
1111
1112 /**
1113  * GLIB_CHECK_VERSION:
1114  * @major: the major version to check for
1115  * @minor: the minor version to check for
1116  * @micro: the micro version to check for
1117  *
1118  * Checks the version of the GLib library that is being compiled
1119  * against.
1120  *
1121  * <example>
1122  * <title>Checking the version of the GLib library</title>
1123  * <programlisting>
1124  *   if (!GLIB_CHECK_VERSION (1, 2, 0))
1125  *     g_error ("GLib version 1.2.0 or above is needed");
1126  * </programlisting>
1127  * </example>
1128  *
1129  * See glib_check_version() for a runtime check.
1130  *
1131  * Returns: %TRUE if the version of the GLib header files
1132  * is the same as or newer than the passed-in version.
1133  */
1134
1135
1136 /**
1137  * GLIB_DISABLE_DEPRECATION_WARNINGS:
1138  *
1139  * A macro that should be defined before including the glib.h header.
1140  * If it is defined, no compiler warnings will be produced for uses
1141  * of deprecated GLib APIs.
1142  */
1143
1144
1145 /**
1146  * GLIB_MAJOR_VERSION:
1147  *
1148  * The major version number of the GLib library.
1149  *
1150  * Like #glib_major_version, but from the headers used at
1151  * application compile time, rather than from the library
1152  * linked against at application run time.
1153  */
1154
1155
1156 /**
1157  * GLIB_MICRO_VERSION:
1158  *
1159  * The micro version number of the GLib library.
1160  *
1161  * Like #gtk_micro_version, but from the headers used at
1162  * application compile time, rather than from the library
1163  * linked against at application run time.
1164  */
1165
1166
1167 /**
1168  * GLIB_MINOR_VERSION:
1169  *
1170  * The minor version number of the GLib library.
1171  *
1172  * Like #gtk_minor_version, but from the headers used at
1173  * application compile time, rather than from the library
1174  * linked against at application run time.
1175  */
1176
1177
1178 /**
1179  * GLONG_FROM_BE:
1180  * @val: a #glong value in big-endian byte order
1181  *
1182  * Converts a #glong value from big-endian to the host byte order.
1183  *
1184  * Returns: @val converted to host byte order
1185  */
1186
1187
1188 /**
1189  * GLONG_FROM_LE:
1190  * @val: a #glong value in little-endian byte order
1191  *
1192  * Converts a #glong value from little-endian to host byte order.
1193  *
1194  * Returns: @val converted to host byte order
1195  */
1196
1197
1198 /**
1199  * GLONG_TO_BE:
1200  * @val: a #glong value in host byte order
1201  *
1202  * Converts a #glong value from host byte order to big-endian.
1203  *
1204  * Returns: @val converted to big-endian byte order
1205  */
1206
1207
1208 /**
1209  * GLONG_TO_LE:
1210  * @val: a #glong value in host byte order
1211  *
1212  * Converts a #glong value from host byte order to little-endian.
1213  *
1214  * Returns: @val converted to little-endian
1215  */
1216
1217
1218 /**
1219  * GList:
1220  * @data: holds the element's data, which can be a pointer to any kind
1221  *        of data, or any integer value using the <link
1222  *        linkend="glib-Type-Conversion-Macros">Type Conversion
1223  *        Macros</link>.
1224  * @next: contains the link to the next element in the list.
1225  * @prev: contains the link to the previous element in the list.
1226  *
1227  * The #GList struct is used for each element in a doubly-linked list.
1228  */
1229
1230
1231 /**
1232  * GLogFunc:
1233  * @log_domain: the log domain of the message
1234  * @log_level: the log level of the message (including the
1235  *     fatal and recursion flags)
1236  * @message: the message to process
1237  * @user_data: user data, set in g_log_set_handler()
1238  *
1239  * Specifies the prototype of log handler functions.
1240  *
1241  * The default log handler, g_log_default_handler(), automatically appends a
1242  * new-line character to @message when printing it. It is advised that any
1243  * custom log handler functions behave similarly, so that logging calls in user
1244  * code do not need modifying to add a new-line character to the message if the
1245  * log handler is changed.
1246  */
1247
1248
1249 /**
1250  * GLogLevelFlags:
1251  * @G_LOG_FLAG_RECURSION: internal flag
1252  * @G_LOG_FLAG_FATAL: internal flag
1253  * @G_LOG_LEVEL_ERROR: log level for errors, see g_error().
1254  *     This level is also used for messages produced by g_assert().
1255  * @G_LOG_LEVEL_CRITICAL: log level for critical messages, see g_critical().
1256  *     This level is also used for messages produced by g_return_if_fail()
1257  *     and g_return_val_if_fail().
1258  * @G_LOG_LEVEL_WARNING: log level for warnings, see g_warning()
1259  * @G_LOG_LEVEL_MESSAGE: log level for messages, see g_message()
1260  * @G_LOG_LEVEL_INFO: log level for informational messages
1261  * @G_LOG_LEVEL_DEBUG: log level for debug messages, see g_debug()
1262  * @G_LOG_LEVEL_MASK: a mask including all log levels
1263  *
1264  * Flags specifying the level of log messages.
1265  *
1266  * It is possible to change how GLib treats messages of the various
1267  * levels using g_log_set_handler() and g_log_set_fatal_mask().
1268  */
1269
1270
1271 /**
1272  * GMappedFile:
1273  *
1274  * The #GMappedFile represents a file mapping created with
1275  * g_mapped_file_new(). It has only private members and should
1276  * not be accessed directly.
1277  */
1278
1279
1280 /**
1281  * GMarkupCollectType:
1282  * @G_MARKUP_COLLECT_INVALID: used to terminate the list of attributes
1283  *     to collect
1284  * @G_MARKUP_COLLECT_STRING: collect the string pointer directly from
1285  *     the attribute_values[] array. Expects a parameter of type (const
1286  *     char **). If %G_MARKUP_COLLECT_OPTIONAL is specified and the
1287  *     attribute isn't present then the pointer will be set to %NULL
1288  * @G_MARKUP_COLLECT_STRDUP: as with %G_MARKUP_COLLECT_STRING, but
1289  *     expects a parameter of type (char **) and g_strdup()s the
1290  *     returned pointer. The pointer must be freed with g_free()
1291  * @G_MARKUP_COLLECT_BOOLEAN: expects a parameter of type (gboolean *)
1292  *     and parses the attribute value as a boolean. Sets %FALSE if the
1293  *     attribute isn't present. Valid boolean values consist of
1294  *     (case-insensitive) "false", "f", "no", "n", "0" and "true", "t",
1295  *     "yes", "y", "1"
1296  * @G_MARKUP_COLLECT_TRISTATE: as with %G_MARKUP_COLLECT_BOOLEAN, but
1297  *     in the case of a missing attribute a value is set that compares
1298  *     equal to neither %FALSE nor %TRUE G_MARKUP_COLLECT_OPTIONAL is
1299  *     implied
1300  * @G_MARKUP_COLLECT_OPTIONAL: can be bitwise ORed with the other fields.
1301  *     If present, allows the attribute not to appear. A default value
1302  *     is set depending on what value type is used
1303  *
1304  * A mixed enumerated type and flags field. You must specify one type
1305  * (string, strdup, boolean, tristate).  Additionally, you may  optionally
1306  * bitwise OR the type with the flag %G_MARKUP_COLLECT_OPTIONAL.
1307  *
1308  * It is likely that this enum will be extended in the future to
1309  * support other types.
1310  */
1311
1312
1313 /**
1314  * GMutex:
1315  *
1316  * The #GMutex struct is an opaque data structure to represent a mutex
1317  * (mutual exclusion). It can be used to protect data against shared
1318  * access. Take for example the following function:
1319  *
1320  * <example>
1321  *  <title>A function which will not work in a threaded environment</title>
1322  *  <programlisting>
1323  *   int
1324  *   give_me_next_number (void)
1325  *   {
1326  *     static int current_number = 0;
1327  *
1328  *     /<!-- -->* now do a very complicated calculation to calculate the new
1329  *      * number, this might for example be a random number generator
1330  *      *<!-- -->/
1331  *     current_number = calc_next_number (current_number);
1332  *
1333  *     return current_number;
1334  *   }
1335  *  </programlisting>
1336  * </example>
1337  *
1338  * It is easy to see that this won't work in a multi-threaded
1339  * application. There current_number must be protected against shared
1340  * access. A #GMutex can be used as a solution to this problem:
1341  *
1342  * <example>
1343  *  <title>Using GMutex to protected a shared variable</title>
1344  *  <programlisting>
1345  *   int
1346  *   give_me_next_number (void)
1347  *   {
1348  *     static GMutex mutex;
1349  *     static int current_number = 0;
1350  *     int ret_val;
1351  *
1352  *     g_mutex_lock (&amp;mutex);
1353  *     ret_val = current_number = calc_next_number (current_number);
1354  *     g_mutex_unlock (&amp;mutex);
1355  *
1356  *     return ret_val;
1357  *   }
1358  *  </programlisting>
1359  * </example>
1360  *
1361  * Notice that the #GMutex is not initialised to any particular value.
1362  * Its placement in static storage ensures that it will be initialised
1363  * to all-zeros, which is appropriate.
1364  *
1365  * If a #GMutex is placed in other contexts (eg: embedded in a struct)
1366  * then it must be explicitly initialised using g_mutex_init().
1367  *
1368  * A #GMutex should only be accessed via <function>g_mutex_</function>
1369  * functions.
1370  */
1371
1372
1373 /**
1374  * GNode:
1375  * @data: contains the actual data of the node.
1376  * @next: points to the node's next sibling (a sibling is another
1377  *        #GNode with the same parent).
1378  * @prev: points to the node's previous sibling.
1379  * @parent: points to the parent of the #GNode, or is %NULL if the
1380  *          #GNode is the root of the tree.
1381  * @children: points to the first child of the #GNode.  The other
1382  *            children are accessed by using the @next pointer of each
1383  *            child.
1384  *
1385  * The #GNode struct represents one node in a
1386  * <link linkend="glib-N-ary-Trees">N-ary Tree</link>. fields
1387  */
1388
1389
1390 /**
1391  * GNodeForeachFunc:
1392  * @node: a #GNode.
1393  * @data: user data passed to g_node_children_foreach().
1394  *
1395  * Specifies the type of function passed to g_node_children_foreach().
1396  * The function is called with each child node, together with the user
1397  * data passed to g_node_children_foreach().
1398  */
1399
1400
1401 /**
1402  * GNodeTraverseFunc:
1403  * @node: a #GNode.
1404  * @data: user data passed to g_node_traverse().
1405  *
1406  * Specifies the type of function passed to g_node_traverse(). The
1407  * function is called with each of the nodes visited, together with the
1408  * user data passed to g_node_traverse(). If the function returns
1409  * %TRUE, then the traversal is stopped.
1410  *
1411  * Returns: %TRUE to stop the traversal.
1412  */
1413
1414
1415 /**
1416  * GOnce:
1417  * @status: the status of the #GOnce
1418  * @retval: the value returned by the call to the function, if @status
1419  *          is %G_ONCE_STATUS_READY
1420  *
1421  * A #GOnce struct controls a one-time initialization function. Any
1422  * one-time initialization function must have its own unique #GOnce
1423  * struct.
1424  *
1425  * Since: 2.4
1426  */
1427
1428
1429 /**
1430  * GOnceStatus:
1431  * @G_ONCE_STATUS_NOTCALLED: the function has not been called yet.
1432  * @G_ONCE_STATUS_PROGRESS: the function call is currently in progress.
1433  * @G_ONCE_STATUS_READY: the function has been called.
1434  *
1435  * The possible statuses of a one-time initialization function
1436  * controlled by a #GOnce struct.
1437  *
1438  * Since: 2.4
1439  */
1440
1441
1442 /**
1443  * GPOINTER_TO_INT:
1444  * @p: pointer containing an integer
1445  *
1446  * Extracts an integer from a pointer. The integer must have
1447  * been stored in the pointer with GINT_TO_POINTER().
1448  *
1449  * Remember, you may not store pointers in integers. This is not portable
1450  * in any way, shape or form. These macros <emphasis>only</emphasis> allow
1451  * storing integers in pointers, and only preserve 32 bits of the
1452  * integer; values outside the range of a 32-bit integer will be mangled.
1453  */
1454
1455
1456 /**
1457  * GPOINTER_TO_SIZE:
1458  * @p: pointer to extract a #gsize from
1459  *
1460  * Extracts a #gsize from a pointer. The #gsize must have
1461  * been stored in the pointer with GSIZE_TO_POINTER().
1462  */
1463
1464
1465 /**
1466  * GPOINTER_TO_UINT:
1467  * @p: pointer to extract an unsigned integer from
1468  *
1469  * Extracts an unsigned integer from a pointer. The integer must have
1470  * been stored in the pointer with GUINT_TO_POINTER().
1471  */
1472
1473
1474 /**
1475  * GPatternSpec:
1476  *
1477  * A <structname>GPatternSpec</structname> is the 'compiled' form of a
1478  * pattern. This structure is opaque and its fields cannot be accessed
1479  * directly.
1480  */
1481
1482
1483 /**
1484  * GPrivate:
1485  *
1486  * The #GPrivate struct is an opaque data structure to represent a
1487  * thread-local data key. It is approximately equivalent to the
1488  * pthread_setspecific()/pthread_getspecific() APIs on POSIX and to
1489  * TlsSetValue()/TlsGetValue() on Windows.
1490  *
1491  * If you don't already know why you might want this functionality,
1492  * then you probably don't need it.
1493  *
1494  * #GPrivate is a very limited resource (as far as 128 per program,
1495  * shared between all libraries). It is also not possible to destroy a
1496  * #GPrivate after it has been used. As such, it is only ever acceptable
1497  * to use #GPrivate in static scope, and even then sparingly so.
1498  *
1499  * See G_PRIVATE_INIT() for a couple of examples.
1500  *
1501  * The #GPrivate structure should be considered opaque.  It should only
1502  * be accessed via the <function>g_private_</function> functions.
1503  */
1504
1505
1506 /**
1507  * GPtrArray:
1508  * @pdata: points to the array of pointers, which may be moved when the
1509  *         array grows.
1510  * @len: number of pointers in the array.
1511  *
1512  * Contains the public fields of a pointer array.
1513  */
1514
1515
1516 /**
1517  * GQuark:
1518  *
1519  * A GQuark is a non-zero integer which uniquely identifies a
1520  * particular string. A GQuark value of zero is associated to %NULL.
1521  */
1522
1523
1524 /**
1525  * GRWLock:
1526  *
1527  * The GRWLock struct is an opaque data structure to represent a
1528  * reader-writer lock. It is similar to a #GMutex in that it allows
1529  * multiple threads to coordinate access to a shared resource.
1530  *
1531  * The difference to a mutex is that a reader-writer lock discriminates
1532  * between read-only ('reader') and full ('writer') access. While only
1533  * one thread at a time is allowed write access (by holding the 'writer'
1534  * lock via g_rw_lock_writer_lock()), multiple threads can gain
1535  * simultaneous read-only access (by holding the 'reader' lock via
1536  * g_rw_lock_reader_lock()).
1537  *
1538  * <example>
1539  *  <title>An array with access functions</title>
1540  *  <programlisting>
1541  *   GRWLock lock;
1542  *   GPtrArray *array;
1543  *
1544  *   gpointer
1545  *   my_array_get (guint index)
1546  *   {
1547  *     gpointer retval = NULL;
1548  *
1549  *     if (!array)
1550  *       return NULL;
1551  *
1552  *     g_rw_lock_reader_lock (&amp;lock);
1553  *     if (index &lt; array->len)
1554  *       retval = g_ptr_array_index (array, index);
1555  *     g_rw_lock_reader_unlock (&amp;lock);
1556  *
1557  *     return retval;
1558  *   }
1559  *
1560  *   void
1561  *   my_array_set (guint index, gpointer data)
1562  *   {
1563  *     g_rw_lock_writer_lock (&amp;lock);
1564  *
1565  *     if (!array)
1566  *       array = g_ptr_array_new (<!-- -->);
1567  *
1568  *     if (index >= array->len)
1569  *       g_ptr_array_set_size (array, index+1);
1570  *     g_ptr_array_index (array, index) = data;
1571  *
1572  *     g_rw_lock_writer_unlock (&amp;lock);
1573  *   }
1574  *  </programlisting>
1575  *  <para>
1576  *    This example shows an array which can be accessed by many readers
1577  *    (the <function>my_array_get()</function> function) simultaneously,
1578  *    whereas the writers (the <function>my_array_set()</function>
1579  *    function) will only be allowed once at a time and only if no readers
1580  *    currently access the array. This is because of the potentially
1581  *    dangerous resizing of the array. Using these functions is fully
1582  *    multi-thread safe now.
1583  *  </para>
1584  * </example>
1585  *
1586  * If a #GRWLock is allocated in static storage then it can be used
1587  * without initialisation.  Otherwise, you should call
1588  * g_rw_lock_init() on it and g_rw_lock_clear() when done.
1589  *
1590  * A GRWLock should only be accessed with the
1591  * <function>g_rw_lock_</function> functions.
1592  *
1593  * Since: 2.32
1594  */
1595
1596
1597 /**
1598  * GRand:
1599  *
1600  * The #GRand struct is an opaque data structure. It should only be
1601  * accessed through the <function>g_rand_*</function> functions.
1602  */
1603
1604
1605 /**
1606  * GRecMutex:
1607  *
1608  * The GRecMutex struct is an opaque data structure to represent a
1609  * recursive mutex. It is similar to a #GMutex with the difference
1610  * that it is possible to lock a GRecMutex multiple times in the same
1611  * thread without deadlock. When doing so, care has to be taken to
1612  * unlock the recursive mutex as often as it has been locked.
1613  *
1614  * If a #GRecMutex is allocated in static storage then it can be used
1615  * without initialisation.  Otherwise, you should call
1616  * g_rec_mutex_init() on it and g_rec_mutex_clear() when done.
1617  *
1618  * A GRecMutex should only be accessed with the
1619  * <function>g_rec_mutex_</function> functions.
1620  *
1621  * Since: 2.32
1622  */
1623
1624
1625 /**
1626  * GSIZE_FROM_BE:
1627  * @val: a #gsize value in big-endian byte order
1628  *
1629  * Converts a #gsize value from big-endian to the host byte order.
1630  *
1631  * Returns: @val converted to host byte order
1632  */
1633
1634
1635 /**
1636  * GSIZE_FROM_LE:
1637  * @val: a #gsize value in little-endian byte order
1638  *
1639  * Converts a #gsize value from little-endian to host byte order.
1640  *
1641  * Returns: @val converted to host byte order
1642  */
1643
1644
1645 /**
1646  * GSIZE_TO_BE:
1647  * @val: a #gsize value in host byte order
1648  *
1649  * Converts a #gsize value from host byte order to big-endian.
1650  *
1651  * Returns: @val converted to big-endian byte order
1652  */
1653
1654
1655 /**
1656  * GSIZE_TO_LE:
1657  * @val: a #gsize value in host byte order
1658  *
1659  * Converts a #gsize value from host byte order to little-endian.
1660  *
1661  * Returns: @val converted to little-endian
1662  */
1663
1664
1665 /**
1666  * GSIZE_TO_POINTER:
1667  * @s: #gsize to stuff into the pointer
1668  *
1669  * Stuffs a #gsize into a pointer type.
1670  */
1671
1672
1673 /**
1674  * GSList:
1675  * @data: holds the element's data, which can be a pointer to any kind
1676  *        of data, or any integer value using the <link
1677  *        linkend="glib-Type-Conversion-Macros">Type Conversion
1678  *        Macros</link>.
1679  * @next: contains the link to the next element in the list.
1680  *
1681  * The #GSList struct is used for each element in the singly-linked
1682  * list.
1683  */
1684
1685
1686 /**
1687  * GSSIZE_FROM_BE:
1688  * @val: a #gssize value in big-endian byte order
1689  *
1690  * Converts a #gssize value from big-endian to host byte order.
1691  *
1692  * Returns: @val converted to host byte order
1693  */
1694
1695
1696 /**
1697  * GSSIZE_FROM_LE:
1698  * @val: a #gssize value in little-endian byte order
1699  *
1700  * Converts a #gssize value from little-endian to host byte order.
1701  *
1702  * Returns: @val converted to host byte order
1703  */
1704
1705
1706 /**
1707  * GSSIZE_TO_BE:
1708  * @val: a #gssize value in host byte order
1709  *
1710  * Converts a #gssize value from host byte order to big-endian.
1711  *
1712  * Returns: @val converted to big-endian
1713  */
1714
1715
1716 /**
1717  * GSSIZE_TO_LE:
1718  * @val: a #gssize value in host byte order
1719  *
1720  * Converts a #gssize value from host byte order to little-endian.
1721  *
1722  * Returns: @val converted to little-endian
1723  */
1724
1725
1726 /**
1727  * GScanner:
1728  * @user_data: unused
1729  * @max_parse_errors: unused
1730  * @parse_errors: g_scanner_error() increments this field
1731  * @input_name: name of input stream, featured by the default message handler
1732  * @qdata: quarked data
1733  * @config: link into the scanner configuration
1734  * @token: token parsed by the last g_scanner_get_next_token()
1735  * @value: value of the last token from g_scanner_get_next_token()
1736  * @line: line number of the last token from g_scanner_get_next_token()
1737  * @position: char number of the last token from g_scanner_get_next_token()
1738  * @next_token: token parsed by the last g_scanner_peek_next_token()
1739  * @next_value: value of the last token from g_scanner_peek_next_token()
1740  * @next_line: line number of the last token from g_scanner_peek_next_token()
1741  * @next_position: char number of the last token from g_scanner_peek_next_token()
1742  * @msg_handler: handler function for _warn and _error
1743  *
1744  * The data structure representing a lexical scanner.
1745  *
1746  * You should set @input_name after creating the scanner, since
1747  * it is used by the default message handler when displaying
1748  * warnings and errors. If you are scanning a file, the filename
1749  * would be a good choice.
1750  *
1751  * The @user_data and @max_parse_errors fields are not used.
1752  * If you need to associate extra data with the scanner you
1753  * can place them here.
1754  *
1755  * If you want to use your own message handler you can set the
1756  * @msg_handler field. The type of the message handler function
1757  * is declared by #GScannerMsgFunc.
1758  */
1759
1760
1761 /**
1762  * GScannerConfig:
1763  * @cset_skip_characters: specifies which characters should be skipped
1764  *     by the scanner (the default is the whitespace characters: space,
1765  *     tab, carriage-return and line-feed).
1766  * @cset_identifier_first: specifies the characters which can start
1767  *     identifiers (the default is #G_CSET_a_2_z, "_", and #G_CSET_A_2_Z).
1768  * @cset_identifier_nth: specifies the characters which can be used
1769  *     in identifiers, after the first character (the default is
1770  *     #G_CSET_a_2_z, "_0123456789", #G_CSET_A_2_Z, #G_CSET_LATINS,
1771  *     #G_CSET_LATINC).
1772  * @cpair_comment_single: specifies the characters at the start and
1773  *     end of single-line comments. The default is "#\n" which means
1774  *     that single-line comments start with a '#' and continue until
1775  *     a '\n' (end of line).
1776  * @case_sensitive: specifies if symbols are case sensitive (the
1777  *     default is %FALSE).
1778  * @skip_comment_multi: specifies if multi-line comments are skipped
1779  *     and not returned as tokens (the default is %TRUE).
1780  * @skip_comment_single: specifies if single-line comments are skipped
1781  *     and not returned as tokens (the default is %TRUE).
1782  * @scan_comment_multi: specifies if multi-line comments are recognized
1783  *     (the default is %TRUE).
1784  * @scan_identifier: specifies if identifiers are recognized (the
1785  *     default is %TRUE).
1786  * @scan_identifier_1char: specifies if single-character
1787  *     identifiers are recognized (the default is %FALSE).
1788  * @scan_identifier_NULL: specifies if %NULL is reported as
1789  *     %G_TOKEN_IDENTIFIER_NULL (the default is %FALSE).
1790  * @scan_symbols: specifies if symbols are recognized (the default
1791  *     is %TRUE).
1792  * @scan_binary: specifies if binary numbers are recognized (the
1793  *     default is %FALSE).
1794  * @scan_octal: specifies if octal numbers are recognized (the
1795  *     default is %TRUE).
1796  * @scan_float: specifies if floating point numbers are recognized
1797  *     (the default is %TRUE).
1798  * @scan_hex: specifies if hexadecimal numbers are recognized (the
1799  *     default is %TRUE).
1800  * @scan_hex_dollar: specifies if '$' is recognized as a prefix for
1801  *     hexadecimal numbers (the default is %FALSE).
1802  * @scan_string_sq: specifies if strings can be enclosed in single
1803  *     quotes (the default is %TRUE).
1804  * @scan_string_dq: specifies if strings can be enclosed in double
1805  *     quotes (the default is %TRUE).
1806  * @numbers_2_int: specifies if binary, octal and hexadecimal numbers
1807  *     are reported as #G_TOKEN_INT (the default is %TRUE).
1808  * @int_2_float: specifies if all numbers are reported as %G_TOKEN_FLOAT
1809  *     (the default is %FALSE).
1810  * @identifier_2_string: specifies if identifiers are reported as strings
1811  *     (the default is %FALSE).
1812  * @char_2_token: specifies if characters are reported by setting
1813  *     <literal>token = ch</literal> or as %G_TOKEN_CHAR (the default
1814  *     is %TRUE).
1815  * @symbol_2_token: specifies if symbols are reported by setting
1816  *     <literal>token = v_symbol</literal> or as %G_TOKEN_SYMBOL (the
1817  *     default is %FALSE).
1818  * @scope_0_fallback: specifies if a symbol is searched for in the
1819  *     default scope in addition to the current scope (the default is %FALSE).
1820  * @store_int64: use value.v_int64 rather than v_int
1821  *
1822  * Specifies the #GScanner parser configuration. Most settings can
1823  * be changed during the parsing phase and will affect the lexical
1824  * parsing of the next unpeeked token.
1825  */
1826
1827
1828 /**
1829  * GScannerMsgFunc:
1830  * @scanner: a #GScanner
1831  * @message: the message
1832  * @error: %TRUE if the message signals an error,
1833  *     %FALSE if it signals a warning.
1834  *
1835  * Specifies the type of the message handler function.
1836  */
1837
1838
1839 /**
1840  * GSeekType:
1841  * @G_SEEK_CUR: the current position in the file.
1842  * @G_SEEK_SET: the start of the file.
1843  * @G_SEEK_END: the end of the file.
1844  *
1845  * An enumeration specifying the base position for a
1846  * g_io_channel_seek_position() operation.
1847  */
1848
1849
1850 /**
1851  * GSequence:
1852  *
1853  * The #GSequence struct is an opaque data type representing a
1854  * <link linkend="glib-Sequences">Sequence</link> data type.
1855  */
1856
1857
1858 /**
1859  * GSequenceIter:
1860  *
1861  * The #GSequenceIter struct is an opaque data type representing an
1862  * iterator pointing into a #GSequence.
1863  */
1864
1865
1866 /**
1867  * GSequenceIterCompareFunc:
1868  * @a: a #GSequenceIter
1869  * @b: a #GSequenceIter
1870  * @data: user data
1871  *
1872  * A #GSequenceIterCompareFunc is a function used to compare iterators.
1873  * It must return zero if the iterators compare equal, a negative value
1874  * if @a comes before @b, and a positive value if @b comes before @a.
1875  *
1876  * Returns: zero if the iterators are equal, a negative value if @a
1877  *          comes before @b, and a positive value if @b comes before
1878  *          @a.
1879  */
1880
1881
1882 /**
1883  * GShellError:
1884  * @G_SHELL_ERROR_BAD_QUOTING: Mismatched or otherwise mangled quoting.
1885  * @G_SHELL_ERROR_EMPTY_STRING: String to be parsed was empty.
1886  * @G_SHELL_ERROR_FAILED: Some other error.
1887  *
1888  * Error codes returned by shell functions.
1889  */
1890
1891
1892 /**
1893  * GStatBuf:
1894  *
1895  * A type corresponding to the appropriate struct type for the stat
1896  * system call, depending on the platform and/or compiler being used.
1897  *
1898  * See g_stat() for more information.
1899  */
1900
1901
1902 /**
1903  * GString:
1904  * @str: points to the character data. It may move as text is added.
1905  *   The @str field is null-terminated and so
1906  *   can be used as an ordinary C string.
1907  * @len: contains the length of the string, not including the
1908  *   terminating nul byte.
1909  * @allocated_len: the number of bytes that can be stored in the
1910  *   string before it needs to be reallocated. May be larger than @len.
1911  *
1912  * The GString struct contains the public fields of a GString.
1913  */
1914
1915
1916 /**
1917  * GStringChunk:
1918  *
1919  * An opaque data structure representing String Chunks.
1920  * It should only be accessed by using the following functions.
1921  */
1922
1923
1924 /**
1925  * GTestCase:
1926  *
1927  * An opaque structure representing a test case.
1928  */
1929
1930
1931 /**
1932  * GTestDataFunc:
1933  * @user_data: the data provided when registering the test
1934  *
1935  * The type used for test case functions that take an extra pointer
1936  * argument.
1937  *
1938  * Since: 2.28
1939  */
1940
1941
1942 /**
1943  * GTestFileType:
1944  * @G_TEST_DIST: a file that was included in the distribution tarball
1945  * @G_TEST_BUILT: a file that was built on the compiling machine
1946  *
1947  * The type of file to return the filename for, when used with
1948  * g_test_build_filename().
1949  *
1950  * These two options correspond rather directly to the 'dist' and
1951  * 'built' terminology that automake uses and are explicitly used to
1952  * distinguish between the 'srcdir' and 'builddir' being separate.  All
1953  * files in your project should either be dist (in the
1954  * <literal>DIST_EXTRA</literal> or <literal>dist_schema_DATA</literal>
1955  * sense, in which case they will always be in the srcdir) or built (in
1956  * the <literal>BUILT_SOURCES</literal> sense, in which case they will
1957  * always be in the builddir).
1958  *
1959  * Note: as a general rule of automake, files that are generated only as
1960  * part of the build-from-git process (but then are distributed with the
1961  * tarball) always go in srcdir (even if doing a srcdir != builddir
1962  * build from git) and are considered as distributed files.
1963  *
1964  * Since: 2.38
1965  */
1966
1967
1968 /**
1969  * GTestFixtureFunc:
1970  * @fixture: the test fixture
1971  * @user_data: the data provided when registering the test
1972  *
1973  * The type used for functions that operate on test fixtures.  This is
1974  * used for the fixture setup and teardown functions as well as for the
1975  * testcases themselves.
1976  *
1977  * @user_data is a pointer to the data that was given when registering
1978  * the test case.
1979  *
1980  * @fixture will be a pointer to the area of memory allocated by the
1981  * test framework, of the size requested.  If the requested size was
1982  * zero then @fixture will be equal to @user_data.
1983  *
1984  * Since: 2.28
1985  */
1986
1987
1988 /**
1989  * GTestFunc:
1990  *
1991  * The type used for test case functions.
1992  *
1993  * Since: 2.28
1994  */
1995
1996
1997 /**
1998  * GTestSubprocessFlags:
1999  * @G_TEST_SUBPROCESS_INHERIT_STDIN: If this flag is given, the child
2000  *     process will inherit the parent's stdin. Otherwise, the child's
2001  *     stdin is redirected to <filename>/dev/null</filename>.
2002  * @G_TEST_SUBPROCESS_INHERIT_STDOUT: If this flag is given, the child
2003  *     process will inherit the parent's stdout. Otherwise, the child's
2004  *     stdout will not be visible, but it will be captured to allow
2005  *     later tests with g_test_trap_assert_stdout().
2006  * @G_TEST_SUBPROCESS_INHERIT_STDERR: If this flag is given, the child
2007  *     process will inherit the parent's stderr. Otherwise, the child's
2008  *     stderr will not be visible, but it will be captured to allow
2009  *     later tests with g_test_trap_assert_stderr().
2010  *
2011  * Flags to pass to g_test_trap_subprocess() to control input and output.
2012  *
2013  * Note that in contrast with g_test_trap_fork(), the default is to
2014  * not show stdout and stderr.
2015  */
2016
2017
2018 /**
2019  * GTestSuite:
2020  *
2021  * An opaque structure representing a test suite.
2022  */
2023
2024
2025 /**
2026  * GTestTrapFlags:
2027  * @G_TEST_TRAP_SILENCE_STDOUT: Redirect stdout of the test child to
2028  *     <filename>/dev/null</filename> so it cannot be observed on the
2029  *     console during test runs. The actual output is still captured
2030  *     though to allow later tests with g_test_trap_assert_stdout().
2031  * @G_TEST_TRAP_SILENCE_STDERR: Redirect stderr of the test child to
2032  *     <filename>/dev/null</filename> so it cannot be observed on the
2033  *     console during test runs. The actual output is still captured
2034  *     though to allow later tests with g_test_trap_assert_stderr().
2035  * @G_TEST_TRAP_INHERIT_STDIN: If this flag is given, stdin of the
2036  *     child process is shared with stdin of its parent process.
2037  *     It is redirected to <filename>/dev/null</filename> otherwise.
2038  *
2039  * Test traps are guards around forked tests.
2040  * These flags determine what traps to set.
2041  *
2042  * Deprecated: #GTestTrapFlags is used only with g_test_trap_fork(),
2043  * which is deprecated. g_test_trap_subprocess() uses
2044  * #GTestTrapSubprocessFlags.
2045  */
2046
2047
2048 /**
2049  * GThread:
2050  *
2051  * The #GThread struct represents a running thread. This struct
2052  * is returned by g_thread_new() or g_thread_try_new(). You can
2053  * obtain the #GThread struct representing the current thead by
2054  * calling g_thread_self().
2055  *
2056  * GThread is refcounted, see g_thread_ref() and g_thread_unref().
2057  * The thread represented by it holds a reference while it is running,
2058  * and g_thread_join() consumes the reference that it is given, so
2059  * it is normally not necessary to manage GThread references
2060  * explicitly.
2061  *
2062  * The structure is opaque -- none of its fields may be directly
2063  * accessed.
2064  */
2065
2066
2067 /**
2068  * GThreadError:
2069  * @G_THREAD_ERROR_AGAIN: a thread couldn't be created due to resource
2070  *                        shortage. Try again later.
2071  *
2072  * Possible errors of thread related functions.
2073  */
2074
2075
2076 /**
2077  * GThreadFunc:
2078  * @data: data passed to the thread
2079  *
2080  * Specifies the type of the @func functions passed to g_thread_new()
2081  * or g_thread_try_new().
2082  *
2083  * Returns: the return value of the thread
2084  */
2085
2086
2087 /**
2088  * GThreadPool:
2089  * @func: the function to execute in the threads of this pool
2090  * @user_data: the user data for the threads of this pool
2091  * @exclusive: are all threads exclusive to this pool
2092  *
2093  * The #GThreadPool struct represents a thread pool. It has three
2094  * public read-only members, but the underlying struct is bigger,
2095  * so you must not copy this struct.
2096  */
2097
2098
2099 /**
2100  * GTime:
2101  *
2102  * Simply a replacement for <type>time_t</type>. It has been deprecated
2103  * since it is <emphasis>not</emphasis> equivalent to <type>time_t</type>
2104  * on 64-bit platforms with a 64-bit <type>time_t</type>.
2105  * Unrelated to #GTimer.
2106  *
2107  * Note that <type>GTime</type> is defined to always be a 32bit integer,
2108  * unlike <type>time_t</type> which may be 64bit on some systems.
2109  * Therefore, <type>GTime</type> will overflow in the year 2038, and
2110  * you cannot use the address of a <type>GTime</type> variable as argument
2111  * to the UNIX time() function. Instead, do the following:
2112  * |[
2113  * time_t ttime;
2114  * GTime gtime;
2115  *
2116  * time (&amp;ttime);
2117  * gtime = (GTime)ttime;
2118  * ]|
2119  */
2120
2121
2122 /**
2123  * GTimeVal:
2124  * @tv_sec: seconds
2125  * @tv_usec: microseconds
2126  *
2127  * Represents a precise time, with seconds and microseconds.
2128  * Similar to the <structname>struct timeval</structname> returned by
2129  * the gettimeofday() UNIX system call.
2130  *
2131  * GLib is attempting to unify around the use of 64bit integers to
2132  * represent microsecond-precision time. As such, this type will be
2133  * removed from a future version of GLib.
2134  */
2135
2136
2137 /**
2138  * GTimeZone:
2139  *
2140  * #GTimeZone is an opaque structure whose members cannot be accessed
2141  * directly.
2142  *
2143  * Since: 2.26
2144  */
2145
2146
2147 /**
2148  * GTimer:
2149  *
2150  * Opaque datatype that records a start time.
2151  */
2152
2153
2154 /**
2155  * GTokenType:
2156  * @G_TOKEN_EOF: the end of the file
2157  * @G_TOKEN_LEFT_PAREN: a '(' character
2158  * @G_TOKEN_LEFT_CURLY: a '{' character
2159  * @G_TOKEN_LEFT_BRACE: a '[' character
2160  * @G_TOKEN_RIGHT_CURLY: a '}' character
2161  * @G_TOKEN_RIGHT_PAREN: a ')' character
2162  * @G_TOKEN_RIGHT_BRACE: a ']' character
2163  * @G_TOKEN_EQUAL_SIGN: a '=' character
2164  * @G_TOKEN_COMMA: a ',' character
2165  * @G_TOKEN_NONE: not a token
2166  * @G_TOKEN_ERROR: an error occurred
2167  * @G_TOKEN_CHAR: a character
2168  * @G_TOKEN_BINARY: a binary integer
2169  * @G_TOKEN_OCTAL: an octal integer
2170  * @G_TOKEN_INT: an integer
2171  * @G_TOKEN_HEX: a hex integer
2172  * @G_TOKEN_FLOAT: a floating point number
2173  * @G_TOKEN_STRING: a string
2174  * @G_TOKEN_SYMBOL: a symbol
2175  * @G_TOKEN_IDENTIFIER: an identifier
2176  * @G_TOKEN_IDENTIFIER_NULL: a null identifier
2177  * @G_TOKEN_COMMENT_SINGLE: one line comment
2178  * @G_TOKEN_COMMENT_MULTI: multi line comment
2179  *
2180  * The possible types of token returned from each
2181  * g_scanner_get_next_token() call.
2182  */
2183
2184
2185 /**
2186  * GTokenValue:
2187  * @v_symbol: token symbol value
2188  * @v_identifier: token identifier value
2189  * @v_binary: token binary integer value
2190  * @v_octal: octal integer value
2191  * @v_int: integer value
2192  * @v_int64: 64-bit integer value
2193  * @v_float: floating point value
2194  * @v_hex: hex integer value
2195  * @v_string: string value
2196  * @v_comment: comment value
2197  * @v_char: character value
2198  * @v_error: error value
2199  *
2200  * A union holding the value of the token.
2201  */
2202
2203
2204 /**
2205  * GTrashStack:
2206  * @next: pointer to the previous element of the stack,
2207  *     gets stored in the first <literal>sizeof (gpointer)</literal>
2208  *     bytes of the element
2209  *
2210  * Each piece of memory that is pushed onto the stack
2211  * is cast to a <structname>GTrashStack*</structname>.
2212  */
2213
2214
2215 /**
2216  * GTraverseFlags:
2217  * @G_TRAVERSE_LEAVES: only leaf nodes should be visited. This name has
2218  *                     been introduced in 2.6, for older version use
2219  *                     %G_TRAVERSE_LEAFS.
2220  * @G_TRAVERSE_NON_LEAVES: only non-leaf nodes should be visited. This
2221  *                         name has been introduced in 2.6, for older
2222  *                         version use %G_TRAVERSE_NON_LEAFS.
2223  * @G_TRAVERSE_ALL: all nodes should be visited.
2224  * @G_TRAVERSE_MASK: a mask of all traverse flags.
2225  * @G_TRAVERSE_LEAFS: identical to %G_TRAVERSE_LEAVES.
2226  * @G_TRAVERSE_NON_LEAFS: identical to %G_TRAVERSE_NON_LEAVES.
2227  *
2228  * Specifies which nodes are visited during several of the tree
2229  * functions, including g_node_traverse() and g_node_find().
2230  */
2231
2232
2233 /**
2234  * GTraverseFunc:
2235  * @key: a key of a #GTree node.
2236  * @value: the value corresponding to the key.
2237  * @data: user data passed to g_tree_traverse().
2238  *
2239  * Specifies the type of function passed to g_tree_traverse(). It is
2240  * passed the key and value of each node, together with the @user_data
2241  * parameter passed to g_tree_traverse(). If the function returns
2242  * %TRUE, the traversal is stopped.
2243  *
2244  * Returns: %TRUE to stop the traversal.
2245  */
2246
2247
2248 /**
2249  * GTraverseType:
2250  * @G_IN_ORDER: vists a node's left child first, then the node itself,
2251  *              then its right child. This is the one to use if you
2252  *              want the output sorted according to the compare
2253  *              function.
2254  * @G_PRE_ORDER: visits a node, then its children.
2255  * @G_POST_ORDER: visits the node's children, then the node itself.
2256  * @G_LEVEL_ORDER: is not implemented for <link
2257  *                 linkend="glib-Balanced-Binary-Trees">Balanced Binary
2258  *                 Trees</link>.  For <link
2259  *                 linkend="glib-N-ary-Trees">N-ary Trees</link>, it
2260  *                 vists the root node first, then its children, then
2261  *                 its grandchildren, and so on. Note that this is less
2262  *                 efficient than the other orders.
2263  *
2264  * Specifies the type of traveral performed by g_tree_traverse(),
2265  * g_node_traverse() and g_node_find().
2266  */
2267
2268
2269 /**
2270  * GTree:
2271  *
2272  * The <structname>GTree</structname> struct is an opaque data
2273  * structure representing a <link
2274  * linkend="glib-Balanced-Binary-Trees">Balanced Binary Tree</link>. It
2275  * should be accessed only by using the following functions.
2276  */
2277
2278
2279 /**
2280  * GUINT16_FROM_BE:
2281  * @val: a #guint16 value in big-endian byte order
2282  *
2283  * Converts a #guint16 value from big-endian to host byte order.
2284  *
2285  * Returns: @val converted to host byte order
2286  */
2287
2288
2289 /**
2290  * GUINT16_FROM_LE:
2291  * @val: a #guint16 value in little-endian byte order
2292  *
2293  * Converts a #guint16 value from little-endian to host byte order.
2294  *
2295  * Returns: @val converted to host byte order
2296  */
2297
2298
2299 /**
2300  * GUINT16_SWAP_BE_PDP:
2301  * @val: a #guint16 value in big-endian or pdp-endian byte order
2302  *
2303  * Converts a #guint16 value between big-endian and pdp-endian byte order.
2304  * The conversion is symmetric so it can be used both ways.
2305  *
2306  * Returns: @val converted to the opposite byte order
2307  */
2308
2309
2310 /**
2311  * GUINT16_SWAP_LE_BE:
2312  * @val: a #guint16 value in little-endian or big-endian byte order
2313  *
2314  * Converts a #guint16 value between little-endian and big-endian byte order.
2315  * The conversion is symmetric so it can be used both ways.
2316  *
2317  * Returns: @val converted to the opposite byte order
2318  */
2319
2320
2321 /**
2322  * GUINT16_SWAP_LE_PDP:
2323  * @val: a #guint16 value in little-endian or pdp-endian byte order
2324  *
2325  * Converts a #guint16 value between little-endian and pdp-endian byte order.
2326  * The conversion is symmetric so it can be used both ways.
2327  *
2328  * Returns: @val converted to the opposite byte order
2329  */
2330
2331
2332 /**
2333  * GUINT16_TO_BE:
2334  * @val: a #guint16 value in host byte order
2335  *
2336  * Converts a #guint16 value from host byte order to big-endian.
2337  *
2338  * Returns: @val converted to big-endian
2339  */
2340
2341
2342 /**
2343  * GUINT16_TO_LE:
2344  * @val: a #guint16 value in host byte order
2345  *
2346  * Converts a #guint16 value from host byte order to little-endian.
2347  *
2348  * Returns: @val converted to little-endian
2349  */
2350
2351
2352 /**
2353  * GUINT32_FROM_BE:
2354  * @val: a #guint32 value in big-endian byte order
2355  *
2356  * Converts a #guint32 value from big-endian to host byte order.
2357  *
2358  * Returns: @val converted to host byte order
2359  */
2360
2361
2362 /**
2363  * GUINT32_FROM_LE:
2364  * @val: a #guint32 value in little-endian byte order
2365  *
2366  * Converts a #guint32 value from little-endian to host byte order.
2367  *
2368  * Returns: @val converted to host byte order
2369  */
2370
2371
2372 /**
2373  * GUINT32_SWAP_BE_PDP:
2374  * @val: a #guint32 value in big-endian or pdp-endian byte order
2375  *
2376  * Converts a #guint32 value between big-endian and pdp-endian byte order.
2377  * The conversion is symmetric so it can be used both ways.
2378  *
2379  * Returns: @val converted to the opposite byte order
2380  */
2381
2382
2383 /**
2384  * GUINT32_SWAP_LE_BE:
2385  * @val: a #guint32 value in little-endian or big-endian byte order
2386  *
2387  * Converts a #guint32 value between little-endian and big-endian byte order.
2388  * The conversion is symmetric so it can be used both ways.
2389  *
2390  * Returns: @val converted to the opposite byte order
2391  */
2392
2393
2394 /**
2395  * GUINT32_SWAP_LE_PDP:
2396  * @val: a #guint32 value in little-endian or pdp-endian byte order
2397  *
2398  * Converts a #guint32 value between little-endian and pdp-endian byte order.
2399  * The conversion is symmetric so it can be used both ways.
2400  *
2401  * Returns: @val converted to the opposite byte order
2402  */
2403
2404
2405 /**
2406  * GUINT32_TO_BE:
2407  * @val: a #guint32 value in host byte order
2408  *
2409  * Converts a #guint32 value from host byte order to big-endian.
2410  *
2411  * Returns: @val converted to big-endian
2412  */
2413
2414
2415 /**
2416  * GUINT32_TO_LE:
2417  * @val: a #guint32 value in host byte order
2418  *
2419  * Converts a #guint32 value from host byte order to little-endian.
2420  *
2421  * Returns: @val converted to little-endian
2422  */
2423
2424
2425 /**
2426  * GUINT64_FROM_BE:
2427  * @val: a #guint64 value in big-endian byte order
2428  *
2429  * Converts a #guint64 value from big-endian to host byte order.
2430  *
2431  * Returns: @val converted to host byte order
2432  */
2433
2434
2435 /**
2436  * GUINT64_FROM_LE:
2437  * @val: a #guint64 value in little-endian byte order
2438  *
2439  * Converts a #guint64 value from little-endian to host byte order.
2440  *
2441  * Returns: @val converted to host byte order
2442  */
2443
2444
2445 /**
2446  * GUINT64_SWAP_LE_BE:
2447  * @val: a #guint64 value in little-endian or big-endian byte order
2448  *
2449  * Converts a #guint64 value between little-endian and big-endian byte order.
2450  * The conversion is symmetric so it can be used both ways.
2451  *
2452  * Returns: @val converted to the opposite byte order
2453  */
2454
2455
2456 /**
2457  * GUINT64_TO_BE:
2458  * @val: a #guint64 value in host byte order
2459  *
2460  * Converts a #guint64 value from host byte order to big-endian.
2461  *
2462  * Returns: @val converted to big-endian
2463  */
2464
2465
2466 /**
2467  * GUINT64_TO_LE:
2468  * @val: a #guint64 value in host byte order
2469  *
2470  * Converts a #guint64 value from host byte order to little-endian.
2471  *
2472  * Returns: @val converted to little-endian
2473  */
2474
2475
2476 /**
2477  * GUINT_FROM_BE:
2478  * @val: a #guint value in big-endian byte order
2479  *
2480  * Converts a #guint value from big-endian to host byte order.
2481  *
2482  * Returns: @val converted to host byte order
2483  */
2484
2485
2486 /**
2487  * GUINT_FROM_LE:
2488  * @val: a #guint value in little-endian byte order
2489  *
2490  * Converts a #guint value from little-endian to host byte order.
2491  *
2492  * Returns: @val converted to host byte order
2493  */
2494
2495
2496 /**
2497  * GUINT_TO_BE:
2498  * @val: a #guint value in host byte order
2499  *
2500  * Converts a #guint value from host byte order to big-endian.
2501  *
2502  * Returns: @val converted to big-endian byte order
2503  */
2504
2505
2506 /**
2507  * GUINT_TO_LE:
2508  * @val: a #guint value in host byte order
2509  *
2510  * Converts a #guint value from host byte order to little-endian.
2511  *
2512  * Returns: @val converted to little-endian byte order.
2513  */
2514
2515
2516 /**
2517  * GUINT_TO_POINTER:
2518  * @u: unsigned integer to stuff into the pointer
2519  *
2520  * Stuffs an unsigned integer into a pointer type.
2521  */
2522
2523
2524 /**
2525  * GULONG_FROM_BE:
2526  * @val: a #gulong value in big-endian byte order
2527  *
2528  * Converts a #gulong value from big-endian to host byte order.
2529  *
2530  * Returns: @val converted to host byte order
2531  */
2532
2533
2534 /**
2535  * GULONG_FROM_LE:
2536  * @val: a #gulong value in little-endian byte order
2537  *
2538  * Converts a #gulong value from little-endian to host byte order.
2539  *
2540  * Returns: @val converted to host byte order
2541  */
2542
2543
2544 /**
2545  * GULONG_TO_BE:
2546  * @val: a #gulong value in host byte order
2547  *
2548  * Converts a #gulong value from host byte order to big-endian.
2549  *
2550  * Returns: @val converted to big-endian
2551  */
2552
2553
2554 /**
2555  * GULONG_TO_LE:
2556  * @val: a #gulong value in host byte order
2557  *
2558  * Converts a #gulong value from host byte order to little-endian.
2559  *
2560  * Returns: @val converted to little-endian
2561  */
2562
2563
2564 /**
2565  * GVariant:
2566  *
2567  * #GVariant is an opaque data structure and can only be accessed
2568  * using the following functions.
2569  *
2570  * Since: 2.24
2571  */
2572
2573
2574 /**
2575  * GVariantBuilder:
2576  *
2577  * A utility type for constructing container-type #GVariant instances.
2578  *
2579  * This is an opaque structure and may only be accessed using the
2580  * following functions.
2581  *
2582  * #GVariantBuilder is not threadsafe in any way.  Do not attempt to
2583  * access it from more than one thread.
2584  */
2585
2586
2587 /**
2588  * GVariantClass:
2589  * @G_VARIANT_CLASS_BOOLEAN: The #GVariant is a boolean.
2590  * @G_VARIANT_CLASS_BYTE: The #GVariant is a byte.
2591  * @G_VARIANT_CLASS_INT16: The #GVariant is a signed 16 bit integer.
2592  * @G_VARIANT_CLASS_UINT16: The #GVariant is an unsigned 16 bit integer.
2593  * @G_VARIANT_CLASS_INT32: The #GVariant is a signed 32 bit integer.
2594  * @G_VARIANT_CLASS_UINT32: The #GVariant is an unsigned 32 bit integer.
2595  * @G_VARIANT_CLASS_INT64: The #GVariant is a signed 64 bit integer.
2596  * @G_VARIANT_CLASS_UINT64: The #GVariant is an unsigned 64 bit integer.
2597  * @G_VARIANT_CLASS_HANDLE: The #GVariant is a file handle index.
2598  * @G_VARIANT_CLASS_DOUBLE: The #GVariant is a double precision floating
2599  *                          point value.
2600  * @G_VARIANT_CLASS_STRING: The #GVariant is a normal string.
2601  * @G_VARIANT_CLASS_OBJECT_PATH: The #GVariant is a D-Bus object path
2602  *                               string.
2603  * @G_VARIANT_CLASS_SIGNATURE: The #GVariant is a D-Bus signature string.
2604  * @G_VARIANT_CLASS_VARIANT: The #GVariant is a variant.
2605  * @G_VARIANT_CLASS_MAYBE: The #GVariant is a maybe-typed value.
2606  * @G_VARIANT_CLASS_ARRAY: The #GVariant is an array.
2607  * @G_VARIANT_CLASS_TUPLE: The #GVariant is a tuple.
2608  * @G_VARIANT_CLASS_DICT_ENTRY: The #GVariant is a dictionary entry.
2609  *
2610  * The range of possible top-level types of #GVariant instances.
2611  *
2612  * Since: 2.24
2613  */
2614
2615
2616 /**
2617  * GVariantIter: (skip)
2618  *
2619  * #GVariantIter is an opaque data structure and can only be accessed
2620  * using the following functions.
2621  */
2622
2623
2624 /**
2625  * GVariantParseError:
2626  * @G_VARIANT_PARSE_ERROR_FAILED: generic error (unused)
2627  * @G_VARIANT_PARSE_ERROR_BASIC_TYPE_EXPECTED: a non-basic #GVariantType was given where a basic type was expected
2628  * @G_VARIANT_PARSE_ERROR_CANNOT_INFER_TYPE: cannot infer the #GVariantType
2629  * @G_VARIANT_PARSE_ERROR_DEFINITE_TYPE_EXPECTED: an indefinite #GVariantType was given where a definite type was expected
2630  * @G_VARIANT_PARSE_ERROR_INPUT_NOT_AT_END: extra data after parsing finished
2631  * @G_VARIANT_PARSE_ERROR_INVALID_CHARACTER: invalid character in number or unicode escape
2632  * @G_VARIANT_PARSE_ERROR_INVALID_FORMAT_STRING: not a valid #GVariant format string
2633  * @G_VARIANT_PARSE_ERROR_INVALID_OBJECT_PATH: not a valid object path
2634  * @G_VARIANT_PARSE_ERROR_INVALID_SIGNATURE: not a valid type signature
2635  * @G_VARIANT_PARSE_ERROR_INVALID_TYPE_STRING: not a valid #GVariant type string
2636  * @G_VARIANT_PARSE_ERROR_NO_COMMON_TYPE: could not find a common type for array entries
2637  * @G_VARIANT_PARSE_ERROR_NUMBER_OUT_OF_RANGE: the numerical value is out of range of the given type
2638  * @G_VARIANT_PARSE_ERROR_NUMBER_TOO_BIG: the numerical value is out of range for any type
2639  * @G_VARIANT_PARSE_ERROR_TYPE_ERROR: cannot parse as variant of the specified type
2640  * @G_VARIANT_PARSE_ERROR_UNEXPECTED_TOKEN: an unexpected token was encountered
2641  * @G_VARIANT_PARSE_ERROR_UNKNOWN_KEYWORD: an unknown keyword was encountered
2642  * @G_VARIANT_PARSE_ERROR_UNTERMINATED_STRING_CONSTANT: unterminated string constant
2643  * @G_VARIANT_PARSE_ERROR_VALUE_EXPECTED: no value given
2644  *
2645  * Error codes returned by parsing text-format GVariants.
2646  */
2647
2648
2649 /**
2650  * G_ASCII_DTOSTR_BUF_SIZE:
2651  *
2652  * A good size for a buffer to be passed into g_ascii_dtostr().
2653  * It is guaranteed to be enough for all output of that function
2654  * on systems with 64bit IEEE-compatible doubles.
2655  *
2656  * The typical usage would be something like:
2657  * |[
2658  *   char buf[G_ASCII_DTOSTR_BUF_SIZE];
2659  *
2660  *   fprintf (out, "value=&percnt;s\n", g_ascii_dtostr (buf, sizeof (buf), value));
2661  * ]|
2662  */
2663
2664
2665 /**
2666  * G_ATOMIC_LOCK_FREE:
2667  *
2668  * This macro is defined if the atomic operations of GLib are
2669  * implemented using real hardware atomic operations.  This means that
2670  * the GLib atomic API can be used between processes and safely mixed
2671  * with other (hardware) atomic APIs.
2672  *
2673  * If this macro is not defined, the atomic operations may be
2674  * emulated using a mutex.  In that case, the GLib atomic operations are
2675  * only atomic relative to themselves and within a single process.
2676  */
2677
2678
2679 /**
2680  * G_BEGIN_DECLS:
2681  *
2682  * Used (along with #G_END_DECLS) to bracket header files. If the
2683  * compiler in use is a C++ compiler, adds <literal>extern "C"</literal>
2684  * around the header.
2685  */
2686
2687
2688 /**
2689  * G_BIG_ENDIAN:
2690  *
2691  * Specifies one of the possible types of byte order.
2692  * See #G_BYTE_ORDER.
2693  */
2694
2695
2696 /**
2697  * G_BYTE_ORDER:
2698  *
2699  * The host byte order.
2700  * This can be either #G_LITTLE_ENDIAN or #G_BIG_ENDIAN (support for
2701  * #G_PDP_ENDIAN may be added in future.)
2702  */
2703
2704
2705 /**
2706  * G_CONST_RETURN:
2707  *
2708  * If <literal>G_DISABLE_CONST_RETURNS</literal> is defined, this macro expands
2709  * to nothing. By default, the macro expands to <literal>const</literal>.
2710  * The macro should be used in place of <literal>const</literal> for
2711  * functions that return a value that should not be modified. The
2712  * purpose of this macro is to allow us to turn on <literal>const</literal>
2713  * for returned constant strings by default, while allowing programmers
2714  * who find that annoying to turn it off. This macro should only be used
2715  * for return values and for <emphasis>out</emphasis> parameters, it doesn't
2716  * make sense for <emphasis>in</emphasis> parameters.
2717  *
2718  * Deprecated: 2.30: API providers should replace all existing uses with
2719  *     <literal>const</literal> and API consumers should adjust their code
2720  *     accordingly
2721  */
2722
2723
2724 /**
2725  * G_CSET_A_2_Z:
2726  *
2727  * The set of uppercase ASCII alphabet characters.
2728  * Used for specifying valid identifier characters
2729  * in #GScannerConfig.
2730  */
2731
2732
2733 /**
2734  * G_CSET_LATINC:
2735  *
2736  * The set of uppercase ISO 8859-1 alphabet characters
2737  * which are not ASCII characters.
2738  * Used for specifying valid identifier characters
2739  * in #GScannerConfig.
2740  */
2741
2742
2743 /**
2744  * G_CSET_LATINS:
2745  *
2746  * The set of lowercase ISO 8859-1 alphabet characters
2747  * which are not ASCII characters.
2748  * Used for specifying valid identifier characters
2749  * in #GScannerConfig.
2750  */
2751
2752
2753 /**
2754  * G_CSET_a_2_z:
2755  *
2756  * The set of lowercase ASCII alphabet characters.
2757  * Used for specifying valid identifier characters
2758  * in #GScannerConfig.
2759  */
2760
2761
2762 /**
2763  * G_DATE_BAD_DAY:
2764  *
2765  * Represents an invalid #GDateDay.
2766  */
2767
2768
2769 /**
2770  * G_DATE_BAD_JULIAN:
2771  *
2772  * Represents an invalid Julian day number.
2773  */
2774
2775
2776 /**
2777  * G_DATE_BAD_YEAR:
2778  *
2779  * Represents an invalid year.
2780  */
2781
2782
2783 /**
2784  * G_DEFINE_QUARK:
2785  * @QN: the name to return a #GQuark for
2786  * @q_n: prefix for the function name
2787  *
2788  * A convenience macro which defines a function returning the
2789  * #GQuark for the name @QN. The function will be named
2790  * @q_n<!-- -->_quark().
2791  * Note that the quark name will be stringified automatically in the
2792  * macro, so you shouldn't use double quotes.
2793  *
2794  * Since: 2.34
2795  */
2796
2797
2798 /**
2799  * G_DEPRECATED:
2800  *
2801  * This macro is similar to %G_GNUC_DEPRECATED, and can be used to mark
2802  * functions declarations as deprecated. Unlike %G_GNUC_DEPRECATED, it is
2803  * meant to be portable across different compilers and must be placed
2804  * before the function declaration.
2805  *
2806  * Since: 2.32
2807  */
2808
2809
2810 /**
2811  * G_DEPRECATED_FOR:
2812  * @f: the name of the function that this function was deprecated for
2813  *
2814  * This macro is similar to %G_GNUC_DEPRECATED_FOR, and can be used to mark
2815  * functions declarations as deprecated. Unlike %G_GNUC_DEPRECATED_FOR, it is
2816  * meant to be portable across different compilers and must be placed
2817  * before the function declaration.
2818  *
2819  * Since: 2.32
2820  */
2821
2822
2823 /**
2824  * G_DIR_SEPARATOR:
2825  *
2826  * The directory separator character.
2827  * This is '/' on UNIX machines and '\' under Windows.
2828  */
2829
2830
2831 /**
2832  * G_DIR_SEPARATOR_S:
2833  *
2834  * The directory separator as a string.
2835  * This is "/" on UNIX machines and "\" under Windows.
2836  */
2837
2838
2839 /**
2840  * G_E:
2841  *
2842  * The base of natural logarithms.
2843  */
2844
2845
2846 /**
2847  * G_END_DECLS:
2848  *
2849  * Used (along with #G_BEGIN_DECLS) to bracket header files. If the
2850  * compiler in use is a C++ compiler, adds <literal>extern "C"</literal>
2851  * around the header.
2852  */
2853
2854
2855 /**
2856  * G_FILE_ERROR:
2857  *
2858  * Error domain for file operations. Errors in this domain will
2859  * be from the #GFileError enumeration. See #GError for information
2860  * on error domains.
2861  */
2862
2863
2864 /**
2865  * G_GINT16_FORMAT:
2866  *
2867  * This is the platform dependent conversion specifier for scanning and
2868  * printing values of type #gint16. It is a string literal, but doesn't
2869  * include the percent-sign, such that you can add precision and length
2870  * modifiers between percent-sign and conversion specifier.
2871  *
2872  * |[
2873  * gint16 in;
2874  * gint32 out;
2875  * sscanf ("42", "%" G_GINT16_FORMAT, &amp;in)
2876  * out = in * 1000;
2877  * g_print ("%" G_GINT32_FORMAT, out);
2878  * ]|
2879  */
2880
2881
2882 /**
2883  * G_GINT16_MODIFIER:
2884  *
2885  * The platform dependent length modifier for conversion specifiers
2886  * for scanning and printing values of type #gint16 or #guint16. It
2887  * is a string literal, but doesn't include the percent-sign, such
2888  * that you can add precision and length modifiers between percent-sign
2889  * and conversion specifier and append a conversion specifier.
2890  *
2891  * The following example prints "0x7b";
2892  * |[
2893  * gint16 value = 123;
2894  * g_print ("%#" G_GINT16_MODIFIER "x", value);
2895  * ]|
2896  *
2897  * Since: 2.4
2898  */
2899
2900
2901 /**
2902  * G_GINT32_FORMAT:
2903  *
2904  * This is the platform dependent conversion specifier for scanning
2905  * and printing values of type #gint32. See also #G_GINT16_FORMAT.
2906  */
2907
2908
2909 /**
2910  * G_GINT32_MODIFIER:
2911  *
2912  * The platform dependent length modifier for conversion specifiers
2913  * for scanning and printing values of type #gint32 or #guint32. It
2914  * is a string literal. See also #G_GINT16_MODIFIER.
2915  *
2916  * Since: 2.4
2917  */
2918
2919
2920 /**
2921  * G_GINT64_CONSTANT:
2922  * @val: a literal integer value, e.g. 0x1d636b02300a7aa7
2923  *
2924  * This macro is used to insert 64-bit integer literals
2925  * into the source code.
2926  */
2927
2928
2929 /**
2930  * G_GINT64_FORMAT:
2931  *
2932  * This is the platform dependent conversion specifier for scanning
2933  * and printing values of type #gint64. See also #G_GINT16_FORMAT.
2934  *
2935  * <note><para>
2936  * Some platforms do not support scanning and printing 64 bit integers,
2937  * even though the types are supported. On such platforms #G_GINT64_FORMAT
2938  * is not defined. Note that scanf() may not support 64 bit integers, even
2939  * if #G_GINT64_FORMAT is defined. Due to its weak error handling, scanf()
2940  * is not recommended for parsing anyway; consider using g_ascii_strtoull()
2941  * instead.
2942  * </para></note>
2943  */
2944
2945
2946 /**
2947  * G_GINT64_MODIFIER:
2948  *
2949  * The platform dependent length modifier for conversion specifiers
2950  * for scanning and printing values of type #gint64 or #guint64.
2951  * It is a string literal.
2952  *
2953  * <note><para>
2954  * Some platforms do not support printing 64 bit integers, even
2955  * though the types are supported. On such platforms #G_GINT64_MODIFIER
2956  * is not defined.
2957  * </para></note>
2958  *
2959  * Since: 2.4
2960  */
2961
2962
2963 /**
2964  * G_GINTPTR_FORMAT:
2965  *
2966  * This is the platform dependent conversion specifier for scanning
2967  * and printing values of type #gintptr.
2968  *
2969  * Since: 2.22
2970  */
2971
2972
2973 /**
2974  * G_GINTPTR_MODIFIER:
2975  *
2976  * The platform dependent length modifier for conversion specifiers
2977  * for scanning and printing values of type #gintptr or #guintptr.
2978  * It is a string literal.
2979  *
2980  * Since: 2.22
2981  */
2982
2983
2984 /**
2985  * G_GNUC_ALLOC_SIZE:
2986  * @x: the index of the argument specifying the allocation size
2987  *
2988  * Expands to the GNU C <literal>alloc_size</literal> function attribute
2989  * if the compiler is a new enough <command>gcc</command>. This attribute
2990  * tells the compiler that the function returns a pointer to memory of a
2991  * size that is specified by the @x<!-- -->th function parameter.
2992  *
2993  * Place the attribute after the function declaration, just before the
2994  * semicolon.
2995  *
2996  * See the GNU C documentation for more details.
2997  *
2998  * Since: 2.18
2999  */
3000
3001
3002 /**
3003  * G_GNUC_ALLOC_SIZE2:
3004  * @x: the index of the argument specifying one factor of the allocation size
3005  * @y: the index of the argument specifying the second factor of the allocation size
3006  *
3007  * Expands to the GNU C <literal>alloc_size</literal> function attribute
3008  * if the compiler is a new enough <command>gcc</command>. This attribute
3009  * tells the compiler that the function returns a pointer to memory of a
3010  * size that is specified by the product of two function parameters.
3011  *
3012  * Place the attribute after the function declaration, just before the
3013  * semicolon.
3014  *
3015  * See the GNU C documentation for more details.
3016  *
3017  * Since: 2.18
3018  */
3019
3020
3021 /**
3022  * G_GNUC_BEGIN_IGNORE_DEPRECATIONS:
3023  *
3024  * Tells <command>gcc</command> (if it is a new enough version) to
3025  * temporarily stop emitting warnings when functions marked with
3026  * %G_GNUC_DEPRECATED or %G_GNUC_DEPRECATED_FOR are called. This is
3027  * useful for when you have one deprecated function calling another
3028  * one, or when you still have regression tests for deprecated
3029  * functions.
3030  *
3031  * Use %G_GNUC_END_IGNORE_DEPRECATIONS to begin warning again. (If you
3032  * are not compiling with <literal>-Wdeprecated-declarations</literal>
3033  * then neither macro has any effect.)
3034  *
3035  * This macro can be used either inside or outside of a function body,
3036  * but must appear on a line by itself.
3037  *
3038  * Since: 2.32
3039  */
3040
3041
3042 /**
3043  * G_GNUC_CONST:
3044  *
3045  * Expands to the GNU C <literal>const</literal> function attribute if
3046  * the compiler is <command>gcc</command>. Declaring a function as const
3047  * enables better optimization of calls to the function. A const function
3048  * doesn't examine any values except its parameters, and has no effects
3049  * except its return value.
3050  *
3051  * Place the attribute after the declaration, just before the semicolon.
3052  *
3053  * See the GNU C documentation for more details.
3054  *
3055  * <note><para>
3056  * A function that has pointer arguments and examines the data pointed to
3057  * must <emphasis>not</emphasis> be declared const. Likewise, a function
3058  * that calls a non-const function usually must not be const. It doesn't
3059  * make sense for a const function to return void.
3060  * </para></note>
3061  */
3062
3063
3064 /**
3065  * G_GNUC_DEPRECATED:
3066  *
3067  * Expands to the GNU C <literal>deprecated</literal> attribute if the
3068  * compiler is <command>gcc</command>. It can be used to mark typedefs,
3069  * variables and functions as deprecated. When called with the
3070  * <option>-Wdeprecated-declarations</option> option, the compiler will
3071  * generate warnings when deprecated interfaces are used.
3072  *
3073  * Place the attribute after the declaration, just before the semicolon.
3074  *
3075  * See the GNU C documentation for more details.
3076  *
3077  * Since: 2.2
3078  */
3079
3080
3081 /**
3082  * G_GNUC_DEPRECATED_FOR:
3083  * @f: the intended replacement for the deprecated symbol,
3084  *     such as the name of a function
3085  *
3086  * Like %G_GNUC_DEPRECATED, but names the intended replacement for the
3087  * deprecated symbol if the version of <command>gcc</command> in use is
3088  * new enough to support custom deprecation messages.
3089  *
3090  * Place the attribute after the declaration, just before the semicolon.
3091  *
3092  * See the GNU C documentation for more details.
3093  *
3094  * Note that if @f is a macro, it will be expanded in the warning message.
3095  * You can enclose it in quotes to prevent this. (The quotes will show up
3096  * in the warning, but it's better than showing the macro expansion.)
3097  *
3098  * Since: 2.26
3099  */
3100
3101
3102 /**
3103  * G_GNUC_END_IGNORE_DEPRECATIONS:
3104  *
3105  * Undoes the effect of %G_GNUC_BEGIN_IGNORE_DEPRECATIONS, telling
3106  * <command>gcc</command> to begin outputting warnings again
3107  * (assuming those warnings had been enabled to begin with).
3108  *
3109  * This macro can be used either inside or outside of a function body,
3110  * but must appear on a line by itself.
3111  *
3112  * Since: 2.32
3113  */
3114
3115
3116 /**
3117  * G_GNUC_EXTENSION:
3118  *
3119  * Expands to <literal>__extension__</literal> when <command>gcc</command>
3120  * is used as the compiler. This simply tells <command>gcc</command> not
3121  * to warn about the following non-standard code when compiling with the
3122  * <option>-pedantic</option> option.
3123  */
3124
3125
3126 /**
3127  * G_GNUC_FORMAT:
3128  * @arg_idx: the index of the argument
3129  *
3130  * Expands to the GNU C <literal>format_arg</literal> function attribute
3131  * if the compiler is <command>gcc</command>. This function attribute
3132  * specifies that a function takes a format string for a printf(),
3133  * scanf(), strftime() or strfmon() style function and modifies it,
3134  * so that the result can be passed to a printf(), scanf(), strftime()
3135  * or strfmon() style function (with the remaining arguments to the
3136  * format function the same as they would have been for the unmodified
3137  * string).
3138  *
3139  * Place the attribute after the function declaration, just before the
3140  * semicolon.
3141  *
3142  * See the GNU C documentation for more details.
3143  *
3144  * |[
3145  * gchar *g_dgettext (gchar *domain_name, gchar *msgid) G_GNUC_FORMAT (2);
3146  * ]|
3147  */
3148
3149
3150 /**
3151  * G_GNUC_FUNCTION:
3152  *
3153  * Expands to "" on all modern compilers, and to
3154  * <literal>__FUNCTION__</literal> on <command>gcc</command> version 2.x.
3155  * Don't use it.
3156  *
3157  * Deprecated: 2.16: Use #G_STRFUNC instead
3158  */
3159
3160
3161 /**
3162  * G_GNUC_INTERNAL:
3163  *
3164  * This attribute can be used for marking library functions as being used
3165  * internally to the library only, which may allow the compiler to handle
3166  * function calls more efficiently. Note that static functions do not need
3167  * to be marked as internal in this way. See the GNU C documentation for
3168  * details.
3169  *
3170  * When using a compiler that supports the GNU C hidden visibility attribute,
3171  * this macro expands to <literal>__attribute__((visibility("hidden")))</literal>.
3172  * When using the Sun Studio compiler, it expands to <literal>__hidden</literal>.
3173  *
3174  * Note that for portability, the attribute should be placed before the
3175  * function declaration. While GCC allows the macro after the declaration,
3176  * Sun Studio does not.
3177  *
3178  * |[
3179  * G_GNUC_INTERNAL
3180  * void _g_log_fallback_handler (const gchar    *log_domain,
3181  *                               GLogLevelFlags  log_level,
3182  *                               const gchar    *message,
3183  *                               gpointer        unused_data);
3184  * ]|
3185  *
3186  * Since: 2.6
3187  */
3188
3189
3190 /**
3191  * G_GNUC_MALLOC:
3192  *
3193  * Expands to the GNU C <literal>malloc</literal> function attribute if the
3194  * compiler is <command>gcc</command>. Declaring a function as malloc enables
3195  * better optimization of the function. A function can have the malloc
3196  * attribute if it returns a pointer which is guaranteed to not alias with
3197  * any other pointer when the function returns (in practice, this means newly
3198  * allocated memory).
3199  *
3200  * Place the attribute after the declaration, just before the semicolon.
3201  *
3202  * See the GNU C documentation for more details.
3203  *
3204  * Since: 2.6
3205  */
3206
3207
3208 /**
3209  * G_GNUC_MAY_ALIAS:
3210  *
3211  * Expands to the GNU C <literal>may_alias</literal> type attribute
3212  * if the compiler is <command>gcc</command>. Types with this attribute
3213  * will not be subjected to type-based alias analysis, but are assumed
3214  * to alias with any other type, just like char.
3215  * See the GNU C documentation for details.
3216  *
3217  * Since: 2.14
3218  */
3219
3220
3221 /**
3222  * G_GNUC_NORETURN:
3223  *
3224  * Expands to the GNU C <literal>noreturn</literal> function attribute
3225  * if the compiler is <command>gcc</command>. It is used for declaring
3226  * functions which never return. It enables optimization of the function,
3227  * and avoids possible compiler warnings.
3228  *
3229  * Place the attribute after the declaration, just before the semicolon.
3230  *
3231  * See the GNU C documentation for more details.
3232  */
3233
3234
3235 /**
3236  * G_GNUC_NO_INSTRUMENT:
3237  *
3238  * Expands to the GNU C <literal>no_instrument_function</literal> function
3239  * attribute if the compiler is <command>gcc</command>. Functions with this
3240  * attribute will not be instrumented for profiling, when the compiler is
3241  * called with the <option>-finstrument-functions</option> option.
3242  *
3243  * Place the attribute after the declaration, just before the semicolon.
3244  *
3245  * See the GNU C documentation for more details.
3246  */
3247
3248
3249 /**
3250  * G_GNUC_NULL_TERMINATED:
3251  *
3252  * Expands to the GNU C <literal>sentinel</literal> function attribute
3253  * if the compiler is <command>gcc</command>, or "" if it isn't. This
3254  * function attribute only applies to variadic functions and instructs
3255  * the compiler to check that the argument list is terminated with an
3256  * explicit %NULL.
3257  *
3258  * Place the attribute after the declaration, just before the semicolon.
3259  *
3260  * See the GNU C documentation for more details.
3261  *
3262  * Since: 2.8
3263  */
3264
3265
3266 /**
3267  * G_GNUC_PRETTY_FUNCTION:
3268  *
3269  * Expands to "" on all modern compilers, and to
3270  * <literal>__PRETTY_FUNCTION__</literal> on <command>gcc</command>
3271  * version 2.x. Don't use it.
3272  *
3273  * Deprecated: 2.16: Use #G_STRFUNC instead
3274  */
3275
3276
3277 /**
3278  * G_GNUC_PRINTF:
3279  * @format_idx: the index of the argument corresponding to the
3280  *     format string (The arguments are numbered from 1)
3281  * @arg_idx: the index of the first of the format arguments
3282  *
3283  * Expands to the GNU C <literal>format</literal> function attribute
3284  * if the compiler is <command>gcc</command>. This is used for declaring
3285  * functions which take a variable number of arguments, with the same
3286  * syntax as printf(). It allows the compiler to type-check the arguments
3287  * passed to the function.
3288  *
3289  * Place the attribute after the function declaration, just before the
3290  * semicolon.
3291  *
3292  * See the GNU C documentation for more details.
3293  *
3294  * |[
3295  * gint g_snprintf (gchar  *string,
3296  *                  gulong       n,
3297  *                  gchar const *format,
3298  *                  ...) G_GNUC_PRINTF (3, 4);
3299  * ]|
3300  */
3301
3302
3303 /**
3304  * G_GNUC_PURE:
3305  *
3306  * Expands to the GNU C <literal>pure</literal> function attribute if the
3307  * compiler is <command>gcc</command>. Declaring a function as pure enables
3308  * better optimization of calls to the function. A pure function has no
3309  * effects except its return value and the return value depends only on
3310  * the parameters and/or global variables.
3311  *
3312  * Place the attribute after the declaration, just before the semicolon.
3313  *
3314  * See the GNU C documentation for more details.
3315  */
3316
3317
3318 /**
3319  * G_GNUC_SCANF:
3320  * @format_idx: the index of the argument corresponding to
3321  *     the format string (The arguments are numbered from 1)
3322  * @arg_idx: the index of the first of the format arguments
3323  *
3324  * Expands to the GNU C <literal>format</literal> function attribute
3325  * if the compiler is <command>gcc</command>. This is used for declaring
3326  * functions which take a variable number of arguments, with the same
3327  * syntax as scanf(). It allows the compiler to type-check the arguments
3328  * passed to the function. See the GNU C documentation for details.
3329  */
3330
3331
3332 /**
3333  * G_GNUC_UNUSED:
3334  *
3335  * Expands to the GNU C <literal>unused</literal> function attribute if
3336  * the compiler is <command>gcc</command>. It is used for declaring
3337  * functions and arguments which may never be used. It avoids possible compiler
3338  * warnings.
3339  *
3340  * For functions, place the attribute after the declaration, just before the
3341  * semicolon. For arguments, place the attribute at the beginning of the
3342  * argument declaration.
3343  *
3344  * |[
3345  * void my_unused_function (G_GNUC_UNUSED gint unused_argument,
3346  *                          gint other_argument) G_GNUC_UNUSED;
3347  * ]|
3348  *
3349  * See the GNU C documentation for more details.
3350  */
3351
3352
3353 /**
3354  * G_GNUC_WARN_UNUSED_RESULT:
3355  *
3356  * Expands to the GNU C <literal>warn_unused_result</literal> function
3357  * attribute if the compiler is <command>gcc</command>, or "" if it isn't.
3358  * This function attribute makes the compiler emit a warning if the result
3359  * of a function call is ignored.
3360  *
3361  * Place the attribute after the declaration, just before the semicolon.
3362  *
3363  * See the GNU C documentation for more details.
3364  *
3365  * Since: 2.10
3366  */
3367
3368
3369 /**
3370  * G_GOFFSET_CONSTANT:
3371  * @val: a literal integer value, e.g. 0x1d636b02300a7aa7
3372  *
3373  * This macro is used to insert #goffset 64-bit integer literals
3374  * into the source code.
3375  *
3376  * See also #G_GINT64_CONSTANT.
3377  *
3378  * Since: 2.20
3379  */
3380
3381
3382 /**
3383  * G_GOFFSET_FORMAT:
3384  *
3385  * This is the platform dependent conversion specifier for scanning
3386  * and printing values of type #goffset. See also #G_GINT64_FORMAT.
3387  *
3388  * Since: 2.20
3389  */
3390
3391
3392 /**
3393  * G_GOFFSET_MODIFIER:
3394  *
3395  * The platform dependent length modifier for conversion specifiers
3396  * for scanning and printing values of type #goffset. It is a string
3397  * literal. See also #G_GINT64_MODIFIER.
3398  *
3399  * Since: 2.20
3400  */
3401
3402
3403 /**
3404  * G_GSIZE_FORMAT:
3405  *
3406  * This is the platform dependent conversion specifier for scanning
3407  * and printing values of type #gsize. See also #G_GINT16_FORMAT.
3408  *
3409  * Since: 2.6
3410  */
3411
3412
3413 /**
3414  * G_GSIZE_MODIFIER:
3415  *
3416  * The platform dependent length modifier for conversion specifiers
3417  * for scanning and printing values of type #gsize or #gssize. It
3418  * is a string literal.
3419  *
3420  * Since: 2.6
3421  */
3422
3423
3424 /**
3425  * G_GSSIZE_FORMAT:
3426  *
3427  * This is the platform dependent conversion specifier for scanning
3428  * and printing values of type #gssize. See also #G_GINT16_FORMAT.
3429  *
3430  * Since: 2.6
3431  */
3432
3433
3434 /**
3435  * G_GUINT16_FORMAT:
3436  *
3437  * This is the platform dependent conversion specifier for scanning
3438  * and printing values of type #guint16. See also #G_GINT16_FORMAT
3439  */
3440
3441
3442 /**
3443  * G_GUINT32_FORMAT:
3444  *
3445  * This is the platform dependent conversion specifier for scanning
3446  * and printing values of type #guint32. See also #G_GINT16_FORMAT.
3447  */
3448
3449
3450 /**
3451  * G_GUINT64_CONSTANT:
3452  * @val: a literal integer value, e.g. 0x1d636b02300a7aa7U
3453  *
3454  * This macro is used to insert 64-bit unsigned integer
3455  * literals into the source code.
3456  *
3457  * Since: 2.10
3458  */
3459
3460
3461 /**
3462  * G_GUINT64_FORMAT:
3463  *
3464  * This is the platform dependent conversion specifier for scanning
3465  * and printing values of type #guint64. See also #G_GINT16_FORMAT.
3466  *
3467  * <note><para>
3468  * Some platforms do not support scanning and printing 64 bit integers,
3469  * even though the types are supported. On such platforms #G_GUINT64_FORMAT
3470  * is not defined.  Note that scanf() may not support 64 bit integers, even
3471  * if #G_GINT64_FORMAT is defined. Due to its weak error handling, scanf()
3472  * is not recommended for parsing anyway; consider using g_ascii_strtoull()
3473  * instead.
3474  * </para></note>
3475  */
3476
3477
3478 /**
3479  * G_GUINTPTR_FORMAT:
3480  *
3481  * This is the platform dependent conversion specifier
3482  * for scanning and printing values of type #guintptr.
3483  *
3484  * Since: 2.22
3485  */
3486
3487
3488 /**
3489  * G_HOOK:
3490  * @hook: a pointer
3491  *
3492  * Casts a pointer to a <literal>GHook*</literal>.
3493  */
3494
3495
3496 /**
3497  * G_HOOK_ACTIVE:
3498  * @hook: a #GHook
3499  *
3500  * Returns %TRUE if the #GHook is active, which is normally the case
3501  * until the #GHook is destroyed.
3502  *
3503  * Returns: %TRUE if the #GHook is active
3504  */
3505
3506
3507 /**
3508  * G_HOOK_FLAGS:
3509  * @hook: a #GHook
3510  *
3511  * Gets the flags of a hook.
3512  */
3513
3514
3515 /**
3516  * G_HOOK_FLAG_USER_SHIFT:
3517  *
3518  * The position of the first bit which is not reserved for internal
3519  * use be the #GHook implementation, i.e.
3520  * <literal>1 &lt;&lt; G_HOOK_FLAG_USER_SHIFT</literal> is the first
3521  * bit which can be used for application-defined flags.
3522  */
3523
3524
3525 /**
3526  * G_HOOK_IN_CALL:
3527  * @hook: a #GHook
3528  *
3529  * Returns %TRUE if the #GHook function is currently executing.
3530  *
3531  * Returns: %TRUE if the #GHook function is currently executing
3532  */
3533
3534
3535 /**
3536  * G_HOOK_IS_UNLINKED:
3537  * @hook: a #GHook
3538  *
3539  * Returns %TRUE if the #GHook is not in a #GHookList.
3540  *
3541  * Returns: %TRUE if the #GHook is not in a #GHookList
3542  */
3543
3544
3545 /**
3546  * G_HOOK_IS_VALID:
3547  * @hook: a #GHook
3548  *
3549  * Returns %TRUE if the #GHook is valid, i.e. it is in a #GHookList,
3550  * it is active and it has not been destroyed.
3551  *
3552  * Returns: %TRUE if the #GHook is valid
3553  */
3554
3555
3556 /**
3557  * G_IEEE754_DOUBLE_BIAS:
3558  *
3559  * The bias by which exponents in double-precision floats are offset.
3560  */
3561
3562
3563 /**
3564  * G_IEEE754_FLOAT_BIAS:
3565  *
3566  * The bias by which exponents in single-precision floats are offset.
3567  */
3568
3569
3570 /**
3571  * G_INLINE_FUNC:
3572  *
3573  * This macro is used to export function prototypes so they can be linked
3574  * with an external version when no inlining is performed. The file which
3575  * implements the functions should define <literal>G_IMPLEMENTS_INLINES</literal>
3576  * before including the headers which contain %G_INLINE_FUNC declarations.
3577  * Since inlining is very compiler-dependent using these macros correctly
3578  * is very difficult. Their use is strongly discouraged.
3579  *
3580  * This macro is often mistaken for a replacement for the inline keyword;
3581  * inline is already declared in a portable manner in the GLib headers
3582  * and can be used normally.
3583  */
3584
3585
3586 /**
3587  * G_IO_CHANNEL_ERROR:
3588  *
3589  * Error domain for #GIOChannel operations. Errors in this domain will
3590  * be from the #GIOChannelError enumeration. See #GError for
3591  * information on error domains.
3592  */
3593
3594
3595 /**
3596  * G_IO_FLAG_IS_WRITEABLE:
3597  *
3598  * This is a misspelled version of G_IO_FLAG_IS_WRITABLE that existed
3599  * before the spelling was fixed in GLib 2.30.  It is kept here for
3600  * compatibility reasons.
3601  *
3602  * Deprecated: 2.30: Use G_IO_FLAG_IS_WRITABLE instead.
3603  */
3604
3605
3606 /**
3607  * G_IS_DIR_SEPARATOR:
3608  * @c: a character
3609  *
3610  * Checks whether a character is a directory
3611  * separator. It returns %TRUE for '/' on UNIX
3612  * machines and for '\' or '/' under Windows.
3613  *
3614  * Since: 2.6
3615  */
3616
3617
3618 /**
3619  * G_KEY_FILE_DESKTOP_GROUP:
3620  *
3621  * The name of the main group of a desktop entry file, as defined in the
3622  * <ulink url="http://freedesktop.org/Standards/desktop-entry-spec">Desktop
3623  * Entry Specification</ulink>. Consult the specification for more
3624  * details about the meanings of the keys below.
3625  *
3626  * Since: 2.14
3627  */
3628
3629
3630 /**
3631  * G_KEY_FILE_DESKTOP_KEY_CATEGORIES:
3632  *
3633  * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a list
3634  * of strings giving the categories in which the desktop entry
3635  * should be shown in a menu.
3636  *
3637  * Since: 2.14
3638  */
3639
3640
3641 /**
3642  * G_KEY_FILE_DESKTOP_KEY_COMMENT:
3643  *
3644  * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a localized
3645  * string giving the tooltip for the desktop entry.
3646  *
3647  * Since: 2.14
3648  */
3649
3650
3651 /**
3652  * G_KEY_FILE_DESKTOP_KEY_EXEC:
3653  *
3654  * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a string
3655  * giving the command line to execute. It is only valid for desktop
3656  * entries with the <literal>Application</literal> type.
3657  *
3658  * Since: 2.14
3659  */
3660
3661
3662 /**
3663  * G_KEY_FILE_DESKTOP_KEY_GENERIC_NAME:
3664  *
3665  * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a localized
3666  * string giving the generic name of the desktop entry.
3667  *
3668  * Since: 2.14
3669  */
3670
3671
3672 /**
3673  * G_KEY_FILE_DESKTOP_KEY_HIDDEN:
3674  *
3675  * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a boolean
3676  * stating whether the desktop entry has been deleted by the user.
3677  *
3678  * Since: 2.14
3679  */
3680
3681
3682 /**
3683  * G_KEY_FILE_DESKTOP_KEY_ICON:
3684  *
3685  * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a localized
3686  * string giving the name of the icon to be displayed for the desktop
3687  * entry.
3688  *
3689  * Since: 2.14
3690  */
3691
3692
3693 /**
3694  * G_KEY_FILE_DESKTOP_KEY_MIME_TYPE:
3695  *
3696  * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a list
3697  * of strings giving the MIME types supported by this desktop entry.
3698  *
3699  * Since: 2.14
3700  */
3701
3702
3703 /**
3704  * G_KEY_FILE_DESKTOP_KEY_NAME:
3705  *
3706  * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a localized
3707  * string giving the specific name of the desktop entry.
3708  *
3709  * Since: 2.14
3710  */
3711
3712
3713 /**
3714  * G_KEY_FILE_DESKTOP_KEY_NOT_SHOW_IN:
3715  *
3716  * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a list of
3717  * strings identifying the environments that should not display the
3718  * desktop entry.
3719  *
3720  * Since: 2.14
3721  */
3722
3723
3724 /**
3725  * G_KEY_FILE_DESKTOP_KEY_NO_DISPLAY:
3726  *
3727  * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a boolean
3728  * stating whether the desktop entry should be shown in menus.
3729  *
3730  * Since: 2.14
3731  */
3732
3733
3734 /**
3735  * G_KEY_FILE_DESKTOP_KEY_ONLY_SHOW_IN:
3736  *
3737  * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a list of
3738  * strings identifying the environments that should display the
3739  * desktop entry.
3740  *
3741  * Since: 2.14
3742  */
3743
3744
3745 /**
3746  * G_KEY_FILE_DESKTOP_KEY_PATH:
3747  *
3748  * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a string
3749  * containing the working directory to run the program in. It is only
3750  * valid for desktop entries with the <literal>Application</literal> type.
3751  *
3752  * Since: 2.14
3753  */
3754
3755
3756 /**
3757  * G_KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY:
3758  *
3759  * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a boolean
3760  * stating whether the application supports the <ulink
3761  * url="http://www.freedesktop.org/Standards/startup-notification-spec">Startup
3762  * Notification Protocol Specification</ulink>.
3763  *
3764  * Since: 2.14
3765  */
3766
3767
3768 /**
3769  * G_KEY_FILE_DESKTOP_KEY_STARTUP_WM_CLASS:
3770  *
3771  * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is string
3772  * identifying the WM class or name hint of a window that the application
3773  * will create, which can be used to emulate Startup Notification with
3774  * older applications.
3775  *
3776  * Since: 2.14
3777  */
3778
3779
3780 /**
3781  * G_KEY_FILE_DESKTOP_KEY_TERMINAL:
3782  *
3783  * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a boolean
3784  * stating whether the program should be run in a terminal window.
3785  * It is only valid for desktop entries with the
3786  * <literal>Application</literal> type.
3787  *
3788  * Since: 2.14
3789  */
3790
3791
3792 /**
3793  * G_KEY_FILE_DESKTOP_KEY_TRY_EXEC:
3794  *
3795  * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a string
3796  * giving the file name of a binary on disk used to determine if the
3797  * program is actually installed. It is only valid for desktop entries
3798  * with the <literal>Application</literal> type.
3799  *
3800  * Since: 2.14
3801  */
3802
3803
3804 /**
3805  * G_KEY_FILE_DESKTOP_KEY_TYPE:
3806  *
3807  * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a string
3808  * giving the type of the desktop entry. Usually
3809  * #G_KEY_FILE_DESKTOP_TYPE_APPLICATION,
3810  * #G_KEY_FILE_DESKTOP_TYPE_LINK, or
3811  * #G_KEY_FILE_DESKTOP_TYPE_DIRECTORY.
3812  *
3813  * Since: 2.14
3814  */
3815
3816
3817 /**
3818  * G_KEY_FILE_DESKTOP_KEY_URL:
3819  *
3820  * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a string
3821  * giving the URL to access. It is only valid for desktop entries
3822  * with the <literal>Link</literal> type.
3823  *
3824  * Since: 2.14
3825  */
3826
3827
3828 /**
3829  * G_KEY_FILE_DESKTOP_KEY_VERSION:
3830  *
3831  * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a string
3832  * giving the version of the Desktop Entry Specification used for
3833  * the desktop entry file.
3834  *
3835  * Since: 2.14
3836  */
3837
3838
3839 /**
3840  * G_KEY_FILE_DESKTOP_TYPE_APPLICATION:
3841  *
3842  * The value of the #G_KEY_FILE_DESKTOP_KEY_TYPE, key for desktop
3843  * entries representing applications.
3844  *
3845  * Since: 2.14
3846  */
3847
3848
3849 /**
3850  * G_KEY_FILE_DESKTOP_TYPE_DIRECTORY:
3851  *
3852  * The value of the #G_KEY_FILE_DESKTOP_KEY_TYPE, key for desktop
3853  * entries representing directories.
3854  *
3855  * Since: 2.14
3856  */
3857
3858
3859 /**
3860  * G_KEY_FILE_DESKTOP_TYPE_LINK:
3861  *
3862  * The value of the #G_KEY_FILE_DESKTOP_KEY_TYPE, key for desktop
3863  * entries representing links to documents.
3864  *
3865  * Since: 2.14
3866  */
3867
3868
3869 /**
3870  * G_KEY_FILE_ERROR:
3871  *
3872  * Error domain for key file parsing. Errors in this domain will
3873  * be from the #GKeyFileError enumeration.
3874  *
3875  * See #GError for information on error domains.
3876  */
3877
3878
3879 /**
3880  * G_LIKELY:
3881  * @expr: the expression
3882  *
3883  * Hints the compiler that the expression is likely to evaluate to
3884  * a true value. The compiler may use this information for optimizations.
3885  *
3886  * |[
3887  * if (G_LIKELY (random () != 1))
3888  *   g_print ("not one");
3889  * ]|
3890  *
3891  * Returns: the value of @expr
3892  * Since: 2.2
3893  */
3894
3895
3896 /**
3897  * G_LITTLE_ENDIAN:
3898  *
3899  * Specifies one of the possible types of byte order.
3900  * See #G_BYTE_ORDER.
3901  */
3902
3903
3904 /**
3905  * G_LN10:
3906  *
3907  * The natural logarithm of 10.
3908  */
3909
3910
3911 /**
3912  * G_LN2:
3913  *
3914  * The natural logarithm of 2.
3915  */
3916
3917
3918 /**
3919  * G_LOCK:
3920  * @name: the name of the lock
3921  *
3922  * Works like g_mutex_lock(), but for a lock defined with
3923  * #G_LOCK_DEFINE.
3924  */
3925
3926
3927 /**
3928  * G_LOCK_DEFINE:
3929  * @name: the name of the lock
3930  *
3931  * The <literal>G_LOCK_*</literal> macros provide a convenient interface to #GMutex.
3932  * #G_LOCK_DEFINE defines a lock. It can appear in any place where
3933  * variable definitions may appear in programs, i.e. in the first block
3934  * of a function or outside of functions. The @name parameter will be
3935  * mangled to get the name of the #GMutex. This means that you
3936  * can use names of existing variables as the parameter - e.g. the name
3937  * of the variable you intend to protect with the lock. Look at our
3938  * <function>give_me_next_number()</function> example using the
3939  * <literal>G_LOCK_*</literal> macros:
3940  *
3941  * <example>
3942  *  <title>Using the <literal>G_LOCK_*</literal> convenience macros</title>
3943  *  <programlisting>
3944  *   G_LOCK_DEFINE (current_number);
3945  *
3946  *   int
3947  *   give_me_next_number (void)
3948  *   {
3949  *     static int current_number = 0;
3950  *     int ret_val;
3951  *
3952  *     G_LOCK (current_number);
3953  *     ret_val = current_number = calc_next_number (current_number);
3954  *     G_UNLOCK (current_number);
3955  *
3956  *     return ret_val;
3957  *   }
3958  *  </programlisting>
3959  * </example>
3960  */
3961
3962
3963 /**
3964  * G_LOCK_DEFINE_STATIC:
3965  * @name: the name of the lock
3966  *
3967  * This works like #G_LOCK_DEFINE, but it creates a static object.
3968  */
3969
3970
3971 /**
3972  * G_LOCK_EXTERN:
3973  * @name: the name of the lock
3974  *
3975  * This declares a lock, that is defined with #G_LOCK_DEFINE in another
3976  * module.
3977  */
3978
3979
3980 /**
3981  * G_LOG_2_BASE_10:
3982  *
3983  * Multiplying the base 2 exponent by this number yields the base 10 exponent.
3984  */
3985
3986
3987 /**
3988  * G_LOG_DOMAIN:
3989  *
3990  * Defines the log domain.
3991  *
3992  * For applications, this is typically left as the default %NULL
3993  * (or "") domain. Libraries should define this so that any messages
3994  * which they log can be differentiated from messages from other
3995  * libraries and application code. But be careful not to define
3996  * it in any public header files.
3997  *
3998  * For example, GTK+ uses this in its Makefile.am:
3999  * |[
4000  * INCLUDES = -DG_LOG_DOMAIN=\"Gtk\"
4001  * ]|
4002  */
4003
4004
4005 /**
4006  * G_LOG_FATAL_MASK:
4007  *
4008  * GLib log levels that are considered fatal by default.
4009  */
4010
4011
4012 /**
4013  * G_MAXDOUBLE:
4014  *
4015  * The maximum value which can be held in a #gdouble.
4016  */
4017
4018
4019 /**
4020  * G_MAXFLOAT:
4021  *
4022  * The maximum value which can be held in a #gfloat.
4023  */
4024
4025
4026 /**
4027  * G_MAXINT:
4028  *
4029  * The maximum value which can be held in a #gint.
4030  */
4031
4032
4033 /**
4034  * G_MAXINT16:
4035  *
4036  * The maximum value which can be held in a #gint16.
4037  *
4038  * Since: 2.4
4039  */
4040
4041
4042 /**
4043  * G_MAXINT32:
4044  *
4045  * The maximum value which can be held in a #gint32.
4046  *
4047  * Since: 2.4
4048  */
4049
4050
4051 /**
4052  * G_MAXINT64:
4053  *
4054  * The maximum value which can be held in a #gint64.
4055  */
4056
4057
4058 /**
4059  * G_MAXINT8:
4060  *
4061  * The maximum value which can be held in a #gint8.
4062  *
4063  * Since: 2.4
4064  */
4065
4066
4067 /**
4068  * G_MAXLONG:
4069  *
4070  * The maximum value which can be held in a #glong.
4071  */
4072
4073
4074 /**
4075  * G_MAXOFFSET:
4076  *
4077  * The maximum value which can be held in a #goffset.
4078  */
4079
4080
4081 /**
4082  * G_MAXSHORT:
4083  *
4084  * The maximum value which can be held in a #gshort.
4085  */
4086
4087
4088 /**
4089  * G_MAXSIZE:
4090  *
4091  * The maximum value which can be held in a #gsize.
4092  *
4093  * Since: 2.4
4094  */
4095
4096
4097 /**
4098  * G_MAXSSIZE:
4099  *
4100  * The maximum value which can be held in a #gssize.
4101  *
4102  * Since: 2.14
4103  */
4104
4105
4106 /**
4107  * G_MAXUINT:
4108  *
4109  * The maximum value which can be held in a #guint.
4110  */
4111
4112
4113 /**
4114  * G_MAXUINT16:
4115  *
4116  * The maximum value which can be held in a #guint16.
4117  *
4118  * Since: 2.4
4119  */
4120
4121
4122 /**
4123  * G_MAXUINT32:
4124  *
4125  * The maximum value which can be held in a #guint32.
4126  *
4127  * Since: 2.4
4128  */
4129
4130
4131 /**
4132  * G_MAXUINT64:
4133  *
4134  * The maximum value which can be held in a #guint64.
4135  */
4136
4137
4138 /**
4139  * G_MAXUINT8:
4140  *
4141  * The maximum value which can be held in a #guint8.
4142  *
4143  * Since: 2.4
4144  */
4145
4146
4147 /**
4148  * G_MAXULONG:
4149  *
4150  * The maximum value which can be held in a #gulong.
4151  */
4152
4153
4154 /**
4155  * G_MAXUSHORT:
4156  *
4157  * The maximum value which can be held in a #gushort.
4158  */
4159
4160
4161 /**
4162  * G_MINDOUBLE:
4163  *
4164  * The minimum positive value which can be held in a #gdouble.
4165  *
4166  * If you are interested in the smallest value which can be held
4167  * in a #gdouble, use -G_MAXDOUBLE.
4168  */
4169
4170
4171 /**
4172  * G_MINFLOAT:
4173  *
4174  * The minimum positive value which can be held in a #gfloat.
4175  *
4176  * If you are interested in the smallest value which can be held
4177  * in a #gfloat, use -G_MAXFLOAT.
4178  */
4179
4180
4181 /**
4182  * G_MININT:
4183  *
4184  * The minimum value which can be held in a #gint.
4185  */
4186
4187
4188 /**
4189  * G_MININT16:
4190  *
4191  * The minimum value which can be held in a #gint16.
4192  *
4193  * Since: 2.4
4194  */
4195
4196
4197 /**
4198  * G_MININT32:
4199  *
4200  * The minimum value which can be held in a #gint32.
4201  *
4202  * Since: 2.4
4203  */
4204
4205
4206 /**
4207  * G_MININT64:
4208  *
4209  * The minimum value which can be held in a #gint64.
4210  */
4211
4212
4213 /**
4214  * G_MININT8:
4215  *
4216  * The minimum value which can be held in a #gint8.
4217  *
4218  * Since: 2.4
4219  */
4220
4221
4222 /**
4223  * G_MINLONG:
4224  *
4225  * The minimum value which can be held in a #glong.
4226  */
4227
4228
4229 /**
4230  * G_MINOFFSET:
4231  *
4232  * The minimum value which can be held in a #goffset.
4233  */
4234
4235
4236 /**
4237  * G_MINSHORT:
4238  *
4239  * The minimum value which can be held in a #gshort.
4240  */
4241
4242
4243 /**
4244  * G_MINSSIZE:
4245  *
4246  * The minimum value which can be held in a #gssize.
4247  *
4248  * Since: 2.14
4249  */
4250
4251
4252 /**
4253  * G_N_ELEMENTS:
4254  * @arr: the array
4255  *
4256  * Determines the number of elements in an array. The array must be
4257  * declared so the compiler knows its size at compile-time; this
4258  * macro will not work on an array allocated on the heap, only static
4259  * arrays or arrays on the stack.
4260  */
4261
4262
4263 /**
4264  * G_ONCE_INIT:
4265  *
4266  * A #GOnce must be initialized with this macro before it can be used.
4267  *
4268  * |[
4269  *   GOnce my_once = G_ONCE_INIT;
4270  * ]|
4271  *
4272  * Since: 2.4
4273  */
4274
4275
4276 /**
4277  * G_OS_BEOS:
4278  *
4279  * This macro is defined only on BeOS. So you can bracket
4280  * BeOS-specific code in "&num;ifdef G_OS_BEOS".
4281  */
4282
4283
4284 /**
4285  * G_OS_UNIX:
4286  *
4287  * This macro is defined only on UNIX. So you can bracket
4288  * UNIX-specific code in "&num;ifdef G_OS_UNIX".
4289  */
4290
4291
4292 /**
4293  * G_OS_WIN32:
4294  *
4295  * This macro is defined only on Windows. So you can bracket
4296  * Windows-specific code in "&num;ifdef G_OS_WIN32".
4297  */
4298
4299
4300 /**
4301  * G_PASTE:
4302  * @identifier1: an identifier
4303  * @identifier2: an identifier
4304  *
4305  * Yields a new preprocessor pasted identifier
4306  * <code>identifier1identifier2</code> from its expanded
4307  * arguments @identifier1 and @identifier2. For example,
4308  * the following code:
4309  * |[
4310  * #define GET(traveller,method) G_PASTE(traveller_get_, method) (traveller)
4311  * const gchar *name = GET (traveller, name);
4312  * const gchar *quest = GET (traveller, quest);
4313  * GdkColor *favourite = GET (traveller, favourite_colour);
4314  * ]|
4315  *
4316  * is transformed by the preprocessor into:
4317  * |[
4318  * const gchar *name = traveller_get_name (traveller);
4319  * const gchar *quest = traveller_get_quest (traveller);
4320  * GdkColor *favourite = traveller_get_favourite_colour (traveller);
4321  * ]|
4322  *
4323  * Since: 2.20
4324  */
4325
4326
4327 /**
4328  * G_PDP_ENDIAN:
4329  *
4330  * Specifies one of the possible types of byte order
4331  * (currently unused). See #G_BYTE_ORDER.
4332  */
4333
4334
4335 /**
4336  * G_PI:
4337  *
4338  * The value of pi (ratio of circle's circumference to its diameter).
4339  */
4340
4341
4342 /**
4343  * G_PI_2:
4344  *
4345  * Pi divided by 2.
4346  */
4347
4348
4349 /**
4350  * G_PI_4:
4351  *
4352  * Pi divided by 4.
4353  */
4354
4355
4356 /**
4357  * G_PRIVATE_INIT:
4358  * @notify: a #GDestroyNotify
4359  *
4360  * A macro to assist with the static initialisation of a #GPrivate.
4361  *
4362  * This macro is useful for the case that a #GDestroyNotify function
4363  * should be associated the key.  This is needed when the key will be
4364  * used to point at memory that should be deallocated when the thread
4365  * exits.
4366  *
4367  * Additionally, the #GDestroyNotify will also be called on the previous
4368  * value stored in the key when g_private_replace() is used.
4369  *
4370  * If no #GDestroyNotify is needed, then use of this macro is not
4371  * required -- if the #GPrivate is declared in static scope then it will
4372  * be properly initialised by default (ie: to all zeros).  See the
4373  * examples below.
4374  *
4375  * |[
4376  * static GPrivate name_key = G_PRIVATE_INIT (g_free);
4377  *
4378  * // return value should not be freed
4379  * const gchar *
4380  * get_local_name (void)
4381  * {
4382  *   return g_private_get (&name_key);
4383  * }
4384  *
4385  * void
4386  * set_local_name (const gchar *name)
4387  * {
4388  *   g_private_replace (&name_key, g_strdup (name));
4389  * }
4390  *
4391  *
4392  * static GPrivate count_key;   // no free function
4393  *
4394  * gint
4395  * get_local_count (void)
4396  * {
4397  *   return GPOINTER_TO_INT (g_private_get (&count_key));
4398  * }
4399  *
4400  * void
4401  * set_local_count (gint count)
4402  * {
4403  *   g_private_set (&count_key, GINT_TO_POINTER (count));
4404  * }
4405  * ]|
4406  *
4407  * Since: 2.32
4408  */
4409
4410
4411 /**
4412  * G_SEARCHPATH_SEPARATOR:
4413  *
4414  * The search path separator character.
4415  * This is ':' on UNIX machines and ';' under Windows.
4416  */
4417
4418
4419 /**
4420  * G_SEARCHPATH_SEPARATOR_S:
4421  *
4422  * The search path separator as a string.
4423  * This is ":" on UNIX machines and ";" under Windows.
4424  */
4425
4426
4427 /**
4428  * G_SHELL_ERROR:
4429  *
4430  * Error domain for shell functions. Errors in this domain will be from
4431  * the #GShellError enumeration. See #GError for information on error
4432  * domains.
4433  */
4434
4435
4436 /**
4437  * G_SQRT2:
4438  *
4439  * The square root of two.
4440  */
4441
4442
4443 /**
4444  * G_STATIC_ASSERT:
4445  * @expr: a constant expression
4446  *
4447  * The G_STATIC_ASSERT macro lets the programmer check
4448  * a condition at compile time, the condition needs to
4449  * be compile time computable. The macro can be used in
4450  * any place where a <literal>typedef</literal> is valid.
4451  *
4452  * <note><para>
4453  * A <literal>typedef</literal> is generally allowed in
4454  * exactly the same places that a variable declaration is
4455  * allowed. For this reason, you should not use
4456  * <literal>G_STATIC_ASSERT</literal> in the middle of
4457  * blocks of code.
4458  * </para></note>
4459  *
4460  * The macro should only be used once per source code line.
4461  *
4462  * Since: 2.20
4463  */
4464
4465
4466 /**
4467  * G_STATIC_ASSERT_EXPR:
4468  * @expr: a constant expression
4469  *
4470  * The G_STATIC_ASSERT_EXPR macro lets the programmer check
4471  * a condition at compile time. The condition needs to be
4472  * compile time computable.
4473  *
4474  * Unlike <literal>G_STATIC_ASSERT</literal>, this macro
4475  * evaluates to an expression and, as such, can be used in
4476  * the middle of other expressions. Its value should be
4477  * ignored. This can be accomplished by placing it as
4478  * the first argument of a comma expression.
4479  *
4480  * |[
4481  * #define ADD_ONE_TO_INT(x) \
4482  *   (G_STATIC_ASSERT_EXPR(sizeof (x) == sizeof (int)), ((x) + 1))
4483  * ]|
4484  *
4485  * Since: 2.30
4486  */
4487
4488
4489 /**
4490  * G_STMT_END:
4491  *
4492  * Used within multi-statement macros so that they can be used in places
4493  * where only one statement is expected by the compiler.
4494  */
4495
4496
4497 /**
4498  * G_STMT_START:
4499  *
4500  * Used within multi-statement macros so that they can be used in places
4501  * where only one statement is expected by the compiler.
4502  */
4503
4504
4505 /**
4506  * G_STRFUNC:
4507  *
4508  * Expands to a string identifying the current function.
4509  *
4510  * Since: 2.4
4511  */
4512
4513
4514 /**
4515  * G_STRINGIFY:
4516  * @macro_or_string: a macro or a string
4517  *
4518  * Accepts a macro or a string and converts it into a string after
4519  * preprocessor argument expansion. For example, the following code:
4520  *
4521  * |[
4522  * #define AGE 27
4523  * const gchar *greeting = G_STRINGIFY (AGE) " today!";
4524  * ]|
4525  *
4526  * is transformed by the preprocessor into (code equivalent to):
4527  *
4528  * |[
4529  * const gchar *greeting = "27 today!";
4530  * ]|
4531  */
4532
4533
4534 /**
4535  * G_STRLOC:
4536  *
4537  * Expands to a string identifying the current code position.
4538  */
4539
4540
4541 /**
4542  * G_STRUCT_MEMBER:
4543  * @member_type: the type of the struct field
4544  * @struct_p: a pointer to a struct
4545  * @struct_offset: the offset of the field from the start of the struct,
4546  *     in bytes
4547  *
4548  * Returns a member of a structure at a given offset, using the given type.
4549  *
4550  * Returns: the struct member
4551  */
4552
4553
4554 /**
4555  * G_STRUCT_MEMBER_P:
4556  * @struct_p: a pointer to a struct
4557  * @struct_offset: the offset from the start of the struct, in bytes
4558  *
4559  * Returns an untyped pointer to a given offset of a struct.
4560  *
4561  * Returns: an untyped pointer to @struct_p plus @struct_offset bytes
4562  */
4563
4564
4565 /**
4566  * G_STRUCT_OFFSET:
4567  * @struct_type: a structure type, e.g. <structname>GtkWidget</structname>
4568  * @member: a field in the structure, e.g. <structfield>window</structfield>
4569  *
4570  * Returns the offset, in bytes, of a member of a struct.
4571  *
4572  * Returns: the offset of @member from the start of @struct_type
4573  */
4574
4575
4576 /**
4577  * G_STR_DELIMITERS:
4578  *
4579  * The standard delimiters, used in g_strdelimit().
4580  */
4581
4582
4583 /**
4584  * G_THREAD_ERROR:
4585  *
4586  * The error domain of the GLib thread subsystem.
4587  */
4588
4589
4590 /**
4591  * G_TRYLOCK:
4592  * @name: the name of the lock
4593  *
4594  * Works like g_mutex_trylock(), but for a lock defined with
4595  * #G_LOCK_DEFINE.
4596  *
4597  * Returns: %TRUE, if the lock could be locked.
4598  */
4599
4600
4601 /**
4602  * G_UNAVAILABLE:
4603  * @maj: the major version that introduced the symbol
4604  * @min: the minor version that introduced the symbol
4605  *
4606  * This macro can be used to mark a function declaration as unavailable.
4607  * It must be placed before the function declaration. Use of a function
4608  * that has been annotated with this macros will produce a compiler warning.
4609  *
4610  * Since: 2.32
4611  */
4612
4613
4614 /**
4615  * G_UNLIKELY:
4616  * @expr: the expression
4617  *
4618  * Hints the compiler that the expression is unlikely to evaluate to
4619  * a true value. The compiler may use this information for optimizations.
4620  *
4621  * |[
4622  * if (G_UNLIKELY (random () == 1))
4623  *   g_print ("a random one");
4624  * ]|
4625  *
4626  * Returns: the value of @expr
4627  * Since: 2.2
4628  */
4629
4630
4631 /**
4632  * G_UNLOCK:
4633  * @name: the name of the lock
4634  *
4635  * Works like g_mutex_unlock(), but for a lock defined with
4636  * #G_LOCK_DEFINE.
4637  */
4638
4639
4640 /**
4641  * G_USEC_PER_SEC:
4642  *
4643  * Number of microseconds in one second (1 million).
4644  * This macro is provided for code readability.
4645  */
4646
4647
4648 /**
4649  * G_VARIANT_PARSE_ERROR:
4650  *
4651  * Error domain for GVariant text format parsing.  Specific error codes
4652  * are not currently defined for this domain.  See #GError for
4653  * information on error domains.
4654  */
4655
4656
4657 /**
4658  * G_VA_COPY:
4659  * @ap1: the <type>va_list</type> variable to place a copy of @ap2 in
4660  * @ap2: a <type>va_list</type>
4661  *
4662  * Portable way to copy <type>va_list</type> variables.
4663  *
4664  * In order to use this function, you must include
4665  * <filename>string.h</filename> yourself, because this macro may
4666  * use memmove() and GLib does not include <filename>string.h</filename>
4667  * for you.
4668  */
4669
4670
4671 /**
4672  * G_WIN32_DLLMAIN_FOR_DLL_NAME:
4673  * @static: empty or "static"
4674  * @dll_name: the name of the (pointer to the) char array where
4675  *     the DLL name will be stored. If this is used, you must also
4676  *     include <filename>windows.h</filename>. If you need a more
4677  *     complex DLL entry point function, you cannot use this
4678  *
4679  * On Windows, this macro defines a DllMain() function that stores
4680  * the actual DLL name that the code being compiled will be included in.
4681  *
4682  * On non-Windows platforms, expands to nothing.
4683  */
4684
4685
4686 /**
4687  * G_WIN32_HAVE_WIDECHAR_API:
4688  *
4689  * On Windows, this macro defines an expression which evaluates to
4690  * %TRUE if the code is running on a version of Windows where the wide
4691  * character versions of the Win32 API functions, and the wide character
4692  * versions of the C library functions work. (They are always present in
4693  * the DLLs, but don't work on Windows 9x and Me.)
4694  *
4695  * On non-Windows platforms, it is not defined.
4696  *
4697  * Since: 2.6
4698  */
4699
4700
4701 /**
4702  * G_WIN32_IS_NT_BASED:
4703  *
4704  * On Windows, this macro defines an expression which evaluates to
4705  * %TRUE if the code is running on an NT-based Windows operating system.
4706  *
4707  * On non-Windows platforms, it is not defined.
4708  *
4709  * Since: 2.6
4710  */
4711
4712
4713 /**
4714  * MAX:
4715  * @a: a numeric value
4716  * @b: a numeric value
4717  *
4718  * Calculates the maximum of @a and @b.
4719  *
4720  * Returns: the maximum of @a and @b.
4721  */
4722
4723
4724 /**
4725  * MAXPATHLEN:
4726  *
4727  * Provided for UNIX emulation on Windows; equivalent to UNIX
4728  * macro %MAXPATHLEN, which is the maximum length of a filename
4729  * (including full path).
4730  */
4731
4732
4733 /**
4734  * MIN:
4735  * @a: a numeric value
4736  * @b: a numeric value
4737  *
4738  * Calculates the minimum of @a and @b.
4739  *
4740  * Returns: the minimum of @a and @b.
4741  */
4742
4743
4744 /**
4745  * NC_:
4746  * @Context: a message context, must be a string literal
4747  * @String: a message id, must be a string literal
4748  *
4749  * Only marks a string for translation, with context.
4750  * This is useful in situations where the translated strings can't
4751  * be directly used, e.g. in string array initializers. To get the
4752  * translated string, you should call g_dpgettext2() at runtime.
4753  *
4754  * |[
4755  * {
4756  *   static const char *messages[] = {
4757  *     NC_("some context", "some very meaningful message"),
4758  *     NC_("some context", "and another one")
4759  *   };
4760  *   const char *string;
4761  *   ...
4762  *   string
4763  *     = index &gt; 1 ? g_dpgettext2 (NULL, "some context", "a default message")
4764  *                    : g_dpgettext2 (NULL, "some context", messages[index]);
4765  *
4766  *   fputs (string);
4767  *   ...
4768  * }
4769  * ]|
4770  *
4771  * <note><para>If you are using the NC_() macro, you need to make sure
4772  * that you pass <option>--keyword=NC_:1c,2</option> to xgettext when
4773  * extracting messages. Note that this only works with GNU gettext >= 0.15.
4774  * Intltool has support for the NC_() macro since version 0.40.1.
4775  * </para></note>
4776  *
4777  * Since: 2.18
4778  */
4779
4780
4781 /**
4782  * NULL:
4783  *
4784  * Defines the standard %NULL pointer.
4785  */
4786
4787
4788 /**
4789  * N_:
4790  * @String: the string to be translated
4791  *
4792  * Only marks a string for translation. This is useful in situations
4793  * where the translated strings can't be directly used, e.g. in string
4794  * array initializers. To get the translated string, call gettext()
4795  * at runtime.
4796  * |[
4797  * {
4798  *   static const char *messages[] = {
4799  *     N_("some very meaningful message"),
4800  *     N_("and another one")
4801  *   };
4802  *   const char *string;
4803  *   ...
4804  *   string
4805  *     = index &gt; 1 ? _("a default message") : gettext (messages[index]);
4806  *
4807  *   fputs (string);
4808  *   ...
4809  * }
4810  * ]|
4811  *
4812  * Since: 2.4
4813  */
4814
4815
4816 /**
4817  * Q_:
4818  * @String: the string to be translated, with a '|'-separated prefix
4819  *     which must not be translated
4820  *
4821  * Like _(), but handles context in message ids. This has the advantage
4822  * that the string can be adorned with a prefix to guarantee uniqueness
4823  * and provide context to the translator.
4824  *
4825  * One use case given in the gettext manual is GUI translation, where one
4826  * could e.g. disambiguate two "Open" menu entries as "File|Open" and
4827  * "Printer|Open". Another use case is the string "Russian" which may
4828  * have to be translated differently depending on whether it's the name
4829  * of a character set or a language. This could be solved by using
4830  * "charset|Russian" and "language|Russian".
4831  *
4832  * See the C_() macro for a different way to mark up translatable strings
4833  * with context.
4834  *
4835  * <note><para>If you are using the Q_() macro, you need to make sure
4836  * that you pass <option>--keyword=Q_</option> to xgettext when extracting
4837  * messages. If you are using GNU gettext >= 0.15, you can also use
4838  * <option>--keyword=Q_:1g</option> to let xgettext split the context
4839  * string off into a msgctxt line in the po file.</para></note>
4840  *
4841  * Returns: the translated message
4842  * Since: 2.4
4843  */
4844
4845
4846 /**
4847  * SECTION:arrays
4848  * @title: Arrays
4849  * @short_description: arrays of arbitrary elements which grow
4850  *                     automatically as elements are added
4851  *
4852  * Arrays are similar to standard C arrays, except that they grow
4853  * automatically as elements are added.
4854  *
4855  * Array elements can be of any size (though all elements of one array
4856  * are the same size), and the array can be automatically cleared to
4857  * '0's and zero-terminated.
4858  *
4859  * To create a new array use g_array_new().
4860  *
4861  * To add elements to an array, use g_array_append_val(),
4862  * g_array_append_vals(), g_array_prepend_val(), and
4863  * g_array_prepend_vals().
4864  *
4865  * To access an element of an array, use g_array_index().
4866  *
4867  * To set the size of an array, use g_array_set_size().
4868  *
4869  * To free an array, use g_array_free().
4870  *
4871  * <example>
4872  *  <title>Using a #GArray to store #gint values</title>
4873  *  <programlisting>
4874  *   GArray *garray;
4875  *   gint i;
4876  *   /<!-- -->* We create a new array to store gint values.
4877  *      We don't want it zero-terminated or cleared to 0's. *<!-- -->/
4878  *   garray = g_array_new (FALSE, FALSE, sizeof (gint));
4879  *   for (i = 0; i &lt; 10000; i++)
4880  *     g_array_append_val (garray, i);
4881  *   for (i = 0; i &lt; 10000; i++)
4882  *     if (g_array_index (garray, gint, i) != i)
4883  *       g_print ("ERROR: got &percnt;d instead of &percnt;d\n",
4884  *                g_array_index (garray, gint, i), i);
4885  *   g_array_free (garray, TRUE);
4886  *  </programlisting>
4887  * </example>
4888  */
4889
4890
4891 /**
4892  * SECTION:arrays_byte
4893  * @title: Byte Arrays
4894  * @short_description: arrays of bytes
4895  *
4896  * #GByteArray is a mutable array of bytes based on #GArray, to provide arrays
4897  * of bytes which grow automatically as elements are added.
4898  *
4899  * To create a new #GByteArray use g_byte_array_new(). To add elements to a
4900  * #GByteArray, use g_byte_array_append(), and g_byte_array_prepend().
4901  *
4902  * To set the size of a #GByteArray, use g_byte_array_set_size().
4903  *
4904  * To free a #GByteArray, use g_byte_array_free().
4905  *
4906  * <example>
4907  *  <title>Using a #GByteArray</title>
4908  *  <programlisting>
4909  *   GByteArray *gbarray;
4910  *   gint i;
4911  *
4912  *   gbarray = g_byte_array_new (<!-- -->);
4913  *   for (i = 0; i &lt; 10000; i++)
4914  *     g_byte_array_append (gbarray, (guint8*) "abcd", 4);
4915  *
4916  *   for (i = 0; i &lt; 10000; i++)
4917  *     {
4918  *       g_assert (gbarray->data[4*i] == 'a');
4919  *       g_assert (gbarray->data[4*i+1] == 'b');
4920  *       g_assert (gbarray->data[4*i+2] == 'c');
4921  *       g_assert (gbarray->data[4*i+3] == 'd');
4922  *     }
4923  *
4924  *   g_byte_array_free (gbarray, TRUE);
4925  *  </programlisting>
4926  * </example>
4927  *
4928  * See #GBytes if you are interested in an immutable object representing a
4929  * sequence of bytes.
4930  */
4931
4932
4933 /**
4934  * SECTION:arrays_pointer
4935  * @title: Pointer Arrays
4936  * @short_description: arrays of pointers to any type of data, which
4937  *                     grow automatically as new elements are added
4938  *
4939  * Pointer Arrays are similar to Arrays but are used only for storing
4940  * pointers.
4941  *
4942  * <note><para>If you remove elements from the array, elements at the
4943  * end of the array are moved into the space previously occupied by the
4944  * removed element. This means that you should not rely on the index of
4945  * particular elements remaining the same. You should also be careful
4946  * when deleting elements while iterating over the array.</para></note>
4947  *
4948  * To create a pointer array, use g_ptr_array_new().
4949  *
4950  * To add elements to a pointer array, use g_ptr_array_add().
4951  *
4952  * To remove elements from a pointer array, use g_ptr_array_remove(),
4953  * g_ptr_array_remove_index() or g_ptr_array_remove_index_fast().
4954  *
4955  * To access an element of a pointer array, use g_ptr_array_index().
4956  *
4957  * To set the size of a pointer array, use g_ptr_array_set_size().
4958  *
4959  * To free a pointer array, use g_ptr_array_free().
4960  *
4961  * <example>
4962  *  <title>Using a #GPtrArray</title>
4963  *  <programlisting>
4964  *   GPtrArray *gparray;
4965  *   gchar *string1 = "one", *string2 = "two", *string3 = "three";
4966  *
4967  *   gparray = g_ptr_array_new (<!-- -->);
4968  *   g_ptr_array_add (gparray, (gpointer) string1);
4969  *   g_ptr_array_add (gparray, (gpointer) string2);
4970  *   g_ptr_array_add (gparray, (gpointer) string3);
4971  *
4972  *   if (g_ptr_array_index (gparray, 0) != (gpointer) string1)
4973  *     g_print ("ERROR: got &percnt;p instead of &percnt;p\n",
4974  *              g_ptr_array_index (gparray, 0), string1);
4975  *
4976  *   g_ptr_array_free (gparray, TRUE);
4977  *  </programlisting>
4978  * </example>
4979  */
4980
4981
4982 /**
4983  * SECTION:async_queues
4984  * @title: Asynchronous Queues
4985  * @short_description: asynchronous communication between threads
4986  * @see_also: #GThreadPool
4987  *
4988  * Often you need to communicate between different threads. In general
4989  * it's safer not to do this by shared memory, but by explicit message
4990  * passing. These messages only make sense asynchronously for
4991  * multi-threaded applications though, as a synchronous operation could
4992  * as well be done in the same thread.
4993  *
4994  * Asynchronous queues are an exception from most other GLib data
4995  * structures, as they can be used simultaneously from multiple threads
4996  * without explicit locking and they bring their own builtin reference
4997  * counting. This is because the nature of an asynchronous queue is that
4998  * it will always be used by at least 2 concurrent threads.
4999  *
5000  * For using an asynchronous queue you first have to create one with
5001  * g_async_queue_new(). #GAsyncQueue structs are reference counted,
5002  * use g_async_queue_ref() and g_async_queue_unref() to manage your
5003  * references.
5004  *
5005  * A thread which wants to send a message to that queue simply calls
5006  * g_async_queue_push() to push the message to the queue.
5007  *
5008  * A thread which is expecting messages from an asynchronous queue
5009  * simply calls g_async_queue_pop() for that queue. If no message is
5010  * available in the queue at that point, the thread is now put to sleep
5011  * until a message arrives. The message will be removed from the queue
5012  * and returned. The functions g_async_queue_try_pop() and
5013  * g_async_queue_timeout_pop() can be used to only check for the presence
5014  * of messages or to only wait a certain time for messages respectively.
5015  *
5016  * For almost every function there exist two variants, one that locks
5017  * the queue and one that doesn't. That way you can hold the queue lock
5018  * (acquire it with g_async_queue_lock() and release it with
5019  * g_async_queue_unlock()) over multiple queue accessing instructions.
5020  * This can be necessary to ensure the integrity of the queue, but should
5021  * only be used when really necessary, as it can make your life harder
5022  * if used unwisely. Normally you should only use the locking function
5023  * variants (those without the _unlocked suffix).
5024  *
5025  * In many cases, it may be more convenient to use #GThreadPool when
5026  * you need to distribute work to a set of worker threads instead of
5027  * using #GAsyncQueue manually. #GThreadPool uses a GAsyncQueue
5028  * internally.
5029  */
5030
5031
5032 /**
5033  * SECTION:atomic_operations
5034  * @title: Atomic Operations
5035  * @short_description: basic atomic integer and pointer operations
5036  * @see_also: #GMutex
5037  *
5038  * The following is a collection of compiler macros to provide atomic
5039  * access to integer and pointer-sized values.
5040  *
5041  * The macros that have 'int' in the name will operate on pointers to
5042  * #gint and #guint.  The macros with 'pointer' in the name will operate
5043  * on pointers to any pointer-sized value, including #gsize.  There is
5044  * no support for 64bit operations on platforms with 32bit pointers
5045  * because it is not generally possible to perform these operations
5046  * atomically.
5047  *
5048  * The get, set and exchange operations for integers and pointers
5049  * nominally operate on #gint and #gpointer, respectively.  Of the
5050  * arithmetic operations, the 'add' operation operates on (and returns)
5051  * signed integer values (#gint and #gssize) and the 'and', 'or', and
5052  * 'xor' operations operate on (and return) unsigned integer values
5053  * (#guint and #gsize).
5054  *
5055  * All of the operations act as a full compiler and (where appropriate)
5056  * hardware memory barrier.  Acquire and release or producer and
5057  * consumer barrier semantics are not available through this API.
5058  *
5059  * It is very important that all accesses to a particular integer or
5060  * pointer be performed using only this API and that different sizes of
5061  * operation are not mixed or used on overlapping memory regions.  Never
5062  * read or assign directly from or to a value -- always use this API.
5063  *
5064  * For simple reference counting purposes you should use
5065  * g_atomic_int_inc() and g_atomic_int_dec_and_test().  Other uses that
5066  * fall outside of simple reference counting patterns are prone to
5067  * subtle bugs and occasionally undefined behaviour.  It is also worth
5068  * noting that since all of these operations require global
5069  * synchronisation of the entire machine, they can be quite slow.  In
5070  * the case of performing multiple atomic operations it can often be
5071  * faster to simply acquire a mutex lock around the critical area,
5072  * perform the operations normally and then release the lock.
5073  */
5074
5075
5076 /**
5077  * SECTION:base64
5078  * @title: Base64 Encoding
5079  * @short_description: encodes and decodes data in Base64 format
5080  *
5081  * Base64 is an encoding that allows a sequence of arbitrary bytes to be
5082  * encoded as a sequence of printable ASCII characters. For the definition
5083  * of Base64, see <ulink url="http://www.ietf.org/rfc/rfc1421.txt">RFC
5084  * 1421</ulink> or <ulink url="http://www.ietf.org/rfc/rfc2045.txt">RFC
5085  * 2045</ulink>. Base64 is most commonly used as a MIME transfer encoding
5086  * for email.
5087  *
5088  * GLib supports incremental encoding using g_base64_encode_step() and
5089  * g_base64_encode_close(). Incremental decoding can be done with
5090  * g_base64_decode_step(). To encode or decode data in one go, use
5091  * g_base64_encode() or g_base64_decode(). To avoid memory allocation when
5092  * decoding, you can use g_base64_decode_inplace().
5093  *
5094  * Support for Base64 encoding has been added in GLib 2.12.
5095  */
5096
5097
5098 /**
5099  * SECTION:bookmarkfile
5100  * @title: Bookmark file parser
5101  * @short_description: parses files containing bookmarks
5102  *
5103  * GBookmarkFile lets you parse, edit or create files containing bookmarks
5104  * to URI, along with some meta-data about the resource pointed by the URI
5105  * like its MIME type, the application that is registering the bookmark and
5106  * the icon that should be used to represent the bookmark. The data is stored
5107  * using the
5108  * <ulink url="http://www.gnome.org/~ebassi/bookmark-spec">Desktop Bookmark
5109  * Specification</ulink>.
5110  *
5111  * The syntax of the bookmark files is described in detail inside the Desktop
5112  * Bookmark Specification, here is a quick summary: bookmark files use a
5113  * sub-class of the <ulink url="">XML Bookmark Exchange Language</ulink>
5114  * specification, consisting of valid UTF-8 encoded XML, under the
5115  * <literal>xbel</literal> root element; each bookmark is stored inside a
5116  * <literal>bookmark</literal> element, using its URI: no relative paths can
5117  * be used inside a bookmark file. The bookmark may have a user defined title
5118  * and description, to be used instead of the URI. Under the
5119  * <literal>metadata</literal> element, with its <literal>owner</literal>
5120  * attribute set to <literal>http://freedesktop.org</literal>, is stored the
5121  * meta-data about a resource pointed by its URI. The meta-data consists of
5122  * the resource's MIME type; the applications that have registered a bookmark;
5123  * the groups to which a bookmark belongs to; a visibility flag, used to set
5124  * the bookmark as "private" to the applications and groups that has it
5125  * registered; the URI and MIME type of an icon, to be used when displaying
5126  * the bookmark inside a GUI.
5127  * |[<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" href="../../../../glib/tests/bookmarks.xbel"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include>]|
5128  *
5129  * A bookmark file might contain more than one bookmark; each bookmark
5130  * is accessed through its URI.
5131  *
5132  * The important caveat of bookmark files is that when you add a new
5133  * bookmark you must also add the application that is registering it, using
5134  * g_bookmark_file_add_application() or g_bookmark_file_set_app_info().
5135  * If a bookmark has no applications then it won't be dumped when creating
5136  * the on disk representation, using g_bookmark_file_to_data() or
5137  * g_bookmark_file_to_file().
5138  *
5139  * The #GBookmarkFile parser was added in GLib 2.12.
5140  */
5141
5142
5143 /**
5144  * SECTION:byte_order
5145  * @title: Byte Order Macros
5146  * @short_description: a portable way to convert between different byte orders
5147  *
5148  * These macros provide a portable way to determine the host byte order
5149  * and to convert values between different byte orders.
5150  *
5151  * The byte order is the order in which bytes are stored to create larger
5152  * data types such as the #gint and #glong values.
5153  * The host byte order is the byte order used on the current machine.
5154  *
5155  * Some processors store the most significant bytes (i.e. the bytes that
5156  * hold the largest part of the value) first. These are known as big-endian
5157  * processors. Other processors (notably the x86 family) store the most
5158  * significant byte last. These are known as little-endian processors.
5159  *
5160  * Finally, to complicate matters, some other processors store the bytes in
5161  * a rather curious order known as PDP-endian. For a 4-byte word, the 3rd
5162  * most significant byte is stored first, then the 4th, then the 1st and
5163  * finally the 2nd.
5164  *
5165  * Obviously there is a problem when these different processors communicate
5166  * with each other, for example over networks or by using binary file formats.
5167  * This is where these macros come in. They are typically used to convert
5168  * values into a byte order which has been agreed on for use when
5169  * communicating between different processors. The Internet uses what is
5170  * known as 'network byte order' as the standard byte order (which is in
5171  * fact the big-endian byte order).
5172  *
5173  * Note that the byte order conversion macros may evaluate their arguments
5174  * multiple times, thus you should not use them with arguments which have
5175  * side-effects.
5176  */
5177
5178
5179 /**
5180  * SECTION:checksum
5181  * @title: Data Checksums
5182  * @short_description: computes the checksum for data
5183  *
5184  * GLib provides a generic API for computing checksums (or "digests")
5185  * for a sequence of arbitrary bytes, using various hashing algorithms
5186  * like MD5, SHA-1 and SHA-256. Checksums are commonly used in various
5187  * environments and specifications.
5188  *
5189  * GLib supports incremental checksums using the GChecksum data
5190  * structure, by calling g_checksum_update() as long as there's data
5191  * available and then using g_checksum_get_string() or
5192  * g_checksum_get_digest() to compute the checksum and return it either
5193  * as a string in hexadecimal form, or as a raw sequence of bytes. To
5194  * compute the checksum for binary blobs and NUL-terminated strings in
5195  * one go, use the convenience functions g_compute_checksum_for_data()
5196  * and g_compute_checksum_for_string(), respectively.
5197  *
5198  * Support for checksums has been added in GLib 2.16
5199  */
5200
5201
5202 /**
5203  * SECTION:conversions
5204  * @title: Character Set Conversion
5205  * @short_description: convert strings between different character sets
5206  *
5207  * The g_convert() family of function wraps the functionality of iconv(). In
5208  * addition to pure character set conversions, GLib has functions to deal
5209  * with the extra complications of encodings for file names.
5210  *
5211  * <refsect2 id="file-name-encodings">
5212  * <title>File Name Encodings</title>
5213  * <para>
5214  * Historically, Unix has not had a defined encoding for file
5215  * names:  a file name is valid as long as it does not have path
5216  * separators in it ("/").  However, displaying file names may
5217  * require conversion:  from the character set in which they were
5218  * created, to the character set in which the application
5219  * operates.  Consider the Spanish file name
5220  * "<filename>Presentaci&oacute;n.sxi</filename>".  If the
5221  * application which created it uses ISO-8859-1 for its encoding,
5222  * </para>
5223  * <programlisting id="filename-iso8859-1">
5224  * Character:  P  r  e  s  e  n  t  a  c  i  &oacute;  n  .  s  x  i
5225  * Hex code:   50 72 65 73 65 6e 74 61 63 69 f3 6e 2e 73 78 69
5226  * </programlisting>
5227  * <para>
5228  * However, if the application use UTF-8, the actual file name on
5229  * disk would look like this:
5230  * </para>
5231  * <programlisting id="filename-utf-8">
5232  * Character:  P  r  e  s  e  n  t  a  c  i  &oacute;     n  .  s  x  i
5233  * Hex code:   50 72 65 73 65 6e 74 61 63 69 c3 b3 6e 2e 73 78 69
5234  * </programlisting>
5235  * <para>
5236  * Glib uses UTF-8 for its strings, and GUI toolkits like GTK+
5237  * that use Glib do the same thing.  If you get a file name from
5238  * the file system, for example, from readdir(3) or from g_dir_read_name(),
5239  * and you wish to display the file name to the user, you
5240  * <emphasis>will</emphasis> need to convert it into UTF-8.  The
5241  * opposite case is when the user types the name of a file he
5242  * wishes to save:  the toolkit will give you that string in
5243  * UTF-8 encoding, and you will need to convert it to the
5244  * character set used for file names before you can create the
5245  * file with open(2) or fopen(3).
5246  * </para>
5247  * <para>
5248  * By default, Glib assumes that file names on disk are in UTF-8
5249  * encoding.  This is a valid assumption for file systems which
5250  * were created relatively recently:  most applications use UTF-8
5251  * encoding for their strings, and that is also what they use for
5252  * the file names they create.  However, older file systems may
5253  * still contain file names created in "older" encodings, such as
5254  * ISO-8859-1. In this case, for compatibility reasons, you may
5255  * want to instruct Glib to use that particular encoding for file
5256  * names rather than UTF-8.  You can do this by specifying the
5257  * encoding for file names in the <link
5258  * linkend="G_FILENAME_ENCODING"><envar>G_FILENAME_ENCODING</envar></link>
5259  * environment variable.  For example, if your installation uses
5260  * ISO-8859-1 for file names, you can put this in your
5261  * <filename>~/.profile</filename>:
5262  * </para>
5263  * <programlisting>
5264  * export G_FILENAME_ENCODING=ISO-8859-1
5265  * </programlisting>
5266  * <para>
5267  * Glib provides the functions g_filename_to_utf8() and
5268  * g_filename_from_utf8() to perform the necessary conversions. These
5269  * functions convert file names from the encoding specified in
5270  * <envar>G_FILENAME_ENCODING</envar> to UTF-8 and vice-versa.
5271  * <xref linkend="file-name-encodings-diagram"/> illustrates how
5272  * these functions are used to convert between UTF-8 and the
5273  * encoding for file names in the file system.
5274  * </para>
5275  * <figure id="file-name-encodings-diagram">
5276  * <title>Conversion between File Name Encodings</title>
5277  * <graphic fileref="file-name-encodings.png" format="PNG"/>
5278  * </figure>
5279  * <refsect3 id="file-name-encodings-checklist">
5280  * <title>Checklist for Application Writers</title>
5281  * <para>
5282  * This section is a practical summary of the detailed
5283  * description above.  You can use this as a checklist of
5284  * things to do to make sure your applications process file
5285  * name encodings correctly.
5286  * </para>
5287  * <orderedlist>
5288  * <listitem><para>
5289  * If you get a file name from the file system from a function
5290  * such as readdir(3) or gtk_file_chooser_get_filename(),
5291  * you do not need to do any conversion to pass that
5292  * file name to functions like open(2), rename(2), or
5293  * fopen(3) &mdash; those are "raw" file names which the file
5294  * system understands.
5295  * </para></listitem>
5296  * <listitem><para>
5297  * If you need to display a file name, convert it to UTF-8 first by
5298  * using g_filename_to_utf8(). If conversion fails, display a string like
5299  * "<literal>Unknown file name</literal>". <emphasis>Do not</emphasis>
5300  * convert this string back into the encoding used for file names if you
5301  * wish to pass it to the file system; use the original file name instead.
5302  * For example, the document window of a word processor could display
5303  * "Unknown file name" in its title bar but still let the user save the
5304  * file, as it would keep the raw file name internally. This can happen
5305  * if the user has not set the <envar>G_FILENAME_ENCODING</envar>
5306  * environment variable even though he has files whose names are not
5307  * encoded in UTF-8.
5308  * </para></listitem>
5309  * <listitem><para>
5310  * If your user interface lets the user type a file name for saving or
5311  * renaming, convert it to the encoding used for file names in the file
5312  * system by using g_filename_from_utf8(). Pass the converted file name
5313  * to functions like fopen(3). If conversion fails, ask the user to enter
5314  * a different file name. This can happen if the user types Japanese
5315  * characters when <envar>G_FILENAME_ENCODING</envar> is set to
5316  * <literal>ISO-8859-1</literal>, for example.
5317  * </para></listitem>
5318  * </orderedlist>
5319  * </refsect3>
5320  * </refsect2>
5321  */
5322
5323
5324 /**
5325  * SECTION:datalist
5326  * @title: Keyed Data Lists
5327  * @short_description: lists of data elements which are accessible by a
5328  *                     string or GQuark identifier
5329  *
5330  * Keyed data lists provide lists of arbitrary data elements which can
5331  * be accessed either with a string or with a #GQuark corresponding to
5332  * the string.
5333  *
5334  * The #GQuark methods are quicker, since the strings have to be
5335  * converted to #GQuarks anyway.
5336  *
5337  * Data lists are used for associating arbitrary data with #GObjects,
5338  * using g_object_set_data() and related functions.
5339  *
5340  * To create a datalist, use g_datalist_init().
5341  *
5342  * To add data elements to a datalist use g_datalist_id_set_data(),
5343  * g_datalist_id_set_data_full(), g_datalist_set_data() and
5344  * g_datalist_set_data_full().
5345  *
5346  * To get data elements from a datalist use g_datalist_id_get_data()
5347  * and g_datalist_get_data().
5348  *
5349  * To iterate over all data elements in a datalist use
5350  * g_datalist_foreach() (not thread-safe).
5351  *
5352  * To remove data elements from a datalist use
5353  * g_datalist_id_remove_data() and g_datalist_remove_data().
5354  *
5355  * To remove all data elements from a datalist, use g_datalist_clear().
5356  */
5357
5358
5359 /**
5360  * SECTION:datasets
5361  * @title: Datasets
5362  * @short_description: associate groups of data elements with
5363  *                     particular memory locations
5364  *
5365  * Datasets associate groups of data elements with particular memory
5366  * locations. These are useful if you need to associate data with a
5367  * structure returned from an external library. Since you cannot modify
5368  * the structure, you use its location in memory as the key into a
5369  * dataset, where you can associate any number of data elements with it.
5370  *
5371  * There are two forms of most of the dataset functions. The first form
5372  * uses strings to identify the data elements associated with a
5373  * location. The second form uses #GQuark identifiers, which are
5374  * created with a call to g_quark_from_string() or
5375  * g_quark_from_static_string(). The second form is quicker, since it
5376  * does not require looking up the string in the hash table of #GQuark
5377  * identifiers.
5378  *
5379  * There is no function to create a dataset. It is automatically
5380  * created as soon as you add elements to it.
5381  *
5382  * To add data elements to a dataset use g_dataset_id_set_data(),
5383  * g_dataset_id_set_data_full(), g_dataset_set_data() and
5384  * g_dataset_set_data_full().
5385  *
5386  * To get data elements from a dataset use g_dataset_id_get_data() and
5387  * g_dataset_get_data().
5388  *
5389  * To iterate over all data elements in a dataset use
5390  * g_dataset_foreach() (not thread-safe).
5391  *
5392  * To remove data elements from a dataset use
5393  * g_dataset_id_remove_data() and g_dataset_remove_data().
5394  *
5395  * To destroy a dataset, use g_dataset_destroy().
5396  */
5397
5398
5399 /**
5400  * SECTION:date
5401  * @title: Date and Time Functions
5402  * @short_description: calendrical calculations and miscellaneous time stuff
5403  *
5404  * The #GDate data structure represents a day between January 1, Year 1,
5405  * and sometime a few thousand years in the future (right now it will go
5406  * to the year 65535 or so, but g_date_set_parse() only parses up to the
5407  * year 8000 or so - just count on "a few thousand"). #GDate is meant to
5408  * represent everyday dates, not astronomical dates or historical dates
5409  * or ISO timestamps or the like. It extrapolates the current Gregorian
5410  * calendar forward and backward in time; there is no attempt to change
5411  * the calendar to match time periods or locations. #GDate does not store
5412  * time information; it represents a <emphasis>day</emphasis>.
5413  *
5414  * The #GDate implementation has several nice features; it is only a
5415  * 64-bit struct, so storing large numbers of dates is very efficient. It
5416  * can keep both a Julian and day-month-year representation of the date,
5417  * since some calculations are much easier with one representation or the
5418  * other. A Julian representation is simply a count of days since some
5419  * fixed day in the past; for #GDate the fixed day is January 1, 1 AD.
5420  * ("Julian" dates in the #GDate API aren't really Julian dates in the
5421  * technical sense; technically, Julian dates count from the start of the
5422  * Julian period, Jan 1, 4713 BC).
5423  *
5424  * #GDate is simple to use. First you need a "blank" date; you can get a
5425  * dynamically allocated date from g_date_new(), or you can declare an
5426  * automatic variable or array and initialize it to a sane state by
5427  * calling g_date_clear(). A cleared date is sane; it's safe to call
5428  * g_date_set_dmy() and the other mutator functions to initialize the
5429  * value of a cleared date. However, a cleared date is initially
5430  * <emphasis>invalid</emphasis>, meaning that it doesn't represent a day
5431  * that exists. It is undefined to call any of the date calculation
5432  * routines on an invalid date. If you obtain a date from a user or other
5433  * unpredictable source, you should check its validity with the
5434  * g_date_valid() predicate. g_date_valid() is also used to check for
5435  * errors with g_date_set_parse() and other functions that can
5436  * fail. Dates can be invalidated by calling g_date_clear() again.
5437  *
5438  * <emphasis>It is very important to use the API to access the #GDate
5439  * struct.</emphasis> Often only the day-month-year or only the Julian
5440  * representation is valid. Sometimes neither is valid. Use the API.
5441  *
5442  * GLib also features #GDateTime which represents a precise time.
5443  */
5444
5445
5446 /**
5447  * SECTION:date-time
5448  * @title: GDateTime
5449  * @short_description: a structure representing Date and Time
5450  * @see_also: #GTimeZone
5451  *
5452  * #GDateTime is a structure that combines a Gregorian date and time
5453  * into a single structure.  It provides many conversion and methods to
5454  * manipulate dates and times.  Time precision is provided down to
5455  * microseconds and the time can range (proleptically) from 0001-01-01
5456  * 00:00:00 to 9999-12-31 23:59:59.999999.  #GDateTime follows POSIX
5457  * time in the sense that it is oblivious to leap seconds.
5458  *
5459  * #GDateTime is an immutable object; once it has been created it cannot
5460  * be modified further.  All modifiers will create a new #GDateTime.
5461  * Nearly all such functions can fail due to the date or time going out
5462  * of range, in which case %NULL will be returned.
5463  *
5464  * #GDateTime is reference counted: the reference count is increased by calling
5465  * g_date_time_ref() and decreased by calling g_date_time_unref(). When the
5466  * reference count drops to 0, the resources allocated by the #GDateTime
5467  * structure are released.
5468  *
5469  * Many parts of the API may produce non-obvious results.  As an
5470  * example, adding two months to January 31st will yield March 31st
5471  * whereas adding one month and then one month again will yield either
5472  * March 28th or March 29th.  Also note that adding 24 hours is not
5473  * always the same as adding one day (since days containing daylight
5474  * savings time transitions are either 23 or 25 hours in length).
5475  *
5476  * #GDateTime is available since GLib 2.26.
5477  */
5478
5479
5480 /**
5481  * SECTION:error_reporting
5482  * @Title: Error Reporting
5483  * @Short_description: a system for reporting errors
5484  *
5485  * GLib provides a standard method of reporting errors from a called
5486  * function to the calling code. (This is the same problem solved by
5487  * exceptions in other languages.) It's important to understand that
5488  * this method is both a <emphasis>data type</emphasis> (the #GError
5489  * object) and a <emphasis>set of rules.</emphasis> If you use #GError
5490  * incorrectly, then your code will not properly interoperate with other
5491  * code that uses #GError, and users of your API will probably get confused.
5492  *
5493  * First and foremost: <emphasis>#GError should only be used to report
5494  * recoverable runtime errors, never to report programming
5495  * errors.</emphasis> If the programmer has screwed up, then you should
5496  * use g_warning(), g_return_if_fail(), g_assert(), g_error(), or some
5497  * similar facility. (Incidentally, remember that the g_error() function
5498  * should <emphasis>only</emphasis> be used for programming errors, it
5499  * should not be used to print any error reportable via #GError.)
5500  *
5501  * Examples of recoverable runtime errors are "file not found" or
5502  * "failed to parse input." Examples of programming errors are "NULL
5503  * passed to strcmp()" or "attempted to free the same pointer twice."
5504  * These two kinds of errors are fundamentally different: runtime errors
5505  * should be handled or reported to the user, programming errors should
5506  * be eliminated by fixing the bug in the program. This is why most
5507  * functions in GLib and GTK+ do not use the #GError facility.
5508  *
5509  * Functions that can fail take a return location for a #GError as their
5510  * last argument. For example:
5511  * |[
5512  * gboolean g_file_get_contents (const gchar  *filename,
5513  *                               gchar       **contents,
5514  *                               gsize        *length,
5515  *                               GError      **error);
5516  * ]|
5517  * If you pass a non-%NULL value for the <literal>error</literal>
5518  * argument, it should point to a location where an error can be placed.
5519  * For example:
5520  * |[
5521  * gchar *contents;
5522  * GError *err = NULL;
5523  * g_file_get_contents ("foo.txt", &amp;contents, NULL, &amp;err);
5524  * g_assert ((contents == NULL &amp;&amp; err != NULL) || (contents != NULL &amp;&amp; err == NULL));
5525  * if (err != NULL)
5526  *   {
5527  *     /&ast; Report error to user, and free error &ast;/
5528  *     g_assert (contents == NULL);
5529  *     fprintf (stderr, "Unable to read file: &percnt;s\n", err->message);
5530  *     g_error_free (err);
5531  *   }
5532  * else
5533  *   {
5534  *     /&ast; Use file contents &ast;/
5535  *     g_assert (contents != NULL);
5536  *   }
5537  * ]|
5538  * Note that <literal>err != NULL</literal> in this example is a
5539  * <emphasis>reliable</emphasis> indicator of whether
5540  * g_file_get_contents() failed. Additionally, g_file_get_contents()
5541  * returns a boolean which indicates whether it was successful.
5542  *
5543  * Because g_file_get_contents() returns %FALSE on failure, if you
5544  * are only interested in whether it failed and don't need to display
5545  * an error message, you can pass %NULL for the <literal>error</literal>
5546  * argument:
5547  * |[
5548  * if (g_file_get_contents ("foo.txt", &amp;contents, NULL, NULL)) /&ast; ignore errors &ast;/
5549  *   /&ast; no error occurred &ast;/ ;
5550  * else
5551  *   /&ast; error &ast;/ ;
5552  * ]|
5553  *
5554  * The #GError object contains three fields: <literal>domain</literal>
5555  * indicates the module the error-reporting function is located in,
5556  * <literal>code</literal> indicates the specific error that occurred,
5557  * and <literal>message</literal> is a user-readable error message with
5558  * as many details as possible. Several functions are provided to deal
5559  * with an error received from a called function: g_error_matches()
5560  * returns %TRUE if the error matches a given domain and code,
5561  * g_propagate_error() copies an error into an error location (so the
5562  * calling function will receive it), and g_clear_error() clears an
5563  * error location by freeing the error and resetting the location to
5564  * %NULL. To display an error to the user, simply display
5565  * <literal>error-&gt;message</literal>, perhaps along with additional
5566  * context known only to the calling function (the file being opened,
5567  * or whatever -- though in the g_file_get_contents() case,
5568  * <literal>error-&gt;message</literal> already contains a filename).
5569  *
5570  * When implementing a function that can report errors, the basic
5571  * tool is g_set_error(). Typically, if a fatal error occurs you
5572  * want to g_set_error(), then return immediately. g_set_error()
5573  * does nothing if the error location passed to it is %NULL.
5574  * Here's an example:
5575  * |[
5576  * gint
5577  * foo_open_file (GError **error)
5578  * {
5579  *   gint fd;
5580  *
5581  *   fd = open ("file.txt", O_RDONLY);
5582  *
5583  *   if (fd &lt; 0)
5584  *     {
5585  *       g_set_error (error,
5586  *                    FOO_ERROR,                 /&ast; error domain &ast;/
5587  *                    FOO_ERROR_BLAH,            /&ast; error code &ast;/
5588  *                    "Failed to open file: &percnt;s", /&ast; error message format string &ast;/
5589  *                    g_strerror (errno));
5590  *       return -1;
5591  *     }
5592  *   else
5593  *     return fd;
5594  * }
5595  * ]|
5596  *
5597  * Things are somewhat more complicated if you yourself call another
5598  * function that can report a #GError. If the sub-function indicates
5599  * fatal errors in some way other than reporting a #GError, such as
5600  * by returning %TRUE on success, you can simply do the following:
5601  * |[
5602  * gboolean
5603  * my_function_that_can_fail (GError **err)
5604  * {
5605  *   g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
5606  *
5607  *   if (!sub_function_that_can_fail (err))
5608  *     {
5609  *       /&ast; assert that error was set by the sub-function &ast;/
5610  *       g_assert (err == NULL || *err != NULL);
5611  *       return FALSE;
5612  *     }
5613  *
5614  *   /&ast; otherwise continue, no error occurred &ast;/
5615  *   g_assert (err == NULL || *err == NULL);
5616  * }
5617  * ]|
5618  *
5619  * If the sub-function does not indicate errors other than by
5620  * reporting a #GError, you need to create a temporary #GError
5621  * since the passed-in one may be %NULL. g_propagate_error() is
5622  * intended for use in this case.
5623  * |[
5624  * gboolean
5625  * my_function_that_can_fail (GError **err)
5626  * {
5627  *   GError *tmp_error;
5628  *
5629  *   g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
5630  *
5631  *   tmp_error = NULL;
5632  *   sub_function_that_can_fail (&amp;tmp_error);
5633  *
5634  *   if (tmp_error != NULL)
5635  *     {
5636  *       /&ast; store tmp_error in err, if err != NULL,
5637  *        &ast; otherwise call g_error_free() on tmp_error
5638  *        &ast;/
5639  *       g_propagate_error (err, tmp_error);
5640  *       return FALSE;
5641  *     }
5642  *
5643  *   /&ast; otherwise continue, no error occurred &ast;/
5644  * }
5645  * ]|
5646  *
5647  * Error pileups are always a bug. For example, this code is incorrect:
5648  * |[
5649  * gboolean
5650  * my_function_that_can_fail (GError **err)
5651  * {
5652  *   GError *tmp_error;
5653  *
5654  *   g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
5655  *
5656  *   tmp_error = NULL;
5657  *   sub_function_that_can_fail (&amp;tmp_error);
5658  *   other_function_that_can_fail (&amp;tmp_error);
5659  *
5660  *   if (tmp_error != NULL)
5661  *     {
5662  *       g_propagate_error (err, tmp_error);
5663  *       return FALSE;
5664  *     }
5665  * }
5666  * ]|
5667  * <literal>tmp_error</literal> should be checked immediately after
5668  * sub_function_that_can_fail(), and either cleared or propagated
5669  * upward. The rule is: <emphasis>after each error, you must either
5670  * handle the error, or return it to the calling function</emphasis>.
5671  * Note that passing %NULL for the error location is the equivalent
5672  * of handling an error by always doing nothing about it. So the
5673  * following code is fine, assuming errors in sub_function_that_can_fail()
5674  * are not fatal to my_function_that_can_fail():
5675  * |[
5676  * gboolean
5677  * my_function_that_can_fail (GError **err)
5678  * {
5679  *   GError *tmp_error;
5680  *
5681  *   g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
5682  *
5683  *   sub_function_that_can_fail (NULL); /&ast; ignore errors &ast;/
5684  *
5685  *   tmp_error = NULL;
5686  *   other_function_that_can_fail (&amp;tmp_error);
5687  *
5688  *   if (tmp_error != NULL)
5689  *     {
5690  *       g_propagate_error (err, tmp_error);
5691  *       return FALSE;
5692  *     }
5693  * }
5694  * ]|
5695  *
5696  * Note that passing %NULL for the error location
5697  * <emphasis>ignores</emphasis> errors; it's equivalent to
5698  * <literal>try { sub_function_that_can_fail (); } catch (...) {}</literal>
5699  * in C++. It does <emphasis>not</emphasis> mean to leave errors
5700  * unhandled; it means to handle them by doing nothing.
5701  *
5702  * Error domains and codes are conventionally named as follows:
5703  * <itemizedlist>
5704  * <listitem><para>
5705  *   The error domain is called
5706  *   <literal>&lt;NAMESPACE&gt;_&lt;MODULE&gt;_ERROR</literal>,
5707  *   for example %G_SPAWN_ERROR or %G_THREAD_ERROR:
5708  *   |[
5709  * #define G_SPAWN_ERROR g_spawn_error_quark ()
5710  *
5711  * GQuark
5712  * g_spawn_error_quark (void)
5713  * {
5714  *   return g_quark_from_static_string ("g-spawn-error-quark");
5715  * }
5716  *   ]|
5717  * </para></listitem>
5718  * <listitem><para>
5719  *   The quark function for the error domain is called
5720  *   <literal>&lt;namespace&gt;_&lt;module&gt;_error_quark</literal>,
5721  *   for example g_spawn_error_quark() or g_thread_error_quark().
5722  * </para></listitem>
5723  * <listitem><para>
5724  *   The error codes are in an enumeration called
5725  *   <literal>&lt;Namespace&gt;&lt;Module&gt;Error</literal>;
5726  *   for example,#GThreadError or #GSpawnError.
5727  * </para></listitem>
5728  * <listitem><para>
5729  *   Members of the error code enumeration are called
5730  *   <literal>&lt;NAMESPACE&gt;_&lt;MODULE&gt;_ERROR_&lt;CODE&gt;</literal>,
5731  *   for example %G_SPAWN_ERROR_FORK or %G_THREAD_ERROR_AGAIN.
5732  * </para></listitem>
5733  * <listitem><para>
5734  *   If there's a "generic" or "unknown" error code for unrecoverable
5735  *   errors it doesn't make sense to distinguish with specific codes,
5736  *   it should be called <literal>&lt;NAMESPACE&gt;_&lt;MODULE&gt;_ERROR_FAILED</literal>,
5737  *   for example %G_SPAWN_ERROR_FAILED.
5738  * </para></listitem>
5739  * </itemizedlist>
5740  *
5741  * Summary of rules for use of #GError:
5742  * <itemizedlist>
5743  * <listitem><para>
5744  *   Do not report programming errors via #GError.
5745  * </para></listitem>
5746  * <listitem><para>
5747  *   The last argument of a function that returns an error should
5748  *   be a location where a #GError can be placed (i.e. "#GError** error").
5749  *   If #GError is used with varargs, the #GError** should be the last
5750  *   argument before the "...".
5751  * </para></listitem>
5752  * <listitem><para>
5753  *   The caller may pass %NULL for the #GError** if they are not interested
5754  *   in details of the exact error that occurred.
5755  * </para></listitem>
5756  * <listitem><para>
5757  *   If %NULL is passed for the #GError** argument, then errors should
5758  *   not be returned to the caller, but your function should still
5759  *   abort and return if an error occurs. That is, control flow should
5760  *   not be affected by whether the caller wants to get a #GError.
5761  * </para></listitem>
5762  * <listitem><para>
5763  *   If a #GError is reported, then your function by definition
5764  *   <emphasis>had a fatal failure and did not complete whatever
5765  *   it was supposed to do</emphasis>. If the failure was not fatal,
5766  *   then you handled it and you should not report it. If it was fatal,
5767  *   then you must report it and discontinue whatever you were doing
5768  *   immediately.
5769  * </para></listitem>
5770  * <listitem><para>
5771  *   If a #GError is reported, out parameters are not guaranteed to
5772  *   be set to any defined value.
5773  * </para></listitem>
5774  * <listitem><para>
5775  *   A #GError* must be initialized to %NULL before passing its address
5776  *   to a function that can report errors.
5777  * </para></listitem>
5778  * <listitem><para>
5779  *   "Piling up" errors is always a bug. That is, if you assign a
5780  *   new #GError to a #GError* that is non-%NULL, thus overwriting
5781  *   the previous error, it indicates that you should have aborted
5782  *   the operation instead of continuing. If you were able to continue,
5783  *   you should have cleared the previous error with g_clear_error().
5784  *   g_set_error() will complain if you pile up errors.
5785  * </para></listitem>
5786  * <listitem><para>
5787  *   By convention, if you return a boolean value indicating success
5788  *   then %TRUE means success and %FALSE means failure. If %FALSE is
5789  *   returned, the error <emphasis>must</emphasis> be set to a non-%NULL
5790  *   value.
5791  * </para></listitem>
5792  * <listitem><para>
5793  *   A %NULL return value is also frequently used to mean that an error
5794  *   occurred. You should make clear in your documentation whether %NULL
5795  *   is a valid return value in non-error cases; if %NULL is a valid value,
5796  *   then users must check whether an error was returned to see if the
5797  *   function succeeded.
5798  * </para></listitem>
5799  * <listitem><para>
5800  *   When implementing a function that can report errors, you may want
5801  *   to add a check at the top of your function that the error return
5802  *   location is either %NULL or contains a %NULL error (e.g.
5803  *   <literal>g_return_if_fail (error == NULL || *error == NULL);</literal>).
5804  * </para></listitem>
5805  * </itemizedlist>
5806  */
5807
5808
5809 /**
5810  * SECTION:fileutils
5811  * @title: File Utilities
5812  * @short_description: various file-related functions
5813  *
5814  * There is a group of functions which wrap the common POSIX functions
5815  * dealing with filenames (g_open(), g_rename(), g_mkdir(), g_stat(),
5816  * g_unlink(), g_remove(), g_fopen(), g_freopen()). The point of these
5817  * wrappers is to make it possible to handle file names with any Unicode
5818  * characters in them on Windows without having to use ifdefs and the
5819  * wide character API in the application code.
5820  *
5821  * The pathname argument should be in the GLib file name encoding.
5822  * On POSIX this is the actual on-disk encoding which might correspond
5823  * to the locale settings of the process (or the
5824  * <envar>G_FILENAME_ENCODING</envar> environment variable), or not.
5825  *
5826  * On Windows the GLib file name encoding is UTF-8. Note that the
5827  * Microsoft C library does not use UTF-8, but has separate APIs for
5828  * current system code page and wide characters (UTF-16). The GLib
5829  * wrappers call the wide character API if present (on modern Windows
5830  * systems), otherwise convert to/from the system code page.
5831  *
5832  * Another group of functions allows to open and read directories
5833  * in the GLib file name encoding. These are g_dir_open(),
5834  * g_dir_read_name(), g_dir_rewind(), g_dir_close().
5835  */
5836
5837
5838 /**
5839  * SECTION:ghostutils
5840  * @short_description: Internet hostname utilities
5841  *
5842  * Functions for manipulating internet hostnames; in particular, for
5843  * converting between Unicode and ASCII-encoded forms of
5844  * Internationalized Domain Names (IDNs).
5845  *
5846  * The <ulink
5847  * url="http://www.ietf.org/rfc/rfc3490.txt">Internationalized Domain
5848  * Names for Applications (IDNA)</ulink> standards allow for the use
5849  * of Unicode domain names in applications, while providing
5850  * backward-compatibility with the old ASCII-only DNS, by defining an
5851  * ASCII-Compatible Encoding of any given Unicode name, which can be
5852  * used with non-IDN-aware applications and protocols. (For example,
5853  * "Παν語.org" maps to "xn--4wa8awb4637h.org".)
5854  */
5855
5856
5857 /**
5858  * SECTION:gregex
5859  * @title: Perl-compatible regular expressions
5860  * @short_description: matches strings against regular expressions
5861  * @see_also: <xref linkend="glib-regex-syntax"/>
5862  *
5863  * The <function>g_regex_*()</function> functions implement regular
5864  * expression pattern matching using syntax and semantics similar to
5865  * Perl regular expression.
5866  *
5867  * Some functions accept a @start_position argument, setting it differs
5868  * from just passing over a shortened string and setting #G_REGEX_MATCH_NOTBOL
5869  * in the case of a pattern that begins with any kind of lookbehind assertion.
5870  * For example, consider the pattern "\Biss\B" which finds occurrences of "iss"
5871  * in the middle of words. ("\B" matches only if the current position in the
5872  * subject is not a word boundary.) When applied to the string "Mississipi"
5873  * from the fourth byte, namely "issipi", it does not match, because "\B" is
5874  * always false at the start of the subject, which is deemed to be a word
5875  * boundary. However, if the entire string is passed , but with
5876  * @start_position set to 4, it finds the second occurrence of "iss" because
5877  * it is able to look behind the starting point to discover that it is
5878  * preceded by a letter.
5879  *
5880  * Note that, unless you set the #G_REGEX_RAW flag, all the strings passed
5881  * to these functions must be encoded in UTF-8. The lengths and the positions
5882  * inside the strings are in bytes and not in characters, so, for instance,
5883  * "\xc3\xa0" (i.e. "&agrave;") is two bytes long but it is treated as a
5884  * single character. If you set #G_REGEX_RAW the strings can be non-valid
5885  * UTF-8 strings and a byte is treated as a character, so "\xc3\xa0" is two
5886  * bytes and two characters long.
5887  *
5888  * When matching a pattern, "\n" matches only against a "\n" character in
5889  * the string, and "\r" matches only a "\r" character. To match any newline
5890  * sequence use "\R". This particular group matches either the two-character
5891  * sequence CR + LF ("\r\n"), or one of the single characters LF (linefeed,
5892  * U+000A, "\n"), VT vertical tab, U+000B, "\v"), FF (formfeed, U+000C, "\f"),
5893  * CR (carriage return, U+000D, "\r"), NEL (next line, U+0085), LS (line
5894  * separator, U+2028), or PS (paragraph separator, U+2029).
5895  *
5896  * The behaviour of the dot, circumflex, and dollar metacharacters are
5897  * affected by newline characters, the default is to recognize any newline
5898  * character (the same characters recognized by "\R"). This can be changed
5899  * with #G_REGEX_NEWLINE_CR, #G_REGEX_NEWLINE_LF and #G_REGEX_NEWLINE_CRLF
5900  * compile options, and with #G_REGEX_MATCH_NEWLINE_ANY,
5901  * #G_REGEX_MATCH_NEWLINE_CR, #G_REGEX_MATCH_NEWLINE_LF and
5902  * #G_REGEX_MATCH_NEWLINE_CRLF match options. These settings are also
5903  * relevant when compiling a pattern if #G_REGEX_EXTENDED is set, and an
5904  * unescaped "#" outside a character class is encountered. This indicates
5905  * a comment that lasts until after the next newline.
5906  *
5907  * When setting the %G_REGEX_JAVASCRIPT_COMPAT flag, pattern syntax and pattern
5908  * matching is changed to be compatible with the way that regular expressions
5909  * work in JavaScript. More precisely, a lonely ']' character in the pattern
5910  * is a syntax error; the '\x' escape only allows 0 to 2 hexadecimal digits, and
5911  * you must use the '\u' escape sequence with 4 hex digits to specify a unicode
5912  * codepoint instead of '\x' or 'x{....}'. If '\x' or '\u' are not followed by
5913  * the specified number of hex digits, they match 'x' and 'u' literally; also
5914  * '\U' always matches 'U' instead of being an error in the pattern. Finally,
5915  * pattern matching is modified so that back references to an unset subpattern
5916  * group produces a match with the empty string instead of an error. See
5917  * <ulink>man:pcreapi(3)</ulink> for more information.
5918  *
5919  * Creating and manipulating the same #GRegex structure from different
5920  * threads is not a problem as #GRegex does not modify its internal
5921  * state between creation and destruction, on the other hand #GMatchInfo
5922  * is not threadsafe.
5923  *
5924  * The regular expressions low-level functionalities are obtained through
5925  * the excellent <ulink url="http://www.pcre.org/">PCRE</ulink> library
5926  * written by Philip Hazel.
5927  */
5928
5929
5930 /**
5931  * SECTION:gunix
5932  * @title: UNIX-specific utilities and integration
5933  * @short_description: pipes, signal handling
5934  * @include: glib-unix.h
5935  *
5936  * Most of GLib is intended to be portable; in contrast, this set of
5937  * functions is designed for programs which explicitly target UNIX,
5938  * or are using it to build higher level abstractions which would be
5939  * conditionally compiled if the platform matches G_OS_UNIX.
5940  *
5941  * To use these functions, you must explicitly include the
5942  * "glib-unix.h" header.
5943  */
5944
5945
5946 /**
5947  * SECTION:gurifuncs
5948  * @title: URI Functions
5949  * @short_description: manipulating URIs
5950  *
5951  * Functions for manipulating Universal Resource Identifiers (URIs) as
5952  * defined by <ulink url="http://www.ietf.org/rfc/rfc3986.txt">
5953  * RFC 3986</ulink>. It is highly recommended that you have read and
5954  * understand RFC 3986 for understanding this API.
5955  */
5956
5957
5958 /**
5959  * SECTION:gvariant
5960  * @title: GVariant
5961  * @short_description: strongly typed value datatype
5962  * @see_also: GVariantType
5963  *
5964  * #GVariant is a variant datatype; it stores a value along with
5965  * information about the type of that value.  The range of possible
5966  * values is determined by the type.  The type system used by #GVariant
5967  * is #GVariantType.
5968  *
5969  * #GVariant instances always have a type and a value (which are given
5970  * at construction time).  The type and value of a #GVariant instance
5971  * can never change other than by the #GVariant itself being
5972  * destroyed.  A #GVariant cannot contain a pointer.
5973  *
5974  * #GVariant is reference counted using g_variant_ref() and
5975  * g_variant_unref().  #GVariant also has floating reference counts --
5976  * see g_variant_ref_sink().
5977  *
5978  * #GVariant is completely threadsafe.  A #GVariant instance can be
5979  * concurrently accessed in any way from any number of threads without
5980  * problems.
5981  *
5982  * #GVariant is heavily optimised for dealing with data in serialised
5983  * form.  It works particularly well with data located in memory-mapped
5984  * files.  It can perform nearly all deserialisation operations in a
5985  * small constant time, usually touching only a single memory page.
5986  * Serialised #GVariant data can also be sent over the network.
5987  *
5988  * #GVariant is largely compatible with D-Bus.  Almost all types of
5989  * #GVariant instances can be sent over D-Bus.  See #GVariantType for
5990  * exceptions.  (However, #GVariant's serialisation format is not the same
5991  * as the serialisation format of a D-Bus message body: use #GDBusMessage,
5992  * in the gio library, for those.)
5993  *
5994  * For space-efficiency, the #GVariant serialisation format does not
5995  * automatically include the variant's type or endianness, which must
5996  * either be implied from context (such as knowledge that a particular
5997  * file format always contains a little-endian %G_VARIANT_TYPE_VARIANT)
5998  * or supplied out-of-band (for instance, a type and/or endianness
5999  * indicator could be placed at the beginning of a file, network message
6000  * or network stream).
6001  *
6002  * A #GVariant's size is limited mainly by any lower level operating
6003  * system constraints, such as the number of bits in #gsize.  For
6004  * example, it is reasonable to have a 2GB file mapped into memory
6005  * with #GMappedFile, and call g_variant_new_from_data() on it.
6006  *
6007  * For convenience to C programmers, #GVariant features powerful
6008  * varargs-based value construction and destruction.  This feature is
6009  * designed to be embedded in other libraries.
6010  *
6011  * There is a Python-inspired text language for describing #GVariant
6012  * values.  #GVariant includes a printer for this language and a parser
6013  * with type inferencing.
6014  *
6015  * <refsect2>
6016  *  <title>Memory Use</title>
6017  *  <para>
6018  *   #GVariant tries to be quite efficient with respect to memory use.
6019  *   This section gives a rough idea of how much memory is used by the
6020  *   current implementation.  The information here is subject to change
6021  *   in the future.
6022  *  </para>
6023  *  <para>
6024  *   The memory allocated by #GVariant can be grouped into 4 broad
6025  *   purposes: memory for serialised data, memory for the type
6026  *   information cache, buffer management memory and memory for the
6027  *   #GVariant structure itself.
6028  *  </para>
6029  *  <refsect3 id="gvariant-serialised-data-memory">
6030  *   <title>Serialised Data Memory</title>
6031  *   <para>
6032  *    This is the memory that is used for storing GVariant data in
6033  *    serialised form.  This is what would be sent over the network or
6034  *    what would end up on disk.
6035  *   </para>
6036  *   <para>
6037  *    The amount of memory required to store a boolean is 1 byte.  16,
6038  *    32 and 64 bit integers and double precision floating point numbers
6039  *    use their "natural" size.  Strings (including object path and
6040  *    signature strings) are stored with a nul terminator, and as such
6041  *    use the length of the string plus 1 byte.
6042  *   </para>
6043  *   <para>
6044  *    Maybe types use no space at all to represent the null value and
6045  *    use the same amount of space (sometimes plus one byte) as the
6046  *    equivalent non-maybe-typed value to represent the non-null case.
6047  *   </para>
6048  *   <para>
6049  *    Arrays use the amount of space required to store each of their
6050  *    members, concatenated.  Additionally, if the items stored in an
6051  *    array are not of a fixed-size (ie: strings, other arrays, etc)
6052  *    then an additional framing offset is stored for each item.  The
6053  *    size of this offset is either 1, 2 or 4 bytes depending on the
6054  *    overall size of the container.  Additionally, extra padding bytes
6055  *    are added as required for alignment of child values.
6056  *   </para>
6057  *   <para>
6058  *    Tuples (including dictionary entries) use the amount of space
6059  *    required to store each of their members, concatenated, plus one
6060  *    framing offset (as per arrays) for each non-fixed-sized item in
6061  *    the tuple, except for the last one.  Additionally, extra padding
6062  *    bytes are added as required for alignment of child values.
6063  *   </para>
6064  *   <para>
6065  *    Variants use the same amount of space as the item inside of the
6066  *    variant, plus 1 byte, plus the length of the type string for the
6067  *    item inside the variant.
6068  *   </para>
6069  *   <para>
6070  *    As an example, consider a dictionary mapping strings to variants.
6071  *    In the case that the dictionary is empty, 0 bytes are required for
6072  *    the serialisation.
6073  *   </para>
6074  *   <para>
6075  *    If we add an item "width" that maps to the int32 value of 500 then
6076  *    we will use 4 byte to store the int32 (so 6 for the variant
6077  *    containing it) and 6 bytes for the string.  The variant must be
6078  *    aligned to 8 after the 6 bytes of the string, so that's 2 extra
6079  *    bytes.  6 (string) + 2 (padding) + 6 (variant) is 14 bytes used
6080  *    for the dictionary entry.  An additional 1 byte is added to the
6081  *    array as a framing offset making a total of 15 bytes.
6082  *   </para>
6083  *   <para>
6084  *    If we add another entry, "title" that maps to a nullable string
6085  *    that happens to have a value of null, then we use 0 bytes for the
6086  *    null value (and 3 bytes for the variant to contain it along with
6087  *    its type string) plus 6 bytes for the string.  Again, we need 2
6088  *    padding bytes.  That makes a total of 6 + 2 + 3 = 11 bytes.
6089  *   </para>
6090  *   <para>
6091  *    We now require extra padding between the two items in the array.
6092  *    After the 14 bytes of the first item, that's 2 bytes required.  We
6093  *    now require 2 framing offsets for an extra two bytes.  14 + 2 + 11
6094  *    + 2 = 29 bytes to encode the entire two-item dictionary.
6095  *   </para>
6096  *  </refsect3>
6097  *  <refsect3>
6098  *   <title>Type Information Cache</title>
6099  *   <para>
6100  *    For each GVariant type that currently exists in the program a type
6101  *    information structure is kept in the type information cache.  The
6102  *    type information structure is required for rapid deserialisation.
6103  *   </para>
6104  *   <para>
6105  *    Continuing with the above example, if a #GVariant exists with the
6106  *    type "a{sv}" then a type information struct will exist for
6107  *    "a{sv}", "{sv}", "s", and "v".  Multiple uses of the same type
6108  *    will share the same type information.  Additionally, all
6109  *    single-digit types are stored in read-only static memory and do
6110  *    not contribute to the writable memory footprint of a program using
6111  *    #GVariant.
6112  *   </para>
6113  *   <para>
6114  *    Aside from the type information structures stored in read-only
6115  *    memory, there are two forms of type information.  One is used for
6116  *    container types where there is a single element type: arrays and
6117  *    maybe types.  The other is used for container types where there
6118  *    are multiple element types: tuples and dictionary entries.
6119  *   </para>
6120  *   <para>
6121  *    Array type info structures are 6 * sizeof (void *), plus the
6122  *    memory required to store the type string itself.  This means that
6123  *    on 32bit systems, the cache entry for "a{sv}" would require 30
6124  *    bytes of memory (plus malloc overhead).
6125  *   </para>
6126  *   <para>
6127  *    Tuple type info structures are 6 * sizeof (void *), plus 4 *
6128  *    sizeof (void *) for each item in the tuple, plus the memory
6129  *    required to store the type string itself.  A 2-item tuple, for
6130  *    example, would have a type information structure that consumed
6131  *    writable memory in the size of 14 * sizeof (void *) (plus type
6132  *    string)  This means that on 32bit systems, the cache entry for
6133  *    "{sv}" would require 61 bytes of memory (plus malloc overhead).
6134  *   </para>
6135  *   <para>
6136  *    This means that in total, for our "a{sv}" example, 91 bytes of
6137  *    type information would be allocated.
6138  *   </para>
6139  *   <para>
6140  *    The type information cache, additionally, uses a #GHashTable to
6141  *    store and lookup the cached items and stores a pointer to this
6142  *    hash table in static storage.  The hash table is freed when there
6143  *    are zero items in the type cache.
6144  *   </para>
6145  *   <para>
6146  *    Although these sizes may seem large it is important to remember
6147  *    that a program will probably only have a very small number of
6148  *    different types of values in it and that only one type information
6149  *    structure is required for many different values of the same type.
6150  *   </para>
6151  *  </refsect3>
6152  *  <refsect3>
6153  *   <title>Buffer Management Memory</title>
6154  *   <para>
6155  *    #GVariant uses an internal buffer management structure to deal
6156  *    with the various different possible sources of serialised data
6157  *    that it uses.  The buffer is responsible for ensuring that the
6158  *    correct call is made when the data is no longer in use by
6159  *    #GVariant.  This may involve a g_free() or a g_slice_free() or
6160  *    even g_mapped_file_unref().
6161  *   </para>
6162  *   <para>
6163  *    One buffer management structure is used for each chunk of
6164  *    serialised data.  The size of the buffer management structure is 4
6165  *    * (void *).  On 32bit systems, that's 16 bytes.
6166  *   </para>
6167  *  </refsect3>
6168  *  <refsect3>
6169  *   <title>GVariant structure</title>
6170  *   <para>
6171  *    The size of a #GVariant structure is 6 * (void *).  On 32 bit
6172  *    systems, that's 24 bytes.
6173  *   </para>
6174  *   <para>
6175  *    #GVariant structures only exist if they are explicitly created
6176  *    with API calls.  For example, if a #GVariant is constructed out of
6177  *    serialised data for the example given above (with the dictionary)
6178  *    then although there are 9 individual values that comprise the
6179  *    entire dictionary (two keys, two values, two variants containing
6180  *    the values, two dictionary entries, plus the dictionary itself),
6181  *    only 1 #GVariant instance exists -- the one referring to the
6182  *    dictionary.
6183  *   </para>
6184  *   <para>
6185  *    If calls are made to start accessing the other values then
6186  *    #GVariant instances will exist for those values only for as long
6187  *    as they are in use (ie: until you call g_variant_unref()).  The
6188  *    type information is shared.  The serialised data and the buffer
6189  *    management structure for that serialised data is shared by the
6190  *    child.
6191  *   </para>
6192  *  </refsect3>
6193  *  <refsect3>
6194  *   <title>Summary</title>
6195  *   <para>
6196  *    To put the entire example together, for our dictionary mapping
6197  *    strings to variants (with two entries, as given above), we are
6198  *    using 91 bytes of memory for type information, 29 byes of memory
6199  *    for the serialised data, 16 bytes for buffer management and 24
6200  *    bytes for the #GVariant instance, or a total of 160 bytes, plus
6201  *    malloc overhead.  If we were to use g_variant_get_child_value() to
6202  *    access the two dictionary entries, we would use an additional 48
6203  *    bytes.  If we were to have other dictionaries of the same type, we
6204  *    would use more memory for the serialised data and buffer
6205  *    management for those dictionaries, but the type information would
6206  *    be shared.
6207  *   </para>
6208  *  </refsect3>
6209  * </refsect2>
6210  */
6211
6212
6213 /**
6214  * SECTION:gvarianttype
6215  * @title: GVariantType
6216  * @short_description: introduction to the GVariant type system
6217  * @see_also: #GVariantType, #GVariant
6218  *
6219  * This section introduces the GVariant type system.  It is based, in
6220  * large part, on the D-Bus type system, with two major changes and some minor
6221  * lifting of restrictions.  The <ulink
6222  * url='http://dbus.freedesktop.org/doc/dbus-specification.html'>DBus
6223  * specification</ulink>, therefore, provides a significant amount of
6224  * information that is useful when working with GVariant.
6225  *
6226  * The first major change with respect to the D-Bus type system is the
6227  * introduction of maybe (or "nullable") types.  Any type in GVariant can be
6228  * converted to a maybe type, in which case, "nothing" (or "null") becomes a
6229  * valid value.  Maybe types have been added by introducing the
6230  * character "<literal>m</literal>" to type strings.
6231  *
6232  * The second major change is that the GVariant type system supports the
6233  * concept of "indefinite types" -- types that are less specific than
6234  * the normal types found in D-Bus.  For example, it is possible to speak
6235  * of "an array of any type" in GVariant, where the D-Bus type system
6236  * would require you to speak of "an array of integers" or "an array of
6237  * strings".  Indefinite types have been added by introducing the
6238  * characters "<literal>*</literal>", "<literal>?</literal>" and
6239  * "<literal>r</literal>" to type strings.
6240  *
6241  * Finally, all arbitrary restrictions relating to the complexity of
6242  * types are lifted along with the restriction that dictionary entries
6243  * may only appear nested inside of arrays.
6244  *
6245  * Just as in D-Bus, GVariant types are described with strings ("type
6246  * strings").  Subject to the differences mentioned above, these strings
6247  * are of the same form as those found in DBus.  Note, however: D-Bus
6248  * always works in terms of messages and therefore individual type
6249  * strings appear nowhere in its interface.  Instead, "signatures"
6250  * are a concatenation of the strings of the type of each argument in a
6251  * message.  GVariant deals with single values directly so GVariant type
6252  * strings always describe the type of exactly one value.  This means
6253  * that a D-Bus signature string is generally not a valid GVariant type
6254  * string -- except in the case that it is the signature of a message
6255  * containing exactly one argument.
6256  *
6257  * An indefinite type is similar in spirit to what may be called an
6258  * abstract type in other type systems.  No value can exist that has an
6259  * indefinite type as its type, but values can exist that have types
6260  * that are subtypes of indefinite types.  That is to say,
6261  * g_variant_get_type() will never return an indefinite type, but
6262  * calling g_variant_is_of_type() with an indefinite type may return
6263  * %TRUE.  For example, you cannot have a value that represents "an
6264  * array of no particular type", but you can have an "array of integers"
6265  * which certainly matches the type of "an array of no particular type",
6266  * since "array of integers" is a subtype of "array of no particular
6267  * type".
6268  *
6269  * This is similar to how instances of abstract classes may not
6270  * directly exist in other type systems, but instances of their
6271  * non-abstract subtypes may.  For example, in GTK, no object that has
6272  * the type of #GtkBin can exist (since #GtkBin is an abstract class),
6273  * but a #GtkWindow can certainly be instantiated, and you would say
6274  * that the #GtkWindow is a #GtkBin (since #GtkWindow is a subclass of
6275  * #GtkBin).
6276  *
6277  * A detailed description of GVariant type strings is given here:
6278  *
6279  * <refsect2 id='gvariant-typestrings'>
6280  *  <title>GVariant Type Strings</title>
6281  *  <para>
6282  *   A GVariant type string can be any of the following:
6283  *  </para>
6284  *  <itemizedlist>
6285  *   <listitem>
6286  *    <para>
6287  *     any basic type string (listed below)
6288  *    </para>
6289  *   </listitem>
6290  *   <listitem>
6291  *    <para>
6292  *     "<literal>v</literal>", "<literal>r</literal>" or
6293  *     "<literal>*</literal>"
6294  *    </para>
6295  *   </listitem>
6296  *   <listitem>
6297  *    <para>
6298  *     one of the characters '<literal>a</literal>' or
6299  *     '<literal>m</literal>', followed by another type string
6300  *    </para>
6301  *   </listitem>
6302  *   <listitem>
6303  *    <para>
6304  *     the character '<literal>(</literal>', followed by a concatenation
6305  *     of zero or more other type strings, followed by the character
6306  *     '<literal>)</literal>'
6307  *    </para>
6308  *   </listitem>
6309  *   <listitem>
6310  *    <para>
6311  *     the character '<literal>{</literal>', followed by a basic type
6312  *     string (see below), followed by another type string, followed by
6313  *     the character '<literal>}</literal>'
6314  *    </para>
6315  *   </listitem>
6316  *  </itemizedlist>
6317  *  <para>
6318  *   A basic type string describes a basic type (as per
6319  *   g_variant_type_is_basic()) and is always a single
6320  *   character in length.  The valid basic type strings are
6321  *   "<literal>b</literal>", "<literal>y</literal>",
6322  *   "<literal>n</literal>", "<literal>q</literal>",
6323  *   "<literal>i</literal>", "<literal>u</literal>",
6324  *   "<literal>x</literal>", "<literal>t</literal>",
6325  *   "<literal>h</literal>", "<literal>d</literal>",
6326  *   "<literal>s</literal>", "<literal>o</literal>",
6327  *   "<literal>g</literal>" and "<literal>?</literal>".
6328  *  </para>
6329  *  <para>
6330  *   The above definition is recursive to arbitrary depth.
6331  *   "<literal>aaaaai</literal>" and "<literal>(ui(nq((y)))s)</literal>"
6332  *   are both valid type strings, as is
6333  *   "<literal>a(aa(ui)(qna{ya(yd)}))</literal>".
6334  *  </para>
6335  *  <para>
6336  *   The meaning of each of the characters is as follows:
6337  *  </para>
6338  *  <informaltable>
6339  *   <tgroup cols='2'>
6340  *    <tbody>
6341  *     <row>
6342  *      <entry>
6343  *       <para>
6344  *        <emphasis role='strong'>Character</emphasis>
6345  *       </para>
6346  *      </entry>
6347  *      <entry>
6348  *       <para>
6349  *        <emphasis role='strong'>Meaning</emphasis>
6350  *       </para>
6351  *      </entry>
6352  *     </row>
6353  *     <row>
6354  *      <entry>
6355  *       <para>
6356  *        <literal>b</literal>
6357  *       </para>
6358  *      </entry>
6359  *      <entry>
6360  *       <para>
6361  *        the type string of %G_VARIANT_TYPE_BOOLEAN; a boolean value.
6362  *       </para>
6363  *      </entry>
6364  *     </row>
6365  *     <row>
6366  *      <entry>
6367  *       <para>
6368  *        <literal>y</literal>
6369  *       </para>
6370  *      </entry>
6371  *      <entry>
6372  *       <para>
6373  *        the type string of %G_VARIANT_TYPE_BYTE; a byte.
6374  *       </para>
6375  *      </entry>
6376  *     </row>
6377  *     <row>
6378  *      <entry>
6379  *       <para>
6380  *        <literal>n</literal>
6381  *       </para>
6382  *      </entry>
6383  *      <entry>
6384  *       <para>
6385  *        the type string of %G_VARIANT_TYPE_INT16; a signed 16 bit
6386  *        integer.
6387  *       </para>
6388  *      </entry>
6389  *     </row>
6390  *     <row>
6391  *      <entry>
6392  *       <para>
6393  *        <literal>q</literal>
6394  *       </para>
6395  *      </entry>
6396  *      <entry>
6397  *       <para>
6398  *        the type string of %G_VARIANT_TYPE_UINT16; an unsigned 16 bit
6399  *        integer.
6400  *       </para>
6401  *      </entry>
6402  *     </row>
6403  *     <row>
6404  *      <entry>
6405  *       <para>
6406  *        <literal>i</literal>
6407  *       </para>
6408  *      </entry>
6409  *      <entry>
6410  *       <para>
6411  *        the type string of %G_VARIANT_TYPE_INT32; a signed 32 bit
6412  *        integer.
6413  *       </para>
6414  *      </entry>
6415  *     </row>
6416  *     <row>
6417  *      <entry>
6418  *       <para>
6419  *        <literal>u</literal>
6420  *       </para>
6421  *      </entry>
6422  *      <entry>
6423  *       <para>
6424  *        the type string of %G_VARIANT_TYPE_UINT32; an unsigned 32 bit
6425  *        integer.
6426  *       </para>
6427  *      </entry>
6428  *     </row>
6429  *     <row>
6430  *      <entry>
6431  *       <para>
6432  *        <literal>x</literal>
6433  *       </para>
6434  *      </entry>
6435  *      <entry>
6436  *       <para>
6437  *        the type string of %G_VARIANT_TYPE_INT64; a signed 64 bit
6438  *        integer.
6439  *       </para>
6440  *      </entry>
6441  *     </row>
6442  *     <row>
6443  *      <entry>
6444  *       <para>
6445  *        <literal>t</literal>
6446  *       </para>
6447  *      </entry>
6448  *      <entry>
6449  *       <para>
6450  *        the type string of %G_VARIANT_TYPE_UINT64; an unsigned 64 bit
6451  *        integer.
6452  *       </para>
6453  *      </entry>
6454  *     </row>
6455  *     <row>
6456  *      <entry>
6457  *       <para>
6458  *        <literal>h</literal>
6459  *       </para>
6460  *      </entry>
6461  *      <entry>
6462  *       <para>
6463  *        the type string of %G_VARIANT_TYPE_HANDLE; a signed 32 bit
6464  *        value that, by convention, is used as an index into an array
6465  *        of file descriptors that are sent alongside a D-Bus message.
6466  *       </para>
6467  *      </entry>
6468  *     </row>
6469  *     <row>
6470  *      <entry>
6471  *       <para>
6472  *        <literal>d</literal>
6473  *       </para>
6474  *      </entry>
6475  *      <entry>
6476  *       <para>
6477  *        the type string of %G_VARIANT_TYPE_DOUBLE; a double precision
6478  *        floating point value.
6479  *       </para>
6480  *      </entry>
6481  *     </row>
6482  *     <row>
6483  *      <entry>
6484  *       <para>
6485  *        <literal>s</literal>
6486  *       </para>
6487  *      </entry>
6488  *      <entry>
6489  *       <para>
6490  *        the type string of %G_VARIANT_TYPE_STRING; a string.
6491  *       </para>
6492  *      </entry>
6493  *     </row>
6494  *     <row>
6495  *      <entry>
6496  *       <para>
6497  *        <literal>o</literal>
6498  *       </para>
6499  *      </entry>
6500  *      <entry>
6501  *       <para>
6502  *        the type string of %G_VARIANT_TYPE_OBJECT_PATH; a string in
6503  *        the form of a D-Bus object path.
6504  *       </para>
6505  *      </entry>
6506  *     </row>
6507  *     <row>
6508  *      <entry>
6509  *       <para>
6510  *        <literal>g</literal>
6511  *       </para>
6512  *      </entry>
6513  *      <entry>
6514  *       <para>
6515  *        the type string of %G_VARIANT_TYPE_STRING; a string in the
6516  *        form of a D-Bus type signature.
6517  *       </para>
6518  *      </entry>
6519  *     </row>
6520  *     <row>
6521  *      <entry>
6522  *       <para>
6523  *        <literal>?</literal>
6524  *       </para>
6525  *      </entry>
6526  *      <entry>
6527  *       <para>
6528  *        the type string of %G_VARIANT_TYPE_BASIC; an indefinite type
6529  *        that is a supertype of any of the basic types.
6530  *       </para>
6531  *      </entry>
6532  *     </row>
6533  *     <row>
6534  *      <entry>
6535  *       <para>
6536  *        <literal>v</literal>
6537  *       </para>
6538  *      </entry>
6539  *      <entry>
6540  *       <para>
6541  *        the type string of %G_VARIANT_TYPE_VARIANT; a container type
6542  *        that contain any other type of value.
6543  *       </para>
6544  *      </entry>
6545  *     </row>
6546  *     <row>
6547  *      <entry>
6548  *       <para>
6549  *        <literal>a</literal>
6550  *       </para>
6551  *      </entry>
6552  *      <entry>
6553  *       <para>
6554  *        used as a prefix on another type string to mean an array of
6555  *        that type; the type string "<literal>ai</literal>", for
6556  *        example, is the type of an array of 32 bit signed integers.
6557  *       </para>
6558  *      </entry>
6559  *     </row>
6560  *     <row>
6561  *      <entry>
6562  *       <para>
6563  *        <literal>m</literal>
6564  *       </para>
6565  *      </entry>
6566  *      <entry>
6567  *       <para>
6568  *        used as a prefix on another type string to mean a "maybe", or
6569  *        "nullable", version of that type; the type string
6570  *        "<literal>ms</literal>", for example, is the type of a value
6571  *        that maybe contains a string, or maybe contains nothing.
6572  *       </para>
6573  *      </entry>
6574  *     </row>
6575  *     <row>
6576  *      <entry>
6577  *       <para>
6578  *        <literal>()</literal>
6579  *       </para>
6580  *      </entry>
6581  *      <entry>
6582  *       <para>
6583  *        used to enclose zero or more other concatenated type strings
6584  *        to create a tuple type; the type string
6585  *        "<literal>(is)</literal>", for example, is the type of a pair
6586  *        of an integer and a string.
6587  *       </para>
6588  *      </entry>
6589  *     </row>
6590  *     <row>
6591  *      <entry>
6592  *       <para>
6593  *        <literal>r</literal>
6594  *       </para>
6595  *      </entry>
6596  *      <entry>
6597  *       <para>
6598  *        the type string of %G_VARIANT_TYPE_TUPLE; an indefinite type
6599  *        that is a supertype of any tuple type, regardless of the
6600  *        number of items.
6601  *       </para>
6602  *      </entry>
6603  *     </row>
6604  *     <row>
6605  *      <entry>
6606  *       <para>
6607  *        <literal>{}</literal>
6608  *       </para>
6609  *      </entry>
6610  *      <entry>
6611  *       <para>
6612  *        used to enclose a basic type string concatenated with another
6613  *        type string to create a dictionary entry type, which usually
6614  *        appears inside of an array to form a dictionary; the type
6615  *        string "<literal>a{sd}</literal>", for example, is the type of
6616  *        a dictionary that maps strings to double precision floating
6617  *        point values.
6618  *       </para>
6619  *       <para>
6620  *        The first type (the basic type) is the key type and the second
6621  *        type is the value type.  The reason that the first type is
6622  *        restricted to being a basic type is so that it can easily be
6623  *        hashed.
6624  *       </para>
6625  *      </entry>
6626  *     </row>
6627  *     <row>
6628  *      <entry>
6629  *       <para>
6630  *        <literal>*</literal>
6631  *       </para>
6632  *      </entry>
6633  *      <entry>
6634  *       <para>
6635  *        the type string of %G_VARIANT_TYPE_ANY; the indefinite type
6636  *        that is a supertype of all types.  Note that, as with all type
6637  *        strings, this character represents exactly one type.  It
6638  *        cannot be used inside of tuples to mean "any number of items".
6639  *       </para>
6640  *      </entry>
6641  *     </row>
6642  *    </tbody>
6643  *   </tgroup>
6644  *  </informaltable>
6645  *  <para>
6646  *   Any type string of a container that contains an indefinite type is,
6647  *   itself, an indefinite type.  For example, the type string
6648  *   "<literal>a*</literal>" (corresponding to %G_VARIANT_TYPE_ARRAY) is
6649  *   an indefinite type that is a supertype of every array type.
6650  *   "<literal>(*s)</literal>" is a supertype of all tuples that
6651  *   contain exactly two items where the second item is a string.
6652  *  </para>
6653  *  <para>
6654  *   "<literal>a{?*}</literal>" is an indefinite type that is a
6655  *   supertype of all arrays containing dictionary entries where the key
6656  *   is any basic type and the value is any type at all.  This is, by
6657  *   definition, a dictionary, so this type string corresponds to
6658  *   %G_VARIANT_TYPE_DICTIONARY.  Note that, due to the restriction that
6659  *   the key of a dictionary entry must be a basic type,
6660  *   "<literal>{**}</literal>" is not a valid type string.
6661  *  </para>
6662  * </refsect2>
6663  */
6664
6665
6666 /**
6667  * SECTION:hash_tables
6668  * @title: Hash Tables
6669  * @short_description: associations between keys and values so that
6670  *     given a key the value can be found quickly
6671  *
6672  * A #GHashTable provides associations between keys and values which is
6673  * optimized so that given a key, the associated value can be found
6674  * very quickly.
6675  *
6676  * Note that neither keys nor values are copied when inserted into the
6677  * #GHashTable, so they must exist for the lifetime of the #GHashTable.
6678  * This means that the use of static strings is OK, but temporary
6679  * strings (i.e. those created in buffers and those returned by GTK+
6680  * widgets) should be copied with g_strdup() before being inserted.
6681  *
6682  * If keys or values are dynamically allocated, you must be careful to
6683  * ensure that they are freed when they are removed from the
6684  * #GHashTable, and also when they are overwritten by new insertions
6685  * into the #GHashTable. It is also not advisable to mix static strings
6686  * and dynamically-allocated strings in a #GHashTable, because it then
6687  * becomes difficult to determine whether the string should be freed.
6688  *
6689  * To create a #GHashTable, use g_hash_table_new().
6690  *
6691  * To insert a key and value into a #GHashTable, use
6692  * g_hash_table_insert().
6693  *
6694  * To lookup a value corresponding to a given key, use
6695  * g_hash_table_lookup() and g_hash_table_lookup_extended().
6696  *
6697  * g_hash_table_lookup_extended() can also be used to simply
6698  * check if a key is present in the hash table.
6699  *
6700  * To remove a key and value, use g_hash_table_remove().
6701  *
6702  * To call a function for each key and value pair use
6703  * g_hash_table_foreach() or use a iterator to iterate over the
6704  * key/value pairs in the hash table, see #GHashTableIter.
6705  *
6706  * To destroy a #GHashTable use g_hash_table_destroy().
6707  *
6708  * A common use-case for hash tables is to store information about a
6709  * set of keys, without associating any particular value with each
6710  * key. GHashTable optimizes one way of doing so: If you store only
6711  * key-value pairs where key == value, then GHashTable does not
6712  * allocate memory to store the values, which can be a considerable
6713  * space saving, if your set is large. The functions
6714  * g_hash_table_add() and g_hash_table_contains() are designed to be
6715  * used when using #GHashTable this way.
6716  */
6717
6718
6719 /**
6720  * SECTION:hmac
6721  * @title: Secure HMAC Digests
6722  * @short_description: computes the HMAC for data
6723  *
6724  * HMACs should be used when producing a cookie or hash based on data
6725  * and a key. Simple mechanisms for using SHA1 and other algorithms to
6726  * digest a key and data together are vulnerable to various security
6727  * issues. <ulink url="http://en.wikipedia.org/wiki/HMAC">HMAC</ulink>
6728  * uses algorithms like SHA1 in a secure way to produce a digest of a
6729  * key and data.
6730  *
6731  * Both the key and data are arbitrary byte arrays of bytes or characters.
6732  *
6733  * Support for HMAC Digests has been added in GLib 2.30.
6734  */
6735
6736
6737 /**
6738  * SECTION:hooks
6739  * @title: Hook Functions
6740  * @short_description: support for manipulating lists of hook functions
6741  *
6742  * The #GHookList, #GHook and their related functions provide support for
6743  * lists of hook functions. Functions can be added and removed from the lists,
6744  * and the list of hook functions can be invoked.
6745  */
6746
6747
6748 /**
6749  * SECTION:i18n
6750  * @title: Internationalization
6751  * @short_description: gettext support macros
6752  * @see_also: the gettext manual
6753  *
6754  * GLib doesn't force any particular localization method upon its users.
6755  * But since GLib itself is localized using the gettext() mechanism, it seems
6756  * natural to offer the de-facto standard gettext() support macros in an
6757  * easy-to-use form.
6758  *
6759  * In order to use these macros in an application, you must include
6760  * <filename>glib/gi18n.h</filename>. For use in a library, you must include
6761  * <filename>glib/gi18n-lib.h</filename> <emphasis>after</emphasis> defining
6762  * the GETTEXT_PACKAGE macro suitably for your library:
6763  * |[
6764  * &num;define GETTEXT_PACKAGE "gtk20"
6765  * &num;include &lt;glib/gi18n-lib.h&gt;
6766  * ]|
6767  * For an application, note that you also have to call bindtextdomain(),
6768  * bind_textdomain_codeset(), textdomain() and setlocale() early on in your
6769  * main() to make gettext() work.
6770  *
6771  * For a library, you only have to call bindtextdomain() and
6772  * bind_textdomain_codeset() in your initialization function. If your library
6773  * doesn't have an initialization function, you can call the functions before
6774  * the first translated message.
6775  *
6776  * The gettext manual covers details of how to set up message extraction
6777  * with xgettext.
6778  */
6779
6780
6781 /**
6782  * SECTION:iochannels
6783  * @title: IO Channels
6784  * @short_description: portable support for using files, pipes and
6785  *                     sockets
6786  * @see_also: <para> <variablelist> <varlistentry>
6787  *            <term>g_io_add_watch(), g_io_add_watch_full(),
6788  *            g_source_remove()</term> <listitem><para> Convenience
6789  *            functions for creating #GIOChannel instances and adding
6790  *            them to the <link linkend="glib-The-Main-Event-Loop">main
6791  *            event loop</link>. </para></listitem> </varlistentry>
6792  *            </variablelist> </para>
6793  *
6794  * The #GIOChannel data type aims to provide a portable method for
6795  * using file descriptors, pipes, and sockets, and integrating them
6796  * into the <link linkend="glib-The-Main-Event-Loop">main event
6797  * loop</link>. Currently full support is available on UNIX platforms,
6798  * support for Windows is only partially complete.
6799  *
6800  * To create a new #GIOChannel on UNIX systems use
6801  * g_io_channel_unix_new(). This works for plain file descriptors,
6802  * pipes and sockets. Alternatively, a channel can be created for a
6803  * file in a system independent manner using g_io_channel_new_file().
6804  *
6805  * Once a #GIOChannel has been created, it can be used in a generic
6806  * manner with the functions g_io_channel_read_chars(),
6807  * g_io_channel_write_chars(), g_io_channel_seek_position(), and
6808  * g_io_channel_shutdown().
6809  *
6810  * To add a #GIOChannel to the <link
6811  * linkend="glib-The-Main-Event-Loop">main event loop</link> use
6812  * g_io_add_watch() or g_io_add_watch_full(). Here you specify which
6813  * events you are interested in on the #GIOChannel, and provide a
6814  * function to be called whenever these events occur.
6815  *
6816  * #GIOChannel instances are created with an initial reference count of
6817  * 1. g_io_channel_ref() and g_io_channel_unref() can be used to
6818  * increment or decrement the reference count respectively. When the
6819  * reference count falls to 0, the #GIOChannel is freed. (Though it
6820  * isn't closed automatically, unless it was created using
6821  * g_io_channel_new_file().) Using g_io_add_watch() or
6822  * g_io_add_watch_full() increments a channel's reference count.
6823  *
6824  * The new functions g_io_channel_read_chars(),
6825  * g_io_channel_read_line(), g_io_channel_read_line_string(),
6826  * g_io_channel_read_to_end(), g_io_channel_write_chars(),
6827  * g_io_channel_seek_position(), and g_io_channel_flush() should not be
6828  * mixed with the deprecated functions g_io_channel_read(),
6829  * g_io_channel_write(), and g_io_channel_seek() on the same channel.
6830  */
6831
6832
6833 /**
6834  * SECTION:keyfile
6835  * @title: Key-value file parser
6836  * @short_description: parses .ini-like config files
6837  *
6838  * #GKeyFile lets you parse, edit or create files containing groups of
6839  * key-value pairs, which we call <firstterm>key files</firstterm> for
6840  * lack of a better name. Several freedesktop.org specifications use
6841  * key files now, e.g the
6842  * <ulink url="http://freedesktop.org/Standards/desktop-entry-spec">Desktop
6843  * Entry Specification</ulink> and the
6844  * <ulink url="http://freedesktop.org/Standards/icon-theme-spec">Icon
6845  * Theme Specification</ulink>.
6846  *
6847  * The syntax of key files is described in detail in the
6848  * <ulink url="http://freedesktop.org/Standards/desktop-entry-spec">Desktop
6849  * Entry Specification</ulink>, here is a quick summary: Key files
6850  * consists of groups of key-value pairs, interspersed with comments.
6851  *
6852  * |[
6853  * # this is just an example
6854  * # there can be comments before the first group
6855  *
6856  * [First Group]
6857  *
6858  * Name=Key File Example\tthis value shows\nescaping
6859  *
6860  * # localized strings are stored in multiple key-value pairs
6861  * Welcome=Hello
6862  * Welcome[de]=Hallo
6863  * Welcome[fr_FR]=Bonjour
6864  * Welcome[it]=Ciao
6865  * Welcome[be@latin]=Hello
6866  *
6867  * [Another Group]
6868  *
6869  * Numbers=2;20;-200;0
6870  *
6871  * Booleans=true;false;true;true
6872  * ]|
6873  *
6874  * Lines beginning with a '#' and blank lines are considered comments.
6875  *
6876  * Groups are started by a header line containing the group name enclosed
6877  * in '[' and ']', and ended implicitly by the start of the next group or
6878  * the end of the file. Each key-value pair must be contained in a group.
6879  *
6880  * Key-value pairs generally have the form <literal>key=value</literal>,
6881  * with the exception of localized strings, which have the form
6882  * <literal>key[locale]=value</literal>, with a locale identifier of the
6883  * form <literal>lang_COUNTRY@MODIFIER</literal> where
6884  * <literal>COUNTRY</literal> and <literal>MODIFIER</literal> are optional.
6885  * Space before and after the '=' character are ignored. Newline, tab,
6886  * carriage return and backslash characters in value are escaped as \n,
6887  * \t, \r, and \\, respectively. To preserve leading spaces in values,
6888  * these can also be escaped as \s.
6889  *
6890  * Key files can store strings (possibly with localized variants), integers,
6891  * booleans and lists of these. Lists are separated by a separator character,
6892  * typically ';' or ','. To use the list separator character in a value in
6893  * a list, it has to be escaped by prefixing it with a backslash.
6894  *
6895  * This syntax is obviously inspired by the .ini files commonly met
6896  * on Windows, but there are some important differences:
6897  * <itemizedlist>
6898  *   <listitem>.ini files use the ';' character to begin comments,
6899  *     key files use the '#' character.</listitem>
6900  *   <listitem>Key files do not allow for ungrouped keys meaning only
6901  *     comments can precede the first group.</listitem>
6902  *   <listitem>Key files are always encoded in UTF-8.</listitem>
6903  *   <listitem>Key and Group names are case-sensitive. For example, a
6904  *     group called <literal>[GROUP]</literal> is a different from
6905  *     <literal>[group]</literal>.</listitem>
6906  *   <listitem>.ini files don't have a strongly typed boolean entry type,
6907  *     they only have GetProfileInt(). In key files, only
6908  *     <literal>true</literal> and <literal>false</literal> (in lower case)
6909  *     are allowed.</listitem>
6910  *  </itemizedlist>
6911  *
6912  * Note that in contrast to the
6913  * <ulink url="http://freedesktop.org/Standards/desktop-entry-spec">Desktop
6914  * Entry Specification</ulink>, groups in key files may contain the same
6915  * key multiple times; the last entry wins. Key files may also contain
6916  * multiple groups with the same name; they are merged together.
6917  * Another difference is that keys and group names in key files are not
6918  * restricted to ASCII characters.
6919  */
6920
6921
6922 /**
6923  * SECTION:linked_lists_double
6924  * @title: Doubly-Linked Lists
6925  * @short_description: linked lists that can be iterated over in both directions
6926  *
6927  * The #GList structure and its associated functions provide a standard
6928  * doubly-linked list data structure.
6929  *
6930  * Each element in the list contains a piece of data, together with
6931  * pointers which link to the previous and next elements in the list.
6932  * Using these pointers it is possible to move through the list in both
6933  * directions (unlike the <link
6934  * linkend="glib-Singly-Linked-Lists">Singly-Linked Lists</link> which
6935  * only allows movement through the list in the forward direction).
6936  *
6937  * The data contained in each element can be either integer values, by
6938  * using one of the <link linkend="glib-Type-Conversion-Macros">Type
6939  * Conversion Macros</link>, or simply pointers to any type of data.
6940  *
6941  * List elements are allocated from the <link
6942  * linkend="glib-Memory-Slices">slice allocator</link>, which is more
6943  * efficient than allocating elements individually.
6944  *
6945  * Note that most of the #GList functions expect to be passed a pointer
6946  * to the first element in the list. The functions which insert
6947  * elements return the new start of the list, which may have changed.
6948  *
6949  * There is no function to create a #GList. %NULL is considered to be
6950  * the empty list so you simply set a #GList* to %NULL.
6951  *
6952  * To add elements, use g_list_append(), g_list_prepend(),
6953  * g_list_insert() and g_list_insert_sorted().
6954  *
6955  * To remove elements, use g_list_remove().
6956  *
6957  * To find elements in the list use g_list_first(), g_list_last(),
6958  * g_list_next(), g_list_previous(), g_list_nth(), g_list_nth_data(),
6959  * g_list_find() and g_list_find_custom().
6960  *
6961  * To find the index of an element use g_list_position() and
6962  * g_list_index().
6963  *
6964  * To call a function for each element in the list use g_list_foreach().
6965  *
6966  * To free the entire list, use g_list_free().
6967  */
6968
6969
6970 /**
6971  * SECTION:linked_lists_single
6972  * @title: Singly-Linked Lists
6973  * @short_description: linked lists that can be iterated in one direction
6974  *
6975  * The #GSList structure and its associated functions provide a
6976  * standard singly-linked list data structure.
6977  *
6978  * Each element in the list contains a piece of data, together with a
6979  * pointer which links to the next element in the list. Using this
6980  * pointer it is possible to move through the list in one direction
6981  * only (unlike the <link
6982  * linkend="glib-Doubly-Linked-Lists">Doubly-Linked Lists</link> which
6983  * allow movement in both directions).
6984  *
6985  * The data contained in each element can be either integer values, by
6986  * using one of the <link linkend="glib-Type-Conversion-Macros">Type
6987  * Conversion Macros</link>, or simply pointers to any type of data.
6988  *
6989  * List elements are allocated from the <link
6990  * linkend="glib-Memory-Slices">slice allocator</link>, which is more
6991  * efficient than allocating elements individually.
6992  *
6993  * Note that most of the #GSList functions expect to be passed a
6994  * pointer to the first element in the list. The functions which insert
6995  * elements return the new start of the list, which may have changed.
6996  *
6997  * There is no function to create a #GSList. %NULL is considered to be
6998  * the empty list so you simply set a #GSList* to %NULL.
6999  *
7000  * To add elements, use g_slist_append(), g_slist_prepend(),
7001  * g_slist_insert() and g_slist_insert_sorted().
7002  *
7003  * To remove elements, use g_slist_remove().
7004  *
7005  * To find elements in the list use g_slist_last(), g_slist_next(),
7006  * g_slist_nth(), g_slist_nth_data(), g_slist_find() and
7007  * g_slist_find_custom().
7008  *
7009  * To find the index of an element use g_slist_position() and
7010  * g_slist_index().
7011  *
7012  * To call a function for each element in the list use
7013  * g_slist_foreach().
7014  *
7015  * To free the entire list, use g_slist_free().
7016  */
7017
7018
7019 /**
7020  * SECTION:macros
7021  * @title: Standard Macros
7022  * @short_description: commonly-used macros
7023  *
7024  * These macros provide a few commonly-used features.
7025  */
7026
7027
7028 /**
7029  * SECTION:macros_misc
7030  * @title: Miscellaneous Macros
7031  * @short_description: specialized macros which are not used often
7032  *
7033  * These macros provide more specialized features which are not
7034  * needed so often by application programmers.
7035  */
7036
7037
7038 /**
7039  * SECTION:main
7040  * @title: The Main Event Loop
7041  * @short_description: manages all available sources of events
7042  *
7043  * The main event loop manages all the available sources of events for
7044  * GLib and GTK+ applications. These events can come from any number of
7045  * different types of sources such as file descriptors (plain files,
7046  * pipes or sockets) and timeouts. New types of event sources can also
7047  * be added using g_source_attach().
7048  *
7049  * To allow multiple independent sets of sources to be handled in
7050  * different threads, each source is associated with a #GMainContext.
7051  * A GMainContext can only be running in a single thread, but
7052  * sources can be added to it and removed from it from other threads.
7053  *
7054  * Each event source is assigned a priority. The default priority,
7055  * #G_PRIORITY_DEFAULT, is 0. Values less than 0 denote higher priorities.
7056  * Values greater than 0 denote lower priorities. Events from high priority
7057  * sources are always processed before events from lower priority sources.
7058  *
7059  * Idle functions can also be added, and assigned a priority. These will
7060  * be run whenever no events with a higher priority are ready to be processed.
7061  *
7062  * The #GMainLoop data type represents a main event loop. A GMainLoop is
7063  * created with g_main_loop_new(). After adding the initial event sources,
7064  * g_main_loop_run() is called. This continuously checks for new events from
7065  * each of the event sources and dispatches them. Finally, the processing of
7066  * an event from one of the sources leads to a call to g_main_loop_quit() to
7067  * exit the main loop, and g_main_loop_run() returns.
7068  *
7069  * It is possible to create new instances of #GMainLoop recursively.
7070  * This is often used in GTK+ applications when showing modal dialog
7071  * boxes. Note that event sources are associated with a particular
7072  * #GMainContext, and will be checked and dispatched for all main
7073  * loops associated with that GMainContext.
7074  *
7075  * GTK+ contains wrappers of some of these functions, e.g. gtk_main(),
7076  * gtk_main_quit() and gtk_events_pending().
7077  *
7078  * <refsect2><title>Creating new source types</title>
7079  * <para>One of the unusual features of the #GMainLoop functionality
7080  * is that new types of event source can be created and used in
7081  * addition to the builtin type of event source. A new event source
7082  * type is used for handling GDK events. A new source type is created
7083  * by <firstterm>deriving</firstterm> from the #GSource structure.
7084  * The derived type of source is represented by a structure that has
7085  * the #GSource structure as a first element, and other elements specific
7086  * to the new source type. To create an instance of the new source type,
7087  * call g_source_new() passing in the size of the derived structure and
7088  * a table of functions. These #GSourceFuncs determine the behavior of
7089  * the new source type.</para>
7090  * <para>New source types basically interact with the main context
7091  * in two ways. Their prepare function in #GSourceFuncs can set a timeout
7092  * to determine the maximum amount of time that the main loop will sleep
7093  * before checking the source again. In addition, or as well, the source
7094  * can add file descriptors to the set that the main context checks using
7095  * g_source_add_poll().</para>
7096  * </refsect2>
7097  * <refsect2><title>Customizing the main loop iteration</title>
7098  * <para>Single iterations of a #GMainContext can be run with
7099  * g_main_context_iteration(). In some cases, more detailed control
7100  * of exactly how the details of the main loop work is desired, for
7101  * instance, when integrating the #GMainLoop with an external main loop.
7102  * In such cases, you can call the component functions of
7103  * g_main_context_iteration() directly. These functions are
7104  * g_main_context_prepare(), g_main_context_query(),
7105  * g_main_context_check() and g_main_context_dispatch().</para>
7106  * <para>The operation of these functions can best be seen in terms
7107  * of a state diagram, as shown in <xref linkend="mainloop-states"/>.</para>
7108  * <figure id="mainloop-states"><title>States of a Main Context</title>
7109  * <graphic fileref="mainloop-states.gif" format="GIF"></graphic>
7110  * </figure>
7111  * </refsect2>
7112  *
7113  * On Unix, the GLib mainloop is incompatible with fork().  Any program
7114  * using the mainloop must either exec() or exit() from the child
7115  * without returning to the mainloop.
7116  */
7117
7118
7119 /**
7120  * SECTION:markup
7121  * @Title: Simple XML Subset Parser
7122  * @Short_description: parses a subset of XML
7123  * @See_also: <ulink url="http://www.w3.org/TR/REC-xml/">XML
7124  *     Specification</ulink>
7125  *
7126  * The "GMarkup" parser is intended to parse a simple markup format
7127  * that's a subset of XML. This is a small, efficient, easy-to-use
7128  * parser. It should not be used if you expect to interoperate with
7129  * other applications generating full-scale XML. However, it's very
7130  * useful for application data files, config files, etc. where you
7131  * know your application will be the only one writing the file.
7132  * Full-scale XML parsers should be able to parse the subset used by
7133  * GMarkup, so you can easily migrate to full-scale XML at a later
7134  * time if the need arises.
7135  *
7136  * GMarkup is not guaranteed to signal an error on all invalid XML;
7137  * the parser may accept documents that an XML parser would not.
7138  * However, XML documents which are not well-formed<footnote
7139  * id="wellformed">Being wellformed is a weaker condition than being
7140  * valid. See the <ulink url="http://www.w3.org/TR/REC-xml/">XML
7141  * specification</ulink> for definitions of these terms.</footnote>
7142  * are not considered valid GMarkup documents.
7143  *
7144  * Simplifications to XML include:
7145  * <itemizedlist>
7146  * <listitem>Only UTF-8 encoding is allowed</listitem>
7147  * <listitem>No user-defined entities</listitem>
7148  * <listitem>Processing instructions, comments and the doctype declaration
7149  * are "passed through" but are not interpreted in any way</listitem>
7150  * <listitem>No DTD or validation.</listitem>
7151  * </itemizedlist>
7152  *
7153  * The markup format does support:
7154  * <itemizedlist>
7155  * <listitem>Elements</listitem>
7156  * <listitem>Attributes</listitem>
7157  * <listitem>5 standard entities:
7158  *   <literal>&amp;amp; &amp;lt; &amp;gt; &amp;quot; &amp;apos;</literal>
7159  * </listitem>
7160  * <listitem>Character references</listitem>
7161  * <listitem>Sections marked as CDATA</listitem>
7162  * </itemizedlist>
7163  */
7164
7165
7166 /**
7167  * SECTION:memory
7168  * @Short_Description: general memory-handling
7169  * @Title: Memory Allocation
7170  *
7171  * These functions provide support for allocating and freeing memory.
7172  *
7173  * <note>
7174  * If any call to allocate memory fails, the application is terminated.
7175  * This also means that there is no need to check if the call succeeded.
7176  * </note>
7177  *
7178  * <note>
7179  * It's important to match g_malloc() with g_free(), plain malloc() with free(),
7180  * and (if you're using C++) new with delete and new[] with delete[]. Otherwise
7181  * bad things can happen, since these allocators may use different memory
7182  * pools (and new/delete call constructors and destructors). See also
7183  * g_mem_set_vtable().
7184  * </note>
7185  */
7186
7187
7188 /**
7189  * SECTION:memory_slices
7190  * @title: Memory Slices
7191  * @short_description: efficient way to allocate groups of equal-sized
7192  *     chunks of memory
7193  *
7194  * Memory slices provide a space-efficient and multi-processing scalable
7195  * way to allocate equal-sized pieces of memory, just like the original
7196  * #GMemChunks (from GLib 2.8), while avoiding their excessive
7197  * memory-waste, scalability and performance problems.
7198  *
7199  * To achieve these goals, the slice allocator uses a sophisticated,
7200  * layered design that has been inspired by Bonwick's slab allocator
7201  * <footnote><para>
7202  * <ulink url="http://citeseer.ist.psu.edu/bonwick94slab.html">[Bonwick94]</ulink> Jeff Bonwick, The slab allocator: An object-caching kernel
7203  * memory allocator. USENIX 1994, and
7204  * <ulink url="http://citeseer.ist.psu.edu/bonwick01magazines.html">[Bonwick01]</ulink> Bonwick and Jonathan Adams, Magazines and vmem: Extending the
7205  * slab allocator to many cpu's and arbitrary resources. USENIX 2001
7206  * </para></footnote>.
7207  * It uses posix_memalign() to optimize allocations of many equally-sized
7208  * chunks, and has per-thread free lists (the so-called magazine layer)
7209  * to quickly satisfy allocation requests of already known structure sizes.
7210  * This is accompanied by extra caching logic to keep freed memory around
7211  * for some time before returning it to the system. Memory that is unused
7212  * due to alignment constraints is used for cache colorization (random
7213  * distribution of chunk addresses) to improve CPU cache utilization. The
7214  * caching layer of the slice allocator adapts itself to high lock contention
7215  * to improve scalability.
7216  *
7217  * The slice allocator can allocate blocks as small as two pointers, and
7218  * unlike malloc(), it does not reserve extra space per block. For large block
7219  * sizes, g_slice_new() and g_slice_alloc() will automatically delegate to the
7220  * system malloc() implementation. For newly written code it is recommended
7221  * to use the new <literal>g_slice</literal> API instead of g_malloc() and
7222  * friends, as long as objects are not resized during their lifetime and the
7223  * object size used at allocation time is still available when freeing.
7224  *
7225  * <example>
7226  * <title>Using the slice allocator</title>
7227  * <programlisting>
7228  * gchar *mem[10000];
7229  * gint i;
7230  *
7231  * /&ast; Allocate 10000 blocks. &ast;/
7232  * for (i = 0; i &lt; 10000; i++)
7233  *   {
7234  *     mem[i] = g_slice_alloc (50);
7235  *
7236  *     /&ast; Fill in the memory with some junk. &ast;/
7237  *     for (j = 0; j &lt; 50; j++)
7238  *       mem[i][j] = i * j;
7239  *   }
7240  *
7241  * /&ast; Now free all of the blocks. &ast;/
7242  * for (i = 0; i &lt; 10000; i++)
7243  *   {
7244  *     g_slice_free1 (50, mem[i]);
7245  *   }
7246  * </programlisting></example>
7247  *
7248  * <example>
7249  * <title>Using the slice allocator with data structures</title>
7250  * <programlisting>
7251  * GRealArray *array;
7252  *
7253  * /&ast; Allocate one block, using the g_slice_new() macro. &ast;/
7254  * array = g_slice_new (GRealArray);
7255  *
7256  * /&ast; We can now use array just like a normal pointer to a structure. &ast;/
7257  * array->data            = NULL;
7258  * array->len             = 0;
7259  * array->alloc           = 0;
7260  * array->zero_terminated = (zero_terminated ? 1 : 0);
7261  * array->clear           = (clear ? 1 : 0);
7262  * array->elt_size        = elt_size;
7263  *
7264  * /&ast; We can free the block, so it can be reused. &ast;/
7265  * g_slice_free (GRealArray, array);
7266  * </programlisting></example>
7267  */
7268
7269
7270 /**
7271  * SECTION:messages
7272  * @title: Message Logging
7273  * @short_description: versatile support for logging messages
7274  *     with different levels of importance
7275  *
7276  * These functions provide support for logging error messages
7277  * or messages used for debugging.
7278  *
7279  * There are several built-in levels of messages, defined in
7280  * #GLogLevelFlags. These can be extended with user-defined levels.
7281  */
7282
7283
7284 /**
7285  * SECTION:misc_utils
7286  * @title: Miscellaneous Utility Functions
7287  * @short_description: a selection of portable utility functions
7288  *
7289  * These are portable utility functions.
7290  */
7291
7292
7293 /**
7294  * SECTION:numerical
7295  * @title: Numerical Definitions
7296  * @short_description: mathematical constants, and floating point decomposition
7297  *
7298  * GLib offers mathematical constants such as #G_PI for the value of pi;
7299  * many platforms have these in the C library, but some don't, the GLib
7300  * versions always exist.
7301  *
7302  * The #GFloatIEEE754 and #GDoubleIEEE754 unions are used to access the
7303  * sign, mantissa and exponent of IEEE floats and doubles. These unions are
7304  * defined as appropriate for a given platform. IEEE floats and doubles are
7305  * supported (used for storage) by at least Intel, PPC and Sparc. See
7306  * <ulink url="http://en.wikipedia.org/wiki/IEEE_float">IEEE 754-2008</ulink>
7307  * for more information about IEEE number formats.
7308  */
7309
7310
7311 /**
7312  * SECTION:option
7313  * @Short_description: parses commandline options
7314  * @Title: Commandline option parser
7315  *
7316  * The GOption commandline parser is intended to be a simpler replacement
7317  * for the popt library. It supports short and long commandline options,
7318  * as shown in the following example:
7319  *
7320  * <literal>testtreemodel -r 1 --max-size 20 --rand --display=:1.0 -vb -- file1 file2</literal>
7321  *
7322  * The example demonstrates a number of features of the GOption
7323  * commandline parser
7324  * <itemizedlist><listitem><para>
7325  *   Options can be single letters, prefixed by a single dash. Multiple
7326  *   short options can be grouped behind a single dash.
7327  * </para></listitem><listitem><para>
7328  *   Long options are prefixed by two consecutive dashes.
7329  * </para></listitem><listitem><para>
7330  *   Options can have an extra argument, which can be a number, a string or
7331  *   a filename. For long options, the extra argument can be appended with
7332  *   an equals sign after the option name, which is useful if the extra
7333  *   argument starts with a dash, which would otherwise cause it to be
7334  *   interpreted as another option.
7335  * </para></listitem><listitem><para>
7336  *   Non-option arguments are returned to the application as rest arguments.
7337  * </para></listitem><listitem><para>
7338  *   An argument consisting solely of two dashes turns off further parsing,
7339  *   any remaining arguments (even those starting with a dash) are returned
7340  *   to the application as rest arguments.
7341  * </para></listitem></itemizedlist>
7342  *
7343  * Another important feature of GOption is that it can automatically
7344  * generate nicely formatted help output. Unless it is explicitly turned
7345  * off with g_option_context_set_help_enabled(), GOption will recognize
7346  * the <option>--help</option>, <option>-?</option>,
7347  * <option>--help-all</option> and
7348  * <option>--help-</option><replaceable>groupname</replaceable> options
7349  * (where <replaceable>groupname</replaceable> is the name of a
7350  * #GOptionGroup) and write a text similar to the one shown in the
7351  * following example to stdout.
7352  *
7353  * <informalexample><screen>
7354  * Usage:
7355  *   testtreemodel [OPTION...] - test tree model performance
7356  *  
7357  * Help Options:
7358  *   -h, --help               Show help options
7359  *   --help-all               Show all help options
7360  *   --help-gtk               Show GTK+ Options
7361  *  
7362  * Application Options:
7363  *   -r, --repeats=N          Average over N repetitions
7364  *   -m, --max-size=M         Test up to 2^M items
7365  *   --display=DISPLAY        X display to use
7366  *   -v, --verbose            Be verbose
7367  *   -b, --beep               Beep when done
7368  *   --rand                   Randomize the data
7369  * </screen></informalexample>
7370  *
7371  * GOption groups options in #GOptionGroup<!-- -->s, which makes it easy to
7372  * incorporate options from multiple sources. The intended use for this is
7373  * to let applications collect option groups from the libraries it uses,
7374  * add them to their #GOptionContext, and parse all options by a single call
7375  * to g_option_context_parse(). See gtk_get_option_group() for an example.
7376  *
7377  * If an option is declared to be of type string or filename, GOption takes
7378  * care of converting it to the right encoding; strings are returned in
7379  * UTF-8, filenames are returned in the GLib filename encoding. Note that
7380  * this only works if setlocale() has been called before
7381  * g_option_context_parse().
7382  *
7383  * Here is a complete example of setting up GOption to parse the example
7384  * commandline above and produce the example help output.
7385  *
7386  * <informalexample><programlisting>
7387  * static gint repeats = 2;
7388  * static gint max_size = 8;
7389  * static gboolean verbose = FALSE;
7390  * static gboolean beep = FALSE;
7391  * static gboolean rand = FALSE;
7392  *
7393  * static GOptionEntry entries[] =
7394  * {
7395  *   { "repeats", 'r', 0, G_OPTION_ARG_INT, &repeats, "Average over N repetitions", "N" },
7396  *   { "max-size", 'm', 0, G_OPTION_ARG_INT, &max_size, "Test up to 2^M items", "M" },
7397  *   { "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, "Be verbose", NULL },
7398  *   { "beep", 'b', 0, G_OPTION_ARG_NONE, &beep, "Beep when done", NULL },
7399  *   { "rand", 0, 0, G_OPTION_ARG_NONE, &rand, "Randomize the data", NULL },
7400  *   { NULL }
7401  * };
7402  *
7403  * int
7404  * main (int argc, char *argv[])
7405  * {
7406  *   GError *error = NULL;
7407  *   GOptionContext *context;
7408  *
7409  *   context = g_option_context_new ("- test tree model performance");
7410  *   g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
7411  *   g_option_context_add_group (context, gtk_get_option_group (TRUE));
7412  *   if (!g_option_context_parse (context, &argc, &argv, &error))
7413  *     {
7414  *       g_print ("option parsing failed: %s\n", error->message);
7415  *       exit (1);
7416  *     }
7417  *
7418  *   /&ast; ... &ast;/
7419  *
7420  * }
7421  * </programlisting></informalexample>
7422  */
7423
7424
7425 /**
7426  * SECTION:patterns
7427  * @title: Glob-style pattern matching
7428  * @short_description: matches strings against patterns containing '*'
7429  *                     (wildcard) and '?' (joker)
7430  *
7431  * The <function>g_pattern_match*</function> functions match a string
7432  * against a pattern containing '*' and '?' wildcards with similar
7433  * semantics as the standard glob() function: '*' matches an arbitrary,
7434  * possibly empty, string, '?' matches an arbitrary character.
7435  *
7436  * Note that in contrast to glob(), the '/' character
7437  * <emphasis>can</emphasis> be matched by the wildcards, there are no
7438  * '[...]' character ranges and '*' and '?' can
7439  * <emphasis>not</emphasis> be escaped to include them literally in a
7440  * pattern.
7441  *
7442  * When multiple strings must be matched against the same pattern, it
7443  * is better to compile the pattern to a #GPatternSpec using
7444  * g_pattern_spec_new() and use g_pattern_match_string() instead of
7445  * g_pattern_match_simple(). This avoids the overhead of repeated
7446  * pattern compilation.
7447  */
7448
7449
7450 /**
7451  * SECTION:quarks
7452  * @title: Quarks
7453  * @short_description: a 2-way association between a string and a
7454  *                     unique integer identifier
7455  *
7456  * Quarks are associations between strings and integer identifiers.
7457  * Given either the string or the #GQuark identifier it is possible to
7458  * retrieve the other.
7459  *
7460  * Quarks are used for both <link
7461  * linkend="glib-Datasets">Datasets</link> and <link
7462  * linkend="glib-Keyed-Data-Lists">Keyed Data Lists</link>.
7463  *
7464  * To create a new quark from a string, use g_quark_from_string() or
7465  * g_quark_from_static_string().
7466  *
7467  * To find the string corresponding to a given #GQuark, use
7468  * g_quark_to_string().
7469  *
7470  * To find the #GQuark corresponding to a given string, use
7471  * g_quark_try_string().
7472  *
7473  * Another use for the string pool maintained for the quark functions
7474  * is string interning, using g_intern_string() or
7475  * g_intern_static_string(). An interned string is a canonical
7476  * representation for a string. One important advantage of interned
7477  * strings is that they can be compared for equality by a simple
7478  * pointer comparison, rather than using strcmp().
7479  */
7480
7481
7482 /**
7483  * SECTION:queue
7484  * @Title: Double-ended Queues
7485  * @Short_description: double-ended queue data structure
7486  *
7487  * The #GQueue structure and its associated functions provide a standard
7488  * queue data structure. Internally, GQueue uses the same data structure
7489  * as #GList to store elements.
7490  *
7491  * The data contained in each element can be either integer values, by
7492  * using one of the <link linkend="glib-Type-Conversion-Macros">Type
7493  * Conversion Macros</link>, or simply pointers to any type of data.
7494  *
7495  * To create a new GQueue, use g_queue_new().
7496  *
7497  * To initialize a statically-allocated GQueue, use #G_QUEUE_INIT or
7498  * g_queue_init().
7499  *
7500  * To add elements, use g_queue_push_head(), g_queue_push_head_link(),
7501  * g_queue_push_tail() and g_queue_push_tail_link().
7502  *
7503  * To remove elements, use g_queue_pop_head() and g_queue_pop_tail().
7504  *
7505  * To free the entire queue, use g_queue_free().
7506  */
7507
7508
7509 /**
7510  * SECTION:random_numbers
7511  * @title: Random Numbers
7512  * @short_description: pseudo-random number generator
7513  *
7514  * The following functions allow you to use a portable, fast and good
7515  * pseudo-random number generator (PRNG).
7516  *
7517  * <warning><para>Do not use this API for cryptographic purposes such as key
7518  * generation, nonces, salts or one-time pads.</para></warning>
7519  *
7520  * This PRNG is suitable for non-cryptographic use such as in games
7521  * (shuffling a card deck, generating levels), generating data for a
7522  * test suite, etc. If you need random data for cryptographic
7523  * purposes, it is recommended to use platform-specific APIs such as
7524  * <literal>/dev/random</literal> on Unix, or CryptGenRandom() on
7525  * Windows.
7526  *
7527  * GRand uses the Mersenne Twister PRNG, which was originally
7528  * developed by Makoto Matsumoto and Takuji Nishimura. Further
7529  * information can be found at <ulink
7530  * url="http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html">
7531  * http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html</ulink>.
7532  *
7533  * If you just need a random number, you simply call the
7534  * <function>g_random_*</function> functions, which will create a
7535  * globally used #GRand and use the according
7536  * <function>g_rand_*</function> functions internally. Whenever you
7537  * need a stream of reproducible random numbers, you better create a
7538  * #GRand yourself and use the <function>g_rand_*</function> functions
7539  * directly, which will also be slightly faster. Initializing a #GRand
7540  * with a certain seed will produce exactly the same series of random
7541  * numbers on all platforms. This can thus be used as a seed for e.g.
7542  * games.
7543  *
7544  * The <function>g_rand*_range</function> functions will return high
7545  * quality equally distributed random numbers, whereas for example the
7546  * <literal>(g_random_int()&percnt;max)</literal> approach often
7547  * doesn't yield equally distributed numbers.
7548  *
7549  * GLib changed the seeding algorithm for the pseudo-random number
7550  * generator Mersenne Twister, as used by
7551  * <structname>GRand</structname> and <structname>GRandom</structname>.
7552  * This was necessary, because some seeds would yield very bad
7553  * pseudo-random streams.  Also the pseudo-random integers generated by
7554  * <function>g_rand*_int_range()</function> will have a slightly better
7555  * equal distribution with the new version of GLib.
7556  *
7557  * The original seeding and generation algorithms, as found in GLib
7558  * 2.0.x, can be used instead of the new ones by setting the
7559  * environment variable <envar>G_RANDOM_VERSION</envar> to the value of
7560  * '2.0'. Use the GLib-2.0 algorithms only if you have sequences of
7561  * numbers generated with Glib-2.0 that you need to reproduce exactly.
7562  */
7563
7564
7565 /**
7566  * SECTION:scanner
7567  * @title: Lexical Scanner
7568  * @short_description: a general purpose lexical scanner
7569  *
7570  * The #GScanner and its associated functions provide a
7571  * general purpose lexical scanner.
7572  */
7573
7574
7575 /**
7576  * SECTION:sequence
7577  * @title: Sequences
7578  * @short_description: scalable lists
7579  *
7580  * The #GSequence data structure has the API of a list, but is
7581  * implemented internally with a balanced binary tree. This means that
7582  * it is possible to maintain a sorted list of n elements in time O(n
7583  * log n). The data contained in each element can be either integer
7584  * values, by using of the <link
7585  * linkend="glib-Type-Conversion-Macros">Type Conversion Macros</link>,
7586  * or simply pointers to any type of data.
7587  *
7588  * A #GSequence is accessed through <firstterm>iterators</firstterm>,
7589  * represented by a #GSequenceIter. An iterator represents a position
7590  * between two elements of the sequence. For example, the
7591  * <firstterm>begin</firstterm> iterator represents the gap immediately
7592  * before the first element of the sequence, and the
7593  * <firstterm>end</firstterm> iterator represents the gap immediately
7594  * after the last element. In an empty sequence, the begin and end
7595  * iterators are the same.
7596  *
7597  * Some methods on #GSequence operate on ranges of items. For example
7598  * g_sequence_foreach_range() will call a user-specified function on
7599  * each element with the given range. The range is delimited by the
7600  * gaps represented by the passed-in iterators, so if you pass in the
7601  * begin and end iterators, the range in question is the entire
7602  * sequence.
7603  *
7604  * The function g_sequence_get() is used with an iterator to access the
7605  * element immediately following the gap that the iterator represents.
7606  * The iterator is said to <firstterm>point</firstterm> to that element.
7607  *
7608  * Iterators are stable across most operations on a #GSequence. For
7609  * example an iterator pointing to some element of a sequence will
7610  * continue to point to that element even after the sequence is sorted.
7611  * Even moving an element to another sequence using for example
7612  * g_sequence_move_range() will not invalidate the iterators pointing
7613  * to it. The only operation that will invalidate an iterator is when
7614  * the element it points to is removed from any sequence.
7615  */
7616
7617
7618 /**
7619  * SECTION:shell
7620  * @title: Shell-related Utilities
7621  * @short_description: shell-like commandline handling
7622  */
7623
7624
7625 /**
7626  * SECTION:spawn
7627  * @Short_description: process launching
7628  * @Title: Spawning Processes
7629  */
7630
7631
7632 /**
7633  * SECTION:string_chunks
7634  * @title: String Chunks
7635  * @short_description: efficient storage of groups of strings
7636  *
7637  * String chunks are used to store groups of strings. Memory is
7638  * allocated in blocks, and as strings are added to the #GStringChunk
7639  * they are copied into the next free position in a block. When a block
7640  * is full a new block is allocated.
7641  *
7642  * When storing a large number of strings, string chunks are more
7643  * efficient than using g_strdup() since fewer calls to malloc() are
7644  * needed, and less memory is wasted in memory allocation overheads.
7645  *
7646  * By adding strings with g_string_chunk_insert_const() it is also
7647  * possible to remove duplicates.
7648  *
7649  * To create a new #GStringChunk use g_string_chunk_new().
7650  *
7651  * To add strings to a #GStringChunk use g_string_chunk_insert().
7652  *
7653  * To add strings to a #GStringChunk, but without duplicating strings
7654  * which are already in the #GStringChunk, use
7655  * g_string_chunk_insert_const().
7656  *
7657  * To free the entire #GStringChunk use g_string_chunk_free(). It is
7658  * not possible to free individual strings.
7659  */
7660
7661
7662 /**
7663  * SECTION:string_utils
7664  * @title: String Utility Functions
7665  * @short_description: various string-related functions
7666  *
7667  * This section describes a number of utility functions for creating,
7668  * duplicating, and manipulating strings.
7669  *
7670  * Note that the functions g_printf(), g_fprintf(), g_sprintf(),
7671  * g_snprintf(), g_vprintf(), g_vfprintf(), g_vsprintf() and g_vsnprintf()
7672  * are declared in the header <filename>gprintf.h</filename> which is
7673  * <emphasis>not</emphasis> included in <filename>glib.h</filename>
7674  * (otherwise using <filename>glib.h</filename> would drag in
7675  * <filename>stdio.h</filename>), so you'll have to explicitly include
7676  * <literal>&lt;glib/gprintf.h&gt;</literal> in order to use the GLib
7677  * printf() functions.
7678  *
7679  * <para id="string-precision">While you may use the printf() functions
7680  * to format UTF-8 strings, notice that the precision of a
7681  * <literal>&percnt;Ns</literal> parameter is interpreted as the
7682  * number of <emphasis>bytes</emphasis>, not <emphasis>characters</emphasis>
7683  * to print. On top of that, the GNU libc implementation of the printf()
7684  * functions has the "feature" that it checks that the string given for
7685  * the <literal>&percnt;Ns</literal> parameter consists of a whole number
7686  * of characters in the current encoding. So, unless you are sure you are
7687  * always going to be in an UTF-8 locale or your know your text is restricted
7688  * to ASCII, avoid using <literal>&percnt;Ns</literal>. If your intention is
7689  * to format strings for a certain number of columns, then
7690  * <literal>&percnt;Ns</literal> is not a correct solution anyway, since it
7691  * fails to take wide characters (see g_unichar_iswide()) into account.
7692  * </para>
7693  */
7694
7695
7696 /**
7697  * SECTION:strings
7698  * @title: Strings
7699  * @short_description: text buffers which grow automatically
7700  *     as text is added
7701  *
7702  * A #GString is an object that handles the memory management of a C
7703  * string for you.  The emphasis of #GString is on text, typically
7704  * UTF-8.  Crucially, the "str" member of a #GString is guaranteed to
7705  * have a trailing nul character, and it is therefore always safe to
7706  * call functions such as strchr() or g_strdup() on it.
7707  *
7708  * However, a #GString can also hold arbitrary binary data, because it
7709  * has a "len" member, which includes any possible embedded nul
7710  * characters in the data.  Conceptually then, #GString is like a
7711  * #GByteArray with the addition of many convenience methods for text,
7712  * and a guaranteed nul terminator.
7713  */
7714
7715
7716 /**
7717  * SECTION:testing
7718  * @title: Testing
7719  * @short_description: a test framework
7720  * @see_also: <link linkend="gtester">gtester</link>,
7721  *            <link linkend="gtester-report">gtester-report</link>
7722  *
7723  * GLib provides a framework for writing and maintaining unit tests
7724  * in parallel to the code they are testing. The API is designed according
7725  * to established concepts found in the other test frameworks (JUnit, NUnit,
7726  * RUnit), which in turn is based on smalltalk unit testing concepts.
7727  *
7728  * <variablelist>
7729  *   <varlistentry>
7730  *     <term>Test case</term>
7731  *     <listitem>Tests (test methods) are grouped together with their
7732  *       fixture into test cases.</listitem>
7733  *   </varlistentry>
7734  *   <varlistentry>
7735  *     <term>Fixture</term>
7736  *     <listitem>A test fixture consists of fixture data and setup and
7737  *       teardown methods to establish the environment for the test
7738  *       functions. We use fresh fixtures, i.e. fixtures are newly set
7739  *       up and torn down around each test invocation to avoid dependencies
7740  *       between tests.</listitem>
7741  *   </varlistentry>
7742  *   <varlistentry>
7743  *     <term>Test suite</term>
7744  *     <listitem>Test cases can be grouped into test suites, to allow
7745  *       subsets of the available tests to be run. Test suites can be
7746  *       grouped into other test suites as well.</listitem>
7747  *   </varlistentry>
7748  * </variablelist>
7749  * The API is designed to handle creation and registration of test suites
7750  * and test cases implicitly. A simple call like
7751  * |[
7752  *   g_test_add_func ("/misc/assertions", test_assertions);
7753  * ]|
7754  * creates a test suite called "misc" with a single test case named
7755  * "assertions", which consists of running the test_assertions function.
7756  *
7757  * In addition to the traditional g_assert(), the test framework provides
7758  * an extended set of assertions for string and numerical comparisons:
7759  * g_assert_cmpfloat(), g_assert_cmpint(), g_assert_cmpuint(),
7760  * g_assert_cmphex(), g_assert_cmpstr(). The advantage of these variants
7761  * over plain g_assert() is that the assertion messages can be more
7762  * elaborate, and include the values of the compared entities.
7763  *
7764  * GLib ships with two utilities called gtester and gtester-report to
7765  * facilitate running tests and producing nicely formatted test reports.
7766  */
7767
7768
7769 /**
7770  * SECTION:thread_pools
7771  * @title: Thread Pools
7772  * @short_description: pools of threads to execute work concurrently
7773  * @see_also: #GThread
7774  *
7775  * Sometimes you wish to asynchronously fork out the execution of work
7776  * and continue working in your own thread. If that will happen often,
7777  * the overhead of starting and destroying a thread each time might be
7778  * too high. In such cases reusing already started threads seems like a
7779  * good idea. And it indeed is, but implementing this can be tedious
7780  * and error-prone.
7781  *
7782  * Therefore GLib provides thread pools for your convenience. An added
7783  * advantage is, that the threads can be shared between the different
7784  * subsystems of your program, when they are using GLib.
7785  *
7786  * To create a new thread pool, you use g_thread_pool_new().
7787  * It is destroyed by g_thread_pool_free().
7788  *
7789  * If you want to execute a certain task within a thread pool,
7790  * you call g_thread_pool_push().
7791  *
7792  * To get the current number of running threads you call
7793  * g_thread_pool_get_num_threads(). To get the number of still
7794  * unprocessed tasks you call g_thread_pool_unprocessed(). To control
7795  * the maximal number of threads for a thread pool, you use
7796  * g_thread_pool_get_max_threads() and g_thread_pool_set_max_threads().
7797  *
7798  * Finally you can control the number of unused threads, that are kept
7799  * alive by GLib for future use. The current number can be fetched with
7800  * g_thread_pool_get_num_unused_threads(). The maximal number can be
7801  * controlled by g_thread_pool_get_max_unused_threads() and
7802  * g_thread_pool_set_max_unused_threads(). All currently unused threads
7803  * can be stopped by calling g_thread_pool_stop_unused_threads().
7804  */
7805
7806
7807 /**
7808  * SECTION:threads
7809  * @title: Threads
7810  * @short_description: portable support for threads, mutexes, locks,
7811  *     conditions and thread private data
7812  * @see_also: #GThreadPool, #GAsyncQueue
7813  *
7814  * Threads act almost like processes, but unlike processes all threads
7815  * of one process share the same memory. This is good, as it provides
7816  * easy communication between the involved threads via this shared
7817  * memory, and it is bad, because strange things (so called
7818  * "Heisenbugs") might happen if the program is not carefully designed.
7819  * In particular, due to the concurrent nature of threads, no
7820  * assumptions on the order of execution of code running in different
7821  * threads can be made, unless order is explicitly forced by the
7822  * programmer through synchronization primitives.
7823  *
7824  * The aim of the thread-related functions in GLib is to provide a
7825  * portable means for writing multi-threaded software. There are
7826  * primitives for mutexes to protect the access to portions of memory
7827  * (#GMutex, #GRecMutex and #GRWLock). There is a facility to use
7828  * individual bits for locks (g_bit_lock()). There are primitives
7829  * for condition variables to allow synchronization of threads (#GCond).
7830  * There are primitives for thread-private data - data that every
7831  * thread has a private instance of (#GPrivate). There are facilities
7832  * for one-time initialization (#GOnce, g_once_init_enter()). Finally,
7833  * there are primitives to create and manage threads (#GThread).
7834  *
7835  * The GLib threading system used to be initialized with g_thread_init().
7836  * This is no longer necessary. Since version 2.32, the GLib threading
7837  * system is automatically initialized at the start of your program,
7838  * and all thread-creation functions and synchronization primitives
7839  * are available right away.
7840  *
7841  * Note that it is not safe to assume that your program has no threads
7842  * even if you don't call g_thread_new() yourself. GLib and GIO can
7843  * and will create threads for their own purposes in some cases, such
7844  * as when using g_unix_signal_source_new() or when using GDBus.
7845  *
7846  * Originally, UNIX did not have threads, and therefore some traditional
7847  * UNIX APIs are problematic in threaded programs. Some notable examples
7848  * are
7849  * <itemizedlist>
7850  *   <listitem>
7851  *     C library functions that return data in statically allocated
7852  *     buffers, such as strtok() or strerror(). For many of these,
7853  *     there are thread-safe variants with a _r suffix, or you can
7854  *     look at corresponding GLib APIs (like g_strsplit() or g_strerror()).
7855  *   </listitem>
7856  *   <listitem>
7857  *     setenv() and unsetenv() manipulate the process environment in
7858  *     a not thread-safe way, and may interfere with getenv() calls
7859  *     in other threads. Note that getenv() calls may be
7860  *     <quote>hidden</quote> behind other APIs. For example, GNU gettext()
7861  *     calls getenv() under the covers. In general, it is best to treat
7862  *     the environment as readonly. If you absolutely have to modify the
7863  *     environment, do it early in main(), when no other threads are around yet.
7864  *   </listitem>
7865  *   <listitem>
7866  *     setlocale() changes the locale for the entire process, affecting
7867  *     all threads. Temporary changes to the locale are often made to
7868  *     change the behavior of string scanning or formatting functions
7869  *     like scanf() or printf(). GLib offers a number of string APIs
7870  *     (like g_ascii_formatd() or g_ascii_strtod()) that can often be
7871  *     used as an alternative. Or you can use the uselocale() function
7872  *     to change the locale only for the current thread.
7873  *   </listitem>
7874  *   <listitem>
7875  *     fork() only takes the calling thread into the child's copy of the
7876  *     process image.  If other threads were executing in critical
7877  *     sections they could have left mutexes locked which could easily
7878  *     cause deadlocks in the new child.  For this reason, you should
7879  *     call exit() or exec() as soon as possible in the child and only
7880  *     make signal-safe library calls before that.
7881  *   </listitem>
7882  *   <listitem>
7883  *     daemon() uses fork() in a way contrary to what is described
7884  *     above.  It should not be used with GLib programs.
7885  *   </listitem>
7886  * </itemizedlist>
7887  *
7888  * GLib itself is internally completely thread-safe (all global data is
7889  * automatically locked), but individual data structure instances are
7890  * not automatically locked for performance reasons. For example,
7891  * you must coordinate accesses to the same #GHashTable from multiple
7892  * threads. The two notable exceptions from this rule are #GMainLoop
7893  * and #GAsyncQueue, which <emphasis>are</emphasis> thread-safe and
7894  * need no further application-level locking to be accessed from
7895  * multiple threads. Most refcounting functions such as g_object_ref()
7896  * are also thread-safe.
7897  */
7898
7899
7900 /**
7901  * SECTION:timers
7902  * @title: Timers
7903  * @short_description: keep track of elapsed time
7904  *
7905  * #GTimer records a start time, and counts microseconds elapsed since
7906  * that time. This is done somewhat differently on different platforms,
7907  * and can be tricky to get exactly right, so #GTimer provides a
7908  * portable/convenient interface.
7909  */
7910
7911
7912 /**
7913  * SECTION:timezone
7914  * @title: GTimeZone
7915  * @short_description: a structure representing a time zone
7916  * @see_also: #GDateTime
7917  *
7918  * #GTimeZone is a structure that represents a time zone, at no
7919  * particular point in time.  It is refcounted and immutable.
7920  *
7921  * A time zone contains a number of intervals.  Each interval has
7922  * an abbreviation to describe it, an offet to UTC and a flag indicating
7923  * if the daylight savings time is in effect during that interval.  A
7924  * time zone always has at least one interval -- interval 0.
7925  *
7926  * Every UTC time is contained within exactly one interval, but a given
7927  * local time may be contained within zero, one or two intervals (due to
7928  * incontinuities associated with daylight savings time).
7929  *
7930  * An interval may refer to a specific period of time (eg: the duration
7931  * of daylight savings time during 2010) or it may refer to many periods
7932  * of time that share the same properties (eg: all periods of daylight
7933  * savings time).  It is also possible (usually for political reasons)
7934  * that some properties (like the abbreviation) change between intervals
7935  * without other properties changing.
7936  *
7937  * #GTimeZone is available since GLib 2.26.
7938  */
7939
7940
7941 /**
7942  * SECTION:trash_stack
7943  * @title: Trash Stacks
7944  * @short_description: maintain a stack of unused allocated memory chunks
7945  *
7946  * A #GTrashStack is an efficient way to keep a stack of unused allocated
7947  * memory chunks. Each memory chunk is required to be large enough to hold
7948  * a #gpointer. This allows the stack to be maintained without any space
7949  * overhead, since the stack pointers can be stored inside the memory chunks.
7950  *
7951  * There is no function to create a #GTrashStack. A %NULL #GTrashStack*
7952  * is a perfectly valid empty stack.
7953  */
7954
7955
7956 /**
7957  * SECTION:trees-binary
7958  * @title: Balanced Binary Trees
7959  * @short_description: a sorted collection of key/value pairs optimized
7960  *                     for searching and traversing in order
7961  *
7962  * The #GTree structure and its associated functions provide a sorted
7963  * collection of key/value pairs optimized for searching and traversing
7964  * in order.
7965  *
7966  * To create a new #GTree use g_tree_new().
7967  *
7968  * To insert a key/value pair into a #GTree use g_tree_insert().
7969  *
7970  * To lookup the value corresponding to a given key, use
7971  * g_tree_lookup() and g_tree_lookup_extended().
7972  *
7973  * To find out the number of nodes in a #GTree, use g_tree_nnodes(). To
7974  * get the height of a #GTree, use g_tree_height().
7975  *
7976  * To traverse a #GTree, calling a function for each node visited in
7977  * the traversal, use g_tree_foreach().
7978  *
7979  * To remove a key/value pair use g_tree_remove().
7980  *
7981  * To destroy a #GTree, use g_tree_destroy().
7982  */
7983
7984
7985 /**
7986  * SECTION:trees-nary
7987  * @title: N-ary Trees
7988  * @short_description: trees of data with any number of branches
7989  *
7990  * The #GNode struct and its associated functions provide a N-ary tree
7991  * data structure, where nodes in the tree can contain arbitrary data.
7992  *
7993  * To create a new tree use g_node_new().
7994  *
7995  * To insert a node into a tree use g_node_insert(),
7996  * g_node_insert_before(), g_node_append() and g_node_prepend().
7997  *
7998  * To create a new node and insert it into a tree use
7999  * g_node_insert_data(), g_node_insert_data_after(),
8000  * g_node_insert_data_before(), g_node_append_data()
8001  * and g_node_prepend_data().
8002  *
8003  * To reverse the children of a node use g_node_reverse_children().
8004  *
8005  * To find a node use g_node_get_root(), g_node_find(),
8006  * g_node_find_child(), g_node_child_index(), g_node_child_position(),
8007  * g_node_first_child(), g_node_last_child(), g_node_nth_child(),
8008  * g_node_first_sibling(), g_node_prev_sibling(), g_node_next_sibling()
8009  * or g_node_last_sibling().
8010  *
8011  * To get information about a node or tree use G_NODE_IS_LEAF(),
8012  * G_NODE_IS_ROOT(), g_node_depth(), g_node_n_nodes(),
8013  * g_node_n_children(), g_node_is_ancestor() or g_node_max_height().
8014  *
8015  * To traverse a tree, calling a function for each node visited in the
8016  * traversal, use g_node_traverse() or g_node_children_foreach().
8017  *
8018  * To remove a node or subtree from a tree use g_node_unlink() or
8019  * g_node_destroy().
8020  */
8021
8022
8023 /**
8024  * SECTION:type_conversion
8025  * @title: Type Conversion Macros
8026  * @short_description: portably storing integers in pointer variables
8027  *
8028  * Many times GLib, GTK+, and other libraries allow you to pass "user
8029  * data" to a callback, in the form of a void pointer. From time to time
8030  * you want to pass an integer instead of a pointer. You could allocate
8031  * an integer, with something like:
8032  * |[
8033  *   int *ip = g_new (int, 1);
8034  *   *ip = 42;
8035  * ]|
8036  * But this is inconvenient, and it's annoying to have to free the
8037  * memory at some later time.
8038  *
8039  * Pointers are always at least 32 bits in size (on all platforms GLib
8040  * intends to support). Thus you can store at least 32-bit integer values
8041  * in a pointer value. Naively, you might try this, but it's incorrect:
8042  * |[
8043  *   gpointer p;
8044  *   int i;
8045  *   p = (void*) 42;
8046  *   i = (int) p;
8047  * ]|
8048  * Again, that example was <emphasis>not</emphasis> correct, don't copy it.
8049  * The problem is that on some systems you need to do this:
8050  * |[
8051  *   gpointer p;
8052  *   int i;
8053  *   p = (void*) (long) 42;
8054  *   i = (int) (long) p;
8055  * ]|
8056  * The GLib macros GPOINTER_TO_INT(), GINT_TO_POINTER(), etc. take care
8057  * to do the right thing on the every platform.
8058  *
8059  * <warning><para>You may not store pointers in integers. This is not
8060  * portable in any way, shape or form. These macros <emphasis>only</emphasis>
8061  * allow storing integers in pointers, and only preserve 32 bits of the
8062  * integer; values outside the range of a 32-bit integer will be mangled.
8063  * </para></warning>
8064  */
8065
8066
8067 /**
8068  * SECTION:types
8069  * @title: Basic Types
8070  * @short_description: standard GLib types, defined for ease-of-use
8071  *     and portability
8072  *
8073  * GLib defines a number of commonly used types, which can be divided
8074  * into 4 groups:
8075  * - New types which are not part of standard C (but are defined in
8076  *   various C standard library header files) - #gboolean, #gsize,
8077  *   #gssize, #goffset, #gintptr, #guintptr.
8078  * - Integer types which are guaranteed to be the same size across
8079  *   all platforms - #gint8, #guint8, #gint16, #guint16, #gint32,
8080  *   #guint32, #gint64, #guint64.
8081  * - Types which are easier to use than their standard C counterparts -
8082  *   #gpointer, #gconstpointer, #guchar, #guint, #gushort, #gulong.
8083  * - Types which correspond exactly to standard C types, but are
8084  *   included for completeness - #gchar, #gint, #gshort, #glong,
8085  *   #gfloat, #gdouble.
8086  *
8087  * GLib also defines macros for the limits of some of the standard
8088  * integer and floating point types, as well as macros for suitable
8089  * printf() formats for these types.
8090  */
8091
8092
8093 /**
8094  * SECTION:unicode
8095  * @Title: Unicode Manipulation
8096  * @Short_description: functions operating on Unicode characters and
8097  *     UTF-8 strings
8098  * @See_also: g_locale_to_utf8(), g_locale_from_utf8()
8099  *
8100  * This section describes a number of functions for dealing with
8101  * Unicode characters and strings.  There are analogues of the
8102  * traditional <filename>ctype.h</filename> character classification
8103  * and case conversion functions, UTF-8 analogues of some string utility
8104  * functions, functions to perform normalization, case conversion and
8105  * collation on UTF-8 strings and finally functions to convert between
8106  * the UTF-8, UTF-16 and UCS-4 encodings of Unicode.
8107  *
8108  * The implementations of the Unicode functions in GLib are based
8109  * on the Unicode Character Data tables, which are available from
8110  * <ulink url="http://www.unicode.org/">www.unicode.org</ulink>.
8111  * GLib 2.8 supports Unicode 4.0, GLib 2.10 supports Unicode 4.1,
8112  * GLib 2.12 supports Unicode 5.0, GLib 2.16.3 supports Unicode 5.1,
8113  * GLib 2.30 supports Unicode 6.0.
8114  */
8115
8116
8117 /**
8118  * SECTION:version
8119  * @Title: Version Information
8120  * @Short_description: variables and functions to check the GLib version
8121  *
8122  * GLib provides version information, primarily useful in configure
8123  * checks for builds that have a configure script. Applications will
8124  * not typically use the features described here.
8125  *
8126  * The GLib headers annotate deprecated APIs in a way that produces
8127  * compiler warnings if these deprecated APIs are used. The warnings
8128  * can be turned off by defining the macro %GLIB_DISABLE_DEPRECATION_WARNINGS
8129  * before including the glib.h header.
8130  *
8131  * GLib also provides support for building applications against
8132  * defined subsets of deprecated or new GLib APIs. Define the macro
8133  * %GLIB_VERSION_MIN_REQUIRED to specify up to what version of GLib
8134  * you want to receive warnings about deprecated APIs. Define the
8135  * macro %GLIB_VERSION_MAX_ALLOWED to specify the newest version of
8136  * GLib whose API you want to use.
8137  */
8138
8139
8140 /**
8141  * SECTION:warnings
8142  * @Title: Message Output and Debugging Functions
8143  * @Short_description: functions to output messages and help debug applications
8144  *
8145  * These functions provide support for outputting messages.
8146  *
8147  * The <function>g_return</function> family of macros (g_return_if_fail(),
8148  * g_return_val_if_fail(), g_return_if_reached(), g_return_val_if_reached())
8149  * should only be used for programming errors, a typical use case is
8150  * checking for invalid parameters at the beginning of a public function.
8151  * They should not be used if you just mean "if (error) return", they
8152  * should only be used if you mean "if (bug in program) return".
8153  * The program behavior is generally considered undefined after one
8154  * of these checks fails. They are not intended for normal control
8155  * flow, only to give a perhaps-helpful warning before giving up.
8156  */
8157
8158
8159 /**
8160  * SECTION:windows
8161  * @title: Windows Compatibility Functions
8162  * @short_description: UNIX emulation on Windows
8163  *
8164  * These functions provide some level of UNIX emulation on the
8165  * Windows platform. If your application really needs the POSIX
8166  * APIs, we suggest you try the Cygwin project.
8167  */
8168
8169
8170 /**
8171  * TRUE:
8172  *
8173  * Defines the %TRUE value for the #gboolean type.
8174  */
8175
8176
8177 /**
8178  * _:
8179  * @String: the string to be translated
8180  *
8181  * Marks a string for translation, gets replaced with the translated string
8182  * at runtime.
8183  *
8184  * Since: 2.4
8185  */
8186
8187
8188 /**
8189  * _glib_get_locale_dir:
8190  *
8191  * Return the path to the share\locale or lib\locale subfolder of the
8192  * GLib installation folder. The path is in the system codepage. We
8193  * have to use system codepage as bindtextdomain() doesn't have a
8194  * UTF-8 interface.
8195  */
8196
8197
8198 /**
8199  * g_access:
8200  * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
8201  * @mode: as in access()
8202  *
8203  * A wrapper for the POSIX access() function. This function is used to
8204  * test a pathname for one or several of read, write or execute
8205  * permissions, or just existence.
8206  *
8207  * On Windows, the file protection mechanism is not at all POSIX-like,
8208  * and the underlying function in the C library only checks the
8209  * FAT-style READONLY attribute, and does not look at the ACL of a
8210  * file at all. This function is this in practise almost useless on
8211  * Windows. Software that needs to handle file permissions on Windows
8212  * more exactly should use the Win32 API.
8213  *
8214  * See your C library manual for more details about access().
8215  *
8216  * Returns: zero if the pathname refers to an existing file system
8217  * object that has all the tested permissions, or -1 otherwise or on
8218  * error.
8219  * Since: 2.8
8220  */
8221
8222
8223 /**
8224  * g_array_append_val:
8225  * @a: a #GArray.
8226  * @v: the value to append to the #GArray.
8227  *
8228  * Adds the value on to the end of the array. The array will grow in
8229  * size automatically if necessary.
8230  *
8231  * <note><para>g_array_append_val() is a macro which uses a reference
8232  * to the value parameter @v. This means that you cannot use it with
8233  * literal values such as "27". You must use variables.</para></note>
8234  *
8235  * Returns: the #GArray.
8236  */
8237
8238
8239 /**
8240  * g_array_append_vals:
8241  * @array: a #GArray.
8242  * @data: a pointer to the elements to append to the end of the array.
8243  * @len: the number of elements to append.
8244  *
8245  * Adds @len elements onto the end of the array.
8246  *
8247  * Returns: the #GArray.
8248  */
8249
8250
8251 /**
8252  * g_array_free:
8253  * @array: a #GArray.
8254  * @free_segment: if %TRUE the actual element data is freed as well.
8255  *
8256  * Frees the memory allocated for the #GArray. If @free_segment is
8257  * %TRUE it frees the memory block holding the elements as well and
8258  * also each element if @array has a @element_free_func set. Pass
8259  * %FALSE if you want to free the #GArray wrapper but preserve the
8260  * underlying array for use elsewhere. If the reference count of @array
8261  * is greater than one, the #GArray wrapper is preserved but the size
8262  * of @array will be set to zero.
8263  *
8264  * <note><para>If array elements contain dynamically-allocated memory,
8265  * they should be freed separately.</para></note>
8266  *
8267  * Returns: the element data if @free_segment is %FALSE, otherwise
8268  *          %NULL.  The element data should be freed using g_free().
8269  */
8270
8271
8272 /**
8273  * g_array_get_element_size:
8274  * @array: A #GArray.
8275  *
8276  * Gets the size of the elements in @array.
8277  *
8278  * Returns: Size of each element, in bytes.
8279  * Since: 2.22
8280  */
8281
8282
8283 /**
8284  * g_array_index:
8285  * @a: a #GArray.
8286  * @t: the type of the elements.
8287  * @i: the index of the element to return.
8288  *
8289  * Returns the element of a #GArray at the given index. The return
8290  * value is cast to the given type.
8291  *
8292  * <example>
8293  *  <title>Getting a pointer to an element in a #GArray</title>
8294  *  <programlisting>
8295  *   EDayViewEvent *event;
8296  *   /<!-- -->* This gets a pointer to the 4th element
8297  *      in the array of EDayViewEvent structs. *<!-- -->/
8298  *   event = &amp;g_array_index (events, EDayViewEvent, 3);
8299  *  </programlisting>
8300  * </example>
8301  *
8302  * Returns: the element of the #GArray at the index given by @i.
8303  */
8304
8305
8306 /**
8307  * g_array_insert_val:
8308  * @a: a #GArray.
8309  * @i: the index to place the element at.
8310  * @v: the value to insert into the array.
8311  *
8312  * Inserts an element into an array at the given index.
8313  *
8314  * <note><para>g_array_insert_val() is a macro which uses a reference
8315  * to the value parameter @v. This means that you cannot use it with
8316  * literal values such as "27". You must use variables.</para></note>
8317  *
8318  * Returns: the #GArray.
8319  */
8320
8321
8322 /**
8323  * g_array_insert_vals:
8324  * @array: a #GArray.
8325  * @index_: the index to place the elements at.
8326  * @data: a pointer to the elements to insert.
8327  * @len: the number of elements to insert.
8328  *
8329  * Inserts @len elements into a #GArray at the given index.
8330  *
8331  * Returns: the #GArray.
8332  */
8333
8334
8335 /**
8336  * g_array_new:
8337  * @zero_terminated: %TRUE if the array should have an extra element at
8338  *                   the end which is set to 0.
8339  * @clear_: %TRUE if #GArray elements should be automatically cleared
8340  *          to 0 when they are allocated.
8341  * @element_size: the size of each element in bytes.
8342  *
8343  * Creates a new #GArray with a reference count of 1.
8344  *
8345  * Returns: the new #GArray.
8346  */
8347
8348
8349 /**
8350  * g_array_prepend_val:
8351  * @a: a #GArray.
8352  * @v: the value to prepend to the #GArray.
8353  *
8354  * Adds the value on to the start of the array. The array will grow in
8355  * size automatically if necessary.
8356  *
8357  * This operation is slower than g_array_append_val() since the
8358  * existing elements in the array have to be moved to make space for
8359  * the new element.
8360  *
8361  * <note><para>g_array_prepend_val() is a macro which uses a reference
8362  * to the value parameter @v. This means that you cannot use it with
8363  * literal values such as "27". You must use variables.</para></note>
8364  *
8365  * Returns: the #GArray.
8366  */
8367
8368
8369 /**
8370  * g_array_prepend_vals:
8371  * @array: a #GArray.
8372  * @data: a pointer to the elements to prepend to the start of the
8373  *        array.
8374  * @len: the number of elements to prepend.
8375  *
8376  * Adds @len elements onto the start of the array.
8377  *
8378  * This operation is slower than g_array_append_vals() since the
8379  * existing elements in the array have to be moved to make space for
8380  * the new elements.
8381  *
8382  * Returns: the #GArray.
8383  */
8384
8385
8386 /**
8387  * g_array_ref:
8388  * @array: A #GArray.
8389  *
8390  * Atomically increments the reference count of @array by one. This
8391  * function is MT-safe and may be called from any thread.
8392  *
8393  * Returns: The passed in #GArray.
8394  * Since: 2.22
8395  */
8396
8397
8398 /**
8399  * g_array_remove_index:
8400  * @array: a #GArray.
8401  * @index_: the index of the element to remove.
8402  *
8403  * Removes the element at the given index from a #GArray. The following
8404  * elements are moved down one place.
8405  *
8406  * Returns: the #GArray.
8407  */
8408
8409
8410 /**
8411  * g_array_remove_index_fast:
8412  * @array: a @GArray.
8413  * @index_: the index of the element to remove.
8414  *
8415  * Removes the element at the given index from a #GArray. The last
8416  * element in the array is used to fill in the space, so this function
8417  * does not preserve the order of the #GArray. But it is faster than
8418  * g_array_remove_index().
8419  *
8420  * Returns: the #GArray.
8421  */
8422
8423
8424 /**
8425  * g_array_remove_range:
8426  * @array: a @GArray.
8427  * @index_: the index of the first element to remove.
8428  * @length: the number of elements to remove.
8429  *
8430  * Removes the given number of elements starting at the given index
8431  * from a #GArray.  The following elements are moved to close the gap.
8432  *
8433  * Returns: the #GArray.
8434  * Since: 2.4
8435  */
8436
8437
8438 /**
8439  * g_array_set_clear_func:
8440  * @array: A #GArray
8441  * @clear_func: a function to clear an element of @array
8442  *
8443  * Sets a function to clear an element of @array.
8444  *
8445  * The @clear_func will be called when an element in the array
8446  * data segment is removed and when the array is freed and data
8447  * segment is deallocated as well.
8448  *
8449  * Note that in contrast with other uses of #GDestroyNotify
8450  * functions, @clear_func is expected to clear the contents of
8451  * the array element it is given, but not free the element itself.
8452  *
8453  * Since: 2.32
8454  */
8455
8456
8457 /**
8458  * g_array_set_size:
8459  * @array: a #GArray.
8460  * @length: the new size of the #GArray.
8461  *
8462  * Sets the size of the array, expanding it if necessary. If the array
8463  * was created with @clear_ set to %TRUE, the new elements are set to 0.
8464  *
8465  * Returns: the #GArray.
8466  */
8467
8468
8469 /**
8470  * g_array_sized_new:
8471  * @zero_terminated: %TRUE if the array should have an extra element at
8472  *                   the end with all bits cleared.
8473  * @clear_: %TRUE if all bits in the array should be cleared to 0 on
8474  *          allocation.
8475  * @element_size: size of each element in the array.
8476  * @reserved_size: number of elements preallocated.
8477  *
8478  * Creates a new #GArray with @reserved_size elements preallocated and
8479  * a reference count of 1. This avoids frequent reallocation, if you
8480  * are going to add many elements to the array. Note however that the
8481  * size of the array is still 0.
8482  *
8483  * Returns: the new #GArray.
8484  */
8485
8486
8487 /**
8488  * g_array_sort:
8489  * @array: a #GArray.
8490  * @compare_func: comparison function.
8491  *
8492  * Sorts a #GArray using @compare_func which should be a qsort()-style
8493  * comparison function (returns less than zero for first arg is less
8494  * than second arg, zero for equal, greater zero if first arg is
8495  * greater than second arg).
8496  *
8497  * This is guaranteed to be a stable sort since version 2.32.
8498  */
8499
8500
8501 /**
8502  * g_array_sort_with_data:
8503  * @array: a #GArray.
8504  * @compare_func: comparison function.
8505  * @user_data: data to pass to @compare_func.
8506  *
8507  * Like g_array_sort(), but the comparison function receives an extra
8508  * user data argument.
8509  *
8510  * This is guaranteed to be a stable sort since version 2.32.
8511  *
8512  * There used to be a comment here about making the sort stable by
8513  * using the addresses of the elements in the comparison function.
8514  * This did not actually work, so any such code should be removed.
8515  */
8516
8517
8518 /**
8519  * g_array_unref:
8520  * @array: A #GArray.
8521  *
8522  * Atomically decrements the reference count of @array by one. If the
8523  * reference count drops to 0, all memory allocated by the array is
8524  * released. This function is MT-safe and may be called from any
8525  * thread.
8526  *
8527  * Since: 2.22
8528  */
8529
8530
8531 /**
8532  * g_ascii_digit_value:
8533  * @c: an ASCII character.
8534  *
8535  * Determines the numeric value of a character as a decimal
8536  * digit. Differs from g_unichar_digit_value() because it takes
8537  * a char, so there's no worry about sign extension if characters
8538  * are signed.
8539  *
8540  * Returns: If @c is a decimal digit (according to
8541  * g_ascii_isdigit()), its numeric value. Otherwise, -1.
8542  */
8543
8544
8545 /**
8546  * g_ascii_dtostr:
8547  * @buffer: A buffer to place the resulting string in
8548  * @buf_len: The length of the buffer.
8549  * @d: The #gdouble to convert
8550  *
8551  * Converts a #gdouble to a string, using the '.' as
8552  * decimal point.
8553  *
8554  * This functions generates enough precision that converting
8555  * the string back using g_ascii_strtod() gives the same machine-number
8556  * (on machines with IEEE compatible 64bit doubles). It is
8557  * guaranteed that the size of the resulting string will never
8558  * be larger than @G_ASCII_DTOSTR_BUF_SIZE bytes.
8559  *
8560  * Returns: The pointer to the buffer with the converted string.
8561  */
8562
8563
8564 /**
8565  * g_ascii_formatd:
8566  * @buffer: A buffer to place the resulting string in
8567  * @buf_len: The length of the buffer.
8568  * @format: The printf()-style format to use for the
8569  *          code to use for converting.
8570  * @d: The #gdouble to convert
8571  *
8572  * Converts a #gdouble to a string, using the '.' as
8573  * decimal point. To format the number you pass in
8574  * a printf()-style format string. Allowed conversion
8575  * specifiers are 'e', 'E', 'f', 'F', 'g' and 'G'.
8576  *
8577  * If you just want to want to serialize the value into a
8578  * string, use g_ascii_dtostr().
8579  *
8580  * Returns: The pointer to the buffer with the converted string.
8581  */
8582
8583
8584 /**
8585  * g_ascii_isalnum:
8586  * @c: any character
8587  *
8588  * Determines whether a character is alphanumeric.
8589  *
8590  * Unlike the standard C library isalnum() function, this only
8591  * recognizes standard ASCII letters and ignores the locale,
8592  * returning %FALSE for all non-ASCII characters. Also, unlike
8593  * the standard library function, this takes a <type>char</type>,
8594  * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need to
8595  * cast to #guchar before passing a possibly non-ASCII character in.
8596  *
8597  * Returns: %TRUE if @c is an ASCII alphanumeric character
8598  */
8599
8600
8601 /**
8602  * g_ascii_isalpha:
8603  * @c: any character
8604  *
8605  * Determines whether a character is alphabetic (i.e. a letter).
8606  *
8607  * Unlike the standard C library isalpha() function, this only
8608  * recognizes standard ASCII letters and ignores the locale,
8609  * returning %FALSE for all non-ASCII characters. Also, unlike
8610  * the standard library function, this takes a <type>char</type>,
8611  * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need to
8612  * cast to #guchar before passing a possibly non-ASCII character in.
8613  *
8614  * Returns: %TRUE if @c is an ASCII alphabetic character
8615  */
8616
8617
8618 /**
8619  * g_ascii_iscntrl:
8620  * @c: any character
8621  *
8622  * Determines whether a character is a control character.
8623  *
8624  * Unlike the standard C library iscntrl() function, this only
8625  * recognizes standard ASCII control characters and ignores the
8626  * locale, returning %FALSE for all non-ASCII characters. Also,
8627  * unlike the standard library function, this takes a <type>char</type>,
8628  * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need to
8629  * cast to #guchar before passing a possibly non-ASCII character in.
8630  *
8631  * Returns: %TRUE if @c is an ASCII control character.
8632  */
8633
8634
8635 /**
8636  * g_ascii_isdigit:
8637  * @c: any character
8638  *
8639  * Determines whether a character is digit (0-9).
8640  *
8641  * Unlike the standard C library isdigit() function, this takes
8642  * a <type>char</type>, not an <type>int</type>, so don't call it
8643  * on <literal>EOF</literal>, but no need to cast to #guchar before passing a possibly
8644  * non-ASCII character in.
8645  *
8646  * Returns: %TRUE if @c is an ASCII digit.
8647  */
8648
8649
8650 /**
8651  * g_ascii_isgraph:
8652  * @c: any character
8653  *
8654  * Determines whether a character is a printing character and not a space.
8655  *
8656  * Unlike the standard C library isgraph() function, this only
8657  * recognizes standard ASCII characters and ignores the locale,
8658  * returning %FALSE for all non-ASCII characters. Also, unlike
8659  * the standard library function, this takes a <type>char</type>,
8660  * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need
8661  * to cast to #guchar before passing a possibly non-ASCII character in.
8662  *
8663  * Returns: %TRUE if @c is an ASCII printing character other than space.
8664  */
8665
8666
8667 /**
8668  * g_ascii_islower:
8669  * @c: any character
8670  *
8671  * Determines whether a character is an ASCII lower case letter.
8672  *
8673  * Unlike the standard C library islower() function, this only
8674  * recognizes standard ASCII letters and ignores the locale,
8675  * returning %FALSE for all non-ASCII characters. Also, unlike
8676  * the standard library function, this takes a <type>char</type>,
8677  * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need
8678  * to worry about casting to #guchar before passing a possibly
8679  * non-ASCII character in.
8680  *
8681  * Returns: %TRUE if @c is an ASCII lower case letter
8682  */
8683
8684
8685 /**
8686  * g_ascii_isprint:
8687  * @c: any character
8688  *
8689  * Determines whether a character is a printing character.
8690  *
8691  * Unlike the standard C library isprint() function, this only
8692  * recognizes standard ASCII characters and ignores the locale,
8693  * returning %FALSE for all non-ASCII characters. Also, unlike
8694  * the standard library function, this takes a <type>char</type>,
8695  * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need
8696  * to cast to #guchar before passing a possibly non-ASCII character in.
8697  *
8698  * Returns: %TRUE if @c is an ASCII printing character.
8699  */
8700
8701
8702 /**
8703  * g_ascii_ispunct:
8704  * @c: any character
8705  *
8706  * Determines whether a character is a punctuation character.
8707  *
8708  * Unlike the standard C library ispunct() function, this only
8709  * recognizes standard ASCII letters and ignores the locale,
8710  * returning %FALSE for all non-ASCII characters. Also, unlike
8711  * the standard library function, this takes a <type>char</type>,
8712  * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need to
8713  * cast to #guchar before passing a possibly non-ASCII character in.
8714  *
8715  * Returns: %TRUE if @c is an ASCII punctuation character.
8716  */
8717
8718
8719 /**
8720  * g_ascii_isspace:
8721  * @c: any character
8722  *
8723  * Determines whether a character is a white-space character.
8724  *
8725  * Unlike the standard C library isspace() function, this only
8726  * recognizes standard ASCII white-space and ignores the locale,
8727  * returning %FALSE for all non-ASCII characters. Also, unlike
8728  * the standard library function, this takes a <type>char</type>,
8729  * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need to
8730  * cast to #guchar before passing a possibly non-ASCII character in.
8731  *
8732  * Returns: %TRUE if @c is an ASCII white-space character
8733  */
8734
8735
8736 /**
8737  * g_ascii_isupper:
8738  * @c: any character
8739  *
8740  * Determines whether a character is an ASCII upper case letter.
8741  *
8742  * Unlike the standard C library isupper() function, this only
8743  * recognizes standard ASCII letters and ignores the locale,
8744  * returning %FALSE for all non-ASCII characters. Also, unlike
8745  * the standard library function, this takes a <type>char</type>,
8746  * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need to
8747  * worry about casting to #guchar before passing a possibly non-ASCII
8748  * character in.
8749  *
8750  * Returns: %TRUE if @c is an ASCII upper case letter
8751  */
8752
8753
8754 /**
8755  * g_ascii_isxdigit:
8756  * @c: any character
8757  *
8758  * Determines whether a character is a hexadecimal-digit character.
8759  *
8760  * Unlike the standard C library isxdigit() function, this takes
8761  * a <type>char</type>, not an <type>int</type>, so don't call it
8762  * on <literal>EOF</literal>, but no need to cast to #guchar before passing a
8763  * possibly non-ASCII character in.
8764  *
8765  * Returns: %TRUE if @c is an ASCII hexadecimal-digit character.
8766  */
8767
8768
8769 /**
8770  * g_ascii_strcasecmp:
8771  * @s1: string to compare with @s2.
8772  * @s2: string to compare with @s1.
8773  *
8774  * Compare two strings, ignoring the case of ASCII characters.
8775  *
8776  * Unlike the BSD strcasecmp() function, this only recognizes standard
8777  * ASCII letters and ignores the locale, treating all non-ASCII
8778  * bytes as if they are not letters.
8779  *
8780  * This function should be used only on strings that are known to be
8781  * in encodings where the bytes corresponding to ASCII letters always
8782  * represent themselves. This includes UTF-8 and the ISO-8859-*
8783  * charsets, but not for instance double-byte encodings like the
8784  * Windows Codepage 932, where the trailing bytes of double-byte
8785  * characters include all ASCII letters. If you compare two CP932
8786  * strings using this function, you will get false matches.
8787  *
8788  * Returns: 0 if the strings match, a negative value if @s1 &lt; @s2,
8789  *   or a positive value if @s1 &gt; @s2.
8790  */
8791
8792
8793 /**
8794  * g_ascii_strdown:
8795  * @str: a string.
8796  * @len: length of @str in bytes, or -1 if @str is nul-terminated.
8797  *
8798  * Converts all upper case ASCII letters to lower case ASCII letters.
8799  *
8800  * Returns: a newly-allocated string, with all the upper case
8801  *               characters in @str converted to lower case, with
8802  *               semantics that exactly match g_ascii_tolower(). (Note
8803  *               that this is unlike the old g_strdown(), which modified
8804  *               the string in place.)
8805  */
8806
8807
8808 /**
8809  * g_ascii_strncasecmp:
8810  * @s1: string to compare with @s2.
8811  * @s2: string to compare with @s1.
8812  * @n: number of characters to compare.
8813  *
8814  * Compare @s1 and @s2, ignoring the case of ASCII characters and any
8815  * characters after the first @n in each string.
8816  *
8817  * Unlike the BSD strcasecmp() function, this only recognizes standard
8818  * ASCII letters and ignores the locale, treating all non-ASCII
8819  * characters as if they are not letters.
8820  *
8821  * The same warning as in g_ascii_strcasecmp() applies: Use this
8822  * function only on strings known to be in encodings where bytes
8823  * corresponding to ASCII letters always represent themselves.
8824  *
8825  * Returns: 0 if the strings match, a negative value if @s1 &lt; @s2,
8826  *   or a positive value if @s1 &gt; @s2.
8827  */
8828
8829
8830 /**
8831  * g_ascii_strtod:
8832  * @nptr: the string to convert to a numeric value.
8833  * @endptr: if non-%NULL, it returns the character after
8834  *           the last character used in the conversion.
8835  *
8836  * Converts a string to a #gdouble value.
8837  *
8838  * This function behaves like the standard strtod() function
8839  * does in the C locale. It does this without actually changing
8840  * the current locale, since that would not be thread-safe.
8841  * A limitation of the implementation is that this function
8842  * will still accept localized versions of infinities and NANs.
8843  *
8844  * This function is typically used when reading configuration
8845  * files or other non-user input that should be locale independent.
8846  * To handle input from the user you should normally use the
8847  * locale-sensitive system strtod() function.
8848  *
8849  * To convert from a #gdouble to a string in a locale-insensitive
8850  * way, use g_ascii_dtostr().
8851  *
8852  * If the correct value would cause overflow, plus or minus <literal>HUGE_VAL</literal>
8853  * is returned (according to the sign of the value), and <literal>ERANGE</literal> is
8854  * stored in <literal>errno</literal>. If the correct value would cause underflow,
8855  * zero is returned and <literal>ERANGE</literal> is stored in <literal>errno</literal>.
8856  *
8857  * This function resets <literal>errno</literal> before calling strtod() so that
8858  * you can reliably detect overflow and underflow.
8859  *
8860  * Returns: the #gdouble value.
8861  */
8862
8863
8864 /**
8865  * g_ascii_strtoll:
8866  * @nptr: the string to convert to a numeric value.
8867  * @endptr: if non-%NULL, it returns the character after
8868  *           the last character used in the conversion.
8869  * @base: to be used for the conversion, 2..36 or 0
8870  *
8871  * Converts a string to a #gint64 value.
8872  * This function behaves like the standard strtoll() function
8873  * does in the C locale. It does this without actually
8874  * changing the current locale, since that would not be
8875  * thread-safe.
8876  *
8877  * This function is typically used when reading configuration
8878  * files or other non-user input that should be locale independent.
8879  * To handle input from the user you should normally use the
8880  * locale-sensitive system strtoll() function.
8881  *
8882  * If the correct value would cause overflow, %G_MAXINT64 or %G_MININT64
8883  * is returned, and <literal>ERANGE</literal> is stored in <literal>errno</literal>.
8884  * If the base is outside the valid range, zero is returned, and
8885  * <literal>EINVAL</literal> is stored in <literal>errno</literal>. If the
8886  * string conversion fails, zero is returned, and @endptr returns @nptr
8887  * (if @endptr is non-%NULL).
8888  *
8889  * Returns: the #gint64 value or zero on error.
8890  * Since: 2.12
8891  */
8892
8893
8894 /**
8895  * g_ascii_strtoull:
8896  * @nptr: the string to convert to a numeric value.
8897  * @endptr: if non-%NULL, it returns the character after
8898  *           the last character used in the conversion.
8899  * @base: to be used for the conversion, 2..36 or 0
8900  *
8901  * Converts a string to a #guint64 value.
8902  * This function behaves like the standard strtoull() function
8903  * does in the C locale. It does this without actually
8904  * changing the current locale, since that would not be
8905  * thread-safe.
8906  *
8907  * This function is typically used when reading configuration
8908  * files or other non-user input that should be locale independent.
8909  * To handle input from the user you should normally use the
8910  * locale-sensitive system strtoull() function.
8911  *
8912  * If the correct value would cause overflow, %G_MAXUINT64
8913  * is returned, and <literal>ERANGE</literal> is stored in <literal>errno</literal>.
8914  * If the base is outside the valid range, zero is returned, and
8915  * <literal>EINVAL</literal> is stored in <literal>errno</literal>.
8916  * If the string conversion fails, zero is returned, and @endptr returns
8917  * @nptr (if @endptr is non-%NULL).
8918  *
8919  * Returns: the #guint64 value or zero on error.
8920  * Since: 2.2
8921  */
8922
8923
8924 /**
8925  * g_ascii_strup:
8926  * @str: a string.
8927  * @len: length of @str in bytes, or -1 if @str is nul-terminated.
8928  *
8929  * Converts all lower case ASCII letters to upper case ASCII letters.
8930  *
8931  * Returns: a newly allocated string, with all the lower case
8932  *               characters in @str converted to upper case, with
8933  *               semantics that exactly match g_ascii_toupper(). (Note
8934  *               that this is unlike the old g_strup(), which modified
8935  *               the string in place.)
8936  */
8937
8938
8939 /**
8940  * g_ascii_tolower:
8941  * @c: any character.
8942  *
8943  * Convert a character to ASCII lower case.
8944  *
8945  * Unlike the standard C library tolower() function, this only
8946  * recognizes standard ASCII letters and ignores the locale, returning
8947  * all non-ASCII characters unchanged, even if they are lower case
8948  * letters in a particular character set. Also unlike the standard
8949  * library function, this takes and returns a char, not an int, so
8950  * don't call it on <literal>EOF</literal> but no need to worry about casting to #guchar
8951  * before passing a possibly non-ASCII character in.
8952  *
8953  * Returns: the result of converting @c to lower case.
8954  *               If @c is not an ASCII upper case letter,
8955  *               @c is returned unchanged.
8956  */
8957
8958
8959 /**
8960  * g_ascii_toupper:
8961  * @c: any character.
8962  *
8963  * Convert a character to ASCII upper case.
8964  *
8965  * Unlike the standard C library toupper() function, this only
8966  * recognizes standard ASCII letters and ignores the locale, returning
8967  * all non-ASCII characters unchanged, even if they are upper case
8968  * letters in a particular character set. Also unlike the standard
8969  * library function, this takes and returns a char, not an int, so
8970  * don't call it on <literal>EOF</literal> but no need to worry about casting to #guchar
8971  * before passing a possibly non-ASCII character in.
8972  *
8973  * Returns: the result of converting @c to upper case.
8974  *               If @c is not an ASCII lower case letter,
8975  *               @c is returned unchanged.
8976  */
8977
8978
8979 /**
8980  * g_ascii_xdigit_value:
8981  * @c: an ASCII character.
8982  *
8983  * Determines the numeric value of a character as a hexidecimal
8984  * digit. Differs from g_unichar_xdigit_value() because it takes
8985  * a char, so there's no worry about sign extension if characters
8986  * are signed.
8987  *
8988  * Returns: If @c is a hex digit (according to
8989  * g_ascii_isxdigit()), its numeric value. Otherwise, -1.
8990  */
8991
8992
8993 /**
8994  * g_assert:
8995  * @expr: the expression to check
8996  *
8997  * Debugging macro to terminate the application if the assertion
8998  * fails. If the assertion fails (i.e. the expression is not true),
8999  * an error message is logged and the application is terminated.
9000  *
9001  * The macro can be turned off in final releases of code by defining
9002  * <envar>G_DISABLE_ASSERT</envar> when compiling the application.
9003  */
9004
9005
9006 /**
9007  * g_assert_cmpfloat:
9008  * @n1: an floating point number
9009  * @cmp: The comparison operator to use.
9010  *     One of ==, !=, &lt;, &gt;, &lt;=, &gt;=.
9011  * @n2: another floating point number
9012  *
9013  * Debugging macro to compare two floating point numbers.
9014  *
9015  * The effect of <literal>g_assert_cmpfloat (n1, op, n2)</literal> is
9016  * the same as <literal>g_assert_true (n1 op n2)</literal>. The advantage
9017  * of this macro is that it can produce a message that includes the
9018  * actual values of @n1 and @n2.
9019  *
9020  * Since: 2.16
9021  */
9022
9023
9024 /**
9025  * g_assert_cmphex:
9026  * @n1: an unsigned integer
9027  * @cmp: The comparison operator to use.
9028  *     One of ==, !=, &lt;, &gt;, &lt;=, &gt;=.
9029  * @n2: another unsigned integer
9030  *
9031  * Debugging macro to compare to unsigned integers.
9032  *
9033  * This is a variant of g_assert_cmpuint() that displays the numbers
9034  * in hexadecimal notation in the message.
9035  *
9036  * Since: 2.16
9037  */
9038
9039
9040 /**
9041  * g_assert_cmpint:
9042  * @n1: an integer
9043  * @cmp: The comparison operator to use.
9044  *     One of ==, !=, &lt;, &gt;, &lt;=, &gt;=.
9045  * @n2: another integer
9046  *
9047  * Debugging macro to compare two integers.
9048  *
9049  * The effect of <literal>g_assert_cmpint (n1, op, n2)</literal> is
9050  * the same as <literal>g_assert_true (n1 op n2)</literal>. The advantage
9051  * of this macro is that it can produce a message that includes the
9052  * actual values of @n1 and @n2.
9053  *
9054  * Since: 2.16
9055  */
9056
9057
9058 /**
9059  * g_assert_cmpstr:
9060  * @s1: a string (may be %NULL)
9061  * @cmp: The comparison operator to use.
9062  *     One of ==, !=, &lt;, &gt;, &lt;=, &gt;=.
9063  * @s2: another string (may be %NULL)
9064  *
9065  * Debugging macro to compare two strings. If the comparison fails,
9066  * an error message is logged and the application is either terminated
9067  * or the testcase marked as failed.
9068  * The strings are compared using g_strcmp0().
9069  *
9070  * The effect of <literal>g_assert_cmpstr (s1, op, s2)</literal> is
9071  * the same as <literal>g_assert_true (g_strcmp0 (s1, s2) op 0)</literal>.
9072  * The advantage of this macro is that it can produce a message that
9073  * includes the actual values of @s1 and @s2.
9074  *
9075  * |[
9076  *   g_assert_cmpstr (mystring, ==, "fubar");
9077  * ]|
9078  *
9079  * Since: 2.16
9080  */
9081
9082
9083 /**
9084  * g_assert_cmpuint:
9085  * @n1: an unsigned integer
9086  * @cmp: The comparison operator to use.
9087  *     One of ==, !=, &lt;, &gt;, &lt;=, &gt;=.
9088  * @n2: another unsigned integer
9089  *
9090  * Debugging macro to compare two unsigned integers.
9091  *
9092  * The effect of <literal>g_assert_cmpuint (n1, op, n2)</literal> is
9093  * the same as <literal>g_assert_true (n1 op n2)</literal>. The advantage
9094  * of this macro is that it can produce a message that includes the
9095  * actual values of @n1 and @n2.
9096  *
9097  * Since: 2.16
9098  */
9099
9100
9101 /**
9102  * g_assert_error:
9103  * @err: a #GError, possibly %NULL
9104  * @dom: the expected error domain (a #GQuark)
9105  * @c: the expected error code
9106  *
9107  * Debugging macro to check that a method has returned
9108  * the correct #GError.
9109  *
9110  * The effect of <literal>g_assert_error (err, dom, c)</literal> is
9111  * the same as <literal>g_assert_true (err != NULL &amp;&amp; err->domain
9112  * == dom &amp;&amp; err->code == c)</literal>. The advantage of this
9113  * macro is that it can produce a message that includes the incorrect
9114  * error message and code.
9115  *
9116  * This can only be used to test for a specific error. If you want to
9117  * test that @err is set, but don't care what it's set to, just use
9118  * <literal>g_assert (err != NULL)</literal>
9119  *
9120  * Since: 2.20
9121  */
9122
9123
9124 /**
9125  * g_assert_false:
9126  * @expr: the expression to check
9127  *
9128  * Debugging macro to check an expression is false.
9129  *
9130  * If the assertion fails (i.e. the expression is not false),
9131  * an error message is logged and the application is either
9132  * terminated or the testcase marked as failed.
9133  *
9134  * See g_test_set_nonfatal_assertions().
9135  *
9136  * Since: 2.38
9137  */
9138
9139
9140 /**
9141  * g_assert_no_error:
9142  * @err: a #GError, possibly %NULL
9143  *
9144  * Debugging macro to check that a #GError is not set.
9145  *
9146  * The effect of <literal>g_assert_no_error (err)</literal> is
9147  * the same as <literal>g_assert_true (err == NULL)</literal>. The advantage
9148  * of this macro is that it can produce a message that includes
9149  * the error message and code.
9150  *
9151  * Since: 2.20
9152  */
9153
9154
9155 /**
9156  * g_assert_not_reached:
9157  *
9158  * Debugging macro to terminate the application if it is ever
9159  * reached. If it is reached, an error message is logged and the
9160  * application is terminated.
9161  *
9162  * The macro can be turned off in final releases of code by defining
9163  * <envar>G_DISABLE_ASSERT</envar> when compiling the application.
9164  */
9165
9166
9167 /**
9168  * g_assert_null:
9169  * @expr: the expression to check
9170  *
9171  * Debugging macro to check an expression is %NULL.
9172  *
9173  * If the assertion fails (i.e. the expression is not %NULL),
9174  * an error message is logged and the application is either
9175  * terminated or the testcase marked as failed.
9176  *
9177  * See g_test_set_nonfatal_assertions().
9178  *
9179  * Since: 2.38
9180  */
9181
9182
9183 /**
9184  * g_assert_true:
9185  * @expr: the expression to check
9186  *
9187  * Debugging macro to check that an expression is true.
9188  *
9189  * If the assertion fails (i.e. the expression is not true),
9190  * an error message is logged and the application is either
9191  * terminated or the testcase marked as failed.
9192  *
9193  * See g_test_set_nonfatal_assertions().
9194  *
9195  * Since: 2.38
9196  */
9197
9198
9199 /**
9200  * g_async_queue_length:
9201  * @queue: a #GAsyncQueue.
9202  *
9203  * Returns the length of the queue.
9204  *
9205  * Actually this function returns the number of data items in
9206  * the queue minus the number of waiting threads, so a negative
9207  * value means waiting threads, and a positive value means available
9208  * entries in the @queue. A return value of 0 could mean n entries
9209  * in the queue and n threads waiting. This can happen due to locking
9210  * of the queue or due to scheduling.
9211  *
9212  * Returns: the length of the @queue
9213  */
9214
9215
9216 /**
9217  * g_async_queue_length_unlocked:
9218  * @queue: a #GAsyncQueue
9219  *
9220  * Returns the length of the queue.
9221  *
9222  * Actually this function returns the number of data items in
9223  * the queue minus the number of waiting threads, so a negative
9224  * value means waiting threads, and a positive value means available
9225  * entries in the @queue. A return value of 0 could mean n entries
9226  * in the queue and n threads waiting. This can happen due to locking
9227  * of the queue or due to scheduling.
9228  *
9229  * This function must be called while holding the @queue's lock.
9230  *
9231  * Returns: the length of the @queue.
9232  */
9233
9234
9235 /**
9236  * g_async_queue_lock:
9237  * @queue: a #GAsyncQueue
9238  *
9239  * Acquires the @queue's lock. If another thread is already
9240  * holding the lock, this call will block until the lock
9241  * becomes available.
9242  *
9243  * Call g_async_queue_unlock() to drop the lock again.
9244  *
9245  * While holding the lock, you can only call the
9246  * <function>g_async_queue_*_unlocked()</function> functions
9247  * on @queue. Otherwise, deadlock may occur.
9248  */
9249
9250
9251 /**
9252  * g_async_queue_new:
9253  *
9254  * Creates a new asynchronous queue.
9255  *
9256  * Returns: a new #GAsyncQueue. Free with g_async_queue_unref()
9257  */
9258
9259
9260 /**
9261  * g_async_queue_new_full:
9262  * @item_free_func: function to free queue elements
9263  *
9264  * Creates a new asynchronous queue and sets up a destroy notify
9265  * function that is used to free any remaining queue items when
9266  * the queue is destroyed after the final unref.
9267  *
9268  * Returns: a new #GAsyncQueue. Free with g_async_queue_unref()
9269  * Since: 2.16
9270  */
9271
9272
9273 /**
9274  * g_async_queue_pop:
9275  * @queue: a #GAsyncQueue
9276  *
9277  * Pops data from the @queue. If @queue is empty, this function
9278  * blocks until data becomes available.
9279  *
9280  * Returns: data from the queue
9281  */
9282
9283
9284 /**
9285  * g_async_queue_pop_unlocked:
9286  * @queue: a #GAsyncQueue
9287  *
9288  * Pops data from the @queue. If @queue is empty, this function
9289  * blocks until data becomes available.
9290  *
9291  * This function must be called while holding the @queue's lock.
9292  *
9293  * Returns: data from the queue.
9294  */
9295
9296
9297 /**
9298  * g_async_queue_push:
9299  * @queue: a #GAsyncQueue
9300  * @data: @data to push into the @queue
9301  *
9302  * Pushes the @data into the @queue. @data must not be %NULL.
9303  */
9304
9305
9306 /**
9307  * g_async_queue_push_sorted:
9308  * @queue: a #GAsyncQueue
9309  * @data: the @data to push into the @queue
9310  * @func: the #GCompareDataFunc is used to sort @queue
9311  * @user_data: user data passed to @func.
9312  *
9313  * Inserts @data into @queue using @func to determine the new
9314  * position.
9315  *
9316  * This function requires that the @queue is sorted before pushing on
9317  * new elements, see g_async_queue_sort().
9318  *
9319  * This function will lock @queue before it sorts the queue and unlock
9320  * it when it is finished.
9321  *
9322  * For an example of @func see g_async_queue_sort().
9323  *
9324  * Since: 2.10
9325  */
9326
9327
9328 /**
9329  * g_async_queue_push_sorted_unlocked:
9330  * @queue: a #GAsyncQueue
9331  * @data: the @data to push into the @queue
9332  * @func: the #GCompareDataFunc is used to sort @queue
9333  * @user_data: user data passed to @func.
9334  *
9335  * Inserts @data into @queue using @func to determine the new
9336  * position.
9337  *
9338  * The sort function @func is passed two elements of the @queue.
9339  * It should return 0 if they are equal, a negative value if the
9340  * first element should be higher in the @queue or a positive value
9341  * if the first element should be lower in the @queue than the second
9342  * element.
9343  *
9344  * This function requires that the @queue is sorted before pushing on
9345  * new elements, see g_async_queue_sort().
9346  *
9347  * This function must be called while holding the @queue's lock.
9348  *
9349  * For an example of @func see g_async_queue_sort().
9350  *
9351  * Since: 2.10
9352  */
9353
9354
9355 /**
9356  * g_async_queue_push_unlocked:
9357  * @queue: a #GAsyncQueue
9358  * @data: @data to push into the @queue
9359  *
9360  * Pushes the @data into the @queue. @data must not be %NULL.
9361  *
9362  * This function must be called while holding the @queue's lock.
9363  */
9364
9365
9366 /**
9367  * g_async_queue_ref:
9368  * @queue: a #GAsyncQueue
9369  *
9370  * Increases the reference count of the asynchronous @queue by 1.
9371  * You do not need to hold the lock to call this function.
9372  *
9373  * Returns: the @queue that was passed in (since 2.6)
9374  */
9375
9376
9377 /**
9378  * g_async_queue_ref_unlocked:
9379  * @queue: a #GAsyncQueue
9380  *
9381  * Increases the reference count of the asynchronous @queue by 1.
9382  *
9383  * Deprecated: 2.8: Reference counting is done atomically.
9384  * so g_async_queue_ref() can be used regardless of the @queue's
9385  * lock.
9386  */
9387
9388
9389 /**
9390  * g_async_queue_sort:
9391  * @queue: a #GAsyncQueue
9392  * @func: the #GCompareDataFunc is used to sort @queue
9393  * @user_data: user data passed to @func
9394  *
9395  * Sorts @queue using @func.
9396  *
9397  * The sort function @func is passed two elements of the @queue.
9398  * It should return 0 if they are equal, a negative value if the
9399  * first element should be higher in the @queue or a positive value
9400  * if the first element should be lower in the @queue than the second
9401  * element.
9402  *
9403  * This function will lock @queue before it sorts the queue and unlock
9404  * it when it is finished.
9405  *
9406  * If you were sorting a list of priority numbers to make sure the
9407  * lowest priority would be at the top of the queue, you could use:
9408  * |[
9409  *  gint32 id1;
9410  *  gint32 id2;
9411  *
9412  *  id1 = GPOINTER_TO_INT (element1);
9413  *  id2 = GPOINTER_TO_INT (element2);
9414  *
9415  *  return (id1 > id2 ? +1 : id1 == id2 ? 0 : -1);
9416  * ]|
9417  *
9418  * Since: 2.10
9419  */
9420
9421
9422 /**
9423  * g_async_queue_sort_unlocked:
9424  * @queue: a #GAsyncQueue
9425  * @func: the #GCompareDataFunc is used to sort @queue
9426  * @user_data: user data passed to @func
9427  *
9428  * Sorts @queue using @func.
9429  *
9430  * The sort function @func is passed two elements of the @queue.
9431  * It should return 0 if they are equal, a negative value if the
9432  * first element should be higher in the @queue or a positive value
9433  * if the first element should be lower in the @queue than the second
9434  * element.
9435  *
9436  * This function must be called while holding the @queue's lock.
9437  *
9438  * Since: 2.10
9439  */
9440
9441
9442 /**
9443  * g_async_queue_timed_pop:
9444  * @queue: a #GAsyncQueue
9445  * @end_time: a #GTimeVal, determining the final time
9446  *
9447  * Pops data from the @queue. If the queue is empty, blocks until
9448  * @end_time or until data becomes available.
9449  *
9450  * If no data is received before @end_time, %NULL is returned.
9451  *
9452  * To easily calculate @end_time, a combination of g_get_current_time()
9453  * and g_time_val_add() can be used.
9454  *
9455  * Returns: data from the queue or %NULL, when no data is
9456  *     received before @end_time.
9457  * Deprecated: use g_async_queue_timeout_pop().
9458  */
9459
9460
9461 /**
9462  * g_async_queue_timed_pop_unlocked:
9463  * @queue: a #GAsyncQueue
9464  * @end_time: a #GTimeVal, determining the final time
9465  *
9466  * Pops data from the @queue. If the queue is empty, blocks until
9467  * @end_time or until data becomes available.
9468  *
9469  * If no data is received before @end_time, %NULL is returned.
9470  *
9471  * To easily calculate @end_time, a combination of g_get_current_time()
9472  * and g_time_val_add() can be used.
9473  *
9474  * This function must be called while holding the @queue's lock.
9475  *
9476  * Returns: data from the queue or %NULL, when no data is
9477  *     received before @end_time.
9478  * Deprecated: use g_async_queue_timeout_pop_unlocked().
9479  */
9480
9481
9482 /**
9483  * g_async_queue_timeout_pop:
9484  * @queue: a #GAsyncQueue
9485  * @timeout: the number of microseconds to wait
9486  *
9487  * Pops data from the @queue. If the queue is empty, blocks for
9488  * @timeout microseconds, or until data becomes available.
9489  *
9490  * If no data is received before the timeout, %NULL is returned.
9491  *
9492  * Returns: data from the queue or %NULL, when no data is
9493  *     received before the timeout.
9494  */
9495
9496
9497 /**
9498  * g_async_queue_timeout_pop_unlocked:
9499  * @queue: a #GAsyncQueue
9500  * @timeout: the number of microseconds to wait
9501  *
9502  * Pops data from the @queue. If the queue is empty, blocks for
9503  * @timeout microseconds, or until data becomes available.
9504  *
9505  * If no data is received before the timeout, %NULL is returned.
9506  *
9507  * This function must be called while holding the @queue's lock.
9508  *
9509  * Returns: data from the queue or %NULL, when no data is
9510  *     received before the timeout.
9511  */
9512
9513
9514 /**
9515  * g_async_queue_try_pop:
9516  * @queue: a #GAsyncQueue
9517  *
9518  * Tries to pop data from the @queue. If no data is available,
9519  * %NULL is returned.
9520  *
9521  * Returns: data from the queue or %NULL, when no data is
9522  *     available immediately.
9523  */
9524
9525
9526 /**
9527  * g_async_queue_try_pop_unlocked:
9528  * @queue: a #GAsyncQueue
9529  *
9530  * Tries to pop data from the @queue. If no data is available,
9531  * %NULL is returned.
9532  *
9533  * This function must be called while holding the @queue's lock.
9534  *
9535  * Returns: data from the queue or %NULL, when no data is
9536  *     available immediately.
9537  */
9538
9539
9540 /**
9541  * g_async_queue_unlock:
9542  * @queue: a #GAsyncQueue
9543  *
9544  * Releases the queue's lock.
9545  *
9546  * Calling this function when you have not acquired
9547  * the with g_async_queue_lock() leads to undefined
9548  * behaviour.
9549  */
9550
9551
9552 /**
9553  * g_async_queue_unref:
9554  * @queue: a #GAsyncQueue.
9555  *
9556  * Decreases the reference count of the asynchronous @queue by 1.
9557  *
9558  * If the reference count went to 0, the @queue will be destroyed
9559  * and the memory allocated will be freed. So you are not allowed
9560  * to use the @queue afterwards, as it might have disappeared.
9561  * You do not need to hold the lock to call this function.
9562  */
9563
9564
9565 /**
9566  * g_async_queue_unref_and_unlock:
9567  * @queue: a #GAsyncQueue
9568  *
9569  * Decreases the reference count of the asynchronous @queue by 1
9570  * and releases the lock. This function must be called while holding
9571  * the @queue's lock. If the reference count went to 0, the @queue
9572  * will be destroyed and the memory allocated will be freed.
9573  *
9574  * Deprecated: 2.8: Reference counting is done atomically.
9575  * so g_async_queue_unref() can be used regardless of the @queue's
9576  * lock.
9577  */
9578
9579
9580 /**
9581  * g_atexit:
9582  * @func: (scope async): the function to call on normal program termination.
9583  *
9584  * Specifies a function to be called at normal program termination.
9585  *
9586  * Since GLib 2.8.2, on Windows g_atexit() actually is a preprocessor
9587  * macro that maps to a call to the atexit() function in the C
9588  * library. This means that in case the code that calls g_atexit(),
9589  * i.e. atexit(), is in a DLL, the function will be called when the
9590  * DLL is detached from the program. This typically makes more sense
9591  * than that the function is called when the GLib DLL is detached,
9592  * which happened earlier when g_atexit() was a function in the GLib
9593  * DLL.
9594  *
9595  * The behaviour of atexit() in the context of dynamically loaded
9596  * modules is not formally specified and varies wildly.
9597  *
9598  * On POSIX systems, calling g_atexit() (or atexit()) in a dynamically
9599  * loaded module which is unloaded before the program terminates might
9600  * well cause a crash at program exit.
9601  *
9602  * Some POSIX systems implement atexit() like Windows, and have each
9603  * dynamically loaded module maintain an own atexit chain that is
9604  * called when the module is unloaded.
9605  *
9606  * On other POSIX systems, before a dynamically loaded module is
9607  * unloaded, the registered atexit functions (if any) residing in that
9608  * module are called, regardless where the code that registered them
9609  * resided. This is presumably the most robust approach.
9610  *
9611  * As can be seen from the above, for portability it's best to avoid
9612  * calling g_atexit() (or atexit()) except in the main executable of a
9613  * program.
9614  *
9615  * Deprecated: 2.32: It is best to avoid g_atexit().
9616  */
9617
9618
9619 /**
9620  * g_atomic_int_add:
9621  * @atomic: a pointer to a #gint or #guint
9622  * @val: the value to add
9623  *
9624  * Atomically adds @val to the value of @atomic.
9625  *
9626  * Think of this operation as an atomic version of
9627  * <literal>{ tmp = *atomic; *@atomic += @val; return tmp; }</literal>
9628  *
9629  * This call acts as a full compiler and hardware memory barrier.
9630  *
9631  * Before version 2.30, this function did not return a value
9632  * (but g_atomic_int_exchange_and_add() did, and had the same meaning).
9633  *
9634  * Returns: the value of @atomic before the add, signed
9635  * Since: 2.4
9636  */
9637
9638
9639 /**
9640  * g_atomic_int_and:
9641  * @atomic: a pointer to a #gint or #guint
9642  * @val: the value to 'and'
9643  *
9644  * Performs an atomic bitwise 'and' of the value of @atomic and @val,
9645  * storing the result back in @atomic.
9646  *
9647  * This call acts as a full compiler and hardware memory barrier.
9648  *
9649  * Think of this operation as an atomic version of
9650  * <literal>{ tmp = *atomic; *@atomic &= @val; return tmp; }</literal>
9651  *
9652  * Returns: the value of @atomic before the operation, unsigned
9653  * Since: 2.30
9654  */
9655
9656
9657 /**
9658  * g_atomic_int_compare_and_exchange:
9659  * @atomic: a pointer to a #gint or #guint
9660  * @oldval: the value to compare with
9661  * @newval: the value to conditionally replace with
9662  *
9663  * Compares @atomic to @oldval and, if equal, sets it to @newval.
9664  * If @atomic was not equal to @oldval then no change occurs.
9665  *
9666  * This compare and exchange is done atomically.
9667  *
9668  * Think of this operation as an atomic version of
9669  * <literal>{ if (*@atomic == @oldval) { *@atomic = @newval; return TRUE; } else return FALSE; }</literal>
9670  *
9671  * This call acts as a full compiler and hardware memory barrier.
9672  *
9673  * Returns: %TRUE if the exchange took place
9674  * Since: 2.4
9675  */
9676
9677
9678 /**
9679  * g_atomic_int_dec_and_test:
9680  * @atomic: a pointer to a #gint or #guint
9681  *
9682  * Decrements the value of @atomic by 1.
9683  *
9684  * Think of this operation as an atomic version of
9685  * <literal>{ *@atomic -= 1; return (*@atomic == 0); }</literal>
9686  *
9687  * This call acts as a full compiler and hardware memory barrier.
9688  *
9689  * Returns: %TRUE if the resultant value is zero
9690  * Since: 2.4
9691  */
9692
9693
9694 /**
9695  * g_atomic_int_exchange_and_add:
9696  * @atomic: a pointer to a #gint
9697  * @val: the value to add
9698  *
9699  * This function existed before g_atomic_int_add() returned the prior
9700  * value of the integer (which it now does).  It is retained only for
9701  * compatibility reasons.  Don't use this function in new code.
9702  *
9703  * Returns: the value of @atomic before the add, signed
9704  * Since: 2.4
9705  * Deprecated: 2.30: Use g_atomic_int_add() instead.
9706  */
9707
9708
9709 /**
9710  * g_atomic_int_get:
9711  * @atomic: a pointer to a #gint or #guint
9712  *
9713  * Gets the current value of @atomic.
9714  *
9715  * This call acts as a full compiler and hardware
9716  * memory barrier (before the get).
9717  *
9718  * Returns: the value of the integer
9719  * Since: 2.4
9720  */
9721
9722
9723 /**
9724  * g_atomic_int_inc:
9725  * @atomic: a pointer to a #gint or #guint
9726  *
9727  * Increments the value of @atomic by 1.
9728  *
9729  * Think of this operation as an atomic version of
9730  * <literal>{ *@atomic += 1; }</literal>
9731  *
9732  * This call acts as a full compiler and hardware memory barrier.
9733  *
9734  * Since: 2.4
9735  */
9736
9737
9738 /**
9739  * g_atomic_int_or:
9740  * @atomic: a pointer to a #gint or #guint
9741  * @val: the value to 'or'
9742  *
9743  * Performs an atomic bitwise 'or' of the value of @atomic and @val,
9744  * storing the result back in @atomic.
9745  *
9746  * Think of this operation as an atomic version of
9747  * <literal>{ tmp = *atomic; *@atomic |= @val; return tmp; }</literal>
9748  *
9749  * This call acts as a full compiler and hardware memory barrier.
9750  *
9751  * Returns: the value of @atomic before the operation, unsigned
9752  * Since: 2.30
9753  */
9754
9755
9756 /**
9757  * g_atomic_int_set:
9758  * @atomic: a pointer to a #gint or #guint
9759  * @newval: a new value to store
9760  *
9761  * Sets the value of @atomic to @newval.
9762  *
9763  * This call acts as a full compiler and hardware
9764  * memory barrier (after the set).
9765  *
9766  * Since: 2.4
9767  */
9768
9769
9770 /**
9771  * g_atomic_int_xor:
9772  * @atomic: a pointer to a #gint or #guint
9773  * @val: the value to 'xor'
9774  *
9775  * Performs an atomic bitwise 'xor' of the value of @atomic and @val,
9776  * storing the result back in @atomic.
9777  *
9778  * Think of this operation as an atomic version of
9779  * <literal>{ tmp = *atomic; *@atomic ^= @val; return tmp; }</literal>
9780  *
9781  * This call acts as a full compiler and hardware memory barrier.
9782  *
9783  * Returns: the value of @atomic before the operation, unsigned
9784  * Since: 2.30
9785  */
9786
9787
9788 /**
9789  * g_atomic_pointer_add:
9790  * @atomic: a pointer to a #gpointer-sized value
9791  * @val: the value to add
9792  *
9793  * Atomically adds @val to the value of @atomic.
9794  *
9795  * Think of this operation as an atomic version of
9796  * <literal>{ tmp = *atomic; *@atomic += @val; return tmp; }</literal>
9797  *
9798  * This call acts as a full compiler and hardware memory barrier.
9799  *
9800  * Returns: the value of @atomic before the add, signed
9801  * Since: 2.30
9802  */
9803
9804
9805 /**
9806  * g_atomic_pointer_and:
9807  * @atomic: a pointer to a #gpointer-sized value
9808  * @val: the value to 'and'
9809  *
9810  * Performs an atomic bitwise 'and' of the value of @atomic and @val,
9811  * storing the result back in @atomic.
9812  *
9813  * Think of this operation as an atomic version of
9814  * <literal>{ tmp = *atomic; *@atomic &= @val; return tmp; }</literal>
9815  *
9816  * This call acts as a full compiler and hardware memory barrier.
9817  *
9818  * Returns: the value of @atomic before the operation, unsigned
9819  * Since: 2.30
9820  */
9821
9822
9823 /**
9824  * g_atomic_pointer_compare_and_exchange:
9825  * @atomic: a pointer to a #gpointer-sized value
9826  * @oldval: the value to compare with
9827  * @newval: the value to conditionally replace with
9828  *
9829  * Compares @atomic to @oldval and, if equal, sets it to @newval.
9830  * If @atomic was not equal to @oldval then no change occurs.
9831  *
9832  * This compare and exchange is done atomically.
9833  *
9834  * Think of this operation as an atomic version of
9835  * <literal>{ if (*@atomic == @oldval) { *@atomic = @newval; return TRUE; } else return FALSE; }</literal>
9836  *
9837  * This call acts as a full compiler and hardware memory barrier.
9838  *
9839  * Returns: %TRUE if the exchange took place
9840  * Since: 2.4
9841  */
9842
9843
9844 /**
9845  * g_atomic_pointer_get:
9846  * @atomic: a pointer to a #gpointer-sized value
9847  *
9848  * Gets the current value of @atomic.
9849  *
9850  * This call acts as a full compiler and hardware
9851  * memory barrier (before the get).
9852  *
9853  * Returns: the value of the pointer
9854  * Since: 2.4
9855  */
9856
9857
9858 /**
9859  * g_atomic_pointer_or:
9860  * @atomic: a pointer to a #gpointer-sized value
9861  * @val: the value to 'or'
9862  *
9863  * Performs an atomic bitwise 'or' of the value of @atomic and @val,
9864  * storing the result back in @atomic.
9865  *
9866  * Think of this operation as an atomic version of
9867  * <literal>{ tmp = *atomic; *@atomic |= @val; return tmp; }</literal>
9868  *
9869  * This call acts as a full compiler and hardware memory barrier.
9870  *
9871  * Returns: the value of @atomic before the operation, unsigned
9872  * Since: 2.30
9873  */
9874
9875
9876 /**
9877  * g_atomic_pointer_set:
9878  * @atomic: a pointer to a #gpointer-sized value
9879  * @newval: a new value to store
9880  *
9881  * Sets the value of @atomic to @newval.
9882  *
9883  * This call acts as a full compiler and hardware
9884  * memory barrier (after the set).
9885  *
9886  * Since: 2.4
9887  */
9888
9889
9890 /**
9891  * g_atomic_pointer_xor:
9892  * @atomic: a pointer to a #gpointer-sized value
9893  * @val: the value to 'xor'
9894  *
9895  * Performs an atomic bitwise 'xor' of the value of @atomic and @val,
9896  * storing the result back in @atomic.
9897  *
9898  * Think of this operation as an atomic version of
9899  * <literal>{ tmp = *atomic; *@atomic ^= @val; return tmp; }</literal>
9900  *
9901  * This call acts as a full compiler and hardware memory barrier.
9902  *
9903  * Returns: the value of @atomic before the operation, unsigned
9904  * Since: 2.30
9905  */
9906
9907
9908 /**
9909  * g_base64_decode:
9910  * @text: zero-terminated string with base64 text to decode
9911  * @out_len: (out): The length of the decoded data is written here
9912  *
9913  * Decode a sequence of Base-64 encoded text into binary data.  Note
9914  * that the returned binary data is not necessarily zero-terminated,
9915  * so it should not be used as a character string.
9916  *
9917  * Returns: (transfer full) (array length=out_len) (element-type guint8):
9918  *               newly allocated buffer containing the binary data
9919  *               that @text represents. The returned buffer must
9920  *               be freed with g_free().
9921  * Since: 2.12
9922  */
9923
9924
9925 /**
9926  * g_base64_decode_inplace:
9927  * @text: (inout) (array length=out_len) (element-type guint8): zero-terminated
9928  *        string with base64 text to decode
9929  * @out_len: (inout): The length of the decoded data is written here
9930  *
9931  * Decode a sequence of Base-64 encoded text into binary data
9932  * by overwriting the input data.
9933  *
9934  * Returns: (transfer none): The binary data that @text responds. This pointer
9935  *               is the same as the input @text.
9936  * Since: 2.20
9937  */
9938
9939
9940 /**
9941  * g_base64_decode_step:
9942  * @in: (array length=len) (element-type guint8): binary input data
9943  * @len: max length of @in data to decode
9944  * @out: (out) (array) (element-type guint8): output buffer
9945  * @state: (inout): Saved state between steps, initialize to 0
9946  * @save: (inout): Saved state between steps, initialize to 0
9947  *
9948  * Incrementally decode a sequence of binary data from its Base-64 stringified
9949  * representation. By calling this function multiple times you can convert
9950  * data in chunks to avoid having to have the full encoded data in memory.
9951  *
9952  * The output buffer must be large enough to fit all the data that will
9953  * be written to it. Since base64 encodes 3 bytes in 4 chars you need
9954  * at least: (@len / 4) * 3 + 3 bytes (+ 3 may be needed in case of non-zero
9955  * state).
9956  *
9957  * Returns: The number of bytes of output that was written
9958  * Since: 2.12
9959  */
9960
9961
9962 /**
9963  * g_base64_encode:
9964  * @data: (array length=len) (element-type guint8): the binary data to encode
9965  * @len: the length of @data
9966  *
9967  * Encode a sequence of binary data into its Base-64 stringified
9968  * representation.
9969  *
9970  * Returns: (transfer full): a newly allocated, zero-terminated Base-64
9971  *               encoded string representing @data. The returned string must
9972  *               be freed with g_free().
9973  * Since: 2.12
9974  */
9975
9976
9977 /**
9978  * g_base64_encode_close:
9979  * @break_lines: whether to break long lines
9980  * @out: (out) (array) (element-type guint8): pointer to destination buffer
9981  * @state: (inout): Saved state from g_base64_encode_step()
9982  * @save: (inout): Saved state from g_base64_encode_step()
9983  *
9984  * Flush the status from a sequence of calls to g_base64_encode_step().
9985  *
9986  * The output buffer must be large enough to fit all the data that will
9987  * be written to it. It will need up to 4 bytes, or up to 5 bytes if
9988  * line-breaking is enabled.
9989  *
9990  * Returns: The number of bytes of output that was written
9991  * Since: 2.12
9992  */
9993
9994
9995 /**
9996  * g_base64_encode_step:
9997  * @in: (array length=len) (element-type guint8): the binary data to encode
9998  * @len: the length of @in
9999  * @break_lines: whether to break long lines
10000  * @out: (out) (array) (element-type guint8): pointer to destination buffer
10001  * @state: (inout): Saved state between steps, initialize to 0
10002  * @save: (inout): Saved state between steps, initialize to 0
10003  *
10004  * Incrementally encode a sequence of binary data into its Base-64 stringified
10005  * representation. By calling this function multiple times you can convert
10006  * data in chunks to avoid having to have the full encoded data in memory.
10007  *
10008  * When all of the data has been converted you must call
10009  * g_base64_encode_close() to flush the saved state.
10010  *
10011  * The output buffer must be large enough to fit all the data that will
10012  * be written to it. Due to the way base64 encodes you will need
10013  * at least: (@len / 3 + 1) * 4 + 4 bytes (+ 4 may be needed in case of
10014  * non-zero state). If you enable line-breaking you will need at least:
10015  * ((@len / 3 + 1) * 4 + 4) / 72 + 1 bytes of extra space.
10016  *
10017  * @break_lines is typically used when putting base64-encoded data in emails.
10018  * It breaks the lines at 72 columns instead of putting all of the text on
10019  * the same line. This avoids problems with long lines in the email system.
10020  * Note however that it breaks the lines with <literal>LF</literal>
10021  * characters, not <literal>CR LF</literal> sequences, so the result cannot
10022  * be passed directly to SMTP or certain other protocols.
10023  *
10024  * Returns: The number of bytes of output that was written
10025  * Since: 2.12
10026  */
10027
10028
10029 /**
10030  * g_basename:
10031  * @file_name: the name of the file
10032  *
10033  * Gets the name of the file without any leading directory
10034  * components. It returns a pointer into the given file name
10035  * string.
10036  *
10037  * Returns: the name of the file without any leading
10038  *     directory components
10039  * Deprecated: 2.2: Use g_path_get_basename() instead, but notice
10040  *     that g_path_get_basename() allocates new memory for the
10041  *     returned string, unlike this function which returns a pointer
10042  *     into the argument.
10043  */
10044
10045
10046 /**
10047  * g_bit_lock:
10048  * @address: a pointer to an integer
10049  * @lock_bit: a bit value between 0 and 31
10050  *
10051  * Sets the indicated @lock_bit in @address.  If the bit is already
10052  * set, this call will block until g_bit_unlock() unsets the
10053  * corresponding bit.
10054  *
10055  * Attempting to lock on two different bits within the same integer is
10056  * not supported and will very probably cause deadlocks.
10057  *
10058  * The value of the bit that is set is (1u << @bit).  If @bit is not
10059  * between 0 and 31 then the result is undefined.
10060  *
10061  * This function accesses @address atomically.  All other accesses to
10062  * @address must be atomic in order for this function to work
10063  * reliably.
10064  *
10065  * Since: 2.24
10066  */
10067
10068
10069 /**
10070  * g_bit_nth_lsf:
10071  * @mask: a #gulong containing flags
10072  * @nth_bit: the index of the bit to start the search from
10073  *
10074  * Find the position of the first bit set in @mask, searching
10075  * from (but not including) @nth_bit upwards. Bits are numbered
10076  * from 0 (least significant) to sizeof(#gulong) * 8 - 1 (31 or 63,
10077  * usually). To start searching from the 0th bit, set @nth_bit to -1.
10078  *
10079  * Returns: the index of the first bit set which is higher than @nth_bit
10080  */
10081
10082
10083 /**
10084  * g_bit_nth_msf:
10085  * @mask: a #gulong containing flags
10086  * @nth_bit: the index of the bit to start the search from
10087  *
10088  * Find the position of the first bit set in @mask, searching
10089  * from (but not including) @nth_bit downwards. Bits are numbered
10090  * from 0 (least significant) to sizeof(#gulong) * 8 - 1 (31 or 63,
10091  * usually). To start searching from the last bit, set @nth_bit to
10092  * -1 or GLIB_SIZEOF_LONG * 8.
10093  *
10094  * Returns: the index of the first bit set which is lower than @nth_bit
10095  */
10096
10097
10098 /**
10099  * g_bit_storage:
10100  * @number: a #guint
10101  *
10102  * Gets the number of bits used to hold @number,
10103  * e.g. if @number is 4, 3 bits are needed.
10104  *
10105  * Returns: the number of bits used to hold @number
10106  */
10107
10108
10109 /**
10110  * g_bit_trylock:
10111  * @address: a pointer to an integer
10112  * @lock_bit: a bit value between 0 and 31
10113  *
10114  * Sets the indicated @lock_bit in @address, returning %TRUE if
10115  * successful.  If the bit is already set, returns %FALSE immediately.
10116  *
10117  * Attempting to lock on two different bits within the same integer is
10118  * not supported.
10119  *
10120  * The value of the bit that is set is (1u << @bit).  If @bit is not
10121  * between 0 and 31 then the result is undefined.
10122  *
10123  * This function accesses @address atomically.  All other accesses to
10124  * @address must be atomic in order for this function to work
10125  * reliably.
10126  *
10127  * Returns: %TRUE if the lock was acquired
10128  * Since: 2.24
10129  */
10130
10131
10132 /**
10133  * g_bit_unlock:
10134  * @address: a pointer to an integer
10135  * @lock_bit: a bit value between 0 and 31
10136  *
10137  * Clears the indicated @lock_bit in @address.  If another thread is
10138  * currently blocked in g_bit_lock() on this same bit then it will be
10139  * woken up.
10140  *
10141  * This function accesses @address atomically.  All other accesses to
10142  * @address must be atomic in order for this function to work
10143  * reliably.
10144  *
10145  * Since: 2.24
10146  */
10147
10148
10149 /**
10150  * g_bookmark_file_add_application:
10151  * @bookmark: a #GBookmarkFile
10152  * @uri: a valid URI
10153  * @name: (allow-none): the name of the application registering the bookmark
10154  *   or %NULL
10155  * @exec: (allow-none): command line to be used to launch the bookmark or %NULL
10156  *
10157  * Adds the application with @name and @exec to the list of
10158  * applications that have registered a bookmark for @uri into
10159  * @bookmark.
10160  *
10161  * Every bookmark inside a #GBookmarkFile must have at least an
10162  * application registered.  Each application must provide a name, a
10163  * command line useful for launching the bookmark, the number of times
10164  * the bookmark has been registered by the application and the last
10165  * time the application registered this bookmark.
10166  *
10167  * If @name is %NULL, the name of the application will be the
10168  * same returned by g_get_application_name(); if @exec is %NULL, the
10169  * command line will be a composition of the program name as
10170  * returned by g_get_prgname() and the "\%u" modifier, which will be
10171  * expanded to the bookmark's URI.
10172  *
10173  * This function will automatically take care of updating the
10174  * registrations count and timestamping in case an application
10175  * with the same @name had already registered a bookmark for
10176  * @uri inside @bookmark.
10177  *
10178  * If no bookmark for @uri is found, one is created.
10179  *
10180  * Since: 2.12
10181  */
10182
10183
10184 /**
10185  * g_bookmark_file_add_group:
10186  * @bookmark: a #GBookmarkFile
10187  * @uri: a valid URI
10188  * @group: the group name to be added
10189  *
10190  * Adds @group to the list of groups to which the bookmark for @uri
10191  * belongs to.
10192  *
10193  * If no bookmark for @uri is found then it is created.
10194  *
10195  * Since: 2.12
10196  */
10197
10198
10199 /**
10200  * g_bookmark_file_free:
10201  * @bookmark: a #GBookmarkFile
10202  *
10203  * Frees a #GBookmarkFile.
10204  *
10205  * Since: 2.12
10206  */
10207
10208
10209 /**
10210  * g_bookmark_file_get_added:
10211  * @bookmark: a #GBookmarkFile
10212  * @uri: a valid URI
10213  * @error: return location for a #GError, or %NULL
10214  *
10215  * Gets the time the bookmark for @uri was added to @bookmark
10216  *
10217  * In the event the URI cannot be found, -1 is returned and
10218  * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10219  *
10220  * Returns: a timestamp
10221  * Since: 2.12
10222  */
10223
10224
10225 /**
10226  * g_bookmark_file_get_app_info:
10227  * @bookmark: a #GBookmarkFile
10228  * @uri: a valid URI
10229  * @name: an application's name
10230  * @exec: (allow-none) (out): return location for the command line of the application, or %NULL
10231  * @count: (allow-none) (out): return location for the registration count, or %NULL
10232  * @stamp: (allow-none) (out): return location for the last registration time, or %NULL
10233  * @error: return location for a #GError, or %NULL
10234  *
10235  * Gets the registration informations of @app_name for the bookmark for
10236  * @uri.  See g_bookmark_file_set_app_info() for more informations about
10237  * the returned data.
10238  *
10239  * The string returned in @app_exec must be freed.
10240  *
10241  * In the event the URI cannot be found, %FALSE is returned and
10242  * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.  In the
10243  * event that no application with name @app_name has registered a bookmark
10244  * for @uri,  %FALSE is returned and error is set to
10245  * #G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED. In the event that unquoting
10246  * the command line fails, an error of the #G_SHELL_ERROR domain is
10247  * set and %FALSE is returned.
10248  *
10249  * Returns: %TRUE on success.
10250  * Since: 2.12
10251  */
10252
10253
10254 /**
10255  * g_bookmark_file_get_applications:
10256  * @bookmark: a #GBookmarkFile
10257  * @uri: a valid URI
10258  * @length: (allow-none) (out): return location of the length of the returned list, or %NULL
10259  * @error: return location for a #GError, or %NULL
10260  *
10261  * Retrieves the names of the applications that have registered the
10262  * bookmark for @uri.
10263  *
10264  * In the event the URI cannot be found, %NULL is returned and
10265  * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10266  *
10267  * Returns: (array length=length) (transfer full): a newly allocated %NULL-terminated array of strings.
10268  *   Use g_strfreev() to free it.
10269  * Since: 2.12
10270  */
10271
10272
10273 /**
10274  * g_bookmark_file_get_description:
10275  * @bookmark: a #GBookmarkFile
10276  * @uri: a valid URI
10277  * @error: return location for a #GError, or %NULL
10278  *
10279  * Retrieves the description of the bookmark for @uri.
10280  *
10281  * In the event the URI cannot be found, %NULL is returned and
10282  * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10283  *
10284  * Returns: a newly allocated string or %NULL if the specified
10285  *   URI cannot be found.
10286  * Since: 2.12
10287  */
10288
10289
10290 /**
10291  * g_bookmark_file_get_groups:
10292  * @bookmark: a #GBookmarkFile
10293  * @uri: a valid URI
10294  * @length: (allow-none) (out): return location for the length of the returned string, or %NULL
10295  * @error: return location for a #GError, or %NULL
10296  *
10297  * Retrieves the list of group names of the bookmark for @uri.
10298  *
10299  * In the event the URI cannot be found, %NULL is returned and
10300  * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10301  *
10302  * The returned array is %NULL terminated, so @length may optionally
10303  * be %NULL.
10304  *
10305  * Returns: (array length=length) (transfer full): a newly allocated %NULL-terminated array of group names.
10306  *   Use g_strfreev() to free it.
10307  * Since: 2.12
10308  */
10309
10310
10311 /**
10312  * g_bookmark_file_get_icon:
10313  * @bookmark: a #GBookmarkFile
10314  * @uri: a valid URI
10315  * @href: (allow-none) (out): return location for the icon's location or %NULL
10316  * @mime_type: (allow-none) (out): return location for the icon's MIME type or %NULL
10317  * @error: return location for a #GError or %NULL
10318  *
10319  * Gets the icon of the bookmark for @uri.
10320  *
10321  * In the event the URI cannot be found, %FALSE is returned and
10322  * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10323  *
10324  * Returns: %TRUE if the icon for the bookmark for the URI was found.
10325  *   You should free the returned strings.
10326  * Since: 2.12
10327  */
10328
10329
10330 /**
10331  * g_bookmark_file_get_is_private:
10332  * @bookmark: a #GBookmarkFile
10333  * @uri: a valid URI
10334  * @error: return location for a #GError, or %NULL
10335  *
10336  * Gets whether the private flag of the bookmark for @uri is set.
10337  *
10338  * In the event the URI cannot be found, %FALSE is returned and
10339  * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.  In the
10340  * event that the private flag cannot be found, %FALSE is returned and
10341  * @error is set to #G_BOOKMARK_FILE_ERROR_INVALID_VALUE.
10342  *
10343  * Returns: %TRUE if the private flag is set, %FALSE otherwise.
10344  * Since: 2.12
10345  */
10346
10347
10348 /**
10349  * g_bookmark_file_get_mime_type:
10350  * @bookmark: a #GBookmarkFile
10351  * @uri: a valid URI
10352  * @error: return location for a #GError, or %NULL
10353  *
10354  * Retrieves the MIME type of the resource pointed by @uri.
10355  *
10356  * In the event the URI cannot be found, %NULL is returned and
10357  * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.  In the
10358  * event that the MIME type cannot be found, %NULL is returned and
10359  * @error is set to #G_BOOKMARK_FILE_ERROR_INVALID_VALUE.
10360  *
10361  * Returns: a newly allocated string or %NULL if the specified
10362  *   URI cannot be found.
10363  * Since: 2.12
10364  */
10365
10366
10367 /**
10368  * g_bookmark_file_get_modified:
10369  * @bookmark: a #GBookmarkFile
10370  * @uri: a valid URI
10371  * @error: return location for a #GError, or %NULL
10372  *
10373  * Gets the time when the bookmark for @uri was last modified.
10374  *
10375  * In the event the URI cannot be found, -1 is returned and
10376  * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10377  *
10378  * Returns: a timestamp
10379  * Since: 2.12
10380  */
10381
10382
10383 /**
10384  * g_bookmark_file_get_size:
10385  * @bookmark: a #GBookmarkFile
10386  *
10387  * Gets the number of bookmarks inside @bookmark.
10388  *
10389  * Returns: the number of bookmarks
10390  * Since: 2.12
10391  */
10392
10393
10394 /**
10395  * g_bookmark_file_get_title:
10396  * @bookmark: a #GBookmarkFile
10397  * @uri: (allow-none): a valid URI or %NULL
10398  * @error: return location for a #GError, or %NULL
10399  *
10400  * Returns the title of the bookmark for @uri.
10401  *
10402  * If @uri is %NULL, the title of @bookmark is returned.
10403  *
10404  * In the event the URI cannot be found, %NULL is returned and
10405  * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10406  *
10407  * Returns: a newly allocated string or %NULL if the specified
10408  *   URI cannot be found.
10409  * Since: 2.12
10410  */
10411
10412
10413 /**
10414  * g_bookmark_file_get_uris:
10415  * @bookmark: a #GBookmarkFile
10416  * @length: (allow-none) (out): return location for the number of returned URIs, or %NULL
10417  *
10418  * Returns all URIs of the bookmarks in the bookmark file @bookmark.
10419  * The array of returned URIs will be %NULL-terminated, so @length may
10420  * optionally be %NULL.
10421  *
10422  * Returns: (array length=length) (transfer full): a newly allocated %NULL-terminated array of strings.
10423  *   Use g_strfreev() to free it.
10424  * Since: 2.12
10425  */
10426
10427
10428 /**
10429  * g_bookmark_file_get_visited:
10430  * @bookmark: a #GBookmarkFile
10431  * @uri: a valid URI
10432  * @error: return location for a #GError, or %NULL
10433  *
10434  * Gets the time the bookmark for @uri was last visited.
10435  *
10436  * In the event the URI cannot be found, -1 is returned and
10437  * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10438  *
10439  * Returns: a timestamp.
10440  * Since: 2.12
10441  */
10442
10443
10444 /**
10445  * g_bookmark_file_has_application:
10446  * @bookmark: a #GBookmarkFile
10447  * @uri: a valid URI
10448  * @name: the name of the application
10449  * @error: return location for a #GError or %NULL
10450  *
10451  * Checks whether the bookmark for @uri inside @bookmark has been
10452  * registered by application @name.
10453  *
10454  * In the event the URI cannot be found, %FALSE is returned and
10455  * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10456  *
10457  * Returns: %TRUE if the application @name was found
10458  * Since: 2.12
10459  */
10460
10461
10462 /**
10463  * g_bookmark_file_has_group:
10464  * @bookmark: a #GBookmarkFile
10465  * @uri: a valid URI
10466  * @group: the group name to be searched
10467  * @error: return location for a #GError, or %NULL
10468  *
10469  * Checks whether @group appears in the list of groups to which
10470  * the bookmark for @uri belongs to.
10471  *
10472  * In the event the URI cannot be found, %FALSE is returned and
10473  * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10474  *
10475  * Returns: %TRUE if @group was found.
10476  * Since: 2.12
10477  */
10478
10479
10480 /**
10481  * g_bookmark_file_has_item:
10482  * @bookmark: a #GBookmarkFile
10483  * @uri: a valid URI
10484  *
10485  * Looks whether the desktop bookmark has an item with its URI set to @uri.
10486  *
10487  * Returns: %TRUE if @uri is inside @bookmark, %FALSE otherwise
10488  * Since: 2.12
10489  */
10490
10491
10492 /**
10493  * g_bookmark_file_load_from_data:
10494  * @bookmark: an empty #GBookmarkFile struct
10495  * @data: desktop bookmarks loaded in memory
10496  * @length: the length of @data in bytes
10497  * @error: return location for a #GError, or %NULL
10498  *
10499  * Loads a bookmark file from memory into an empty #GBookmarkFile
10500  * structure.  If the object cannot be created then @error is set to a
10501  * #GBookmarkFileError.
10502  *
10503  * Returns: %TRUE if a desktop bookmark could be loaded.
10504  * Since: 2.12
10505  */
10506
10507
10508 /**
10509  * g_bookmark_file_load_from_data_dirs:
10510  * @bookmark: a #GBookmarkFile
10511  * @file: a relative path to a filename to open and parse
10512  * @full_path: (allow-none): return location for a string containing the full path
10513  *   of the file, or %NULL
10514  * @error: return location for a #GError, or %NULL
10515  *
10516  * This function looks for a desktop bookmark file named @file in the
10517  * paths returned from g_get_user_data_dir() and g_get_system_data_dirs(),
10518  * loads the file into @bookmark and returns the file's full path in
10519  * @full_path.  If the file could not be loaded then an %error is
10520  * set to either a #GFileError or #GBookmarkFileError.
10521  *
10522  * Returns: %TRUE if a key file could be loaded, %FALSE otherwise
10523  * Since: 2.12
10524  */
10525
10526
10527 /**
10528  * g_bookmark_file_load_from_file:
10529  * @bookmark: an empty #GBookmarkFile struct
10530  * @filename: the path of a filename to load, in the GLib file name encoding
10531  * @error: return location for a #GError, or %NULL
10532  *
10533  * Loads a desktop bookmark file into an empty #GBookmarkFile structure.
10534  * If the file could not be loaded then @error is set to either a #GFileError
10535  * or #GBookmarkFileError.
10536  *
10537  * Returns: %TRUE if a desktop bookmark file could be loaded
10538  * Since: 2.12
10539  */
10540
10541
10542 /**
10543  * g_bookmark_file_move_item:
10544  * @bookmark: a #GBookmarkFile
10545  * @old_uri: a valid URI
10546  * @new_uri: (allow-none): a valid URI, or %NULL
10547  * @error: return location for a #GError or %NULL
10548  *
10549  * Changes the URI of a bookmark item from @old_uri to @new_uri.  Any
10550  * existing bookmark for @new_uri will be overwritten.  If @new_uri is
10551  * %NULL, then the bookmark is removed.
10552  *
10553  * In the event the URI cannot be found, %FALSE is returned and
10554  * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10555  *
10556  * Returns: %TRUE if the URI was successfully changed
10557  * Since: 2.12
10558  */
10559
10560
10561 /**
10562  * g_bookmark_file_new:
10563  *
10564  * Creates a new empty #GBookmarkFile object.
10565  *
10566  * Use g_bookmark_file_load_from_file(), g_bookmark_file_load_from_data()
10567  * or g_bookmark_file_load_from_data_dirs() to read an existing bookmark
10568  * file.
10569  *
10570  * Returns: an empty #GBookmarkFile
10571  * Since: 2.12
10572  */
10573
10574
10575 /**
10576  * g_bookmark_file_remove_application:
10577  * @bookmark: a #GBookmarkFile
10578  * @uri: a valid URI
10579  * @name: the name of the application
10580  * @error: return location for a #GError or %NULL
10581  *
10582  * Removes application registered with @name from the list of applications
10583  * that have registered a bookmark for @uri inside @bookmark.
10584  *
10585  * In the event the URI cannot be found, %FALSE is returned and
10586  * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10587  * In the event that no application with name @app_name has registered
10588  * a bookmark for @uri,  %FALSE is returned and error is set to
10589  * #G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED.
10590  *
10591  * Returns: %TRUE if the application was successfully removed.
10592  * Since: 2.12
10593  */
10594
10595
10596 /**
10597  * g_bookmark_file_remove_group:
10598  * @bookmark: a #GBookmarkFile
10599  * @uri: a valid URI
10600  * @group: the group name to be removed
10601  * @error: return location for a #GError, or %NULL
10602  *
10603  * Removes @group from the list of groups to which the bookmark
10604  * for @uri belongs to.
10605  *
10606  * In the event the URI cannot be found, %FALSE is returned and
10607  * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10608  * In the event no group was defined, %FALSE is returned and
10609  * @error is set to #G_BOOKMARK_FILE_ERROR_INVALID_VALUE.
10610  *
10611  * Returns: %TRUE if @group was successfully removed.
10612  * Since: 2.12
10613  */
10614
10615
10616 /**
10617  * g_bookmark_file_remove_item:
10618  * @bookmark: a #GBookmarkFile
10619  * @uri: a valid URI
10620  * @error: return location for a #GError, or %NULL
10621  *
10622  * Removes the bookmark for @uri from the bookmark file @bookmark.
10623  *
10624  * Returns: %TRUE if the bookmark was removed successfully.
10625  * Since: 2.12
10626  */
10627
10628
10629 /**
10630  * g_bookmark_file_set_added:
10631  * @bookmark: a #GBookmarkFile
10632  * @uri: a valid URI
10633  * @added: a timestamp or -1 to use the current time
10634  *
10635  * Sets the time the bookmark for @uri was added into @bookmark.
10636  *
10637  * If no bookmark for @uri is found then it is created.
10638  *
10639  * Since: 2.12
10640  */
10641
10642
10643 /**
10644  * g_bookmark_file_set_app_info:
10645  * @bookmark: a #GBookmarkFile
10646  * @uri: a valid URI
10647  * @name: an application's name
10648  * @exec: an application's command line
10649  * @count: the number of registrations done for this application
10650  * @stamp: the time of the last registration for this application
10651  * @error: return location for a #GError or %NULL
10652  *
10653  * Sets the meta-data of application @name inside the list of
10654  * applications that have registered a bookmark for @uri inside
10655  * @bookmark.
10656  *
10657  * You should rarely use this function; use g_bookmark_file_add_application()
10658  * and g_bookmark_file_remove_application() instead.
10659  *
10660  * @name can be any UTF-8 encoded string used to identify an
10661  * application.
10662  * @exec can have one of these two modifiers: "\%f", which will
10663  * be expanded as the local file name retrieved from the bookmark's
10664  * URI; "\%u", which will be expanded as the bookmark's URI.
10665  * The expansion is done automatically when retrieving the stored
10666  * command line using the g_bookmark_file_get_app_info() function.
10667  * @count is the number of times the application has registered the
10668  * bookmark; if is < 0, the current registration count will be increased
10669  * by one, if is 0, the application with @name will be removed from
10670  * the list of registered applications.
10671  * @stamp is the Unix time of the last registration; if it is -1, the
10672  * current time will be used.
10673  *
10674  * If you try to remove an application by setting its registration count to
10675  * zero, and no bookmark for @uri is found, %FALSE is returned and
10676  * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND; similarly,
10677  * in the event that no application @name has registered a bookmark
10678  * for @uri,  %FALSE is returned and error is set to
10679  * #G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED.  Otherwise, if no bookmark
10680  * for @uri is found, one is created.
10681  *
10682  * Returns: %TRUE if the application's meta-data was successfully
10683  *   changed.
10684  * Since: 2.12
10685  */
10686
10687
10688 /**
10689  * g_bookmark_file_set_description:
10690  * @bookmark: a #GBookmarkFile
10691  * @uri: (allow-none): a valid URI or %NULL
10692  * @description: a string
10693  *
10694  * Sets @description as the description of the bookmark for @uri.
10695  *
10696  * If @uri is %NULL, the description of @bookmark is set.
10697  *
10698  * If a bookmark for @uri cannot be found then it is created.
10699  *
10700  * Since: 2.12
10701  */
10702
10703
10704 /**
10705  * g_bookmark_file_set_groups:
10706  * @bookmark: a #GBookmarkFile
10707  * @uri: an item's URI
10708  * @groups: (allow-none): an array of group names, or %NULL to remove all groups
10709  * @length: number of group name values in @groups
10710  *
10711  * Sets a list of group names for the item with URI @uri.  Each previously
10712  * set group name list is removed.
10713  *
10714  * If @uri cannot be found then an item for it is created.
10715  *
10716  * Since: 2.12
10717  */
10718
10719
10720 /**
10721  * g_bookmark_file_set_icon:
10722  * @bookmark: a #GBookmarkFile
10723  * @uri: a valid URI
10724  * @href: (allow-none): the URI of the icon for the bookmark, or %NULL
10725  * @mime_type: the MIME type of the icon for the bookmark
10726  *
10727  * Sets the icon for the bookmark for @uri. If @href is %NULL, unsets
10728  * the currently set icon. @href can either be a full URL for the icon
10729  * file or the icon name following the Icon Naming specification.
10730  *
10731  * If no bookmark for @uri is found one is created.
10732  *
10733  * Since: 2.12
10734  */
10735
10736
10737 /**
10738  * g_bookmark_file_set_is_private:
10739  * @bookmark: a #GBookmarkFile
10740  * @uri: a valid URI
10741  * @is_private: %TRUE if the bookmark should be marked as private
10742  *
10743  * Sets the private flag of the bookmark for @uri.
10744  *
10745  * If a bookmark for @uri cannot be found then it is created.
10746  *
10747  * Since: 2.12
10748  */
10749
10750
10751 /**
10752  * g_bookmark_file_set_mime_type:
10753  * @bookmark: a #GBookmarkFile
10754  * @uri: a valid URI
10755  * @mime_type: a MIME type
10756  *
10757  * Sets @mime_type as the MIME type of the bookmark for @uri.
10758  *
10759  * If a bookmark for @uri cannot be found then it is created.
10760  *
10761  * Since: 2.12
10762  */
10763
10764
10765 /**
10766  * g_bookmark_file_set_modified:
10767  * @bookmark: a #GBookmarkFile
10768  * @uri: a valid URI
10769  * @modified: a timestamp or -1 to use the current time
10770  *
10771  * Sets the last time the bookmark for @uri was last modified.
10772  *
10773  * If no bookmark for @uri is found then it is created.
10774  *
10775  * The "modified" time should only be set when the bookmark's meta-data
10776  * was actually changed.  Every function of #GBookmarkFile that
10777  * modifies a bookmark also changes the modification time, except for
10778  * g_bookmark_file_set_visited().
10779  *
10780  * Since: 2.12
10781  */
10782
10783
10784 /**
10785  * g_bookmark_file_set_title:
10786  * @bookmark: a #GBookmarkFile
10787  * @uri: (allow-none): a valid URI or %NULL
10788  * @title: a UTF-8 encoded string
10789  *
10790  * Sets @title as the title of the bookmark for @uri inside the
10791  * bookmark file @bookmark.
10792  *
10793  * If @uri is %NULL, the title of @bookmark is set.
10794  *
10795  * If a bookmark for @uri cannot be found then it is created.
10796  *
10797  * Since: 2.12
10798  */
10799
10800
10801 /**
10802  * g_bookmark_file_set_visited:
10803  * @bookmark: a #GBookmarkFile
10804  * @uri: a valid URI
10805  * @visited: a timestamp or -1 to use the current time
10806  *
10807  * Sets the time the bookmark for @uri was last visited.
10808  *
10809  * If no bookmark for @uri is found then it is created.
10810  *
10811  * The "visited" time should only be set if the bookmark was launched,
10812  * either using the command line retrieved by g_bookmark_file_get_app_info()
10813  * or by the default application for the bookmark's MIME type, retrieved
10814  * using g_bookmark_file_get_mime_type().  Changing the "visited" time
10815  * does not affect the "modified" time.
10816  *
10817  * Since: 2.12
10818  */
10819
10820
10821 /**
10822  * g_bookmark_file_to_data:
10823  * @bookmark: a #GBookmarkFile
10824  * @length: (allow-none) (out): return location for the length of the returned string, or %NULL
10825  * @error: return location for a #GError, or %NULL
10826  *
10827  * This function outputs @bookmark as a string.
10828  *
10829  * Returns: a newly allocated string holding
10830  *   the contents of the #GBookmarkFile
10831  * Since: 2.12
10832  */
10833
10834
10835 /**
10836  * g_bookmark_file_to_file:
10837  * @bookmark: a #GBookmarkFile
10838  * @filename: path of the output file
10839  * @error: return location for a #GError, or %NULL
10840  *
10841  * This function outputs @bookmark into a file.  The write process is
10842  * guaranteed to be atomic by using g_file_set_contents() internally.
10843  *
10844  * Returns: %TRUE if the file was successfully written.
10845  * Since: 2.12
10846  */
10847
10848
10849 /**
10850  * g_build_filename:
10851  * @first_element: the first element in the path
10852  * @...: remaining elements in path, terminated by %NULL
10853  *
10854  * Creates a filename from a series of elements using the correct
10855  * separator for filenames.
10856  *
10857  * On Unix, this function behaves identically to <literal>g_build_path
10858  * (G_DIR_SEPARATOR_S, first_element, ....)</literal>.
10859  *
10860  * On Windows, it takes into account that either the backslash
10861  * (<literal>\</literal> or slash (<literal>/</literal>) can be used
10862  * as separator in filenames, but otherwise behaves as on Unix. When
10863  * file pathname separators need to be inserted, the one that last
10864  * previously occurred in the parameters (reading from left to right)
10865  * is used.
10866  *
10867  * No attempt is made to force the resulting filename to be an absolute
10868  * path. If the first element is a relative path, the result will
10869  * be a relative path.
10870  *
10871  * Returns: a newly-allocated string that must be freed with g_free().
10872  */
10873
10874
10875 /**
10876  * g_build_filenamev:
10877  * @args: (array zero-terminated=1): %NULL-terminated array of strings containing the path elements.
10878  *
10879  * Behaves exactly like g_build_filename(), but takes the path elements
10880  * as a string array, instead of varargs. This function is mainly
10881  * meant for language bindings.
10882  *
10883  * Returns: a newly-allocated string that must be freed with g_free().
10884  * Since: 2.8
10885  */
10886
10887
10888 /**
10889  * g_build_path:
10890  * @separator: a string used to separator the elements of the path.
10891  * @first_element: the first element in the path
10892  * @...: remaining elements in path, terminated by %NULL
10893  *
10894  * Creates a path from a series of elements using @separator as the
10895  * separator between elements. At the boundary between two elements,
10896  * any trailing occurrences of separator in the first element, or
10897  * leading occurrences of separator in the second element are removed
10898  * and exactly one copy of the separator is inserted.
10899  *
10900  * Empty elements are ignored.
10901  *
10902  * The number of leading copies of the separator on the result is
10903  * the same as the number of leading copies of the separator on
10904  * the first non-empty element.
10905  *
10906  * The number of trailing copies of the separator on the result is
10907  * the same as the number of trailing copies of the separator on
10908  * the last non-empty element. (Determination of the number of
10909  * trailing copies is done without stripping leading copies, so
10910  * if the separator is <literal>ABA</literal>, <literal>ABABA</literal>
10911  * has 1 trailing copy.)
10912  *
10913  * However, if there is only a single non-empty element, and there
10914  * are no characters in that element not part of the leading or
10915  * trailing separators, then the result is exactly the original value
10916  * of that element.
10917  *
10918  * Other than for determination of the number of leading and trailing
10919  * copies of the separator, elements consisting only of copies
10920  * of the separator are ignored.
10921  *
10922  * Returns: a newly-allocated string that must be freed with g_free().
10923  */
10924
10925
10926 /**
10927  * g_build_pathv:
10928  * @separator: a string used to separator the elements of the path.
10929  * @args: (array zero-terminated=1): %NULL-terminated array of strings containing the path elements.
10930  *
10931  * Behaves exactly like g_build_path(), but takes the path elements
10932  * as a string array, instead of varargs. This function is mainly
10933  * meant for language bindings.
10934  *
10935  * Returns: a newly-allocated string that must be freed with g_free().
10936  * Since: 2.8
10937  */
10938
10939
10940 /**
10941  * g_byte_array_append:
10942  * @array: a #GByteArray.
10943  * @data: the byte data to be added.
10944  * @len: the number of bytes to add.
10945  *
10946  * Adds the given bytes to the end of the #GByteArray. The array will
10947  * grow in size automatically if necessary.
10948  *
10949  * Returns: the #GByteArray.
10950  */
10951
10952
10953 /**
10954  * g_byte_array_free:
10955  * @array: a #GByteArray.
10956  * @free_segment: if %TRUE the actual byte data is freed as well.
10957  *
10958  * Frees the memory allocated by the #GByteArray. If @free_segment is
10959  * %TRUE it frees the actual byte data. If the reference count of
10960  * @array is greater than one, the #GByteArray wrapper is preserved but
10961  * the size of @array will be set to zero.
10962  *
10963  * Returns: the element data if @free_segment is %FALSE, otherwise
10964  *          %NULL.  The element data should be freed using g_free().
10965  */
10966
10967
10968 /**
10969  * g_byte_array_free_to_bytes:
10970  * @array: (transfer full): a #GByteArray
10971  *
10972  * Transfers the data from the #GByteArray into a new immutable #GBytes.
10973  *
10974  * The #GByteArray is freed unless the reference count of @array is greater
10975  * than one, the #GByteArray wrapper is preserved but the size of @array
10976  * will be set to zero.
10977  *
10978  * This is identical to using g_bytes_new_take() and g_byte_array_free()
10979  * together.
10980  *
10981  * Since: 2.32
10982  * Returns: (transfer full): a new immutable #GBytes representing same byte
10983  *          data that was in the array
10984  */
10985
10986
10987 /**
10988  * g_byte_array_new:
10989  *
10990  * Creates a new #GByteArray with a reference count of 1.
10991  *
10992  * Returns: (transfer full): the new #GByteArray.
10993  */
10994
10995
10996 /**
10997  * g_byte_array_new_take:
10998  * @data: (transfer full) (array length=len): byte data for the array
10999  * @len: length of @data
11000  *
11001  * Create byte array containing the data. The data will be owned by the array
11002  * and will be freed with g_free(), i.e. it could be allocated using g_strdup().
11003  *
11004  * Since: 2.32
11005  * Returns: (transfer full): a new #GByteArray
11006  */
11007
11008
11009 /**
11010  * g_byte_array_prepend:
11011  * @array: a #GByteArray.
11012  * @data: the byte data to be added.
11013  * @len: the number of bytes to add.
11014  *
11015  * Adds the given data to the start of the #GByteArray. The array will
11016  * grow in size automatically if necessary.
11017  *
11018  * Returns: the #GByteArray.
11019  */
11020
11021
11022 /**
11023  * g_byte_array_ref:
11024  * @array: A #GByteArray.
11025  *
11026  * Atomically increments the reference count of @array by one. This
11027  * function is MT-safe and may be called from any thread.
11028  *
11029  * Returns: The passed in #GByteArray.
11030  * Since: 2.22
11031  */
11032
11033
11034 /**
11035  * g_byte_array_remove_index:
11036  * @array: a #GByteArray.
11037  * @index_: the index of the byte to remove.
11038  *
11039  * Removes the byte at the given index from a #GByteArray. The
11040  * following bytes are moved down one place.
11041  *
11042  * Returns: the #GByteArray.
11043  */
11044
11045
11046 /**
11047  * g_byte_array_remove_index_fast:
11048  * @array: a #GByteArray.
11049  * @index_: the index of the byte to remove.
11050  *
11051  * Removes the byte at the given index from a #GByteArray. The last
11052  * element in the array is used to fill in the space, so this function
11053  * does not preserve the order of the #GByteArray. But it is faster
11054  * than g_byte_array_remove_index().
11055  *
11056  * Returns: the #GByteArray.
11057  */
11058
11059
11060 /**
11061  * g_byte_array_remove_range:
11062  * @array: a @GByteArray.
11063  * @index_: the index of the first byte to remove.
11064  * @length: the number of bytes to remove.
11065  *
11066  * Removes the given number of bytes starting at the given index from a
11067  * #GByteArray.  The following elements are moved to close the gap.
11068  *
11069  * Returns: the #GByteArray.
11070  * Since: 2.4
11071  */
11072
11073
11074 /**
11075  * g_byte_array_set_size:
11076  * @array: a #GByteArray.
11077  * @length: the new size of the #GByteArray.
11078  *
11079  * Sets the size of the #GByteArray, expanding it if necessary.
11080  *
11081  * Returns: the #GByteArray.
11082  */
11083
11084
11085 /**
11086  * g_byte_array_sized_new:
11087  * @reserved_size: number of bytes preallocated.
11088  *
11089  * Creates a new #GByteArray with @reserved_size bytes preallocated.
11090  * This avoids frequent reallocation, if you are going to add many
11091  * bytes to the array. Note however that the size of the array is still
11092  * 0.
11093  *
11094  * Returns: the new #GByteArray.
11095  */
11096
11097
11098 /**
11099  * g_byte_array_sort:
11100  * @array: a #GByteArray.
11101  * @compare_func: comparison function.
11102  *
11103  * Sorts a byte array, using @compare_func which should be a
11104  * qsort()-style comparison function (returns less than zero for first
11105  * arg is less than second arg, zero for equal, greater than zero if
11106  * first arg is greater than second arg).
11107  *
11108  * If two array elements compare equal, their order in the sorted array
11109  * is undefined. If you want equal elements to keep their order (i.e.
11110  * you want a stable sort) you can write a comparison function that,
11111  * if two elements would otherwise compare equal, compares them by
11112  * their addresses.
11113  */
11114
11115
11116 /**
11117  * g_byte_array_sort_with_data:
11118  * @array: a #GByteArray.
11119  * @compare_func: comparison function.
11120  * @user_data: data to pass to @compare_func.
11121  *
11122  * Like g_byte_array_sort(), but the comparison function takes an extra
11123  * user data argument.
11124  */
11125
11126
11127 /**
11128  * g_byte_array_unref:
11129  * @array: A #GByteArray.
11130  *
11131  * Atomically decrements the reference count of @array by one. If the
11132  * reference count drops to 0, all memory allocated by the array is
11133  * released. This function is MT-safe and may be called from any
11134  * thread.
11135  *
11136  * Since: 2.22
11137  */
11138
11139
11140 /**
11141  * g_bytes_compare:
11142  * @bytes1: (type GLib.Bytes): a pointer to a #GBytes
11143  * @bytes2: (type GLib.Bytes): a pointer to a #GBytes to compare with @bytes1
11144  *
11145  * Compares the two #GBytes values.
11146  *
11147  * This function can be used to sort GBytes instances in lexographical order.
11148  *
11149  * Returns: a negative value if bytes2 is lesser, a positive value if bytes2 is
11150  *          greater, and zero if bytes2 is equal to bytes1
11151  * Since: 2.32
11152  */
11153
11154
11155 /**
11156  * g_bytes_equal:
11157  * @bytes1: (type GLib.Bytes): a pointer to a #GBytes
11158  * @bytes2: (type GLib.Bytes): a pointer to a #GBytes to compare with @bytes1
11159  *
11160  * Compares the two #GBytes values being pointed to and returns
11161  * %TRUE if they are equal.
11162  *
11163  * This function can be passed to g_hash_table_new() as the @key_equal_func
11164  * parameter, when using non-%NULL #GBytes pointers as keys in a #GHashTable.
11165  *
11166  * Returns: %TRUE if the two keys match.
11167  * Since: 2.32
11168  */
11169
11170
11171 /**
11172  * g_bytes_get_data:
11173  * @bytes: a #GBytes
11174  * @size: (out) (allow-none): location to return size of byte data
11175  *
11176  * Get the byte data in the #GBytes. This data should not be modified.
11177  *
11178  * This function will always return the same pointer for a given #GBytes.
11179  *
11180  * Returns: (transfer none) (array length=size) (type guint8): a pointer to the
11181  *          byte data
11182  * Since: 2.32
11183  */
11184
11185
11186 /**
11187  * g_bytes_get_size:
11188  * @bytes: a #GBytes
11189  *
11190  * Get the size of the byte data in the #GBytes.
11191  *
11192  * This function will always return the same value for a given #GBytes.
11193  *
11194  * Returns: the size
11195  * Since: 2.32
11196  */
11197
11198
11199 /**
11200  * g_bytes_hash:
11201  * @bytes: (type GLib.Bytes): a pointer to a #GBytes key
11202  *
11203  * Creates an integer hash code for the byte data in the #GBytes.
11204  *
11205  * This function can be passed to g_hash_table_new() as the @key_equal_func
11206  * parameter, when using non-%NULL #GBytes pointers as keys in a #GHashTable.
11207  *
11208  * Returns: a hash value corresponding to the key.
11209  * Since: 2.32
11210  */
11211
11212
11213 /**
11214  * g_bytes_new:
11215  * @data: (transfer none) (array length=size) (element-type guint8):
11216  *        the data to be used for the bytes
11217  * @size: the size of @data
11218  *
11219  * Creates a new #GBytes from @data.
11220  *
11221  * @data is copied.
11222  *
11223  * Returns: (transfer full): a new #GBytes
11224  * Since: 2.32
11225  */
11226
11227
11228 /**
11229  * g_bytes_new_from_bytes:
11230  * @bytes: a #GBytes
11231  * @offset: offset which subsection starts at
11232  * @length: length of subsection
11233  *
11234  * Creates a #GBytes which is a subsection of another #GBytes. The @offset +
11235  * @length may not be longer than the size of @bytes.
11236  *
11237  * A reference to @bytes will be held by the newly created #GBytes until
11238  * the byte data is no longer needed.
11239  *
11240  * Returns: (transfer full): a new #GBytes
11241  * Since: 2.32
11242  */
11243
11244
11245 /**
11246  * g_bytes_new_static: (skip)
11247  * @data: (transfer full) (array length=size) (element-type guint8):
11248  *           the data to be used for the bytes
11249  * @size: the size of @data
11250  *
11251  * Creates a new #GBytes from static data.
11252  *
11253  * @data must be static (ie: never modified or freed).
11254  *
11255  * Returns: (transfer full): a new #GBytes
11256  * Since: 2.32
11257  */
11258
11259
11260 /**
11261  * g_bytes_new_take:
11262  * @data: (transfer full) (array length=size) (element-type guint8):
11263  *           the data to be used for the bytes
11264  * @size: the size of @data
11265  *
11266  * Creates a new #GBytes from @data.
11267  *
11268  * After this call, @data belongs to the bytes and may no longer be
11269  * modified by the caller.  g_free() will be called on @data when the
11270  * bytes is no longer in use. Because of this @data must have been created by
11271  * a call to g_malloc(), g_malloc0() or g_realloc() or by one of the many
11272  * functions that wrap these calls (such as g_new(), g_strdup(), etc).
11273  *
11274  * For creating #GBytes with memory from other allocators, see
11275  * g_bytes_new_with_free_func().
11276  *
11277  * Returns: (transfer full): a new #GBytes
11278  * Since: 2.32
11279  */
11280
11281
11282 /**
11283  * g_bytes_new_with_free_func:
11284  * @data: (array length=size): the data to be used for the bytes
11285  * @size: the size of @data
11286  * @free_func: the function to call to release the data
11287  * @user_data: data to pass to @free_func
11288  *
11289  * Creates a #GBytes from @data.
11290  *
11291  * When the last reference is dropped, @free_func will be called with the
11292  * @user_data argument.
11293  *
11294  * @data must not be modified after this call is made until @free_func has
11295  * been called to indicate that the bytes is no longer in use.
11296  *
11297  * Returns: (transfer full): a new #GBytes
11298  * Since: 2.32
11299  */
11300
11301
11302 /**
11303  * g_bytes_ref:
11304  * @bytes: a #GBytes
11305  *
11306  * Increase the reference count on @bytes.
11307  *
11308  * Returns: the #GBytes
11309  * Since: 2.32
11310  */
11311
11312
11313 /**
11314  * g_bytes_unref:
11315  * @bytes: (allow-none): a #GBytes
11316  *
11317  * Releases a reference on @bytes.  This may result in the bytes being
11318  * freed.
11319  *
11320  * Since: 2.32
11321  */
11322
11323
11324 /**
11325  * g_bytes_unref_to_array:
11326  * @bytes: (transfer full): a #GBytes
11327  *
11328  * Unreferences the bytes, and returns a new mutable #GByteArray containing
11329  * the same byte data.
11330  *
11331  * As an optimization, the byte data is transferred to the array without copying
11332  * if this was the last reference to bytes and bytes was created with
11333  * g_bytes_new(), g_bytes_new_take() or g_byte_array_free_to_bytes(). In all
11334  * other cases the data is copied.
11335  *
11336  * Returns: (transfer full): a new mutable #GByteArray containing the same byte data
11337  * Since: 2.32
11338  */
11339
11340
11341 /**
11342  * g_bytes_unref_to_data:
11343  * @bytes: (transfer full): a #GBytes
11344  * @size: location to place the length of the returned data
11345  *
11346  * Unreferences the bytes, and returns a pointer the same byte data
11347  * contents.
11348  *
11349  * As an optimization, the byte data is returned without copying if this was
11350  * the last reference to bytes and bytes was created with g_bytes_new(),
11351  * g_bytes_new_take() or g_byte_array_free_to_bytes(). In all other cases the
11352  * data is copied.
11353  *
11354  * Returns: (transfer full): a pointer to the same byte data, which should
11355  *          be freed with g_free()
11356  * Since: 2.32
11357  */
11358
11359
11360 /**
11361  * g_chdir:
11362  * @path: a pathname in the GLib file name encoding (UTF-8 on Windows)
11363  *
11364  * A wrapper for the POSIX chdir() function. The function changes the
11365  * current directory of the process to @path.
11366  *
11367  * See your C library manual for more details about chdir().
11368  *
11369  * Returns: 0 on success, -1 if an error occurred.
11370  * Since: 2.8
11371  */
11372
11373
11374 /**
11375  * g_checksum_copy:
11376  * @checksum: the #GChecksum to copy
11377  *
11378  * Copies a #GChecksum. If @checksum has been closed, by calling
11379  * g_checksum_get_string() or g_checksum_get_digest(), the copied
11380  * checksum will be closed as well.
11381  *
11382  * Returns: the copy of the passed #GChecksum. Use g_checksum_free()
11383  *   when finished using it.
11384  * Since: 2.16
11385  */
11386
11387
11388 /**
11389  * g_checksum_free:
11390  * @checksum: a #GChecksum
11391  *
11392  * Frees the memory allocated for @checksum.
11393  *
11394  * Since: 2.16
11395  */
11396
11397
11398 /**
11399  * g_checksum_get_digest: (skip)
11400  * @checksum: a #GChecksum
11401  * @buffer: output buffer
11402  * @digest_len: an inout parameter. The caller initializes it to the size of @buffer.
11403  *   After the call it contains the length of the digest.
11404  *
11405  * Gets the digest from @checksum as a raw binary vector and places it
11406  * into @buffer. The size of the digest depends on the type of checksum.
11407  *
11408  * Once this function has been called, the #GChecksum is closed and can
11409  * no longer be updated with g_checksum_update().
11410  *
11411  * Since: 2.16
11412  */
11413
11414
11415 /**
11416  * g_checksum_get_string:
11417  * @checksum: a #GChecksum
11418  *
11419  * Gets the digest as an hexadecimal string.
11420  *
11421  * Once this function has been called the #GChecksum can no longer be
11422  * updated with g_checksum_update().
11423  *
11424  * The hexadecimal characters will be lower case.
11425  *
11426  * Returns: the hexadecimal representation of the checksum. The
11427  *   returned string is owned by the checksum and should not be modified
11428  *   or freed.
11429  * Since: 2.16
11430  */
11431
11432
11433 /**
11434  * g_checksum_new:
11435  * @checksum_type: the desired type of checksum
11436  *
11437  * Creates a new #GChecksum, using the checksum algorithm @checksum_type.
11438  * If the @checksum_type is not known, %NULL is returned.
11439  * A #GChecksum can be used to compute the checksum, or digest, of an
11440  * arbitrary binary blob, using different hashing algorithms.
11441  *
11442  * A #GChecksum works by feeding a binary blob through g_checksum_update()
11443  * until there is data to be checked; the digest can then be extracted
11444  * using g_checksum_get_string(), which will return the checksum as a
11445  * hexadecimal string; or g_checksum_get_digest(), which will return a
11446  * vector of raw bytes. Once either g_checksum_get_string() or
11447  * g_checksum_get_digest() have been called on a #GChecksum, the checksum
11448  * will be closed and it won't be possible to call g_checksum_update()
11449  * on it anymore.
11450  *
11451  * Returns: (transfer full): the newly created #GChecksum, or %NULL.
11452  *   Use g_checksum_free() to free the memory allocated by it.
11453  * Since: 2.16
11454  */
11455
11456
11457 /**
11458  * g_checksum_reset:
11459  * @checksum: the #GChecksum to reset
11460  *
11461  * Resets the state of the @checksum back to its initial state.
11462  *
11463  * Since: 2.18
11464  */
11465
11466
11467 /**
11468  * g_checksum_type_get_length:
11469  * @checksum_type: a #GChecksumType
11470  *
11471  * Gets the length in bytes of digests of type @checksum_type
11472  *
11473  * Returns: the checksum length, or -1 if @checksum_type is
11474  * not supported.
11475  * Since: 2.16
11476  */
11477
11478
11479 /**
11480  * g_checksum_update:
11481  * @checksum: a #GChecksum
11482  * @data: (array length=length) (element-type guint8): buffer used to compute the checksum
11483  * @length: size of the buffer, or -1 if it is a null-terminated string.
11484  *
11485  * Feeds @data into an existing #GChecksum. The checksum must still be
11486  * open, that is g_checksum_get_string() or g_checksum_get_digest() must
11487  * not have been called on @checksum.
11488  *
11489  * Since: 2.16
11490  */
11491
11492
11493 /**
11494  * g_child_watch_add:
11495  * @pid: process id to watch. On POSIX the pid of a child process. On
11496  * Windows a handle for a process (which doesn't have to be a child).
11497  * @function: function to call
11498  * @data: data to pass to @function
11499  *
11500  * Sets a function to be called when the child indicated by @pid
11501  * exits, at a default priority, #G_PRIORITY_DEFAULT.
11502  *
11503  * If you obtain @pid from g_spawn_async() or g_spawn_async_with_pipes()
11504  * you will need to pass #G_SPAWN_DO_NOT_REAP_CHILD as flag to
11505  * the spawn function for the child watching to work.
11506  *
11507  * Note that on platforms where #GPid must be explicitly closed
11508  * (see g_spawn_close_pid()) @pid must not be closed while the
11509  * source is still active. Typically, you will want to call
11510  * g_spawn_close_pid() in the callback function for the source.
11511  *
11512  * GLib supports only a single callback per process id.
11513  *
11514  * This internally creates a main loop source using
11515  * g_child_watch_source_new() and attaches it to the main loop context
11516  * using g_source_attach(). You can do these steps manually if you
11517  * need greater control.
11518  *
11519  * Returns: the ID (greater than 0) of the event source.
11520  * Since: 2.4
11521  */
11522
11523
11524 /**
11525  * g_child_watch_add_full: (rename-to g_child_watch_add)
11526  * @priority: the priority of the idle source. Typically this will be in the
11527  *            range between #G_PRIORITY_DEFAULT_IDLE and #G_PRIORITY_HIGH_IDLE.
11528  * @pid: process to watch. On POSIX the pid of a child process. On
11529  * Windows a handle for a process (which doesn't have to be a child).
11530  * @function: function to call
11531  * @data: data to pass to @function
11532  * @notify: (allow-none): function to call when the idle is removed, or %NULL
11533  *
11534  * Sets a function to be called when the child indicated by @pid
11535  * exits, at the priority @priority.
11536  *
11537  * If you obtain @pid from g_spawn_async() or g_spawn_async_with_pipes()
11538  * you will need to pass #G_SPAWN_DO_NOT_REAP_CHILD as flag to
11539  * the spawn function for the child watching to work.
11540  *
11541  * In many programs, you will want to call g_spawn_check_exit_status()
11542  * in the callback to determine whether or not the child exited
11543  * successfully.
11544  *
11545  * Also, note that on platforms where #GPid must be explicitly closed
11546  * (see g_spawn_close_pid()) @pid must not be closed while the source
11547  * is still active.  Typically, you should invoke g_spawn_close_pid()
11548  * in the callback function for the source.
11549  *
11550  * GLib supports only a single callback per process id.
11551  *
11552  * This internally creates a main loop source using
11553  * g_child_watch_source_new() and attaches it to the main loop context
11554  * using g_source_attach(). You can do these steps manually if you
11555  * need greater control.
11556  *
11557  * Returns: the ID (greater than 0) of the event source.
11558  * Since: 2.4
11559  */
11560
11561
11562 /**
11563  * g_child_watch_source_new:
11564  * @pid: process to watch. On POSIX the pid of a child process. On
11565  * Windows a handle for a process (which doesn't have to be a child).
11566  *
11567  * Creates a new child_watch source.
11568  *
11569  * The source will not initially be associated with any #GMainContext
11570  * and must be added to one with g_source_attach() before it will be
11571  * executed.
11572  *
11573  * Note that child watch sources can only be used in conjunction with
11574  * <literal>g_spawn...</literal> when the %G_SPAWN_DO_NOT_REAP_CHILD
11575  * flag is used.
11576  *
11577  * Note that on platforms where #GPid must be explicitly closed
11578  * (see g_spawn_close_pid()) @pid must not be closed while the
11579  * source is still active. Typically, you will want to call
11580  * g_spawn_close_pid() in the callback function for the source.
11581  *
11582  * Note further that using g_child_watch_source_new() is not
11583  * compatible with calling <literal>waitpid</literal> with a
11584  * nonpositive first argument in the application. Calling waitpid()
11585  * for individual pids will still work fine.
11586  *
11587  * Returns: the newly-created child watch source
11588  * Since: 2.4
11589  */
11590
11591
11592 /**
11593  * g_chmod:
11594  * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
11595  * @mode: as in chmod()
11596  *
11597  * A wrapper for the POSIX chmod() function. The chmod() function is
11598  * used to set the permissions of a file system object.
11599  *
11600  * On Windows the file protection mechanism is not at all POSIX-like,
11601  * and the underlying chmod() function in the C library just sets or
11602  * clears the FAT-style READONLY attribute. It does not touch any
11603  * ACL. Software that needs to manage file permissions on Windows
11604  * exactly should use the Win32 API.
11605  *
11606  * See your C library manual for more details about chmod().
11607  *
11608  * Returns: zero if the operation succeeded, -1 on error.
11609  * Since: 2.8
11610  */
11611
11612
11613 /**
11614  * g_clear_error:
11615  * @err: a #GError return location
11616  *
11617  * If @err is %NULL, does nothing. If @err is non-%NULL,
11618  * calls g_error_free() on *@err and sets *@err to %NULL.
11619  */
11620
11621
11622 /**
11623  * g_clear_pointer: (skip)
11624  * @pp: a pointer to a variable, struct member etc. holding a pointer
11625  * @destroy: a function to which a gpointer can be passed, to destroy *@pp
11626  *
11627  * Clears a reference to a variable.
11628  *
11629  * @pp must not be %NULL.
11630  *
11631  * If the reference is %NULL then this function does nothing.
11632  * Otherwise, the variable is destroyed using @destroy and the
11633  * pointer is set to %NULL.
11634  *
11635  * This function is threadsafe and modifies the pointer atomically,
11636  * using memory barriers where needed.
11637  *
11638  * A macro is also included that allows this function to be used without
11639  * pointer casts.
11640  *
11641  * Since: 2.34
11642  */
11643
11644
11645 /**
11646  * g_close:
11647  * @fd: A file descriptor
11648  * @error: a #GError
11649  *
11650  * This wraps the close() call; in case of error, %errno will be
11651  * preserved, but the error will also be stored as a #GError in @error.
11652  *
11653  * Besides using #GError, there is another major reason to prefer this
11654  * function over the call provided by the system; on Unix, it will
11655  * attempt to correctly handle %EINTR, which has platform-specific
11656  * semantics.
11657  *
11658  * Since: 2.36
11659  */
11660
11661
11662 /**
11663  * g_compute_checksum_for_bytes:
11664  * @checksum_type: a #GChecksumType
11665  * @data: binary blob to compute the digest of
11666  *
11667  * Computes the checksum for a binary @data. This is a
11668  * convenience wrapper for g_checksum_new(), g_checksum_get_string()
11669  * and g_checksum_free().
11670  *
11671  * The hexadecimal string returned will be in lower case.
11672  *
11673  * Returns: the digest of the binary data as a string in hexadecimal.
11674  *   The returned string should be freed with g_free() when done using it.
11675  * Since: 2.34
11676  */
11677
11678
11679 /**
11680  * g_compute_checksum_for_data:
11681  * @checksum_type: a #GChecksumType
11682  * @data: (array length=length) (element-type guint8): binary blob to compute the digest of
11683  * @length: length of @data
11684  *
11685  * Computes the checksum for a binary @data of @length. This is a
11686  * convenience wrapper for g_checksum_new(), g_checksum_get_string()
11687  * and g_checksum_free().
11688  *
11689  * The hexadecimal string returned will be in lower case.
11690  *
11691  * Returns: the digest of the binary data as a string in hexadecimal.
11692  *   The returned string should be freed with g_free() when done using it.
11693  * Since: 2.16
11694  */
11695
11696
11697 /**
11698  * g_compute_checksum_for_string:
11699  * @checksum_type: a #GChecksumType
11700  * @str: the string to compute the checksum of
11701  * @length: the length of the string, or -1 if the string is null-terminated.
11702  *
11703  * Computes the checksum of a string.
11704  *
11705  * The hexadecimal string returned will be in lower case.
11706  *
11707  * Returns: the checksum as a hexadecimal string. The returned string
11708  *   should be freed with g_free() when done using it.
11709  * Since: 2.16
11710  */
11711
11712
11713 /**
11714  * g_compute_hmac_for_data:
11715  * @digest_type: a #GChecksumType to use for the HMAC
11716  * @key: (array length=key_len): the key to use in the HMAC
11717  * @key_len: the length of the key
11718  * @data: binary blob to compute the HMAC of
11719  * @length: length of @data
11720  *
11721  * Computes the HMAC for a binary @data of @length. This is a
11722  * convenience wrapper for g_hmac_new(), g_hmac_get_string()
11723  * and g_hmac_unref().
11724  *
11725  * The hexadecimal string returned will be in lower case.
11726  *
11727  * Returns: the HMAC of the binary data as a string in hexadecimal.
11728  *   The returned string should be freed with g_free() when done using it.
11729  * Since: 2.30
11730  */
11731
11732
11733 /**
11734  * g_compute_hmac_for_string:
11735  * @digest_type: a #GChecksumType to use for the HMAC
11736  * @key: (array length=key_len): the key to use in the HMAC
11737  * @key_len: the length of the key
11738  * @str: the string to compute the HMAC for
11739  * @length: the length of the string, or -1 if the string is nul-terminated
11740  *
11741  * Computes the HMAC for a string.
11742  *
11743  * The hexadecimal string returned will be in lower case.
11744  *
11745  * Returns: the HMAC as a hexadecimal string.
11746  *     The returned string should be freed with g_free()
11747  *     when done using it.
11748  * Since: 2.30
11749  */
11750
11751
11752 /**
11753  * g_cond_broadcast:
11754  * @cond: a #GCond
11755  *
11756  * If threads are waiting for @cond, all of them are unblocked.
11757  * If no threads are waiting for @cond, this function has no effect.
11758  * It is good practice to lock the same mutex as the waiting threads
11759  * while calling this function, though not required.
11760  */
11761
11762
11763 /**
11764  * g_cond_clear:
11765  * @cond: an initialised #GCond
11766  *
11767  * Frees the resources allocated to a #GCond with g_cond_init().
11768  *
11769  * This function should not be used with a #GCond that has been
11770  * statically allocated.
11771  *
11772  * Calling g_cond_clear() for a #GCond on which threads are
11773  * blocking leads to undefined behaviour.
11774  *
11775  * Since: 2.32
11776  */
11777
11778
11779 /**
11780  * g_cond_init:
11781  * @cond: an uninitialized #GCond
11782  *
11783  * Initialises a #GCond so that it can be used.
11784  *
11785  * This function is useful to initialise a #GCond that has been
11786  * allocated as part of a larger structure.  It is not necessary to
11787  * initialise a #GCond that has been statically allocated.
11788  *
11789  * To undo the effect of g_cond_init() when a #GCond is no longer
11790  * needed, use g_cond_clear().
11791  *
11792  * Calling g_cond_init() on an already-initialised #GCond leads
11793  * to undefined behaviour.
11794  *
11795  * Since: 2.32
11796  */
11797
11798
11799 /**
11800  * g_cond_signal:
11801  * @cond: a #GCond
11802  *
11803  * If threads are waiting for @cond, at least one of them is unblocked.
11804  * If no threads are waiting for @cond, this function has no effect.
11805  * It is good practice to hold the same lock as the waiting thread
11806  * while calling this function, though not required.
11807  */
11808
11809
11810 /**
11811  * g_cond_wait:
11812  * @cond: a #GCond
11813  * @mutex: a #GMutex that is currently locked
11814  *
11815  * Atomically releases @mutex and waits until @cond is signalled.
11816  * When this function returns, @mutex is locked again and owned by the
11817  * calling thread.
11818  *
11819  * When using condition variables, it is possible that a spurious wakeup
11820  * may occur (ie: g_cond_wait() returns even though g_cond_signal() was
11821  * not called).  It's also possible that a stolen wakeup may occur.
11822  * This is when g_cond_signal() is called, but another thread acquires
11823  * @mutex before this thread and modifies the state of the program in
11824  * such a way that when g_cond_wait() is able to return, the expected
11825  * condition is no longer met.
11826  *
11827  * For this reason, g_cond_wait() must always be used in a loop.  See
11828  * the documentation for #GCond for a complete example.
11829  */
11830
11831
11832 /**
11833  * g_cond_wait_until:
11834  * @cond: a #GCond
11835  * @mutex: a #GMutex that is currently locked
11836  * @end_time: the monotonic time to wait until
11837  *
11838  * Waits until either @cond is signalled or @end_time has passed.
11839  *
11840  * As with g_cond_wait() it is possible that a spurious or stolen wakeup
11841  * could occur.  For that reason, waiting on a condition variable should
11842  * always be in a loop, based on an explicitly-checked predicate.
11843  *
11844  * %TRUE is returned if the condition variable was signalled (or in the
11845  * case of a spurious wakeup).  %FALSE is returned if @end_time has
11846  * passed.
11847  *
11848  * The following code shows how to correctly perform a timed wait on a
11849  * condition variable (extended the example presented in the
11850  * documentation for #GCond):
11851  *
11852  * |[
11853  * gpointer
11854  * pop_data_timed (void)
11855  * {
11856  *   gint64 end_time;
11857  *   gpointer data;
11858  *
11859  *   g_mutex_lock (&data_mutex);
11860  *
11861  *   end_time = g_get_monotonic_time () + 5 * G_TIME_SPAN_SECOND;
11862  *   while (!current_data)
11863  *     if (!g_cond_wait_until (&data_cond, &data_mutex, end_time))
11864  *       {
11865  *         // timeout has passed.
11866  *         g_mutex_unlock (&data_mutex);
11867  *         return NULL;
11868  *       }
11869  *
11870  *   // there is data for us
11871  *   data = current_data;
11872  *   current_data = NULL;
11873  *
11874  *   g_mutex_unlock (&data_mutex);
11875  *
11876  *   return data;
11877  * }
11878  * ]|
11879  *
11880  * Notice that the end time is calculated once, before entering the
11881  * loop and reused.  This is the motivation behind the use of absolute
11882  * time on this API -- if a relative time of 5 seconds were passed
11883  * directly to the call and a spurious wakeup occurred, the program would
11884  * have to start over waiting again (which would lead to a total wait
11885  * time of more than 5 seconds).
11886  *
11887  * Returns: %TRUE on a signal, %FALSE on a timeout
11888  * Since: 2.32
11889  */
11890
11891
11892 /**
11893  * g_convert:
11894  * @str: the string to convert
11895  * @len: the length of the string, or -1 if the string is
11896  *                 nul-terminated<footnote id="nul-unsafe">
11897  *                      <para>
11898  *                        Note that some encodings may allow nul bytes to
11899  *                        occur inside strings. In that case, using -1 for
11900  *                        the @len parameter is unsafe.
11901  *                      </para>
11902  *                    </footnote>.
11903  * @to_codeset: name of character set into which to convert @str
11904  * @from_codeset: character set of @str.
11905  * @bytes_read: (out): location to store the number of bytes in the
11906  *                 input string that were successfully converted, or %NULL.
11907  *                 Even if the conversion was successful, this may be
11908  *                 less than @len if there were partial characters
11909  *                 at the end of the input. If the error
11910  *                 #G_CONVERT_ERROR_ILLEGAL_SEQUENCE occurs, the value
11911  *                 stored will the byte offset after the last valid
11912  *                 input sequence.
11913  * @bytes_written: (out): the number of bytes stored in the output buffer (not
11914  *                 including the terminating nul).
11915  * @error: location to store the error occurring, or %NULL to ignore
11916  *                 errors. Any of the errors in #GConvertError may occur.
11917  *
11918  * Converts a string from one character set to another.
11919  *
11920  * Note that you should use g_iconv() for streaming
11921  * conversions<footnoteref linkend="streaming-state"/>.
11922  *
11923  * Returns: If the conversion was successful, a newly allocated
11924  *               nul-terminated string, which must be freed with
11925  *               g_free(). Otherwise %NULL and @error will be set.
11926  */
11927
11928
11929 /**
11930  * g_convert_with_fallback:
11931  * @str: the string to convert
11932  * @len: the length of the string, or -1 if the string is
11933  *                nul-terminated<footnoteref linkend="nul-unsafe"/>.
11934  * @to_codeset: name of character set into which to convert @str
11935  * @from_codeset: character set of @str.
11936  * @fallback: UTF-8 string to use in place of character not
11937  *                present in the target encoding. (The string must be
11938  *                representable in the target encoding).
11939  *                   If %NULL, characters not in the target encoding will
11940  *                   be represented as Unicode escapes \uxxxx or \Uxxxxyyyy.
11941  * @bytes_read: location to store the number of bytes in the
11942  *                input string that were successfully converted, or %NULL.
11943  *                Even if the conversion was successful, this may be
11944  *                less than @len if there were partial characters
11945  *                at the end of the input.
11946  * @bytes_written: the number of bytes stored in the output buffer (not
11947  *                including the terminating nul).
11948  * @error: location to store the error occurring, or %NULL to ignore
11949  *                errors. Any of the errors in #GConvertError may occur.
11950  *
11951  * Converts a string from one character set to another, possibly
11952  * including fallback sequences for characters not representable
11953  * in the output. Note that it is not guaranteed that the specification
11954  * for the fallback sequences in @fallback will be honored. Some
11955  * systems may do an approximate conversion from @from_codeset
11956  * to @to_codeset in their iconv() functions,
11957  * in which case GLib will simply return that approximate conversion.
11958  *
11959  * Note that you should use g_iconv() for streaming
11960  * conversions<footnoteref linkend="streaming-state"/>.
11961  *
11962  * Returns: If the conversion was successful, a newly allocated
11963  *               nul-terminated string, which must be freed with
11964  *               g_free(). Otherwise %NULL and @error will be set.
11965  */
11966
11967
11968 /**
11969  * g_convert_with_iconv:
11970  * @str: the string to convert
11971  * @len: the length of the string, or -1 if the string is
11972  *                 nul-terminated<footnoteref linkend="nul-unsafe"/>.
11973  * @converter: conversion descriptor from g_iconv_open()
11974  * @bytes_read: location to store the number of bytes in the
11975  *                 input string that were successfully converted, or %NULL.
11976  *                 Even if the conversion was successful, this may be
11977  *                 less than @len if there were partial characters
11978  *                 at the end of the input. If the error
11979  *                 #G_CONVERT_ERROR_ILLEGAL_SEQUENCE occurs, the value
11980  *                 stored will the byte offset after the last valid
11981  *                 input sequence.
11982  * @bytes_written: the number of bytes stored in the output buffer (not
11983  *                 including the terminating nul).
11984  * @error: location to store the error occurring, or %NULL to ignore
11985  *                 errors. Any of the errors in #GConvertError may occur.
11986  *
11987  * Converts a string from one character set to another.
11988  *
11989  * Note that you should use g_iconv() for streaming
11990  * conversions<footnote id="streaming-state">
11991  *  <para>
11992  * Despite the fact that @byes_read can return information about partial
11993  * characters, the <literal>g_convert_...</literal> functions
11994  * are not generally suitable for streaming. If the underlying converter
11995  * being used maintains internal state, then this won't be preserved
11996  * across successive calls to g_convert(), g_convert_with_iconv() or
11997  * g_convert_with_fallback(). (An example of this is the GNU C converter
11998  * for CP1255 which does not emit a base character until it knows that
11999  * the next character is not a mark that could combine with the base
12000  * character.)
12001  *  </para>
12002  * </footnote>.
12003  *
12004  * Returns: If the conversion was successful, a newly allocated
12005  *               nul-terminated string, which must be freed with
12006  *               g_free(). Otherwise %NULL and @error will be set.
12007  */
12008
12009
12010 /**
12011  * g_creat:
12012  * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
12013  * @mode: as in creat()
12014  *
12015  * A wrapper for the POSIX creat() function. The creat() function is
12016  * used to convert a pathname into a file descriptor, creating a file
12017  * if necessary.
12018  *
12019  * On POSIX systems file descriptors are implemented by the operating
12020  * system. On Windows, it's the C library that implements creat() and
12021  * file descriptors. The actual Windows API for opening files is
12022  * different, see MSDN documentation for CreateFile(). The Win32 API
12023  * uses file handles, which are more randomish integers, not small
12024  * integers like file descriptors.
12025  *
12026  * Because file descriptors are specific to the C library on Windows,
12027  * the file descriptor returned by this function makes sense only to
12028  * functions in the same C library. Thus if the GLib-using code uses a
12029  * different C library than GLib does, the file descriptor returned by
12030  * this function cannot be passed to C library functions like write()
12031  * or read().
12032  *
12033  * See your C library manual for more details about creat().
12034  *
12035  * Returns: a new file descriptor, or -1 if an error occurred. The
12036  * return value can be used exactly like the return value from creat().
12037  * Since: 2.8
12038  */
12039
12040
12041 /**
12042  * g_critical:
12043  * @...: format string, followed by parameters to insert
12044  *     into the format string (as with printf())
12045  *
12046  * Logs a "critical warning" (#G_LOG_LEVEL_CRITICAL).
12047  * It's more or less application-defined what constitutes
12048  * a critical vs. a regular warning. You could call
12049  * g_log_set_always_fatal() to make critical warnings exit
12050  * the program, then use g_critical() for fatal errors, for
12051  * example.
12052  *
12053  * You can also make critical warnings fatal at runtime by
12054  * setting the <envar>G_DEBUG</envar> environment variable (see
12055  * <ulink url="glib-running.html">Running GLib Applications</ulink>).
12056  *
12057  * If g_log_default_handler() is used as the log handler function, a new-line
12058  * character will automatically be appended to @..., and need not be entered
12059  * manually.
12060  */
12061
12062
12063 /**
12064  * g_datalist_clear:
12065  * @datalist: a datalist.
12066  *
12067  * Frees all the data elements of the datalist.
12068  * The data elements' destroy functions are called
12069  * if they have been set.
12070  */
12071
12072
12073 /**
12074  * g_datalist_foreach:
12075  * @datalist: a datalist.
12076  * @func: the function to call for each data element.
12077  * @user_data: user data to pass to the function.
12078  *
12079  * Calls the given function for each data element of the datalist. The
12080  * function is called with each data element's #GQuark id and data,
12081  * together with the given @user_data parameter. Note that this
12082  * function is NOT thread-safe. So unless @datalist can be protected
12083  * from any modifications during invocation of this function, it should
12084  * not be called.
12085  */
12086
12087
12088 /**
12089  * g_datalist_get_data:
12090  * @datalist: a datalist.
12091  * @key: the string identifying a data element.
12092  *
12093  * Gets a data element, using its string identifier. This is slower than
12094  * g_datalist_id_get_data() because it compares strings.
12095  *
12096  * Returns: the data element, or %NULL if it is not found.
12097  */
12098
12099
12100 /**
12101  * g_datalist_get_flags:
12102  * @datalist: pointer to the location that holds a list
12103  *
12104  * Gets flags values packed in together with the datalist.
12105  * See g_datalist_set_flags().
12106  *
12107  * Returns: the flags of the datalist
12108  * Since: 2.8
12109  */
12110
12111
12112 /**
12113  * g_datalist_id_dup_data:
12114  * @datalist: location of a datalist
12115  * @key_id: the #GQuark identifying a data element
12116  * @dup_func: (allow-none): function to duplicate the old value
12117  * @user_data: (allow-none): passed as user_data to @dup_func
12118  *
12119  * This is a variant of g_datalist_id_get_data() which
12120  * returns a 'duplicate' of the value. @dup_func defines the
12121  * meaning of 'duplicate' in this context, it could e.g.
12122  * take a reference on a ref-counted object.
12123  *
12124  * If the @key_id is not set in the datalist then @dup_func
12125  * will be called with a %NULL argument.
12126  *
12127  * Note that @dup_func is called while the datalist is locked, so it
12128  * is not allowed to read or modify the datalist.
12129  *
12130  * This function can be useful to avoid races when multiple
12131  * threads are using the same datalist and the same key.
12132  *
12133  * Returns: the result of calling @dup_func on the value
12134  *     associated with @key_id in @datalist, or %NULL if not set.
12135  *     If @dup_func is %NULL, the value is returned unmodified.
12136  * Since: 2.34
12137  */
12138
12139
12140 /**
12141  * g_datalist_id_get_data:
12142  * @datalist: a datalist.
12143  * @key_id: the #GQuark identifying a data element.
12144  *
12145  * Retrieves the data element corresponding to @key_id.
12146  *
12147  * Returns: the data element, or %NULL if it is not found.
12148  */
12149
12150
12151 /**
12152  * g_datalist_id_remove_data:
12153  * @dl: a datalist.
12154  * @q: the #GQuark identifying the data element.
12155  *
12156  * Removes an element, using its #GQuark identifier.
12157  */
12158
12159
12160 /**
12161  * g_datalist_id_remove_no_notify:
12162  * @datalist: a datalist.
12163  * @key_id: the #GQuark identifying a data element.
12164  *
12165  * Removes an element, without calling its destroy notification
12166  * function.
12167  *
12168  * Returns: the data previously stored at @key_id, or %NULL if none.
12169  */
12170
12171
12172 /**
12173  * g_datalist_id_replace_data:
12174  * @datalist: location of a datalist
12175  * @key_id: the #GQuark identifying a data element
12176  * @oldval: (allow-none): the old value to compare against
12177  * @newval: (allow-none): the new value to replace it with
12178  * @destroy: (allow-none): destroy notify for the new value
12179  * @old_destroy: (allow-none): destroy notify for the existing value
12180  *
12181  * Compares the member that is associated with @key_id in
12182  * @datalist to @oldval, and if they are the same, replace
12183  * @oldval with @newval.
12184  *
12185  * This is like a typical atomic compare-and-exchange
12186  * operation, for a member of @datalist.
12187  *
12188  * If the previous value was replaced then ownership of the
12189  * old value (@oldval) is passed to the caller, including
12190  * the registred destroy notify for it (passed out in @old_destroy).
12191  * Its up to the caller to free this as he wishes, which may
12192  * or may not include using @old_destroy as sometimes replacement
12193  * should not destroy the object in the normal way.
12194  *
12195  * Returns: %TRUE if the existing value for @key_id was replaced
12196  *  by @newval, %FALSE otherwise.
12197  * Since: 2.34
12198  */
12199
12200
12201 /**
12202  * g_datalist_id_set_data:
12203  * @dl: a datalist.
12204  * @q: the #GQuark to identify the data element.
12205  * @d: (allow-none): the data element, or %NULL to remove any previous element
12206  *     corresponding to @q.
12207  *
12208  * Sets the data corresponding to the given #GQuark id. Any previous
12209  * data with the same key is removed, and its destroy function is
12210  * called.
12211  */
12212
12213
12214 /**
12215  * g_datalist_id_set_data_full:
12216  * @datalist: a datalist.
12217  * @key_id: the #GQuark to identify the data element.
12218  * @data: (allow-none): the data element or %NULL to remove any previous element
12219  *        corresponding to @key_id.
12220  * @destroy_func: the function to call when the data element is
12221  *                removed. This function will be called with the data
12222  *                element and can be used to free any memory allocated
12223  *                for it. If @data is %NULL, then @destroy_func must
12224  *                also be %NULL.
12225  *
12226  * Sets the data corresponding to the given #GQuark id, and the
12227  * function to be called when the element is removed from the datalist.
12228  * Any previous data with the same key is removed, and its destroy
12229  * function is called.
12230  */
12231
12232
12233 /**
12234  * g_datalist_init:
12235  * @datalist: a pointer to a pointer to a datalist.
12236  *
12237  * Resets the datalist to %NULL. It does not free any memory or call
12238  * any destroy functions.
12239  */
12240
12241
12242 /**
12243  * g_datalist_remove_data:
12244  * @dl: a datalist.
12245  * @k: the string identifying the data element.
12246  *
12247  * Removes an element using its string identifier. The data element's
12248  * destroy function is called if it has been set.
12249  */
12250
12251
12252 /**
12253  * g_datalist_remove_no_notify:
12254  * @dl: a datalist.
12255  * @k: the string identifying the data element.
12256  *
12257  * Removes an element, without calling its destroy notifier.
12258  */
12259
12260
12261 /**
12262  * g_datalist_set_data:
12263  * @dl: a datalist.
12264  * @k: the string to identify the data element.
12265  * @d: (allow-none): the data element, or %NULL to remove any previous element
12266  *     corresponding to @k.
12267  *
12268  * Sets the data element corresponding to the given string identifier.
12269  */
12270
12271
12272 /**
12273  * g_datalist_set_data_full:
12274  * @dl: a datalist.
12275  * @k: the string to identify the data element.
12276  * @d: (allow-none): the data element, or %NULL to remove any previous element
12277  *     corresponding to @k.
12278  * @f: the function to call when the data element is removed. This
12279  *     function will be called with the data element and can be used to
12280  *     free any memory allocated for it. If @d is %NULL, then @f must
12281  *     also be %NULL.
12282  *
12283  * Sets the data element corresponding to the given string identifier,
12284  * and the function to be called when the data element is removed.
12285  */
12286
12287
12288 /**
12289  * g_datalist_set_flags:
12290  * @datalist: pointer to the location that holds a list
12291  * @flags: the flags to turn on. The values of the flags are
12292  *   restricted by %G_DATALIST_FLAGS_MASK (currently
12293  *   3; giving two possible boolean flags).
12294  *   A value for @flags that doesn't fit within the mask is
12295  *   an error.
12296  *
12297  * Turns on flag values for a data list. This function is used
12298  * to keep a small number of boolean flags in an object with
12299  * a data list without using any additional space. It is
12300  * not generally useful except in circumstances where space
12301  * is very tight. (It is used in the base #GObject type, for
12302  * example.)
12303  *
12304  * Since: 2.8
12305  */
12306
12307
12308 /**
12309  * g_datalist_unset_flags:
12310  * @datalist: pointer to the location that holds a list
12311  * @flags: the flags to turn off. The values of the flags are
12312  *   restricted by %G_DATALIST_FLAGS_MASK (currently
12313  *   3: giving two possible boolean flags).
12314  *   A value for @flags that doesn't fit within the mask is
12315  *   an error.
12316  *
12317  * Turns off flag values for a data list. See g_datalist_unset_flags()
12318  *
12319  * Since: 2.8
12320  */
12321
12322
12323 /**
12324  * g_dataset_destroy:
12325  * @dataset_location: the location identifying the dataset.
12326  *
12327  * Destroys the dataset, freeing all memory allocated, and calling any
12328  * destroy functions set for data elements.
12329  */
12330
12331
12332 /**
12333  * g_dataset_foreach:
12334  * @dataset_location: the location identifying the dataset.
12335  * @func: the function to call for each data element.
12336  * @user_data: user data to pass to the function.
12337  *
12338  * Calls the given function for each data element which is associated
12339  * with the given location. Note that this function is NOT thread-safe.
12340  * So unless @datalist can be protected from any modifications during
12341  * invocation of this function, it should not be called.
12342  */
12343
12344
12345 /**
12346  * g_dataset_get_data:
12347  * @l: the location identifying the dataset.
12348  * @k: the string identifying the data element.
12349  *
12350  * Gets the data element corresponding to a string.
12351  *
12352  * Returns: the data element corresponding to the string, or %NULL if
12353  *          it is not found.
12354  */
12355
12356
12357 /**
12358  * g_dataset_id_get_data:
12359  * @dataset_location: the location identifying the dataset.
12360  * @key_id: the #GQuark id to identify the data element.
12361  *
12362  * Gets the data element corresponding to a #GQuark.
12363  *
12364  * Returns: the data element corresponding to the #GQuark, or %NULL if
12365  *          it is not found.
12366  */
12367
12368
12369 /**
12370  * g_dataset_id_remove_data:
12371  * @l: the location identifying the dataset.
12372  * @k: the #GQuark id identifying the data element.
12373  *
12374  * Removes a data element from a dataset. The data element's destroy
12375  * function is called if it has been set.
12376  */
12377
12378
12379 /**
12380  * g_dataset_id_remove_no_notify:
12381  * @dataset_location: the location identifying the dataset.
12382  * @key_id: the #GQuark ID identifying the data element.
12383  *
12384  * Removes an element, without calling its destroy notification
12385  * function.
12386  *
12387  * Returns: the data previously stored at @key_id, or %NULL if none.
12388  */
12389
12390
12391 /**
12392  * g_dataset_id_set_data:
12393  * @l: the location identifying the dataset.
12394  * @k: the #GQuark id to identify the data element.
12395  * @d: the data element.
12396  *
12397  * Sets the data element associated with the given #GQuark id. Any
12398  * previous data with the same key is removed, and its destroy function
12399  * is called.
12400  */
12401
12402
12403 /**
12404  * g_dataset_id_set_data_full:
12405  * @dataset_location: the location identifying the dataset.
12406  * @key_id: the #GQuark id to identify the data element.
12407  * @data: the data element.
12408  * @destroy_func: the function to call when the data element is
12409  *                removed. This function will be called with the data
12410  *                element and can be used to free any memory allocated
12411  *                for it.
12412  *
12413  * Sets the data element associated with the given #GQuark id, and also
12414  * the function to call when the data element is destroyed. Any
12415  * previous data with the same key is removed, and its destroy function
12416  * is called.
12417  */
12418
12419
12420 /**
12421  * g_dataset_remove_data:
12422  * @l: the location identifying the dataset.
12423  * @k: the string identifying the data element.
12424  *
12425  * Removes a data element corresponding to a string. Its destroy
12426  * function is called if it has been set.
12427  */
12428
12429
12430 /**
12431  * g_dataset_remove_no_notify:
12432  * @l: the location identifying the dataset.
12433  * @k: the string identifying the data element.
12434  *
12435  * Removes an element, without calling its destroy notifier.
12436  */
12437
12438
12439 /**
12440  * g_dataset_set_data:
12441  * @l: the location identifying the dataset.
12442  * @k: the string to identify the data element.
12443  * @d: the data element.
12444  *
12445  * Sets the data corresponding to the given string identifier.
12446  */
12447
12448
12449 /**
12450  * g_dataset_set_data_full:
12451  * @l: the location identifying the dataset.
12452  * @k: the string to identify the data element.
12453  * @d: the data element.
12454  * @f: the function to call when the data element is removed. This
12455  *     function will be called with the data element and can be used to
12456  *     free any memory allocated for it.
12457  *
12458  * Sets the data corresponding to the given string identifier, and the
12459  * function to call when the data element is destroyed.
12460  */
12461
12462
12463 /**
12464  * g_date_add_days:
12465  * @date: a #GDate to increment
12466  * @n_days: number of days to move the date forward
12467  *
12468  * Increments a date some number of days.
12469  * To move forward by weeks, add weeks*7 days.
12470  * The date must be valid.
12471  */
12472
12473
12474 /**
12475  * g_date_add_months:
12476  * @date: a #GDate to increment
12477  * @n_months: number of months to move forward
12478  *
12479  * Increments a date by some number of months.
12480  * If the day of the month is greater than 28,
12481  * this routine may change the day of the month
12482  * (because the destination month may not have
12483  * the current day in it). The date must be valid.
12484  */
12485
12486
12487 /**
12488  * g_date_add_years:
12489  * @date: a #GDate to increment
12490  * @n_years: number of years to move forward
12491  *
12492  * Increments a date by some number of years.
12493  * If the date is February 29, and the destination
12494  * year is not a leap year, the date will be changed
12495  * to February 28. The date must be valid.
12496  */
12497
12498
12499 /**
12500  * g_date_clamp:
12501  * @date: a #GDate to clamp
12502  * @min_date: minimum accepted value for @date
12503  * @max_date: maximum accepted value for @date
12504  *
12505  * If @date is prior to @min_date, sets @date equal to @min_date.
12506  * If @date falls after @max_date, sets @date equal to @max_date.
12507  * Otherwise, @date is unchanged.
12508  * Either of @min_date and @max_date may be %NULL.
12509  * All non-%NULL dates must be valid.
12510  */
12511
12512
12513 /**
12514  * g_date_clear:
12515  * @date: pointer to one or more dates to clear
12516  * @n_dates: number of dates to clear
12517  *
12518  * Initializes one or more #GDate structs to a sane but invalid
12519  * state. The cleared dates will not represent an existing date, but will
12520  * not contain garbage. Useful to init a date declared on the stack.
12521  * Validity can be tested with g_date_valid().
12522  */
12523
12524
12525 /**
12526  * g_date_compare:
12527  * @lhs: first date to compare
12528  * @rhs: second date to compare
12529  *
12530  * qsort()-style comparison function for dates.
12531  * Both dates must be valid.
12532  *
12533  * Returns: 0 for equal, less than zero if @lhs is less than @rhs,
12534  *     greater than zero if @lhs is greater than @rhs
12535  */
12536
12537
12538 /**
12539  * g_date_days_between:
12540  * @date1: the first date
12541  * @date2: the second date
12542  *
12543  * Computes the number of days between two dates.
12544  * If @date2 is prior to @date1, the returned value is negative.
12545  * Both dates must be valid.
12546  *
12547  * Returns: the number of days between @date1 and @date2
12548  */
12549
12550
12551 /**
12552  * g_date_free:
12553  * @date: a #GDate to free
12554  *
12555  * Frees a #GDate returned from g_date_new().
12556  */
12557
12558
12559 /**
12560  * g_date_get_day:
12561  * @date: a #GDate to extract the day of the month from
12562  *
12563  * Returns the day of the month. The date must be valid.
12564  *
12565  * Returns: day of the month
12566  */
12567
12568
12569 /**
12570  * g_date_get_day_of_year:
12571  * @date: a #GDate to extract day of year from
12572  *
12573  * Returns the day of the year, where Jan 1 is the first day of the
12574  * year. The date must be valid.
12575  *
12576  * Returns: day of the year
12577  */
12578
12579
12580 /**
12581  * g_date_get_days_in_month:
12582  * @month: month
12583  * @year: year
12584  *
12585  * Returns the number of days in a month, taking leap
12586  * years into account.
12587  *
12588  * Returns: number of days in @month during the @year
12589  */
12590
12591
12592 /**
12593  * g_date_get_iso8601_week_of_year:
12594  * @date: a valid #GDate
12595  *
12596  * Returns the week of the year, where weeks are interpreted according
12597  * to ISO 8601.
12598  *
12599  * Returns: ISO 8601 week number of the year.
12600  * Since: 2.6
12601  */
12602
12603
12604 /**
12605  * g_date_get_julian:
12606  * @date: a #GDate to extract the Julian day from
12607  *
12608  * Returns the Julian day or "serial number" of the #GDate. The
12609  * Julian day is simply the number of days since January 1, Year 1; i.e.,
12610  * January 1, Year 1 is Julian day 1; January 2, Year 1 is Julian day 2,
12611  * etc. The date must be valid.
12612  *
12613  * Returns: Julian day
12614  */
12615
12616
12617 /**
12618  * g_date_get_monday_week_of_year:
12619  * @date: a #GDate
12620  *
12621  * Returns the week of the year, where weeks are understood to start on
12622  * Monday. If the date is before the first Monday of the year, return
12623  * 0. The date must be valid.
12624  *
12625  * Returns: week of the year
12626  */
12627
12628
12629 /**
12630  * g_date_get_monday_weeks_in_year:
12631  * @year: a year
12632  *
12633  * Returns the number of weeks in the year, where weeks
12634  * are taken to start on Monday. Will be 52 or 53. The
12635  * date must be valid. (Years always have 52 7-day periods,
12636  * plus 1 or 2 extra days depending on whether it's a leap
12637  * year. This function is basically telling you how many
12638  * Mondays are in the year, i.e. there are 53 Mondays if
12639  * one of the extra days happens to be a Monday.)
12640  *
12641  * Returns: number of Mondays in the year
12642  */
12643
12644
12645 /**
12646  * g_date_get_month:
12647  * @date: a #GDate to get the month from
12648  *
12649  * Returns the month of the year. The date must be valid.
12650  *
12651  * Returns: month of the year as a #GDateMonth
12652  */
12653
12654
12655 /**
12656  * g_date_get_sunday_week_of_year:
12657  * @date: a #GDate
12658  *
12659  * Returns the week of the year during which this date falls, if weeks
12660  * are understood to being on Sunday. The date must be valid. Can return
12661  * 0 if the day is before the first Sunday of the year.
12662  *
12663  * Returns: week number
12664  */
12665
12666
12667 /**
12668  * g_date_get_sunday_weeks_in_year:
12669  * @year: year to count weeks in
12670  *
12671  * Returns the number of weeks in the year, where weeks
12672  * are taken to start on Sunday. Will be 52 or 53. The
12673  * date must be valid. (Years always have 52 7-day periods,
12674  * plus 1 or 2 extra days depending on whether it's a leap
12675  * year. This function is basically telling you how many
12676  * Sundays are in the year, i.e. there are 53 Sundays if
12677  * one of the extra days happens to be a Sunday.)
12678  *
12679  * Returns: the number of weeks in @year
12680  */
12681
12682
12683 /**
12684  * g_date_get_weekday:
12685  * @date: a #GDate
12686  *
12687  * Returns the day of the week for a #GDate. The date must be valid.
12688  *
12689  * Returns: day of the week as a #GDateWeekday.
12690  */
12691
12692
12693 /**
12694  * g_date_get_year:
12695  * @date: a #GDate
12696  *
12697  * Returns the year of a #GDate. The date must be valid.
12698  *
12699  * Returns: year in which the date falls
12700  */
12701
12702
12703 /**
12704  * g_date_is_first_of_month:
12705  * @date: a #GDate to check
12706  *
12707  * Returns %TRUE if the date is on the first of a month.
12708  * The date must be valid.
12709  *
12710  * Returns: %TRUE if the date is the first of the month
12711  */
12712
12713
12714 /**
12715  * g_date_is_last_of_month:
12716  * @date: a #GDate to check
12717  *
12718  * Returns %TRUE if the date is the last day of the month.
12719  * The date must be valid.
12720  *
12721  * Returns: %TRUE if the date is the last day of the month
12722  */
12723
12724
12725 /**
12726  * g_date_is_leap_year:
12727  * @year: year to check
12728  *
12729  * Returns %TRUE if the year is a leap year.
12730  * <footnote><para>For the purposes of this function,
12731  * leap year is every year divisible by 4 unless that year
12732  * is divisible by 100. If it is divisible by 100 it would
12733  * be a leap year only if that year is also divisible
12734  * by 400.</para></footnote>
12735  *
12736  * Returns: %TRUE if the year is a leap year
12737  */
12738
12739
12740 /**
12741  * g_date_new:
12742  *
12743  * Allocates a #GDate and initializes
12744  * it to a sane state. The new date will
12745  * be cleared (as if you'd called g_date_clear()) but invalid (it won't
12746  * represent an existing day). Free the return value with g_date_free().
12747  *
12748  * Returns: a newly-allocated #GDate
12749  */
12750
12751
12752 /**
12753  * g_date_new_dmy:
12754  * @day: day of the month
12755  * @month: month of the year
12756  * @year: year
12757  *
12758  * Like g_date_new(), but also sets the value of the date. Assuming the
12759  * day-month-year triplet you pass in represents an existing day, the
12760  * returned date will be valid.
12761  *
12762  * Returns: a newly-allocated #GDate initialized with @day, @month, and @year
12763  */
12764
12765
12766 /**
12767  * g_date_new_julian:
12768  * @julian_day: days since January 1, Year 1
12769  *
12770  * Like g_date_new(), but also sets the value of the date. Assuming the
12771  * Julian day number you pass in is valid (greater than 0, less than an
12772  * unreasonably large number), the returned date will be valid.
12773  *
12774  * Returns: a newly-allocated #GDate initialized with @julian_day
12775  */
12776
12777
12778 /**
12779  * g_date_order:
12780  * @date1: the first date
12781  * @date2: the second date
12782  *
12783  * Checks if @date1 is less than or equal to @date2,
12784  * and swap the values if this is not the case.
12785  */
12786
12787
12788 /**
12789  * g_date_set_day:
12790  * @date: a #GDate
12791  * @day: day to set
12792  *
12793  * Sets the day of the month for a #GDate. If the resulting
12794  * day-month-year triplet is invalid, the date will be invalid.
12795  */
12796
12797
12798 /**
12799  * g_date_set_dmy:
12800  * @date: a #GDate
12801  * @day: day
12802  * @month: month
12803  * @y: year
12804  *
12805  * Sets the value of a #GDate from a day, month, and year.
12806  * The day-month-year triplet must be valid; if you aren't
12807  * sure it is, call g_date_valid_dmy() to check before you
12808  * set it.
12809  */
12810
12811
12812 /**
12813  * g_date_set_julian:
12814  * @date: a #GDate
12815  * @julian_date: Julian day number (days since January 1, Year 1)
12816  *
12817  * Sets the value of a #GDate from a Julian day number.
12818  */
12819
12820
12821 /**
12822  * g_date_set_month:
12823  * @date: a #GDate
12824  * @month: month to set
12825  *
12826  * Sets the month of the year for a #GDate.  If the resulting
12827  * day-month-year triplet is invalid, the date will be invalid.
12828  */
12829
12830
12831 /**
12832  * g_date_set_parse:
12833  * @date: a #GDate to fill in
12834  * @str: string to parse
12835  *
12836  * Parses a user-inputted string @str, and try to figure out what date it
12837  * represents, taking the <link linkend="setlocale">current locale</link>
12838  * into account. If the string is successfully parsed, the date will be
12839  * valid after the call. Otherwise, it will be invalid. You should check
12840  * using g_date_valid() to see whether the parsing succeeded.
12841  *
12842  * This function is not appropriate for file formats and the like; it
12843  * isn't very precise, and its exact behavior varies with the locale.
12844  * It's intended to be a heuristic routine that guesses what the user
12845  * means by a given string (and it does work pretty well in that
12846  * capacity).
12847  */
12848
12849
12850 /**
12851  * g_date_set_time:
12852  * @date: a #GDate.
12853  * @time_: #GTime value to set.
12854  *
12855  * Sets the value of a date from a #GTime value.
12856  * The time to date conversion is done using the user's current timezone.
12857  *
12858  * Deprecated: 2.10: Use g_date_set_time_t() instead.
12859  */
12860
12861
12862 /**
12863  * g_date_set_time_t:
12864  * @date: a #GDate
12865  * @timet: <type>time_t</type> value to set
12866  *
12867  * Sets the value of a date to the date corresponding to a time
12868  * specified as a time_t. The time to date conversion is done using
12869  * the user's current timezone.
12870  *
12871  * To set the value of a date to the current day, you could write:
12872  * |[
12873  *  g_date_set_time_t (date, time (NULL));
12874  * ]|
12875  *
12876  * Since: 2.10
12877  */
12878
12879
12880 /**
12881  * g_date_set_time_val:
12882  * @date: a #GDate
12883  * @timeval: #GTimeVal value to set
12884  *
12885  * Sets the value of a date from a #GTimeVal value.  Note that the
12886  * @tv_usec member is ignored, because #GDate can't make use of the
12887  * additional precision.
12888  *
12889  * The time to date conversion is done using the user's current timezone.
12890  *
12891  * Since: 2.10
12892  */
12893
12894
12895 /**
12896  * g_date_set_year:
12897  * @date: a #GDate
12898  * @year: year to set
12899  *
12900  * Sets the year for a #GDate. If the resulting day-month-year
12901  * triplet is invalid, the date will be invalid.
12902  */
12903
12904
12905 /**
12906  * g_date_strftime:
12907  * @s: destination buffer
12908  * @slen: buffer size
12909  * @format: format string
12910  * @date: valid #GDate
12911  *
12912  * Generates a printed representation of the date, in a
12913  * <link linkend="setlocale">locale</link>-specific way.
12914  * Works just like the platform's C library strftime() function,
12915  * but only accepts date-related formats; time-related formats
12916  * give undefined results. Date must be valid. Unlike strftime()
12917  * (which uses the locale encoding), works on a UTF-8 format
12918  * string and stores a UTF-8 result.
12919  *
12920  * This function does not provide any conversion specifiers in
12921  * addition to those implemented by the platform's C library.
12922  * For example, don't expect that using g_date_strftime() would
12923  * make the \%F provided by the C99 strftime() work on Windows
12924  * where the C library only complies to C89.
12925  *
12926  * Returns: number of characters written to the buffer, or 0 the buffer was too small
12927  */
12928
12929
12930 /**
12931  * g_date_subtract_days:
12932  * @date: a #GDate to decrement
12933  * @n_days: number of days to move
12934  *
12935  * Moves a date some number of days into the past.
12936  * To move by weeks, just move by weeks*7 days.
12937  * The date must be valid.
12938  */
12939
12940
12941 /**
12942  * g_date_subtract_months:
12943  * @date: a #GDate to decrement
12944  * @n_months: number of months to move
12945  *
12946  * Moves a date some number of months into the past.
12947  * If the current day of the month doesn't exist in
12948  * the destination month, the day of the month
12949  * may change. The date must be valid.
12950  */
12951
12952
12953 /**
12954  * g_date_subtract_years:
12955  * @date: a #GDate to decrement
12956  * @n_years: number of years to move
12957  *
12958  * Moves a date some number of years into the past.
12959  * If the current day doesn't exist in the destination
12960  * year (i.e. it's February 29 and you move to a non-leap-year)
12961  * then the day is changed to February 29. The date
12962  * must be valid.
12963  */
12964
12965
12966 /**
12967  * g_date_time_add:
12968  * @datetime: a #GDateTime
12969  * @timespan: a #GTimeSpan
12970  *
12971  * Creates a copy of @datetime and adds the specified timespan to the copy.
12972  *
12973  * Returns: the newly created #GDateTime which should be freed with
12974  *   g_date_time_unref().
12975  * Since: 2.26
12976  */
12977
12978
12979 /**
12980  * g_date_time_add_days:
12981  * @datetime: a #GDateTime
12982  * @days: the number of days
12983  *
12984  * Creates a copy of @datetime and adds the specified number of days to the
12985  * copy. Add negative values to subtract days.
12986  *
12987  * Returns: the newly created #GDateTime which should be freed with
12988  *   g_date_time_unref().
12989  * Since: 2.26
12990  */
12991
12992
12993 /**
12994  * g_date_time_add_full:
12995  * @datetime: a #GDateTime
12996  * @years: the number of years to add
12997  * @months: the number of months to add
12998  * @days: the number of days to add
12999  * @hours: the number of hours to add
13000  * @minutes: the number of minutes to add
13001  * @seconds: the number of seconds to add
13002  *
13003  * Creates a new #GDateTime adding the specified values to the current date and
13004  * time in @datetime. Add negative values to subtract.
13005  *
13006  * Returns: the newly created #GDateTime that should be freed with
13007  *   g_date_time_unref().
13008  * Since: 2.26
13009  */
13010
13011
13012 /**
13013  * g_date_time_add_hours:
13014  * @datetime: a #GDateTime
13015  * @hours: the number of hours to add
13016  *
13017  * Creates a copy of @datetime and adds the specified number of hours.
13018  * Add negative values to subtract hours.
13019  *
13020  * Returns: the newly created #GDateTime which should be freed with
13021  *   g_date_time_unref().
13022  * Since: 2.26
13023  */
13024
13025
13026 /**
13027  * g_date_time_add_minutes:
13028  * @datetime: a #GDateTime
13029  * @minutes: the number of minutes to add
13030  *
13031  * Creates a copy of @datetime adding the specified number of minutes.
13032  * Add negative values to subtract minutes.
13033  *
13034  * Returns: the newly created #GDateTime which should be freed with
13035  *   g_date_time_unref().
13036  * Since: 2.26
13037  */
13038
13039
13040 /**
13041  * g_date_time_add_months:
13042  * @datetime: a #GDateTime
13043  * @months: the number of months
13044  *
13045  * Creates a copy of @datetime and adds the specified number of months to the
13046  * copy. Add negative values to subtract months.
13047  *
13048  * Returns: the newly created #GDateTime which should be freed with
13049  *   g_date_time_unref().
13050  * Since: 2.26
13051  */
13052
13053
13054 /**
13055  * g_date_time_add_seconds:
13056  * @datetime: a #GDateTime
13057  * @seconds: the number of seconds to add
13058  *
13059  * Creates a copy of @datetime and adds the specified number of seconds.
13060  * Add negative values to subtract seconds.
13061  *
13062  * Returns: the newly created #GDateTime which should be freed with
13063  *   g_date_time_unref().
13064  * Since: 2.26
13065  */
13066
13067
13068 /**
13069  * g_date_time_add_weeks:
13070  * @datetime: a #GDateTime
13071  * @weeks: the number of weeks
13072  *
13073  * Creates a copy of @datetime and adds the specified number of weeks to the
13074  * copy. Add negative values to subtract weeks.
13075  *
13076  * Returns: the newly created #GDateTime which should be freed with
13077  *   g_date_time_unref().
13078  * Since: 2.26
13079  */
13080
13081
13082 /**
13083  * g_date_time_add_years:
13084  * @datetime: a #GDateTime
13085  * @years: the number of years
13086  *
13087  * Creates a copy of @datetime and adds the specified number of years to the
13088  * copy. Add negative values to subtract years.
13089  *
13090  * Returns: the newly created #GDateTime which should be freed with
13091  *   g_date_time_unref().
13092  * Since: 2.26
13093  */
13094
13095
13096 /**
13097  * g_date_time_compare:
13098  * @dt1: first #GDateTime to compare
13099  * @dt2: second #GDateTime to compare
13100  *
13101  * A comparison function for #GDateTimes that is suitable
13102  * as a #GCompareFunc. Both #GDateTimes must be non-%NULL.
13103  *
13104  * Returns: -1, 0 or 1 if @dt1 is less than, equal to or greater
13105  *   than @dt2.
13106  * Since: 2.26
13107  */
13108
13109
13110 /**
13111  * g_date_time_difference:
13112  * @end: a #GDateTime
13113  * @begin: a #GDateTime
13114  *
13115  * Calculates the difference in time between @end and @begin.  The
13116  * #GTimeSpan that is returned is effectively @end - @begin (ie:
13117  * positive if the first parameter is larger).
13118  *
13119  * Returns: the difference between the two #GDateTime, as a time
13120  *   span expressed in microseconds.
13121  * Since: 2.26
13122  */
13123
13124
13125 /**
13126  * g_date_time_equal:
13127  * @dt1: a #GDateTime
13128  * @dt2: a #GDateTime
13129  *
13130  * Checks to see if @dt1 and @dt2 are equal.
13131  *
13132  * Equal here means that they represent the same moment after converting
13133  * them to the same time zone.
13134  *
13135  * Returns: %TRUE if @dt1 and @dt2 are equal
13136  * Since: 2.26
13137  */
13138
13139
13140 /**
13141  * g_date_time_format:
13142  * @datetime: A #GDateTime
13143  * @format: a valid UTF-8 string, containing the format for the
13144  *          #GDateTime
13145  *
13146  * Creates a newly allocated string representing the requested @format.
13147  *
13148  * The format strings understood by this function are a subset of the
13149  * strftime() format language as specified by C99.  The \%D, \%U and \%W
13150  * conversions are not supported, nor is the 'E' modifier.  The GNU
13151  * extensions \%k, \%l, \%s and \%P are supported, however, as are the
13152  * '0', '_' and '-' modifiers.
13153  *
13154  * In contrast to strftime(), this function always produces a UTF-8
13155  * string, regardless of the current locale.  Note that the rendering of
13156  * many formats is locale-dependent and may not match the strftime()
13157  * output exactly.
13158  *
13159  * The following format specifiers are supported:
13160  *
13161  * <variablelist>
13162  *  <varlistentry><term>
13163  *    <literal>\%a</literal>:
13164  *   </term><listitem><simpara>
13165  *    the abbreviated weekday name according to the current locale
13166  *  </simpara></listitem></varlistentry>
13167  *  <varlistentry><term>
13168  *    <literal>\%A</literal>:
13169  *   </term><listitem><simpara>
13170  *    the full weekday name according to the current locale
13171  *  </simpara></listitem></varlistentry>
13172  *  <varlistentry><term>
13173  *    <literal>\%b</literal>:
13174  *   </term><listitem><simpara>
13175  *    the abbreviated month name according to the current locale
13176  *  </simpara></listitem></varlistentry>
13177  *  <varlistentry><term>
13178  *    <literal>\%B</literal>:
13179  *   </term><listitem><simpara>
13180  *    the full month name according to the current locale
13181  *  </simpara></listitem></varlistentry>
13182  *  <varlistentry><term>
13183  *    <literal>\%c</literal>:
13184  *   </term><listitem><simpara>
13185  *    the  preferred  date  and  time  representation  for the current locale
13186  *  </simpara></listitem></varlistentry>
13187  *  <varlistentry><term>
13188  *    <literal>\%C</literal>:
13189  *   </term><listitem><simpara>
13190  *    The century number (year/100) as a 2-digit integer (00-99)
13191  *  </simpara></listitem></varlistentry>
13192  *  <varlistentry><term>
13193  *    <literal>\%d</literal>:
13194  *   </term><listitem><simpara>
13195  *    the day of the month as a decimal number (range 01 to 31)
13196  *  </simpara></listitem></varlistentry>
13197  *  <varlistentry><term>
13198  *    <literal>\%e</literal>:
13199  *   </term><listitem><simpara>
13200  *    the day of the month as a decimal number (range  1 to 31)
13201  *  </simpara></listitem></varlistentry>
13202  *  <varlistentry><term>
13203  *    <literal>\%F</literal>:
13204  *   </term><listitem><simpara>
13205  *    equivalent to <literal>\%Y-\%m-\%d</literal> (the ISO 8601 date
13206  *    format)
13207  *  </simpara></listitem></varlistentry>
13208  *  <varlistentry><term>
13209  *    <literal>\%g</literal>:
13210  *   </term><listitem><simpara>
13211  *    the last two digits of the ISO 8601 week-based year as a decimal
13212  *    number (00-99).  This works well with \%V and \%u.
13213  *  </simpara></listitem></varlistentry>
13214  *  <varlistentry><term>
13215  *    <literal>\%G</literal>:
13216  *   </term><listitem><simpara>
13217  *    the ISO 8601 week-based year as a decimal number.  This works well
13218  *    with \%V and \%u.
13219  *  </simpara></listitem></varlistentry>
13220  *  <varlistentry><term>
13221  *    <literal>\%h</literal>:
13222  *   </term><listitem><simpara>
13223  *    equivalent to <literal>\%b</literal>
13224  *  </simpara></listitem></varlistentry>
13225  *  <varlistentry><term>
13226  *    <literal>\%H</literal>:
13227  *   </term><listitem><simpara>
13228  *    the hour as a decimal number using a 24-hour clock (range 00 to
13229  *    23)
13230  *  </simpara></listitem></varlistentry>
13231  *  <varlistentry><term>
13232  *    <literal>\%I</literal>:
13233  *   </term><listitem><simpara>
13234  *    the hour as a decimal number using a 12-hour clock (range 01 to
13235  *    12)
13236  *  </simpara></listitem></varlistentry>
13237  *  <varlistentry><term>
13238  *    <literal>\%j</literal>:
13239  *   </term><listitem><simpara>
13240  *    the day of the year as a decimal number (range 001 to 366)
13241  *  </simpara></listitem></varlistentry>
13242  *  <varlistentry><term>
13243  *    <literal>\%k</literal>:
13244  *   </term><listitem><simpara>
13245  *    the hour (24-hour clock) as a decimal number (range 0 to 23);
13246  *    single digits are preceded by a blank
13247  *  </simpara></listitem></varlistentry>
13248  *  <varlistentry><term>
13249  *    <literal>\%l</literal>:
13250  *   </term><listitem><simpara>
13251  *    the hour (12-hour clock) as a decimal number (range 1 to 12);
13252  *    single digits are preceded by a blank
13253  *  </simpara></listitem></varlistentry>
13254  *  <varlistentry><term>
13255  *    <literal>\%m</literal>:
13256  *   </term><listitem><simpara>
13257  *    the month as a decimal number (range 01 to 12)
13258  *  </simpara></listitem></varlistentry>
13259  *  <varlistentry><term>
13260  *    <literal>\%M</literal>:
13261  *   </term><listitem><simpara>
13262  *    the minute as a decimal number (range 00 to 59)
13263  *  </simpara></listitem></varlistentry>
13264  *  <varlistentry><term>
13265  *    <literal>\%p</literal>:
13266  *   </term><listitem><simpara>
13267  *    either "AM" or "PM" according to the given time value, or the
13268  *    corresponding  strings for the current locale.  Noon is treated as
13269  *    "PM" and midnight as "AM".
13270  *  </simpara></listitem></varlistentry>
13271  *  <varlistentry><term>
13272  *    <literal>\%P</literal>:
13273  *   </term><listitem><simpara>
13274  *    like \%p but lowercase: "am" or "pm" or a corresponding string for
13275  *    the current locale
13276  *  </simpara></listitem></varlistentry>
13277  *  <varlistentry><term>
13278  *    <literal>\%r</literal>:
13279  *   </term><listitem><simpara>
13280  *    the time in a.m. or p.m. notation
13281  *  </simpara></listitem></varlistentry>
13282  *  <varlistentry><term>
13283  *    <literal>\%R</literal>:
13284  *   </term><listitem><simpara>
13285  *    the time in 24-hour notation (<literal>\%H:\%M</literal>)
13286  *  </simpara></listitem></varlistentry>
13287  *  <varlistentry><term>
13288  *    <literal>\%s</literal>:
13289  *   </term><listitem><simpara>
13290  *    the number of seconds since the Epoch, that is, since 1970-01-01
13291  *    00:00:00 UTC
13292  *  </simpara></listitem></varlistentry>
13293  *  <varlistentry><term>
13294  *    <literal>\%S</literal>:
13295  *   </term><listitem><simpara>
13296  *    the second as a decimal number (range 00 to 60)
13297  *  </simpara></listitem></varlistentry>
13298  *  <varlistentry><term>
13299  *    <literal>\%t</literal>:
13300  *   </term><listitem><simpara>
13301  *    a tab character
13302  *  </simpara></listitem></varlistentry>
13303  *  <varlistentry><term>
13304  *    <literal>\%T</literal>:
13305  *   </term><listitem><simpara>
13306  *    the time in 24-hour notation with seconds (<literal>\%H:\%M:\%S</literal>)
13307  *  </simpara></listitem></varlistentry>
13308  *  <varlistentry><term>
13309  *    <literal>\%u</literal>:
13310  *   </term><listitem><simpara>
13311  *    the ISO 8601 standard day of the week as a decimal, range 1 to 7,
13312  *    Monday being 1.  This works well with \%G and \%V.
13313  *  </simpara></listitem></varlistentry>
13314  *  <varlistentry><term>
13315  *    <literal>\%V</literal>:
13316  *   </term><listitem><simpara>
13317  *    the ISO 8601 standard week number of the current year as a decimal
13318  *    number, range 01 to 53, where week 1 is the first week that has at
13319  *    least 4 days in the new year. See g_date_time_get_week_of_year().
13320  *    This works well with \%G and \%u.
13321  *  </simpara></listitem></varlistentry>
13322  *  <varlistentry><term>
13323  *    <literal>\%w</literal>:
13324  *   </term><listitem><simpara>
13325  *    the day of the week as a decimal, range 0 to 6, Sunday being 0.
13326  *    This is not the ISO 8601 standard format -- use \%u instead.
13327  *  </simpara></listitem></varlistentry>
13328  *  <varlistentry><term>
13329  *    <literal>\%x</literal>:
13330  *   </term><listitem><simpara>
13331  *    the preferred date representation for the current locale without
13332  *    the time
13333  *  </simpara></listitem></varlistentry>
13334  *  <varlistentry><term>
13335  *    <literal>\%X</literal>:
13336  *   </term><listitem><simpara>
13337  *    the preferred time representation for the current locale without
13338  *    the date
13339  *  </simpara></listitem></varlistentry>
13340  *  <varlistentry><term>
13341  *    <literal>\%y</literal>:
13342  *   </term><listitem><simpara>
13343  *    the year as a decimal number without the century
13344  *  </simpara></listitem></varlistentry>
13345  *  <varlistentry><term>
13346  *    <literal>\%Y</literal>:
13347  *   </term><listitem><simpara>
13348  *    the year as a decimal number including the century
13349  *  </simpara></listitem></varlistentry>
13350  *  <varlistentry><term>
13351  *    <literal>\%z</literal>:
13352  *   </term><listitem><simpara>
13353  *    the time zone as an offset from UTC (+hhmm)
13354  *  </simpara></listitem></varlistentry>
13355  *  <varlistentry><term>
13356  *    <literal>\%:z</literal>:
13357  *   </term><listitem><simpara>
13358  *    the time zone as an offset from UTC (+hh:mm). This is a gnulib strftime extension. Since: 2.38
13359  *  </simpara></listitem></varlistentry>
13360  *  <varlistentry><term>
13361  *    <literal>\%::z</literal>:
13362  *   </term><listitem><simpara>
13363  *    the time zone as an offset from UTC (+hh:mm:ss). This is a gnulib strftime extension. Since: 2.38
13364  *  </simpara></listitem></varlistentry>
13365  *  <varlistentry><term>
13366  *    <literal>\%:::z</literal>:
13367  *   </term><listitem><simpara>
13368  *    the time zone as an offset from UTC, with : to necessary precision
13369  *    (e.g., -04, +05:30). This is a gnulib strftime extension. Since: 2.38
13370  *  </simpara></listitem></varlistentry>
13371  *  <varlistentry><term>
13372  *    <literal>\%Z</literal>:
13373  *   </term><listitem><simpara>
13374  *    the time zone or name or abbreviation
13375  *  </simpara></listitem></varlistentry>
13376  *  <varlistentry><term>
13377  *    <literal>\%\%</literal>:
13378  *   </term><listitem><simpara>
13379  *    a literal <literal>\%</literal> character
13380  *  </simpara></listitem></varlistentry>
13381  * </variablelist>
13382  *
13383  * Some conversion specifications can be modified by preceding the
13384  * conversion specifier by one or more modifier characters. The
13385  * following modifiers are supported for many of the numeric
13386  * conversions:
13387  * <variablelist>
13388  *   <varlistentry>
13389  *     <term>O</term>
13390  *     <listitem>
13391  *       Use alternative numeric symbols, if the current locale
13392  *       supports those.
13393  *     </listitem>
13394  *   </varlistentry>
13395  *   <varlistentry>
13396  *     <term>_</term>
13397  *     <listitem>
13398  *       Pad a numeric result with spaces.
13399  *       This overrides the default padding for the specifier.
13400  *     </listitem>
13401  *   </varlistentry>
13402  *   <varlistentry>
13403  *     <term>-</term>
13404  *     <listitem>
13405  *       Do not pad a numeric result.
13406  *       This overrides the default padding for the specifier.
13407  *     </listitem>
13408  *   </varlistentry>
13409  *   <varlistentry>
13410  *     <term>0</term>
13411  *     <listitem>
13412  *       Pad a numeric result with zeros.
13413  *       This overrides the default padding for the specifier.
13414  *     </listitem>
13415  *   </varlistentry>
13416  * </variablelist>
13417  *
13418  * Returns: a newly allocated string formatted to the requested format
13419  *          or %NULL in the case that there was an error.  The string
13420  *          should be freed with g_free().
13421  * Since: 2.26
13422  */
13423
13424
13425 /**
13426  * g_date_time_get_day_of_month:
13427  * @datetime: a #GDateTime
13428  *
13429  * Retrieves the day of the month represented by @datetime in the gregorian
13430  * calendar.
13431  *
13432  * Returns: the day of the month
13433  * Since: 2.26
13434  */
13435
13436
13437 /**
13438  * g_date_time_get_day_of_week:
13439  * @datetime: a #GDateTime
13440  *
13441  * Retrieves the ISO 8601 day of the week on which @datetime falls (1 is
13442  * Monday, 2 is Tuesday... 7 is Sunday).
13443  *
13444  * Returns: the day of the week
13445  * Since: 2.26
13446  */
13447
13448
13449 /**
13450  * g_date_time_get_day_of_year:
13451  * @datetime: a #GDateTime
13452  *
13453  * Retrieves the day of the year represented by @datetime in the Gregorian
13454  * calendar.
13455  *
13456  * Returns: the day of the year
13457  * Since: 2.26
13458  */
13459
13460
13461 /**
13462  * g_date_time_get_hour:
13463  * @datetime: a #GDateTime
13464  *
13465  * Retrieves the hour of the day represented by @datetime
13466  *
13467  * Returns: the hour of the day
13468  * Since: 2.26
13469  */
13470
13471
13472 /**
13473  * g_date_time_get_microsecond:
13474  * @datetime: a #GDateTime
13475  *
13476  * Retrieves the microsecond of the date represented by @datetime
13477  *
13478  * Returns: the microsecond of the second
13479  * Since: 2.26
13480  */
13481
13482
13483 /**
13484  * g_date_time_get_minute:
13485  * @datetime: a #GDateTime
13486  *
13487  * Retrieves the minute of the hour represented by @datetime
13488  *
13489  * Returns: the minute of the hour
13490  * Since: 2.26
13491  */
13492
13493
13494 /**
13495  * g_date_time_get_month:
13496  * @datetime: a #GDateTime
13497  *
13498  * Retrieves the month of the year represented by @datetime in the Gregorian
13499  * calendar.
13500  *
13501  * Returns: the month represented by @datetime
13502  * Since: 2.26
13503  */
13504
13505
13506 /**
13507  * g_date_time_get_second:
13508  * @datetime: a #GDateTime
13509  *
13510  * Retrieves the second of the minute represented by @datetime
13511  *
13512  * Returns: the second represented by @datetime
13513  * Since: 2.26
13514  */
13515
13516
13517 /**
13518  * g_date_time_get_seconds:
13519  * @datetime: a #GDateTime
13520  *
13521  * Retrieves the number of seconds since the start of the last minute,
13522  * including the fractional part.
13523  *
13524  * Returns: the number of seconds
13525  * Since: 2.26
13526  */
13527
13528
13529 /**
13530  * g_date_time_get_timezone_abbreviation:
13531  * @datetime: a #GDateTime
13532  *
13533  * Determines the time zone abbreviation to be used at the time and in
13534  * the time zone of @datetime.
13535  *
13536  * For example, in Toronto this is currently "EST" during the winter
13537  * months and "EDT" during the summer months when daylight savings
13538  * time is in effect.
13539  *
13540  * Returns: (transfer none): the time zone abbreviation. The returned
13541  *          string is owned by the #GDateTime and it should not be
13542  *          modified or freed
13543  * Since: 2.26
13544  */
13545
13546
13547 /**
13548  * g_date_time_get_utc_offset:
13549  * @datetime: a #GDateTime
13550  *
13551  * Determines the offset to UTC in effect at the time and in the time
13552  * zone of @datetime.
13553  *
13554  * The offset is the number of microseconds that you add to UTC time to
13555  * arrive at local time for the time zone (ie: negative numbers for time
13556  * zones west of GMT, positive numbers for east).
13557  *
13558  * If @datetime represents UTC time, then the offset is always zero.
13559  *
13560  * Returns: the number of microseconds that should be added to UTC to
13561  *          get the local time
13562  * Since: 2.26
13563  */
13564
13565
13566 /**
13567  * g_date_time_get_week_numbering_year:
13568  * @datetime: a #GDateTime
13569  *
13570  * Returns the ISO 8601 week-numbering year in which the week containing
13571  * @datetime falls.
13572  *
13573  * This function, taken together with g_date_time_get_week_of_year() and
13574  * g_date_time_get_day_of_week() can be used to determine the full ISO
13575  * week date on which @datetime falls.
13576  *
13577  * This is usually equal to the normal Gregorian year (as returned by
13578  * g_date_time_get_year()), except as detailed below:
13579  *
13580  * For Thursday, the week-numbering year is always equal to the usual
13581  * calendar year.  For other days, the number is such that every day
13582  * within a complete week (Monday to Sunday) is contained within the
13583  * same week-numbering year.
13584  *
13585  * For Monday, Tuesday and Wednesday occurring near the end of the year,
13586  * this may mean that the week-numbering year is one greater than the
13587  * calendar year (so that these days have the same week-numbering year
13588  * as the Thursday occurring early in the next year).
13589  *
13590  * For Friday, Saturaday and Sunday occurring near the start of the year,
13591  * this may mean that the week-numbering year is one less than the
13592  * calendar year (so that these days have the same week-numbering year
13593  * as the Thursday occurring late in the previous year).
13594  *
13595  * An equivalent description is that the week-numbering year is equal to
13596  * the calendar year containing the majority of the days in the current
13597  * week (Monday to Sunday).
13598  *
13599  * Note that January 1 0001 in the proleptic Gregorian calendar is a
13600  * Monday, so this function never returns 0.
13601  *
13602  * Returns: the ISO 8601 week-numbering year for @datetime
13603  * Since: 2.26
13604  */
13605
13606
13607 /**
13608  * g_date_time_get_week_of_year:
13609  * @datetime: a #GDateTime
13610  *
13611  * Returns the ISO 8601 week number for the week containing @datetime.
13612  * The ISO 8601 week number is the same for every day of the week (from
13613  * Moday through Sunday).  That can produce some unusual results
13614  * (described below).
13615  *
13616  * The first week of the year is week 1.  This is the week that contains
13617  * the first Thursday of the year.  Equivalently, this is the first week
13618  * that has more than 4 of its days falling within the calendar year.
13619  *
13620  * The value 0 is never returned by this function.  Days contained
13621  * within a year but occurring before the first ISO 8601 week of that
13622  * year are considered as being contained in the last week of the
13623  * previous year.  Similarly, the final days of a calendar year may be
13624  * considered as being part of the first ISO 8601 week of the next year
13625  * if 4 or more days of that week are contained within the new year.
13626  *
13627  * Returns: the ISO 8601 week number for @datetime.
13628  * Since: 2.26
13629  */
13630
13631
13632 /**
13633  * g_date_time_get_year:
13634  * @datetime: A #GDateTime
13635  *
13636  * Retrieves the year represented by @datetime in the Gregorian calendar.
13637  *
13638  * Returns: the year represented by @datetime
13639  * Since: 2.26
13640  */
13641
13642
13643 /**
13644  * g_date_time_get_ymd:
13645  * @datetime: a #GDateTime.
13646  * @year: (out) (allow-none): the return location for the gregorian year, or %NULL.
13647  * @month: (out) (allow-none): the return location for the month of the year, or %NULL.
13648  * @day: (out) (allow-none): the return location for the day of the month, or %NULL.
13649  *
13650  * Retrieves the Gregorian day, month, and year of a given #GDateTime.
13651  *
13652  * Since: 2.26
13653  */
13654
13655
13656 /**
13657  * g_date_time_hash:
13658  * @datetime: a #GDateTime
13659  *
13660  * Hashes @datetime into a #guint, suitable for use within #GHashTable.
13661  *
13662  * Returns: a #guint containing the hash
13663  * Since: 2.26
13664  */
13665
13666
13667 /**
13668  * g_date_time_is_daylight_savings:
13669  * @datetime: a #GDateTime
13670  *
13671  * Determines if daylight savings time is in effect at the time and in
13672  * the time zone of @datetime.
13673  *
13674  * Returns: %TRUE if daylight savings time is in effect
13675  * Since: 2.26
13676  */
13677
13678
13679 /**
13680  * g_date_time_new:
13681  * @tz: a #GTimeZone
13682  * @year: the year component of the date
13683  * @month: the month component of the date
13684  * @day: the day component of the date
13685  * @hour: the hour component of the date
13686  * @minute: the minute component of the date
13687  * @seconds: the number of seconds past the minute
13688  *
13689  * Creates a new #GDateTime corresponding to the given date and time in
13690  * the time zone @tz.
13691  *
13692  * The @year must be between 1 and 9999, @month between 1 and 12 and @day
13693  * between 1 and 28, 29, 30 or 31 depending on the month and the year.
13694  *
13695  * @hour must be between 0 and 23 and @minute must be between 0 and 59.
13696  *
13697  * @seconds must be at least 0.0 and must be strictly less than 60.0.
13698  * It will be rounded down to the nearest microsecond.
13699  *
13700  * If the given time is not representable in the given time zone (for
13701  * example, 02:30 on March 14th 2010 in Toronto, due to daylight savings
13702  * time) then the time will be rounded up to the nearest existing time
13703  * (in this case, 03:00).  If this matters to you then you should verify
13704  * the return value for containing the same as the numbers you gave.
13705  *
13706  * In the case that the given time is ambiguous in the given time zone
13707  * (for example, 01:30 on November 7th 2010 in Toronto, due to daylight
13708  * savings time) then the time falling within standard (ie:
13709  * non-daylight) time is taken.
13710  *
13711  * It not considered a programmer error for the values to this function
13712  * to be out of range, but in the case that they are, the function will
13713  * return %NULL.
13714  *
13715  * You should release the return value by calling g_date_time_unref()
13716  * when you are done with it.
13717  *
13718  * Returns: a new #GDateTime, or %NULL
13719  * Since: 2.26
13720  */
13721
13722
13723 /**
13724  * g_date_time_new_from_timeval_local:
13725  * @tv: a #GTimeVal
13726  *
13727  * Creates a #GDateTime corresponding to the given #GTimeVal @tv in the
13728  * local time zone.
13729  *
13730  * The time contained in a #GTimeVal is always stored in the form of
13731  * seconds elapsed since 1970-01-01 00:00:00 UTC, regardless of the
13732  * local time offset.
13733  *
13734  * This call can fail (returning %NULL) if @tv represents a time outside
13735  * of the supported range of #GDateTime.
13736  *
13737  * You should release the return value by calling g_date_time_unref()
13738  * when you are done with it.
13739  *
13740  * Returns: a new #GDateTime, or %NULL
13741  * Since: 2.26
13742  */
13743
13744
13745 /**
13746  * g_date_time_new_from_timeval_utc:
13747  * @tv: a #GTimeVal
13748  *
13749  * Creates a #GDateTime corresponding to the given #GTimeVal @tv in UTC.
13750  *
13751  * The time contained in a #GTimeVal is always stored in the form of
13752  * seconds elapsed since 1970-01-01 00:00:00 UTC.
13753  *
13754  * This call can fail (returning %NULL) if @tv represents a time outside
13755  * of the supported range of #GDateTime.
13756  *
13757  * You should release the return value by calling g_date_time_unref()
13758  * when you are done with it.
13759  *
13760  * Returns: a new #GDateTime, or %NULL
13761  * Since: 2.26
13762  */
13763
13764
13765 /**
13766  * g_date_time_new_from_unix_local:
13767  * @t: the Unix time
13768  *
13769  * Creates a #GDateTime corresponding to the given Unix time @t in the
13770  * local time zone.
13771  *
13772  * Unix time is the number of seconds that have elapsed since 1970-01-01
13773  * 00:00:00 UTC, regardless of the local time offset.
13774  *
13775  * This call can fail (returning %NULL) if @t represents a time outside
13776  * of the supported range of #GDateTime.
13777  *
13778  * You should release the return value by calling g_date_time_unref()
13779  * when you are done with it.
13780  *
13781  * Returns: a new #GDateTime, or %NULL
13782  * Since: 2.26
13783  */
13784
13785
13786 /**
13787  * g_date_time_new_from_unix_utc:
13788  * @t: the Unix time
13789  *
13790  * Creates a #GDateTime corresponding to the given Unix time @t in UTC.
13791  *
13792  * Unix time is the number of seconds that have elapsed since 1970-01-01
13793  * 00:00:00 UTC.
13794  *
13795  * This call can fail (returning %NULL) if @t represents a time outside
13796  * of the supported range of #GDateTime.
13797  *
13798  * You should release the return value by calling g_date_time_unref()
13799  * when you are done with it.
13800  *
13801  * Returns: a new #GDateTime, or %NULL
13802  * Since: 2.26
13803  */
13804
13805
13806 /**
13807  * g_date_time_new_local:
13808  * @year: the year component of the date
13809  * @month: the month component of the date
13810  * @day: the day component of the date
13811  * @hour: the hour component of the date
13812  * @minute: the minute component of the date
13813  * @seconds: the number of seconds past the minute
13814  *
13815  * Creates a new #GDateTime corresponding to the given date and time in
13816  * the local time zone.
13817  *
13818  * This call is equivalent to calling g_date_time_new() with the time
13819  * zone returned by g_time_zone_new_local().
13820  *
13821  * Returns: a #GDateTime, or %NULL
13822  * Since: 2.26
13823  */
13824
13825
13826 /**
13827  * g_date_time_new_now:
13828  * @tz: a #GTimeZone
13829  *
13830  * Creates a #GDateTime corresponding to this exact instant in the given
13831  * time zone @tz.  The time is as accurate as the system allows, to a
13832  * maximum accuracy of 1 microsecond.
13833  *
13834  * This function will always succeed unless the system clock is set to
13835  * truly insane values (or unless GLib is still being used after the
13836  * year 9999).
13837  *
13838  * You should release the return value by calling g_date_time_unref()
13839  * when you are done with it.
13840  *
13841  * Returns: a new #GDateTime, or %NULL
13842  * Since: 2.26
13843  */
13844
13845
13846 /**
13847  * g_date_time_new_now_local:
13848  *
13849  * Creates a #GDateTime corresponding to this exact instant in the local
13850  * time zone.
13851  *
13852  * This is equivalent to calling g_date_time_new_now() with the time
13853  * zone returned by g_time_zone_new_local().
13854  *
13855  * Returns: a new #GDateTime, or %NULL
13856  * Since: 2.26
13857  */
13858
13859
13860 /**
13861  * g_date_time_new_now_utc:
13862  *
13863  * Creates a #GDateTime corresponding to this exact instant in UTC.
13864  *
13865  * This is equivalent to calling g_date_time_new_now() with the time
13866  * zone returned by g_time_zone_new_utc().
13867  *
13868  * Returns: a new #GDateTime, or %NULL
13869  * Since: 2.26
13870  */
13871
13872
13873 /**
13874  * g_date_time_new_utc:
13875  * @year: the year component of the date
13876  * @month: the month component of the date
13877  * @day: the day component of the date
13878  * @hour: the hour component of the date
13879  * @minute: the minute component of the date
13880  * @seconds: the number of seconds past the minute
13881  *
13882  * Creates a new #GDateTime corresponding to the given date and time in
13883  * UTC.
13884  *
13885  * This call is equivalent to calling g_date_time_new() with the time
13886  * zone returned by g_time_zone_new_utc().
13887  *
13888  * Returns: a #GDateTime, or %NULL
13889  * Since: 2.26
13890  */
13891
13892
13893 /**
13894  * g_date_time_ref:
13895  * @datetime: a #GDateTime
13896  *
13897  * Atomically increments the reference count of @datetime by one.
13898  *
13899  * Returns: the #GDateTime with the reference count increased
13900  * Since: 2.26
13901  */
13902
13903
13904 /**
13905  * g_date_time_to_local:
13906  * @datetime: a #GDateTime
13907  *
13908  * Creates a new #GDateTime corresponding to the same instant in time as
13909  * @datetime, but in the local time zone.
13910  *
13911  * This call is equivalent to calling g_date_time_to_timezone() with the
13912  * time zone returned by g_time_zone_new_local().
13913  *
13914  * Returns: the newly created #GDateTime
13915  * Since: 2.26
13916  */
13917
13918
13919 /**
13920  * g_date_time_to_timeval:
13921  * @datetime: a #GDateTime
13922  * @tv: a #GTimeVal to modify
13923  *
13924  * Stores the instant in time that @datetime represents into @tv.
13925  *
13926  * The time contained in a #GTimeVal is always stored in the form of
13927  * seconds elapsed since 1970-01-01 00:00:00 UTC, regardless of the time
13928  * zone associated with @datetime.
13929  *
13930  * On systems where 'long' is 32bit (ie: all 32bit systems and all
13931  * Windows systems), a #GTimeVal is incapable of storing the entire
13932  * range of values that #GDateTime is capable of expressing.  On those
13933  * systems, this function returns %FALSE to indicate that the time is
13934  * out of range.
13935  *
13936  * On systems where 'long' is 64bit, this function never fails.
13937  *
13938  * Returns: %TRUE if successful, else %FALSE
13939  * Since: 2.26
13940  */
13941
13942
13943 /**
13944  * g_date_time_to_timezone:
13945  * @datetime: a #GDateTime
13946  * @tz: the new #GTimeZone
13947  *
13948  * Create a new #GDateTime corresponding to the same instant in time as
13949  * @datetime, but in the time zone @tz.
13950  *
13951  * This call can fail in the case that the time goes out of bounds.  For
13952  * example, converting 0001-01-01 00:00:00 UTC to a time zone west of
13953  * Greenwich will fail (due to the year 0 being out of range).
13954  *
13955  * You should release the return value by calling g_date_time_unref()
13956  * when you are done with it.
13957  *
13958  * Returns: a new #GDateTime, or %NULL
13959  * Since: 2.26
13960  */
13961
13962
13963 /**
13964  * g_date_time_to_unix:
13965  * @datetime: a #GDateTime
13966  *
13967  * Gives the Unix time corresponding to @datetime, rounding down to the
13968  * nearest second.
13969  *
13970  * Unix time is the number of seconds that have elapsed since 1970-01-01
13971  * 00:00:00 UTC, regardless of the time zone associated with @datetime.
13972  *
13973  * Returns: the Unix time corresponding to @datetime
13974  * Since: 2.26
13975  */
13976
13977
13978 /**
13979  * g_date_time_to_utc:
13980  * @datetime: a #GDateTime
13981  *
13982  * Creates a new #GDateTime corresponding to the same instant in time as
13983  * @datetime, but in UTC.
13984  *
13985  * This call is equivalent to calling g_date_time_to_timezone() with the
13986  * time zone returned by g_time_zone_new_utc().
13987  *
13988  * Returns: the newly created #GDateTime
13989  * Since: 2.26
13990  */
13991
13992
13993 /**
13994  * g_date_time_unref:
13995  * @datetime: a #GDateTime
13996  *
13997  * Atomically decrements the reference count of @datetime by one.
13998  *
13999  * When the reference count reaches zero, the resources allocated by
14000  * @datetime are freed
14001  *
14002  * Since: 2.26
14003  */
14004
14005
14006 /**
14007  * g_date_to_struct_tm:
14008  * @date: a #GDate to set the <structname>struct tm</structname> from
14009  * @tm: <structname>struct tm</structname> to fill
14010  *
14011  * Fills in the date-related bits of a <structname>struct tm</structname>
14012  * using the @date value. Initializes the non-date parts with something
14013  * sane but meaningless.
14014  */
14015
14016
14017 /**
14018  * g_date_valid:
14019  * @date: a #GDate to check
14020  *
14021  * Returns %TRUE if the #GDate represents an existing day. The date must not
14022  * contain garbage; it should have been initialized with g_date_clear()
14023  * if it wasn't allocated by one of the g_date_new() variants.
14024  *
14025  * Returns: Whether the date is valid
14026  */
14027
14028
14029 /**
14030  * g_date_valid_day:
14031  * @day: day to check
14032  *
14033  * Returns %TRUE if the day of the month is valid (a day is valid if it's
14034  * between 1 and 31 inclusive).
14035  *
14036  * Returns: %TRUE if the day is valid
14037  */
14038
14039
14040 /**
14041  * g_date_valid_dmy:
14042  * @day: day
14043  * @month: month
14044  * @year: year
14045  *
14046  * Returns %TRUE if the day-month-year triplet forms a valid, existing day
14047  * in the range of days #GDate understands (Year 1 or later, no more than
14048  * a few thousand years in the future).
14049  *
14050  * Returns: %TRUE if the date is a valid one
14051  */
14052
14053
14054 /**
14055  * g_date_valid_julian:
14056  * @julian_date: Julian day to check
14057  *
14058  * Returns %TRUE if the Julian day is valid. Anything greater than zero
14059  * is basically a valid Julian, though there is a 32-bit limit.
14060  *
14061  * Returns: %TRUE if the Julian day is valid
14062  */
14063
14064
14065 /**
14066  * g_date_valid_month:
14067  * @month: month
14068  *
14069  * Returns %TRUE if the month value is valid. The 12 #GDateMonth
14070  * enumeration values are the only valid months.
14071  *
14072  * Returns: %TRUE if the month is valid
14073  */
14074
14075
14076 /**
14077  * g_date_valid_weekday:
14078  * @weekday: weekday
14079  *
14080  * Returns %TRUE if the weekday is valid. The seven #GDateWeekday enumeration
14081  * values are the only valid weekdays.
14082  *
14083  * Returns: %TRUE if the weekday is valid
14084  */
14085
14086
14087 /**
14088  * g_date_valid_year:
14089  * @year: year
14090  *
14091  * Returns %TRUE if the year is valid. Any year greater than 0 is valid,
14092  * though there is a 16-bit limit to what #GDate will understand.
14093  *
14094  * Returns: %TRUE if the year is valid
14095  */
14096
14097
14098 /**
14099  * g_dcgettext:
14100  * @domain: (allow-none): the translation domain to use, or %NULL to use
14101  *   the domain set with textdomain()
14102  * @msgid: message to translate
14103  * @category: a locale category
14104  *
14105  * This is a variant of g_dgettext() that allows specifying a locale
14106  * category instead of always using <envar>LC_MESSAGES</envar>. See g_dgettext() for
14107  * more information about how this functions differs from calling
14108  * dcgettext() directly.
14109  *
14110  * Returns: the translated string for the given locale category
14111  * Since: 2.26
14112  */
14113
14114
14115 /**
14116  * g_debug:
14117  * @...: format string, followed by parameters to insert
14118  *     into the format string (as with printf())
14119  *
14120  * A convenience function/macro to log a debug message.
14121  *
14122  * If g_log_default_handler() is used as the log handler function, a new-line
14123  * character will automatically be appended to @..., and need not be entered
14124  * manually.
14125  *
14126  * Since: 2.6
14127  */
14128
14129
14130 /**
14131  * g_dgettext:
14132  * @domain: (allow-none): the translation domain to use, or %NULL to use
14133  *   the domain set with textdomain()
14134  * @msgid: message to translate
14135  *
14136  * This function is a wrapper of dgettext() which does not translate
14137  * the message if the default domain as set with textdomain() has no
14138  * translations for the current locale.
14139  *
14140  * The advantage of using this function over dgettext() proper is that
14141  * libraries using this function (like GTK+) will not use translations
14142  * if the application using the library does not have translations for
14143  * the current locale.  This results in a consistent English-only
14144  * interface instead of one having partial translations.  For this
14145  * feature to work, the call to textdomain() and setlocale() should
14146  * precede any g_dgettext() invocations.  For GTK+, it means calling
14147  * textdomain() before gtk_init or its variants.
14148  *
14149  * This function disables translations if and only if upon its first
14150  * call all the following conditions hold:
14151  * <itemizedlist>
14152  * <listitem>@domain is not %NULL</listitem>
14153  * <listitem>textdomain() has been called to set a default text domain</listitem>
14154  * <listitem>there is no translations available for the default text domain
14155  *           and the current locale</listitem>
14156  * <listitem>current locale is not "C" or any English locales (those
14157  *           starting with "en_")</listitem>
14158  * </itemizedlist>
14159  *
14160  * Note that this behavior may not be desired for example if an application
14161  * has its untranslated messages in a language other than English.  In those
14162  * cases the application should call textdomain() after initializing GTK+.
14163  *
14164  * Applications should normally not use this function directly,
14165  * but use the _() macro for translations.
14166  *
14167  * Returns: The translated string
14168  * Since: 2.18
14169  */
14170
14171
14172 /**
14173  * g_dir_close:
14174  * @dir: a #GDir* created by g_dir_open()
14175  *
14176  * Closes the directory and deallocates all related resources.
14177  */
14178
14179
14180 /**
14181  * g_dir_make_tmp:
14182  * @tmpl: (type filename) (allow-none): Template for directory name,
14183  *     as in g_mkdtemp(), basename only, or %NULL for a default template
14184  * @error: return location for a #GError
14185  *
14186  * Creates a subdirectory in the preferred directory for temporary
14187  * files (as returned by g_get_tmp_dir()).
14188  *
14189  * @tmpl should be a string in the GLib file name encoding containing
14190  * a sequence of six 'X' characters, as the parameter to g_mkstemp().
14191  * However, unlike these functions, the template should only be a
14192  * basename, no directory components are allowed. If template is
14193  * %NULL, a default template is used.
14194  *
14195  * Note that in contrast to g_mkdtemp() (and mkdtemp()) @tmpl is not
14196  * modified, and might thus be a read-only literal string.
14197  *
14198  * Returns: (type filename): The actual name used. This string
14199  *     should be freed with g_free() when not needed any longer and is
14200  *     is in the GLib file name encoding. In case of errors, %NULL is
14201  *     returned and @error will be set.
14202  * Since: 2.30
14203  */
14204
14205
14206 /**
14207  * g_dir_open:
14208  * @path: the path to the directory you are interested in. On Unix
14209  *         in the on-disk encoding. On Windows in UTF-8
14210  * @flags: Currently must be set to 0. Reserved for future use.
14211  * @error: return location for a #GError, or %NULL.
14212  *         If non-%NULL, an error will be set if and only if
14213  *         g_dir_open() fails.
14214  *
14215  * Opens a directory for reading. The names of the files in the
14216  * directory can then be retrieved using g_dir_read_name().  Note
14217  * that the ordering is not defined.
14218  *
14219  * Returns: a newly allocated #GDir on success, %NULL on failure.
14220  *   If non-%NULL, you must free the result with g_dir_close()
14221  *   when you are finished with it.
14222  */
14223
14224
14225 /**
14226  * g_dir_read_name:
14227  * @dir: a #GDir* created by g_dir_open()
14228  *
14229  * Retrieves the name of another entry in the directory, or %NULL.
14230  * The order of entries returned from this function is not defined,
14231  * and may vary by file system or other operating-system dependent
14232  * factors.
14233  *
14234  * %NULL may also be returned in case of errors. On Unix, you can
14235  * check <literal>errno</literal> to find out if %NULL was returned
14236  * because of an error.
14237  *
14238  * On Unix, the '.' and '..' entries are omitted, and the returned
14239  * name is in the on-disk encoding.
14240  *
14241  * On Windows, as is true of all GLib functions which operate on
14242  * filenames, the returned name is in UTF-8.
14243  *
14244  * Returns: The entry's name or %NULL if there are no
14245  *   more entries. The return value is owned by GLib and
14246  *   must not be modified or freed.
14247  */
14248
14249
14250 /**
14251  * g_dir_rewind:
14252  * @dir: a #GDir* created by g_dir_open()
14253  *
14254  * Resets the given directory. The next call to g_dir_read_name()
14255  * will return the first entry again.
14256  */
14257
14258
14259 /**
14260  * g_direct_equal:
14261  * @v1: (allow-none): a key
14262  * @v2: (allow-none): a key to compare with @v1
14263  *
14264  * Compares two #gpointer arguments and returns %TRUE if they are equal.
14265  * It can be passed to g_hash_table_new() as the @key_equal_func
14266  * parameter, when using opaque pointers compared by pointer value as keys
14267  * in a #GHashTable.
14268  *
14269  * This equality function is also appropriate for keys that are integers stored
14270  * in pointers, such as <literal>GINT_TO_POINTER (n)</literal>.
14271  *
14272  * Returns: %TRUE if the two keys match.
14273  */
14274
14275
14276 /**
14277  * g_direct_hash:
14278  * @v: (allow-none): a #gpointer key
14279  *
14280  * Converts a gpointer to a hash value.
14281  * It can be passed to g_hash_table_new() as the @hash_func parameter,
14282  * when using opaque pointers compared by pointer value as keys in a
14283  * #GHashTable.
14284  *
14285  * This hash function is also appropriate for keys that are integers stored
14286  * in pointers, such as <literal>GINT_TO_POINTER (n)</literal>.
14287  *
14288  * Returns: a hash value corresponding to the key.
14289  */
14290
14291
14292 /**
14293  * g_dirname:
14294  * @file_name: the name of the file
14295  *
14296  * Gets the directory components of a file name.
14297  *
14298  * If the file name has no directory components "." is returned.
14299  * The returned string should be freed when no longer needed.
14300  *
14301  * Returns: the directory components of the file
14302  * Deprecated: use g_path_get_dirname() instead
14303  */
14304
14305
14306 /**
14307  * g_dngettext:
14308  * @domain: (allow-none): the translation domain to use, or %NULL to use
14309  *   the domain set with textdomain()
14310  * @msgid: message to translate
14311  * @msgid_plural: plural form of the message
14312  * @n: the quantity for which translation is needed
14313  *
14314  * This function is a wrapper of dngettext() which does not translate
14315  * the message if the default domain as set with textdomain() has no
14316  * translations for the current locale.
14317  *
14318  * See g_dgettext() for details of how this differs from dngettext()
14319  * proper.
14320  *
14321  * Returns: The translated string
14322  * Since: 2.18
14323  */
14324
14325
14326 /**
14327  * g_double_equal:
14328  * @v1: a pointer to a #gdouble key
14329  * @v2: a pointer to a #gdouble key to compare with @v1
14330  *
14331  * Compares the two #gdouble values being pointed to and returns
14332  * %TRUE if they are equal.
14333  * It can be passed to g_hash_table_new() as the @key_equal_func
14334  * parameter, when using non-%NULL pointers to doubles as keys in a
14335  * #GHashTable.
14336  *
14337  * Returns: %TRUE if the two keys match.
14338  * Since: 2.22
14339  */
14340
14341
14342 /**
14343  * g_double_hash:
14344  * @v: a pointer to a #gdouble key
14345  *
14346  * Converts a pointer to a #gdouble to a hash value.
14347  * It can be passed to g_hash_table_new() as the @hash_func parameter,
14348  * It can be passed to g_hash_table_new() as the @hash_func parameter,
14349  * when using non-%NULL pointers to doubles as keys in a #GHashTable.
14350  *
14351  * Returns: a hash value corresponding to the key.
14352  * Since: 2.22
14353  */
14354
14355
14356 /**
14357  * g_dpgettext:
14358  * @domain: (allow-none): the translation domain to use, or %NULL to use
14359  *   the domain set with textdomain()
14360  * @msgctxtid: a combined message context and message id, separated
14361  *   by a \004 character
14362  * @msgidoffset: the offset of the message id in @msgctxid
14363  *
14364  * This function is a variant of g_dgettext() which supports
14365  * a disambiguating message context. GNU gettext uses the
14366  * '\004' character to separate the message context and
14367  * message id in @msgctxtid.
14368  * If 0 is passed as @msgidoffset, this function will fall back to
14369  * trying to use the deprecated convention of using "|" as a separation
14370  * character.
14371  *
14372  * This uses g_dgettext() internally. See that functions for differences
14373  * with dgettext() proper.
14374  *
14375  * Applications should normally not use this function directly,
14376  * but use the C_() macro for translations with context.
14377  *
14378  * Returns: The translated string
14379  * Since: 2.16
14380  */
14381
14382
14383 /**
14384  * g_dpgettext2:
14385  * @domain: (allow-none): the translation domain to use, or %NULL to use
14386  *   the domain set with textdomain()
14387  * @context: the message context
14388  * @msgid: the message
14389  *
14390  * This function is a variant of g_dgettext() which supports
14391  * a disambiguating message context. GNU gettext uses the
14392  * '\004' character to separate the message context and
14393  * message id in @msgctxtid.
14394  *
14395  * This uses g_dgettext() internally. See that functions for differences
14396  * with dgettext() proper.
14397  *
14398  * This function differs from C_() in that it is not a macro and
14399  * thus you may use non-string-literals as context and msgid arguments.
14400  *
14401  * Returns: The translated string
14402  * Since: 2.18
14403  */
14404
14405
14406 /**
14407  * g_environ_getenv:
14408  * @envp: (allow-none) (array zero-terminated=1) (transfer none): an environment
14409  *     list (eg, as returned from g_get_environ()), or %NULL
14410  *     for an empty environment list
14411  * @variable: the environment variable to get, in the GLib file name
14412  *     encoding
14413  *
14414  * Returns the value of the environment variable @variable in the
14415  * provided list @envp.
14416  *
14417  * Returns: the value of the environment variable, or %NULL if
14418  *     the environment variable is not set in @envp. The returned
14419  *     string is owned by @envp, and will be freed if @variable is
14420  *     set or unset again.
14421  * Since: 2.32
14422  */
14423
14424
14425 /**
14426  * g_environ_setenv:
14427  * @envp: (allow-none) (array zero-terminated=1) (transfer full): an
14428  *     environment list that can be freed using g_strfreev() (e.g., as
14429  *     returned from g_get_environ()), or %NULL for an empty
14430  *     environment list
14431  * @variable: the environment variable to set, must not contain '='
14432  * @value: the value for to set the variable to
14433  * @overwrite: whether to change the variable if it already exists
14434  *
14435  * Sets the environment variable @variable in the provided list
14436  * @envp to @value.
14437  *
14438  * Returns: (array zero-terminated=1) (transfer full): the
14439  *     updated environment list. Free it using g_strfreev().
14440  * Since: 2.32
14441  */
14442
14443
14444 /**
14445  * g_environ_unsetenv:
14446  * @envp: (allow-none) (array zero-terminated=1) (transfer full): an environment
14447  *     list that can be freed using g_strfreev() (e.g., as returned from g_get_environ()),
14448  *     or %NULL for an empty environment list
14449  * @variable: the environment variable to remove, must not contain '='
14450  *
14451  * Removes the environment variable @variable from the provided
14452  * environment @envp.
14453  *
14454  * Returns: (array zero-terminated=1) (transfer full): the
14455  *     updated environment list. Free it using g_strfreev().
14456  * Since: 2.32
14457  */
14458
14459
14460 /**
14461  * g_error:
14462  * @...: format string, followed by parameters to insert
14463  *     into the format string (as with printf())
14464  *
14465  * A convenience function/macro to log an error message.
14466  *
14467  * Error messages are always fatal, resulting in a call to
14468  * abort() to terminate the application. This function will
14469  * result in a core dump; don't use it for errors you expect.
14470  * Using this function indicates a bug in your program, i.e.
14471  * an assertion failure.
14472  *
14473  * If g_log_default_handler() is used as the log handler function, a new-line
14474  * character will automatically be appended to @..., and need not be entered
14475  * manually.
14476  */
14477
14478
14479 /**
14480  * g_error_copy:
14481  * @error: a #GError
14482  *
14483  * Makes a copy of @error.
14484  *
14485  * Returns: a new #GError
14486  */
14487
14488
14489 /**
14490  * g_error_free:
14491  * @error: a #GError
14492  *
14493  * Frees a #GError and associated resources.
14494  */
14495
14496
14497 /**
14498  * g_error_matches:
14499  * @error: (allow-none): a #GError or %NULL
14500  * @domain: an error domain
14501  * @code: an error code
14502  *
14503  * Returns %TRUE if @error matches @domain and @code, %FALSE
14504  * otherwise. In particular, when @error is %NULL, %FALSE will
14505  * be returned.
14506  *
14507  * Returns: whether @error has @domain and @code
14508  */
14509
14510
14511 /**
14512  * g_error_new:
14513  * @domain: error domain
14514  * @code: error code
14515  * @format: printf()-style format for error message
14516  * @...: parameters for message format
14517  *
14518  * Creates a new #GError with the given @domain and @code,
14519  * and a message formatted with @format.
14520  *
14521  * Returns: a new #GError
14522  */
14523
14524
14525 /**
14526  * g_error_new_literal:
14527  * @domain: error domain
14528  * @code: error code
14529  * @message: error message
14530  *
14531  * Creates a new #GError; unlike g_error_new(), @message is
14532  * not a printf()-style format string. Use this function if
14533  * @message contains text you don't have control over,
14534  * that could include printf() escape sequences.
14535  *
14536  * Returns: a new #GError
14537  */
14538
14539
14540 /**
14541  * g_error_new_valist:
14542  * @domain: error domain
14543  * @code: error code
14544  * @format: printf()-style format for error message
14545  * @args: #va_list of parameters for the message format
14546  *
14547  * Creates a new #GError with the given @domain and @code,
14548  * and a message formatted with @format.
14549  *
14550  * Returns: a new #GError
14551  * Since: 2.22
14552  */
14553
14554
14555 /**
14556  * g_file_error_from_errno:
14557  * @err_no: an "errno" value
14558  *
14559  * Gets a #GFileError constant based on the passed-in @err_no.
14560  * For example, if you pass in <literal>EEXIST</literal> this function returns
14561  * #G_FILE_ERROR_EXIST. Unlike <literal>errno</literal> values, you can portably
14562  * assume that all #GFileError values will exist.
14563  *
14564  * Normally a #GFileError value goes into a #GError returned
14565  * from a function that manipulates files. So you would use
14566  * g_file_error_from_errno() when constructing a #GError.
14567  *
14568  * Returns: #GFileError corresponding to the given @errno
14569  */
14570
14571
14572 /**
14573  * g_file_get_contents:
14574  * @filename: (type filename): name of a file to read contents from, in the GLib file name encoding
14575  * @contents: (out) (array length=length) (element-type guint8): location to store an allocated string, use g_free() to free
14576  *     the returned string
14577  * @length: (allow-none): location to store length in bytes of the contents, or %NULL
14578  * @error: return location for a #GError, or %NULL
14579  *
14580  * Reads an entire file into allocated memory, with good error
14581  * checking.
14582  *
14583  * If the call was successful, it returns %TRUE and sets @contents to the file
14584  * contents and @length to the length of the file contents in bytes. The string
14585  * stored in @contents will be nul-terminated, so for text files you can pass
14586  * %NULL for the @length argument. If the call was not successful, it returns
14587  * %FALSE and sets @error. The error domain is #G_FILE_ERROR. Possible error
14588  * codes are those in the #GFileError enumeration. In the error case,
14589  * @contents is set to %NULL and @length is set to zero.
14590  *
14591  * Returns: %TRUE on success, %FALSE if an error occurred
14592  */
14593
14594
14595 /**
14596  * g_file_open_tmp:
14597  * @tmpl: (type filename) (allow-none): Template for file name, as in
14598  *     g_mkstemp(), basename only, or %NULL for a default template
14599  * @name_used: (out) (type filename): location to store actual name used,
14600  *     or %NULL
14601  * @error: return location for a #GError
14602  *
14603  * Opens a file for writing in the preferred directory for temporary
14604  * files (as returned by g_get_tmp_dir()).
14605  *
14606  * @tmpl should be a string in the GLib file name encoding containing
14607  * a sequence of six 'X' characters, as the parameter to g_mkstemp().
14608  * However, unlike these functions, the template should only be a
14609  * basename, no directory components are allowed. If template is
14610  * %NULL, a default template is used.
14611  *
14612  * Note that in contrast to g_mkstemp() (and mkstemp()) @tmpl is not
14613  * modified, and might thus be a read-only literal string.
14614  *
14615  * Upon success, and if @name_used is non-%NULL, the actual name used
14616  * is returned in @name_used. This string should be freed with g_free()
14617  * when not needed any longer. The returned name is in the GLib file
14618  * name encoding.
14619  *
14620  * Returns: A file handle (as from open()) to the file opened for
14621  *     reading and writing. The file is opened in binary mode on platforms
14622  *     where there is a difference. The file handle should be closed with
14623  *     close(). In case of errors, -1 is returned and @error will be set.
14624  */
14625
14626
14627 /**
14628  * g_file_read_link:
14629  * @filename: the symbolic link
14630  * @error: return location for a #GError
14631  *
14632  * Reads the contents of the symbolic link @filename like the POSIX
14633  * readlink() function.  The returned string is in the encoding used
14634  * for filenames. Use g_filename_to_utf8() to convert it to UTF-8.
14635  *
14636  * Returns: A newly-allocated string with the contents of the symbolic link,
14637  *          or %NULL if an error occurred.
14638  * Since: 2.4
14639  */
14640
14641
14642 /**
14643  * g_file_set_contents:
14644  * @filename: (type filename): name of a file to write @contents to, in the GLib file name
14645  *   encoding
14646  * @contents: (array length=length) (element-type guint8): string to write to the file
14647  * @length: length of @contents, or -1 if @contents is a nul-terminated string
14648  * @error: return location for a #GError, or %NULL
14649  *
14650  * Writes all of @contents to a file named @filename, with good error checking.
14651  * If a file called @filename already exists it will be overwritten.
14652  *
14653  * This write is atomic in the sense that it is first written to a temporary
14654  * file which is then renamed to the final name. Notes:
14655  * <itemizedlist>
14656  * <listitem>
14657  *    On Unix, if @filename already exists hard links to @filename will break.
14658  *    Also since the file is recreated, existing permissions, access control
14659  *    lists, metadata etc. may be lost. If @filename is a symbolic link,
14660  *    the link itself will be replaced, not the linked file.
14661  * </listitem>
14662  * <listitem>
14663  *   On Windows renaming a file will not remove an existing file with the
14664  *   new name, so on Windows there is a race condition between the existing
14665  *   file being removed and the temporary file being renamed.
14666  * </listitem>
14667  * <listitem>
14668  *   On Windows there is no way to remove a file that is open to some
14669  *   process, or mapped into memory. Thus, this function will fail if
14670  *   @filename already exists and is open.
14671  * </listitem>
14672  * </itemizedlist>
14673  *
14674  * If the call was successful, it returns %TRUE. If the call was not successful,
14675  * it returns %FALSE and sets @error. The error domain is #G_FILE_ERROR.
14676  * Possible error codes are those in the #GFileError enumeration.
14677  *
14678  * Note that the name for the temporary file is constructed by appending up
14679  * to 7 characters to @filename.
14680  *
14681  * Returns: %TRUE on success, %FALSE if an error occurred
14682  * Since: 2.8
14683  */
14684
14685
14686 /**
14687  * g_file_test:
14688  * @filename: a filename to test in the GLib file name encoding
14689  * @test: bitfield of #GFileTest flags
14690  *
14691  * Returns %TRUE if any of the tests in the bitfield @test are
14692  * %TRUE. For example, <literal>(G_FILE_TEST_EXISTS |
14693  * G_FILE_TEST_IS_DIR)</literal> will return %TRUE if the file exists;
14694  * the check whether it's a directory doesn't matter since the existence
14695  * test is %TRUE. With the current set of available tests, there's no point
14696  * passing in more than one test at a time.
14697  *
14698  * Apart from %G_FILE_TEST_IS_SYMLINK all tests follow symbolic links,
14699  * so for a symbolic link to a regular file g_file_test() will return
14700  * %TRUE for both %G_FILE_TEST_IS_SYMLINK and %G_FILE_TEST_IS_REGULAR.
14701  *
14702  * Note, that for a dangling symbolic link g_file_test() will return
14703  * %TRUE for %G_FILE_TEST_IS_SYMLINK and %FALSE for all other flags.
14704  *
14705  * You should never use g_file_test() to test whether it is safe
14706  * to perform an operation, because there is always the possibility
14707  * of the condition changing before you actually perform the operation.
14708  * For example, you might think you could use %G_FILE_TEST_IS_SYMLINK
14709  * to know whether it is safe to write to a file without being
14710  * tricked into writing into a different location. It doesn't work!
14711  * |[
14712  * /&ast; DON'T DO THIS &ast;/
14713  *  if (!g_file_test (filename, G_FILE_TEST_IS_SYMLINK))
14714  *    {
14715  *      fd = g_open (filename, O_WRONLY);
14716  *      /&ast; write to fd &ast;/
14717  *    }
14718  * ]|
14719  *
14720  * Another thing to note is that %G_FILE_TEST_EXISTS and
14721  * %G_FILE_TEST_IS_EXECUTABLE are implemented using the access()
14722  * system call. This usually doesn't matter, but if your program
14723  * is setuid or setgid it means that these tests will give you
14724  * the answer for the real user ID and group ID, rather than the
14725  * effective user ID and group ID.
14726  *
14727  * On Windows, there are no symlinks, so testing for
14728  * %G_FILE_TEST_IS_SYMLINK will always return %FALSE. Testing for
14729  * %G_FILE_TEST_IS_EXECUTABLE will just check that the file exists and
14730  * its name indicates that it is executable, checking for well-known
14731  * extensions and those listed in the <envar>PATHEXT</envar> environment variable.
14732  *
14733  * Returns: whether a test was %TRUE
14734  */
14735
14736
14737 /**
14738  * g_filename_display_basename:
14739  * @filename: an absolute pathname in the GLib file name encoding
14740  *
14741  * Returns the display basename for the particular filename, guaranteed
14742  * to be valid UTF-8. The display name might not be identical to the filename,
14743  * for instance there might be problems converting it to UTF-8, and some files
14744  * can be translated in the display.
14745  *
14746  * If GLib cannot make sense of the encoding of @filename, as a last resort it
14747  * replaces unknown characters with U+FFFD, the Unicode replacement character.
14748  * You can search the result for the UTF-8 encoding of this character (which is
14749  * "\357\277\275" in octal notation) to find out if @filename was in an invalid
14750  * encoding.
14751  *
14752  * You must pass the whole absolute pathname to this functions so that
14753  * translation of well known locations can be done.
14754  *
14755  * This function is preferred over g_filename_display_name() if you know the
14756  * whole path, as it allows translation.
14757  *
14758  * Returns: a newly allocated string containing
14759  *   a rendition of the basename of the filename in valid UTF-8
14760  * Since: 2.6
14761  */
14762
14763
14764 /**
14765  * g_filename_display_name:
14766  * @filename: a pathname hopefully in the GLib file name encoding
14767  *
14768  * Converts a filename into a valid UTF-8 string. The conversion is
14769  * not necessarily reversible, so you should keep the original around
14770  * and use the return value of this function only for display purposes.
14771  * Unlike g_filename_to_utf8(), the result is guaranteed to be non-%NULL
14772  * even if the filename actually isn't in the GLib file name encoding.
14773  *
14774  * If GLib cannot make sense of the encoding of @filename, as a last resort it
14775  * replaces unknown characters with U+FFFD, the Unicode replacement character.
14776  * You can search the result for the UTF-8 encoding of this character (which is
14777  * "\357\277\275" in octal notation) to find out if @filename was in an invalid
14778  * encoding.
14779  *
14780  * If you know the whole pathname of the file you should use
14781  * g_filename_display_basename(), since that allows location-based
14782  * translation of filenames.
14783  *
14784  * Returns: a newly allocated string containing
14785  *   a rendition of the filename in valid UTF-8
14786  * Since: 2.6
14787  */
14788
14789
14790 /**
14791  * g_filename_from_uri:
14792  * @uri: a uri describing a filename (escaped, encoded in ASCII).
14793  * @hostname: (out) (allow-none): Location to store hostname for the URI, or %NULL.
14794  *            If there is no hostname in the URI, %NULL will be
14795  *            stored in this location.
14796  * @error: location to store the error occurring, or %NULL to ignore
14797  *         errors. Any of the errors in #GConvertError may occur.
14798  *
14799  * Converts an escaped ASCII-encoded URI to a local filename in the
14800  * encoding used for filenames.
14801  *
14802  * Returns: (type filename): a newly-allocated string holding
14803  *               the resulting filename, or %NULL on an error.
14804  */
14805
14806
14807 /**
14808  * g_filename_from_utf8:
14809  * @utf8string: a UTF-8 encoded string.
14810  * @len: the length of the string, or -1 if the string is
14811  *                 nul-terminated.
14812  * @bytes_read: (out) (allow-none): location to store the number of bytes in
14813  *                 the input string that were successfully converted, or %NULL.
14814  *                 Even if the conversion was successful, this may be
14815  *                 less than @len if there were partial characters
14816  *                 at the end of the input. If the error
14817  *                 #G_CONVERT_ERROR_ILLEGAL_SEQUENCE occurs, the value
14818  *                 stored will the byte offset after the last valid
14819  *                 input sequence.
14820  * @bytes_written: (out): the number of bytes stored in the output buffer (not
14821  *                 including the terminating nul).
14822  * @error: location to store the error occurring, or %NULL to ignore
14823  *                 errors. Any of the errors in #GConvertError may occur.
14824  *
14825  * Converts a string from UTF-8 to the encoding GLib uses for
14826  * filenames. Note that on Windows GLib uses UTF-8 for filenames;
14827  * on other platforms, this function indirectly depends on the
14828  * <link linkend="setlocale">current locale</link>.
14829  *
14830  * Returns: (array length=bytes_written) (element-type guint8) (transfer full):
14831  *               The converted string, or %NULL on an error.
14832  */
14833
14834
14835 /**
14836  * g_filename_to_uri:
14837  * @filename: an absolute filename specified in the GLib file name encoding,
14838  *            which is the on-disk file name bytes on Unix, and UTF-8 on
14839  *            Windows
14840  * @hostname: (allow-none): A UTF-8 encoded hostname, or %NULL for none.
14841  * @error: location to store the error occurring, or %NULL to ignore
14842  *         errors. Any of the errors in #GConvertError may occur.
14843  *
14844  * Converts an absolute filename to an escaped ASCII-encoded URI, with the path
14845  * component following Section 3.3. of RFC 2396.
14846  *
14847  * Returns: a newly-allocated string holding the resulting
14848  *               URI, or %NULL on an error.
14849  */
14850
14851
14852 /**
14853  * g_filename_to_utf8:
14854  * @opsysstring: a string in the encoding for filenames
14855  * @len: the length of the string, or -1 if the string is
14856  *                 nul-terminated<footnoteref linkend="nul-unsafe"/>.
14857  * @bytes_read: location to store the number of bytes in the
14858  *                 input string that were successfully converted, or %NULL.
14859  *                 Even if the conversion was successful, this may be
14860  *                 less than @len if there were partial characters
14861  *                 at the end of the input. If the error
14862  *                 #G_CONVERT_ERROR_ILLEGAL_SEQUENCE occurs, the value
14863  *                 stored will the byte offset after the last valid
14864  *                 input sequence.
14865  * @bytes_written: the number of bytes stored in the output buffer (not
14866  *                 including the terminating nul).
14867  * @error: location to store the error occurring, or %NULL to ignore
14868  *                 errors. Any of the errors in #GConvertError may occur.
14869  *
14870  * Converts a string which is in the encoding used by GLib for
14871  * filenames into a UTF-8 string. Note that on Windows GLib uses UTF-8
14872  * for filenames; on other platforms, this function indirectly depends on
14873  * the <link linkend="setlocale">current locale</link>.
14874  *
14875  * Returns: The converted string, or %NULL on an error.
14876  */
14877
14878
14879 /**
14880  * g_find_program_in_path:
14881  * @program: a program name in the GLib file name encoding
14882  *
14883  * Locates the first executable named @program in the user's path, in the
14884  * same way that execvp() would locate it. Returns an allocated string
14885  * with the absolute path name, or %NULL if the program is not found in
14886  * the path. If @program is already an absolute path, returns a copy of
14887  * @program if @program exists and is executable, and %NULL otherwise.
14888  *  
14889  * On Windows, if @program does not have a file type suffix, tries
14890  * with the suffixes .exe, .cmd, .bat and .com, and the suffixes in
14891  * the <envar>PATHEXT</envar> environment variable.
14892  *
14893  * On Windows, it looks for the file in the same way as CreateProcess()
14894  * would. This means first in the directory where the executing
14895  * program was loaded from, then in the current directory, then in the
14896  * Windows 32-bit system directory, then in the Windows directory, and
14897  * finally in the directories in the <envar>PATH</envar> environment
14898  * variable. If the program is found, the return value contains the
14899  * full name including the type suffix.
14900  *
14901  * Returns: a newly-allocated string with the absolute path, or %NULL
14902  */
14903
14904
14905 /**
14906  * g_fopen:
14907  * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
14908  * @mode: a string describing the mode in which the file should be
14909  *   opened
14910  *
14911  * A wrapper for the stdio fopen() function. The fopen() function
14912  * opens a file and associates a new stream with it.
14913  *
14914  * Because file descriptors are specific to the C library on Windows,
14915  * and a file descriptor is partof the <type>FILE</type> struct, the
14916  * <type>FILE</type> pointer returned by this function makes sense
14917  * only to functions in the same C library. Thus if the GLib-using
14918  * code uses a different C library than GLib does, the
14919  * <type>FILE</type> pointer returned by this function cannot be
14920  * passed to C library functions like fprintf() or fread().
14921  *
14922  * See your C library manual for more details about fopen().
14923  *
14924  * Returns: A <type>FILE</type> pointer if the file was successfully
14925  *    opened, or %NULL if an error occurred
14926  * Since: 2.6
14927  */
14928
14929
14930 /**
14931  * g_format_size:
14932  * @size: a size in bytes
14933  *
14934  * Formats a size (for example the size of a file) into a human readable
14935  * string.  Sizes are rounded to the nearest size prefix (kB, MB, GB)
14936  * and are displayed rounded to the nearest tenth. E.g. the file size
14937  * 3292528 bytes will be converted into the string "3.2 MB".
14938  *
14939  * The prefix units base is 1000 (i.e. 1 kB is 1000 bytes).
14940  *
14941  * This string should be freed with g_free() when not needed any longer.
14942  *
14943  * See g_format_size_full() for more options about how the size might be
14944  * formatted.
14945  *
14946  * Returns: a newly-allocated formatted string containing a human readable
14947  *     file size
14948  * Since: 2.30
14949  */
14950
14951
14952 /**
14953  * g_format_size_for_display:
14954  * @size: a size in bytes
14955  *
14956  * Formats a size (for example the size of a file) into a human
14957  * readable string. Sizes are rounded to the nearest size prefix
14958  * (KB, MB, GB) and are displayed rounded to the nearest tenth.
14959  * E.g. the file size 3292528 bytes will be converted into the
14960  * string "3.1 MB".
14961  *
14962  * The prefix units base is 1024 (i.e. 1 KB is 1024 bytes).
14963  *
14964  * This string should be freed with g_free() when not needed any longer.
14965  *
14966  * Returns: a newly-allocated formatted string containing a human
14967  *     readable file size
14968  * Since: 2.16
14969  * Deprecated: 2.30: This function is broken due to its use of SI
14970  *     suffixes to denote IEC units. Use g_format_size() instead.
14971  */
14972
14973
14974 /**
14975  * g_format_size_full:
14976  * @size: a size in bytes
14977  * @flags: #GFormatSizeFlags to modify the output
14978  *
14979  * Formats a size.
14980  *
14981  * This function is similar to g_format_size() but allows for flags
14982  * that modify the output. See #GFormatSizeFlags.
14983  *
14984  * Returns: a newly-allocated formatted string containing a human
14985  *     readable file size
14986  * Since: 2.30
14987  */
14988
14989
14990 /**
14991  * g_fprintf:
14992  * @file: the stream to write to.
14993  * @format: a standard printf() format string, but notice
14994  *          <link linkend="string-precision">string precision pitfalls</link>.
14995  * @...: the arguments to insert in the output.
14996  *
14997  * An implementation of the standard fprintf() function which supports
14998  * positional parameters, as specified in the Single Unix Specification.
14999  *
15000  * Returns: the number of bytes printed.
15001  * Since: 2.2
15002  */
15003
15004
15005 /**
15006  * g_free:
15007  * @mem: the memory to free
15008  *
15009  * Frees the memory pointed to by @mem.
15010  * If @mem is %NULL it simply returns.
15011  */
15012
15013
15014 /**
15015  * g_freopen:
15016  * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
15017  * @mode: a string describing the mode in which the file should be
15018  *   opened
15019  * @stream: (allow-none): an existing stream which will be reused, or %NULL
15020  *
15021  * A wrapper for the POSIX freopen() function. The freopen() function
15022  * opens a file and associates it with an existing stream.
15023  *
15024  * See your C library manual for more details about freopen().
15025  *
15026  * Returns: A <literal>FILE</literal> pointer if the file was successfully
15027  *    opened, or %NULL if an error occurred.
15028  * Since: 2.6
15029  */
15030
15031
15032 /**
15033  * g_get_application_name:
15034  *
15035  * Gets a human-readable name for the application, as set by
15036  * g_set_application_name(). This name should be localized if
15037  * possible, and is intended for display to the user.  Contrast with
15038  * g_get_prgname(), which gets a non-localized name. If
15039  * g_set_application_name() has not been called, returns the result of
15040  * g_get_prgname() (which may be %NULL if g_set_prgname() has also not
15041  * been called).
15042  *
15043  * Returns: human-readable application name. may return %NULL
15044  * Since: 2.2
15045  */
15046
15047
15048 /**
15049  * g_get_charset:
15050  * @charset: return location for character set name
15051  *
15052  * Obtains the character set for the <link linkend="setlocale">current
15053  * locale</link>; you might use this character set as an argument to
15054  * g_convert(), to convert from the current locale's encoding to some
15055  * other encoding. (Frequently g_locale_to_utf8() and g_locale_from_utf8()
15056  * are nice shortcuts, though.)
15057  *
15058  * On Windows the character set returned by this function is the
15059  * so-called system default ANSI code-page. That is the character set
15060  * used by the "narrow" versions of C library and Win32 functions that
15061  * handle file names. It might be different from the character set
15062  * used by the C library's current locale.
15063  *
15064  * The return value is %TRUE if the locale's encoding is UTF-8, in that
15065  * case you can perhaps avoid calling g_convert().
15066  *
15067  * The string returned in @charset is not allocated, and should not be
15068  * freed.
15069  *
15070  * Returns: %TRUE if the returned charset is UTF-8
15071  */
15072
15073
15074 /**
15075  * g_get_codeset:
15076  *
15077  * Gets the character set for the current locale.
15078  *
15079  * Returns: a newly allocated string containing the name
15080  *     of the character set. This string must be freed with g_free().
15081  */
15082
15083
15084 /**
15085  * g_get_current_dir:
15086  *
15087  * Gets the current directory.
15088  *
15089  * The returned string should be freed when no longer needed.
15090  * The encoding of the returned string is system defined.
15091  * On Windows, it is always UTF-8.
15092  *
15093  * Returns: the current directory
15094  */
15095
15096
15097 /**
15098  * g_get_current_time:
15099  * @result: #GTimeVal structure in which to store current time.
15100  *
15101  * Equivalent to the UNIX gettimeofday() function, but portable.
15102  *
15103  * You may find g_get_real_time() to be more convenient.
15104  */
15105
15106
15107 /**
15108  * g_get_environ:
15109  *
15110  * Gets the list of environment variables for the current process.
15111  *
15112  * The list is %NULL terminated and each item in the list is of the
15113  * form 'NAME=VALUE'.
15114  *
15115  * This is equivalent to direct access to the 'environ' global variable,
15116  * except portable.
15117  *
15118  * The return value is freshly allocated and it should be freed with
15119  * g_strfreev() when it is no longer needed.
15120  *
15121  * Returns: (array zero-terminated=1) (transfer full): the list of
15122  *     environment variables
15123  * Since: 2.28
15124  */
15125
15126
15127 /**
15128  * g_get_filename_charsets:
15129  * @charsets: return location for the %NULL-terminated list of encoding names
15130  *
15131  * Determines the preferred character sets used for filenames.
15132  * The first character set from the @charsets is the filename encoding, the
15133  * subsequent character sets are used when trying to generate a displayable
15134  * representation of a filename, see g_filename_display_name().
15135  *
15136  * On Unix, the character sets are determined by consulting the
15137  * environment variables <envar>G_FILENAME_ENCODING</envar> and
15138  * <envar>G_BROKEN_FILENAMES</envar>. On Windows, the character set
15139  * used in the GLib API is always UTF-8 and said environment variables
15140  * have no effect.
15141  *
15142  * <envar>G_FILENAME_ENCODING</envar> may be set to a comma-separated list
15143  * of character set names. The special token "&commat;locale" is taken to
15144  * mean the character set for the <link linkend="setlocale">current
15145  * locale</link>. If <envar>G_FILENAME_ENCODING</envar> is not set, but
15146  * <envar>G_BROKEN_FILENAMES</envar> is, the character set of the current
15147  * locale is taken as the filename encoding. If neither environment variable
15148  * is set, UTF-8 is taken as the filename encoding, but the character
15149  * set of the current locale is also put in the list of encodings.
15150  *
15151  * The returned @charsets belong to GLib and must not be freed.
15152  *
15153  * Note that on Unix, regardless of the locale character set or
15154  * <envar>G_FILENAME_ENCODING</envar> value, the actual file names present
15155  * on a system might be in any random encoding or just gibberish.
15156  *
15157  * Returns: %TRUE if the filename encoding is UTF-8.
15158  * Since: 2.6
15159  */
15160
15161
15162 /**
15163  * g_get_home_dir:
15164  *
15165  * Gets the current user's home directory.
15166  *
15167  * As with most UNIX tools, this function will return the value of the
15168  * <envar>HOME</envar> environment variable if it is set to an existing
15169  * absolute path name, falling back to the <filename>passwd</filename>
15170  * file in the case that it is unset.
15171  *
15172  * If the path given in <envar>HOME</envar> is non-absolute, does not
15173  * exist, or is not a directory, the result is undefined.
15174  *
15175  * <note><para>
15176  *   Before version 2.36 this function would ignore the
15177  *   <envar>HOME</envar> environment variable, taking the value from the
15178  *   <filename>passwd</filename> database instead.  This was changed to
15179  *   increase the compatibility of GLib with other programs (and the XDG
15180  *   basedir specification) and to increase testability of programs
15181  *   based on GLib (by making it easier to run them from test
15182  *   frameworks).
15183  * </para><para>
15184  *   If your program has a strong requirement for either the new or the
15185  *   old behaviour (and if you don't wish to increase your GLib
15186  *   dependency to ensure that the new behaviour is in effect) then you
15187  *   should either directly check the <envar>HOME</envar> environment
15188  *   variable yourself or unset it before calling any functions in GLib.
15189  * </para></note>
15190  *
15191  * Returns: the current user's home directory
15192  */
15193
15194
15195 /**
15196  * g_get_host_name:
15197  *
15198  * Return a name for the machine.
15199  *
15200  * The returned name is not necessarily a fully-qualified domain name,
15201  * or even present in DNS or some other name service at all. It need
15202  * not even be unique on your local network or site, but usually it
15203  * is. Callers should not rely on the return value having any specific
15204  * properties like uniqueness for security purposes. Even if the name
15205  * of the machine is changed while an application is running, the
15206  * return value from this function does not change. The returned
15207  * string is owned by GLib and should not be modified or freed. If no
15208  * name can be determined, a default fixed string "localhost" is
15209  * returned.
15210  *
15211  * Returns: the host name of the machine.
15212  * Since: 2.8
15213  */
15214
15215
15216 /**
15217  * g_get_language_names:
15218  *
15219  * Computes a list of applicable locale names, which can be used to
15220  * e.g. construct locale-dependent filenames or search paths. The returned
15221  * list is sorted from most desirable to least desirable and always contains
15222  * the default locale "C".
15223  *
15224  * For example, if LANGUAGE=de:en_US, then the returned list is
15225  * "de", "en_US", "en", "C".
15226  *
15227  * This function consults the environment variables <envar>LANGUAGE</envar>,
15228  * <envar>LC_ALL</envar>, <envar>LC_MESSAGES</envar> and <envar>LANG</envar>
15229  * to find the list of locales specified by the user.
15230  *
15231  * Returns: (array zero-terminated=1) (transfer none): a %NULL-terminated array of strings owned by GLib
15232  *    that must not be modified or freed.
15233  * Since: 2.6
15234  */
15235
15236
15237 /**
15238  * g_get_locale_variants:
15239  * @locale: a locale identifier
15240  *
15241  * Returns a list of derived variants of @locale, which can be used to
15242  * e.g. construct locale-dependent filenames or search paths. The returned
15243  * list is sorted from most desirable to least desirable.
15244  * This function handles territory, charset and extra locale modifiers.
15245  *
15246  * For example, if @locale is "fr_BE", then the returned list
15247  * is "fr_BE", "fr".
15248  *
15249  * If you need the list of variants for the <emphasis>current locale</emphasis>,
15250  * use g_get_language_names().
15251  *
15252  * Returns: (transfer full) (array zero-terminated=1) (element-type utf8): a newly
15253  *   allocated array of newly allocated strings with the locale variants. Free with
15254  *   g_strfreev().
15255  * Since: 2.28
15256  */
15257
15258
15259 /**
15260  * g_get_monotonic_time:
15261  *
15262  * Queries the system monotonic time, if available.
15263  *
15264  * On POSIX systems with clock_gettime() and <literal>CLOCK_MONOTONIC</literal> this call
15265  * is a very shallow wrapper for that.  Otherwise, we make a best effort
15266  * that probably involves returning the wall clock time (with at least
15267  * microsecond accuracy, subject to the limitations of the OS kernel).
15268  *
15269  * It's important to note that POSIX <literal>CLOCK_MONOTONIC</literal> does
15270  * not count time spent while the machine is suspended.
15271  *
15272  * On Windows, "limitations of the OS kernel" is a rather substantial
15273  * statement.  Depending on the configuration of the system, the wall
15274  * clock time is updated as infrequently as 64 times a second (which
15275  * is approximately every 16ms). Also, on XP (but not on Vista or later)
15276  * the monotonic clock is locally monotonic, but may differ in exact
15277  * value between processes due to timer wrap handling.
15278  *
15279  * Returns: the monotonic time, in microseconds
15280  * Since: 2.28
15281  */
15282
15283
15284 /**
15285  * g_get_num_processors:
15286  *
15287  * Determine the approximate number of threads that the system will
15288  * schedule simultaneously for this process.  This is intended to be
15289  * used as a parameter to g_thread_pool_new() for CPU bound tasks and
15290  * similar cases.
15291  *
15292  * Returns: Number of schedulable threads, always greater than 0
15293  * Since: 2.36
15294  */
15295
15296
15297 /**
15298  * g_get_prgname:
15299  *
15300  * Gets the name of the program. This name should <emphasis>not</emphasis>
15301  * be localized, contrast with g_get_application_name().
15302  * (If you are using GDK or GTK+ the program name is set in gdk_init(),
15303  * which is called by gtk_init(). The program name is found by taking
15304  * the last component of <literal>argv[0]</literal>.)
15305  *
15306  * Returns: the name of the program. The returned string belongs
15307  * to GLib and must not be modified or freed.
15308  */
15309
15310
15311 /**
15312  * g_get_real_name:
15313  *
15314  * Gets the real name of the user. This usually comes from the user's entry
15315  * in the <filename>passwd</filename> file. The encoding of the returned
15316  * string is system-defined. (On Windows, it is, however, always UTF-8.)
15317  * If the real user name cannot be determined, the string "Unknown" is
15318  * returned.
15319  *
15320  * Returns: the user's real name.
15321  */
15322
15323
15324 /**
15325  * g_get_real_time:
15326  *
15327  * Queries the system wall-clock time.
15328  *
15329  * This call is functionally equivalent to g_get_current_time() except
15330  * that the return value is often more convenient than dealing with a
15331  * #GTimeVal.
15332  *
15333  * You should only use this call if you are actually interested in the real
15334  * wall-clock time.  g_get_monotonic_time() is probably more useful for
15335  * measuring intervals.
15336  *
15337  * Returns: the number of microseconds since January 1, 1970 UTC.
15338  * Since: 2.28
15339  */
15340
15341
15342 /**
15343  * g_get_system_config_dirs:
15344  *
15345  * Returns an ordered list of base directories in which to access
15346  * system-wide configuration information.
15347  *
15348  * On UNIX platforms this is determined using the mechanisms described in
15349  * the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
15350  * XDG Base Directory Specification</ulink>.
15351  * In this case the list of directories retrieved will be XDG_CONFIG_DIRS.
15352  *
15353  * On Windows is the directory that contains application data for all users.
15354  * A typical path is C:\Documents and Settings\All Users\Application Data.
15355  * This folder is used for application data that is not user specific.
15356  * For example, an application can store a spell-check dictionary, a database
15357  * of clip art, or a log file in the CSIDL_COMMON_APPDATA folder.
15358  * This information will not roam and is available to anyone using the computer.
15359  *
15360  * Returns: (array zero-terminated=1) (transfer none): a %NULL-terminated array of strings owned by GLib that must
15361  *               not be modified or freed.
15362  * Since: 2.6
15363  */
15364
15365
15366 /**
15367  * g_get_system_data_dirs:
15368  *
15369  * Returns an ordered list of base directories in which to access
15370  * system-wide application data.
15371  *
15372  * On UNIX platforms this is determined using the mechanisms described in
15373  * the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
15374  * XDG Base Directory Specification</ulink>
15375  * In this case the list of directories retrieved will be XDG_DATA_DIRS.
15376  *
15377  * On Windows the first elements in the list are the Application Data
15378  * and Documents folders for All Users. (These can be determined only
15379  * on Windows 2000 or later and are not present in the list on other
15380  * Windows versions.) See documentation for CSIDL_COMMON_APPDATA and
15381  * CSIDL_COMMON_DOCUMENTS.
15382  *
15383  * Then follows the "share" subfolder in the installation folder for
15384  * the package containing the DLL that calls this function, if it can
15385  * be determined.
15386  *
15387  * Finally the list contains the "share" subfolder in the installation
15388  * folder for GLib, and in the installation folder for the package the
15389  * application's .exe file belongs to.
15390  *
15391  * The installation folders above are determined by looking up the
15392  * folder where the module (DLL or EXE) in question is located. If the
15393  * folder's name is "bin", its parent is used, otherwise the folder
15394  * itself.
15395  *
15396  * Note that on Windows the returned list can vary depending on where
15397  * this function is called.
15398  *
15399  * Returns: (array zero-terminated=1) (transfer none): a %NULL-terminated array of strings owned by GLib that must
15400  *               not be modified or freed.
15401  * Since: 2.6
15402  */
15403
15404
15405 /**
15406  * g_get_tmp_dir:
15407  *
15408  * Gets the directory to use for temporary files.
15409  *
15410  * On UNIX, this is taken from the <envar>TMPDIR</envar> environment
15411  * variable.  If the variable is not set, <literal>P_tmpdir</literal> is
15412  * used, as defined by the system C library.  Failing that, a hard-coded
15413  * default of "/tmp" is returned.
15414  *
15415  * On Windows, the <envar>TEMP</envar> environment variable is used,
15416  * with the root directory of the Windows installation (eg: "C:\") used
15417  * as a default.
15418  *
15419  * The encoding of the returned string is system-defined. On Windows, it
15420  * is always UTF-8. The return value is never %NULL or the empty string.
15421  *
15422  * Returns: the directory to use for temporary files.
15423  */
15424
15425
15426 /**
15427  * g_get_user_cache_dir:
15428  *
15429  * Returns a base directory in which to store non-essential, cached
15430  * data specific to particular user.
15431  *
15432  * On UNIX platforms this is determined using the mechanisms described in
15433  * the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
15434  * XDG Base Directory Specification</ulink>.
15435  * In this case the directory retrieved will be XDG_CACHE_HOME.
15436  *
15437  * On Windows is the directory that serves as a common repository for
15438  * temporary Internet files. A typical path is
15439  * C:\Documents and Settings\username\Local Settings\Temporary Internet Files.
15440  * See documentation for CSIDL_INTERNET_CACHE.
15441  *
15442  * Returns: a string owned by GLib that must not be modified
15443  *               or freed.
15444  * Since: 2.6
15445  */
15446
15447
15448 /**
15449  * g_get_user_config_dir:
15450  *
15451  * Returns a base directory in which to store user-specific application
15452  * configuration information such as user preferences and settings.
15453  *
15454  * On UNIX platforms this is determined using the mechanisms described in
15455  * the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
15456  * XDG Base Directory Specification</ulink>.
15457  * In this case the directory retrieved will be XDG_CONFIG_HOME.
15458  *
15459  * On Windows this is the folder to use for local (as opposed to
15460  * roaming) application data. See documentation for
15461  * CSIDL_LOCAL_APPDATA. Note that on Windows it thus is the same as
15462  * what g_get_user_data_dir() returns.
15463  *
15464  * Returns: a string owned by GLib that must not be modified
15465  *               or freed.
15466  * Since: 2.6
15467  */
15468
15469
15470 /**
15471  * g_get_user_data_dir:
15472  *
15473  * Returns a base directory in which to access application data such
15474  * as icons that is customized for a particular user.
15475  *
15476  * On UNIX platforms this is determined using the mechanisms described in
15477  * the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
15478  * XDG Base Directory Specification</ulink>.
15479  * In this case the directory retrieved will be XDG_DATA_HOME.
15480  *
15481  * On Windows this is the folder to use for local (as opposed to
15482  * roaming) application data. See documentation for
15483  * CSIDL_LOCAL_APPDATA. Note that on Windows it thus is the same as
15484  * what g_get_user_config_dir() returns.
15485  *
15486  * Returns: a string owned by GLib that must not be modified
15487  *               or freed.
15488  * Since: 2.6
15489  */
15490
15491
15492 /**
15493  * g_get_user_name:
15494  *
15495  * Gets the user name of the current user. The encoding of the returned
15496  * string is system-defined. On UNIX, it might be the preferred file name
15497  * encoding, or something else, and there is no guarantee that it is even
15498  * consistent on a machine. On Windows, it is always UTF-8.
15499  *
15500  * Returns: the user name of the current user.
15501  */
15502
15503
15504 /**
15505  * g_get_user_runtime_dir:
15506  *
15507  * Returns a directory that is unique to the current user on the local
15508  * system.
15509  *
15510  * On UNIX platforms this is determined using the mechanisms described in
15511  * the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
15512  * XDG Base Directory Specification</ulink>.  This is the directory
15513  * specified in the <envar>XDG_RUNTIME_DIR</envar> environment variable.
15514  * In the case that this variable is not set, GLib will issue a warning
15515  * message to stderr and return the value of g_get_user_cache_dir().
15516  *
15517  * On Windows this is the folder to use for local (as opposed to
15518  * roaming) application data. See documentation for
15519  * CSIDL_LOCAL_APPDATA.  Note that on Windows it thus is the same as
15520  * what g_get_user_config_dir() returns.
15521  *
15522  * Returns: a string owned by GLib that must not be modified or freed.
15523  * Since: 2.28
15524  */
15525
15526
15527 /**
15528  * g_get_user_special_dir:
15529  * @directory: the logical id of special directory
15530  *
15531  * Returns the full path of a special directory using its logical id.
15532  *
15533  * On Unix this is done using the XDG special user directories.
15534  * For compatibility with existing practise, %G_USER_DIRECTORY_DESKTOP
15535  * falls back to <filename>$HOME/Desktop</filename> when XDG special
15536  * user directories have not been set up.
15537  *
15538  * Depending on the platform, the user might be able to change the path
15539  * of the special directory without requiring the session to restart; GLib
15540  * will not reflect any change once the special directories are loaded.
15541  *
15542  * Returns: the path to the specified special directory, or %NULL
15543  *   if the logical id was not found. The returned string is owned by
15544  *   GLib and should not be modified or freed.
15545  * Since: 2.14
15546  */
15547
15548
15549 /**
15550  * g_getenv:
15551  * @variable: the environment variable to get, in the GLib file name
15552  *     encoding
15553  *
15554  * Returns the value of an environment variable.
15555  *
15556  * The name and value are in the GLib file name encoding. On UNIX,
15557  * this means the actual bytes which might or might not be in some
15558  * consistent character set and encoding. On Windows, it is in UTF-8.
15559  * On Windows, in case the environment variable's value contains
15560  * references to other environment variables, they are expanded.
15561  *
15562  * Returns: the value of the environment variable, or %NULL if
15563  *     the environment variable is not found. The returned string
15564  *     may be overwritten by the next call to g_getenv(), g_setenv()
15565  *     or g_unsetenv().
15566  */
15567
15568
15569 /**
15570  * g_hash_table_add:
15571  * @hash_table: a #GHashTable
15572  * @key: a key to insert
15573  *
15574  * This is a convenience function for using a #GHashTable as a set.  It
15575  * is equivalent to calling g_hash_table_replace() with @key as both the
15576  * key and the value.
15577  *
15578  * When a hash table only ever contains keys that have themselves as the
15579  * corresponding value it is able to be stored more efficiently.  See
15580  * the discussion in the section description.
15581  *
15582  * Since: 2.32
15583  */
15584
15585
15586 /**
15587  * g_hash_table_contains:
15588  * @hash_table: a #GHashTable
15589  * @key: a key to check
15590  *
15591  * Checks if @key is in @hash_table.
15592  *
15593  * Since: 2.32
15594  */
15595
15596
15597 /**
15598  * g_hash_table_destroy:
15599  * @hash_table: a #GHashTable
15600  *
15601  * Destroys all keys and values in the #GHashTable and decrements its
15602  * reference count by 1. If keys and/or values are dynamically allocated,
15603  * you should either free them first or create the #GHashTable with destroy
15604  * notifiers using g_hash_table_new_full(). In the latter case the destroy
15605  * functions you supplied will be called on all keys and values during the
15606  * destruction phase.
15607  */
15608
15609
15610 /**
15611  * g_hash_table_find:
15612  * @hash_table: a #GHashTable
15613  * @predicate: function to test the key/value pairs for a certain property
15614  * @user_data: user data to pass to the function
15615  *
15616  * Calls the given function for key/value pairs in the #GHashTable
15617  * until @predicate returns %TRUE. The function is passed the key
15618  * and value of each pair, and the given @user_data parameter. The
15619  * hash table may not be modified while iterating over it (you can't
15620  * add/remove items).
15621  *
15622  * Note, that hash tables are really only optimized for forward
15623  * lookups, i.e. g_hash_table_lookup(). So code that frequently issues
15624  * g_hash_table_find() or g_hash_table_foreach() (e.g. in the order of
15625  * once per every entry in a hash table) should probably be reworked
15626  * to use additional or different data structures for reverse lookups
15627  * (keep in mind that an O(n) find/foreach operation issued for all n
15628  * values in a hash table ends up needing O(n*n) operations).
15629  *
15630  * Returns: (allow-none): The value of the first key/value pair is returned,
15631  *     for which @predicate evaluates to %TRUE. If no pair with the
15632  *     requested property is found, %NULL is returned.
15633  * Since: 2.4
15634  */
15635
15636
15637 /**
15638  * g_hash_table_foreach:
15639  * @hash_table: a #GHashTable
15640  * @func: the function to call for each key/value pair
15641  * @user_data: user data to pass to the function
15642  *
15643  * Calls the given function for each of the key/value pairs in the
15644  * #GHashTable.  The function is passed the key and value of each
15645  * pair, and the given @user_data parameter.  The hash table may not
15646  * be modified while iterating over it (you can't add/remove
15647  * items). To remove all items matching a predicate, use
15648  * g_hash_table_foreach_remove().
15649  *
15650  * See g_hash_table_find() for performance caveats for linear
15651  * order searches in contrast to g_hash_table_lookup().
15652  */
15653
15654
15655 /**
15656  * g_hash_table_foreach_remove:
15657  * @hash_table: a #GHashTable
15658  * @func: the function to call for each key/value pair
15659  * @user_data: user data to pass to the function
15660  *
15661  * Calls the given function for each key/value pair in the
15662  * #GHashTable. If the function returns %TRUE, then the key/value
15663  * pair is removed from the #GHashTable. If you supplied key or
15664  * value destroy functions when creating the #GHashTable, they are
15665  * used to free the memory allocated for the removed keys and values.
15666  *
15667  * See #GHashTableIter for an alternative way to loop over the
15668  * key/value pairs in the hash table.
15669  *
15670  * Returns: the number of key/value pairs removed
15671  */
15672
15673
15674 /**
15675  * g_hash_table_foreach_steal:
15676  * @hash_table: a #GHashTable
15677  * @func: the function to call for each key/value pair
15678  * @user_data: user data to pass to the function
15679  *
15680  * Calls the given function for each key/value pair in the
15681  * #GHashTable. If the function returns %TRUE, then the key/value
15682  * pair is removed from the #GHashTable, but no key or value
15683  * destroy functions are called.
15684  *
15685  * See #GHashTableIter for an alternative way to loop over the
15686  * key/value pairs in the hash table.
15687  *
15688  * Returns: the number of key/value pairs removed.
15689  */
15690
15691
15692 /**
15693  * g_hash_table_freeze:
15694  * @hash_table: a #GHashTable
15695  *
15696  * This function is deprecated and will be removed in the next major
15697  * release of GLib. It does nothing.
15698  */
15699
15700
15701 /**
15702  * g_hash_table_get_keys:
15703  * @hash_table: a #GHashTable
15704  *
15705  * Retrieves every key inside @hash_table. The returned data is valid
15706  * until changes to the hash release those keys.
15707  *
15708  * Returns: a #GList containing all the keys inside the hash
15709  *     table. The content of the list is owned by the hash table and
15710  *     should not be modified or freed. Use g_list_free() when done
15711  *     using the list.
15712  * Since: 2.14
15713  */
15714
15715
15716 /**
15717  * g_hash_table_get_keys_as_array:
15718  * @hash_table: a #GHashTable
15719  * @length: (out): the length of the returned array
15720  *
15721  * Retrieves every key inside @hash_table, as an array.
15722  *
15723  * The returned array is %NULL-terminated but may contain %NULL as a
15724  * key.  Use @length to determine the true length if it's possible that
15725  * %NULL was used as the value for a key.
15726  *
15727  * Note: in the common case of a string-keyed #GHashTable, the return
15728  * value of this function can be conveniently cast to (gchar **).
15729  *
15730  * You should always free the return result with g_free().  In the
15731  * above-mentioned case of a string-keyed hash table, it may be
15732  * appropriate to use g_strfreev() if you call g_hash_table_steal_all()
15733  * first to transfer ownership of the keys.
15734  *
15735  * Returns: (array length=length) (transfer container): a
15736  *   %NULL-terminated array containing each key from the table.
15737  * Since: 2.40
15738  */
15739
15740
15741 /**
15742  * g_hash_table_get_values:
15743  * @hash_table: a #GHashTable
15744  *
15745  * Retrieves every value inside @hash_table. The returned data
15746  * is valid until @hash_table is modified.
15747  *
15748  * Returns: a #GList containing all the values inside the hash
15749  *     table. The content of the list is owned by the hash table and
15750  *     should not be modified or freed. Use g_list_free() when done
15751  *     using the list.
15752  * Since: 2.14
15753  */
15754
15755
15756 /**
15757  * g_hash_table_insert:
15758  * @hash_table: a #GHashTable
15759  * @key: a key to insert
15760  * @value: the value to associate with the key
15761  *
15762  * Inserts a new key and value into a #GHashTable.
15763  *
15764  * If the key already exists in the #GHashTable its current
15765  * value is replaced with the new value. If you supplied a
15766  * @value_destroy_func when creating the #GHashTable, the old
15767  * value is freed using that function. If you supplied a
15768  * @key_destroy_func when creating the #GHashTable, the passed
15769  * key is freed using that function.
15770  */
15771
15772
15773 /**
15774  * g_hash_table_iter_get_hash_table:
15775  * @iter: an initialized #GHashTableIter
15776  *
15777  * Returns the #GHashTable associated with @iter.
15778  *
15779  * Returns: the #GHashTable associated with @iter.
15780  * Since: 2.16
15781  */
15782
15783
15784 /**
15785  * g_hash_table_iter_init:
15786  * @iter: an uninitialized #GHashTableIter
15787  * @hash_table: a #GHashTable
15788  *
15789  * Initializes a key/value pair iterator and associates it with
15790  * @hash_table. Modifying the hash table after calling this function
15791  * invalidates the returned iterator.
15792  * |[
15793  * GHashTableIter iter;
15794  * gpointer key, value;
15795  *
15796  * g_hash_table_iter_init (&iter, hash_table);
15797  * while (g_hash_table_iter_next (&iter, &key, &value))
15798  *   {
15799  *     /&ast; do something with key and value &ast;/
15800  *   }
15801  * ]|
15802  *
15803  * Since: 2.16
15804  */
15805
15806
15807 /**
15808  * g_hash_table_iter_next:
15809  * @iter: an initialized #GHashTableIter
15810  * @key: (allow-none): a location to store the key, or %NULL
15811  * @value: (allow-none): a location to store the value, or %NULL
15812  *
15813  * Advances @iter and retrieves the key and/or value that are now
15814  * pointed to as a result of this advancement. If %FALSE is returned,
15815  * @key and @value are not set, and the iterator becomes invalid.
15816  *
15817  * Returns: %FALSE if the end of the #GHashTable has been reached.
15818  * Since: 2.16
15819  */
15820
15821
15822 /**
15823  * g_hash_table_iter_remove:
15824  * @iter: an initialized #GHashTableIter
15825  *
15826  * Removes the key/value pair currently pointed to by the iterator
15827  * from its associated #GHashTable. Can only be called after
15828  * g_hash_table_iter_next() returned %TRUE, and cannot be called
15829  * more than once for the same key/value pair.
15830  *
15831  * If the #GHashTable was created using g_hash_table_new_full(),
15832  * the key and value are freed using the supplied destroy functions,
15833  * otherwise you have to make sure that any dynamically allocated
15834  * values are freed yourself.
15835  *
15836  * Since: 2.16
15837  */
15838
15839
15840 /**
15841  * g_hash_table_iter_replace:
15842  * @iter: an initialized #GHashTableIter
15843  * @value: the value to replace with
15844  *
15845  * Replaces the value currently pointed to by the iterator
15846  * from its associated #GHashTable. Can only be called after
15847  * g_hash_table_iter_next() returned %TRUE.
15848  *
15849  * If you supplied a @value_destroy_func when creating the
15850  * #GHashTable, the old value is freed using that function.
15851  *
15852  * Since: 2.30
15853  */
15854
15855
15856 /**
15857  * g_hash_table_iter_steal:
15858  * @iter: an initialized #GHashTableIter
15859  *
15860  * Removes the key/value pair currently pointed to by the
15861  * iterator from its associated #GHashTable, without calling
15862  * the key and value destroy functions. Can only be called
15863  * after g_hash_table_iter_next() returned %TRUE, and cannot
15864  * be called more than once for the same key/value pair.
15865  *
15866  * Since: 2.16
15867  */
15868
15869
15870 /**
15871  * g_hash_table_lookup:
15872  * @hash_table: a #GHashTable
15873  * @key: the key to look up
15874  *
15875  * Looks up a key in a #GHashTable. Note that this function cannot
15876  * distinguish between a key that is not present and one which is present
15877  * and has the value %NULL. If you need this distinction, use
15878  * g_hash_table_lookup_extended().
15879  *
15880  * Returns: (allow-none): the associated value, or %NULL if the key is not found
15881  */
15882
15883
15884 /**
15885  * g_hash_table_lookup_extended:
15886  * @hash_table: a #GHashTable
15887  * @lookup_key: the key to look up
15888  * @orig_key: (allow-none): return location for the original key, or %NULL
15889  * @value: (allow-none): return location for the value associated with the key, or %NULL
15890  *
15891  * Looks up a key in the #GHashTable, returning the original key and the
15892  * associated value and a #gboolean which is %TRUE if the key was found. This
15893  * is useful if you need to free the memory allocated for the original key,
15894  * for example before calling g_hash_table_remove().
15895  *
15896  * You can actually pass %NULL for @lookup_key to test
15897  * whether the %NULL key exists, provided the hash and equal functions
15898  * of @hash_table are %NULL-safe.
15899  *
15900  * Returns: %TRUE if the key was found in the #GHashTable
15901  */
15902
15903
15904 /**
15905  * g_hash_table_new:
15906  * @hash_func: a function to create a hash value from a key
15907  * @key_equal_func: a function to check two keys for equality
15908  *
15909  * Creates a new #GHashTable with a reference count of 1.
15910  *
15911  * Hash values returned by @hash_func are used to determine where keys
15912  * are stored within the #GHashTable data structure. The g_direct_hash(),
15913  * g_int_hash(), g_int64_hash(), g_double_hash() and g_str_hash()
15914  * functions are provided for some common types of keys.
15915  * If @hash_func is %NULL, g_direct_hash() is used.
15916  *
15917  * @key_equal_func is used when looking up keys in the #GHashTable.
15918  * The g_direct_equal(), g_int_equal(), g_int64_equal(), g_double_equal()
15919  * and g_str_equal() functions are provided for the most common types
15920  * of keys. If @key_equal_func is %NULL, keys are compared directly in
15921  * a similar fashion to g_direct_equal(), but without the overhead of
15922  * a function call.
15923  *
15924  * Returns: a new #GHashTable
15925  */
15926
15927
15928 /**
15929  * g_hash_table_new_full:
15930  * @hash_func: a function to create a hash value from a key
15931  * @key_equal_func: a function to check two keys for equality
15932  * @key_destroy_func: (allow-none): a function to free the memory allocated for the key
15933  *     used when removing the entry from the #GHashTable, or %NULL
15934  *     if you don't want to supply such a function.
15935  * @value_destroy_func: (allow-none): a function to free the memory allocated for the
15936  *     value used when removing the entry from the #GHashTable, or %NULL
15937  *     if you don't want to supply such a function.
15938  *
15939  * Creates a new #GHashTable like g_hash_table_new() with a reference
15940  * count of 1 and allows to specify functions to free the memory
15941  * allocated for the key and value that get called when removing the
15942  * entry from the #GHashTable.
15943  *
15944  * Returns: a new #GHashTable
15945  */
15946
15947
15948 /**
15949  * g_hash_table_ref:
15950  * @hash_table: a valid #GHashTable
15951  *
15952  * Atomically increments the reference count of @hash_table by one.
15953  * This function is MT-safe and may be called from any thread.
15954  *
15955  * Returns: the passed in #GHashTable
15956  * Since: 2.10
15957  */
15958
15959
15960 /**
15961  * g_hash_table_remove:
15962  * @hash_table: a #GHashTable
15963  * @key: the key to remove
15964  *
15965  * Removes a key and its associated value from a #GHashTable.
15966  *
15967  * If the #GHashTable was created using g_hash_table_new_full(), the
15968  * key and value are freed using the supplied destroy functions, otherwise
15969  * you have to make sure that any dynamically allocated values are freed
15970  * yourself.
15971  *
15972  * Returns: %TRUE if the key was found and removed from the #GHashTable
15973  */
15974
15975
15976 /**
15977  * g_hash_table_remove_all:
15978  * @hash_table: a #GHashTable
15979  *
15980  * Removes all keys and their associated values from a #GHashTable.
15981  *
15982  * If the #GHashTable was created using g_hash_table_new_full(),
15983  * the keys and values are freed using the supplied destroy functions,
15984  * otherwise you have to make sure that any dynamically allocated
15985  * values are freed yourself.
15986  *
15987  * Since: 2.12
15988  */
15989
15990
15991 /**
15992  * g_hash_table_replace:
15993  * @hash_table: a #GHashTable
15994  * @key: a key to insert
15995  * @value: the value to associate with the key
15996  *
15997  * Inserts a new key and value into a #GHashTable similar to
15998  * g_hash_table_insert(). The difference is that if the key
15999  * already exists in the #GHashTable, it gets replaced by the
16000  * new key. If you supplied a @value_destroy_func when creating
16001  * the #GHashTable, the old value is freed using that function.
16002  * If you supplied a @key_destroy_func when creating the
16003  * #GHashTable, the old key is freed using that function.
16004  */
16005
16006
16007 /**
16008  * g_hash_table_size:
16009  * @hash_table: a #GHashTable
16010  *
16011  * Returns the number of elements contained in the #GHashTable.
16012  *
16013  * Returns: the number of key/value pairs in the #GHashTable.
16014  */
16015
16016
16017 /**
16018  * g_hash_table_steal:
16019  * @hash_table: a #GHashTable
16020  * @key: the key to remove
16021  *
16022  * Removes a key and its associated value from a #GHashTable without
16023  * calling the key and value destroy functions.
16024  *
16025  * Returns: %TRUE if the key was found and removed from the #GHashTable
16026  */
16027
16028
16029 /**
16030  * g_hash_table_steal_all:
16031  * @hash_table: a #GHashTable
16032  *
16033  * Removes all keys and their associated values from a #GHashTable
16034  * without calling the key and value destroy functions.
16035  *
16036  * Since: 2.12
16037  */
16038
16039
16040 /**
16041  * g_hash_table_thaw:
16042  * @hash_table: a #GHashTable
16043  *
16044  * This function is deprecated and will be removed in the next major
16045  * release of GLib. It does nothing.
16046  */
16047
16048
16049 /**
16050  * g_hash_table_unref:
16051  * @hash_table: a valid #GHashTable
16052  *
16053  * Atomically decrements the reference count of @hash_table by one.
16054  * If the reference count drops to 0, all keys and values will be
16055  * destroyed, and all memory allocated by the hash table is released.
16056  * This function is MT-safe and may be called from any thread.
16057  *
16058  * Since: 2.10
16059  */
16060
16061
16062 /**
16063  * g_hmac_copy:
16064  * @hmac: the #GHmac to copy
16065  *
16066  * Copies a #GHmac. If @hmac has been closed, by calling
16067  * g_hmac_get_string() or g_hmac_get_digest(), the copied
16068  * HMAC will be closed as well.
16069  *
16070  * Returns: the copy of the passed #GHmac. Use g_hmac_unref()
16071  *   when finished using it.
16072  * Since: 2.30
16073  */
16074
16075
16076 /**
16077  * g_hmac_get_digest:
16078  * @hmac: a #GHmac
16079  * @buffer: output buffer
16080  * @digest_len: an inout parameter. The caller initializes it to the
16081  *   size of @buffer. After the call it contains the length of the digest
16082  *
16083  * Gets the digest from @checksum as a raw binary array and places it
16084  * into @buffer. The size of the digest depends on the type of checksum.
16085  *
16086  * Once this function has been called, the #GHmac is closed and can
16087  * no longer be updated with g_checksum_update().
16088  *
16089  * Since: 2.30
16090  */
16091
16092
16093 /**
16094  * g_hmac_get_string:
16095  * @hmac: a #GHmac
16096  *
16097  * Gets the HMAC as an hexadecimal string.
16098  *
16099  * Once this function has been called the #GHmac can no longer be
16100  * updated with g_hmac_update().
16101  *
16102  * The hexadecimal characters will be lower case.
16103  *
16104  * Returns: the hexadecimal representation of the HMAC. The
16105  *   returned string is owned by the HMAC and should not be modified
16106  *   or freed.
16107  * Since: 2.30
16108  */
16109
16110
16111 /**
16112  * g_hmac_new:
16113  * @digest_type: the desired type of digest
16114  * @key: (array length=key_len): the key for the HMAC
16115  * @key_len: the length of the keys
16116  *
16117  * Creates a new #GHmac, using the digest algorithm @digest_type.
16118  * If the @digest_type is not known, %NULL is returned.
16119  * A #GHmac can be used to compute the HMAC of a key and an
16120  * arbitrary binary blob, using different hashing algorithms.
16121  *
16122  * A #GHmac works by feeding a binary blob through g_hmac_update()
16123  * until the data is complete; the digest can then be extracted
16124  * using g_hmac_get_string(), which will return the checksum as a
16125  * hexadecimal string; or g_hmac_get_digest(), which will return a
16126  * array of raw bytes. Once either g_hmac_get_string() or
16127  * g_hmac_get_digest() have been called on a #GHmac, the HMAC
16128  * will be closed and it won't be possible to call g_hmac_update()
16129  * on it anymore.
16130  *
16131  * Returns: the newly created #GHmac, or %NULL.
16132  *   Use g_hmac_unref() to free the memory allocated by it.
16133  * Since: 2.30
16134  */
16135
16136
16137 /**
16138  * g_hmac_ref:
16139  * @hmac: a valid #GHmac
16140  *
16141  * Atomically increments the reference count of @hmac by one.
16142  *
16143  * This function is MT-safe and may be called from any thread.
16144  *
16145  * Returns: the passed in #GHmac.
16146  * Since: 2.30
16147  */
16148
16149
16150 /**
16151  * g_hmac_unref:
16152  * @hmac: a #GHmac
16153  *
16154  * Atomically decrements the reference count of @hmac by one.
16155  *
16156  * If the reference count drops to 0, all keys and values will be
16157  * destroyed, and all memory allocated by the hash table is released.
16158  * This function is MT-safe and may be called from any thread.
16159  * Frees the memory allocated for @hmac.
16160  *
16161  * Since: 2.30
16162  */
16163
16164
16165 /**
16166  * g_hmac_update:
16167  * @hmac: a #GHmac
16168  * @data: (array length=length): buffer used to compute the checksum
16169  * @length: size of the buffer, or -1 if it is a nul-terminated string
16170  *
16171  * Feeds @data into an existing #GHmac.
16172  *
16173  * The HMAC must still be open, that is g_hmac_get_string() or
16174  * g_hmac_get_digest() must not have been called on @hmac.
16175  *
16176  * Since: 2.30
16177  */
16178
16179
16180 /**
16181  * g_hook_alloc:
16182  * @hook_list: a #GHookList
16183  *
16184  * Allocates space for a #GHook and initializes it.
16185  *
16186  * Returns: a new #GHook
16187  */
16188
16189
16190 /**
16191  * g_hook_append:
16192  * @hook_list: a #GHookList
16193  * @hook: the #GHook to add to the end of @hook_list
16194  *
16195  * Appends a #GHook onto the end of a #GHookList.
16196  */
16197
16198
16199 /**
16200  * g_hook_compare_ids:
16201  * @new_hook: a #GHook
16202  * @sibling: a #GHook to compare with @new_hook
16203  *
16204  * Compares the ids of two #GHook elements, returning a negative value
16205  * if the second id is greater than the first.
16206  *
16207  * Returns: a value &lt;= 0 if the id of @sibling is >= the id of @new_hook
16208  */
16209
16210
16211 /**
16212  * g_hook_destroy:
16213  * @hook_list: a #GHookList
16214  * @hook_id: a hook ID
16215  *
16216  * Destroys a #GHook, given its ID.
16217  *
16218  * Returns: %TRUE if the #GHook was found in the #GHookList and destroyed
16219  */
16220
16221
16222 /**
16223  * g_hook_destroy_link:
16224  * @hook_list: a #GHookList
16225  * @hook: the #GHook to remove
16226  *
16227  * Removes one #GHook from a #GHookList, marking it
16228  * inactive and calling g_hook_unref() on it.
16229  */
16230
16231
16232 /**
16233  * g_hook_find:
16234  * @hook_list: a #GHookList
16235  * @need_valids: %TRUE if #GHook elements which have been destroyed
16236  *     should be skipped
16237  * @func: the function to call for each #GHook, which should return
16238  *     %TRUE when the #GHook has been found
16239  * @data: the data to pass to @func
16240  *
16241  * Finds a #GHook in a #GHookList using the given function to
16242  * test for a match.
16243  *
16244  * Returns: the found #GHook or %NULL if no matching #GHook is found
16245  */
16246
16247
16248 /**
16249  * g_hook_find_data:
16250  * @hook_list: a #GHookList
16251  * @need_valids: %TRUE if #GHook elements which have been destroyed
16252  *     should be skipped
16253  * @data: the data to find
16254  *
16255  * Finds a #GHook in a #GHookList with the given data.
16256  *
16257  * Returns: the #GHook with the given @data or %NULL if no matching
16258  *     #GHook is found
16259  */
16260
16261
16262 /**
16263  * g_hook_find_func:
16264  * @hook_list: a #GHookList
16265  * @need_valids: %TRUE if #GHook elements which have been destroyed
16266  *     should be skipped
16267  * @func: the function to find
16268  *
16269  * Finds a #GHook in a #GHookList with the given function.
16270  *
16271  * Returns: the #GHook with the given @func or %NULL if no matching
16272  *     #GHook is found
16273  */
16274
16275
16276 /**
16277  * g_hook_find_func_data:
16278  * @hook_list: a #GHookList
16279  * @need_valids: %TRUE if #GHook elements which have been destroyed
16280  *     should be skipped
16281  * @func: the function to find
16282  * @data: the data to find
16283  *
16284  * Finds a #GHook in a #GHookList with the given function and data.
16285  *
16286  * Returns: the #GHook with the given @func and @data or %NULL if
16287  *     no matching #GHook is found
16288  */
16289
16290
16291 /**
16292  * g_hook_first_valid:
16293  * @hook_list: a #GHookList
16294  * @may_be_in_call: %TRUE if hooks which are currently running
16295  *     (e.g. in another thread) are considered valid. If set to %FALSE,
16296  *     these are skipped
16297  *
16298  * Returns the first #GHook in a #GHookList which has not been destroyed.
16299  * The reference count for the #GHook is incremented, so you must call
16300  * g_hook_unref() to restore it when no longer needed. (Or call
16301  * g_hook_next_valid() if you are stepping through the #GHookList.)
16302  *
16303  * Returns: the first valid #GHook, or %NULL if none are valid
16304  */
16305
16306
16307 /**
16308  * g_hook_free:
16309  * @hook_list: a #GHookList
16310  * @hook: the #GHook to free
16311  *
16312  * Calls the #GHookList @finalize_hook function if it exists,
16313  * and frees the memory allocated for the #GHook.
16314  */
16315
16316
16317 /**
16318  * g_hook_get:
16319  * @hook_list: a #GHookList
16320  * @hook_id: a hook id
16321  *
16322  * Returns the #GHook with the given id, or %NULL if it is not found.
16323  *
16324  * Returns: the #GHook with the given id, or %NULL if it is not found
16325  */
16326
16327
16328 /**
16329  * g_hook_insert_before:
16330  * @hook_list: a #GHookList
16331  * @sibling: the #GHook to insert the new #GHook before
16332  * @hook: the #GHook to insert
16333  *
16334  * Inserts a #GHook into a #GHookList, before a given #GHook.
16335  */
16336
16337
16338 /**
16339  * g_hook_insert_sorted:
16340  * @hook_list: a #GHookList
16341  * @hook: the #GHook to insert
16342  * @func: the comparison function used to sort the #GHook elements
16343  *
16344  * Inserts a #GHook into a #GHookList, sorted by the given function.
16345  */
16346
16347
16348 /**
16349  * g_hook_list_clear:
16350  * @hook_list: a #GHookList
16351  *
16352  * Removes all the #GHook elements from a #GHookList.
16353  */
16354
16355
16356 /**
16357  * g_hook_list_init:
16358  * @hook_list: a #GHookList
16359  * @hook_size: the size of each element in the #GHookList,
16360  *     typically <literal>sizeof (GHook)</literal>
16361  *
16362  * Initializes a #GHookList.
16363  * This must be called before the #GHookList is used.
16364  */
16365
16366
16367 /**
16368  * g_hook_list_invoke:
16369  * @hook_list: a #GHookList
16370  * @may_recurse: %TRUE if functions which are already running
16371  *     (e.g. in another thread) can be called. If set to %FALSE,
16372  *     these are skipped
16373  *
16374  * Calls all of the #GHook functions in a #GHookList.
16375  */
16376
16377
16378 /**
16379  * g_hook_list_invoke_check:
16380  * @hook_list: a #GHookList
16381  * @may_recurse: %TRUE if functions which are already running
16382  *     (e.g. in another thread) can be called. If set to %FALSE,
16383  *     these are skipped
16384  *
16385  * Calls all of the #GHook functions in a #GHookList.
16386  * Any function which returns %FALSE is removed from the #GHookList.
16387  */
16388
16389
16390 /**
16391  * g_hook_list_marshal:
16392  * @hook_list: a #GHookList
16393  * @may_recurse: %TRUE if hooks which are currently running
16394  *     (e.g. in another thread) are considered valid. If set to %FALSE,
16395  *     these are skipped
16396  * @marshaller: the function to call for each #GHook
16397  * @marshal_data: data to pass to @marshaller
16398  *
16399  * Calls a function on each valid #GHook.
16400  */
16401
16402
16403 /**
16404  * g_hook_list_marshal_check:
16405  * @hook_list: a #GHookList
16406  * @may_recurse: %TRUE if hooks which are currently running
16407  *     (e.g. in another thread) are considered valid. If set to %FALSE,
16408  *     these are skipped
16409  * @marshaller: the function to call for each #GHook
16410  * @marshal_data: data to pass to @marshaller
16411  *
16412  * Calls a function on each valid #GHook and destroys it if the
16413  * function returns %FALSE.
16414  */
16415
16416
16417 /**
16418  * g_hook_next_valid:
16419  * @hook_list: a #GHookList
16420  * @hook: the current #GHook
16421  * @may_be_in_call: %TRUE if hooks which are currently running
16422  *     (e.g. in another thread) are considered valid. If set to %FALSE,
16423  *     these are skipped
16424  *
16425  * Returns the next #GHook in a #GHookList which has not been destroyed.
16426  * The reference count for the #GHook is incremented, so you must call
16427  * g_hook_unref() to restore it when no longer needed. (Or continue to call
16428  * g_hook_next_valid() until %NULL is returned.)
16429  *
16430  * Returns: the next valid #GHook, or %NULL if none are valid
16431  */
16432
16433
16434 /**
16435  * g_hook_prepend:
16436  * @hook_list: a #GHookList
16437  * @hook: the #GHook to add to the start of @hook_list
16438  *
16439  * Prepends a #GHook on the start of a #GHookList.
16440  */
16441
16442
16443 /**
16444  * g_hook_ref:
16445  * @hook_list: a #GHookList
16446  * @hook: the #GHook to increment the reference count of
16447  *
16448  * Increments the reference count for a #GHook.
16449  *
16450  * Returns: the @hook that was passed in (since 2.6)
16451  */
16452
16453
16454 /**
16455  * g_hook_unref:
16456  * @hook_list: a #GHookList
16457  * @hook: the #GHook to unref
16458  *
16459  * Decrements the reference count of a #GHook.
16460  * If the reference count falls to 0, the #GHook is removed
16461  * from the #GHookList and g_hook_free() is called to free it.
16462  */
16463
16464
16465 /**
16466  * g_hostname_is_ascii_encoded:
16467  * @hostname: a hostname
16468  *
16469  * Tests if @hostname contains segments with an ASCII-compatible
16470  * encoding of an Internationalized Domain Name. If this returns
16471  * %TRUE, you should decode the hostname with g_hostname_to_unicode()
16472  * before displaying it to the user.
16473  *
16474  * Note that a hostname might contain a mix of encoded and unencoded
16475  * segments, and so it is possible for g_hostname_is_non_ascii() and
16476  * g_hostname_is_ascii_encoded() to both return %TRUE for a name.
16477  *
16478  * Returns: %TRUE if @hostname contains any ASCII-encoded
16479  * segments.
16480  * Since: 2.22
16481  */
16482
16483
16484 /**
16485  * g_hostname_is_ip_address:
16486  * @hostname: a hostname (or IP address in string form)
16487  *
16488  * Tests if @hostname is the string form of an IPv4 or IPv6 address.
16489  * (Eg, "192.168.0.1".)
16490  *
16491  * Returns: %TRUE if @hostname is an IP address
16492  * Since: 2.22
16493  */
16494
16495
16496 /**
16497  * g_hostname_is_non_ascii:
16498  * @hostname: a hostname
16499  *
16500  * Tests if @hostname contains Unicode characters. If this returns
16501  * %TRUE, you need to encode the hostname with g_hostname_to_ascii()
16502  * before using it in non-IDN-aware contexts.
16503  *
16504  * Note that a hostname might contain a mix of encoded and unencoded
16505  * segments, and so it is possible for g_hostname_is_non_ascii() and
16506  * g_hostname_is_ascii_encoded() to both return %TRUE for a name.
16507  *
16508  * Returns: %TRUE if @hostname contains any non-ASCII characters
16509  * Since: 2.22
16510  */
16511
16512
16513 /**
16514  * g_hostname_to_ascii:
16515  * @hostname: a valid UTF-8 or ASCII hostname
16516  *
16517  * Converts @hostname to its canonical ASCII form; an ASCII-only
16518  * string containing no uppercase letters and not ending with a
16519  * trailing dot.
16520  *
16521  * Returns: an ASCII hostname, which must be freed, or %NULL if
16522  * @hostname is in some way invalid.
16523  * Since: 2.22
16524  */
16525
16526
16527 /**
16528  * g_hostname_to_unicode:
16529  * @hostname: a valid UTF-8 or ASCII hostname
16530  *
16531  * Converts @hostname to its canonical presentation form; a UTF-8
16532  * string in Unicode normalization form C, containing no uppercase
16533  * letters, no forbidden characters, and no ASCII-encoded segments,
16534  * and not ending with a trailing dot.
16535  *
16536  * Of course if @hostname is not an internationalized hostname, then
16537  * the canonical presentation form will be entirely ASCII.
16538  *
16539  * Returns: a UTF-8 hostname, which must be freed, or %NULL if
16540  * @hostname is in some way invalid.
16541  * Since: 2.22
16542  */
16543
16544
16545 /**
16546  * g_htonl:
16547  * @val: a 32-bit integer value in host byte order
16548  *
16549  * Converts a 32-bit integer value from host to network byte order.
16550  *
16551  * Returns: @val converted to network byte order
16552  */
16553
16554
16555 /**
16556  * g_htons:
16557  * @val: a 16-bit integer value in host byte order
16558  *
16559  * Converts a 16-bit integer value from host to network byte order.
16560  *
16561  * Returns: @val converted to network byte order
16562  */
16563
16564
16565 /**
16566  * g_iconv:
16567  * @converter: conversion descriptor from g_iconv_open()
16568  * @inbuf: bytes to convert
16569  * @inbytes_left: inout parameter, bytes remaining to convert in @inbuf
16570  * @outbuf: converted output bytes
16571  * @outbytes_left: inout parameter, bytes available to fill in @outbuf
16572  *
16573  * Same as the standard UNIX routine iconv(), but
16574  * may be implemented via libiconv on UNIX flavors that lack
16575  * a native implementation.
16576  *
16577  * GLib provides g_convert() and g_locale_to_utf8() which are likely
16578  * more convenient than the raw iconv wrappers.
16579  *
16580  * Returns: count of non-reversible conversions, or -1 on error
16581  */
16582
16583
16584 /**
16585  * g_iconv_close:
16586  * @converter: a conversion descriptor from g_iconv_open()
16587  *
16588  * Same as the standard UNIX routine iconv_close(), but
16589  * may be implemented via libiconv on UNIX flavors that lack
16590  * a native implementation. Should be called to clean up
16591  * the conversion descriptor from g_iconv_open() when
16592  * you are done converting things.
16593  *
16594  * GLib provides g_convert() and g_locale_to_utf8() which are likely
16595  * more convenient than the raw iconv wrappers.
16596  *
16597  * Returns: -1 on error, 0 on success
16598  */
16599
16600
16601 /**
16602  * g_iconv_open:
16603  * @to_codeset: destination codeset
16604  * @from_codeset: source codeset
16605  *
16606  * Same as the standard UNIX routine iconv_open(), but
16607  * may be implemented via libiconv on UNIX flavors that lack
16608  * a native implementation.
16609  *
16610  * GLib provides g_convert() and g_locale_to_utf8() which are likely
16611  * more convenient than the raw iconv wrappers.
16612  *
16613  * Returns: a "conversion descriptor", or (GIConv)-1 if
16614  *  opening the converter failed.
16615  */
16616
16617
16618 /**
16619  * g_idle_add:
16620  * @function: function to call
16621  * @data: data to pass to @function.
16622  *
16623  * Adds a function to be called whenever there are no higher priority
16624  * events pending to the default main loop. The function is given the
16625  * default idle priority, #G_PRIORITY_DEFAULT_IDLE.  If the function
16626  * returns %FALSE it is automatically removed from the list of event
16627  * sources and will not be called again.
16628  *
16629  * This internally creates a main loop source using g_idle_source_new()
16630  * and attaches it to the main loop context using g_source_attach().
16631  * You can do these steps manually if you need greater control.
16632  *
16633  * Returns: the ID (greater than 0) of the event source.
16634  */
16635
16636
16637 /**
16638  * g_idle_add_full: (rename-to g_idle_add)
16639  * @priority: the priority of the idle source. Typically this will be in the
16640  *            range between #G_PRIORITY_DEFAULT_IDLE and #G_PRIORITY_HIGH_IDLE.
16641  * @function: function to call
16642  * @data: data to pass to @function
16643  * @notify: (allow-none): function to call when the idle is removed, or %NULL
16644  *
16645  * Adds a function to be called whenever there are no higher priority
16646  * events pending.  If the function returns %FALSE it is automatically
16647  * removed from the list of event sources and will not be called again.
16648  *
16649  * This internally creates a main loop source using g_idle_source_new()
16650  * and attaches it to the main loop context using g_source_attach().
16651  * You can do these steps manually if you need greater control.
16652  *
16653  * Returns: the ID (greater than 0) of the event source.
16654  */
16655
16656
16657 /**
16658  * g_idle_remove_by_data:
16659  * @data: the data for the idle source's callback.
16660  *
16661  * Removes the idle function with the given data.
16662  *
16663  * Returns: %TRUE if an idle source was found and removed.
16664  */
16665
16666
16667 /**
16668  * g_idle_source_new:
16669  *
16670  * Creates a new idle source.
16671  *
16672  * The source will not initially be associated with any #GMainContext
16673  * and must be added to one with g_source_attach() before it will be
16674  * executed. Note that the default priority for idle sources is
16675  * %G_PRIORITY_DEFAULT_IDLE, as compared to other sources which
16676  * have a default priority of %G_PRIORITY_DEFAULT.
16677  *
16678  * Returns: the newly-created idle source
16679  */
16680
16681
16682 /**
16683  * g_int64_equal:
16684  * @v1: a pointer to a #gint64 key
16685  * @v2: a pointer to a #gint64 key to compare with @v1
16686  *
16687  * Compares the two #gint64 values being pointed to and returns
16688  * %TRUE if they are equal.
16689  * It can be passed to g_hash_table_new() as the @key_equal_func
16690  * parameter, when using non-%NULL pointers to 64-bit integers as keys in a
16691  * #GHashTable.
16692  *
16693  * Returns: %TRUE if the two keys match.
16694  * Since: 2.22
16695  */
16696
16697
16698 /**
16699  * g_int64_hash:
16700  * @v: a pointer to a #gint64 key
16701  *
16702  * Converts a pointer to a #gint64 to a hash value.
16703  *
16704  * It can be passed to g_hash_table_new() as the @hash_func parameter,
16705  * when using non-%NULL pointers to 64-bit integer values as keys in a
16706  * #GHashTable.
16707  *
16708  * Returns: a hash value corresponding to the key.
16709  * Since: 2.22
16710  */
16711
16712
16713 /**
16714  * g_int_equal:
16715  * @v1: a pointer to a #gint key
16716  * @v2: a pointer to a #gint key to compare with @v1
16717  *
16718  * Compares the two #gint values being pointed to and returns
16719  * %TRUE if they are equal.
16720  * It can be passed to g_hash_table_new() as the @key_equal_func
16721  * parameter, when using non-%NULL pointers to integers as keys in a
16722  * #GHashTable.
16723  *
16724  * Note that this function acts on pointers to #gint, not on #gint directly:
16725  * if your hash table's keys are of the form
16726  * <literal>GINT_TO_POINTER (n)</literal>, use g_direct_equal() instead.
16727  *
16728  * Returns: %TRUE if the two keys match.
16729  */
16730
16731
16732 /**
16733  * g_int_hash:
16734  * @v: a pointer to a #gint key
16735  *
16736  * Converts a pointer to a #gint to a hash value.
16737  * It can be passed to g_hash_table_new() as the @hash_func parameter,
16738  * when using non-%NULL pointers to integer values as keys in a #GHashTable.
16739  *
16740  * Note that this function acts on pointers to #gint, not on #gint directly:
16741  * if your hash table's keys are of the form
16742  * <literal>GINT_TO_POINTER (n)</literal>, use g_direct_hash() instead.
16743  *
16744  * Returns: a hash value corresponding to the key.
16745  */
16746
16747
16748 /**
16749  * g_intern_static_string:
16750  * @string: (allow-none): a static string
16751  *
16752  * Returns a canonical representation for @string. Interned strings
16753  * can be compared for equality by comparing the pointers, instead of
16754  * using strcmp(). g_intern_static_string() does not copy the string,
16755  * therefore @string must not be freed or modified.
16756  *
16757  * Returns: a canonical representation for the string
16758  * Since: 2.10
16759  */
16760
16761
16762 /**
16763  * g_intern_string:
16764  * @string: (allow-none): a string
16765  *
16766  * Returns a canonical representation for @string. Interned strings
16767  * can be compared for equality by comparing the pointers, instead of
16768  * using strcmp().
16769  *
16770  * Returns: a canonical representation for the string
16771  * Since: 2.10
16772  */
16773
16774
16775 /**
16776  * g_io_add_watch:
16777  * @channel: a #GIOChannel
16778  * @condition: the condition to watch for
16779  * @func: the function to call when the condition is satisfied
16780  * @user_data: user data to pass to @func
16781  *
16782  * Adds the #GIOChannel into the default main loop context
16783  * with the default priority.
16784  *
16785  * Returns: the event source id
16786  */
16787
16788
16789 /**
16790  * g_io_add_watch_full: (rename-to g_io_add_watch)
16791  * @channel: a #GIOChannel
16792  * @priority: the priority of the #GIOChannel source
16793  * @condition: the condition to watch for
16794  * @func: the function to call when the condition is satisfied
16795  * @user_data: user data to pass to @func
16796  * @notify: the function to call when the source is removed
16797  *
16798  * Adds the #GIOChannel into the default main loop context
16799  * with the given priority.
16800  *
16801  * This internally creates a main loop source using g_io_create_watch()
16802  * and attaches it to the main loop context with g_source_attach().
16803  * You can do these steps manually if you need greater control.
16804  *
16805  * Returns: the event source id
16806  */
16807
16808
16809 /**
16810  * g_io_channel_close:
16811  * @channel: A #GIOChannel
16812  *
16813  * Close an IO channel. Any pending data to be written will be
16814  * flushed, ignoring errors. The channel will not be freed until the
16815  * last reference is dropped using g_io_channel_unref().
16816  *
16817  * Deprecated: 2.2: Use g_io_channel_shutdown() instead.
16818  */
16819
16820
16821 /**
16822  * g_io_channel_error_from_errno:
16823  * @en: an <literal>errno</literal> error number, e.g. <literal>EINVAL</literal>
16824  *
16825  * Converts an <literal>errno</literal> error number to a #GIOChannelError.
16826  *
16827  * Returns: a #GIOChannelError error number, e.g.
16828  *      %G_IO_CHANNEL_ERROR_INVAL.
16829  */
16830
16831
16832 /**
16833  * g_io_channel_error_quark:
16834  *
16835  * Returns: the quark used as %G_IO_CHANNEL_ERROR
16836  */
16837
16838
16839 /**
16840  * g_io_channel_flush:
16841  * @channel: a #GIOChannel
16842  * @error: location to store an error of type #GIOChannelError
16843  *
16844  * Flushes the write buffer for the GIOChannel.
16845  *
16846  * Returns: the status of the operation: One of
16847  *   #G_IO_STATUS_NORMAL, #G_IO_STATUS_AGAIN, or
16848  *   #G_IO_STATUS_ERROR.
16849  */
16850
16851
16852 /**
16853  * g_io_channel_get_buffer_condition:
16854  * @channel: A #GIOChannel
16855  *
16856  * This function returns a #GIOCondition depending on whether there
16857  * is data to be read/space to write data in the internal buffers in
16858  * the #GIOChannel. Only the flags %G_IO_IN and %G_IO_OUT may be set.
16859  *
16860  * Returns: A #GIOCondition
16861  */
16862
16863
16864 /**
16865  * g_io_channel_get_buffer_size:
16866  * @channel: a #GIOChannel
16867  *
16868  * Gets the buffer size.
16869  *
16870  * Returns: the size of the buffer.
16871  */
16872
16873
16874 /**
16875  * g_io_channel_get_buffered:
16876  * @channel: a #GIOChannel
16877  *
16878  * Returns whether @channel is buffered.
16879  *
16880  * Returns: %TRUE if the @channel is buffered.
16881  */
16882
16883
16884 /**
16885  * g_io_channel_get_close_on_unref:
16886  * @channel: a #GIOChannel.
16887  *
16888  * Returns whether the file/socket/whatever associated with @channel
16889  * will be closed when @channel receives its final unref and is
16890  * destroyed. The default value of this is %TRUE for channels created
16891  * by g_io_channel_new_file (), and %FALSE for all other channels.
16892  *
16893  * Returns: Whether the channel will be closed on the final unref of
16894  *               the GIOChannel data structure.
16895  */
16896
16897
16898 /**
16899  * g_io_channel_get_encoding:
16900  * @channel: a #GIOChannel
16901  *
16902  * Gets the encoding for the input/output of the channel.
16903  * The internal encoding is always UTF-8. The encoding %NULL
16904  * makes the channel safe for binary data.
16905  *
16906  * Returns: A string containing the encoding, this string is
16907  *   owned by GLib and must not be freed.
16908  */
16909
16910
16911 /**
16912  * g_io_channel_get_flags:
16913  * @channel: a #GIOChannel
16914  *
16915  * Gets the current flags for a #GIOChannel, including read-only
16916  * flags such as %G_IO_FLAG_IS_READABLE.
16917  *
16918  * The values of the flags %G_IO_FLAG_IS_READABLE and %G_IO_FLAG_IS_WRITABLE
16919  * are cached for internal use by the channel when it is created.
16920  * If they should change at some later point (e.g. partial shutdown
16921  * of a socket with the UNIX shutdown() function), the user
16922  * should immediately call g_io_channel_get_flags() to update
16923  * the internal values of these flags.
16924  *
16925  * Returns: the flags which are set on the channel
16926  */
16927
16928
16929 /**
16930  * g_io_channel_get_line_term:
16931  * @channel: a #GIOChannel
16932  * @length: a location to return the length of the line terminator
16933  *
16934  * This returns the string that #GIOChannel uses to determine
16935  * where in the file a line break occurs. A value of %NULL
16936  * indicates autodetection.
16937  *
16938  * Returns: The line termination string. This value
16939  *   is owned by GLib and must not be freed.
16940  */
16941
16942
16943 /**
16944  * g_io_channel_init:
16945  * @channel: a #GIOChannel
16946  *
16947  * Initializes a #GIOChannel struct.
16948  *
16949  * This is called by each of the above functions when creating a
16950  * #GIOChannel, and so is not often needed by the application
16951  * programmer (unless you are creating a new type of #GIOChannel).
16952  */
16953
16954
16955 /**
16956  * g_io_channel_new_file:
16957  * @filename: A string containing the name of a file
16958  * @mode: One of "r", "w", "a", "r+", "w+", "a+". These have
16959  *        the same meaning as in fopen()
16960  * @error: A location to return an error of type %G_FILE_ERROR
16961  *
16962  * Open a file @filename as a #GIOChannel using mode @mode. This
16963  * channel will be closed when the last reference to it is dropped,
16964  * so there is no need to call g_io_channel_close() (though doing
16965  * so will not cause problems, as long as no attempt is made to
16966  * access the channel after it is closed).
16967  *
16968  * Returns: A #GIOChannel on success, %NULL on failure.
16969  */
16970
16971
16972 /**
16973  * g_io_channel_read:
16974  * @channel: a #GIOChannel
16975  * @buf: a buffer to read the data into (which should be at least
16976  *       count bytes long)
16977  * @count: the number of bytes to read from the #GIOChannel
16978  * @bytes_read: returns the number of bytes actually read
16979  *
16980  * Reads data from a #GIOChannel.
16981  *
16982  * Returns: %G_IO_ERROR_NONE if the operation was successful.
16983  * Deprecated: 2.2: Use g_io_channel_read_chars() instead.
16984  */
16985
16986
16987 /**
16988  * g_io_channel_read_chars:
16989  * @channel: a #GIOChannel
16990  * @buf: (out caller-allocates) (array length=count) (element-type guint8):
16991  *     a buffer to read data into
16992  * @count: (in): the size of the buffer. Note that the buffer may not be
16993  *     complelely filled even if there is data in the buffer if the
16994  *     remaining data is not a complete character.
16995  * @bytes_read: (allow-none) (out): The number of bytes read. This may be
16996  *     zero even on success if count < 6 and the channel's encoding
16997  *     is non-%NULL. This indicates that the next UTF-8 character is
16998  *     too wide for the buffer.
16999  * @error: a location to return an error of type #GConvertError
17000  *     or #GIOChannelError.
17001  *
17002  * Replacement for g_io_channel_read() with the new API.
17003  *
17004  * Returns: the status of the operation.
17005  */
17006
17007
17008 /**
17009  * g_io_channel_read_line:
17010  * @channel: a #GIOChannel
17011  * @str_return: (out): The line read from the #GIOChannel, including the
17012  *              line terminator. This data should be freed with g_free()
17013  *              when no longer needed. This is a nul-terminated string.
17014  *              If a @length of zero is returned, this will be %NULL instead.
17015  * @length: (allow-none) (out): location to store length of the read data, or %NULL
17016  * @terminator_pos: (allow-none) (out): location to store position of line terminator, or %NULL
17017  * @error: A location to return an error of type #GConvertError
17018  *         or #GIOChannelError
17019  *
17020  * Reads a line, including the terminating character(s),
17021  * from a #GIOChannel into a newly-allocated string.
17022  * @str_return will contain allocated memory if the return
17023  * is %G_IO_STATUS_NORMAL.
17024  *
17025  * Returns: the status of the operation.
17026  */
17027
17028
17029 /**
17030  * g_io_channel_read_line_string:
17031  * @channel: a #GIOChannel
17032  * @buffer: a #GString into which the line will be written.
17033  *          If @buffer already contains data, the old data will
17034  *          be overwritten.
17035  * @terminator_pos: (allow-none): location to store position of line terminator, or %NULL
17036  * @error: a location to store an error of type #GConvertError
17037  *         or #GIOChannelError
17038  *
17039  * Reads a line from a #GIOChannel, using a #GString as a buffer.
17040  *
17041  * Returns: the status of the operation.
17042  */
17043
17044
17045 /**
17046  * g_io_channel_read_to_end:
17047  * @channel: a #GIOChannel
17048  * @str_return: (out) (array length=length) (element-type guint8): Location to
17049  *              store a pointer to a string holding the remaining data in the
17050  *              #GIOChannel. This data should be freed with g_free() when no
17051  *              longer needed. This data is terminated by an extra nul
17052  *              character, but there may be other nuls in the intervening data.
17053  * @length: (out): location to store length of the data
17054  * @error: location to return an error of type #GConvertError
17055  *         or #GIOChannelError
17056  *
17057  * Reads all the remaining data from the file.
17058  *
17059  * Returns: %G_IO_STATUS_NORMAL on success.
17060  *     This function never returns %G_IO_STATUS_EOF.
17061  */
17062
17063
17064 /**
17065  * g_io_channel_read_unichar:
17066  * @channel: a #GIOChannel
17067  * @thechar: (out): a location to return a character
17068  * @error: a location to return an error of type #GConvertError
17069  *         or #GIOChannelError
17070  *
17071  * Reads a Unicode character from @channel.
17072  * This function cannot be called on a channel with %NULL encoding.
17073  *
17074  * Returns: a #GIOStatus
17075  */
17076
17077
17078 /**
17079  * g_io_channel_ref:
17080  * @channel: a #GIOChannel
17081  *
17082  * Increments the reference count of a #GIOChannel.
17083  *
17084  * Returns: the @channel that was passed in (since 2.6)
17085  */
17086
17087
17088 /**
17089  * g_io_channel_seek:
17090  * @channel: a #GIOChannel
17091  * @offset: an offset, in bytes, which is added to the position specified
17092  *          by @type
17093  * @type: the position in the file, which can be %G_SEEK_CUR (the current
17094  *        position), %G_SEEK_SET (the start of the file), or %G_SEEK_END
17095  *        (the end of the file)
17096  *
17097  * Sets the current position in the #GIOChannel, similar to the standard
17098  * library function fseek().
17099  *
17100  * Returns: %G_IO_ERROR_NONE if the operation was successful.
17101  * Deprecated: 2.2: Use g_io_channel_seek_position() instead.
17102  */
17103
17104
17105 /**
17106  * g_io_channel_seek_position:
17107  * @channel: a #GIOChannel
17108  * @offset: The offset in bytes from the position specified by @type
17109  * @type: a #GSeekType. The type %G_SEEK_CUR is only allowed in those
17110  *                      cases where a call to g_io_channel_set_encoding ()
17111  *                      is allowed. See the documentation for
17112  *                      g_io_channel_set_encoding () for details.
17113  * @error: A location to return an error of type #GIOChannelError
17114  *
17115  * Replacement for g_io_channel_seek() with the new API.
17116  *
17117  * Returns: the status of the operation.
17118  */
17119
17120
17121 /**
17122  * g_io_channel_set_buffer_size:
17123  * @channel: a #GIOChannel
17124  * @size: the size of the buffer, or 0 to let GLib pick a good size
17125  *
17126  * Sets the buffer size.
17127  */
17128
17129
17130 /**
17131  * g_io_channel_set_buffered:
17132  * @channel: a #GIOChannel
17133  * @buffered: whether to set the channel buffered or unbuffered
17134  *
17135  * The buffering state can only be set if the channel's encoding
17136  * is %NULL. For any other encoding, the channel must be buffered.
17137  *
17138  * A buffered channel can only be set unbuffered if the channel's
17139  * internal buffers have been flushed. Newly created channels or
17140  * channels which have returned %G_IO_STATUS_EOF
17141  * not require such a flush. For write-only channels, a call to
17142  * g_io_channel_flush () is sufficient. For all other channels,
17143  * the buffers may be flushed by a call to g_io_channel_seek_position ().
17144  * This includes the possibility of seeking with seek type %G_SEEK_CUR
17145  * and an offset of zero. Note that this means that socket-based
17146  * channels cannot be set unbuffered once they have had data
17147  * read from them.
17148  *
17149  * On unbuffered channels, it is safe to mix read and write
17150  * calls from the new and old APIs, if this is necessary for
17151  * maintaining old code.
17152  *
17153  * The default state of the channel is buffered.
17154  */
17155
17156
17157 /**
17158  * g_io_channel_set_close_on_unref:
17159  * @channel: a #GIOChannel
17160  * @do_close: Whether to close the channel on the final unref of
17161  *            the GIOChannel data structure. The default value of
17162  *            this is %TRUE for channels created by g_io_channel_new_file (),
17163  *            and %FALSE for all other channels.
17164  *
17165  * Setting this flag to %TRUE for a channel you have already closed
17166  * can cause problems.
17167  */
17168
17169
17170 /**
17171  * g_io_channel_set_encoding:
17172  * @channel: a #GIOChannel
17173  * @encoding: (allow-none): the encoding type
17174  * @error: location to store an error of type #GConvertError
17175  *
17176  * Sets the encoding for the input/output of the channel.
17177  * The internal encoding is always UTF-8. The default encoding
17178  * for the external file is UTF-8.
17179  *
17180  * The encoding %NULL is safe to use with binary data.
17181  *
17182  * The encoding can only be set if one of the following conditions
17183  * is true:
17184  * <itemizedlist>
17185  * <listitem><para>
17186  *    The channel was just created, and has not been written to or read
17187  *    from yet.
17188  * </para></listitem>
17189  * <listitem><para>
17190  *    The channel is write-only.
17191  * </para></listitem>
17192  * <listitem><para>
17193  *    The channel is a file, and the file pointer was just
17194  *    repositioned by a call to g_io_channel_seek_position().
17195  *    (This flushes all the internal buffers.)
17196  * </para></listitem>
17197  * <listitem><para>
17198  *    The current encoding is %NULL or UTF-8.
17199  * </para></listitem>
17200  * <listitem><para>
17201  *    One of the (new API) read functions has just returned %G_IO_STATUS_EOF
17202  *    (or, in the case of g_io_channel_read_to_end(), %G_IO_STATUS_NORMAL).
17203  * </para></listitem>
17204  * <listitem><para>
17205  *    One of the functions g_io_channel_read_chars() or
17206  *    g_io_channel_read_unichar() has returned %G_IO_STATUS_AGAIN or
17207  *    %G_IO_STATUS_ERROR. This may be useful in the case of
17208  *    %G_CONVERT_ERROR_ILLEGAL_SEQUENCE.
17209  *    Returning one of these statuses from g_io_channel_read_line(),
17210  *    g_io_channel_read_line_string(), or g_io_channel_read_to_end()
17211  *    does <emphasis>not</emphasis> guarantee that the encoding can
17212  *    be changed.
17213  * </para></listitem>
17214  * </itemizedlist>
17215  * Channels which do not meet one of the above conditions cannot call
17216  * g_io_channel_seek_position() with an offset of %G_SEEK_CUR, and, if
17217  * they are "seekable", cannot call g_io_channel_write_chars() after
17218  * calling one of the API "read" functions.
17219  *
17220  * Returns: %G_IO_STATUS_NORMAL if the encoding was successfully set.
17221  */
17222
17223
17224 /**
17225  * g_io_channel_set_flags:
17226  * @channel: a #GIOChannel
17227  * @flags: the flags to set on the IO channel
17228  * @error: A location to return an error of type #GIOChannelError
17229  *
17230  * Sets the (writeable) flags in @channel to (@flags & %G_IO_FLAG_SET_MASK).
17231  *
17232  * Returns: the status of the operation.
17233  */
17234
17235
17236 /**
17237  * g_io_channel_set_line_term:
17238  * @channel: a #GIOChannel
17239  * @line_term: (allow-none): The line termination string. Use %NULL for
17240  *             autodetect.  Autodetection breaks on "\n", "\r\n", "\r", "\0",
17241  *             and the Unicode paragraph separator. Autodetection should not be
17242  *             used for anything other than file-based channels.
17243  * @length: The length of the termination string. If -1 is passed, the
17244  *          string is assumed to be nul-terminated. This option allows
17245  *          termination strings with embedded nuls.
17246  *
17247  * This sets the string that #GIOChannel uses to determine
17248  * where in the file a line break occurs.
17249  */
17250
17251
17252 /**
17253  * g_io_channel_shutdown:
17254  * @channel: a #GIOChannel
17255  * @flush: if %TRUE, flush pending
17256  * @err: location to store a #GIOChannelError
17257  *
17258  * Close an IO channel. Any pending data to be written will be
17259  * flushed if @flush is %TRUE. The channel will not be freed until the
17260  * last reference is dropped using g_io_channel_unref().
17261  *
17262  * Returns: the status of the operation.
17263  */
17264
17265
17266 /**
17267  * g_io_channel_unix_get_fd:
17268  * @channel: a #GIOChannel, created with g_io_channel_unix_new().
17269  *
17270  * Returns the file descriptor of the #GIOChannel.
17271  *
17272  * On Windows this function returns the file descriptor or socket of
17273  * the #GIOChannel.
17274  *
17275  * Returns: the file descriptor of the #GIOChannel.
17276  */
17277
17278
17279 /**
17280  * g_io_channel_unix_new:
17281  * @fd: a file descriptor.
17282  *
17283  * Creates a new #GIOChannel given a file descriptor. On UNIX systems
17284  * this works for plain files, pipes, and sockets.
17285  *
17286  * The returned #GIOChannel has a reference count of 1.
17287  *
17288  * The default encoding for #GIOChannel is UTF-8. If your application
17289  * is reading output from a command using via pipe, you may need to set
17290  * the encoding to the encoding of the current locale (see
17291  * g_get_charset()) with the g_io_channel_set_encoding() function.
17292  *
17293  * If you want to read raw binary data without interpretation, then
17294  * call the g_io_channel_set_encoding() function with %NULL for the
17295  * encoding argument.
17296  *
17297  * This function is available in GLib on Windows, too, but you should
17298  * avoid using it on Windows. The domain of file descriptors and
17299  * sockets overlap. There is no way for GLib to know which one you mean
17300  * in case the argument you pass to this function happens to be both a
17301  * valid file descriptor and socket. If that happens a warning is
17302  * issued, and GLib assumes that it is the file descriptor you mean.
17303  *
17304  * Returns: a new #GIOChannel.
17305  */
17306
17307
17308 /**
17309  * g_io_channel_unref:
17310  * @channel: a #GIOChannel
17311  *
17312  * Decrements the reference count of a #GIOChannel.
17313  */
17314
17315
17316 /**
17317  * g_io_channel_win32_new_fd:
17318  * @fd: a C library file descriptor.
17319  *
17320  * Creates a new #GIOChannel given a file descriptor on Windows. This
17321  * works for file descriptors from the C runtime.
17322  *
17323  * This function works for file descriptors as returned by the open(),
17324  * creat(), pipe() and fileno() calls in the Microsoft C runtime. In
17325  * order to meaningfully use this function your code should use the
17326  * same C runtime as GLib uses, which is msvcrt.dll. Note that in
17327  * current Microsoft compilers it is near impossible to convince it to
17328  * build code that would use msvcrt.dll. The last Microsoft compiler
17329  * version that supported using msvcrt.dll as the C runtime was version
17330  * 6. The GNU compiler and toolchain for Windows, also known as Mingw,
17331  * fully supports msvcrt.dll.
17332  *
17333  * If you have created a #GIOChannel for a file descriptor and started
17334  * watching (polling) it, you shouldn't call read() on the file
17335  * descriptor. This is because adding polling for a file descriptor is
17336  * implemented in GLib on Windows by starting a thread that sits
17337  * blocked in a read() from the file descriptor most of the time. All
17338  * reads from the file descriptor should be done by this internal GLib
17339  * thread. Your code should call only g_io_channel_read().
17340  *
17341  * This function is available only in GLib on Windows.
17342  *
17343  * Returns: a new #GIOChannel.
17344  */
17345
17346
17347 /**
17348  * g_io_channel_win32_new_messages:
17349  * @hwnd: a window handle.
17350  *
17351  * Creates a new #GIOChannel given a window handle on Windows.
17352  *
17353  * This function creates a #GIOChannel that can be used to poll for
17354  * Windows messages for the window in question.
17355  *
17356  * Returns: a new #GIOChannel.
17357  */
17358
17359
17360 /**
17361  * g_io_channel_win32_new_socket:
17362  * @socket: a Winsock socket
17363  *
17364  * Creates a new #GIOChannel given a socket on Windows.
17365  *
17366  * This function works for sockets created by Winsock. It's available
17367  * only in GLib on Windows.
17368  *
17369  * Polling a #GSource created to watch a channel for a socket puts the
17370  * socket in non-blocking mode. This is a side-effect of the
17371  * implementation and unavoidable.
17372  *
17373  * Returns: a new #GIOChannel
17374  */
17375
17376
17377 /**
17378  * g_io_channel_write:
17379  * @channel: a #GIOChannel
17380  * @buf: the buffer containing the data to write
17381  * @count: the number of bytes to write
17382  * @bytes_written: the number of bytes actually written
17383  *
17384  * Writes data to a #GIOChannel.
17385  *
17386  * Returns: %G_IO_ERROR_NONE if the operation was successful.
17387  * Deprecated: 2.2: Use g_io_channel_write_chars() instead.
17388  */
17389
17390
17391 /**
17392  * g_io_channel_write_chars:
17393  * @channel: a #GIOChannel
17394  * @buf: (array) (element-type guint8): a buffer to write data from
17395  * @count: the size of the buffer. If -1, the buffer
17396  *         is taken to be a nul-terminated string.
17397  * @bytes_written: (out): The number of bytes written. This can be nonzero
17398  *                 even if the return value is not %G_IO_STATUS_NORMAL.
17399  *                 If the return value is %G_IO_STATUS_NORMAL and the
17400  *                 channel is blocking, this will always be equal
17401  *                 to @count if @count >= 0.
17402  * @error: a location to return an error of type #GConvertError
17403  *         or #GIOChannelError
17404  *
17405  * Replacement for g_io_channel_write() with the new API.
17406  *
17407  * On seekable channels with encodings other than %NULL or UTF-8, generic
17408  * mixing of reading and writing is not allowed. A call to g_io_channel_write_chars ()
17409  * may only be made on a channel from which data has been read in the
17410  * cases described in the documentation for g_io_channel_set_encoding ().
17411  *
17412  * Returns: the status of the operation.
17413  */
17414
17415
17416 /**
17417  * g_io_channel_write_unichar:
17418  * @channel: a #GIOChannel
17419  * @thechar: a character
17420  * @error: location to return an error of type #GConvertError
17421  *         or #GIOChannelError
17422  *
17423  * Writes a Unicode character to @channel.
17424  * This function cannot be called on a channel with %NULL encoding.
17425  *
17426  * Returns: a #GIOStatus
17427  */
17428
17429
17430 /**
17431  * g_io_create_watch:
17432  * @channel: a #GIOChannel to watch
17433  * @condition: conditions to watch for
17434  *
17435  * Creates a #GSource that's dispatched when @condition is met for the
17436  * given @channel. For example, if condition is #G_IO_IN, the source will
17437  * be dispatched when there's data available for reading.
17438  *
17439  * g_io_add_watch() is a simpler interface to this same functionality, for
17440  * the case where you want to add the source to the default main loop context
17441  * at the default priority.
17442  *
17443  * On Windows, polling a #GSource created to watch a channel for a socket
17444  * puts the socket in non-blocking mode. This is a side-effect of the
17445  * implementation and unavoidable.
17446  *
17447  * Returns: a new #GSource
17448  */
17449
17450
17451 /**
17452  * g_key_file_free: (skip)
17453  * @key_file: a #GKeyFile
17454  *
17455  * Clears all keys and groups from @key_file, and decreases the
17456  * reference count by 1. If the reference count reaches zero,
17457  * frees the key file and all its allocated memory.
17458  *
17459  * Since: 2.6
17460  */
17461
17462
17463 /**
17464  * g_key_file_get_boolean:
17465  * @key_file: a #GKeyFile
17466  * @group_name: a group name
17467  * @key: a key
17468  * @error: return location for a #GError
17469  *
17470  * Returns the value associated with @key under @group_name as a
17471  * boolean.
17472  *
17473  * If @key cannot be found then %FALSE is returned and @error is set
17474  * to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the value
17475  * associated with @key cannot be interpreted as a boolean then %FALSE
17476  * is returned and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
17477  *
17478  * Returns: the value associated with the key as a boolean,
17479  *    or %FALSE if the key was not found or could not be parsed.
17480  * Since: 2.6
17481  */
17482
17483
17484 /**
17485  * g_key_file_get_boolean_list:
17486  * @key_file: a #GKeyFile
17487  * @group_name: a group name
17488  * @key: a key
17489  * @length: (out): the number of booleans returned
17490  * @error: return location for a #GError
17491  *
17492  * Returns the values associated with @key under @group_name as
17493  * booleans.
17494  *
17495  * If @key cannot be found then %NULL is returned and @error is set to
17496  * #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the values associated
17497  * with @key cannot be interpreted as booleans then %NULL is returned
17498  * and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
17499  *
17500  * Returns: (array length=length) (element-type gboolean) (transfer container):
17501  *    the values associated with the key as a list of booleans, or %NULL if the
17502  *    key was not found or could not be parsed. The returned list of booleans
17503  *    should be freed with g_free() when no longer needed.
17504  * Since: 2.6
17505  */
17506
17507
17508 /**
17509  * g_key_file_get_comment:
17510  * @key_file: a #GKeyFile
17511  * @group_name: (allow-none): a group name, or %NULL
17512  * @key: a key
17513  * @error: return location for a #GError
17514  *
17515  * Retrieves a comment above @key from @group_name.
17516  * If @key is %NULL then @comment will be read from above
17517  * @group_name. If both @key and @group_name are %NULL, then
17518  * @comment will be read from above the first group in the file.
17519  *
17520  * Returns: a comment that should be freed with g_free()
17521  * Since: 2.6
17522  */
17523
17524
17525 /**
17526  * g_key_file_get_double:
17527  * @key_file: a #GKeyFile
17528  * @group_name: a group name
17529  * @key: a key
17530  * @error: return location for a #GError
17531  *
17532  * Returns the value associated with @key under @group_name as a
17533  * double. If @group_name is %NULL, the start_group is used.
17534  *
17535  * If @key cannot be found then 0.0 is returned and @error is set to
17536  * #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the value associated
17537  * with @key cannot be interpreted as a double then 0.0 is returned
17538  * and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
17539  *
17540  * Returns: the value associated with the key as a double, or
17541  *     0.0 if the key was not found or could not be parsed.
17542  * Since: 2.12
17543  */
17544
17545
17546 /**
17547  * g_key_file_get_double_list:
17548  * @key_file: a #GKeyFile
17549  * @group_name: a group name
17550  * @key: a key
17551  * @length: (out): the number of doubles returned
17552  * @error: return location for a #GError
17553  *
17554  * Returns the values associated with @key under @group_name as
17555  * doubles.
17556  *
17557  * If @key cannot be found then %NULL is returned and @error is set to
17558  * #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the values associated
17559  * with @key cannot be interpreted as doubles then %NULL is returned
17560  * and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
17561  *
17562  * Returns: (array length=length) (element-type gdouble) (transfer container):
17563  *     the values associated with the key as a list of doubles, or %NULL if the
17564  *     key was not found or could not be parsed. The returned list of doubles
17565  *     should be freed with g_free() when no longer needed.
17566  * Since: 2.12
17567  */
17568
17569
17570 /**
17571  * g_key_file_get_groups:
17572  * @key_file: a #GKeyFile
17573  * @length: (out) (allow-none): return location for the number of returned groups, or %NULL
17574  *
17575  * Returns all groups in the key file loaded with @key_file.
17576  * The array of returned groups will be %NULL-terminated, so
17577  * @length may optionally be %NULL.
17578  *
17579  * Returns: (array zero-terminated=1) (transfer full): a newly-allocated %NULL-terminated array of strings.
17580  *   Use g_strfreev() to free it.
17581  * Since: 2.6
17582  */
17583
17584
17585 /**
17586  * g_key_file_get_int64:
17587  * @key_file: a non-%NULL #GKeyFile
17588  * @group_name: a non-%NULL group name
17589  * @key: a non-%NULL key
17590  * @error: return location for a #GError
17591  *
17592  * Returns the value associated with @key under @group_name as a signed
17593  * 64-bit integer. This is similar to g_key_file_get_integer() but can return
17594  * 64-bit results without truncation.
17595  *
17596  * Returns: the value associated with the key as a signed 64-bit integer, or
17597  * 0 if the key was not found or could not be parsed.
17598  * Since: 2.26
17599  */
17600
17601
17602 /**
17603  * g_key_file_get_integer:
17604  * @key_file: a #GKeyFile
17605  * @group_name: a group name
17606  * @key: a key
17607  * @error: return location for a #GError
17608  *
17609  * Returns the value associated with @key under @group_name as an
17610  * integer.
17611  *
17612  * If @key cannot be found then 0 is returned and @error is set to
17613  * #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the value associated
17614  * with @key cannot be interpreted as an integer then 0 is returned
17615  * and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
17616  *
17617  * Returns: the value associated with the key as an integer, or
17618  *     0 if the key was not found or could not be parsed.
17619  * Since: 2.6
17620  */
17621
17622
17623 /**
17624  * g_key_file_get_integer_list:
17625  * @key_file: a #GKeyFile
17626  * @group_name: a group name
17627  * @key: a key
17628  * @length: (out): the number of integers returned
17629  * @error: return location for a #GError
17630  *
17631  * Returns the values associated with @key under @group_name as
17632  * integers.
17633  *
17634  * If @key cannot be found then %NULL is returned and @error is set to
17635  * #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the values associated
17636  * with @key cannot be interpreted as integers then %NULL is returned
17637  * and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
17638  *
17639  * Returns: (array length=length) (element-type gint) (transfer container):
17640  *     the values associated with the key as a list of integers, or %NULL if
17641  *     the key was not found or could not be parsed. The returned list of
17642  *     integers should be freed with g_free() when no longer needed.
17643  * Since: 2.6
17644  */
17645
17646
17647 /**
17648  * g_key_file_get_keys:
17649  * @key_file: a #GKeyFile
17650  * @group_name: a group name
17651  * @length: (out) (allow-none): return location for the number of keys returned, or %NULL
17652  * @error: return location for a #GError, or %NULL
17653  *
17654  * Returns all keys for the group name @group_name.  The array of
17655  * returned keys will be %NULL-terminated, so @length may
17656  * optionally be %NULL. In the event that the @group_name cannot
17657  * be found, %NULL is returned and @error is set to
17658  * #G_KEY_FILE_ERROR_GROUP_NOT_FOUND.
17659  *
17660  * Returns: (array zero-terminated=1) (transfer full): a newly-allocated %NULL-terminated array of strings.
17661  *     Use g_strfreev() to free it.
17662  * Since: 2.6
17663  */
17664
17665
17666 /**
17667  * g_key_file_get_locale_string:
17668  * @key_file: a #GKeyFile
17669  * @group_name: a group name
17670  * @key: a key
17671  * @locale: (allow-none): a locale identifier or %NULL
17672  * @error: return location for a #GError, or %NULL
17673  *
17674  * Returns the value associated with @key under @group_name
17675  * translated in the given @locale if available.  If @locale is
17676  * %NULL then the current locale is assumed.
17677  *
17678  * If @key cannot be found then %NULL is returned and @error is set
17679  * to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. If the value associated
17680  * with @key cannot be interpreted or no suitable translation can
17681  * be found then the untranslated value is returned.
17682  *
17683  * Returns: a newly allocated string or %NULL if the specified
17684  *   key cannot be found.
17685  * Since: 2.6
17686  */
17687
17688
17689 /**
17690  * g_key_file_get_locale_string_list:
17691  * @key_file: a #GKeyFile
17692  * @group_name: a group name
17693  * @key: a key
17694  * @locale: (allow-none): a locale identifier or %NULL
17695  * @length: (out) (allow-none): return location for the number of returned strings or %NULL
17696  * @error: return location for a #GError or %NULL
17697  *
17698  * Returns the values associated with @key under @group_name
17699  * translated in the given @locale if available.  If @locale is
17700  * %NULL then the current locale is assumed.
17701  *
17702  * If @key cannot be found then %NULL is returned and @error is set
17703  * to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. If the values associated
17704  * with @key cannot be interpreted or no suitable translations
17705  * can be found then the untranslated values are returned. The
17706  * returned array is %NULL-terminated, so @length may optionally
17707  * be %NULL.
17708  *
17709  * Returns: (array zero-terminated=1 length=length) (element-type utf8) (transfer full): a newly allocated %NULL-terminated string array
17710  *   or %NULL if the key isn't found. The string array should be freed
17711  *   with g_strfreev().
17712  * Since: 2.6
17713  */
17714
17715
17716 /**
17717  * g_key_file_get_start_group:
17718  * @key_file: a #GKeyFile
17719  *
17720  * Returns the name of the start group of the file.
17721  *
17722  * Returns: The start group of the key file.
17723  * Since: 2.6
17724  */
17725
17726
17727 /**
17728  * g_key_file_get_string:
17729  * @key_file: a #GKeyFile
17730  * @group_name: a group name
17731  * @key: a key
17732  * @error: return location for a #GError, or %NULL
17733  *
17734  * Returns the string value associated with @key under @group_name.
17735  * Unlike g_key_file_get_value(), this function handles escape sequences
17736  * like \s.
17737  *
17738  * In the event the key cannot be found, %NULL is returned and
17739  * @error is set to #G_KEY_FILE_ERROR_KEY_NOT_FOUND.  In the
17740  * event that the @group_name cannot be found, %NULL is returned
17741  * and @error is set to #G_KEY_FILE_ERROR_GROUP_NOT_FOUND.
17742  *
17743  * Returns: a newly allocated string or %NULL if the specified
17744  *   key cannot be found.
17745  * Since: 2.6
17746  */
17747
17748
17749 /**
17750  * g_key_file_get_string_list:
17751  * @key_file: a #GKeyFile
17752  * @group_name: a group name
17753  * @key: a key
17754  * @length: (out) (allow-none): return location for the number of returned strings, or %NULL
17755  * @error: return location for a #GError, or %NULL
17756  *
17757  * Returns the values associated with @key under @group_name.
17758  *
17759  * In the event the key cannot be found, %NULL is returned and
17760  * @error is set to #G_KEY_FILE_ERROR_KEY_NOT_FOUND.  In the
17761  * event that the @group_name cannot be found, %NULL is returned
17762  * and @error is set to #G_KEY_FILE_ERROR_GROUP_NOT_FOUND.
17763  *
17764  * Returns: (array zero-terminated=1 length=length) (element-type utf8) (transfer full):
17765  *  a %NULL-terminated string array or %NULL if the specified
17766  *  key cannot be found. The array should be freed with g_strfreev().
17767  * Since: 2.6
17768  */
17769
17770
17771 /**
17772  * g_key_file_get_uint64:
17773  * @key_file: a non-%NULL #GKeyFile
17774  * @group_name: a non-%NULL group name
17775  * @key: a non-%NULL key
17776  * @error: return location for a #GError
17777  *
17778  * Returns the value associated with @key under @group_name as an unsigned
17779  * 64-bit integer. This is similar to g_key_file_get_integer() but can return
17780  * large positive results without truncation.
17781  *
17782  * Returns: the value associated with the key as an unsigned 64-bit integer,
17783  * or 0 if the key was not found or could not be parsed.
17784  * Since: 2.26
17785  */
17786
17787
17788 /**
17789  * g_key_file_get_value:
17790  * @key_file: a #GKeyFile
17791  * @group_name: a group name
17792  * @key: a key
17793  * @error: return location for a #GError, or %NULL
17794  *
17795  * Returns the raw value associated with @key under @group_name.
17796  * Use g_key_file_get_string() to retrieve an unescaped UTF-8 string.
17797  *
17798  * In the event the key cannot be found, %NULL is returned and
17799  * @error is set to #G_KEY_FILE_ERROR_KEY_NOT_FOUND.  In the
17800  * event that the @group_name cannot be found, %NULL is returned
17801  * and @error is set to #G_KEY_FILE_ERROR_GROUP_NOT_FOUND.
17802  *
17803  * Returns: a newly allocated string or %NULL if the specified
17804  *  key cannot be found.
17805  * Since: 2.6
17806  */
17807
17808
17809 /**
17810  * g_key_file_has_group:
17811  * @key_file: a #GKeyFile
17812  * @group_name: a group name
17813  *
17814  * Looks whether the key file has the group @group_name.
17815  *
17816  * Returns: %TRUE if @group_name is a part of @key_file, %FALSE
17817  * otherwise.
17818  * Since: 2.6
17819  */
17820
17821
17822 /**
17823  * g_key_file_has_key: (skip)
17824  * @key_file: a #GKeyFile
17825  * @group_name: a group name
17826  * @key: a key name
17827  * @error: return location for a #GError
17828  *
17829  * Looks whether the key file has the key @key in the group
17830  * @group_name.
17831  *
17832  * <note>This function does not follow the rules for #GError strictly;
17833  * the return value both carries meaning and signals an error.  To use
17834  * this function, you must pass a #GError pointer in @error, and check
17835  * whether it is not %NULL to see if an error occurred.</note>
17836  *
17837  * Language bindings should use g_key_file_get_value() to test whether
17838  * or not a key exists.
17839  *
17840  * Returns: %TRUE if @key is a part of @group_name, %FALSE
17841  * otherwise.
17842  * Since: 2.6
17843  */
17844
17845
17846 /**
17847  * g_key_file_load_from_data:
17848  * @key_file: an empty #GKeyFile struct
17849  * @data: key file loaded in memory
17850  * @length: the length of @data in bytes (or -1 if data is nul-terminated)
17851  * @flags: flags from #GKeyFileFlags
17852  * @error: return location for a #GError, or %NULL
17853  *
17854  * Loads a key file from memory into an empty #GKeyFile structure.
17855  * If the object cannot be created then %error is set to a #GKeyFileError.
17856  *
17857  * Returns: %TRUE if a key file could be loaded, %FALSE otherwise
17858  * Since: 2.6
17859  */
17860
17861
17862 /**
17863  * g_key_file_load_from_data_dirs:
17864  * @key_file: an empty #GKeyFile struct
17865  * @file: (type filename): a relative path to a filename to open and parse
17866  * @full_path: (out) (type filename) (allow-none): return location for a string containing the full path
17867  *   of the file, or %NULL
17868  * @flags: flags from #GKeyFileFlags
17869  * @error: return location for a #GError, or %NULL
17870  *
17871  * This function looks for a key file named @file in the paths
17872  * returned from g_get_user_data_dir() and g_get_system_data_dirs(),
17873  * loads the file into @key_file and returns the file's full path in
17874  * @full_path.  If the file could not be loaded then an %error is
17875  * set to either a #GFileError or #GKeyFileError.
17876  *
17877  * Returns: %TRUE if a key file could be loaded, %FALSE othewise
17878  * Since: 2.6
17879  */
17880
17881
17882 /**
17883  * g_key_file_load_from_dirs:
17884  * @key_file: an empty #GKeyFile struct
17885  * @file: (type filename): a relative path to a filename to open and parse
17886  * @search_dirs: (array zero-terminated=1) (element-type filename): %NULL-terminated array of directories to search
17887  * @full_path: (out) (type filename) (allow-none): return location for a string containing the full path
17888  *   of the file, or %NULL
17889  * @flags: flags from #GKeyFileFlags
17890  * @error: return location for a #GError, or %NULL
17891  *
17892  * This function looks for a key file named @file in the paths
17893  * specified in @search_dirs, loads the file into @key_file and
17894  * returns the file's full path in @full_path.  If the file could not
17895  * be loaded then an %error is set to either a #GFileError or
17896  * #GKeyFileError.
17897  *
17898  * Returns: %TRUE if a key file could be loaded, %FALSE otherwise
17899  * Since: 2.14
17900  */
17901
17902
17903 /**
17904  * g_key_file_load_from_file:
17905  * @key_file: an empty #GKeyFile struct
17906  * @file: (type filename): the path of a filename to load, in the GLib filename encoding
17907  * @flags: flags from #GKeyFileFlags
17908  * @error: return location for a #GError, or %NULL
17909  *
17910  * Loads a key file into an empty #GKeyFile structure.
17911  * If the file could not be loaded then @error is set to
17912  * either a #GFileError or #GKeyFileError.
17913  *
17914  * Returns: %TRUE if a key file could be loaded, %FALSE otherwise
17915  * Since: 2.6
17916  */
17917
17918
17919 /**
17920  * g_key_file_new:
17921  *
17922  * Creates a new empty #GKeyFile object. Use
17923  * g_key_file_load_from_file(), g_key_file_load_from_data(),
17924  * g_key_file_load_from_dirs() or g_key_file_load_from_data_dirs() to
17925  * read an existing key file.
17926  *
17927  * Returns: (transfer full): an empty #GKeyFile.
17928  * Since: 2.6
17929  */
17930
17931
17932 /**
17933  * g_key_file_ref: (skip)
17934  * @key_file: a #GKeyFile
17935  *
17936  * Increases the reference count of @key_file.
17937  *
17938  * Returns: the same @key_file.
17939  * Since: 2.32
17940  */
17941
17942
17943 /**
17944  * g_key_file_remove_comment:
17945  * @key_file: a #GKeyFile
17946  * @group_name: (allow-none): a group name, or %NULL
17947  * @key: (allow-none): a key
17948  * @error: return location for a #GError
17949  *
17950  * Removes a comment above @key from @group_name.
17951  * If @key is %NULL then @comment will be removed above @group_name.
17952  * If both @key and @group_name are %NULL, then @comment will
17953  * be removed above the first group in the file.
17954  *
17955  * Returns: %TRUE if the comment was removed, %FALSE otherwise
17956  * Since: 2.6
17957  */
17958
17959
17960 /**
17961  * g_key_file_remove_group:
17962  * @key_file: a #GKeyFile
17963  * @group_name: a group name
17964  * @error: return location for a #GError or %NULL
17965  *
17966  * Removes the specified group, @group_name,
17967  * from the key file.
17968  *
17969  * Returns: %TRUE if the group was removed, %FALSE otherwise
17970  * Since: 2.6
17971  */
17972
17973
17974 /**
17975  * g_key_file_remove_key:
17976  * @key_file: a #GKeyFile
17977  * @group_name: a group name
17978  * @key: a key name to remove
17979  * @error: return location for a #GError or %NULL
17980  *
17981  * Removes @key in @group_name from the key file.
17982  *
17983  * Returns: %TRUE if the key was removed, %FALSE otherwise
17984  * Since: 2.6
17985  */
17986
17987
17988 /**
17989  * g_key_file_save_to_file:
17990  * @key_file: a #GKeyFile
17991  * @filename: the name of the file to write to
17992  * @error: a pointer to a %NULL #GError, or %NULL
17993  *
17994  * Writes the contents of @key_file to @filename using
17995  * g_file_set_contents().
17996  *
17997  * This function can fail for any of the reasons that
17998  * g_file_set_contents() may fail.
17999  *
18000  * Returns: %TRUE if successful, else %FALSE with @error set
18001  * Since: 2.40
18002  */
18003
18004
18005 /**
18006  * g_key_file_set_boolean:
18007  * @key_file: a #GKeyFile
18008  * @group_name: a group name
18009  * @key: a key
18010  * @value: %TRUE or %FALSE
18011  *
18012  * Associates a new boolean value with @key under @group_name.
18013  * If @key cannot be found then it is created.
18014  *
18015  * Since: 2.6
18016  */
18017
18018
18019 /**
18020  * g_key_file_set_boolean_list:
18021  * @key_file: a #GKeyFile
18022  * @group_name: a group name
18023  * @key: a key
18024  * @list: (array length=length): an array of boolean values
18025  * @length: length of @list
18026  *
18027  * Associates a list of boolean values with @key under @group_name.
18028  * If @key cannot be found then it is created.
18029  * If @group_name is %NULL, the start_group is used.
18030  *
18031  * Since: 2.6
18032  */
18033
18034
18035 /**
18036  * g_key_file_set_comment:
18037  * @key_file: a #GKeyFile
18038  * @group_name: (allow-none): a group name, or %NULL
18039  * @key: (allow-none): a key
18040  * @comment: a comment
18041  * @error: return location for a #GError
18042  *
18043  * Places a comment above @key from @group_name.
18044  * If @key is %NULL then @comment will be written above @group_name.
18045  * If both @key and @group_name  are %NULL, then @comment will be
18046  * written above the first group in the file.
18047  *
18048  * Returns: %TRUE if the comment was written, %FALSE otherwise
18049  * Since: 2.6
18050  */
18051
18052
18053 /**
18054  * g_key_file_set_double:
18055  * @key_file: a #GKeyFile
18056  * @group_name: a group name
18057  * @key: a key
18058  * @value: an double value
18059  *
18060  * Associates a new double value with @key under @group_name.
18061  * If @key cannot be found then it is created.
18062  *
18063  * Since: 2.12
18064  */
18065
18066
18067 /**
18068  * g_key_file_set_double_list:
18069  * @key_file: a #GKeyFile
18070  * @group_name: a group name
18071  * @key: a key
18072  * @list: (array length=length): an array of double values
18073  * @length: number of double values in @list
18074  *
18075  * Associates a list of double values with @key under
18076  * @group_name.  If @key cannot be found then it is created.
18077  *
18078  * Since: 2.12
18079  */
18080
18081
18082 /**
18083  * g_key_file_set_int64:
18084  * @key_file: a #GKeyFile
18085  * @group_name: a group name
18086  * @key: a key
18087  * @value: an integer value
18088  *
18089  * Associates a new integer value with @key under @group_name.
18090  * If @key cannot be found then it is created.
18091  *
18092  * Since: 2.26
18093  */
18094
18095
18096 /**
18097  * g_key_file_set_integer:
18098  * @key_file: a #GKeyFile
18099  * @group_name: a group name
18100  * @key: a key
18101  * @value: an integer value
18102  *
18103  * Associates a new integer value with @key under @group_name.
18104  * If @key cannot be found then it is created.
18105  *
18106  * Since: 2.6
18107  */
18108
18109
18110 /**
18111  * g_key_file_set_integer_list:
18112  * @key_file: a #GKeyFile
18113  * @group_name: a group name
18114  * @key: a key
18115  * @list: (array length=length): an array of integer values
18116  * @length: number of integer values in @list
18117  *
18118  * Associates a list of integer values with @key under @group_name.
18119  * If @key cannot be found then it is created.
18120  *
18121  * Since: 2.6
18122  */
18123
18124
18125 /**
18126  * g_key_file_set_list_separator:
18127  * @key_file: a #GKeyFile
18128  * @separator: the separator
18129  *
18130  * Sets the character which is used to separate
18131  * values in lists. Typically ';' or ',' are used
18132  * as separators. The default list separator is ';'.
18133  *
18134  * Since: 2.6
18135  */
18136
18137
18138 /**
18139  * g_key_file_set_locale_string:
18140  * @key_file: a #GKeyFile
18141  * @group_name: a group name
18142  * @key: a key
18143  * @locale: a locale identifier
18144  * @string: a string
18145  *
18146  * Associates a string value for @key and @locale under @group_name.
18147  * If the translation for @key cannot be found then it is created.
18148  *
18149  * Since: 2.6
18150  */
18151
18152
18153 /**
18154  * g_key_file_set_locale_string_list:
18155  * @key_file: a #GKeyFile
18156  * @group_name: a group name
18157  * @key: a key
18158  * @locale: a locale identifier
18159  * @list: (array zero-terminated=1 length=length): a %NULL-terminated array of locale string values
18160  * @length: the length of @list
18161  *
18162  * Associates a list of string values for @key and @locale under
18163  * @group_name.  If the translation for @key cannot be found then
18164  * it is created.
18165  *
18166  * Since: 2.6
18167  */
18168
18169
18170 /**
18171  * g_key_file_set_string:
18172  * @key_file: a #GKeyFile
18173  * @group_name: a group name
18174  * @key: a key
18175  * @string: a string
18176  *
18177  * Associates a new string value with @key under @group_name.
18178  * If @key cannot be found then it is created.
18179  * If @group_name cannot be found then it is created.
18180  * Unlike g_key_file_set_value(), this function handles characters
18181  * that need escaping, such as newlines.
18182  *
18183  * Since: 2.6
18184  */
18185
18186
18187 /**
18188  * g_key_file_set_string_list:
18189  * @key_file: a #GKeyFile
18190  * @group_name: a group name
18191  * @key: a key
18192  * @list: (array zero-terminated=1 length=length) (element-type utf8): an array of string values
18193  * @length: number of string values in @list
18194  *
18195  * Associates a list of string values for @key under @group_name.
18196  * If @key cannot be found then it is created.
18197  * If @group_name cannot be found then it is created.
18198  *
18199  * Since: 2.6
18200  */
18201
18202
18203 /**
18204  * g_key_file_set_uint64:
18205  * @key_file: a #GKeyFile
18206  * @group_name: a group name
18207  * @key: a key
18208  * @value: an integer value
18209  *
18210  * Associates a new integer value with @key under @group_name.
18211  * If @key cannot be found then it is created.
18212  *
18213  * Since: 2.26
18214  */
18215
18216
18217 /**
18218  * g_key_file_set_value:
18219  * @key_file: a #GKeyFile
18220  * @group_name: a group name
18221  * @key: a key
18222  * @value: a string
18223  *
18224  * Associates a new value with @key under @group_name.
18225  *
18226  * If @key cannot be found then it is created. If @group_name cannot
18227  * be found then it is created. To set an UTF-8 string which may contain
18228  * characters that need escaping (such as newlines or spaces), use
18229  * g_key_file_set_string().
18230  *
18231  * Since: 2.6
18232  */
18233
18234
18235 /**
18236  * g_key_file_to_data:
18237  * @key_file: a #GKeyFile
18238  * @length: (out) (allow-none): return location for the length of the
18239  *   returned string, or %NULL
18240  * @error: return location for a #GError, or %NULL
18241  *
18242  * This function outputs @key_file as a string.
18243  *
18244  * Note that this function never reports an error,
18245  * so it is safe to pass %NULL as @error.
18246  *
18247  * Returns: a newly allocated string holding
18248  *   the contents of the #GKeyFile
18249  * Since: 2.6
18250  */
18251
18252
18253 /**
18254  * g_key_file_unref:
18255  * @key_file: a #GKeyFile
18256  *
18257  * Decreases the reference count of @key_file by 1. If the reference count
18258  * reaches zero, frees the key file and all its allocated memory.
18259  *
18260  * Since: 2.32
18261  */
18262
18263
18264 /**
18265  * g_list_alloc:
18266  *
18267  * Allocates space for one #GList element. It is called by
18268  * g_list_append(), g_list_prepend(), g_list_insert() and
18269  * g_list_insert_sorted() and so is rarely used on its own.
18270  *
18271  * Returns: a pointer to the newly-allocated #GList element.
18272  */
18273
18274
18275 /**
18276  * g_list_append:
18277  * @list: a pointer to a #GList
18278  * @data: the data for the new element
18279  *
18280  * Adds a new element on to the end of the list.
18281  *
18282  * <note><para>
18283  * The return value is the new start of the list, which
18284  * may have changed, so make sure you store the new value.
18285  * </para></note>
18286  *
18287  * <note><para>
18288  * Note that g_list_append() has to traverse the entire list
18289  * to find the end, which is inefficient when adding multiple
18290  * elements. A common idiom to avoid the inefficiency is to prepend
18291  * the elements and reverse the list when all elements have been added.
18292  * </para></note>
18293  *
18294  * |[
18295  * /&ast; Notice that these are initialized to the empty list. &ast;/
18296  * GList *list = NULL, *number_list = NULL;
18297  *
18298  * /&ast; This is a list of strings. &ast;/
18299  * list = g_list_append (list, "first");
18300  * list = g_list_append (list, "second");
18301  *
18302  * /&ast; This is a list of integers. &ast;/
18303  * number_list = g_list_append (number_list, GINT_TO_POINTER (27));
18304  * number_list = g_list_append (number_list, GINT_TO_POINTER (14));
18305  * ]|
18306  *
18307  * Returns: the new start of the #GList
18308  */
18309
18310
18311 /**
18312  * g_list_concat:
18313  * @list1: a #GList
18314  * @list2: the #GList to add to the end of the first #GList
18315  *
18316  * Adds the second #GList onto the end of the first #GList.
18317  * Note that the elements of the second #GList are not copied.
18318  * They are used directly.
18319  *
18320  * Returns: the start of the new #GList
18321  */
18322
18323
18324 /**
18325  * g_list_copy:
18326  * @list: a #GList
18327  *
18328  * Copies a #GList.
18329  *
18330  * <note><para>
18331  * Note that this is a "shallow" copy. If the list elements
18332  * consist of pointers to data, the pointers are copied but
18333  * the actual data is not. See g_list_copy_deep() if you need
18334  * to copy the data as well.
18335  * </para></note>
18336  *
18337  * Returns: a copy of @list
18338  */
18339
18340
18341 /**
18342  * g_list_copy_deep:
18343  * @list: a #GList
18344  * @func: a copy function used to copy every element in the list
18345  * @user_data: user data passed to the copy function @func, or #NULL
18346  *
18347  * Makes a full (deep) copy of a #GList.
18348  *
18349  * In contrast with g_list_copy(), this function uses @func to make a copy of
18350  * each list element, in addition to copying the list container itself.
18351  *
18352  * @func, as a #GCopyFunc, takes two arguments, the data to be copied and a user
18353  * pointer. It's safe to pass #NULL as user_data, if the copy function takes only
18354  * one argument.
18355  *
18356  * For instance, if @list holds a list of GObjects, you can do:
18357  * |[
18358  * another_list = g_list_copy_deep (list, (GCopyFunc) g_object_ref, NULL);
18359  * ]|
18360  *
18361  * And, to entirely free the new list, you could do:
18362  * |[
18363  * g_list_free_full (another_list, g_object_unref);
18364  * ]|
18365  *
18366  * Returns: a full copy of @list, use #g_list_free_full to free it
18367  * Since: 2.34
18368  */
18369
18370
18371 /**
18372  * g_list_delete_link:
18373  * @list: a #GList
18374  * @link_: node to delete from @list
18375  *
18376  * Removes the node link_ from the list and frees it.
18377  * Compare this to g_list_remove_link() which removes the node
18378  * without freeing it.
18379  *
18380  * Returns: the new head of @list
18381  */
18382
18383
18384 /**
18385  * g_list_find:
18386  * @list: a #GList
18387  * @data: the element data to find
18388  *
18389  * Finds the element in a #GList which
18390  * contains the given data.
18391  *
18392  * Returns: the found #GList element,
18393  *     or %NULL if it is not found
18394  */
18395
18396
18397 /**
18398  * g_list_find_custom:
18399  * @list: a #GList
18400  * @data: user data passed to the function
18401  * @func: the function to call for each element.
18402  *     It should return 0 when the desired element is found
18403  *
18404  * Finds an element in a #GList, using a supplied function to
18405  * find the desired element. It iterates over the list, calling
18406  * the given function which should return 0 when the desired
18407  * element is found. The function takes two #gconstpointer arguments,
18408  * the #GList element's data as the first argument and the
18409  * given user data.
18410  *
18411  * Returns: the found #GList element, or %NULL if it is not found
18412  */
18413
18414
18415 /**
18416  * g_list_first:
18417  * @list: a #GList
18418  *
18419  * Gets the first element in a #GList.
18420  *
18421  * Returns: the first element in the #GList,
18422  *     or %NULL if the #GList has no elements
18423  */
18424
18425
18426 /**
18427  * g_list_foreach:
18428  * @list: a #GList
18429  * @func: the function to call with each element's data
18430  * @user_data: user data to pass to the function
18431  *
18432  * Calls a function for each element of a #GList.
18433  */
18434
18435
18436 /**
18437  * g_list_free:
18438  * @list: a #GList
18439  *
18440  * Frees all of the memory used by a #GList.
18441  * The freed elements are returned to the slice allocator.
18442  *
18443  * <note><para>
18444  * If list elements contain dynamically-allocated memory,
18445  * you should either use g_list_free_full() or free them manually
18446  * first.
18447  * </para></note>
18448  */
18449
18450
18451 /**
18452  * g_list_free1:
18453  *
18454  * Another name for g_list_free_1().
18455  */
18456
18457
18458 /**
18459  * g_list_free_1:
18460  * @list: a #GList element
18461  *
18462  * Frees one #GList element.
18463  * It is usually used after g_list_remove_link().
18464  */
18465
18466
18467 /**
18468  * g_list_free_full:
18469  * @list: a pointer to a #GList
18470  * @free_func: the function to be called to free each element's data
18471  *
18472  * Convenience method, which frees all the memory used by a #GList, and
18473  * calls the specified destroy function on every element's data.
18474  *
18475  * Since: 2.28
18476  */
18477
18478
18479 /**
18480  * g_list_index:
18481  * @list: a #GList
18482  * @data: the data to find
18483  *
18484  * Gets the position of the element containing
18485  * the given data (starting from 0).
18486  *
18487  * Returns: the index of the element containing the data,
18488  *     or -1 if the data is not found
18489  */
18490
18491
18492 /**
18493  * g_list_insert:
18494  * @list: a pointer to a #GList
18495  * @data: the data for the new element
18496  * @position: the position to insert the element. If this is
18497  *     negative, or is larger than the number of elements in the
18498  *     list, the new element is added on to the end of the list.
18499  *
18500  * Inserts a new element into the list at the given position.
18501  *
18502  * Returns: the new start of the #GList
18503  */
18504
18505
18506 /**
18507  * g_list_insert_before:
18508  * @list: a pointer to a #GList
18509  * @sibling: the list element before which the new element
18510  *     is inserted or %NULL to insert at the end of the list
18511  * @data: the data for the new element
18512  *
18513  * Inserts a new element into the list before the given position.
18514  *
18515  * Returns: the new start of the #GList
18516  */
18517
18518
18519 /**
18520  * g_list_insert_sorted:
18521  * @list: a pointer to a #GList
18522  * @data: the data for the new element
18523  * @func: the function to compare elements in the list. It should
18524  *     return a number > 0 if the first parameter comes after the
18525  *     second parameter in the sort order.
18526  *
18527  * Inserts a new element into the list, using the given comparison
18528  * function to determine its position.
18529  *
18530  * Returns: the new start of the #GList
18531  */
18532
18533
18534 /**
18535  * g_list_insert_sorted_with_data:
18536  * @list: a pointer to a #GList
18537  * @data: the data for the new element
18538  * @func: the function to compare elements in the list.
18539  *     It should return a number > 0 if the first parameter
18540  *     comes after the second parameter in the sort order.
18541  * @user_data: user data to pass to comparison function.
18542  *
18543  * Inserts a new element into the list, using the given comparison
18544  * function to determine its position.
18545  *
18546  * Returns: the new start of the #GList
18547  * Since: 2.10
18548  */
18549
18550
18551 /**
18552  * g_list_last:
18553  * @list: a #GList
18554  *
18555  * Gets the last element in a #GList.
18556  *
18557  * Returns: the last element in the #GList,
18558  *     or %NULL if the #GList has no elements
18559  */
18560
18561
18562 /**
18563  * g_list_length:
18564  * @list: a #GList
18565  *
18566  * Gets the number of elements in a #GList.
18567  *
18568  * <note><para>
18569  * This function iterates over the whole list to
18570  * count its elements.
18571  * </para></note>
18572  *
18573  * Returns: the number of elements in the #GList
18574  */
18575
18576
18577 /**
18578  * g_list_next:
18579  * @list: an element in a #GList.
18580  *
18581  * A convenience macro to get the next element in a #GList.
18582  *
18583  * Returns: the next element, or %NULL if there are no more elements.
18584  */
18585
18586
18587 /**
18588  * g_list_nth:
18589  * @list: a #GList
18590  * @n: the position of the element, counting from 0
18591  *
18592  * Gets the element at the given position in a #GList.
18593  *
18594  * Returns: the element, or %NULL if the position is off
18595  *     the end of the #GList
18596  */
18597
18598
18599 /**
18600  * g_list_nth_data:
18601  * @list: a #GList
18602  * @n: the position of the element
18603  *
18604  * Gets the data of the element at the given position.
18605  *
18606  * Returns: the element's data, or %NULL if the position
18607  *     is off the end of the #GList
18608  */
18609
18610
18611 /**
18612  * g_list_nth_prev:
18613  * @list: a #GList
18614  * @n: the position of the element, counting from 0
18615  *
18616  * Gets the element @n places before @list.
18617  *
18618  * Returns: the element, or %NULL if the position is
18619  *     off the end of the #GList
18620  */
18621
18622
18623 /**
18624  * g_list_position:
18625  * @list: a #GList
18626  * @llink: an element in the #GList
18627  *
18628  * Gets the position of the given element
18629  * in the #GList (starting from 0).
18630  *
18631  * Returns: the position of the element in the #GList,
18632  *     or -1 if the element is not found
18633  */
18634
18635
18636 /**
18637  * g_list_prepend:
18638  * @list: a pointer to a #GList
18639  * @data: the data for the new element
18640  *
18641  * Adds a new element on to the start of the list.
18642  *
18643  * <note><para>
18644  * The return value is the new start of the list, which
18645  * may have changed, so make sure you store the new value.
18646  * </para></note>
18647  *
18648  * |[
18649  * /&ast; Notice that it is initialized to the empty list. &ast;/
18650  * GList *list = NULL;
18651  * list = g_list_prepend (list, "last");
18652  * list = g_list_prepend (list, "first");
18653  * ]|
18654  *
18655  * Returns: the new start of the #GList
18656  */
18657
18658
18659 /**
18660  * g_list_previous:
18661  * @list: an element in a #GList.
18662  *
18663  * A convenience macro to get the previous element in a #GList.
18664  *
18665  * Returns: the previous element, or %NULL if there are no previous
18666  *          elements.
18667  */
18668
18669
18670 /**
18671  * g_list_remove:
18672  * @list: a #GList
18673  * @data: the data of the element to remove
18674  *
18675  * Removes an element from a #GList.
18676  * If two elements contain the same data, only the first is removed.
18677  * If none of the elements contain the data, the #GList is unchanged.
18678  *
18679  * Returns: the new start of the #GList
18680  */
18681
18682
18683 /**
18684  * g_list_remove_all:
18685  * @list: a #GList
18686  * @data: data to remove
18687  *
18688  * Removes all list nodes with data equal to @data.
18689  * Returns the new head of the list. Contrast with
18690  * g_list_remove() which removes only the first node
18691  * matching the given data.
18692  *
18693  * Returns: new head of @list
18694  */
18695
18696
18697 /**
18698  * g_list_remove_link:
18699  * @list: a #GList
18700  * @llink: an element in the #GList
18701  *
18702  * Removes an element from a #GList, without freeing the element.
18703  * The removed element's prev and next links are set to %NULL, so
18704  * that it becomes a self-contained list with one element.
18705  *
18706  * Returns: the new start of the #GList, without the element
18707  */
18708
18709
18710 /**
18711  * g_list_reverse:
18712  * @list: a #GList
18713  *
18714  * Reverses a #GList.
18715  * It simply switches the next and prev pointers of each element.
18716  *
18717  * Returns: the start of the reversed #GList
18718  */
18719
18720
18721 /**
18722  * g_list_sort:
18723  * @list: a #GList
18724  * @compare_func: the comparison function used to sort the #GList.
18725  *     This function is passed the data from 2 elements of the #GList
18726  *     and should return 0 if they are equal, a negative value if the
18727  *     first element comes before the second, or a positive value if
18728  *     the first element comes after the second.
18729  *
18730  * Sorts a #GList using the given comparison function. The algorithm
18731  * used is a stable sort.
18732  *
18733  * Returns: the start of the sorted #GList
18734  */
18735
18736
18737 /**
18738  * g_list_sort_with_data:
18739  * @list: a #GList
18740  * @compare_func: comparison function
18741  * @user_data: user data to pass to comparison function
18742  *
18743  * Like g_list_sort(), but the comparison function accepts
18744  * a user data argument.
18745  *
18746  * Returns: the new head of @list
18747  */
18748
18749
18750 /**
18751  * g_listenv:
18752  *
18753  * Gets the names of all variables set in the environment.
18754  *
18755  * Programs that want to be portable to Windows should typically use
18756  * this function and g_getenv() instead of using the environ array
18757  * from the C library directly. On Windows, the strings in the environ
18758  * array are in system codepage encoding, while in most of the typical
18759  * use cases for environment variables in GLib-using programs you want
18760  * the UTF-8 encoding that this function and g_getenv() provide.
18761  *
18762  * Returns: (array zero-terminated=1) (transfer full): a %NULL-terminated
18763  *     list of strings which must be freed with g_strfreev().
18764  * Since: 2.8
18765  */
18766
18767
18768 /**
18769  * g_locale_from_utf8:
18770  * @utf8string: a UTF-8 encoded string
18771  * @len: the length of the string, or -1 if the string is
18772  *                 nul-terminated<footnoteref linkend="nul-unsafe"/>.
18773  * @bytes_read: location to store the number of bytes in the
18774  *                 input string that were successfully converted, or %NULL.
18775  *                 Even if the conversion was successful, this may be
18776  *                 less than @len if there were partial characters
18777  *                 at the end of the input. If the error
18778  *                 #G_CONVERT_ERROR_ILLEGAL_SEQUENCE occurs, the value
18779  *                 stored will the byte offset after the last valid
18780  *                 input sequence.
18781  * @bytes_written: the number of bytes stored in the output buffer (not
18782  *                 including the terminating nul).
18783  * @error: location to store the error occurring, or %NULL to ignore
18784  *                 errors. Any of the errors in #GConvertError may occur.
18785  *
18786  * Converts a string from UTF-8 to the encoding used for strings by
18787  * the C runtime (usually the same as that used by the operating
18788  * system) in the <link linkend="setlocale">current locale</link>. On
18789  * Windows this means the system codepage.
18790  *
18791  * Returns: A newly-allocated buffer containing the converted string,
18792  *               or %NULL on an error, and error will be set.
18793  */
18794
18795
18796 /**
18797  * g_locale_to_utf8:
18798  * @opsysstring: a string in the encoding of the current locale. On Windows
18799  *                 this means the system codepage.
18800  * @len: the length of the string, or -1 if the string is
18801  *                 nul-terminated<footnoteref linkend="nul-unsafe"/>.
18802  * @bytes_read: location to store the number of bytes in the
18803  *                 input string that were successfully converted, or %NULL.
18804  *                 Even if the conversion was successful, this may be
18805  *                 less than @len if there were partial characters
18806  *                 at the end of the input. If the error
18807  *                 #G_CONVERT_ERROR_ILLEGAL_SEQUENCE occurs, the value
18808  *                 stored will the byte offset after the last valid
18809  *                 input sequence.
18810  * @bytes_written: the number of bytes stored in the output buffer (not
18811  *                 including the terminating nul).
18812  * @error: location to store the error occurring, or %NULL to ignore
18813  *                 errors. Any of the errors in #GConvertError may occur.
18814  *
18815  * Converts a string which is in the encoding used for strings by
18816  * the C runtime (usually the same as that used by the operating
18817  * system) in the <link linkend="setlocale">current locale</link> into a
18818  * UTF-8 string.
18819  *
18820  * Returns: A newly-allocated buffer containing the converted string,
18821  *               or %NULL on an error, and error will be set.
18822  */
18823
18824
18825 /**
18826  * g_log:
18827  * @log_domain: the log domain, usually #G_LOG_DOMAIN
18828  * @log_level: the log level, either from #GLogLevelFlags
18829  *     or a user-defined level
18830  * @format: the message format. See the printf() documentation
18831  * @...: the parameters to insert into the format string
18832  *
18833  * Logs an error or debugging message.
18834  *
18835  * If the log level has been set as fatal, the abort()
18836  * function is called to terminate the program.
18837  *
18838  * If g_log_default_handler() is used as the log handler function, a new-line
18839  * character will automatically be appended to @..., and need not be entered
18840  * manually.
18841  */
18842
18843
18844 /**
18845  * g_log_default_handler:
18846  * @log_domain: the log domain of the message
18847  * @log_level: the level of the message
18848  * @message: the message
18849  * @unused_data: data passed from g_log() which is unused
18850  *
18851  * The default log handler set up by GLib; g_log_set_default_handler()
18852  * allows to install an alternate default log handler.
18853  * This is used if no log handler has been set for the particular log
18854  * domain and log level combination. It outputs the message to stderr
18855  * or stdout and if the log level is fatal it calls abort(). It automatically
18856  * prints a new-line character after the message, so one does not need to be
18857  * manually included in @message.
18858  *
18859  * The behavior of this log handler can be influenced by a number of
18860  * environment variables:
18861  * <variablelist>
18862  *   <varlistentry>
18863  *     <term><envar>G_MESSAGES_PREFIXED</envar></term>
18864  *     <listitem>
18865  *       A :-separated list of log levels for which messages should
18866  *       be prefixed by the program name and PID of the aplication.
18867  *     </listitem>
18868  *   </varlistentry>
18869  *   <varlistentry>
18870  *     <term><envar>G_MESSAGES_DEBUG</envar></term>
18871  *     <listitem>
18872  *       A space-separated list of log domains for which debug and
18873  *       informational messages are printed. By default these
18874  *       messages are not printed.
18875  *     </listitem>
18876  *   </varlistentry>
18877  * </variablelist>
18878  *
18879  * stderr is used for levels %G_LOG_LEVEL_ERROR, %G_LOG_LEVEL_CRITICAL,
18880  * %G_LOG_LEVEL_WARNING and %G_LOG_LEVEL_MESSAGE. stdout is used for
18881  * the rest.
18882  */
18883
18884
18885 /**
18886  * g_log_remove_handler:
18887  * @log_domain: the log domain
18888  * @handler_id: the id of the handler, which was returned
18889  *     in g_log_set_handler()
18890  *
18891  * Removes the log handler.
18892  */
18893
18894
18895 /**
18896  * g_log_set_always_fatal:
18897  * @fatal_mask: the mask containing bits set for each level
18898  *     of error which is to be fatal
18899  *
18900  * Sets the message levels which are always fatal, in any log domain.
18901  * When a message with any of these levels is logged the program terminates.
18902  * You can only set the levels defined by GLib to be fatal.
18903  * %G_LOG_LEVEL_ERROR is always fatal.
18904  *
18905  * You can also make some message levels fatal at runtime by setting
18906  * the <envar>G_DEBUG</envar> environment variable (see
18907  * <ulink url="glib-running.html">Running GLib Applications</ulink>).
18908  *
18909  * Returns: the old fatal mask
18910  */
18911
18912
18913 /**
18914  * g_log_set_default_handler:
18915  * @log_func: the log handler function
18916  * @user_data: data passed to the log handler
18917  *
18918  * Installs a default log handler which is used if no
18919  * log handler has been set for the particular log domain
18920  * and log level combination. By default, GLib uses
18921  * g_log_default_handler() as default log handler.
18922  *
18923  * Returns: the previous default log handler
18924  * Since: 2.6
18925  */
18926
18927
18928 /**
18929  * g_log_set_fatal_mask:
18930  * @log_domain: the log domain
18931  * @fatal_mask: the new fatal mask
18932  *
18933  * Sets the log levels which are fatal in the given domain.
18934  * %G_LOG_LEVEL_ERROR is always fatal.
18935  *
18936  * Returns: the old fatal mask for the log domain
18937  */
18938
18939
18940 /**
18941  * g_log_set_handler:
18942  * @log_domain: (allow-none): the log domain, or %NULL for the default ""
18943  *     application domain
18944  * @log_levels: the log levels to apply the log handler for.
18945  *     To handle fatal and recursive messages as well, combine
18946  *     the log levels with the #G_LOG_FLAG_FATAL and
18947  *     #G_LOG_FLAG_RECURSION bit flags.
18948  * @log_func: the log handler function
18949  * @user_data: data passed to the log handler
18950  *
18951  * Sets the log handler for a domain and a set of log levels.
18952  * To handle fatal and recursive messages the @log_levels parameter
18953  * must be combined with the #G_LOG_FLAG_FATAL and #G_LOG_FLAG_RECURSION
18954  * bit flags.
18955  *
18956  * Note that since the #G_LOG_LEVEL_ERROR log level is always fatal, if
18957  * you want to set a handler for this log level you must combine it with
18958  * #G_LOG_FLAG_FATAL.
18959  *
18960  * <example>
18961  * <title>Adding a log handler for all warning messages in the default
18962  * (application) domain</title>
18963  * <programlisting>
18964  * g_log_set_handler (NULL, G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL
18965  *                    | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
18966  * </programlisting>
18967  * </example>
18968  *
18969  * <example>
18970  * <title>Adding a log handler for all critical messages from GTK+</title>
18971  * <programlisting>
18972  * g_log_set_handler ("Gtk", G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL
18973  *                    | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
18974  * </programlisting>
18975  * </example>
18976  *
18977  * <example>
18978  * <title>Adding a log handler for <emphasis>all</emphasis> messages from
18979  * GLib</title>
18980  * <programlisting>
18981  * g_log_set_handler ("GLib", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
18982  *                    | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
18983  * </programlisting>
18984  * </example>
18985  *
18986  * Returns: the id of the new handler
18987  */
18988
18989
18990 /**
18991  * g_logv:
18992  * @log_domain: the log domain
18993  * @log_level: the log level
18994  * @format: the message format. See the printf() documentation
18995  * @args: the parameters to insert into the format string
18996  *
18997  * Logs an error or debugging message.
18998  *
18999  * If the log level has been set as fatal, the abort()
19000  * function is called to terminate the program.
19001  *
19002  * If g_log_default_handler() is used as the log handler function, a new-line
19003  * character will automatically be appended to @..., and need not be entered
19004  * manually.
19005  */
19006
19007
19008 /**
19009  * g_lstat:
19010  * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
19011  * @buf: a pointer to a <structname>stat</structname> struct, which
19012  *    will be filled with the file information
19013  *
19014  * A wrapper for the POSIX lstat() function. The lstat() function is
19015  * like stat() except that in the case of symbolic links, it returns
19016  * information about the symbolic link itself and not the file that it
19017  * refers to. If the system does not support symbolic links g_lstat()
19018  * is identical to g_stat().
19019  *
19020  * See your C library manual for more details about lstat().
19021  *
19022  * Returns: 0 if the information was successfully retrieved, -1 if an error
19023  *    occurred
19024  * Since: 2.6
19025  */
19026
19027
19028 /**
19029  * g_main_context_acquire:
19030  * @context: a #GMainContext
19031  *
19032  * Tries to become the owner of the specified context.
19033  * If some other thread is the owner of the context,
19034  * returns %FALSE immediately. Ownership is properly
19035  * recursive: the owner can require ownership again
19036  * and will release ownership when g_main_context_release()
19037  * is called as many times as g_main_context_acquire().
19038  *
19039  * You must be the owner of a context before you
19040  * can call g_main_context_prepare(), g_main_context_query(),
19041  * g_main_context_check(), g_main_context_dispatch().
19042  *
19043  * Returns: %TRUE if the operation succeeded, and
19044  *   this thread is now the owner of @context.
19045  */
19046
19047
19048 /**
19049  * g_main_context_add_poll:
19050  * @context: (allow-none): a #GMainContext (or %NULL for the default context)
19051  * @fd: a #GPollFD structure holding information about a file
19052  *      descriptor to watch.
19053  * @priority: the priority for this file descriptor which should be
19054  *      the same as the priority used for g_source_attach() to ensure that the
19055  *      file descriptor is polled whenever the results may be needed.
19056  *
19057  * Adds a file descriptor to the set of file descriptors polled for
19058  * this context. This will very seldom be used directly. Instead
19059  * a typical event source will use g_source_add_unix_fd() instead.
19060  */
19061
19062
19063 /**
19064  * g_main_context_check:
19065  * @context: a #GMainContext
19066  * @max_priority: the maximum numerical priority of sources to check
19067  * @fds: (array length=n_fds): array of #GPollFD's that was passed to
19068  *       the last call to g_main_context_query()
19069  * @n_fds: return value of g_main_context_query()
19070  *
19071  * Passes the results of polling back to the main loop.
19072  *
19073  * Returns: %TRUE if some sources are ready to be dispatched.
19074  */
19075
19076
19077 /**
19078  * g_main_context_default:
19079  *
19080  * Returns the global default main context. This is the main context
19081  * used for main loop functions when a main loop is not explicitly
19082  * specified, and corresponds to the "main" main loop. See also
19083  * g_main_context_get_thread_default().
19084  *
19085  * Returns: (transfer none): the global default main context.
19086  */
19087
19088
19089 /**
19090  * g_main_context_dispatch:
19091  * @context: a #GMainContext
19092  *
19093  * Dispatches all pending sources.
19094  */
19095
19096
19097 /**
19098  * g_main_context_find_source_by_funcs_user_data:
19099  * @context: (allow-none): a #GMainContext (if %NULL, the default context will be used).
19100  * @funcs: the @source_funcs passed to g_source_new().
19101  * @user_data: the user data from the callback.
19102  *
19103  * Finds a source with the given source functions and user data.  If
19104  * multiple sources exist with the same source function and user data,
19105  * the first one found will be returned.
19106  *
19107  * Returns: (transfer none): the source, if one was found, otherwise %NULL
19108  */
19109
19110
19111 /**
19112  * g_main_context_find_source_by_id:
19113  * @context: (allow-none): a #GMainContext (if %NULL, the default context will be used)
19114  * @source_id: the source ID, as returned by g_source_get_id().
19115  *
19116  * Finds a #GSource given a pair of context and ID.
19117  *
19118  * Returns: (transfer none): the #GSource if found, otherwise, %NULL
19119  */
19120
19121
19122 /**
19123  * g_main_context_find_source_by_user_data:
19124  * @context: a #GMainContext
19125  * @user_data: the user_data for the callback.
19126  *
19127  * Finds a source with the given user data for the callback.  If
19128  * multiple sources exist with the same user data, the first
19129  * one found will be returned.
19130  *
19131  * Returns: (transfer none): the source, if one was found, otherwise %NULL
19132  */
19133
19134
19135 /**
19136  * g_main_context_get_poll_func:
19137  * @context: a #GMainContext
19138  *
19139  * Gets the poll function set by g_main_context_set_poll_func().
19140  *
19141  * Returns: the poll function
19142  */
19143
19144
19145 /**
19146  * g_main_context_get_thread_default:
19147  *
19148  * Gets the thread-default #GMainContext for this thread. Asynchronous
19149  * operations that want to be able to be run in contexts other than
19150  * the default one should call this method or
19151  * g_main_context_ref_thread_default() to get a #GMainContext to add
19152  * their #GSource<!-- -->s to. (Note that even in single-threaded
19153  * programs applications may sometimes want to temporarily push a
19154  * non-default context, so it is not safe to assume that this will
19155  * always return %NULL if you are running in the default thread.)
19156  *
19157  * If you need to hold a reference on the context, use
19158  * g_main_context_ref_thread_default() instead.
19159  *
19160  * Returns: (transfer none): the thread-default #GMainContext, or
19161  * %NULL if the thread-default context is the global default context.
19162  * Since: 2.22
19163  */
19164
19165
19166 /**
19167  * g_main_context_invoke:
19168  * @context: (allow-none): a #GMainContext, or %NULL
19169  * @function: function to call
19170  * @data: data to pass to @function
19171  *
19172  * Invokes a function in such a way that @context is owned during the
19173  * invocation of @function.
19174  *
19175  * If @context is %NULL then the global default main context â€” as
19176  * returned by g_main_context_default() â€” is used.
19177  *
19178  * If @context is owned by the current thread, @function is called
19179  * directly.  Otherwise, if @context is the thread-default main context
19180  * of the current thread and g_main_context_acquire() succeeds, then
19181  * @function is called and g_main_context_release() is called
19182  * afterwards.
19183  *
19184  * In any other case, an idle source is created to call @function and
19185  * that source is attached to @context (presumably to be run in another
19186  * thread).  The idle source is attached with #G_PRIORITY_DEFAULT
19187  * priority.  If you want a different priority, use
19188  * g_main_context_invoke_full().
19189  *
19190  * Note that, as with normal idle functions, @function should probably
19191  * return %FALSE.  If it returns %TRUE, it will be continuously run in a
19192  * loop (and may prevent this call from returning).
19193  *
19194  * Since: 2.28
19195  */
19196
19197
19198 /**
19199  * g_main_context_invoke_full:
19200  * @context: (allow-none): a #GMainContext, or %NULL
19201  * @priority: the priority at which to run @function
19202  * @function: function to call
19203  * @data: data to pass to @function
19204  * @notify: (allow-none): a function to call when @data is no longer in use, or %NULL.
19205  *
19206  * Invokes a function in such a way that @context is owned during the
19207  * invocation of @function.
19208  *
19209  * This function is the same as g_main_context_invoke() except that it
19210  * lets you specify the priority incase @function ends up being
19211  * scheduled as an idle and also lets you give a #GDestroyNotify for @data.
19212  *
19213  * @notify should not assume that it is called from any particular
19214  * thread or with any particular context acquired.
19215  *
19216  * Since: 2.28
19217  */
19218
19219
19220 /**
19221  * g_main_context_is_owner:
19222  * @context: a #GMainContext
19223  *
19224  * Determines whether this thread holds the (recursive)
19225  * ownership of this #GMainContext. This is useful to
19226  * know before waiting on another thread that may be
19227  * blocking to get ownership of @context.
19228  *
19229  * Returns: %TRUE if current thread is owner of @context.
19230  * Since: 2.10
19231  */
19232
19233
19234 /**
19235  * g_main_context_iteration:
19236  * @context: (allow-none): a #GMainContext (if %NULL, the default context will be used)
19237  * @may_block: whether the call may block.
19238  *
19239  * Runs a single iteration for the given main loop. This involves
19240  * checking to see if any event sources are ready to be processed,
19241  * then if no events sources are ready and @may_block is %TRUE, waiting
19242  * for a source to become ready, then dispatching the highest priority
19243  * events sources that are ready. Otherwise, if @may_block is %FALSE
19244  * sources are not waited to become ready, only those highest priority
19245  * events sources will be dispatched (if any), that are ready at this
19246  * given moment without further waiting.
19247  *
19248  * Note that even when @may_block is %TRUE, it is still possible for
19249  * g_main_context_iteration() to return %FALSE, since the wait may
19250  * be interrupted for other reasons than an event source becoming ready.
19251  *
19252  * Returns: %TRUE if events were dispatched.
19253  */
19254
19255
19256 /**
19257  * g_main_context_new:
19258  *
19259  * Creates a new #GMainContext structure.
19260  *
19261  * Returns: the new #GMainContext
19262  */
19263
19264
19265 /**
19266  * g_main_context_pending:
19267  * @context: (allow-none): a #GMainContext (if %NULL, the default context will be used)
19268  *
19269  * Checks if any sources have pending events for the given context.
19270  *
19271  * Returns: %TRUE if events are pending.
19272  */
19273
19274
19275 /**
19276  * g_main_context_pop_thread_default:
19277  * @context: (allow-none): a #GMainContext object, or %NULL
19278  *
19279  * Pops @context off the thread-default context stack (verifying that
19280  * it was on the top of the stack).
19281  *
19282  * Since: 2.22
19283  */
19284
19285
19286 /**
19287  * g_main_context_prepare:
19288  * @context: a #GMainContext
19289  * @priority: location to store priority of highest priority
19290  *            source already ready.
19291  *
19292  * Prepares to poll sources within a main loop. The resulting information
19293  * for polling is determined by calling g_main_context_query ().
19294  *
19295  * Returns: %TRUE if some source is ready to be dispatched
19296  *               prior to polling.
19297  */
19298
19299
19300 /**
19301  * g_main_context_push_thread_default:
19302  * @context: (allow-none): a #GMainContext, or %NULL for the global default context
19303  *
19304  * Acquires @context and sets it as the thread-default context for the
19305  * current thread. This will cause certain asynchronous operations
19306  * (such as most <link linkend="gio">gio</link>-based I/O) which are
19307  * started in this thread to run under @context and deliver their
19308  * results to its main loop, rather than running under the global
19309  * default context in the main thread. Note that calling this function
19310  * changes the context returned by
19311  * g_main_context_get_thread_default(), <emphasis>not</emphasis> the
19312  * one returned by g_main_context_default(), so it does not affect the
19313  * context used by functions like g_idle_add().
19314  *
19315  * Normally you would call this function shortly after creating a new
19316  * thread, passing it a #GMainContext which will be run by a
19317  * #GMainLoop in that thread, to set a new default context for all
19318  * async operations in that thread. (In this case, you don't need to
19319  * ever call g_main_context_pop_thread_default().) In some cases
19320  * however, you may want to schedule a single operation in a
19321  * non-default context, or temporarily use a non-default context in
19322  * the main thread. In that case, you can wrap the call to the
19323  * asynchronous operation inside a
19324  * g_main_context_push_thread_default() /
19325  * g_main_context_pop_thread_default() pair, but it is up to you to
19326  * ensure that no other asynchronous operations accidentally get
19327  * started while the non-default context is active.
19328  *
19329  * Beware that libraries that predate this function may not correctly
19330  * handle being used from a thread with a thread-default context. Eg,
19331  * see g_file_supports_thread_contexts().
19332  *
19333  * Since: 2.22
19334  */
19335
19336
19337 /**
19338  * g_main_context_query:
19339  * @context: a #GMainContext
19340  * @max_priority: maximum priority source to check
19341  * @timeout_: (out): location to store timeout to be used in polling
19342  * @fds: (out caller-allocates) (array length=n_fds): location to
19343  *       store #GPollFD records that need to be polled.
19344  * @n_fds: length of @fds.
19345  *
19346  * Determines information necessary to poll this main loop.
19347  *
19348  * Returns: the number of records actually stored in @fds,
19349  *   or, if more than @n_fds records need to be stored, the number
19350  *   of records that need to be stored.
19351  */
19352
19353
19354 /**
19355  * g_main_context_ref:
19356  * @context: a #GMainContext
19357  *
19358  * Increases the reference count on a #GMainContext object by one.
19359  *
19360  * Returns: the @context that was passed in (since 2.6)
19361  */
19362
19363
19364 /**
19365  * g_main_context_ref_thread_default:
19366  *
19367  * Gets the thread-default #GMainContext for this thread, as with
19368  * g_main_context_get_thread_default(), but also adds a reference to
19369  * it with g_main_context_ref(). In addition, unlike
19370  * g_main_context_get_thread_default(), if the thread-default context
19371  * is the global default context, this will return that #GMainContext
19372  * (with a ref added to it) rather than returning %NULL.
19373  *
19374  * Returns: (transfer full): the thread-default #GMainContext. Unref
19375  *     with g_main_context_unref() when you are done with it.
19376  * Since: 2.32
19377  */
19378
19379
19380 /**
19381  * g_main_context_release:
19382  * @context: a #GMainContext
19383  *
19384  * Releases ownership of a context previously acquired by this thread
19385  * with g_main_context_acquire(). If the context was acquired multiple
19386  * times, the ownership will be released only when g_main_context_release()
19387  * is called as many times as it was acquired.
19388  */
19389
19390
19391 /**
19392  * g_main_context_remove_poll:
19393  * @context: a #GMainContext
19394  * @fd: a #GPollFD descriptor previously added with g_main_context_add_poll()
19395  *
19396  * Removes file descriptor from the set of file descriptors to be
19397  * polled for a particular context.
19398  */
19399
19400
19401 /**
19402  * g_main_context_set_poll_func:
19403  * @context: a #GMainContext
19404  * @func: the function to call to poll all file descriptors
19405  *
19406  * Sets the function to use to handle polling of file descriptors. It
19407  * will be used instead of the poll() system call
19408  * (or GLib's replacement function, which is used where
19409  * poll() isn't available).
19410  *
19411  * This function could possibly be used to integrate the GLib event
19412  * loop with an external event loop.
19413  */
19414
19415
19416 /**
19417  * g_main_context_unref:
19418  * @context: a #GMainContext
19419  *
19420  * Decreases the reference count on a #GMainContext object by one. If
19421  * the result is zero, free the context and free all associated memory.
19422  */
19423
19424
19425 /**
19426  * g_main_context_wait:
19427  * @context: a #GMainContext
19428  * @cond: a condition variable
19429  * @mutex: a mutex, currently held
19430  *
19431  * Tries to become the owner of the specified context,
19432  * as with g_main_context_acquire(). But if another thread
19433  * is the owner, atomically drop @mutex and wait on @cond until
19434  * that owner releases ownership or until @cond is signaled, then
19435  * try again (once) to become the owner.
19436  *
19437  * Returns: %TRUE if the operation succeeded, and
19438  *   this thread is now the owner of @context.
19439  */
19440
19441
19442 /**
19443  * g_main_context_wakeup:
19444  * @context: a #GMainContext
19445  *
19446  * If @context is currently blocking in g_main_context_iteration()
19447  * waiting for a source to become ready, cause it to stop blocking
19448  * and return.  Otherwise, cause the next invocation of
19449  * g_main_context_iteration() to return without blocking.
19450  *
19451  * This API is useful for low-level control over #GMainContext; for
19452  * example, integrating it with main loop implementations such as
19453  * #GMainLoop.
19454  *
19455  * Another related use for this function is when implementing a main
19456  * loop with a termination condition, computed from multiple threads:
19457  *
19458  * |[
19459  *   #define NUM_TASKS 10
19460  *   static volatile gint tasks_remaining = NUM_TASKS;
19461  *   ...
19462  *  
19463  *   while (g_atomic_int_get (&tasks_remaining) != 0)
19464  *     g_main_context_iteration (NULL, TRUE);
19465  * ]|
19466  *  
19467  * Then in a thread:
19468  * |[
19469  *   perform_work();
19470  *
19471  *   if (g_atomic_int_dec_and_test (&tasks_remaining))
19472  *     g_main_context_wakeup (NULL);
19473  * ]|
19474  */
19475
19476
19477 /**
19478  * g_main_current_source:
19479  *
19480  * Returns the currently firing source for this thread.
19481  *
19482  * Returns: (transfer none): The currently firing source or %NULL.
19483  * Since: 2.12
19484  */
19485
19486
19487 /**
19488  * g_main_depth:
19489  *
19490  * Returns the depth of the stack of calls to
19491  * g_main_context_dispatch() on any #GMainContext in the current thread.
19492  *  That is, when called from the toplevel, it gives 0. When
19493  * called from within a callback from g_main_context_iteration()
19494  * (or g_main_loop_run(), etc.) it returns 1. When called from within
19495  * a callback to a recursive call to g_main_context_iteration(),
19496  * it returns 2. And so forth.
19497  *
19498  * This function is useful in a situation like the following:
19499  * Imagine an extremely simple "garbage collected" system.
19500  *
19501  * |[
19502  * static GList *free_list;
19503  *
19504  * gpointer
19505  * allocate_memory (gsize size)
19506  * {
19507  *   gpointer result = g_malloc (size);
19508  *   free_list = g_list_prepend (free_list, result);
19509  *   return result;
19510  * }
19511  *
19512  * void
19513  * free_allocated_memory (void)
19514  * {
19515  *   GList *l;
19516  *   for (l = free_list; l; l = l->next);
19517  *     g_free (l->data);
19518  *   g_list_free (free_list);
19519  *   free_list = NULL;
19520  *  }
19521  *
19522  * [...]
19523  *
19524  * while (TRUE);
19525  *  {
19526  *    g_main_context_iteration (NULL, TRUE);
19527  *    free_allocated_memory();
19528  *   }
19529  * ]|
19530  *
19531  * This works from an application, however, if you want to do the same
19532  * thing from a library, it gets more difficult, since you no longer
19533  * control the main loop. You might think you can simply use an idle
19534  * function to make the call to free_allocated_memory(), but that
19535  * doesn't work, since the idle function could be called from a
19536  * recursive callback. This can be fixed by using g_main_depth()
19537  *
19538  * |[
19539  * gpointer
19540  * allocate_memory (gsize size)
19541  * {
19542  *   FreeListBlock *block = g_new (FreeListBlock, 1);
19543  *   block->mem = g_malloc (size);
19544  *   block->depth = g_main_depth ();
19545  *   free_list = g_list_prepend (free_list, block);
19546  *   return block->mem;
19547  * }
19548  *
19549  * void
19550  * free_allocated_memory (void)
19551  * {
19552  *   GList *l;
19553  *   
19554  *   int depth = g_main_depth ();
19555  *   for (l = free_list; l; );
19556  *     {
19557  *       GList *next = l->next;
19558  *       FreeListBlock *block = l->data;
19559  *       if (block->depth > depth)
19560  *         {
19561  *           g_free (block->mem);
19562  *           g_free (block);
19563  *           free_list = g_list_delete_link (free_list, l);
19564  *         }
19565  *               
19566  *       l = next;
19567  *     }
19568  *   }
19569  * ]|
19570  *
19571  * There is a temptation to use g_main_depth() to solve
19572  * problems with reentrancy. For instance, while waiting for data
19573  * to be received from the network in response to a menu item,
19574  * the menu item might be selected again. It might seem that
19575  * one could make the menu item's callback return immediately
19576  * and do nothing if g_main_depth() returns a value greater than 1.
19577  * However, this should be avoided since the user then sees selecting
19578  * the menu item do nothing. Furthermore, you'll find yourself adding
19579  * these checks all over your code, since there are doubtless many,
19580  * many things that the user could do. Instead, you can use the
19581  * following techniques:
19582  *
19583  * <orderedlist>
19584  *  <listitem>
19585  *   <para>
19586  *     Use gtk_widget_set_sensitive() or modal dialogs to prevent
19587  *     the user from interacting with elements while the main
19588  *     loop is recursing.
19589  *   </para>
19590  *  </listitem>
19591  *  <listitem>
19592  *   <para>
19593  *     Avoid main loop recursion in situations where you can't handle
19594  *     arbitrary  callbacks. Instead, structure your code so that you
19595  *     simply return to the main loop and then get called again when
19596  *     there is more work to do.
19597  *   </para>
19598  *  </listitem>
19599  * </orderedlist>
19600  *
19601  * Returns: The main loop recursion level in the current thread
19602  */
19603
19604
19605 /**
19606  * g_main_loop_get_context:
19607  * @loop: a #GMainLoop.
19608  *
19609  * Returns the #GMainContext of @loop.
19610  *
19611  * Returns: (transfer none): the #GMainContext of @loop
19612  */
19613
19614
19615 /**
19616  * g_main_loop_is_running:
19617  * @loop: a #GMainLoop.
19618  *
19619  * Checks to see if the main loop is currently being run via g_main_loop_run().
19620  *
19621  * Returns: %TRUE if the mainloop is currently being run.
19622  */
19623
19624
19625 /**
19626  * g_main_loop_new:
19627  * @context: (allow-none): a #GMainContext  (if %NULL, the default context will be used).
19628  * @is_running: set to %TRUE to indicate that the loop is running. This
19629  * is not very important since calling g_main_loop_run() will set this to
19630  * %TRUE anyway.
19631  *
19632  * Creates a new #GMainLoop structure.
19633  *
19634  * Returns: a new #GMainLoop.
19635  */
19636
19637
19638 /**
19639  * g_main_loop_quit:
19640  * @loop: a #GMainLoop
19641  *
19642  * Stops a #GMainLoop from running. Any calls to g_main_loop_run()
19643  * for the loop will return.
19644  *
19645  * Note that sources that have already been dispatched when
19646  * g_main_loop_quit() is called will still be executed.
19647  */
19648
19649
19650 /**
19651  * g_main_loop_ref:
19652  * @loop: a #GMainLoop
19653  *
19654  * Increases the reference count on a #GMainLoop object by one.
19655  *
19656  * Returns: @loop
19657  */
19658
19659
19660 /**
19661  * g_main_loop_run:
19662  * @loop: a #GMainLoop
19663  *
19664  * Runs a main loop until g_main_loop_quit() is called on the loop.
19665  * If this is called for the thread of the loop's #GMainContext,
19666  * it will process events from the loop, otherwise it will
19667  * simply wait.
19668  */
19669
19670
19671 /**
19672  * g_main_loop_unref:
19673  * @loop: a #GMainLoop
19674  *
19675  * Decreases the reference count on a #GMainLoop object by one. If
19676  * the result is zero, free the loop and free all associated memory.
19677  */
19678
19679
19680 /**
19681  * g_malloc:
19682  * @n_bytes: the number of bytes to allocate
19683  *
19684  * Allocates @n_bytes bytes of memory.
19685  * If @n_bytes is 0 it returns %NULL.
19686  *
19687  * Returns: a pointer to the allocated memory
19688  */
19689
19690
19691 /**
19692  * g_malloc0:
19693  * @n_bytes: the number of bytes to allocate
19694  *
19695  * Allocates @n_bytes bytes of memory, initialized to 0's.
19696  * If @n_bytes is 0 it returns %NULL.
19697  *
19698  * Returns: a pointer to the allocated memory
19699  */
19700
19701
19702 /**
19703  * g_malloc0_n:
19704  * @n_blocks: the number of blocks to allocate
19705  * @n_block_bytes: the size of each block in bytes
19706  *
19707  * This function is similar to g_malloc0(), allocating (@n_blocks * @n_block_bytes) bytes,
19708  * but care is taken to detect possible overflow during multiplication.
19709  *
19710  * Since: 2.24
19711  * Returns: a pointer to the allocated memory
19712  */
19713
19714
19715 /**
19716  * g_malloc_n:
19717  * @n_blocks: the number of blocks to allocate
19718  * @n_block_bytes: the size of each block in bytes
19719  *
19720  * This function is similar to g_malloc(), allocating (@n_blocks * @n_block_bytes) bytes,
19721  * but care is taken to detect possible overflow during multiplication.
19722  *
19723  * Since: 2.24
19724  * Returns: a pointer to the allocated memory
19725  */
19726
19727
19728 /**
19729  * g_mapped_file_free:
19730  * @file: a #GMappedFile
19731  *
19732  * This call existed before #GMappedFile had refcounting and is currently
19733  * exactly the same as g_mapped_file_unref().
19734  *
19735  * Since: 2.8
19736  * Deprecated: 2.22: Use g_mapped_file_unref() instead.
19737  */
19738
19739
19740 /**
19741  * g_mapped_file_get_bytes:
19742  * @file: a #GMappedFile
19743  *
19744  * Creates a new #GBytes which references the data mapped from @file.
19745  * The mapped contents of the file must not be modified after creating this
19746  * bytes object, because a #GBytes should be immutable.
19747  *
19748  * Returns: (transfer full): A newly allocated #GBytes referencing data
19749  *     from @file
19750  * Since: 2.34
19751  */
19752
19753
19754 /**
19755  * g_mapped_file_get_contents:
19756  * @file: a #GMappedFile
19757  *
19758  * Returns the contents of a #GMappedFile.
19759  *
19760  * Note that the contents may not be zero-terminated,
19761  * even if the #GMappedFile is backed by a text file.
19762  *
19763  * If the file is empty then %NULL is returned.
19764  *
19765  * Returns: the contents of @file, or %NULL.
19766  * Since: 2.8
19767  */
19768
19769
19770 /**
19771  * g_mapped_file_get_length:
19772  * @file: a #GMappedFile
19773  *
19774  * Returns the length of the contents of a #GMappedFile.
19775  *
19776  * Returns: the length of the contents of @file.
19777  * Since: 2.8
19778  */
19779
19780
19781 /**
19782  * g_mapped_file_new:
19783  * @filename: The path of the file to load, in the GLib filename encoding
19784  * @writable: whether the mapping should be writable
19785  * @error: return location for a #GError, or %NULL
19786  *
19787  * Maps a file into memory. On UNIX, this is using the mmap() function.
19788  *
19789  * If @writable is %TRUE, the mapped buffer may be modified, otherwise
19790  * it is an error to modify the mapped buffer. Modifications to the buffer
19791  * are not visible to other processes mapping the same file, and are not
19792  * written back to the file.
19793  *
19794  * Note that modifications of the underlying file might affect the contents
19795  * of the #GMappedFile. Therefore, mapping should only be used if the file
19796  * will not be modified, or if all modifications of the file are done
19797  * atomically (e.g. using g_file_set_contents()).
19798  *
19799  * If @filename is the name of an empty, regular file, the function
19800  * will successfully return an empty #GMappedFile. In other cases of
19801  * size 0 (e.g. device files such as /dev/null), @error will be set
19802  * to the #GFileError value #G_FILE_ERROR_INVAL.
19803  *
19804  * Returns: a newly allocated #GMappedFile which must be unref'd
19805  *    with g_mapped_file_unref(), or %NULL if the mapping failed.
19806  * Since: 2.8
19807  */
19808
19809
19810 /**
19811  * g_mapped_file_new_from_fd:
19812  * @fd: The file descriptor of the file to load
19813  * @writable: whether the mapping should be writable
19814  * @error: return location for a #GError, or %NULL
19815  *
19816  * Maps a file into memory. On UNIX, this is using the mmap() function.
19817  *
19818  * If @writable is %TRUE, the mapped buffer may be modified, otherwise
19819  * it is an error to modify the mapped buffer. Modifications to the buffer
19820  * are not visible to other processes mapping the same file, and are not
19821  * written back to the file.
19822  *
19823  * Note that modifications of the underlying file might affect the contents
19824  * of the #GMappedFile. Therefore, mapping should only be used if the file
19825  * will not be modified, or if all modifications of the file are done
19826  * atomically (e.g. using g_file_set_contents()).
19827  *
19828  * Returns: a newly allocated #GMappedFile which must be unref'd
19829  *    with g_mapped_file_unref(), or %NULL if the mapping failed.
19830  * Since: 2.32
19831  */
19832
19833
19834 /**
19835  * g_mapped_file_ref:
19836  * @file: a #GMappedFile
19837  *
19838  * Increments the reference count of @file by one.  It is safe to call
19839  * this function from any thread.
19840  *
19841  * Returns: the passed in #GMappedFile.
19842  * Since: 2.22
19843  */
19844
19845
19846 /**
19847  * g_mapped_file_unref:
19848  * @file: a #GMappedFile
19849  *
19850  * Decrements the reference count of @file by one.  If the reference count
19851  * drops to 0, unmaps the buffer of @file and frees it.
19852  *
19853  * It is safe to call this function from any thread.
19854  *
19855  * Since 2.22
19856  */
19857
19858
19859 /**
19860  * g_markup_collect_attributes:
19861  * @element_name: the current tag name
19862  * @attribute_names: the attribute names
19863  * @attribute_values: the attribute values
19864  * @error: a pointer to a #GError or %NULL
19865  * @first_type: the #GMarkupCollectType of the first attribute
19866  * @first_attr: the name of the first attribute
19867  * @...: a pointer to the storage location of the first attribute
19868  *     (or %NULL), followed by more types names and pointers, ending
19869  *     with %G_MARKUP_COLLECT_INVALID
19870  *
19871  * Collects the attributes of the element from the data passed to the
19872  * #GMarkupParser start_element function, dealing with common error
19873  * conditions and supporting boolean values.
19874  *
19875  * This utility function is not required to write a parser but can save
19876  * a lot of typing.
19877  *
19878  * The @element_name, @attribute_names, @attribute_values and @error
19879  * parameters passed to the start_element callback should be passed
19880  * unmodified to this function.
19881  *
19882  * Following these arguments is a list of "supported" attributes to collect.
19883  * It is an error to specify multiple attributes with the same name. If any
19884  * attribute not in the list appears in the @attribute_names array then an
19885  * unknown attribute error will result.
19886  *
19887  * The #GMarkupCollectType field allows specifying the type of collection
19888  * to perform and if a given attribute must appear or is optional.
19889  *
19890  * The attribute name is simply the name of the attribute to collect.
19891  *
19892  * The pointer should be of the appropriate type (see the descriptions
19893  * under #GMarkupCollectType) and may be %NULL in case a particular
19894  * attribute is to be allowed but ignored.
19895  *
19896  * This function deals with issuing errors for missing attributes
19897  * (of type %G_MARKUP_ERROR_MISSING_ATTRIBUTE), unknown attributes
19898  * (of type %G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE) and duplicate
19899  * attributes (of type %G_MARKUP_ERROR_INVALID_CONTENT) as well
19900  * as parse errors for boolean-valued attributes (again of type
19901  * %G_MARKUP_ERROR_INVALID_CONTENT). In all of these cases %FALSE
19902  * will be returned and @error will be set as appropriate.
19903  *
19904  * Returns: %TRUE if successful
19905  * Since: 2.16
19906  */
19907
19908
19909 /**
19910  * g_markup_escape_text:
19911  * @text: some valid UTF-8 text
19912  * @length: length of @text in bytes, or -1 if the text is nul-terminated
19913  *
19914  * Escapes text so that the markup parser will parse it verbatim.
19915  * Less than, greater than, ampersand, etc. are replaced with the
19916  * corresponding entities. This function would typically be used
19917  * when writing out a file to be parsed with the markup parser.
19918  *
19919  * Note that this function doesn't protect whitespace and line endings
19920  * from being processed according to the XML rules for normalization
19921  * of line endings and attribute values.
19922  *
19923  * Note also that this function will produce character references in
19924  * the range of &amp;#x1; ... &amp;#x1f; for all control sequences
19925  * except for tabstop, newline and carriage return.  The character
19926  * references in this range are not valid XML 1.0, but they are
19927  * valid XML 1.1 and will be accepted by the GMarkup parser.
19928  *
19929  * Returns: a newly allocated string with the escaped text
19930  */
19931
19932
19933 /**
19934  * g_markup_parse_context_end_parse:
19935  * @context: a #GMarkupParseContext
19936  * @error: return location for a #GError
19937  *
19938  * Signals to the #GMarkupParseContext that all data has been
19939  * fed into the parse context with g_markup_parse_context_parse().
19940  *
19941  * This function reports an error if the document isn't complete,
19942  * for example if elements are still open.
19943  *
19944  * Returns: %TRUE on success, %FALSE if an error was set
19945  */
19946
19947
19948 /**
19949  * g_markup_parse_context_free:
19950  * @context: a #GMarkupParseContext
19951  *
19952  * Frees a #GMarkupParseContext.
19953  *
19954  * This function can't be called from inside one of the
19955  * #GMarkupParser functions or while a subparser is pushed.
19956  */
19957
19958
19959 /**
19960  * g_markup_parse_context_get_element:
19961  * @context: a #GMarkupParseContext
19962  *
19963  * Retrieves the name of the currently open element.
19964  *
19965  * If called from the start_element or end_element handlers this will
19966  * give the element_name as passed to those functions. For the parent
19967  * elements, see g_markup_parse_context_get_element_stack().
19968  *
19969  * Returns: the name of the currently open element, or %NULL
19970  * Since: 2.2
19971  */
19972
19973
19974 /**
19975  * g_markup_parse_context_get_element_stack:
19976  * @context: a #GMarkupParseContext
19977  *
19978  * Retrieves the element stack from the internal state of the parser.
19979  *
19980  * The returned #GSList is a list of strings where the first item is
19981  * the currently open tag (as would be returned by
19982  * g_markup_parse_context_get_element()) and the next item is its
19983  * immediate parent.
19984  *
19985  * This function is intended to be used in the start_element and
19986  * end_element handlers where g_markup_parse_context_get_element()
19987  * would merely return the name of the element that is being
19988  * processed.
19989  *
19990  * Returns: the element stack, which must not be modified
19991  * Since: 2.16
19992  */
19993
19994
19995 /**
19996  * g_markup_parse_context_get_position:
19997  * @context: a #GMarkupParseContext
19998  * @line_number: (allow-none): return location for a line number, or %NULL
19999  * @char_number: (allow-none): return location for a char-on-line number, or %NULL
20000  *
20001  * Retrieves the current line number and the number of the character on
20002  * that line. Intended for use in error messages; there are no strict
20003  * semantics for what constitutes the "current" line number other than
20004  * "the best number we could come up with for error messages."
20005  */
20006
20007
20008 /**
20009  * g_markup_parse_context_get_user_data:
20010  * @context: a #GMarkupParseContext
20011  *
20012  * Returns the user_data associated with @context.
20013  *
20014  * This will either be the user_data that was provided to
20015  * g_markup_parse_context_new() or to the most recent call
20016  * of g_markup_parse_context_push().
20017  *
20018  * Returns: the provided user_data. The returned data belongs to
20019  *     the markup context and will be freed when
20020  *     g_markup_parse_context_free() is called.
20021  * Since: 2.18
20022  */
20023
20024
20025 /**
20026  * g_markup_parse_context_new:
20027  * @parser: a #GMarkupParser
20028  * @flags: one or more #GMarkupParseFlags
20029  * @user_data: user data to pass to #GMarkupParser functions
20030  * @user_data_dnotify: user data destroy notifier called when
20031  *     the parse context is freed
20032  *
20033  * Creates a new parse context. A parse context is used to parse
20034  * marked-up documents. You can feed any number of documents into
20035  * a context, as long as no errors occur; once an error occurs,
20036  * the parse context can't continue to parse text (you have to
20037  * free it and create a new parse context).
20038  *
20039  * Returns: a new #GMarkupParseContext
20040  */
20041
20042
20043 /**
20044  * g_markup_parse_context_parse:
20045  * @context: a #GMarkupParseContext
20046  * @text: chunk of text to parse
20047  * @text_len: length of @text in bytes
20048  * @error: return location for a #GError
20049  *
20050  * Feed some data to the #GMarkupParseContext.
20051  *
20052  * The data need not be valid UTF-8; an error will be signaled if
20053  * it's invalid. The data need not be an entire document; you can
20054  * feed a document into the parser incrementally, via multiple calls
20055  * to this function. Typically, as you receive data from a network
20056  * connection or file, you feed each received chunk of data into this
20057  * function, aborting the process if an error occurs. Once an error
20058  * is reported, no further data may be fed to the #GMarkupParseContext;
20059  * all errors are fatal.
20060  *
20061  * Returns: %FALSE if an error occurred, %TRUE on success
20062  */
20063
20064
20065 /**
20066  * g_markup_parse_context_pop:
20067  * @context: a #GMarkupParseContext
20068  *
20069  * Completes the process of a temporary sub-parser redirection.
20070  *
20071  * This function exists to collect the user_data allocated by a
20072  * matching call to g_markup_parse_context_push(). It must be called
20073  * in the end_element handler corresponding to the start_element
20074  * handler during which g_markup_parse_context_push() was called.
20075  * You must not call this function from the error callback -- the
20076  * @user_data is provided directly to the callback in that case.
20077  *
20078  * This function is not intended to be directly called by users
20079  * interested in invoking subparsers. Instead, it is intended to
20080  * be used by the subparsers themselves to implement a higher-level
20081  * interface.
20082  *
20083  * Returns: the user data passed to g_markup_parse_context_push()
20084  * Since: 2.18
20085  */
20086
20087
20088 /**
20089  * g_markup_parse_context_push:
20090  * @context: a #GMarkupParseContext
20091  * @parser: a #GMarkupParser
20092  * @user_data: user data to pass to #GMarkupParser functions
20093  *
20094  * Temporarily redirects markup data to a sub-parser.
20095  *
20096  * This function may only be called from the start_element handler of
20097  * a #GMarkupParser. It must be matched with a corresponding call to
20098  * g_markup_parse_context_pop() in the matching end_element handler
20099  * (except in the case that the parser aborts due to an error).
20100  *
20101  * All tags, text and other data between the matching tags is
20102  * redirected to the subparser given by @parser. @user_data is used
20103  * as the user_data for that parser. @user_data is also passed to the
20104  * error callback in the event that an error occurs. This includes
20105  * errors that occur in subparsers of the subparser.
20106  *
20107  * The end tag matching the start tag for which this call was made is
20108  * handled by the previous parser (which is given its own user_data)
20109  * which is why g_markup_parse_context_pop() is provided to allow "one
20110  * last access" to the @user_data provided to this function. In the
20111  * case of error, the @user_data provided here is passed directly to
20112  * the error callback of the subparser and g_markup_parse_context_pop()
20113  * should not be called. In either case, if @user_data was allocated
20114  * then it ought to be freed from both of these locations.
20115  *
20116  * This function is not intended to be directly called by users
20117  * interested in invoking subparsers. Instead, it is intended to be
20118  * used by the subparsers themselves to implement a higher-level
20119  * interface.
20120  *
20121  * As an example, see the following implementation of a simple
20122  * parser that counts the number of tags encountered.
20123  *
20124  * |[
20125  * typedef struct
20126  * {
20127  *   gint tag_count;
20128  * } CounterData;
20129  *
20130  * static void
20131  * counter_start_element (GMarkupParseContext  *context,
20132  *                        const gchar          *element_name,
20133  *                        const gchar         **attribute_names,
20134  *                        const gchar         **attribute_values,
20135  *                        gpointer              user_data,
20136  *                        GError              **error)
20137  * {
20138  *   CounterData *data = user_data;
20139  *
20140  *   data->tag_count++;
20141  * }
20142  *
20143  * static void
20144  * counter_error (GMarkupParseContext *context,
20145  *                GError              *error,
20146  *                gpointer             user_data)
20147  * {
20148  *   CounterData *data = user_data;
20149  *
20150  *   g_slice_free (CounterData, data);
20151  * }
20152  *
20153  * static GMarkupParser counter_subparser =
20154  * {
20155  *   counter_start_element,
20156  *   NULL,
20157  *   NULL,
20158  *   NULL,
20159  *   counter_error
20160  * };
20161  * ]|
20162  *
20163  * In order to allow this parser to be easily used as a subparser, the
20164  * following interface is provided:
20165  *
20166  * |[
20167  * void
20168  * start_counting (GMarkupParseContext *context)
20169  * {
20170  *   CounterData *data = g_slice_new (CounterData);
20171  *
20172  *   data->tag_count = 0;
20173  *   g_markup_parse_context_push (context, &counter_subparser, data);
20174  * }
20175  *
20176  * gint
20177  * end_counting (GMarkupParseContext *context)
20178  * {
20179  *   CounterData *data = g_markup_parse_context_pop (context);
20180  *   int result;
20181  *
20182  *   result = data->tag_count;
20183  *   g_slice_free (CounterData, data);
20184  *
20185  *   return result;
20186  * }
20187  * ]|
20188  *
20189  * The subparser would then be used as follows:
20190  *
20191  * |[
20192  * static void start_element (context, element_name, ...)
20193  * {
20194  *   if (strcmp (element_name, "count-these") == 0)
20195  *     start_counting (context);
20196  *
20197  *   /&ast; else, handle other tags... &ast;/
20198  * }
20199  *
20200  * static void end_element (context, element_name, ...)
20201  * {
20202  *   if (strcmp (element_name, "count-these") == 0)
20203  *     g_print ("Counted %d tags\n", end_counting (context));
20204  *
20205  *   /&ast; else, handle other tags... &ast;/
20206  * }
20207  * ]|
20208  *
20209  * Since: 2.18
20210  */
20211
20212
20213 /**
20214  * g_markup_parse_context_ref:
20215  * @context: a #GMarkupParseContext
20216  *
20217  * Increases the reference count of @context.
20218  *
20219  * Returns: the same @context
20220  * Since: 2.36
20221  */
20222
20223
20224 /**
20225  * g_markup_parse_context_unref:
20226  * @context: a #GMarkupParseContext
20227  *
20228  * Decreases the reference count of @context.  When its reference count
20229  * drops to 0, it is freed.
20230  *
20231  * Since: 2.36
20232  */
20233
20234
20235 /**
20236  * g_markup_printf_escaped:
20237  * @format: printf() style format string
20238  * @...: the arguments to insert in the format string
20239  *
20240  * Formats arguments according to @format, escaping
20241  * all string and character arguments in the fashion
20242  * of g_markup_escape_text(). This is useful when you
20243  * want to insert literal strings into XML-style markup
20244  * output, without having to worry that the strings
20245  * might themselves contain markup.
20246  *
20247  * |[
20248  * const char *store = "Fortnum &amp; Mason";
20249  * const char *item = "Tea";
20250  * char *output;
20251  * &nbsp;
20252  * output = g_markup_printf_escaped ("&lt;purchase&gt;"
20253  *                                   "&lt;store&gt;&percnt;s&lt;/store&gt;"
20254  *                                   "&lt;item&gt;&percnt;s&lt;/item&gt;"
20255  *                                   "&lt;/purchase&gt;",
20256  *                                   store, item);
20257  * ]|
20258  *
20259  * Returns: newly allocated result from formatting
20260  *    operation. Free with g_free().
20261  * Since: 2.4
20262  */
20263
20264
20265 /**
20266  * g_markup_vprintf_escaped:
20267  * @format: printf() style format string
20268  * @args: variable argument list, similar to vprintf()
20269  *
20270  * Formats the data in @args according to @format, escaping
20271  * all string and character arguments in the fashion
20272  * of g_markup_escape_text(). See g_markup_printf_escaped().
20273  *
20274  * Returns: newly allocated result from formatting
20275  *  operation. Free with g_free().
20276  * Since: 2.4
20277  */
20278
20279
20280 /**
20281  * g_match_info_expand_references:
20282  * @match_info: (allow-none): a #GMatchInfo or %NULL
20283  * @string_to_expand: the string to expand
20284  * @error: location to store the error occurring, or %NULL to ignore errors
20285  *
20286  * Returns a new string containing the text in @string_to_expand with
20287  * references and escape sequences expanded. References refer to the last
20288  * match done with @string against @regex and have the same syntax used by
20289  * g_regex_replace().
20290  *
20291  * The @string_to_expand must be UTF-8 encoded even if #G_REGEX_RAW was
20292  * passed to g_regex_new().
20293  *
20294  * The backreferences are extracted from the string passed to the match
20295  * function, so you cannot call this function after freeing the string.
20296  *
20297  * @match_info may be %NULL in which case @string_to_expand must not
20298  * contain references. For instance "foo\n" does not refer to an actual
20299  * pattern and '\n' merely will be replaced with \n character,
20300  * while to expand "\0" (whole match) one needs the result of a match.
20301  * Use g_regex_check_replacement() to find out whether @string_to_expand
20302  * contains references.
20303  *
20304  * Returns: (allow-none): the expanded string, or %NULL if an error occurred
20305  * Since: 2.14
20306  */
20307
20308
20309 /**
20310  * g_match_info_fetch:
20311  * @match_info: #GMatchInfo structure
20312  * @match_num: number of the sub expression
20313  *
20314  * Retrieves the text matching the @match_num<!-- -->'th capturing
20315  * parentheses. 0 is the full text of the match, 1 is the first paren
20316  * set, 2 the second, and so on.
20317  *
20318  * If @match_num is a valid sub pattern but it didn't match anything
20319  * (e.g. sub pattern 1, matching "b" against "(a)?b") then an empty
20320  * string is returned.
20321  *
20322  * If the match was obtained using the DFA algorithm, that is using
20323  * g_regex_match_all() or g_regex_match_all_full(), the retrieved
20324  * string is not that of a set of parentheses but that of a matched
20325  * substring. Substrings are matched in reverse order of length, so
20326  * 0 is the longest match.
20327  *
20328  * The string is fetched from the string passed to the match function,
20329  * so you cannot call this function after freeing the string.
20330  *
20331  * Returns: (allow-none): The matched substring, or %NULL if an error
20332  *     occurred. You have to free the string yourself
20333  * Since: 2.14
20334  */
20335
20336
20337 /**
20338  * g_match_info_fetch_all:
20339  * @match_info: a #GMatchInfo structure
20340  *
20341  * Bundles up pointers to each of the matching substrings from a match
20342  * and stores them in an array of gchar pointers. The first element in
20343  * the returned array is the match number 0, i.e. the entire matched
20344  * text.
20345  *
20346  * If a sub pattern didn't match anything (e.g. sub pattern 1, matching
20347  * "b" against "(a)?b") then an empty string is inserted.
20348  *
20349  * If the last match was obtained using the DFA algorithm, that is using
20350  * g_regex_match_all() or g_regex_match_all_full(), the retrieved
20351  * strings are not that matched by sets of parentheses but that of the
20352  * matched substring. Substrings are matched in reverse order of length,
20353  * so the first one is the longest match.
20354  *
20355  * The strings are fetched from the string passed to the match function,
20356  * so you cannot call this function after freeing the string.
20357  *
20358  * Returns: (transfer full): a %NULL-terminated array of gchar *
20359  *     pointers.  It must be freed using g_strfreev(). If the previous
20360  *     match failed %NULL is returned
20361  * Since: 2.14
20362  */
20363
20364
20365 /**
20366  * g_match_info_fetch_named:
20367  * @match_info: #GMatchInfo structure
20368  * @name: name of the subexpression
20369  *
20370  * Retrieves the text matching the capturing parentheses named @name.
20371  *
20372  * If @name is a valid sub pattern name but it didn't match anything
20373  * (e.g. sub pattern "X", matching "b" against "(?P&lt;X&gt;a)?b")
20374  * then an empty string is returned.
20375  *
20376  * The string is fetched from the string passed to the match function,
20377  * so you cannot call this function after freeing the string.
20378  *
20379  * Returns: (allow-none): The matched substring, or %NULL if an error
20380  *     occurred. You have to free the string yourself
20381  * Since: 2.14
20382  */
20383
20384
20385 /**
20386  * g_match_info_fetch_named_pos:
20387  * @match_info: #GMatchInfo structure
20388  * @name: name of the subexpression
20389  * @start_pos: (out) (allow-none): pointer to location where to store
20390  *     the start position, or %NULL
20391  * @end_pos: (out) (allow-none): pointer to location where to store
20392  *     the end position, or %NULL
20393  *
20394  * Retrieves the position in bytes of the capturing parentheses named @name.
20395  *
20396  * If @name is a valid sub pattern name but it didn't match anything
20397  * (e.g. sub pattern "X", matching "b" against "(?P&lt;X&gt;a)?b")
20398  * then @start_pos and @end_pos are set to -1 and %TRUE is returned.
20399  *
20400  * Returns: %TRUE if the position was fetched, %FALSE otherwise.
20401  *     If the position cannot be fetched, @start_pos and @end_pos
20402  *     are left unchanged.
20403  * Since: 2.14
20404  */
20405
20406
20407 /**
20408  * g_match_info_fetch_pos:
20409  * @match_info: #GMatchInfo structure
20410  * @match_num: number of the sub expression
20411  * @start_pos: (out) (allow-none): pointer to location where to store
20412  *     the start position, or %NULL
20413  * @end_pos: (out) (allow-none): pointer to location where to store
20414  *     the end position, or %NULL
20415  *
20416  * Retrieves the position in bytes of the @match_num<!-- -->'th capturing
20417  * parentheses. 0 is the full text of the match, 1 is the first
20418  * paren set, 2 the second, and so on.
20419  *
20420  * If @match_num is a valid sub pattern but it didn't match anything
20421  * (e.g. sub pattern 1, matching "b" against "(a)?b") then @start_pos
20422  * and @end_pos are set to -1 and %TRUE is returned.
20423  *
20424  * If the match was obtained using the DFA algorithm, that is using
20425  * g_regex_match_all() or g_regex_match_all_full(), the retrieved
20426  * position is not that of a set of parentheses but that of a matched
20427  * substring. Substrings are matched in reverse order of length, so
20428  * 0 is the longest match.
20429  *
20430  * Returns: %TRUE if the position was fetched, %FALSE otherwise. If
20431  *   the position cannot be fetched, @start_pos and @end_pos are left
20432  *   unchanged
20433  * Since: 2.14
20434  */
20435
20436
20437 /**
20438  * g_match_info_free:
20439  * @match_info: (allow-none): a #GMatchInfo, or %NULL
20440  *
20441  * If @match_info is not %NULL, calls g_match_info_unref(); otherwise does
20442  * nothing.
20443  *
20444  * Since: 2.14
20445  */
20446
20447
20448 /**
20449  * g_match_info_get_match_count:
20450  * @match_info: a #GMatchInfo structure
20451  *
20452  * Retrieves the number of matched substrings (including substring 0,
20453  * that is the whole matched text), so 1 is returned if the pattern
20454  * has no substrings in it and 0 is returned if the match failed.
20455  *
20456  * If the last match was obtained using the DFA algorithm, that is
20457  * using g_regex_match_all() or g_regex_match_all_full(), the retrieved
20458  * count is not that of the number of capturing parentheses but that of
20459  * the number of matched substrings.
20460  *
20461  * Returns: Number of matched substrings, or -1 if an error occurred
20462  * Since: 2.14
20463  */
20464
20465
20466 /**
20467  * g_match_info_get_regex:
20468  * @match_info: a #GMatchInfo
20469  *
20470  * Returns #GRegex object used in @match_info. It belongs to Glib
20471  * and must not be freed. Use g_regex_ref() if you need to keep it
20472  * after you free @match_info object.
20473  *
20474  * Returns: #GRegex object used in @match_info
20475  * Since: 2.14
20476  */
20477
20478
20479 /**
20480  * g_match_info_get_string:
20481  * @match_info: a #GMatchInfo
20482  *
20483  * Returns the string searched with @match_info. This is the
20484  * string passed to g_regex_match() or g_regex_replace() so
20485  * you may not free it before calling this function.
20486  *
20487  * Returns: the string searched with @match_info
20488  * Since: 2.14
20489  */
20490
20491
20492 /**
20493  * g_match_info_is_partial_match:
20494  * @match_info: a #GMatchInfo structure
20495  *
20496  * Usually if the string passed to g_regex_match*() matches as far as
20497  * it goes, but is too short to match the entire pattern, %FALSE is
20498  * returned. There are circumstances where it might be helpful to
20499  * distinguish this case from other cases in which there is no match.
20500  *
20501  * Consider, for example, an application where a human is required to
20502  * type in data for a field with specific formatting requirements. An
20503  * example might be a date in the form ddmmmyy, defined by the pattern
20504  * "^\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d$".
20505  * If the application sees the user’s keystrokes one by one, and can
20506  * check that what has been typed so far is potentially valid, it is
20507  * able to raise an error as soon as a mistake is made.
20508  *
20509  * GRegex supports the concept of partial matching by means of the
20510  * #G_REGEX_MATCH_PARTIAL_SOFT and #G_REGEX_MATCH_PARTIAL_HARD flags.
20511  * When they are used, the return code for
20512  * g_regex_match() or g_regex_match_full() is, as usual, %TRUE
20513  * for a complete match, %FALSE otherwise. But, when these functions
20514  * return %FALSE, you can check if the match was partial calling
20515  * g_match_info_is_partial_match().
20516  *
20517  * The difference between #G_REGEX_MATCH_PARTIAL_SOFT and
20518  * #G_REGEX_MATCH_PARTIAL_HARD is that when a partial match is encountered
20519  * with #G_REGEX_MATCH_PARTIAL_SOFT, matching continues to search for a
20520  * possible complete match, while with #G_REGEX_MATCH_PARTIAL_HARD matching
20521  * stops at the partial match.
20522  * When both #G_REGEX_MATCH_PARTIAL_SOFT and #G_REGEX_MATCH_PARTIAL_HARD
20523  * are set, the latter takes precedence.
20524  *
20525  * There were formerly some restrictions on the pattern for partial matching.
20526  * The restrictions no longer apply.
20527  *
20528  * See <ulink>man:pcrepartial</ulink> for more information on partial matching.
20529  *
20530  * Returns: %TRUE if the match was partial, %FALSE otherwise
20531  * Since: 2.14
20532  */
20533
20534
20535 /**
20536  * g_match_info_matches:
20537  * @match_info: a #GMatchInfo structure
20538  *
20539  * Returns whether the previous match operation succeeded.
20540  *
20541  * Returns: %TRUE if the previous match operation succeeded,
20542  *   %FALSE otherwise
20543  * Since: 2.14
20544  */
20545
20546
20547 /**
20548  * g_match_info_next:
20549  * @match_info: a #GMatchInfo structure
20550  * @error: location to store the error occurring, or %NULL to ignore errors
20551  *
20552  * Scans for the next match using the same parameters of the previous
20553  * call to g_regex_match_full() or g_regex_match() that returned
20554  * @match_info.
20555  *
20556  * The match is done on the string passed to the match function, so you
20557  * cannot free it before calling this function.
20558  *
20559  * Returns: %TRUE is the string matched, %FALSE otherwise
20560  * Since: 2.14
20561  */
20562
20563
20564 /**
20565  * g_match_info_ref:
20566  * @match_info: a #GMatchInfo
20567  *
20568  * Increases reference count of @match_info by 1.
20569  *
20570  * Returns: @match_info
20571  * Since: 2.30
20572  */
20573
20574
20575 /**
20576  * g_match_info_unref:
20577  * @match_info: a #GMatchInfo
20578  *
20579  * Decreases reference count of @match_info by 1. When reference count drops
20580  * to zero, it frees all the memory associated with the match_info structure.
20581  *
20582  * Since: 2.30
20583  */
20584
20585
20586 /**
20587  * g_mem_gc_friendly:
20588  *
20589  * This variable is %TRUE if the <envar>G_DEBUG</envar> environment variable
20590  * includes the key <literal>gc-friendly</literal>.
20591  */
20592
20593
20594 /**
20595  * g_mem_is_system_malloc:
20596  *
20597  * Checks whether the allocator used by g_malloc() is the system's
20598  * malloc implementation. If it returns %TRUE memory allocated with
20599  * malloc() can be used interchangeable with memory allocated using g_malloc().
20600  * This function is useful for avoiding an extra copy of allocated memory returned
20601  * by a non-GLib-based API.
20602  *
20603  * A different allocator can be set using g_mem_set_vtable().
20604  *
20605  * Returns: if %TRUE, malloc() and g_malloc() can be mixed.
20606  */
20607
20608
20609 /**
20610  * g_mem_profile:
20611  *
20612  * Outputs a summary of memory usage.
20613  *
20614  * It outputs the frequency of allocations of different sizes,
20615  * the total number of bytes which have been allocated,
20616  * the total number of bytes which have been freed,
20617  * and the difference between the previous two values, i.e. the number of bytes
20618  * still in use.
20619  *
20620  * Note that this function will not output anything unless you have
20621  * previously installed the #glib_mem_profiler_table with g_mem_set_vtable().
20622  */
20623
20624
20625 /**
20626  * g_mem_set_vtable:
20627  * @vtable: table of memory allocation routines.
20628  *
20629  * Sets the #GMemVTable to use for memory allocation. You can use this to provide
20630  * custom memory allocation routines. <emphasis>This function must be called
20631  * before using any other GLib functions.</emphasis> The @vtable only needs to
20632  * provide malloc(), realloc(), and free() functions; GLib can provide default
20633  * implementations of the others. The malloc() and realloc() implementations
20634  * should return %NULL on failure, GLib will handle error-checking for you.
20635  * @vtable is copied, so need not persist after this function has been called.
20636  */
20637
20638
20639 /**
20640  * g_memdup:
20641  * @mem: the memory to copy.
20642  * @byte_size: the number of bytes to copy.
20643  *
20644  * Allocates @byte_size bytes of memory, and copies @byte_size bytes into it
20645  * from @mem. If @mem is %NULL it returns %NULL.
20646  *
20647  * Returns: a pointer to the newly-allocated copy of the memory, or %NULL if @mem
20648  *  is %NULL.
20649  */
20650
20651
20652 /**
20653  * g_memmove:
20654  * @dest: the destination address to copy the bytes to.
20655  * @src: the source address to copy the bytes from.
20656  * @len: the number of bytes to copy.
20657  *
20658  * Copies a block of memory @len bytes long, from @src to @dest.
20659  * The source and destination areas may overlap.
20660  *
20661  * In order to use this function, you must include
20662  * <filename>string.h</filename> yourself, because this macro will
20663  * typically simply resolve to memmove() and GLib does not include
20664  * <filename>string.h</filename> for you.
20665  */
20666
20667
20668 /**
20669  * g_message:
20670  * @...: format string, followed by parameters to insert
20671  *     into the format string (as with printf())
20672  *
20673  * A convenience function/macro to log a normal message.
20674  *
20675  * If g_log_default_handler() is used as the log handler function, a new-line
20676  * character will automatically be appended to @..., and need not be entered
20677  * manually.
20678  */
20679
20680
20681 /**
20682  * g_mkdir:
20683  * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
20684  * @mode: permissions to use for the newly created directory
20685  *
20686  * A wrapper for the POSIX mkdir() function. The mkdir() function
20687  * attempts to create a directory with the given name and permissions.
20688  * The mode argument is ignored on Windows.
20689  *
20690  * See your C library manual for more details about mkdir().
20691  *
20692  * Returns: 0 if the directory was successfully created, -1 if an error
20693  *    occurred
20694  * Since: 2.6
20695  */
20696
20697
20698 /**
20699  * g_mkdir_with_parents:
20700  * @pathname: a pathname in the GLib file name encoding
20701  * @mode: permissions to use for newly created directories
20702  *
20703  * Create a directory if it doesn't already exist. Create intermediate
20704  * parent directories as needed, too.
20705  *
20706  * Returns: 0 if the directory already exists, or was successfully
20707  * created. Returns -1 if an error occurred, with errno set.
20708  * Since: 2.8
20709  */
20710
20711
20712 /**
20713  * g_mkdtemp:
20714  * @tmpl: (type filename): template directory name
20715  *
20716  * Creates a temporary directory. See the mkdtemp() documentation
20717  * on most UNIX-like systems.
20718  *
20719  * The parameter is a string that should follow the rules for
20720  * mkdtemp() templates, i.e. contain the string "XXXXXX".
20721  * g_mkdtemp() is slightly more flexible than mkdtemp() in that the
20722  * sequence does not have to occur at the very end of the template
20723  * and you can pass a @mode and additional @flags. The X string will
20724  * be modified to form the name of a directory that didn't exist.
20725  * The string should be in the GLib file name encoding. Most importantly,
20726  * on Windows it should be in UTF-8.
20727  *
20728  * Returns: A pointer to @tmpl, which has been modified
20729  *     to hold the directory name.  In case of errors, %NULL is
20730  *     returned and %errno will be set.
20731  * Since: 2.30
20732  */
20733
20734
20735 /**
20736  * g_mkdtemp_full:
20737  * @tmpl: (type filename): template directory name
20738  * @mode: permissions to create the temporary directory with
20739  *
20740  * Creates a temporary directory. See the mkdtemp() documentation
20741  * on most UNIX-like systems.
20742  *
20743  * The parameter is a string that should follow the rules for
20744  * mkdtemp() templates, i.e. contain the string "XXXXXX".
20745  * g_mkdtemp() is slightly more flexible than mkdtemp() in that the
20746  * sequence does not have to occur at the very end of the template
20747  * and you can pass a @mode. The X string will be modified to form
20748  * the name of a directory that didn't exist. The string should be
20749  * in the GLib file name encoding. Most importantly, on Windows it
20750  * should be in UTF-8.
20751  *
20752  * Returns: A pointer to @tmpl, which has been modified
20753  *     to hold the directory name. In case of errors, %NULL is
20754  *     returned, and %errno will be set.
20755  * Since: 2.30
20756  */
20757
20758
20759 /**
20760  * g_mkstemp:
20761  * @tmpl: (type filename): template filename
20762  *
20763  * Opens a temporary file. See the mkstemp() documentation
20764  * on most UNIX-like systems.
20765  *
20766  * The parameter is a string that should follow the rules for
20767  * mkstemp() templates, i.e. contain the string "XXXXXX".
20768  * g_mkstemp() is slightly more flexible than mkstemp() in that the
20769  * sequence does not have to occur at the very end of the template.
20770  * The X string will be modified to form the name of a file that
20771  * didn't exist. The string should be in the GLib file name encoding.
20772  * Most importantly, on Windows it should be in UTF-8.
20773  *
20774  * Returns: A file handle (as from open()) to the file
20775  *     opened for reading and writing. The file is opened in binary
20776  *     mode on platforms where there is a difference. The file handle
20777  *     should be closed with close(). In case of errors, -1 is
20778  *     returned and %errno will be set.
20779  */
20780
20781
20782 /**
20783  * g_mkstemp_full:
20784  * @tmpl: (type filename): template filename
20785  * @flags: flags to pass to an open() call in addition to O_EXCL
20786  *     and O_CREAT, which are passed automatically
20787  * @mode: permissions to create the temporary file with
20788  *
20789  * Opens a temporary file. See the mkstemp() documentation
20790  * on most UNIX-like systems.
20791  *
20792  * The parameter is a string that should follow the rules for
20793  * mkstemp() templates, i.e. contain the string "XXXXXX".
20794  * g_mkstemp_full() is slightly more flexible than mkstemp()
20795  * in that the sequence does not have to occur at the very end of the
20796  * template and you can pass a @mode and additional @flags. The X
20797  * string will be modified to form the name of a file that didn't exist.
20798  * The string should be in the GLib file name encoding. Most importantly,
20799  * on Windows it should be in UTF-8.
20800  *
20801  * Returns: A file handle (as from open()) to the file
20802  *     opened for reading and writing. The file handle should be
20803  *     closed with close(). In case of errors, -1 is returned
20804  *     and %errno will be set.
20805  * Since: 2.22
20806  */
20807
20808
20809 /**
20810  * g_mutex_clear:
20811  * @mutex: an initialized #GMutex
20812  *
20813  * Frees the resources allocated to a mutex with g_mutex_init().
20814  *
20815  * This function should not be used with a #GMutex that has been
20816  * statically allocated.
20817  *
20818  * Calling g_mutex_clear() on a locked mutex leads to undefined
20819  * behaviour.
20820  *
20821  * Sine: 2.32
20822  */
20823
20824
20825 /**
20826  * g_mutex_init:
20827  * @mutex: an uninitialized #GMutex
20828  *
20829  * Initializes a #GMutex so that it can be used.
20830  *
20831  * This function is useful to initialize a mutex that has been
20832  * allocated on the stack, or as part of a larger structure.
20833  * It is not necessary to initialize a mutex that has been
20834  * statically allocated.
20835  *
20836  * |[
20837  *   typedef struct {
20838  *     GMutex m;
20839  *     ...
20840  *   } Blob;
20841  *
20842  * Blob *b;
20843  *
20844  * b = g_new (Blob, 1);
20845  * g_mutex_init (&b->m);
20846  * ]|
20847  *
20848  * To undo the effect of g_mutex_init() when a mutex is no longer
20849  * needed, use g_mutex_clear().
20850  *
20851  * Calling g_mutex_init() on an already initialized #GMutex leads
20852  * to undefined behaviour.
20853  *
20854  * Since: 2.32
20855  */
20856
20857
20858 /**
20859  * g_mutex_lock:
20860  * @mutex: a #GMutex
20861  *
20862  * Locks @mutex. If @mutex is already locked by another thread, the
20863  * current thread will block until @mutex is unlocked by the other
20864  * thread.
20865  *
20866  * <note>#GMutex is neither guaranteed to be recursive nor to be
20867  * non-recursive.  As such, calling g_mutex_lock() on a #GMutex that has
20868  * already been locked by the same thread results in undefined behaviour
20869  * (including but not limited to deadlocks).</note>
20870  */
20871
20872
20873 /**
20874  * g_mutex_trylock:
20875  * @mutex: a #GMutex
20876  *
20877  * Tries to lock @mutex. If @mutex is already locked by another thread,
20878  * it immediately returns %FALSE. Otherwise it locks @mutex and returns
20879  * %TRUE.
20880  *
20881  * <note>#GMutex is neither guaranteed to be recursive nor to be
20882  * non-recursive.  As such, calling g_mutex_lock() on a #GMutex that has
20883  * already been locked by the same thread results in undefined behaviour
20884  * (including but not limited to deadlocks or arbitrary return values).
20885  * </note>
20886  *
20887  * Returns: %TRUE if @mutex could be locked
20888  */
20889
20890
20891 /**
20892  * g_mutex_unlock:
20893  * @mutex: a #GMutex
20894  *
20895  * Unlocks @mutex. If another thread is blocked in a g_mutex_lock()
20896  * call for @mutex, it will become unblocked and can lock @mutex itself.
20897  *
20898  * Calling g_mutex_unlock() on a mutex that is not locked by the
20899  * current thread leads to undefined behaviour.
20900  */
20901
20902
20903 /**
20904  * g_node_child_index:
20905  * @node: a #GNode
20906  * @data: the data to find
20907  *
20908  * Gets the position of the first child of a #GNode
20909  * which contains the given data.
20910  *
20911  * Returns: the index of the child of @node which contains
20912  *     @data, or -1 if the data is not found
20913  */
20914
20915
20916 /**
20917  * g_node_child_position:
20918  * @node: a #GNode
20919  * @child: a child of @node
20920  *
20921  * Gets the position of a #GNode with respect to its siblings.
20922  * @child must be a child of @node. The first child is numbered 0,
20923  * the second 1, and so on.
20924  *
20925  * Returns: the position of @child with respect to its siblings
20926  */
20927
20928
20929 /**
20930  * g_node_children_foreach:
20931  * @node: a #GNode
20932  * @flags: which types of children are to be visited, one of
20933  *     %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
20934  * @func: the function to call for each visited node
20935  * @data: user data to pass to the function
20936  *
20937  * Calls a function for each of the children of a #GNode.
20938  * Note that it doesn't descend beneath the child nodes.
20939  */
20940
20941
20942 /**
20943  * g_node_copy:
20944  * @node: a #GNode
20945  *
20946  * Recursively copies a #GNode (but does not deep-copy the data inside the
20947  * nodes, see g_node_copy_deep() if you need that).
20948  *
20949  * Returns: a new #GNode containing the same data pointers
20950  */
20951
20952
20953 /**
20954  * g_node_copy_deep:
20955  * @node: a #GNode
20956  * @copy_func: the function which is called to copy the data inside each node,
20957  *   or %NULL to use the original data.
20958  * @data: data to pass to @copy_func
20959  *
20960  * Recursively copies a #GNode and its data.
20961  *
20962  * Returns: a new #GNode containing copies of the data in @node.
20963  * Since: 2.4
20964  */
20965
20966
20967 /**
20968  * g_node_depth:
20969  * @node: a #GNode
20970  *
20971  * Gets the depth of a #GNode.
20972  *
20973  * If @node is %NULL the depth is 0. The root node has a depth of 1.
20974  * For the children of the root node the depth is 2. And so on.
20975  *
20976  * Returns: the depth of the #GNode
20977  */
20978
20979
20980 /**
20981  * g_node_destroy:
20982  * @root: the root of the tree/subtree to destroy
20983  *
20984  * Removes @root and its children from the tree, freeing any memory
20985  * allocated.
20986  */
20987
20988
20989 /**
20990  * g_node_find:
20991  * @root: the root #GNode of the tree to search
20992  * @order: the order in which nodes are visited - %G_IN_ORDER,
20993  *     %G_PRE_ORDER, %G_POST_ORDER, or %G_LEVEL_ORDER
20994  * @flags: which types of children are to be searched, one of
20995  *     %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
20996  * @data: the data to find
20997  *
20998  * Finds a #GNode in a tree.
20999  *
21000  * Returns: the found #GNode, or %NULL if the data is not found
21001  */
21002
21003
21004 /**
21005  * g_node_find_child:
21006  * @node: a #GNode
21007  * @flags: which types of children are to be searched, one of
21008  *     %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
21009  * @data: the data to find
21010  *
21011  * Finds the first child of a #GNode with the given data.
21012  *
21013  * Returns: the found child #GNode, or %NULL if the data is not found
21014  */
21015
21016
21017 /**
21018  * g_node_first_sibling:
21019  * @node: a #GNode
21020  *
21021  * Gets the first sibling of a #GNode.
21022  * This could possibly be the node itself.
21023  *
21024  * Returns: the first sibling of @node
21025  */
21026
21027
21028 /**
21029  * g_node_get_root:
21030  * @node: a #GNode
21031  *
21032  * Gets the root of a tree.
21033  *
21034  * Returns: the root of the tree
21035  */
21036
21037
21038 /**
21039  * g_node_insert:
21040  * @parent: the #GNode to place @node under
21041  * @position: the position to place @node at, with respect to its siblings
21042  *     If position is -1, @node is inserted as the last child of @parent
21043  * @node: the #GNode to insert
21044  *
21045  * Inserts a #GNode beneath the parent at the given position.
21046  *
21047  * Returns: the inserted #GNode
21048  */
21049
21050
21051 /**
21052  * g_node_insert_after:
21053  * @parent: the #GNode to place @node under
21054  * @sibling: the sibling #GNode to place @node after.
21055  *     If sibling is %NULL, the node is inserted as the first child of @parent.
21056  * @node: the #GNode to insert
21057  *
21058  * Inserts a #GNode beneath the parent after the given sibling.
21059  *
21060  * Returns: the inserted #GNode
21061  */
21062
21063
21064 /**
21065  * g_node_insert_before:
21066  * @parent: the #GNode to place @node under
21067  * @sibling: the sibling #GNode to place @node before.
21068  *     If sibling is %NULL, the node is inserted as the last child of @parent.
21069  * @node: the #GNode to insert
21070  *
21071  * Inserts a #GNode beneath the parent before the given sibling.
21072  *
21073  * Returns: the inserted #GNode
21074  */
21075
21076
21077 /**
21078  * g_node_is_ancestor:
21079  * @node: a #GNode
21080  * @descendant: a #GNode
21081  *
21082  * Returns %TRUE if @node is an ancestor of @descendant.
21083  * This is true if node is the parent of @descendant,
21084  * or if node is the grandparent of @descendant etc.
21085  *
21086  * Returns: %TRUE if @node is an ancestor of @descendant
21087  */
21088
21089
21090 /**
21091  * g_node_last_child:
21092  * @node: a #GNode (must not be %NULL)
21093  *
21094  * Gets the last child of a #GNode.
21095  *
21096  * Returns: the last child of @node, or %NULL if @node has no children
21097  */
21098
21099
21100 /**
21101  * g_node_last_sibling:
21102  * @node: a #GNode
21103  *
21104  * Gets the last sibling of a #GNode.
21105  * This could possibly be the node itself.
21106  *
21107  * Returns: the last sibling of @node
21108  */
21109
21110
21111 /**
21112  * g_node_max_height:
21113  * @root: a #GNode
21114  *
21115  * Gets the maximum height of all branches beneath a #GNode.
21116  * This is the maximum distance from the #GNode to all leaf nodes.
21117  *
21118  * If @root is %NULL, 0 is returned. If @root has no children,
21119  * 1 is returned. If @root has children, 2 is returned. And so on.
21120  *
21121  * Returns: the maximum height of the tree beneath @root
21122  */
21123
21124
21125 /**
21126  * g_node_n_children:
21127  * @node: a #GNode
21128  *
21129  * Gets the number of children of a #GNode.
21130  *
21131  * Returns: the number of children of @node
21132  */
21133
21134
21135 /**
21136  * g_node_n_nodes:
21137  * @root: a #GNode
21138  * @flags: which types of children are to be counted, one of
21139  *     %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
21140  *
21141  * Gets the number of nodes in a tree.
21142  *
21143  * Returns: the number of nodes in the tree
21144  */
21145
21146
21147 /**
21148  * g_node_new:
21149  * @data: the data of the new node
21150  *
21151  * Creates a new #GNode containing the given data.
21152  * Used to create the first node in a tree.
21153  *
21154  * Returns: a new #GNode
21155  */
21156
21157
21158 /**
21159  * g_node_nth_child:
21160  * @node: a #GNode
21161  * @n: the index of the desired child
21162  *
21163  * Gets a child of a #GNode, using the given index.
21164  * The first child is at index 0. If the index is
21165  * too big, %NULL is returned.
21166  *
21167  * Returns: the child of @node at index @n
21168  */
21169
21170
21171 /**
21172  * g_node_prepend:
21173  * @parent: the #GNode to place the new #GNode under
21174  * @node: the #GNode to insert
21175  *
21176  * Inserts a #GNode as the first child of the given parent.
21177  *
21178  * Returns: the inserted #GNode
21179  */
21180
21181
21182 /**
21183  * g_node_reverse_children:
21184  * @node: a #GNode.
21185  *
21186  * Reverses the order of the children of a #GNode.
21187  * (It doesn't change the order of the grandchildren.)
21188  */
21189
21190
21191 /**
21192  * g_node_traverse:
21193  * @root: the root #GNode of the tree to traverse
21194  * @order: the order in which nodes are visited - %G_IN_ORDER,
21195  *     %G_PRE_ORDER, %G_POST_ORDER, or %G_LEVEL_ORDER.
21196  * @flags: which types of children are to be visited, one of
21197  *     %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
21198  * @max_depth: the maximum depth of the traversal. Nodes below this
21199  *     depth will not be visited. If max_depth is -1 all nodes in
21200  *     the tree are visited. If depth is 1, only the root is visited.
21201  *     If depth is 2, the root and its children are visited. And so on.
21202  * @func: the function to call for each visited #GNode
21203  * @data: user data to pass to the function
21204  *
21205  * Traverses a tree starting at the given root #GNode.
21206  * It calls the given function for each node visited.
21207  * The traversal can be halted at any point by returning %TRUE from @func.
21208  */
21209
21210
21211 /**
21212  * g_node_unlink:
21213  * @node: the #GNode to unlink, which becomes the root of a new tree
21214  *
21215  * Unlinks a #GNode from a tree, resulting in two separate trees.
21216  */
21217
21218
21219 /**
21220  * g_ntohl:
21221  * @val: a 32-bit integer value in network byte order
21222  *
21223  * Converts a 32-bit integer value from network to host byte order.
21224  *
21225  * Returns: @val converted to host byte order.
21226  */
21227
21228
21229 /**
21230  * g_ntohs:
21231  * @val: a 16-bit integer value in network byte order
21232  *
21233  * Converts a 16-bit integer value from network to host byte order.
21234  *
21235  * Returns: @val converted to host byte order
21236  */
21237
21238
21239 /**
21240  * g_nullify_pointer:
21241  * @nullify_location: the memory address of the pointer.
21242  *
21243  * Set the pointer at the specified location to %NULL.
21244  */
21245
21246
21247 /**
21248  * g_on_error_query:
21249  * @prg_name: the program name, needed by <command>gdb</command>
21250  *     for the [S]tack trace option. If @prg_name is %NULL, g_get_prgname()
21251  *     is called to get the program name (which will work correctly if
21252  *     gdk_init() or gtk_init() has been called)
21253  *
21254  * Prompts the user with
21255  * <computeroutput>[E]xit, [H]alt, show [S]tack trace or [P]roceed</computeroutput>.
21256  * This function is intended to be used for debugging use only.
21257  * The following example shows how it can be used together with
21258  * the g_log() functions.
21259  *
21260  * |[
21261  * &num;include &lt;glib.h&gt;
21262  *
21263  * static void
21264  * log_handler (const gchar   *log_domain,
21265  *              GLogLevelFlags log_level,
21266  *              const gchar   *message,
21267  *              gpointer       user_data)
21268  * {
21269  *   g_log_default_handler (log_domain, log_level, message, user_data);
21270  *
21271  *   g_on_error_query (MY_PROGRAM_NAME);
21272  * }
21273  *
21274  * int
21275  * main (int argc, char *argv[])
21276  * {
21277  *   g_log_set_handler (MY_LOG_DOMAIN,
21278  *                      G_LOG_LEVEL_WARNING |
21279  *                      G_LOG_LEVEL_ERROR |
21280  *                      G_LOG_LEVEL_CRITICAL,
21281  *                      log_handler,
21282  *                      NULL);
21283  *   /&ast; ... &ast;/
21284  * ]|
21285  *
21286  * If [E]xit is selected, the application terminates with a call
21287  * to <literal>_exit(0)</literal>.
21288  *
21289  * If [S]tack trace is selected, g_on_error_stack_trace() is called.
21290  * This invokes <command>gdb</command>, which attaches to the current
21291  * process and shows a stack trace. The prompt is then shown again.
21292  *
21293  * If [P]roceed is selected, the function returns.
21294  *
21295  * This function may cause different actions on non-UNIX platforms.
21296  */
21297
21298
21299 /**
21300  * g_on_error_stack_trace:
21301  * @prg_name: the program name, needed by <command>gdb</command>
21302  *     for the [S]tack trace option.
21303  *
21304  * Invokes <command>gdb</command>, which attaches to the current
21305  * process and shows a stack trace. Called by g_on_error_query()
21306  * when the [S]tack trace option is selected. You can get the current
21307  * process's "program name" with g_get_prgname(), assuming that you
21308  * have called gtk_init() or gdk_init().
21309  *
21310  * This function may cause different actions on non-UNIX platforms.
21311  */
21312
21313
21314 /**
21315  * g_once:
21316  * @once: a #GOnce structure
21317  * @func: the #GThreadFunc function associated to @once. This function
21318  *        is called only once, regardless of the number of times it and
21319  *        its associated #GOnce struct are passed to g_once().
21320  * @arg: data to be passed to @func
21321  *
21322  * The first call to this routine by a process with a given #GOnce
21323  * struct calls @func with the given argument. Thereafter, subsequent
21324  * calls to g_once()  with the same #GOnce struct do not call @func
21325  * again, but return the stored result of the first call. On return
21326  * from g_once(), the status of @once will be %G_ONCE_STATUS_READY.
21327  *
21328  * For example, a mutex or a thread-specific data key must be created
21329  * exactly once. In a threaded environment, calling g_once() ensures
21330  * that the initialization is serialized across multiple threads.
21331  *
21332  * Calling g_once() recursively on the same #GOnce struct in
21333  * @func will lead to a deadlock.
21334  *
21335  * |[
21336  *   gpointer
21337  *   get_debug_flags (void)
21338  *   {
21339  *     static GOnce my_once = G_ONCE_INIT;
21340  *
21341  *     g_once (&my_once, parse_debug_flags, NULL);
21342  *
21343  *     return my_once.retval;
21344  *   }
21345  * ]|
21346  *
21347  * Since: 2.4
21348  */
21349
21350
21351 /**
21352  * g_once_init_enter:
21353  * @location: location of a static initializable variable containing 0
21354  *
21355  * Function to be called when starting a critical initialization
21356  * section. The argument @location must point to a static
21357  * 0-initialized variable that will be set to a value other than 0 at
21358  * the end of the initialization section. In combination with
21359  * g_once_init_leave() and the unique address @value_location, it can
21360  * be ensured that an initialization section will be executed only once
21361  * during a program's life time, and that concurrent threads are
21362  * blocked until initialization completed. To be used in constructs
21363  * like this:
21364  *
21365  * |[
21366  *   static gsize initialization_value = 0;
21367  *
21368  *   if (g_once_init_enter (&amp;initialization_value))
21369  *     {
21370  *       gsize setup_value = 42; /&ast;* initialization code here *&ast;/
21371  *
21372  *       g_once_init_leave (&amp;initialization_value, setup_value);
21373  *     }
21374  *
21375  *   /&ast;* use initialization_value here *&ast;/
21376  * ]|
21377  *
21378  * Returns: %TRUE if the initialization section should be entered,
21379  *     %FALSE and blocks otherwise
21380  * Since: 2.14
21381  */
21382
21383
21384 /**
21385  * g_once_init_leave:
21386  * @location: location of a static initializable variable containing 0
21387  * @result: new non-0 value for *@value_location
21388  *
21389  * Counterpart to g_once_init_enter(). Expects a location of a static
21390  * 0-initialized initialization variable, and an initialization value
21391  * other than 0. Sets the variable to the initialization value, and
21392  * releases concurrent threads blocking in g_once_init_enter() on this
21393  * initialization variable.
21394  *
21395  * Since: 2.14
21396  */
21397
21398
21399 /**
21400  * g_open:
21401  * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
21402  * @flags: as in open()
21403  * @mode: as in open()
21404  *
21405  * A wrapper for the POSIX open() function. The open() function is
21406  * used to convert a pathname into a file descriptor.
21407  *
21408  * On POSIX systems file descriptors are implemented by the operating
21409  * system. On Windows, it's the C library that implements open() and
21410  * file descriptors. The actual Win32 API for opening files is quite
21411  * different, see MSDN documentation for CreateFile(). The Win32 API
21412  * uses file handles, which are more randomish integers, not small
21413  * integers like file descriptors.
21414  *
21415  * Because file descriptors are specific to the C library on Windows,
21416  * the file descriptor returned by this function makes sense only to
21417  * functions in the same C library. Thus if the GLib-using code uses a
21418  * different C library than GLib does, the file descriptor returned by
21419  * this function cannot be passed to C library functions like write()
21420  * or read().
21421  *
21422  * See your C library manual for more details about open().
21423  *
21424  * Returns: a new file descriptor, or -1 if an error occurred. The
21425  * return value can be used exactly like the return value from open().
21426  * Since: 2.6
21427  */
21428
21429
21430 /**
21431  * g_option_context_add_group:
21432  * @context: a #GOptionContext
21433  * @group: the group to add
21434  *
21435  * Adds a #GOptionGroup to the @context, so that parsing with @context
21436  * will recognize the options in the group. Note that the group will
21437  * be freed together with the context when g_option_context_free() is
21438  * called, so you must not free the group yourself after adding it
21439  * to a context.
21440  *
21441  * Since: 2.6
21442  */
21443
21444
21445 /**
21446  * g_option_context_add_main_entries:
21447  * @context: a #GOptionContext
21448  * @entries: a %NULL-terminated array of #GOptionEntry<!-- -->s
21449  * @translation_domain: (allow-none): a translation domain to use for translating
21450  *    the <option>--help</option> output for the options in @entries
21451  *    with gettext(), or %NULL
21452  *
21453  * A convenience function which creates a main group if it doesn't
21454  * exist, adds the @entries to it and sets the translation domain.
21455  *
21456  * Since: 2.6
21457  */
21458
21459
21460 /**
21461  * g_option_context_free:
21462  * @context: a #GOptionContext
21463  *
21464  * Frees context and all the groups which have been
21465  * added to it.
21466  *
21467  * Please note that parsed arguments need to be freed separately (see
21468  * #GOptionEntry).
21469  *
21470  * Since: 2.6
21471  */
21472
21473
21474 /**
21475  * g_option_context_get_description:
21476  * @context: a #GOptionContext
21477  *
21478  * Returns the description. See g_option_context_set_description().
21479  *
21480  * Returns: the description
21481  * Since: 2.12
21482  */
21483
21484
21485 /**
21486  * g_option_context_get_help:
21487  * @context: a #GOptionContext
21488  * @main_help: if %TRUE, only include the main group
21489  * @group: (allow-none): the #GOptionGroup to create help for, or %NULL
21490  *
21491  * Returns a formatted, translated help text for the given context.
21492  * To obtain the text produced by <option>--help</option>, call
21493  * <literal>g_option_context_get_help (context, TRUE, NULL)</literal>.
21494  * To obtain the text produced by <option>--help-all</option>, call
21495  * <literal>g_option_context_get_help (context, FALSE, NULL)</literal>.
21496  * To obtain the help text for an option group, call
21497  * <literal>g_option_context_get_help (context, FALSE, group)</literal>.
21498  *
21499  * Returns: A newly allocated string containing the help text
21500  * Since: 2.14
21501  */
21502
21503
21504 /**
21505  * g_option_context_get_help_enabled:
21506  * @context: a #GOptionContext
21507  *
21508  * Returns whether automatic <option>--help</option> generation
21509  * is turned on for @context. See g_option_context_set_help_enabled().
21510  *
21511  * Returns: %TRUE if automatic help generation is turned on.
21512  * Since: 2.6
21513  */
21514
21515
21516 /**
21517  * g_option_context_get_ignore_unknown_options:
21518  * @context: a #GOptionContext
21519  *
21520  * Returns whether unknown options are ignored or not. See
21521  * g_option_context_set_ignore_unknown_options().
21522  *
21523  * Returns: %TRUE if unknown options are ignored.
21524  * Since: 2.6
21525  */
21526
21527
21528 /**
21529  * g_option_context_get_main_group:
21530  * @context: a #GOptionContext
21531  *
21532  * Returns a pointer to the main group of @context.
21533  *
21534  * Returns: the main group of @context, or %NULL if @context doesn't
21535  *  have a main group. Note that group belongs to @context and should
21536  *  not be modified or freed.
21537  * Since: 2.6
21538  */
21539
21540
21541 /**
21542  * g_option_context_get_summary:
21543  * @context: a #GOptionContext
21544  *
21545  * Returns the summary. See g_option_context_set_summary().
21546  *
21547  * Returns: the summary
21548  * Since: 2.12
21549  */
21550
21551
21552 /**
21553  * g_option_context_new:
21554  * @parameter_string: (allow-none): a string which is displayed in
21555  *    the first line of <option>--help</option> output, after the
21556  *    usage summary
21557  *    <literal><replaceable>programname</replaceable> [OPTION...]</literal>
21558  *
21559  * Creates a new option context.
21560  *
21561  * The @parameter_string can serve multiple purposes. It can be used
21562  * to add descriptions for "rest" arguments, which are not parsed by
21563  * the #GOptionContext, typically something like "FILES" or
21564  * "FILE1 FILE2...". If you are using #G_OPTION_REMAINING for
21565  * collecting "rest" arguments, GLib handles this automatically by
21566  * using the @arg_description of the corresponding #GOptionEntry in
21567  * the usage summary.
21568  *
21569  * Another usage is to give a short summary of the program
21570  * functionality, like " - frob the strings", which will be displayed
21571  * in the same line as the usage. For a longer description of the
21572  * program functionality that should be displayed as a paragraph
21573  * below the usage line, use g_option_context_set_summary().
21574  *
21575  * Note that the @parameter_string is translated using the
21576  * function set with g_option_context_set_translate_func(), so
21577  * it should normally be passed untranslated.
21578  *
21579  * Returns: a newly created #GOptionContext, which must be
21580  *    freed with g_option_context_free() after use.
21581  * Since: 2.6
21582  */
21583
21584
21585 /**
21586  * g_option_context_parse:
21587  * @context: a #GOptionContext
21588  * @argc: (inout) (allow-none): a pointer to the number of command line arguments
21589  * @argv: (inout) (array length=argc) (allow-none): a pointer to the array of command line arguments
21590  * @error: a return location for errors
21591  *
21592  * Parses the command line arguments, recognizing options
21593  * which have been added to @context. A side-effect of
21594  * calling this function is that g_set_prgname() will be
21595  * called.
21596  *
21597  * If the parsing is successful, any parsed arguments are
21598  * removed from the array and @argc and @argv are updated
21599  * accordingly. A '--' option is stripped from @argv
21600  * unless there are unparsed options before and after it,
21601  * or some of the options after it start with '-'. In case
21602  * of an error, @argc and @argv are left unmodified.
21603  *
21604  * If automatic <option>--help</option> support is enabled
21605  * (see g_option_context_set_help_enabled()), and the
21606  * @argv array contains one of the recognized help options,
21607  * this function will produce help output to stdout and
21608  * call <literal>exit (0)</literal>.
21609  *
21610  * Note that function depends on the
21611  * <link linkend="setlocale">current locale</link> for
21612  * automatic character set conversion of string and filename
21613  * arguments.
21614  *
21615  * Returns: %TRUE if the parsing was successful,
21616  *               %FALSE if an error occurred
21617  * Since: 2.6
21618  */
21619
21620
21621 /**
21622  * g_option_context_set_description:
21623  * @context: a #GOptionContext
21624  * @description: (allow-none): a string to be shown in <option>--help</option> output
21625  *   after the list of options, or %NULL
21626  *
21627  * Adds a string to be displayed in <option>--help</option> output
21628  * after the list of options. This text often includes a bug reporting
21629  * address.
21630  *
21631  * Note that the summary is translated (see
21632  * g_option_context_set_translate_func()).
21633  *
21634  * Since: 2.12
21635  */
21636
21637
21638 /**
21639  * g_option_context_set_help_enabled:
21640  * @context: a #GOptionContext
21641  * @help_enabled: %TRUE to enable <option>--help</option>, %FALSE to disable it
21642  *
21643  * Enables or disables automatic generation of <option>--help</option>
21644  * output. By default, g_option_context_parse() recognizes
21645  * <option>--help</option>, <option>-h</option>,
21646  * <option>-?</option>, <option>--help-all</option>
21647  * and <option>--help-</option><replaceable>groupname</replaceable> and creates
21648  * suitable output to stdout.
21649  *
21650  * Since: 2.6
21651  */
21652
21653
21654 /**
21655  * g_option_context_set_ignore_unknown_options:
21656  * @context: a #GOptionContext
21657  * @ignore_unknown: %TRUE to ignore unknown options, %FALSE to produce
21658  *    an error when unknown options are met
21659  *
21660  * Sets whether to ignore unknown options or not. If an argument is
21661  * ignored, it is left in the @argv array after parsing. By default,
21662  * g_option_context_parse() treats unknown options as error.
21663  *
21664  * This setting does not affect non-option arguments (i.e. arguments
21665  * which don't start with a dash). But note that GOption cannot reliably
21666  * determine whether a non-option belongs to a preceding unknown option.
21667  *
21668  * Since: 2.6
21669  */
21670
21671
21672 /**
21673  * g_option_context_set_main_group:
21674  * @context: a #GOptionContext
21675  * @group: the group to set as main group
21676  *
21677  * Sets a #GOptionGroup as main group of the @context.
21678  * This has the same effect as calling g_option_context_add_group(),
21679  * the only difference is that the options in the main group are
21680  * treated differently when generating <option>--help</option> output.
21681  *
21682  * Since: 2.6
21683  */
21684
21685
21686 /**
21687  * g_option_context_set_summary:
21688  * @context: a #GOptionContext
21689  * @summary: (allow-none): a string to be shown in <option>--help</option> output
21690  *  before the list of options, or %NULL
21691  *
21692  * Adds a string to be displayed in <option>--help</option> output
21693  * before the list of options. This is typically a summary of the
21694  * program functionality.
21695  *
21696  * Note that the summary is translated (see
21697  * g_option_context_set_translate_func() and
21698  * g_option_context_set_translation_domain()).
21699  *
21700  * Since: 2.12
21701  */
21702
21703
21704 /**
21705  * g_option_context_set_translate_func:
21706  * @context: a #GOptionContext
21707  * @func: (allow-none): the #GTranslateFunc, or %NULL
21708  * @data: (allow-none): user data to pass to @func, or %NULL
21709  * @destroy_notify: (allow-none): a function which gets called to free @data, or %NULL
21710  *
21711  * Sets the function which is used to translate the contexts
21712  * user-visible strings, for <option>--help</option> output.
21713  * If @func is %NULL, strings are not translated.
21714  *
21715  * Note that option groups have their own translation functions,
21716  * this function only affects the @parameter_string (see g_option_context_new()),
21717  * the summary (see g_option_context_set_summary()) and the description
21718  * (see g_option_context_set_description()).
21719  *
21720  * If you are using gettext(), you only need to set the translation
21721  * domain, see g_option_context_set_translation_domain().
21722  *
21723  * Since: 2.12
21724  */
21725
21726
21727 /**
21728  * g_option_context_set_translation_domain:
21729  * @context: a #GOptionContext
21730  * @domain: the domain to use
21731  *
21732  * A convenience function to use gettext() for translating
21733  * user-visible strings.
21734  *
21735  * Since: 2.12
21736  */
21737
21738
21739 /**
21740  * g_option_group_add_entries:
21741  * @group: a #GOptionGroup
21742  * @entries: a %NULL-terminated array of #GOptionEntry<!-- -->s
21743  *
21744  * Adds the options specified in @entries to @group.
21745  *
21746  * Since: 2.6
21747  */
21748
21749
21750 /**
21751  * g_option_group_free:
21752  * @group: a #GOptionGroup
21753  *
21754  * Frees a #GOptionGroup. Note that you must <emphasis>not</emphasis>
21755  * free groups which have been added to a #GOptionContext.
21756  *
21757  * Since: 2.6
21758  */
21759
21760
21761 /**
21762  * g_option_group_new:
21763  * @name: the name for the option group, this is used to provide
21764  *   help for the options in this group with <option>--help-</option>@name
21765  * @description: a description for this group to be shown in
21766  *   <option>--help</option>. This string is translated using the translation
21767  *   domain or translation function of the group
21768  * @help_description: a description for the <option>--help-</option>@name option.
21769  *   This string is translated using the translation domain or translation function
21770  *   of the group
21771  * @user_data: (allow-none): user data that will be passed to the pre- and post-parse hooks,
21772  *   the error hook and to callbacks of %G_OPTION_ARG_CALLBACK options, or %NULL
21773  * @destroy: (allow-none): a function that will be called to free @user_data, or %NULL
21774  *
21775  * Creates a new #GOptionGroup.
21776  *
21777  * Returns: a newly created option group. It should be added
21778  *   to a #GOptionContext or freed with g_option_group_free().
21779  * Since: 2.6
21780  */
21781
21782
21783 /**
21784  * g_option_group_set_error_hook:
21785  * @group: a #GOptionGroup
21786  * @error_func: a function to call when an error occurs
21787  *
21788  * Associates a function with @group which will be called
21789  * from g_option_context_parse() when an error occurs.
21790  *
21791  * Note that the user data to be passed to @error_func can be
21792  * specified when constructing the group with g_option_group_new().
21793  *
21794  * Since: 2.6
21795  */
21796
21797
21798 /**
21799  * g_option_group_set_parse_hooks:
21800  * @group: a #GOptionGroup
21801  * @pre_parse_func: (allow-none): a function to call before parsing, or %NULL
21802  * @post_parse_func: (allow-none): a function to call after parsing, or %NULL
21803  *
21804  * Associates two functions with @group which will be called
21805  * from g_option_context_parse() before the first option is parsed
21806  * and after the last option has been parsed, respectively.
21807  *
21808  * Note that the user data to be passed to @pre_parse_func and
21809  * @post_parse_func can be specified when constructing the group
21810  * with g_option_group_new().
21811  *
21812  * Since: 2.6
21813  */
21814
21815
21816 /**
21817  * g_option_group_set_translate_func:
21818  * @group: a #GOptionGroup
21819  * @func: (allow-none): the #GTranslateFunc, or %NULL
21820  * @data: (allow-none): user data to pass to @func, or %NULL
21821  * @destroy_notify: (allow-none): a function which gets called to free @data, or %NULL
21822  *
21823  * Sets the function which is used to translate user-visible
21824  * strings, for <option>--help</option> output. Different
21825  * groups can use different #GTranslateFunc<!-- -->s. If @func
21826  * is %NULL, strings are not translated.
21827  *
21828  * If you are using gettext(), you only need to set the translation
21829  * domain, see g_option_group_set_translation_domain().
21830  *
21831  * Since: 2.6
21832  */
21833
21834
21835 /**
21836  * g_option_group_set_translation_domain:
21837  * @group: a #GOptionGroup
21838  * @domain: the domain to use
21839  *
21840  * A convenience function to use gettext() for translating
21841  * user-visible strings.
21842  *
21843  * Since: 2.6
21844  */
21845
21846
21847 /**
21848  * g_parse_debug_string:
21849  * @string: (allow-none): a list of debug options separated by colons, spaces, or
21850  * commas, or %NULL.
21851  * @keys: (array length=nkeys): pointer to an array of #GDebugKey which associate
21852  *     strings with bit flags.
21853  * @nkeys: the number of #GDebugKey<!-- -->s in the array.
21854  *
21855  * Parses a string containing debugging options
21856  * into a %guint containing bit flags. This is used
21857  * within GDK and GTK+ to parse the debug options passed on the
21858  * command line or through environment variables.
21859  *
21860  * If @string is equal to <code>"all"</code>, all flags are set. Any flags
21861  * specified along with <code>"all"</code> in @string are inverted; thus,
21862  * <code>"all,foo,bar"</code> or <code>"foo,bar,all"</code> sets all flags
21863  * except those corresponding to <code>"foo"</code> and <code>"bar"</code>.
21864  *
21865  * If @string is equal to <code>"help"</code>, all the available keys in @keys
21866  * are printed out to standard error.
21867  *
21868  * Returns: the combined set of bit flags.
21869  */
21870
21871
21872 /**
21873  * g_path_get_basename:
21874  * @file_name: the name of the file
21875  *
21876  * Gets the last component of the filename.
21877  *
21878  * If @file_name ends with a directory separator it gets the component
21879  * before the last slash. If @file_name consists only of directory
21880  * separators (and on Windows, possibly a drive letter), a single
21881  * separator is returned. If @file_name is empty, it gets ".".
21882  *
21883  * Returns: a newly allocated string containing the last
21884  *    component of the filename
21885  */
21886
21887
21888 /**
21889  * g_path_get_dirname:
21890  * @file_name: the name of the file
21891  *
21892  * Gets the directory components of a file name.
21893  *
21894  * If the file name has no directory components "." is returned.
21895  * The returned string should be freed when no longer needed.
21896  *
21897  * Returns: the directory components of the file
21898  */
21899
21900
21901 /**
21902  * g_path_is_absolute:
21903  * @file_name: a file name
21904  *
21905  * Returns %TRUE if the given @file_name is an absolute file name.
21906  * Note that this is a somewhat vague concept on Windows.
21907  *
21908  * On POSIX systems, an absolute file name is well-defined. It always
21909  * starts from the single root directory. For example "/usr/local".
21910  *
21911  * On Windows, the concepts of current drive and drive-specific
21912  * current directory introduce vagueness. This function interprets as
21913  * an absolute file name one that either begins with a directory
21914  * separator such as "\Users\tml" or begins with the root on a drive,
21915  * for example "C:\Windows". The first case also includes UNC paths
21916  * such as "\\myserver\docs\foo". In all cases, either slashes or
21917  * backslashes are accepted.
21918  *
21919  * Note that a file name relative to the current drive root does not
21920  * truly specify a file uniquely over time and across processes, as
21921  * the current drive is a per-process value and can be changed.
21922  *
21923  * File names relative the current directory on some specific drive,
21924  * such as "D:foo/bar", are not interpreted as absolute by this
21925  * function, but they obviously are not relative to the normal current
21926  * directory as returned by getcwd() or g_get_current_dir()
21927  * either. Such paths should be avoided, or need to be handled using
21928  * Windows-specific code.
21929  *
21930  * Returns: %TRUE if @file_name is absolute
21931  */
21932
21933
21934 /**
21935  * g_path_skip_root:
21936  * @file_name: a file name
21937  *
21938  * Returns a pointer into @file_name after the root component,
21939  * i.e. after the "/" in UNIX or "C:\" under Windows. If @file_name
21940  * is not an absolute path it returns %NULL.
21941  *
21942  * Returns: a pointer into @file_name after the root component
21943  */
21944
21945
21946 /**
21947  * g_pattern_match:
21948  * @pspec: a #GPatternSpec
21949  * @string_length: the length of @string (in bytes, i.e. strlen(),
21950  *                 <emphasis>not</emphasis> g_utf8_strlen())
21951  * @string: the UTF-8 encoded string to match
21952  * @string_reversed: (allow-none): the reverse of @string or %NULL
21953  *
21954  * Matches a string against a compiled pattern. Passing the correct
21955  * length of the string given is mandatory. The reversed string can be
21956  * omitted by passing %NULL, this is more efficient if the reversed
21957  * version of the string to be matched is not at hand, as
21958  * g_pattern_match() will only construct it if the compiled pattern
21959  * requires reverse matches.
21960  *
21961  * Note that, if the user code will (possibly) match a string against a
21962  * multitude of patterns containing wildcards, chances are high that
21963  * some patterns will require a reversed string. In this case, it's
21964  * more efficient to provide the reversed string to avoid multiple
21965  * constructions thereof in the various calls to g_pattern_match().
21966  *
21967  * Note also that the reverse of a UTF-8 encoded string can in general
21968  * <emphasis>not</emphasis> be obtained by g_strreverse(). This works
21969  * only if the string doesn't contain any multibyte characters. GLib
21970  * offers the g_utf8_strreverse() function to reverse UTF-8 encoded
21971  * strings.
21972  *
21973  * Returns: %TRUE if @string matches @pspec
21974  */
21975
21976
21977 /**
21978  * g_pattern_match_simple:
21979  * @pattern: the UTF-8 encoded pattern
21980  * @string: the UTF-8 encoded string to match
21981  *
21982  * Matches a string against a pattern given as a string. If this
21983  * function is to be called in a loop, it's more efficient to compile
21984  * the pattern once with g_pattern_spec_new() and call
21985  * g_pattern_match_string() repeatedly.
21986  *
21987  * Returns: %TRUE if @string matches @pspec
21988  */
21989
21990
21991 /**
21992  * g_pattern_match_string:
21993  * @pspec: a #GPatternSpec
21994  * @string: the UTF-8 encoded string to match
21995  *
21996  * Matches a string against a compiled pattern. If the string is to be
21997  * matched against more than one pattern, consider using
21998  * g_pattern_match() instead while supplying the reversed string.
21999  *
22000  * Returns: %TRUE if @string matches @pspec
22001  */
22002
22003
22004 /**
22005  * g_pattern_spec_equal:
22006  * @pspec1: a #GPatternSpec
22007  * @pspec2: another #GPatternSpec
22008  *
22009  * Compares two compiled pattern specs and returns whether they will
22010  * match the same set of strings.
22011  *
22012  * Returns: Whether the compiled patterns are equal
22013  */
22014
22015
22016 /**
22017  * g_pattern_spec_free:
22018  * @pspec: a #GPatternSpec
22019  *
22020  * Frees the memory allocated for the #GPatternSpec.
22021  */
22022
22023
22024 /**
22025  * g_pattern_spec_new:
22026  * @pattern: a zero-terminated UTF-8 encoded string
22027  *
22028  * Compiles a pattern to a #GPatternSpec.
22029  *
22030  * Returns: a newly-allocated #GPatternSpec
22031  */
22032
22033
22034 /**
22035  * g_pointer_bit_lock:
22036  * @address: a pointer to a #gpointer-sized value
22037  * @lock_bit: a bit value between 0 and 31
22038  *
22039  * This is equivalent to g_bit_lock, but working on pointers (or other
22040  * pointer-sized values).
22041  *
22042  * For portability reasons, you may only lock on the bottom 32 bits of
22043  * the pointer.
22044  *
22045  * Since: 2.30
22046  */
22047
22048
22049 /**
22050  * g_pointer_bit_trylock:
22051  * @address: a pointer to a #gpointer-sized value
22052  * @lock_bit: a bit value between 0 and 31
22053  *
22054  * This is equivalent to g_bit_trylock, but working on pointers (or
22055  * other pointer-sized values).
22056  *
22057  * For portability reasons, you may only lock on the bottom 32 bits of
22058  * the pointer.
22059  *
22060  * Returns: %TRUE if the lock was acquired
22061  * Since: 2.30
22062  */
22063
22064
22065 /**
22066  * g_pointer_bit_unlock:
22067  * @address: a pointer to a #gpointer-sized value
22068  * @lock_bit: a bit value between 0 and 31
22069  *
22070  * This is equivalent to g_bit_unlock, but working on pointers (or other
22071  * pointer-sized values).
22072  *
22073  * For portability reasons, you may only lock on the bottom 32 bits of
22074  * the pointer.
22075  *
22076  * Since: 2.30
22077  */
22078
22079
22080 /**
22081  * g_poll:
22082  * @fds: file descriptors to poll
22083  * @nfds: the number of file descriptors in @fds
22084  * @timeout: amount of time to wait, in milliseconds, or -1 to wait forever
22085  *
22086  * Polls @fds, as with the poll() system call, but portably. (On
22087  * systems that don't have poll(), it is emulated using select().)
22088  * This is used internally by #GMainContext, but it can be called
22089  * directly if you need to block until a file descriptor is ready, but
22090  * don't want to run the full main loop.
22091  *
22092  * Each element of @fds is a #GPollFD describing a single file
22093  * descriptor to poll. The %fd field indicates the file descriptor,
22094  * and the %events field indicates the events to poll for. On return,
22095  * the %revents fields will be filled with the events that actually
22096  * occurred.
22097  *
22098  * On POSIX systems, the file descriptors in @fds can be any sort of
22099  * file descriptor, but the situation is much more complicated on
22100  * Windows. If you need to use g_poll() in code that has to run on
22101  * Windows, the easiest solution is to construct all of your
22102  * #GPollFD<!-- -->s with g_io_channel_win32_make_pollfd().
22103  *
22104  * Returns: the number of entries in @fds whose %revents fields
22105  * were filled in, or 0 if the operation timed out, or -1 on error or
22106  * if the call was interrupted.
22107  * Since: 2.20
22108  */
22109
22110
22111 /**
22112  * g_prefix_error:
22113  * @err: (allow-none): a return location for a #GError, or %NULL
22114  * @format: printf()-style format string
22115  * @...: arguments to @format
22116  *
22117  * Formats a string according to @format and
22118  * prefix it to an existing error message.  If
22119  * @err is %NULL (ie: no error variable) then do
22120  * nothing.
22121  *
22122  * If *@err is %NULL (ie: an error variable is
22123  * present but there is no error condition) then
22124  * also do nothing.  Whether or not it makes
22125  * sense to take advantage of this feature is up
22126  * to you.
22127  *
22128  * Since: 2.16
22129  */
22130
22131
22132 /**
22133  * g_print:
22134  * @format: the message format. See the printf() documentation
22135  * @...: the parameters to insert into the format string
22136  *
22137  * Outputs a formatted message via the print handler.
22138  * The default print handler simply outputs the message to stdout, without
22139  * appending a trailing new-line character. Typically, @format should end with
22140  * its own new-line character.
22141  *
22142  * g_print() should not be used from within libraries for debugging
22143  * messages, since it may be redirected by applications to special
22144  * purpose message windows or even files. Instead, libraries should
22145  * use g_log(), or the convenience functions g_message(), g_warning()
22146  * and g_error().
22147  */
22148
22149
22150 /**
22151  * g_printerr:
22152  * @format: the message format. See the printf() documentation
22153  * @...: the parameters to insert into the format string
22154  *
22155  * Outputs a formatted message via the error message handler.
22156  * The default handler simply outputs the message to stderr, without appending
22157  * a trailing new-line character. Typically, @format should end with its own
22158  * new-line character.
22159  *
22160  * g_printerr() should not be used from within libraries.
22161  * Instead g_log() should be used, or the convenience functions
22162  * g_message(), g_warning() and g_error().
22163  */
22164
22165
22166 /**
22167  * g_printf:
22168  * @format: a standard printf() format string, but notice
22169  *          <link linkend="string-precision">string precision pitfalls</link>.
22170  * @...: the arguments to insert in the output.
22171  *
22172  * An implementation of the standard printf() function which supports
22173  * positional parameters, as specified in the Single Unix Specification.
22174  *
22175  * As with the standard printf(), this does not automatically append a trailing
22176  * new-line character to the message, so typically @format should end with its
22177  * own new-line character.
22178  *
22179  * Returns: the number of bytes printed.
22180  * Since: 2.2
22181  */
22182
22183
22184 /**
22185  * g_printf_string_upper_bound:
22186  * @format: the format string. See the printf() documentation
22187  * @args: the parameters to be inserted into the format string
22188  *
22189  * Calculates the maximum space needed to store the output
22190  * of the sprintf() function.
22191  *
22192  * Returns: the maximum space needed to store the formatted string
22193  */
22194
22195
22196 /**
22197  * g_private_get:
22198  * @key: a #GPrivate
22199  *
22200  * Returns the current value of the thread local variable @key.
22201  *
22202  * If the value has not yet been set in this thread, %NULL is returned.
22203  * Values are never copied between threads (when a new thread is
22204  * created, for example).
22205  *
22206  * Returns: the thread-local value
22207  */
22208
22209
22210 /**
22211  * g_private_replace:
22212  * @key: a #GPrivate
22213  * @value: the new value
22214  *
22215  * Sets the thread local variable @key to have the value @value in the
22216  * current thread.
22217  *
22218  * This function differs from g_private_set() in the following way: if
22219  * the previous value was non-%NULL then the #GDestroyNotify handler for
22220  * @key is run on it.
22221  *
22222  * Since: 2.32
22223  */
22224
22225
22226 /**
22227  * g_private_set:
22228  * @key: a #GPrivate
22229  * @value: the new value
22230  *
22231  * Sets the thread local variable @key to have the value @value in the
22232  * current thread.
22233  *
22234  * This function differs from g_private_replace() in the following way:
22235  * the #GDestroyNotify for @key is not called on the old value.
22236  */
22237
22238
22239 /**
22240  * g_propagate_error:
22241  * @dest: error return location
22242  * @src: error to move into the return location
22243  *
22244  * If @dest is %NULL, free @src; otherwise, moves @src into *@dest.
22245  * The error variable @dest points to must be %NULL.
22246  */
22247
22248
22249 /**
22250  * g_propagate_prefixed_error:
22251  * @dest: error return location
22252  * @src: error to move into the return location
22253  * @format: printf()-style format string
22254  * @...: arguments to @format
22255  *
22256  * If @dest is %NULL, free @src; otherwise,
22257  * moves @src into *@dest. *@dest must be %NULL.
22258  * After the move, add a prefix as with
22259  * g_prefix_error().
22260  *
22261  * Since: 2.16
22262  */
22263
22264
22265 /**
22266  * g_ptr_array_add:
22267  * @array: a #GPtrArray.
22268  * @data: the pointer to add.
22269  *
22270  * Adds a pointer to the end of the pointer array. The array will grow
22271  * in size automatically if necessary.
22272  */
22273
22274
22275 /**
22276  * g_ptr_array_foreach:
22277  * @array: a #GPtrArray
22278  * @func: the function to call for each array element
22279  * @user_data: user data to pass to the function
22280  *
22281  * Calls a function for each element of a #GPtrArray.
22282  *
22283  * Since: 2.4
22284  */
22285
22286
22287 /**
22288  * g_ptr_array_free:
22289  * @array: a #GPtrArray.
22290  * @free_seg: if %TRUE the actual pointer array is freed as well.
22291  *
22292  * Frees the memory allocated for the #GPtrArray. If @free_seg is %TRUE
22293  * it frees the memory block holding the elements as well. Pass %FALSE
22294  * if you want to free the #GPtrArray wrapper but preserve the
22295  * underlying array for use elsewhere. If the reference count of @array
22296  * is greater than one, the #GPtrArray wrapper is preserved but the
22297  * size of @array will be set to zero.
22298  *
22299  * <note><para>If array contents point to dynamically-allocated
22300  * memory, they should be freed separately if @free_seg is %TRUE and no
22301  * #GDestroyNotify function has been set for @array.</para></note>
22302  *
22303  * Returns: the pointer array if @free_seg is %FALSE, otherwise %NULL.
22304  *          The pointer array should be freed using g_free().
22305  */
22306
22307
22308 /**
22309  * g_ptr_array_index:
22310  * @array: a #GPtrArray.
22311  * @index_: the index of the pointer to return.
22312  *
22313  * Returns the pointer at the given index of the pointer array.
22314  *
22315  * <note><para>
22316  * This does not perform bounds checking on the given @index_, so you are
22317  * responsible for checking it against the array length.</para></note>
22318  *
22319  * Returns: the pointer at the given index.
22320  */
22321
22322
22323 /**
22324  * g_ptr_array_new:
22325  *
22326  * Creates a new #GPtrArray with a reference count of 1.
22327  *
22328  * Returns: the new #GPtrArray.
22329  */
22330
22331
22332 /**
22333  * g_ptr_array_new_full:
22334  * @reserved_size: number of pointers preallocated.
22335  * @element_free_func: (allow-none): A function to free elements with destroy @array or %NULL.
22336  *
22337  * Creates a new #GPtrArray with @reserved_size pointers preallocated
22338  * and a reference count of 1. This avoids frequent reallocation, if
22339  * you are going to add many pointers to the array. Note however that
22340  * the size of the array is still 0. It also set @element_free_func
22341  * for freeing each element when the array is destroyed either via
22342  * g_ptr_array_unref(), when g_ptr_array_free() is called with @free_segment
22343  * set to %TRUE or when removing elements.
22344  *
22345  * Returns: A new #GPtrArray.
22346  * Since: 2.30
22347  */
22348
22349
22350 /**
22351  * g_ptr_array_new_with_free_func:
22352  * @element_free_func: (allow-none): A function to free elements with destroy @array or %NULL.
22353  *
22354  * Creates a new #GPtrArray with a reference count of 1 and use @element_free_func
22355  * for freeing each element when the array is destroyed either via
22356  * g_ptr_array_unref(), when g_ptr_array_free() is called with @free_segment
22357  * set to %TRUE or when removing elements.
22358  *
22359  * Returns: A new #GPtrArray.
22360  * Since: 2.22
22361  */
22362
22363
22364 /**
22365  * g_ptr_array_ref:
22366  * @array: a #GPtrArray
22367  *
22368  * Atomically increments the reference count of @array by one.
22369  * This function is thread-safe and may be called from any thread.
22370  *
22371  * Returns: The passed in #GPtrArray
22372  * Since: 2.22
22373  */
22374
22375
22376 /**
22377  * g_ptr_array_remove:
22378  * @array: a #GPtrArray.
22379  * @data: the pointer to remove.
22380  *
22381  * Removes the first occurrence of the given pointer from the pointer
22382  * array. The following elements are moved down one place. If @array
22383  * has a non-%NULL #GDestroyNotify function it is called for the
22384  * removed element.
22385  *
22386  * It returns %TRUE if the pointer was removed, or %FALSE if the
22387  * pointer was not found.
22388  *
22389  * Returns: %TRUE if the pointer is removed. %FALSE if the pointer is
22390  *          not found in the array.
22391  */
22392
22393
22394 /**
22395  * g_ptr_array_remove_fast:
22396  * @array: a #GPtrArray.
22397  * @data: the pointer to remove.
22398  *
22399  * Removes the first occurrence of the given pointer from the pointer
22400  * array. The last element in the array is used to fill in the space,
22401  * so this function does not preserve the order of the array. But it is
22402  * faster than g_ptr_array_remove(). If @array has a non-%NULL
22403  * #GDestroyNotify function it is called for the removed element.
22404  *
22405  * It returns %TRUE if the pointer was removed, or %FALSE if the
22406  * pointer was not found.
22407  *
22408  * Returns: %TRUE if the pointer was found in the array.
22409  */
22410
22411
22412 /**
22413  * g_ptr_array_remove_index:
22414  * @array: a #GPtrArray.
22415  * @index_: the index of the pointer to remove.
22416  *
22417  * Removes the pointer at the given index from the pointer array. The
22418  * following elements are moved down one place. If @array has a
22419  * non-%NULL #GDestroyNotify function it is called for the removed
22420  * element.
22421  *
22422  * Returns: the pointer which was removed.
22423  */
22424
22425
22426 /**
22427  * g_ptr_array_remove_index_fast:
22428  * @array: a #GPtrArray.
22429  * @index_: the index of the pointer to remove.
22430  *
22431  * Removes the pointer at the given index from the pointer array. The
22432  * last element in the array is used to fill in the space, so this
22433  * function does not preserve the order of the array. But it is faster
22434  * than g_ptr_array_remove_index(). If @array has a non-%NULL
22435  * #GDestroyNotify function it is called for the removed element.
22436  *
22437  * Returns: the pointer which was removed.
22438  */
22439
22440
22441 /**
22442  * g_ptr_array_remove_range:
22443  * @array: a @GPtrArray.
22444  * @index_: the index of the first pointer to remove.
22445  * @length: the number of pointers to remove.
22446  *
22447  * Removes the given number of pointers starting at the given index
22448  * from a #GPtrArray.  The following elements are moved to close the
22449  * gap. If @array has a non-%NULL #GDestroyNotify function it is called
22450  * for the removed elements.
22451  *
22452  * Since: 2.4
22453  */
22454
22455
22456 /**
22457  * g_ptr_array_set_free_func:
22458  * @array: A #GPtrArray.
22459  * @element_free_func: (allow-none): A function to free elements with destroy @array or %NULL.
22460  *
22461  * Sets a function for freeing each element when @array is destroyed
22462  * either via g_ptr_array_unref(), when g_ptr_array_free() is called
22463  * with @free_segment set to %TRUE or when removing elements.
22464  *
22465  * Since: 2.22
22466  */
22467
22468
22469 /**
22470  * g_ptr_array_set_size:
22471  * @array: a #GPtrArray.
22472  * @length: the new length of the pointer array.
22473  *
22474  * Sets the size of the array. When making the array larger,
22475  * newly-added elements will be set to %NULL. When making it smaller,
22476  * if @array has a non-%NULL #GDestroyNotify function then it will be
22477  * called for the removed elements.
22478  */
22479
22480
22481 /**
22482  * g_ptr_array_sized_new:
22483  * @reserved_size: number of pointers preallocated.
22484  *
22485  * Creates a new #GPtrArray with @reserved_size pointers preallocated
22486  * and a reference count of 1. This avoids frequent reallocation, if
22487  * you are going to add many pointers to the array. Note however that
22488  * the size of the array is still 0.
22489  *
22490  * Returns: the new #GPtrArray.
22491  */
22492
22493
22494 /**
22495  * g_ptr_array_sort:
22496  * @array: a #GPtrArray.
22497  * @compare_func: comparison function.
22498  *
22499  * Sorts the array, using @compare_func which should be a qsort()-style
22500  * comparison function (returns less than zero for first arg is less
22501  * than second arg, zero for equal, greater than zero if irst arg is
22502  * greater than second arg).
22503  *
22504  * <note><para>The comparison function for g_ptr_array_sort() doesn't
22505  * take the pointers from the array as arguments, it takes pointers to
22506  * the pointers in the array.</para></note>
22507  *
22508  * This is guaranteed to be a stable sort since version 2.32.
22509  */
22510
22511
22512 /**
22513  * g_ptr_array_sort_with_data:
22514  * @array: a #GPtrArray.
22515  * @compare_func: comparison function.
22516  * @user_data: data to pass to @compare_func.
22517  *
22518  * Like g_ptr_array_sort(), but the comparison function has an extra
22519  * user data argument.
22520  *
22521  * <note><para>The comparison function for g_ptr_array_sort_with_data()
22522  * doesn't take the pointers from the array as arguments, it takes
22523  * pointers to the pointers in the array.</para></note>
22524  *
22525  * This is guaranteed to be a stable sort since version 2.32.
22526  */
22527
22528
22529 /**
22530  * g_ptr_array_unref:
22531  * @array: A #GPtrArray.
22532  *
22533  * Atomically decrements the reference count of @array by one. If the
22534  * reference count drops to 0, the effect is the same as calling
22535  * g_ptr_array_free() with @free_segment set to %TRUE. This function
22536  * is MT-safe and may be called from any thread.
22537  *
22538  * Since: 2.22
22539  */
22540
22541
22542 /**
22543  * g_qsort_with_data:
22544  * @pbase: start of array to sort
22545  * @total_elems: elements in the array
22546  * @size: size of each element
22547  * @compare_func: function to compare elements
22548  * @user_data: data to pass to @compare_func
22549  *
22550  * This is just like the standard C qsort() function, but
22551  * the comparison routine accepts a user data argument.
22552  *
22553  * This is guaranteed to be a stable sort since version 2.32.
22554  */
22555
22556
22557 /**
22558  * g_quark_from_static_string:
22559  * @string: (allow-none): a string.
22560  *
22561  * Gets the #GQuark identifying the given (static) string. If the
22562  * string does not currently have an associated #GQuark, a new #GQuark
22563  * is created, linked to the given string.
22564  *
22565  * Note that this function is identical to g_quark_from_string() except
22566  * that if a new #GQuark is created the string itself is used rather
22567  * than a copy. This saves memory, but can only be used if the string
22568  * will <emphasis>always</emphasis> exist. It can be used with
22569  * statically allocated strings in the main program, but not with
22570  * statically allocated memory in dynamically loaded modules, if you
22571  * expect to ever unload the module again (e.g. do not use this
22572  * function in GTK+ theme engines).
22573  *
22574  * Returns: the #GQuark identifying the string, or 0 if @string is
22575  *     %NULL.
22576  */
22577
22578
22579 /**
22580  * g_quark_from_string:
22581  * @string: (allow-none): a string.
22582  *
22583  * Gets the #GQuark identifying the given string. If the string does
22584  * not currently have an associated #GQuark, a new #GQuark is created,
22585  * using a copy of the string.
22586  *
22587  * Returns: the #GQuark identifying the string, or 0 if @string is
22588  *     %NULL.
22589  */
22590
22591
22592 /**
22593  * g_quark_to_string:
22594  * @quark: a #GQuark.
22595  *
22596  * Gets the string associated with the given #GQuark.
22597  *
22598  * Returns: the string associated with the #GQuark
22599  */
22600
22601
22602 /**
22603  * g_quark_try_string:
22604  * @string: (allow-none): a string.
22605  *
22606  * Gets the #GQuark associated with the given string, or 0 if string is
22607  * %NULL or it has no associated #GQuark.
22608  *
22609  * If you want the GQuark to be created if it doesn't already exist,
22610  * use g_quark_from_string() or g_quark_from_static_string().
22611  *
22612  * Returns: the #GQuark associated with the string, or 0 if @string is
22613  *           %NULL or there is no #GQuark associated with it.
22614  */
22615
22616
22617 /**
22618  * g_queue_clear:
22619  * @queue: a #GQueue
22620  *
22621  * Removes all the elements in @queue. If queue elements contain
22622  * dynamically-allocated memory, they should be freed first.
22623  *
22624  * Since: 2.14
22625  */
22626
22627
22628 /**
22629  * g_queue_copy:
22630  * @queue: a #GQueue
22631  *
22632  * Copies a @queue. Note that is a shallow copy. If the elements in the
22633  * queue consist of pointers to data, the pointers are copied, but the
22634  * actual data is not.
22635  *
22636  * Returns: A copy of @queue
22637  * Since: 2.4
22638  */
22639
22640
22641 /**
22642  * g_queue_delete_link:
22643  * @queue: a #GQueue
22644  * @link_: a #GList link that <emphasis>must</emphasis> be part of @queue
22645  *
22646  * Removes @link_ from @queue and frees it.
22647  *
22648  * @link_ must be part of @queue.
22649  *
22650  * Since: 2.4
22651  */
22652
22653
22654 /**
22655  * g_queue_find:
22656  * @queue: a #GQueue
22657  * @data: data to find
22658  *
22659  * Finds the first link in @queue which contains @data.
22660  *
22661  * Returns: The first link in @queue which contains @data.
22662  * Since: 2.4
22663  */
22664
22665
22666 /**
22667  * g_queue_find_custom:
22668  * @queue: a #GQueue
22669  * @data: user data passed to @func
22670  * @func: a #GCompareFunc to call for each element. It should return 0
22671  * when the desired element is found
22672  *
22673  * Finds an element in a #GQueue, using a supplied function to find the
22674  * desired element. It iterates over the queue, calling the given function
22675  * which should return 0 when the desired element is found. The function
22676  * takes two gconstpointer arguments, the #GQueue element's data as the
22677  * first argument and the given user data as the second argument.
22678  *
22679  * Returns: The found link, or %NULL if it wasn't found
22680  * Since: 2.4
22681  */
22682
22683
22684 /**
22685  * g_queue_foreach:
22686  * @queue: a #GQueue
22687  * @func: the function to call for each element's data
22688  * @user_data: user data to pass to @func
22689  *
22690  * Calls @func for each element in the queue passing @user_data to the
22691  * function.
22692  *
22693  * Since: 2.4
22694  */
22695
22696
22697 /**
22698  * g_queue_free:
22699  * @queue: a #GQueue.
22700  *
22701  * Frees the memory allocated for the #GQueue. Only call this function if
22702  * @queue was created with g_queue_new(). If queue elements contain
22703  * dynamically-allocated memory, they should be freed first.
22704  *
22705  * <note><para>
22706  * If queue elements contain dynamically-allocated memory,
22707  * you should either use g_queue_free_full() or free them manually
22708  * first.
22709  * </para></note>
22710  */
22711
22712
22713 /**
22714  * g_queue_free_full:
22715  * @queue: a pointer to a #GQueue
22716  * @free_func: the function to be called to free each element's data
22717  *
22718  * Convenience method, which frees all the memory used by a #GQueue, and
22719  * calls the specified destroy function on every element's data.
22720  *
22721  * Since: 2.32
22722  */
22723
22724
22725 /**
22726  * g_queue_get_length:
22727  * @queue: a #GQueue
22728  *
22729  * Returns the number of items in @queue.
22730  *
22731  * Returns: The number of items in @queue.
22732  * Since: 2.4
22733  */
22734
22735
22736 /**
22737  * g_queue_index:
22738  * @queue: a #GQueue
22739  * @data: the data to find.
22740  *
22741  * Returns the position of the first element in @queue which contains @data.
22742  *
22743  * Returns: The position of the first element in @queue which contains @data, or -1 if no element in @queue contains @data.
22744  * Since: 2.4
22745  */
22746
22747
22748 /**
22749  * g_queue_init:
22750  * @queue: an uninitialized #GQueue
22751  *
22752  * A statically-allocated #GQueue must be initialized with this function
22753  * before it can be used. Alternatively you can initialize it with
22754  * #G_QUEUE_INIT. It is not necessary to initialize queues created with
22755  * g_queue_new().
22756  *
22757  * Since: 2.14
22758  */
22759
22760
22761 /**
22762  * g_queue_insert_after:
22763  * @queue: a #GQueue
22764  * @sibling: a #GList link that <emphasis>must</emphasis> be part of @queue
22765  * @data: the data to insert
22766  *
22767  * Inserts @data into @queue after @sibling
22768  *
22769  * @sibling must be part of @queue
22770  *
22771  * Since: 2.4
22772  */
22773
22774
22775 /**
22776  * g_queue_insert_before:
22777  * @queue: a #GQueue
22778  * @sibling: a #GList link that <emphasis>must</emphasis> be part of @queue
22779  * @data: the data to insert
22780  *
22781  * Inserts @data into @queue before @sibling.
22782  *
22783  * @sibling must be part of @queue.
22784  *
22785  * Since: 2.4
22786  */
22787
22788
22789 /**
22790  * g_queue_insert_sorted:
22791  * @queue: a #GQueue
22792  * @data: the data to insert
22793  * @func: the #GCompareDataFunc used to compare elements in the queue. It is
22794  *     called with two elements of the @queue and @user_data. It should
22795  *     return 0 if the elements are equal, a negative value if the first
22796  *     element comes before the second, and a positive value if the second
22797  *     element comes before the first.
22798  * @user_data: user data passed to @func.
22799  *
22800  * Inserts @data into @queue using @func to determine the new position.
22801  *
22802  * Since: 2.4
22803  */
22804
22805
22806 /**
22807  * g_queue_is_empty:
22808  * @queue: a #GQueue.
22809  *
22810  * Returns %TRUE if the queue is empty.
22811  *
22812  * Returns: %TRUE if the queue is empty.
22813  */
22814
22815
22816 /**
22817  * g_queue_link_index:
22818  * @queue: a #GQueue
22819  * @link_: A #GList link
22820  *
22821  * Returns the position of @link_ in @queue.
22822  *
22823  * Returns: The position of @link_, or -1 if the link is
22824  * not part of @queue
22825  * Since: 2.4
22826  */
22827
22828
22829 /**
22830  * g_queue_new:
22831  *
22832  * Creates a new #GQueue.
22833  *
22834  * Returns: a new #GQueue.
22835  */
22836
22837
22838 /**
22839  * g_queue_peek_head:
22840  * @queue: a #GQueue.
22841  *
22842  * Returns the first element of the queue.
22843  *
22844  * Returns: the data of the first element in the queue, or %NULL if the queue
22845  *   is empty.
22846  */
22847
22848
22849 /**
22850  * g_queue_peek_head_link:
22851  * @queue: a #GQueue
22852  *
22853  * Returns the first link in @queue
22854  *
22855  * Returns: the first link in @queue, or %NULL if @queue is empty
22856  * Since: 2.4
22857  */
22858
22859
22860 /**
22861  * g_queue_peek_nth:
22862  * @queue: a #GQueue
22863  * @n: the position of the element.
22864  *
22865  * Returns the @n'th element of @queue.
22866  *
22867  * Returns: The data for the @n'th element of @queue, or %NULL if @n is
22868  *   off the end of @queue.
22869  * Since: 2.4
22870  */
22871
22872
22873 /**
22874  * g_queue_peek_nth_link:
22875  * @queue: a #GQueue
22876  * @n: the position of the link
22877  *
22878  * Returns the link at the given position
22879  *
22880  * Returns: The link at the @n'th position, or %NULL if @n is off the
22881  * end of the list
22882  * Since: 2.4
22883  */
22884
22885
22886 /**
22887  * g_queue_peek_tail:
22888  * @queue: a #GQueue.
22889  *
22890  * Returns the last element of the queue.
22891  *
22892  * Returns: the data of the last element in the queue, or %NULL if the queue
22893  *   is empty.
22894  */
22895
22896
22897 /**
22898  * g_queue_peek_tail_link:
22899  * @queue: a #GQueue
22900  *
22901  * Returns the last link @queue.
22902  *
22903  * Returns: the last link in @queue, or %NULL if @queue is empty
22904  * Since: 2.4
22905  */
22906
22907
22908 /**
22909  * g_queue_pop_head:
22910  * @queue: a #GQueue.
22911  *
22912  * Removes the first element of the queue.
22913  *
22914  * Returns: the data of the first element in the queue, or %NULL if the queue
22915  *   is empty.
22916  */
22917
22918
22919 /**
22920  * g_queue_pop_head_link:
22921  * @queue: a #GQueue.
22922  *
22923  * Removes the first element of the queue.
22924  *
22925  * Returns: the #GList element at the head of the queue, or %NULL if the queue
22926  *   is empty.
22927  */
22928
22929
22930 /**
22931  * g_queue_pop_nth:
22932  * @queue: a #GQueue
22933  * @n: the position of the element.
22934  *
22935  * Removes the @n'th element of @queue.
22936  *
22937  * Returns: the element's data, or %NULL if @n is off the end of @queue.
22938  * Since: 2.4
22939  */
22940
22941
22942 /**
22943  * g_queue_pop_nth_link:
22944  * @queue: a #GQueue
22945  * @n: the link's position
22946  *
22947  * Removes and returns the link at the given position.
22948  *
22949  * Returns: The @n'th link, or %NULL if @n is off the end of @queue.
22950  * Since: 2.4
22951  */
22952
22953
22954 /**
22955  * g_queue_pop_tail:
22956  * @queue: a #GQueue.
22957  *
22958  * Removes the last element of the queue.
22959  *
22960  * Returns: the data of the last element in the queue, or %NULL if the queue
22961  *   is empty.
22962  */
22963
22964
22965 /**
22966  * g_queue_pop_tail_link:
22967  * @queue: a #GQueue.
22968  *
22969  * Removes the last element of the queue.
22970  *
22971  * Returns: the #GList element at the tail of the queue, or %NULL if the queue
22972  *   is empty.
22973  */
22974
22975
22976 /**
22977  * g_queue_push_head:
22978  * @queue: a #GQueue.
22979  * @data: the data for the new element.
22980  *
22981  * Adds a new element at the head of the queue.
22982  */
22983
22984
22985 /**
22986  * g_queue_push_head_link:
22987  * @queue: a #GQueue.
22988  * @link_: a single #GList element, <emphasis>not</emphasis> a list with
22989  *     more than one element.
22990  *
22991  * Adds a new element at the head of the queue.
22992  */
22993
22994
22995 /**
22996  * g_queue_push_nth:
22997  * @queue: a #GQueue
22998  * @data: the data for the new element
22999  * @n: the position to insert the new element. If @n is negative or
23000  *     larger than the number of elements in the @queue, the element is
23001  *     added to the end of the queue.
23002  *
23003  * Inserts a new element into @queue at the given position
23004  *
23005  * Since: 2.4
23006  */
23007
23008
23009 /**
23010  * g_queue_push_nth_link:
23011  * @queue: a #GQueue
23012  * @n: the position to insert the link. If this is negative or larger than
23013  *     the number of elements in @queue, the link is added to the end of
23014  *     @queue.
23015  * @link_: the link to add to @queue
23016  *
23017  * Inserts @link into @queue at the given position.
23018  *
23019  * Since: 2.4
23020  */
23021
23022
23023 /**
23024  * g_queue_push_tail:
23025  * @queue: a #GQueue.
23026  * @data: the data for the new element.
23027  *
23028  * Adds a new element at the tail of the queue.
23029  */
23030
23031
23032 /**
23033  * g_queue_push_tail_link:
23034  * @queue: a #GQueue.
23035  * @link_: a single #GList element, <emphasis>not</emphasis> a list with
23036  *   more than one element.
23037  *
23038  * Adds a new element at the tail of the queue.
23039  */
23040
23041
23042 /**
23043  * g_queue_remove:
23044  * @queue: a #GQueue
23045  * @data: data to remove.
23046  *
23047  * Removes the first element in @queue that contains @data.
23048  *
23049  * Returns: %TRUE if @data was found and removed from @queue
23050  * Since: 2.4
23051  */
23052
23053
23054 /**
23055  * g_queue_remove_all:
23056  * @queue: a #GQueue
23057  * @data: data to remove
23058  *
23059  * Remove all elements whose data equals @data from @queue.
23060  *
23061  * Returns: the number of elements removed from @queue
23062  * Since: 2.4
23063  */
23064
23065
23066 /**
23067  * g_queue_reverse:
23068  * @queue: a #GQueue
23069  *
23070  * Reverses the order of the items in @queue.
23071  *
23072  * Since: 2.4
23073  */
23074
23075
23076 /**
23077  * g_queue_sort:
23078  * @queue: a #GQueue
23079  * @compare_func: the #GCompareDataFunc used to sort @queue. This function
23080  *     is passed two elements of the queue and should return 0 if they are
23081  *     equal, a negative value if the first comes before the second, and
23082  *     a positive value if the second comes before the first.
23083  * @user_data: user data passed to @compare_func
23084  *
23085  * Sorts @queue using @compare_func.
23086  *
23087  * Since: 2.4
23088  */
23089
23090
23091 /**
23092  * g_queue_unlink:
23093  * @queue: a #GQueue
23094  * @link_: a #GList link that <emphasis>must</emphasis> be part of @queue
23095  *
23096  * Unlinks @link_ so that it will no longer be part of @queue. The link is
23097  * not freed.
23098  *
23099  * @link_ must be part of @queue,
23100  *
23101  * Since: 2.4
23102  */
23103
23104
23105 /**
23106  * g_rand_boolean:
23107  * @rand_: a #GRand.
23108  *
23109  * Returns a random #gboolean from @rand_. This corresponds to a
23110  * unbiased coin toss.
23111  *
23112  * Returns: a random #gboolean.
23113  */
23114
23115
23116 /**
23117  * g_rand_copy:
23118  * @rand_: a #GRand.
23119  *
23120  * Copies a #GRand into a new one with the same exact state as before.
23121  * This way you can take a snapshot of the random number generator for
23122  * replaying later.
23123  *
23124  * Returns: the new #GRand.
23125  * Since: 2.4
23126  */
23127
23128
23129 /**
23130  * g_rand_double:
23131  * @rand_: a #GRand.
23132  *
23133  * Returns the next random #gdouble from @rand_ equally distributed over
23134  * the range [0..1).
23135  *
23136  * Returns: A random number.
23137  */
23138
23139
23140 /**
23141  * g_rand_double_range:
23142  * @rand_: a #GRand.
23143  * @begin: lower closed bound of the interval.
23144  * @end: upper open bound of the interval.
23145  *
23146  * Returns the next random #gdouble from @rand_ equally distributed over
23147  * the range [@begin..@end).
23148  *
23149  * Returns: A random number.
23150  */
23151
23152
23153 /**
23154  * g_rand_free:
23155  * @rand_: a #GRand.
23156  *
23157  * Frees the memory allocated for the #GRand.
23158  */
23159
23160
23161 /**
23162  * g_rand_int:
23163  * @rand_: a #GRand.
23164  *
23165  * Returns the next random #guint32 from @rand_ equally distributed over
23166  * the range [0..2^32-1].
23167  *
23168  * Returns: A random number.
23169  */
23170
23171
23172 /**
23173  * g_rand_int_range:
23174  * @rand_: a #GRand.
23175  * @begin: lower closed bound of the interval.
23176  * @end: upper open bound of the interval.
23177  *
23178  * Returns the next random #gint32 from @rand_ equally distributed over
23179  * the range [@begin..@end-1].
23180  *
23181  * Returns: A random number.
23182  */
23183
23184
23185 /**
23186  * g_rand_new:
23187  *
23188  * Creates a new random number generator initialized with a seed taken
23189  * either from <filename>/dev/urandom</filename> (if existing) or from
23190  * the current time (as a fallback).  On Windows, the seed is taken from
23191  * rand_s().
23192  *
23193  * Returns: the new #GRand.
23194  */
23195
23196
23197 /**
23198  * g_rand_new_with_seed:
23199  * @seed: a value to initialize the random number generator.
23200  *
23201  * Creates a new random number generator initialized with @seed.
23202  *
23203  * Returns: the new #GRand.
23204  */
23205
23206
23207 /**
23208  * g_rand_new_with_seed_array:
23209  * @seed: an array of seeds to initialize the random number generator.
23210  * @seed_length: an array of seeds to initialize the random number generator.
23211  *
23212  * Creates a new random number generator initialized with @seed.
23213  *
23214  * Returns: the new #GRand.
23215  * Since: 2.4
23216  */
23217
23218
23219 /**
23220  * g_rand_set_seed:
23221  * @rand_: a #GRand.
23222  * @seed: a value to reinitialize the random number generator.
23223  *
23224  * Sets the seed for the random number generator #GRand to @seed.
23225  */
23226
23227
23228 /**
23229  * g_rand_set_seed_array:
23230  * @rand_: a #GRand.
23231  * @seed: array to initialize with
23232  * @seed_length: length of array
23233  *
23234  * Initializes the random number generator by an array of
23235  * longs.  Array can be of arbitrary size, though only the
23236  * first 624 values are taken.  This function is useful
23237  * if you have many low entropy seeds, or if you require more then
23238  * 32bits of actual entropy for your application.
23239  *
23240  * Since: 2.4
23241  */
23242
23243
23244 /**
23245  * g_random_boolean:
23246  *
23247  * Returns a random #gboolean. This corresponds to a unbiased coin toss.
23248  *
23249  * Returns: a random #gboolean.
23250  */
23251
23252
23253 /**
23254  * g_random_double:
23255  *
23256  * Returns a random #gdouble equally distributed over the range [0..1).
23257  *
23258  * Returns: A random number.
23259  */
23260
23261
23262 /**
23263  * g_random_double_range:
23264  * @begin: lower closed bound of the interval.
23265  * @end: upper open bound of the interval.
23266  *
23267  * Returns a random #gdouble equally distributed over the range [@begin..@end).
23268  *
23269  * Returns: A random number.
23270  */
23271
23272
23273 /**
23274  * g_random_int:
23275  *
23276  * Return a random #guint32 equally distributed over the range
23277  * [0..2^32-1].
23278  *
23279  * Returns: A random number.
23280  */
23281
23282
23283 /**
23284  * g_random_int_range:
23285  * @begin: lower closed bound of the interval.
23286  * @end: upper open bound of the interval.
23287  *
23288  * Returns a random #gint32 equally distributed over the range
23289  * [@begin..@end-1].
23290  *
23291  * Returns: A random number.
23292  */
23293
23294
23295 /**
23296  * g_random_set_seed:
23297  * @seed: a value to reinitialize the global random number generator.
23298  *
23299  * Sets the seed for the global random number generator, which is used
23300  * by the <function>g_random_*</function> functions, to @seed.
23301  */
23302
23303
23304 /**
23305  * g_realloc:
23306  * @mem: the memory to reallocate
23307  * @n_bytes: new size of the memory in bytes
23308  *
23309  * Reallocates the memory pointed to by @mem, so that it now has space for
23310  * @n_bytes bytes of memory. It returns the new address of the memory, which may
23311  * have been moved. @mem may be %NULL, in which case it's considered to
23312  * have zero-length. @n_bytes may be 0, in which case %NULL will be returned
23313  * and @mem will be freed unless it is %NULL.
23314  *
23315  * Returns: the new address of the allocated memory
23316  */
23317
23318
23319 /**
23320  * g_realloc_n:
23321  * @mem: the memory to reallocate
23322  * @n_blocks: the number of blocks to allocate
23323  * @n_block_bytes: the size of each block in bytes
23324  *
23325  * This function is similar to g_realloc(), allocating (@n_blocks * @n_block_bytes) bytes,
23326  * but care is taken to detect possible overflow during multiplication.
23327  *
23328  * Since: 2.24
23329  * Returns: the new address of the allocated memory
23330  */
23331
23332
23333 /**
23334  * g_rec_mutex_clear:
23335  * @rec_mutex: an initialized #GRecMutex
23336  *
23337  * Frees the resources allocated to a recursive mutex with
23338  * g_rec_mutex_init().
23339  *
23340  * This function should not be used with a #GRecMutex that has been
23341  * statically allocated.
23342  *
23343  * Calling g_rec_mutex_clear() on a locked recursive mutex leads
23344  * to undefined behaviour.
23345  *
23346  * Sine: 2.32
23347  */
23348
23349
23350 /**
23351  * g_rec_mutex_init:
23352  * @rec_mutex: an uninitialized #GRecMutex
23353  *
23354  * Initializes a #GRecMutex so that it can be used.
23355  *
23356  * This function is useful to initialize a recursive mutex
23357  * that has been allocated on the stack, or as part of a larger
23358  * structure.
23359  *
23360  * It is not necessary to initialise a recursive mutex that has been
23361  * statically allocated.
23362  *
23363  * |[
23364  *   typedef struct {
23365  *     GRecMutex m;
23366  *     ...
23367  *   } Blob;
23368  *
23369  * Blob *b;
23370  *
23371  * b = g_new (Blob, 1);
23372  * g_rec_mutex_init (&b->m);
23373  * ]|
23374  *
23375  * Calling g_rec_mutex_init() on an already initialized #GRecMutex
23376  * leads to undefined behaviour.
23377  *
23378  * To undo the effect of g_rec_mutex_init() when a recursive mutex
23379  * is no longer needed, use g_rec_mutex_clear().
23380  *
23381  * Since: 2.32
23382  */
23383
23384
23385 /**
23386  * g_rec_mutex_lock:
23387  * @rec_mutex: a #GRecMutex
23388  *
23389  * Locks @rec_mutex. If @rec_mutex is already locked by another
23390  * thread, the current thread will block until @rec_mutex is
23391  * unlocked by the other thread. If @rec_mutex is already locked
23392  * by the current thread, the 'lock count' of @rec_mutex is increased.
23393  * The mutex will only become available again when it is unlocked
23394  * as many times as it has been locked.
23395  *
23396  * Since: 2.32
23397  */
23398
23399
23400 /**
23401  * g_rec_mutex_trylock:
23402  * @rec_mutex: a #GRecMutex
23403  *
23404  * Tries to lock @rec_mutex. If @rec_mutex is already locked
23405  * by another thread, it immediately returns %FALSE. Otherwise
23406  * it locks @rec_mutex and returns %TRUE.
23407  *
23408  * Returns: %TRUE if @rec_mutex could be locked
23409  * Since: 2.32
23410  */
23411
23412
23413 /**
23414  * g_rec_mutex_unlock:
23415  * @rec_mutex: a #GRecMutex
23416  *
23417  * Unlocks @rec_mutex. If another thread is blocked in a
23418  * g_rec_mutex_lock() call for @rec_mutex, it will become unblocked
23419  * and can lock @rec_mutex itself.
23420  *
23421  * Calling g_rec_mutex_unlock() on a recursive mutex that is not
23422  * locked by the current thread leads to undefined behaviour.
23423  *
23424  * Since: 2.32
23425  */
23426
23427
23428 /**
23429  * g_regex_check_replacement:
23430  * @replacement: the replacement string
23431  * @has_references: (out) (allow-none): location to store information about
23432  *   references in @replacement or %NULL
23433  * @error: location to store error
23434  *
23435  * Checks whether @replacement is a valid replacement string
23436  * (see g_regex_replace()), i.e. that all escape sequences in
23437  * it are valid.
23438  *
23439  * If @has_references is not %NULL then @replacement is checked
23440  * for pattern references. For instance, replacement text 'foo\n'
23441  * does not contain references and may be evaluated without information
23442  * about actual match, but '\0\1' (whole match followed by first
23443  * subpattern) requires valid #GMatchInfo object.
23444  *
23445  * Returns: whether @replacement is a valid replacement string
23446  * Since: 2.14
23447  */
23448
23449
23450 /**
23451  * g_regex_escape_nul:
23452  * @string: the string to escape
23453  * @length: the length of @string
23454  *
23455  * Escapes the nul characters in @string to "\x00".  It can be used
23456  * to compile a regex with embedded nul characters.
23457  *
23458  * For completeness, @length can be -1 for a nul-terminated string.
23459  * In this case the output string will be of course equal to @string.
23460  *
23461  * Returns: a newly-allocated escaped string
23462  * Since: 2.30
23463  */
23464
23465
23466 /**
23467  * g_regex_escape_string:
23468  * @string: (array length=length): the string to escape
23469  * @length: the length of @string, or -1 if @string is nul-terminated
23470  *
23471  * Escapes the special characters used for regular expressions
23472  * in @string, for instance "a.b*c" becomes "a\.b\*c". This
23473  * function is useful to dynamically generate regular expressions.
23474  *
23475  * @string can contain nul characters that are replaced with "\0",
23476  * in this case remember to specify the correct length of @string
23477  * in @length.
23478  *
23479  * Returns: a newly-allocated escaped string
23480  * Since: 2.14
23481  */
23482
23483
23484 /**
23485  * g_regex_get_capture_count:
23486  * @regex: a #GRegex
23487  *
23488  * Returns the number of capturing subpatterns in the pattern.
23489  *
23490  * Returns: the number of capturing subpatterns
23491  * Since: 2.14
23492  */
23493
23494
23495 /**
23496  * g_regex_get_compile_flags:
23497  * @regex: a #GRegex
23498  *
23499  * Returns the compile options that @regex was created with.
23500  *
23501  * Returns: flags from #GRegexCompileFlags
23502  * Since: 2.26
23503  */
23504
23505
23506 /**
23507  * g_regex_get_has_cr_or_lf:
23508  * @regex: a #GRegex structure
23509  *
23510  * Checks whether the pattern contains explicit CR or LF references.
23511  *
23512  * Returns: %TRUE if the pattern contains explicit CR or LF references
23513  * Since: 2.34
23514  */
23515
23516
23517 /**
23518  * g_regex_get_match_flags:
23519  * @regex: a #GRegex
23520  *
23521  * Returns the match options that @regex was created with.
23522  *
23523  * Returns: flags from #GRegexMatchFlags
23524  * Since: 2.26
23525  */
23526
23527
23528 /**
23529  * g_regex_get_max_backref:
23530  * @regex: a #GRegex
23531  *
23532  * Returns the number of the highest back reference
23533  * in the pattern, or 0 if the pattern does not contain
23534  * back references.
23535  *
23536  * Returns: the number of the highest back reference
23537  * Since: 2.14
23538  */
23539
23540
23541 /**
23542  * g_regex_get_max_lookbehind:
23543  * @regex: a #GRegex structure
23544  *
23545  * Gets the number of characters in the longest lookbehind assertion in the
23546  * pattern. This information is useful when doing multi-segment matching using
23547  * the partial matching facilities.
23548  *
23549  * Returns: the number of characters in the longest lookbehind assertion.
23550  * Since: 2.38
23551  */
23552
23553
23554 /**
23555  * g_regex_get_pattern:
23556  * @regex: a #GRegex structure
23557  *
23558  * Gets the pattern string associated with @regex, i.e. a copy of
23559  * the string passed to g_regex_new().
23560  *
23561  * Returns: the pattern of @regex
23562  * Since: 2.14
23563  */
23564
23565
23566 /**
23567  * g_regex_get_string_number:
23568  * @regex: #GRegex structure
23569  * @name: name of the subexpression
23570  *
23571  * Retrieves the number of the subexpression named @name.
23572  *
23573  * Returns: The number of the subexpression or -1 if @name
23574  *   does not exists
23575  * Since: 2.14
23576  */
23577
23578
23579 /**
23580  * g_regex_match:
23581  * @regex: a #GRegex structure from g_regex_new()
23582  * @string: the string to scan for matches
23583  * @match_options: match options
23584  * @match_info: (out) (allow-none): pointer to location where to store
23585  *     the #GMatchInfo, or %NULL if you do not need it
23586  *
23587  * Scans for a match in string for the pattern in @regex.
23588  * The @match_options are combined with the match options specified
23589  * when the @regex structure was created, letting you have more
23590  * flexibility in reusing #GRegex structures.
23591  *
23592  * A #GMatchInfo structure, used to get information on the match,
23593  * is stored in @match_info if not %NULL. Note that if @match_info
23594  * is not %NULL then it is created even if the function returns %FALSE,
23595  * i.e. you must free it regardless if regular expression actually matched.
23596  *
23597  * To retrieve all the non-overlapping matches of the pattern in
23598  * string you can use g_match_info_next().
23599  *
23600  * |[
23601  * static void
23602  * print_uppercase_words (const gchar *string)
23603  * {
23604  *   /&ast; Print all uppercase-only words. &ast;/
23605  *   GRegex *regex;
23606  *   GMatchInfo *match_info;
23607  *   &nbsp;
23608  *   regex = g_regex_new ("[A-Z]+", 0, 0, NULL);
23609  *   g_regex_match (regex, string, 0, &amp;match_info);
23610  *   while (g_match_info_matches (match_info))
23611  *     {
23612  *       gchar *word = g_match_info_fetch (match_info, 0);
23613  *       g_print ("Found: %s\n", word);
23614  *       g_free (word);
23615  *       g_match_info_next (match_info, NULL);
23616  *     }
23617  *   g_match_info_free (match_info);
23618  *   g_regex_unref (regex);
23619  * }
23620  * ]|
23621  *
23622  * @string is not copied and is used in #GMatchInfo internally. If
23623  * you use any #GMatchInfo method (except g_match_info_free()) after
23624  * freeing or modifying @string then the behaviour is undefined.
23625  *
23626  * Returns: %TRUE is the string matched, %FALSE otherwise
23627  * Since: 2.14
23628  */
23629
23630
23631 /**
23632  * g_regex_match_all:
23633  * @regex: a #GRegex structure from g_regex_new()
23634  * @string: the string to scan for matches
23635  * @match_options: match options
23636  * @match_info: (out) (allow-none): pointer to location where to store
23637  *     the #GMatchInfo, or %NULL if you do not need it
23638  *
23639  * Using the standard algorithm for regular expression matching only
23640  * the longest match in the string is retrieved. This function uses
23641  * a different algorithm so it can retrieve all the possible matches.
23642  * For more documentation see g_regex_match_all_full().
23643  *
23644  * A #GMatchInfo structure, used to get information on the match, is
23645  * stored in @match_info if not %NULL. Note that if @match_info is
23646  * not %NULL then it is created even if the function returns %FALSE,
23647  * i.e. you must free it regardless if regular expression actually
23648  * matched.
23649  *
23650  * @string is not copied and is used in #GMatchInfo internally. If
23651  * you use any #GMatchInfo method (except g_match_info_free()) after
23652  * freeing or modifying @string then the behaviour is undefined.
23653  *
23654  * Returns: %TRUE is the string matched, %FALSE otherwise
23655  * Since: 2.14
23656  */
23657
23658
23659 /**
23660  * g_regex_match_all_full:
23661  * @regex: a #GRegex structure from g_regex_new()
23662  * @string: (array length=string_len): the string to scan for matches
23663  * @string_len: the length of @string, or -1 if @string is nul-terminated
23664  * @start_position: starting index of the string to match
23665  * @match_options: match options
23666  * @match_info: (out) (allow-none): pointer to location where to store
23667  *     the #GMatchInfo, or %NULL if you do not need it
23668  * @error: location to store the error occurring, or %NULL to ignore errors
23669  *
23670  * Using the standard algorithm for regular expression matching only
23671  * the longest match in the string is retrieved, it is not possible
23672  * to obtain all the available matches. For instance matching
23673  * "&lt;a&gt; &lt;b&gt; &lt;c&gt;" against the pattern "&lt;.*&gt;"
23674  * you get "&lt;a&gt; &lt;b&gt; &lt;c&gt;".
23675  *
23676  * This function uses a different algorithm (called DFA, i.e. deterministic
23677  * finite automaton), so it can retrieve all the possible matches, all
23678  * starting at the same point in the string. For instance matching
23679  * "&lt;a&gt; &lt;b&gt; &lt;c&gt;" against the pattern "&lt;.*&gt;"
23680  * you would obtain three matches: "&lt;a&gt; &lt;b&gt; &lt;c&gt;",
23681  * "&lt;a&gt; &lt;b&gt;" and "&lt;a&gt;".
23682  *
23683  * The number of matched strings is retrieved using
23684  * g_match_info_get_match_count(). To obtain the matched strings and
23685  * their position you can use, respectively, g_match_info_fetch() and
23686  * g_match_info_fetch_pos(). Note that the strings are returned in
23687  * reverse order of length; that is, the longest matching string is
23688  * given first.
23689  *
23690  * Note that the DFA algorithm is slower than the standard one and it
23691  * is not able to capture substrings, so backreferences do not work.
23692  *
23693  * Setting @start_position differs from just passing over a shortened
23694  * string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern
23695  * that begins with any kind of lookbehind assertion, such as "\b".
23696  *
23697  * A #GMatchInfo structure, used to get information on the match, is
23698  * stored in @match_info if not %NULL. Note that if @match_info is
23699  * not %NULL then it is created even if the function returns %FALSE,
23700  * i.e. you must free it regardless if regular expression actually
23701  * matched.
23702  *
23703  * @string is not copied and is used in #GMatchInfo internally. If
23704  * you use any #GMatchInfo method (except g_match_info_free()) after
23705  * freeing or modifying @string then the behaviour is undefined.
23706  *
23707  * Returns: %TRUE is the string matched, %FALSE otherwise
23708  * Since: 2.14
23709  */
23710
23711
23712 /**
23713  * g_regex_match_full:
23714  * @regex: a #GRegex structure from g_regex_new()
23715  * @string: (array length=string_len): the string to scan for matches
23716  * @string_len: the length of @string, or -1 if @string is nul-terminated
23717  * @start_position: starting index of the string to match
23718  * @match_options: match options
23719  * @match_info: (out) (allow-none): pointer to location where to store
23720  *     the #GMatchInfo, or %NULL if you do not need it
23721  * @error: location to store the error occurring, or %NULL to ignore errors
23722  *
23723  * Scans for a match in string for the pattern in @regex.
23724  * The @match_options are combined with the match options specified
23725  * when the @regex structure was created, letting you have more
23726  * flexibility in reusing #GRegex structures.
23727  *
23728  * Setting @start_position differs from just passing over a shortened
23729  * string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern
23730  * that begins with any kind of lookbehind assertion, such as "\b".
23731  *
23732  * A #GMatchInfo structure, used to get information on the match, is
23733  * stored in @match_info if not %NULL. Note that if @match_info is
23734  * not %NULL then it is created even if the function returns %FALSE,
23735  * i.e. you must free it regardless if regular expression actually
23736  * matched.
23737  *
23738  * @string is not copied and is used in #GMatchInfo internally. If
23739  * you use any #GMatchInfo method (except g_match_info_free()) after
23740  * freeing or modifying @string then the behaviour is undefined.
23741  *
23742  * To retrieve all the non-overlapping matches of the pattern in
23743  * string you can use g_match_info_next().
23744  *
23745  * |[
23746  * static void
23747  * print_uppercase_words (const gchar *string)
23748  * {
23749  *   /&ast; Print all uppercase-only words. &ast;/
23750  *   GRegex *regex;
23751  *   GMatchInfo *match_info;
23752  *   GError *error = NULL;
23753  *   &nbsp;
23754  *   regex = g_regex_new ("[A-Z]+", 0, 0, NULL);
23755  *   g_regex_match_full (regex, string, -1, 0, 0, &amp;match_info, &amp;error);
23756  *   while (g_match_info_matches (match_info))
23757  *     {
23758  *       gchar *word = g_match_info_fetch (match_info, 0);
23759  *       g_print ("Found: %s\n", word);
23760  *       g_free (word);
23761  *       g_match_info_next (match_info, &amp;error);
23762  *     }
23763  *   g_match_info_free (match_info);
23764  *   g_regex_unref (regex);
23765  *   if (error != NULL)
23766  *     {
23767  *       g_printerr ("Error while matching: %s\n", error->message);
23768  *       g_error_free (error);
23769  *     }
23770  * }
23771  * ]|
23772  *
23773  * Returns: %TRUE is the string matched, %FALSE otherwise
23774  * Since: 2.14
23775  */
23776
23777
23778 /**
23779  * g_regex_match_simple:
23780  * @pattern: the regular expression
23781  * @string: the string to scan for matches
23782  * @compile_options: compile options for the regular expression, or 0
23783  * @match_options: match options, or 0
23784  *
23785  * Scans for a match in @string for @pattern.
23786  *
23787  * This function is equivalent to g_regex_match() but it does not
23788  * require to compile the pattern with g_regex_new(), avoiding some
23789  * lines of code when you need just to do a match without extracting
23790  * substrings, capture counts, and so on.
23791  *
23792  * If this function is to be called on the same @pattern more than
23793  * once, it's more efficient to compile the pattern once with
23794  * g_regex_new() and then use g_regex_match().
23795  *
23796  * Returns: %TRUE if the string matched, %FALSE otherwise
23797  * Since: 2.14
23798  */
23799
23800
23801 /**
23802  * g_regex_new:
23803  * @pattern: the regular expression
23804  * @compile_options: compile options for the regular expression, or 0
23805  * @match_options: match options for the regular expression, or 0
23806  * @error: return location for a #GError
23807  *
23808  * Compiles the regular expression to an internal form, and does
23809  * the initial setup of the #GRegex structure.
23810  *
23811  * Returns: a #GRegex structure. Call g_regex_unref() when you
23812  *   are done with it
23813  * Since: 2.14
23814  */
23815
23816
23817 /**
23818  * g_regex_ref:
23819  * @regex: a #GRegex
23820  *
23821  * Increases reference count of @regex by 1.
23822  *
23823  * Returns: @regex
23824  * Since: 2.14
23825  */
23826
23827
23828 /**
23829  * g_regex_replace:
23830  * @regex: a #GRegex structure
23831  * @string: (array length=string_len): the string to perform matches against
23832  * @string_len: the length of @string, or -1 if @string is nul-terminated
23833  * @start_position: starting index of the string to match
23834  * @replacement: text to replace each match with
23835  * @match_options: options for the match
23836  * @error: location to store the error occurring, or %NULL to ignore errors
23837  *
23838  * Replaces all occurrences of the pattern in @regex with the
23839  * replacement text. Backreferences of the form '\number' or
23840  * '\g&lt;number&gt;' in the replacement text are interpolated by the
23841  * number-th captured subexpression of the match, '\g&lt;name&gt;' refers
23842  * to the captured subexpression with the given name. '\0' refers to the
23843  * complete match, but '\0' followed by a number is the octal representation
23844  * of a character. To include a literal '\' in the replacement, write '\\'.
23845  * There are also escapes that changes the case of the following text:
23846  *
23847  * <variablelist>
23848  * <varlistentry><term>\l</term>
23849  * <listitem>
23850  * <para>Convert to lower case the next character</para>
23851  * </listitem>
23852  * </varlistentry>
23853  * <varlistentry><term>\u</term>
23854  * <listitem>
23855  * <para>Convert to upper case the next character</para>
23856  * </listitem>
23857  * </varlistentry>
23858  * <varlistentry><term>\L</term>
23859  * <listitem>
23860  * <para>Convert to lower case till \E</para>
23861  * </listitem>
23862  * </varlistentry>
23863  * <varlistentry><term>\U</term>
23864  * <listitem>
23865  * <para>Convert to upper case till \E</para>
23866  * </listitem>
23867  * </varlistentry>
23868  * <varlistentry><term>\E</term>
23869  * <listitem>
23870  * <para>End case modification</para>
23871  * </listitem>
23872  * </varlistentry>
23873  * </variablelist>
23874  *
23875  * If you do not need to use backreferences use g_regex_replace_literal().
23876  *
23877  * The @replacement string must be UTF-8 encoded even if #G_REGEX_RAW was
23878  * passed to g_regex_new(). If you want to use not UTF-8 encoded stings
23879  * you can use g_regex_replace_literal().
23880  *
23881  * Setting @start_position differs from just passing over a shortened
23882  * string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern that
23883  * begins with any kind of lookbehind assertion, such as "\b".
23884  *
23885  * Returns: a newly allocated string containing the replacements
23886  * Since: 2.14
23887  */
23888
23889
23890 /**
23891  * g_regex_replace_eval:
23892  * @regex: a #GRegex structure from g_regex_new()
23893  * @string: (array length=string_len): string to perform matches against
23894  * @string_len: the length of @string, or -1 if @string is nul-terminated
23895  * @start_position: starting index of the string to match
23896  * @match_options: options for the match
23897  * @eval: a function to call for each match
23898  * @user_data: user data to pass to the function
23899  * @error: location to store the error occurring, or %NULL to ignore errors
23900  *
23901  * Replaces occurrences of the pattern in regex with the output of
23902  * @eval for that occurrence.
23903  *
23904  * Setting @start_position differs from just passing over a shortened
23905  * string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern
23906  * that begins with any kind of lookbehind assertion, such as "\b".
23907  *
23908  * The following example uses g_regex_replace_eval() to replace multiple
23909  * strings at once:
23910  * |[
23911  * static gboolean
23912  * eval_cb (const GMatchInfo *info,
23913  *          GString          *res,
23914  *          gpointer          data)
23915  * {
23916  *   gchar *match;
23917  *   gchar *r;
23918  *
23919  *    match = g_match_info_fetch (info, 0);
23920  *    r = g_hash_table_lookup ((GHashTable *)data, match);
23921  *    g_string_append (res, r);
23922  *    g_free (match);
23923  *
23924  *    return FALSE;
23925  * }
23926  *
23927  * /&ast; ... &ast;/
23928  *
23929  * GRegex *reg;
23930  * GHashTable *h;
23931  * gchar *res;
23932  *
23933  * h = g_hash_table_new (g_str_hash, g_str_equal);
23934  *
23935  * g_hash_table_insert (h, "1", "ONE");
23936  * g_hash_table_insert (h, "2", "TWO");
23937  * g_hash_table_insert (h, "3", "THREE");
23938  * g_hash_table_insert (h, "4", "FOUR");
23939  *
23940  * reg = g_regex_new ("1|2|3|4", 0, 0, NULL);
23941  * res = g_regex_replace_eval (reg, text, -1, 0, 0, eval_cb, h, NULL);
23942  * g_hash_table_destroy (h);
23943  *
23944  * /&ast; ... &ast;/
23945  * ]|
23946  *
23947  * Returns: a newly allocated string containing the replacements
23948  * Since: 2.14
23949  */
23950
23951
23952 /**
23953  * g_regex_replace_literal:
23954  * @regex: a #GRegex structure
23955  * @string: (array length=string_len): the string to perform matches against
23956  * @string_len: the length of @string, or -1 if @string is nul-terminated
23957  * @start_position: starting index of the string to match
23958  * @replacement: text to replace each match with
23959  * @match_options: options for the match
23960  * @error: location to store the error occurring, or %NULL to ignore errors
23961  *
23962  * Replaces all occurrences of the pattern in @regex with the
23963  * replacement text. @replacement is replaced literally, to
23964  * include backreferences use g_regex_replace().
23965  *
23966  * Setting @start_position differs from just passing over a
23967  * shortened string and setting #G_REGEX_MATCH_NOTBOL in the
23968  * case of a pattern that begins with any kind of lookbehind
23969  * assertion, such as "\b".
23970  *
23971  * Returns: a newly allocated string containing the replacements
23972  * Since: 2.14
23973  */
23974
23975
23976 /**
23977  * g_regex_split:
23978  * @regex: a #GRegex structure
23979  * @string: the string to split with the pattern
23980  * @match_options: match time option flags
23981  *
23982  * Breaks the string on the pattern, and returns an array of the tokens.
23983  * If the pattern contains capturing parentheses, then the text for each
23984  * of the substrings will also be returned. If the pattern does not match
23985  * anywhere in the string, then the whole string is returned as the first
23986  * token.
23987  *
23988  * As a special case, the result of splitting the empty string "" is an
23989  * empty vector, not a vector containing a single string. The reason for
23990  * this special case is that being able to represent a empty vector is
23991  * typically more useful than consistent handling of empty elements. If
23992  * you do need to represent empty elements, you'll need to check for the
23993  * empty string before calling this function.
23994  *
23995  * A pattern that can match empty strings splits @string into separate
23996  * characters wherever it matches the empty string between characters.
23997  * For example splitting "ab c" using as a separator "\s*", you will get
23998  * "a", "b" and "c".
23999  *
24000  * Returns: (transfer full): a %NULL-terminated gchar ** array. Free
24001  * it using g_strfreev()
24002  * Since: 2.14
24003  */
24004
24005
24006 /**
24007  * g_regex_split_full:
24008  * @regex: a #GRegex structure
24009  * @string: (array length=string_len): the string to split with the pattern
24010  * @string_len: the length of @string, or -1 if @string is nul-terminated
24011  * @start_position: starting index of the string to match
24012  * @match_options: match time option flags
24013  * @max_tokens: the maximum number of tokens to split @string into.
24014  *   If this is less than 1, the string is split completely
24015  * @error: return location for a #GError
24016  *
24017  * Breaks the string on the pattern, and returns an array of the tokens.
24018  * If the pattern contains capturing parentheses, then the text for each
24019  * of the substrings will also be returned. If the pattern does not match
24020  * anywhere in the string, then the whole string is returned as the first
24021  * token.
24022  *
24023  * As a special case, the result of splitting the empty string "" is an
24024  * empty vector, not a vector containing a single string. The reason for
24025  * this special case is that being able to represent a empty vector is
24026  * typically more useful than consistent handling of empty elements. If
24027  * you do need to represent empty elements, you'll need to check for the
24028  * empty string before calling this function.
24029  *
24030  * A pattern that can match empty strings splits @string into separate
24031  * characters wherever it matches the empty string between characters.
24032  * For example splitting "ab c" using as a separator "\s*", you will get
24033  * "a", "b" and "c".
24034  *
24035  * Setting @start_position differs from just passing over a shortened
24036  * string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern
24037  * that begins with any kind of lookbehind assertion, such as "\b".
24038  *
24039  * Returns: (transfer full): a %NULL-terminated gchar ** array. Free
24040  * it using g_strfreev()
24041  * Since: 2.14
24042  */
24043
24044
24045 /**
24046  * g_regex_split_simple:
24047  * @pattern: the regular expression
24048  * @string: the string to scan for matches
24049  * @compile_options: compile options for the regular expression, or 0
24050  * @match_options: match options, or 0
24051  *
24052  * Breaks the string on the pattern, and returns an array of
24053  * the tokens. If the pattern contains capturing parentheses,
24054  * then the text for each of the substrings will also be returned.
24055  * If the pattern does not match anywhere in the string, then the
24056  * whole string is returned as the first token.
24057  *
24058  * This function is equivalent to g_regex_split() but it does
24059  * not require to compile the pattern with g_regex_new(), avoiding
24060  * some lines of code when you need just to do a split without
24061  * extracting substrings, capture counts, and so on.
24062  *
24063  * If this function is to be called on the same @pattern more than
24064  * once, it's more efficient to compile the pattern once with
24065  * g_regex_new() and then use g_regex_split().
24066  *
24067  * As a special case, the result of splitting the empty string ""
24068  * is an empty vector, not a vector containing a single string.
24069  * The reason for this special case is that being able to represent
24070  * a empty vector is typically more useful than consistent handling
24071  * of empty elements. If you do need to represent empty elements,
24072  * you'll need to check for the empty string before calling this
24073  * function.
24074  *
24075  * A pattern that can match empty strings splits @string into
24076  * separate characters wherever it matches the empty string between
24077  * characters. For example splitting "ab c" using as a separator
24078  * "\s*", you will get "a", "b" and "c".
24079  *
24080  * Returns: (transfer full): a %NULL-terminated array of strings. Free
24081  * it using g_strfreev()
24082  * Since: 2.14
24083  */
24084
24085
24086 /**
24087  * g_regex_unref:
24088  * @regex: a #GRegex
24089  *
24090  * Decreases reference count of @regex by 1. When reference count drops
24091  * to zero, it frees all the memory associated with the regex structure.
24092  *
24093  * Since: 2.14
24094  */
24095
24096
24097 /**
24098  * g_reload_user_special_dirs_cache:
24099  *
24100  * Resets the cache used for g_get_user_special_dir(), so
24101  * that the latest on-disk version is used. Call this only
24102  * if you just changed the data on disk yourself.
24103  *
24104  * Due to threadsafety issues this may cause leaking of strings
24105  * that were previously returned from g_get_user_special_dir()
24106  * that can't be freed. We ensure to only leak the data for
24107  * the directories that actually changed value though.
24108  *
24109  * Since: 2.22
24110  */
24111
24112
24113 /**
24114  * g_remove:
24115  * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
24116  *
24117  * A wrapper for the POSIX remove() function. The remove() function
24118  * deletes a name from the filesystem.
24119  *
24120  * See your C library manual for more details about how remove() works
24121  * on your system. On Unix, remove() removes also directories, as it
24122  * calls unlink() for files and rmdir() for directories. On Windows,
24123  * although remove() in the C library only works for files, this
24124  * function tries first remove() and then if that fails rmdir(), and
24125  * thus works for both files and directories. Note however, that on
24126  * Windows, it is in general not possible to remove a file that is
24127  * open to some process, or mapped into memory.
24128  *
24129  * If this function fails on Windows you can't infer too much from the
24130  * errno value. rmdir() is tried regardless of what caused remove() to
24131  * fail. Any errno value set by remove() will be overwritten by that
24132  * set by rmdir().
24133  *
24134  * Returns: 0 if the file was successfully removed, -1 if an error
24135  *    occurred
24136  * Since: 2.6
24137  */
24138
24139
24140 /**
24141  * g_rename:
24142  * @oldfilename: a pathname in the GLib file name encoding (UTF-8 on Windows)
24143  * @newfilename: a pathname in the GLib file name encoding
24144  *
24145  * A wrapper for the POSIX rename() function. The rename() function
24146  * renames a file, moving it between directories if required.
24147  *
24148  * See your C library manual for more details about how rename() works
24149  * on your system. It is not possible in general on Windows to rename
24150  * a file that is open to some process.
24151  *
24152  * Returns: 0 if the renaming succeeded, -1 if an error occurred
24153  * Since: 2.6
24154  */
24155
24156
24157 /**
24158  * g_rmdir:
24159  * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
24160  *
24161  * A wrapper for the POSIX rmdir() function. The rmdir() function
24162  * deletes a directory from the filesystem.
24163  *
24164  * See your C library manual for more details about how rmdir() works
24165  * on your system.
24166  *
24167  * Returns: 0 if the directory was successfully removed, -1 if an error
24168  *    occurred
24169  * Since: 2.6
24170  */
24171
24172
24173 /**
24174  * g_rw_lock_clear:
24175  * @rw_lock: an initialized #GRWLock
24176  *
24177  * Frees the resources allocated to a lock with g_rw_lock_init().
24178  *
24179  * This function should not be used with a #GRWLock that has been
24180  * statically allocated.
24181  *
24182  * Calling g_rw_lock_clear() when any thread holds the lock
24183  * leads to undefined behaviour.
24184  *
24185  * Sine: 2.32
24186  */
24187
24188
24189 /**
24190  * g_rw_lock_init:
24191  * @rw_lock: an uninitialized #GRWLock
24192  *
24193  * Initializes a #GRWLock so that it can be used.
24194  *
24195  * This function is useful to initialize a lock that has been
24196  * allocated on the stack, or as part of a larger structure.  It is not
24197  * necessary to initialise a reader-writer lock that has been statically
24198  * allocated.
24199  *
24200  * |[
24201  *   typedef struct {
24202  *     GRWLock l;
24203  *     ...
24204  *   } Blob;
24205  *
24206  * Blob *b;
24207  *
24208  * b = g_new (Blob, 1);
24209  * g_rw_lock_init (&b->l);
24210  * ]|
24211  *
24212  * To undo the effect of g_rw_lock_init() when a lock is no longer
24213  * needed, use g_rw_lock_clear().
24214  *
24215  * Calling g_rw_lock_init() on an already initialized #GRWLock leads
24216  * to undefined behaviour.
24217  *
24218  * Since: 2.32
24219  */
24220
24221
24222 /**
24223  * g_rw_lock_reader_lock:
24224  * @rw_lock: a #GRWLock
24225  *
24226  * Obtain a read lock on @rw_lock. If another thread currently holds
24227  * the write lock on @rw_lock or blocks waiting for it, the current
24228  * thread will block. Read locks can be taken recursively.
24229  *
24230  * It is implementation-defined how many threads are allowed to
24231  * hold read locks on the same lock simultaneously.
24232  *
24233  * Since: 2.32
24234  */
24235
24236
24237 /**
24238  * g_rw_lock_reader_trylock:
24239  * @rw_lock: a #GRWLock
24240  *
24241  * Tries to obtain a read lock on @rw_lock and returns %TRUE if
24242  * the read lock was successfully obtained. Otherwise it
24243  * returns %FALSE.
24244  *
24245  * Returns: %TRUE if @rw_lock could be locked
24246  * Since: 2.32
24247  */
24248
24249
24250 /**
24251  * g_rw_lock_reader_unlock:
24252  * @rw_lock: a #GRWLock
24253  *
24254  * Release a read lock on @rw_lock.
24255  *
24256  * Calling g_rw_lock_reader_unlock() on a lock that is not held
24257  * by the current thread leads to undefined behaviour.
24258  *
24259  * Since: 2.32
24260  */
24261
24262
24263 /**
24264  * g_rw_lock_writer_lock:
24265  * @rw_lock: a #GRWLock
24266  *
24267  * Obtain a write lock on @rw_lock. If any thread already holds
24268  * a read or write lock on @rw_lock, the current thread will block
24269  * until all other threads have dropped their locks on @rw_lock.
24270  *
24271  * Since: 2.32
24272  */
24273
24274
24275 /**
24276  * g_rw_lock_writer_trylock:
24277  * @rw_lock: a #GRWLock
24278  *
24279  * Tries to obtain a write lock on @rw_lock. If any other thread holds
24280  * a read or write lock on @rw_lock, it immediately returns %FALSE.
24281  * Otherwise it locks @rw_lock and returns %TRUE.
24282  *
24283  * Returns: %TRUE if @rw_lock could be locked
24284  * Since: 2.32
24285  */
24286
24287
24288 /**
24289  * g_rw_lock_writer_unlock:
24290  * @rw_lock: a #GRWLock
24291  *
24292  * Release a write lock on @rw_lock.
24293  *
24294  * Calling g_rw_lock_writer_unlock() on a lock that is not held
24295  * by the current thread leads to undefined behaviour.
24296  *
24297  * Since: 2.32
24298  */
24299
24300
24301 /**
24302  * g_scanner_add_symbol:
24303  * @scanner: a #GScanner
24304  * @symbol: the symbol to add
24305  * @value: the value of the symbol
24306  *
24307  * Adds a symbol to the default scope.
24308  *
24309  * Deprecated: 2.2: Use g_scanner_scope_add_symbol() instead.
24310  */
24311
24312
24313 /**
24314  * g_scanner_cur_line:
24315  * @scanner: a #GScanner
24316  *
24317  * Returns the current line in the input stream (counting
24318  * from 1). This is the line of the last token parsed via
24319  * g_scanner_get_next_token().
24320  *
24321  * Returns: the current line
24322  */
24323
24324
24325 /**
24326  * g_scanner_cur_position:
24327  * @scanner: a #GScanner
24328  *
24329  * Returns the current position in the current line (counting
24330  * from 0). This is the position of the last token parsed via
24331  * g_scanner_get_next_token().
24332  *
24333  * Returns: the current position on the line
24334  */
24335
24336
24337 /**
24338  * g_scanner_cur_token:
24339  * @scanner: a #GScanner
24340  *
24341  * Gets the current token type. This is simply the @token
24342  * field in the #GScanner structure.
24343  *
24344  * Returns: the current token type
24345  */
24346
24347
24348 /**
24349  * g_scanner_cur_value:
24350  * @scanner: a #GScanner
24351  *
24352  * Gets the current token value. This is simply the @value
24353  * field in the #GScanner structure.
24354  *
24355  * Returns: the current token value
24356  */
24357
24358
24359 /**
24360  * g_scanner_destroy:
24361  * @scanner: a #GScanner
24362  *
24363  * Frees all memory used by the #GScanner.
24364  */
24365
24366
24367 /**
24368  * g_scanner_eof:
24369  * @scanner: a #GScanner
24370  *
24371  * Returns %TRUE if the scanner has reached the end of
24372  * the file or text buffer.
24373  *
24374  * Returns: %TRUE if the scanner has reached the end of
24375  *     the file or text buffer
24376  */
24377
24378
24379 /**
24380  * g_scanner_error:
24381  * @scanner: a #GScanner
24382  * @format: the message format. See the printf() documentation
24383  * @...: the parameters to insert into the format string
24384  *
24385  * Outputs an error message, via the #GScanner message handler.
24386  */
24387
24388
24389 /**
24390  * g_scanner_foreach_symbol:
24391  * @scanner: a #GScanner
24392  * @func: the function to call with each symbol
24393  * @data: data to pass to the function
24394  *
24395  * Calls a function for each symbol in the default scope.
24396  *
24397  * Deprecated: 2.2: Use g_scanner_scope_foreach_symbol() instead.
24398  */
24399
24400
24401 /**
24402  * g_scanner_freeze_symbol_table:
24403  * @scanner: a #GScanner
24404  *
24405  * There is no reason to use this macro, since it does nothing.
24406  *
24407  * Deprecated: 2.2: This macro does nothing.
24408  */
24409
24410
24411 /**
24412  * g_scanner_get_next_token:
24413  * @scanner: a #GScanner
24414  *
24415  * Parses the next token just like g_scanner_peek_next_token()
24416  * and also removes it from the input stream. The token data is
24417  * placed in the @token, @value, @line, and @position fields of
24418  * the #GScanner structure.
24419  *
24420  * Returns: the type of the token
24421  */
24422
24423
24424 /**
24425  * g_scanner_input_file:
24426  * @scanner: a #GScanner
24427  * @input_fd: a file descriptor
24428  *
24429  * Prepares to scan a file.
24430  */
24431
24432
24433 /**
24434  * g_scanner_input_text:
24435  * @scanner: a #GScanner
24436  * @text: the text buffer to scan
24437  * @text_len: the length of the text buffer
24438  *
24439  * Prepares to scan a text buffer.
24440  */
24441
24442
24443 /**
24444  * g_scanner_lookup_symbol:
24445  * @scanner: a #GScanner
24446  * @symbol: the symbol to look up
24447  *
24448  * Looks up a symbol in the current scope and return its value.
24449  * If the symbol is not bound in the current scope, %NULL is
24450  * returned.
24451  *
24452  * Returns: the value of @symbol in the current scope, or %NULL
24453  *     if @symbol is not bound in the current scope
24454  */
24455
24456
24457 /**
24458  * g_scanner_new:
24459  * @config_templ: the initial scanner settings
24460  *
24461  * Creates a new #GScanner.
24462  *
24463  * The @config_templ structure specifies the initial settings
24464  * of the scanner, which are copied into the #GScanner
24465  * @config field. If you pass %NULL then the default settings
24466  * are used.
24467  *
24468  * Returns: the new #GScanner
24469  */
24470
24471
24472 /**
24473  * g_scanner_peek_next_token:
24474  * @scanner: a #GScanner
24475  *
24476  * Parses the next token, without removing it from the input stream.
24477  * The token data is placed in the @next_token, @next_value, @next_line,
24478  * and @next_position fields of the #GScanner structure.
24479  *
24480  * Note that, while the token is not removed from the input stream
24481  * (i.e. the next call to g_scanner_get_next_token() will return the
24482  * same token), it will not be reevaluated. This can lead to surprising
24483  * results when changing scope or the scanner configuration after peeking
24484  * the next token. Getting the next token after switching the scope or
24485  * configuration will return whatever was peeked before, regardless of
24486  * any symbols that may have been added or removed in the new scope.
24487  *
24488  * Returns: the type of the token
24489  */
24490
24491
24492 /**
24493  * g_scanner_remove_symbol:
24494  * @scanner: a #GScanner
24495  * @symbol: the symbol to remove
24496  *
24497  * Removes a symbol from the default scope.
24498  *
24499  * Deprecated: 2.2: Use g_scanner_scope_remove_symbol() instead.
24500  */
24501
24502
24503 /**
24504  * g_scanner_scope_add_symbol:
24505  * @scanner: a #GScanner
24506  * @scope_id: the scope id
24507  * @symbol: the symbol to add
24508  * @value: the value of the symbol
24509  *
24510  * Adds a symbol to the given scope.
24511  */
24512
24513
24514 /**
24515  * g_scanner_scope_foreach_symbol:
24516  * @scanner: a #GScanner
24517  * @scope_id: the scope id
24518  * @func: the function to call for each symbol/value pair
24519  * @user_data: user data to pass to the function
24520  *
24521  * Calls the given function for each of the symbol/value pairs
24522  * in the given scope of the #GScanner. The function is passed
24523  * the symbol and value of each pair, and the given @user_data
24524  * parameter.
24525  */
24526
24527
24528 /**
24529  * g_scanner_scope_lookup_symbol:
24530  * @scanner: a #GScanner
24531  * @scope_id: the scope id
24532  * @symbol: the symbol to look up
24533  *
24534  * Looks up a symbol in a scope and return its value. If the
24535  * symbol is not bound in the scope, %NULL is returned.
24536  *
24537  * Returns: the value of @symbol in the given scope, or %NULL
24538  *     if @symbol is not bound in the given scope.
24539  */
24540
24541
24542 /**
24543  * g_scanner_scope_remove_symbol:
24544  * @scanner: a #GScanner
24545  * @scope_id: the scope id
24546  * @symbol: the symbol to remove
24547  *
24548  * Removes a symbol from a scope.
24549  */
24550
24551
24552 /**
24553  * g_scanner_set_scope:
24554  * @scanner: a #GScanner
24555  * @scope_id: the new scope id
24556  *
24557  * Sets the current scope.
24558  *
24559  * Returns: the old scope id
24560  */
24561
24562
24563 /**
24564  * g_scanner_sync_file_offset:
24565  * @scanner: a #GScanner
24566  *
24567  * Rewinds the filedescriptor to the current buffer position
24568  * and blows the file read ahead buffer. This is useful for
24569  * third party uses of the scanners filedescriptor, which hooks
24570  * onto the current scanning position.
24571  */
24572
24573
24574 /**
24575  * g_scanner_thaw_symbol_table:
24576  * @scanner: a #GScanner
24577  *
24578  * There is no reason to use this macro, since it does nothing.
24579  *
24580  * Deprecated: 2.2: This macro does nothing.
24581  */
24582
24583
24584 /**
24585  * g_scanner_unexp_token:
24586  * @scanner: a #GScanner
24587  * @expected_token: the expected token
24588  * @identifier_spec: a string describing how the scanner's user
24589  *     refers to identifiers (%NULL defaults to "identifier").
24590  *     This is used if @expected_token is %G_TOKEN_IDENTIFIER or
24591  *     %G_TOKEN_IDENTIFIER_NULL.
24592  * @symbol_spec: a string describing how the scanner's user refers
24593  *     to symbols (%NULL defaults to "symbol"). This is used if
24594  *     @expected_token is %G_TOKEN_SYMBOL or any token value greater
24595  *     than %G_TOKEN_LAST.
24596  * @symbol_name: the name of the symbol, if the scanner's current
24597  *     token is a symbol.
24598  * @message: a message string to output at the end of the
24599  *     warning/error, or %NULL.
24600  * @is_error: if %TRUE it is output as an error. If %FALSE it is
24601  *     output as a warning.
24602  *
24603  * Outputs a message through the scanner's msg_handler,
24604  * resulting from an unexpected token in the input stream.
24605  * Note that you should not call g_scanner_peek_next_token()
24606  * followed by g_scanner_unexp_token() without an intermediate
24607  * call to g_scanner_get_next_token(), as g_scanner_unexp_token()
24608  * evaluates the scanner's current token (not the peeked token)
24609  * to construct part of the message.
24610  */
24611
24612
24613 /**
24614  * g_scanner_warn:
24615  * @scanner: a #GScanner
24616  * @format: the message format. See the printf() documentation
24617  * @...: the parameters to insert into the format string
24618  *
24619  * Outputs a warning message, via the #GScanner message handler.
24620  */
24621
24622
24623 /**
24624  * g_sequence_append:
24625  * @seq: a #GSequence
24626  * @data: the data for the new item
24627  *
24628  * Adds a new item to the end of @seq.
24629  *
24630  * Returns: an iterator pointing to the new item
24631  * Since: 2.14
24632  */
24633
24634
24635 /**
24636  * g_sequence_foreach:
24637  * @seq: a #GSequence
24638  * @func: the function to call for each item in @seq
24639  * @user_data: user data passed to @func
24640  *
24641  * Calls @func for each item in the sequence passing @user_data
24642  * to the function.
24643  *
24644  * Since: 2.14
24645  */
24646
24647
24648 /**
24649  * g_sequence_foreach_range:
24650  * @begin: a #GSequenceIter
24651  * @end: a #GSequenceIter
24652  * @func: a #GFunc
24653  * @user_data: user data passed to @func
24654  *
24655  * Calls @func for each item in the range (@begin, @end) passing
24656  * @user_data to the function.
24657  *
24658  * Since: 2.14
24659  */
24660
24661
24662 /**
24663  * g_sequence_free:
24664  * @seq: a #GSequence
24665  *
24666  * Frees the memory allocated for @seq. If @seq has a data destroy
24667  * function associated with it, that function is called on all items in
24668  * @seq.
24669  *
24670  * Since: 2.14
24671  */
24672
24673
24674 /**
24675  * g_sequence_get:
24676  * @iter: a #GSequenceIter
24677  *
24678  * Returns the data that @iter points to.
24679  *
24680  * Returns: the data that @iter points to
24681  * Since: 2.14
24682  */
24683
24684
24685 /**
24686  * g_sequence_get_begin_iter:
24687  * @seq: a #GSequence
24688  *
24689  * Returns the begin iterator for @seq.
24690  *
24691  * Returns: the begin iterator for @seq.
24692  * Since: 2.14
24693  */
24694
24695
24696 /**
24697  * g_sequence_get_end_iter:
24698  * @seq: a #GSequence
24699  *
24700  * Returns the end iterator for @seg
24701  *
24702  * Returns: the end iterator for @seq
24703  * Since: 2.14
24704  */
24705
24706
24707 /**
24708  * g_sequence_get_iter_at_pos:
24709  * @seq: a #GSequence
24710  * @pos: a position in @seq, or -1 for the end.
24711  *
24712  * Returns the iterator at position @pos. If @pos is negative or larger
24713  * than the number of items in @seq, the end iterator is returned.
24714  *
24715  * Returns: The #GSequenceIter at position @pos
24716  * Since: 2.14
24717  */
24718
24719
24720 /**
24721  * g_sequence_get_length:
24722  * @seq: a #GSequence
24723  *
24724  * Returns the length of @seq
24725  *
24726  * Returns: the length of @seq
24727  * Since: 2.14
24728  */
24729
24730
24731 /**
24732  * g_sequence_insert_before:
24733  * @iter: a #GSequenceIter
24734  * @data: the data for the new item
24735  *
24736  * Inserts a new item just before the item pointed to by @iter.
24737  *
24738  * Returns: an iterator pointing to the new item
24739  * Since: 2.14
24740  */
24741
24742
24743 /**
24744  * g_sequence_insert_sorted:
24745  * @seq: a #GSequence
24746  * @data: the data to insert
24747  * @cmp_func: the function used to compare items in the sequence
24748  * @cmp_data: user data passed to @cmp_func.
24749  *
24750  * Inserts @data into @sequence using @func to determine the new
24751  * position. The sequence must already be sorted according to @cmp_func;
24752  * otherwise the new position of @data is undefined.
24753  *
24754  * @cmp_func is called with two items of the @seq and @user_data.
24755  * It should return 0 if the items are equal, a negative value
24756  * if the first item comes before the second, and a positive value
24757  * if the second  item comes before the first.
24758  *
24759  * Returns: a #GSequenceIter pointing to the new item.
24760  * Since: 2.14
24761  */
24762
24763
24764 /**
24765  * g_sequence_insert_sorted_iter:
24766  * @seq: a #GSequence
24767  * @data: data for the new item
24768  * @iter_cmp: the function used to compare iterators in the sequence
24769  * @cmp_data: user data passed to @cmp_func
24770  *
24771  * Like g_sequence_insert_sorted(), but uses
24772  * a #GSequenceIterCompareFunc instead of a #GCompareDataFunc as
24773  * the compare function.
24774  *
24775  * @iter_cmp is called with two iterators pointing into @seq.
24776  * It should return 0 if the iterators are equal, a negative
24777  * value if the first iterator comes before the second, and a
24778  * positive value if the second iterator comes before the first.
24779  *
24780  * It is called with two iterators pointing into @seq. It should
24781  * return 0 if the iterators are equal, a negative value if the
24782  * first iterator comes before the second, and a positive value
24783  * if the second iterator comes before the first.
24784  *
24785  * Returns: a #GSequenceIter pointing to the new item
24786  * Since: 2.14
24787  */
24788
24789
24790 /**
24791  * g_sequence_iter_compare:
24792  * @a: a #GSequenceIter
24793  * @b: a #GSequenceIter
24794  *
24795  * Returns a negative number if @a comes before @b, 0 if they are equal,
24796  * and a positive number if @a comes after @b.
24797  *
24798  * The @a and @b iterators must point into the same sequence.
24799  *
24800  * Returns: A negative number if @a comes before @b, 0 if they are
24801  * equal, and a positive number if @a comes after @b.
24802  * Since: 2.14
24803  */
24804
24805
24806 /**
24807  * g_sequence_iter_get_position:
24808  * @iter: a #GSequenceIter
24809  *
24810  * Returns the position of @iter
24811  *
24812  * Returns: the position of @iter
24813  * Since: 2.14
24814  */
24815
24816
24817 /**
24818  * g_sequence_iter_get_sequence:
24819  * @iter: a #GSequenceIter
24820  *
24821  * Returns the #GSequence that @iter points into.
24822  *
24823  * Returns: the #GSequence that @iter points into.
24824  * Since: 2.14
24825  */
24826
24827
24828 /**
24829  * g_sequence_iter_is_begin:
24830  * @iter: a #GSequenceIter
24831  *
24832  * Returns whether @iter is the begin iterator
24833  *
24834  * Returns: whether @iter is the begin iterator
24835  * Since: 2.14
24836  */
24837
24838
24839 /**
24840  * g_sequence_iter_is_end:
24841  * @iter: a #GSequenceIter
24842  *
24843  * Returns whether @iter is the end iterator
24844  *
24845  * Returns: Whether @iter is the end iterator.
24846  * Since: 2.14
24847  */
24848
24849
24850 /**
24851  * g_sequence_iter_move:
24852  * @iter: a #GSequenceIter
24853  * @delta: A positive or negative number indicating how many positions away
24854  *    from @iter the returned #GSequenceIter will be.
24855  *
24856  * Returns the #GSequenceIter which is @delta positions away from @iter.
24857  * If @iter is closer than -@delta positions to the beginning of the sequence,
24858  * the begin iterator is returned. If @iter is closer than @delta positions
24859  * to the end of the sequence, the end iterator is returned.
24860  *
24861  * Returns: a #GSequenceIter which is @delta positions away from @iter.
24862  * Since: 2.14
24863  */
24864
24865
24866 /**
24867  * g_sequence_iter_next:
24868  * @iter: a #GSequenceIter
24869  *
24870  * Returns an iterator pointing to the next position after @iter. If
24871  * @iter is the end iterator, the end iterator is returned.
24872  *
24873  * Returns: a #GSequenceIter pointing to the next position after @iter.
24874  * Since: 2.14
24875  */
24876
24877
24878 /**
24879  * g_sequence_iter_prev:
24880  * @iter: a #GSequenceIter
24881  *
24882  * Returns an iterator pointing to the previous position before @iter. If
24883  * @iter is the begin iterator, the begin iterator is returned.
24884  *
24885  * Returns: a #GSequenceIter pointing to the previous position before
24886  * @iter.
24887  * Since: 2.14
24888  */
24889
24890
24891 /**
24892  * g_sequence_lookup:
24893  * @seq: a #GSequence
24894  * @data: data to lookup
24895  * @cmp_func: the function used to compare items in the sequence
24896  * @cmp_data: user data passed to @cmp_func.
24897  *
24898  * Returns an iterator pointing to the position of the first item found
24899  * equal to @data according to @cmp_func and @cmp_data. If more than one
24900  * item is equal, it is not guaranteed that it is the first which is
24901  * returned. In that case, you can use g_sequence_iter_next() and
24902  * g_sequence_iter_prev() to get others.
24903  *
24904  * @cmp_func is called with two items of the @seq and @user_data.
24905  * It should return 0 if the items are equal, a negative value if
24906  * the first item comes before the second, and a positive value if
24907  * the second item comes before the first.
24908  *
24909  * <note><para>
24910  * This function will fail if the data contained in the sequence is
24911  * unsorted.  Use g_sequence_insert_sorted() or
24912  * g_sequence_insert_sorted_iter() to add data to your sequence or, if
24913  * you want to add a large amount of data, call g_sequence_sort() after
24914  * doing unsorted insertions.
24915  * </para></note>
24916  *
24917  * Returns: an #GSequenceIter pointing to the position of the
24918  *     first item found equal to @data according to @cmp_func and
24919  *     @cmp_data, or %NULL if no such item exists.
24920  * Since: 2.28
24921  */
24922
24923
24924 /**
24925  * g_sequence_lookup_iter:
24926  * @seq: a #GSequence
24927  * @data: data to lookup
24928  * @iter_cmp: the function used to compare iterators in the sequence
24929  * @cmp_data: user data passed to @iter_cmp
24930  *
24931  * Like g_sequence_lookup(), but uses a #GSequenceIterCompareFunc
24932  * instead of a #GCompareDataFunc as the compare function.
24933  *
24934  * @iter_cmp is called with two iterators pointing into @seq.
24935  * It should return 0 if the iterators are equal, a negative value
24936  * if the first iterator comes before the second, and a positive
24937  * value if the second iterator comes before the first.
24938  *
24939  * <note><para>
24940  * This function will fail if the data contained in the sequence is
24941  * unsorted.  Use g_sequence_insert_sorted() or
24942  * g_sequence_insert_sorted_iter() to add data to your sequence or, if
24943  * you want to add a large amount of data, call g_sequence_sort() after
24944  * doing unsorted insertions.
24945  * </para></note>
24946  *
24947  * Returns: an #GSequenceIter pointing to the position of
24948  *     the first item found equal to @data according to @cmp_func
24949  *     and @cmp_data, or %NULL if no such item exists.
24950  * Since: 2.28
24951  */
24952
24953
24954 /**
24955  * g_sequence_move:
24956  * @src: a #GSequenceIter pointing to the item to move
24957  * @dest: a #GSequenceIter pointing to the position to which
24958  *        the item is moved.
24959  *
24960  * Moves the item pointed to by @src to the position indicated by @dest.
24961  * After calling this function @dest will point to the position immediately
24962  * after @src. It is allowed for @src and @dest to point into different
24963  * sequences.
24964  *
24965  * Since: 2.14
24966  */
24967
24968
24969 /**
24970  * g_sequence_move_range:
24971  * @dest: a #GSequenceIter
24972  * @begin: a #GSequenceIter
24973  * @end: a #GSequenceIter
24974  *
24975  * Inserts the (@begin, @end) range at the destination pointed to by ptr.
24976  * The @begin and @end iters must point into the same sequence. It is
24977  * allowed for @dest to point to a different sequence than the one pointed
24978  * into by @begin and @end.
24979  *
24980  * If @dest is NULL, the range indicated by @begin and @end is
24981  * removed from the sequence. If @dest iter points to a place within
24982  * the (@begin, @end) range, the range does not move.
24983  *
24984  * Since: 2.14
24985  */
24986
24987
24988 /**
24989  * g_sequence_new:
24990  * @data_destroy: (allow-none): a #GDestroyNotify function, or %NULL
24991  *
24992  * Creates a new GSequence. The @data_destroy function, if non-%NULL will
24993  * be called on all items when the sequence is destroyed and on items that
24994  * are removed from the sequence.
24995  *
24996  * Returns: a new #GSequence
24997  * Since: 2.14
24998  */
24999
25000
25001 /**
25002  * g_sequence_prepend:
25003  * @seq: a #GSequence
25004  * @data: the data for the new item
25005  *
25006  * Adds a new item to the front of @seq
25007  *
25008  * Returns: an iterator pointing to the new item
25009  * Since: 2.14
25010  */
25011
25012
25013 /**
25014  * g_sequence_range_get_midpoint:
25015  * @begin: a #GSequenceIter
25016  * @end: a #GSequenceIter
25017  *
25018  * Finds an iterator somewhere in the range (@begin, @end). This
25019  * iterator will be close to the middle of the range, but is not
25020  * guaranteed to be <emphasis>exactly</emphasis> in the middle.
25021  *
25022  * The @begin and @end iterators must both point to the same sequence and
25023  * @begin must come before or be equal to @end in the sequence.
25024  *
25025  * Returns: A #GSequenceIter pointing somewhere in the
25026  * (@begin, @end) range.
25027  * Since: 2.14
25028  */
25029
25030
25031 /**
25032  * g_sequence_remove:
25033  * @iter: a #GSequenceIter
25034  *
25035  * Removes the item pointed to by @iter. It is an error to pass the
25036  * end iterator to this function.
25037  *
25038  * If the sequence has a data destroy function associated with it, this
25039  * function is called on the data for the removed item.
25040  *
25041  * Since: 2.14
25042  */
25043
25044
25045 /**
25046  * g_sequence_remove_range:
25047  * @begin: a #GSequenceIter
25048  * @end: a #GSequenceIter
25049  *
25050  * Removes all items in the (@begin, @end) range.
25051  *
25052  * If the sequence has a data destroy function associated with it, this
25053  * function is called on the data for the removed items.
25054  *
25055  * Since: 2.14
25056  */
25057
25058
25059 /**
25060  * g_sequence_search:
25061  * @seq: a #GSequence
25062  * @data: data for the new item
25063  * @cmp_func: the function used to compare items in the sequence
25064  * @cmp_data: user data passed to @cmp_func.
25065  *
25066  * Returns an iterator pointing to the position where @data would
25067  * be inserted according to @cmp_func and @cmp_data.
25068  *
25069  * @cmp_func is called with two items of the @seq and @user_data.
25070  * It should return 0 if the items are equal, a negative value if
25071  * the first item comes before the second, and a positive value if
25072  * the second item comes before the first.
25073  *
25074  * If you are simply searching for an existing element of the sequence,
25075  * consider using g_sequence_lookup().
25076  *
25077  * <note><para>
25078  * This function will fail if the data contained in the sequence is
25079  * unsorted.  Use g_sequence_insert_sorted() or
25080  * g_sequence_insert_sorted_iter() to add data to your sequence or, if
25081  * you want to add a large amount of data, call g_sequence_sort() after
25082  * doing unsorted insertions.
25083  * </para></note>
25084  *
25085  * Returns: an #GSequenceIter pointing to the position where @data
25086  * would have been inserted according to @cmp_func and @cmp_data.
25087  * Since: 2.14
25088  */
25089
25090
25091 /**
25092  * g_sequence_search_iter:
25093  * @seq: a #GSequence
25094  * @data: data for the new item
25095  * @iter_cmp: the function used to compare iterators in the sequence
25096  * @cmp_data: user data passed to @iter_cmp
25097  *
25098  * Like g_sequence_search(), but uses a #GSequenceIterCompareFunc
25099  * instead of a #GCompareDataFunc as the compare function.
25100  *
25101  * @iter_cmp is called with two iterators pointing into @seq.
25102  * It should return 0 if the iterators are equal, a negative value
25103  * if the first iterator comes before the second, and a positive
25104  * value if the second iterator comes before the first.
25105  *
25106  * If you are simply searching for an existing element of the sequence,
25107  * consider using g_sequence_lookup_iter().
25108  *
25109  * <note><para>
25110  * This function will fail if the data contained in the sequence is
25111  * unsorted.  Use g_sequence_insert_sorted() or
25112  * g_sequence_insert_sorted_iter() to add data to your sequence or, if
25113  * you want to add a large amount of data, call g_sequence_sort() after
25114  * doing unsorted insertions.
25115  * </para></note>
25116  *
25117  * Returns: a #GSequenceIter pointing to the position in @seq
25118  *     where @data would have been inserted according to @iter_cmp
25119  *     and @cmp_data.
25120  * Since: 2.14
25121  */
25122
25123
25124 /**
25125  * g_sequence_set:
25126  * @iter: a #GSequenceIter
25127  * @data: new data for the item
25128  *
25129  * Changes the data for the item pointed to by @iter to be @data. If
25130  * the sequence has a data destroy function associated with it, that
25131  * function is called on the existing data that @iter pointed to.
25132  *
25133  * Since: 2.14
25134  */
25135
25136
25137 /**
25138  * g_sequence_sort:
25139  * @seq: a #GSequence
25140  * @cmp_func: the function used to sort the sequence
25141  * @cmp_data: user data passed to @cmp_func
25142  *
25143  * Sorts @seq using @cmp_func.
25144  *
25145  * @cmp_func is passed two items of @seq and should
25146  * return 0 if they are equal, a negative value if the
25147  * first comes before the second, and a positive value
25148  * if the second comes before the first.
25149  *
25150  * Since: 2.14
25151  */
25152
25153
25154 /**
25155  * g_sequence_sort_changed:
25156  * @iter: A #GSequenceIter
25157  * @cmp_func: the function used to compare items in the sequence
25158  * @cmp_data: user data passed to @cmp_func.
25159  *
25160  * Moves the data pointed to a new position as indicated by @cmp_func. This
25161  * function should be called for items in a sequence already sorted according
25162  * to @cmp_func whenever some aspect of an item changes so that @cmp_func
25163  * may return different values for that item.
25164  *
25165  * @cmp_func is called with two items of the @seq and @user_data.
25166  * It should return 0 if the items are equal, a negative value if
25167  * the first item comes before the second, and a positive value if
25168  * the second item comes before the first.
25169  *
25170  * Since: 2.14
25171  */
25172
25173
25174 /**
25175  * g_sequence_sort_changed_iter:
25176  * @iter: a #GSequenceIter
25177  * @iter_cmp: the function used to compare iterators in the sequence
25178  * @cmp_data: user data passed to @cmp_func
25179  *
25180  * Like g_sequence_sort_changed(), but uses
25181  * a #GSequenceIterCompareFunc instead of a #GCompareDataFunc as
25182  * the compare function.
25183  *
25184  * @iter_cmp is called with two iterators pointing into @seq. It should
25185  * return 0 if the iterators are equal, a negative value if the first
25186  * iterator comes before the second, and a positive value if the second
25187  * iterator comes before the first.
25188  *
25189  * Since: 2.14
25190  */
25191
25192
25193 /**
25194  * g_sequence_sort_iter:
25195  * @seq: a #GSequence
25196  * @cmp_func: the function used to compare iterators in the sequence
25197  * @cmp_data: user data passed to @cmp_func
25198  *
25199  * Like g_sequence_sort(), but uses a #GSequenceIterCompareFunc instead
25200  * of a GCompareDataFunc as the compare function
25201  *
25202  * @cmp_func is called with two iterators pointing into @seq. It should
25203  * return 0 if the iterators are equal, a negative value if the first
25204  * iterator comes before the second, and a positive value if the second
25205  * iterator comes before the first.
25206  *
25207  * Since: 2.14
25208  */
25209
25210
25211 /**
25212  * g_sequence_swap:
25213  * @a: a #GSequenceIter
25214  * @b: a #GSequenceIter
25215  *
25216  * Swaps the items pointed to by @a and @b. It is allowed for @a and @b
25217  * to point into difference sequences.
25218  *
25219  * Since: 2.14
25220  */
25221
25222
25223 /**
25224  * g_set_application_name:
25225  * @application_name: localized name of the application
25226  *
25227  * Sets a human-readable name for the application. This name should be
25228  * localized if possible, and is intended for display to the user.
25229  * Contrast with g_set_prgname(), which sets a non-localized name.
25230  * g_set_prgname() will be called automatically by gtk_init(),
25231  * but g_set_application_name() will not.
25232  *
25233  * Note that for thread safety reasons, this function can only
25234  * be called once.
25235  *
25236  * The application name will be used in contexts such as error messages,
25237  * or when displaying an application's name in the task list.
25238  *
25239  * Since: 2.2
25240  */
25241
25242
25243 /**
25244  * g_set_error:
25245  * @err: (allow-none): a return location for a #GError, or %NULL
25246  * @domain: error domain
25247  * @code: error code
25248  * @format: printf()-style format
25249  * @...: args for @format
25250  *
25251  * Does nothing if @err is %NULL; if @err is non-%NULL, then *@err
25252  * must be %NULL. A new #GError is created and assigned to *@err.
25253  */
25254
25255
25256 /**
25257  * g_set_error_literal:
25258  * @err: (allow-none): a return location for a #GError, or %NULL
25259  * @domain: error domain
25260  * @code: error code
25261  * @message: error message
25262  *
25263  * Does nothing if @err is %NULL; if @err is non-%NULL, then *@err
25264  * must be %NULL. A new #GError is created and assigned to *@err.
25265  * Unlike g_set_error(), @message is not a printf()-style format string.
25266  * Use this function if @message contains text you don't have control over,
25267  * that could include printf() escape sequences.
25268  *
25269  * Since: 2.18
25270  */
25271
25272
25273 /**
25274  * g_set_prgname:
25275  * @prgname: the name of the program.
25276  *
25277  * Sets the name of the program. This name should <emphasis>not</emphasis>
25278  * be localized, contrast with g_set_application_name(). Note that for
25279  * thread-safety reasons this function can only be called once.
25280  */
25281
25282
25283 /**
25284  * g_set_print_handler:
25285  * @func: the new print handler
25286  *
25287  * Sets the print handler.
25288  *
25289  * Any messages passed to g_print() will be output via
25290  * the new handler. The default handler simply outputs
25291  * the message to stdout. By providing your own handler
25292  * you can redirect the output, to a GTK+ widget or a
25293  * log file for example.
25294  *
25295  * Returns: the old print handler
25296  */
25297
25298
25299 /**
25300  * g_set_printerr_handler:
25301  * @func: the new error message handler
25302  *
25303  * Sets the handler for printing error messages.
25304  *
25305  * Any messages passed to g_printerr() will be output via
25306  * the new handler. The default handler simply outputs the
25307  * message to stderr. By providing your own handler you can
25308  * redirect the output, to a GTK+ widget or a log file for
25309  * example.
25310  *
25311  * Returns: the old error message handler
25312  */
25313
25314
25315 /**
25316  * g_setenv:
25317  * @variable: the environment variable to set, must not contain '='.
25318  * @value: the value for to set the variable to.
25319  * @overwrite: whether to change the variable if it already exists.
25320  *
25321  * Sets an environment variable. Both the variable's name and value
25322  * should be in the GLib file name encoding. On UNIX, this means that
25323  * they can be arbitrary byte strings. On Windows, they should be in
25324  * UTF-8.
25325  *
25326  * Note that on some systems, when variables are overwritten, the memory
25327  * used for the previous variables and its value isn't reclaimed.
25328  *
25329  * <warning><para>
25330  * Environment variable handling in UNIX is not thread-safe, and your
25331  * program may crash if one thread calls g_setenv() while another
25332  * thread is calling getenv(). (And note that many functions, such as
25333  * gettext(), call getenv() internally.) This function is only safe to
25334  * use at the very start of your program, before creating any other
25335  * threads (or creating objects that create worker threads of their
25336  * own).
25337  * </para><para>
25338  * If you need to set up the environment for a child process, you can
25339  * use g_get_environ() to get an environment array, modify that with
25340  * g_environ_setenv() and g_environ_unsetenv(), and then pass that
25341  * array directly to execvpe(), g_spawn_async(), or the like.
25342  * </para></warning>
25343  *
25344  * Returns: %FALSE if the environment variable couldn't be set.
25345  * Since: 2.4
25346  */
25347
25348
25349 /**
25350  * g_shell_parse_argv:
25351  * @command_line: command line to parse
25352  * @argcp: (out): return location for number of args
25353  * @argvp: (out) (array length=argcp zero-terminated=1): return location for array of args
25354  * @error: return location for error
25355  *
25356  * Parses a command line into an argument vector, in much the same way
25357  * the shell would, but without many of the expansions the shell would
25358  * perform (variable expansion, globs, operators, filename expansion,
25359  * etc. are not supported). The results are defined to be the same as
25360  * those you would get from a UNIX98 /bin/sh, as long as the input
25361  * contains none of the unsupported shell expansions. If the input
25362  * does contain such expansions, they are passed through
25363  * literally. Possible errors are those from the #G_SHELL_ERROR
25364  * domain. Free the returned vector with g_strfreev().
25365  *
25366  * Returns: %TRUE on success, %FALSE if error set
25367  */
25368
25369
25370 /**
25371  * g_shell_quote:
25372  * @unquoted_string: a literal string
25373  *
25374  * Quotes a string so that the shell (/bin/sh) will interpret the
25375  * quoted string to mean @unquoted_string. If you pass a filename to
25376  * the shell, for example, you should first quote it with this
25377  * function.  The return value must be freed with g_free(). The
25378  * quoting style used is undefined (single or double quotes may be
25379  * used).
25380  *
25381  * Returns: quoted string
25382  */
25383
25384
25385 /**
25386  * g_shell_unquote:
25387  * @quoted_string: shell-quoted string
25388  * @error: error return location or NULL
25389  *
25390  * Unquotes a string as the shell (/bin/sh) would. Only handles
25391  * quotes; if a string contains file globs, arithmetic operators,
25392  * variables, backticks, redirections, or other special-to-the-shell
25393  * features, the result will be different from the result a real shell
25394  * would produce (the variables, backticks, etc. will be passed
25395  * through literally instead of being expanded). This function is
25396  * guaranteed to succeed if applied to the result of
25397  * g_shell_quote(). If it fails, it returns %NULL and sets the
25398  * error. The @quoted_string need not actually contain quoted or
25399  * escaped text; g_shell_unquote() simply goes through the string and
25400  * unquotes/unescapes anything that the shell would. Both single and
25401  * double quotes are handled, as are escapes including escaped
25402  * newlines. The return value must be freed with g_free(). Possible
25403  * errors are in the #G_SHELL_ERROR domain.
25404  *
25405  * Shell quoting rules are a bit strange. Single quotes preserve the
25406  * literal string exactly. escape sequences are not allowed; not even
25407  * \' - if you want a ' in the quoted text, you have to do something
25408  * like 'foo'\''bar'.  Double quotes allow $, `, ", \, and newline to
25409  * be escaped with backslash. Otherwise double quotes preserve things
25410  * literally.
25411  *
25412  * Returns: an unquoted string
25413  */
25414
25415
25416 /**
25417  * g_slice_alloc:
25418  * @block_size: the number of bytes to allocate
25419  *
25420  * Allocates a block of memory from the slice allocator.
25421  * The block adress handed out can be expected to be aligned
25422  * to at least <literal>1 * sizeof (void*)</literal>,
25423  * though in general slices are 2 * sizeof (void*) bytes aligned,
25424  * if a malloc() fallback implementation is used instead,
25425  * the alignment may be reduced in a libc dependent fashion.
25426  * Note that the underlying slice allocation mechanism can
25427  * be changed with the <link linkend="G_SLICE">G_SLICE=always-malloc</link>
25428  * environment variable.
25429  *
25430  * Returns: a pointer to the allocated memory block
25431  * Since: 2.10
25432  */
25433
25434
25435 /**
25436  * g_slice_alloc0:
25437  * @block_size: the number of bytes to allocate
25438  *
25439  * Allocates a block of memory via g_slice_alloc() and initializes
25440  * the returned memory to 0. Note that the underlying slice allocation
25441  * mechanism can be changed with the
25442  * <link linkend="G_SLICE">G_SLICE=always-malloc</link>
25443  * environment variable.
25444  *
25445  * Returns: a pointer to the allocated block
25446  * Since: 2.10
25447  */
25448
25449
25450 /**
25451  * g_slice_copy:
25452  * @block_size: the number of bytes to allocate
25453  * @mem_block: the memory to copy
25454  *
25455  * Allocates a block of memory from the slice allocator
25456  * and copies @block_size bytes into it from @mem_block.
25457  *
25458  * Returns: a pointer to the allocated memory block
25459  * Since: 2.14
25460  */
25461
25462
25463 /**
25464  * g_slice_dup:
25465  * @type: the type to duplicate, typically a structure name
25466  * @mem: the memory to copy into the allocated block
25467  *
25468  * A convenience macro to duplicate a block of memory using
25469  * the slice allocator.
25470  *
25471  * It calls g_slice_copy() with <literal>sizeof (@type)</literal>
25472  * and casts the returned pointer to a pointer of the given type,
25473  * avoiding a type cast in the source code.
25474  * Note that the underlying slice allocation mechanism can
25475  * be changed with the <link linkend="G_SLICE">G_SLICE=always-malloc</link>
25476  * environment variable.
25477  *
25478  * Returns: a pointer to the allocated block, cast to a pointer to @type
25479  * Since: 2.14
25480  */
25481
25482
25483 /**
25484  * g_slice_free:
25485  * @type: the type of the block to free, typically a structure name
25486  * @mem: a pointer to the block to free
25487  *
25488  * A convenience macro to free a block of memory that has
25489  * been allocated from the slice allocator.
25490  *
25491  * It calls g_slice_free1() using <literal>sizeof (type)</literal>
25492  * as the block size.
25493  * Note that the exact release behaviour can be changed with the
25494  * <link linkend="G_DEBUG">G_DEBUG=gc-friendly</link> environment
25495  * variable, also see <link linkend="G_SLICE">G_SLICE</link> for
25496  * related debugging options.
25497  *
25498  * Since: 2.10
25499  */
25500
25501
25502 /**
25503  * g_slice_free1:
25504  * @block_size: the size of the block
25505  * @mem_block: a pointer to the block to free
25506  *
25507  * Frees a block of memory.
25508  *
25509  * The memory must have been allocated via g_slice_alloc() or
25510  * g_slice_alloc0() and the @block_size has to match the size
25511  * specified upon allocation. Note that the exact release behaviour
25512  * can be changed with the
25513  * <link linkend="G_DEBUG">G_DEBUG=gc-friendly</link> environment
25514  * variable, also see <link linkend="G_SLICE">G_SLICE</link> for
25515  * related debugging options.
25516  *
25517  * Since: 2.10
25518  */
25519
25520
25521 /**
25522  * g_slice_free_chain:
25523  * @type: the type of the @mem_chain blocks
25524  * @mem_chain: a pointer to the first block of the chain
25525  * @next: the field name of the next pointer in @type
25526  *
25527  * Frees a linked list of memory blocks of structure type @type.
25528  * The memory blocks must be equal-sized, allocated via
25529  * g_slice_alloc() or g_slice_alloc0() and linked together by
25530  * a @next pointer (similar to #GSList). The name of the
25531  * @next field in @type is passed as third argument.
25532  * Note that the exact release behaviour can be changed with the
25533  * <link linkend="G_DEBUG">G_DEBUG=gc-friendly</link> environment
25534  * variable, also see <link linkend="G_SLICE">G_SLICE</link> for
25535  * related debugging options.
25536  *
25537  * Since: 2.10
25538  */
25539
25540
25541 /**
25542  * g_slice_free_chain_with_offset:
25543  * @block_size: the size of the blocks
25544  * @mem_chain: a pointer to the first block of the chain
25545  * @next_offset: the offset of the @next field in the blocks
25546  *
25547  * Frees a linked list of memory blocks of structure type @type.
25548  *
25549  * The memory blocks must be equal-sized, allocated via
25550  * g_slice_alloc() or g_slice_alloc0() and linked together by a
25551  * @next pointer (similar to #GSList). The offset of the @next
25552  * field in each block is passed as third argument.
25553  * Note that the exact release behaviour can be changed with the
25554  * <link linkend="G_DEBUG">G_DEBUG=gc-friendly</link> environment
25555  * variable, also see <link linkend="G_SLICE">G_SLICE</link> for
25556  * related debugging options.
25557  *
25558  * Since: 2.10
25559  */
25560
25561
25562 /**
25563  * g_slice_new:
25564  * @type: the type to allocate, typically a structure name
25565  *
25566  * A convenience macro to allocate a block of memory from the
25567  * slice allocator.
25568  *
25569  * It calls g_slice_alloc() with <literal>sizeof (@type)</literal>
25570  * and casts the returned pointer to a pointer of the given type,
25571  * avoiding a type cast in the source code.
25572  * Note that the underlying slice allocation mechanism can
25573  * be changed with the <link linkend="G_SLICE">G_SLICE=always-malloc</link>
25574  * environment variable.
25575  *
25576  * Returns: a pointer to the allocated block, cast to a pointer to @type
25577  * Since: 2.10
25578  */
25579
25580
25581 /**
25582  * g_slice_new0:
25583  * @type: the type to allocate, typically a structure name
25584  *
25585  * A convenience macro to allocate a block of memory from the
25586  * slice allocator and set the memory to 0.
25587  *
25588  * It calls g_slice_alloc0() with <literal>sizeof (@type)</literal>
25589  * and casts the returned pointer to a pointer of the given type,
25590  * avoiding a type cast in the source code.
25591  * Note that the underlying slice allocation mechanism can
25592  * be changed with the <link linkend="G_SLICE">G_SLICE=always-malloc</link>
25593  * environment variable.
25594  *
25595  * Since: 2.10
25596  */
25597
25598
25599 /**
25600  * g_slist_alloc:
25601  *
25602  * Allocates space for one #GSList element. It is called by the
25603  * g_slist_append(), g_slist_prepend(), g_slist_insert() and
25604  * g_slist_insert_sorted() functions and so is rarely used on its own.
25605  *
25606  * Returns: a pointer to the newly-allocated #GSList element.
25607  */
25608
25609
25610 /**
25611  * g_slist_append:
25612  * @list: a #GSList
25613  * @data: the data for the new element
25614  *
25615  * Adds a new element on to the end of the list.
25616  *
25617  * <note><para>
25618  * The return value is the new start of the list, which may
25619  * have changed, so make sure you store the new value.
25620  * </para></note>
25621  *
25622  * <note><para>
25623  * Note that g_slist_append() has to traverse the entire list
25624  * to find the end, which is inefficient when adding multiple
25625  * elements. A common idiom to avoid the inefficiency is to prepend
25626  * the elements and reverse the list when all elements have been added.
25627  * </para></note>
25628  *
25629  * |[
25630  * /&ast; Notice that these are initialized to the empty list. &ast;/
25631  * GSList *list = NULL, *number_list = NULL;
25632  *
25633  * /&ast; This is a list of strings. &ast;/
25634  * list = g_slist_append (list, "first");
25635  * list = g_slist_append (list, "second");
25636  *
25637  * /&ast; This is a list of integers. &ast;/
25638  * number_list = g_slist_append (number_list, GINT_TO_POINTER (27));
25639  * number_list = g_slist_append (number_list, GINT_TO_POINTER (14));
25640  * ]|
25641  *
25642  * Returns: the new start of the #GSList
25643  */
25644
25645
25646 /**
25647  * g_slist_concat:
25648  * @list1: a #GSList
25649  * @list2: the #GSList to add to the end of the first #GSList
25650  *
25651  * Adds the second #GSList onto the end of the first #GSList.
25652  * Note that the elements of the second #GSList are not copied.
25653  * They are used directly.
25654  *
25655  * Returns: the start of the new #GSList
25656  */
25657
25658
25659 /**
25660  * g_slist_copy:
25661  * @list: a #GSList
25662  *
25663  * Copies a #GSList.
25664  *
25665  * <note><para>
25666  * Note that this is a "shallow" copy. If the list elements
25667  * consist of pointers to data, the pointers are copied but
25668  * the actual data isn't. See g_slist_copy_deep() if you need
25669  * to copy the data as well.
25670  * </para></note>
25671  *
25672  * Returns: a copy of @list
25673  */
25674
25675
25676 /**
25677  * g_slist_copy_deep:
25678  * @list: a #GSList
25679  * @func: a copy function used to copy every element in the list
25680  * @user_data: user data passed to the copy function @func, or #NULL
25681  *
25682  * Makes a full (deep) copy of a #GSList.
25683  *
25684  * In contrast with g_slist_copy(), this function uses @func to make a copy of
25685  * each list element, in addition to copying the list container itself.
25686  *
25687  * @func, as a #GCopyFunc, takes two arguments, the data to be copied and a user
25688  * pointer. It's safe to pass #NULL as user_data, if the copy function takes only
25689  * one argument.
25690  *
25691  * For instance, if @list holds a list of GObjects, you can do:
25692  * |[
25693  * another_list = g_slist_copy_deep (list, (GCopyFunc) g_object_ref, NULL);
25694  * ]|
25695  *
25696  * And, to entirely free the new list, you could do:
25697  * |[
25698  * g_slist_free_full (another_list, g_object_unref);
25699  * ]|
25700  *
25701  * Returns: a full copy of @list, use #g_slist_free_full to free it
25702  * Since: 2.34
25703  */
25704
25705
25706 /**
25707  * g_slist_delete_link:
25708  * @list: a #GSList
25709  * @link_: node to delete
25710  *
25711  * Removes the node link_ from the list and frees it.
25712  * Compare this to g_slist_remove_link() which removes the node
25713  * without freeing it.
25714  *
25715  * <note>Removing arbitrary nodes from a singly-linked list
25716  * requires time that is proportional to the length of the list
25717  * (ie. O(n)). If you find yourself using g_slist_delete_link()
25718  * frequently, you should consider a different data structure, such
25719  * as the doubly-linked #GList.</note>
25720  *
25721  * Returns: the new head of @list
25722  */
25723
25724
25725 /**
25726  * g_slist_find:
25727  * @list: a #GSList
25728  * @data: the element data to find
25729  *
25730  * Finds the element in a #GSList which
25731  * contains the given data.
25732  *
25733  * Returns: the found #GSList element,
25734  *     or %NULL if it is not found
25735  */
25736
25737
25738 /**
25739  * g_slist_find_custom:
25740  * @list: a #GSList
25741  * @data: user data passed to the function
25742  * @func: the function to call for each element.
25743  *     It should return 0 when the desired element is found
25744  *
25745  * Finds an element in a #GSList, using a supplied function to
25746  * find the desired element. It iterates over the list, calling
25747  * the given function which should return 0 when the desired
25748  * element is found. The function takes two #gconstpointer arguments,
25749  * the #GSList element's data as the first argument and the
25750  * given user data.
25751  *
25752  * Returns: the found #GSList element, or %NULL if it is not found
25753  */
25754
25755
25756 /**
25757  * g_slist_foreach:
25758  * @list: a #GSList
25759  * @func: the function to call with each element's data
25760  * @user_data: user data to pass to the function
25761  *
25762  * Calls a function for each element of a #GSList.
25763  */
25764
25765
25766 /**
25767  * g_slist_free:
25768  * @list: a #GSList
25769  *
25770  * Frees all of the memory used by a #GSList.
25771  * The freed elements are returned to the slice allocator.
25772  *
25773  * <note><para>
25774  * If list elements contain dynamically-allocated memory,
25775  * you should either use g_slist_free_full() or free them manually
25776  * first.
25777  * </para></note>
25778  */
25779
25780
25781 /**
25782  * g_slist_free1:
25783  *
25784  * A macro which does the same as g_slist_free_1().
25785  *
25786  * Since: 2.10
25787  */
25788
25789
25790 /**
25791  * g_slist_free_1:
25792  * @list: a #GSList element
25793  *
25794  * Frees one #GSList element.
25795  * It is usually used after g_slist_remove_link().
25796  */
25797
25798
25799 /**
25800  * g_slist_free_full:
25801  * @list: a pointer to a #GSList
25802  * @free_func: the function to be called to free each element's data
25803  *
25804  * Convenience method, which frees all the memory used by a #GSList, and
25805  * calls the specified destroy function on every element's data.
25806  *
25807  * Since: 2.28
25808  */
25809
25810
25811 /**
25812  * g_slist_index:
25813  * @list: a #GSList
25814  * @data: the data to find
25815  *
25816  * Gets the position of the element containing
25817  * the given data (starting from 0).
25818  *
25819  * Returns: the index of the element containing the data,
25820  *     or -1 if the data is not found
25821  */
25822
25823
25824 /**
25825  * g_slist_insert:
25826  * @list: a #GSList
25827  * @data: the data for the new element
25828  * @position: the position to insert the element.
25829  *     If this is negative, or is larger than the number
25830  *     of elements in the list, the new element is added on
25831  *     to the end of the list.
25832  *
25833  * Inserts a new element into the list at the given position.
25834  *
25835  * Returns: the new start of the #GSList
25836  */
25837
25838
25839 /**
25840  * g_slist_insert_before:
25841  * @slist: a #GSList
25842  * @sibling: node to insert @data before
25843  * @data: data to put in the newly-inserted node
25844  *
25845  * Inserts a node before @sibling containing @data.
25846  *
25847  * Returns: the new head of the list.
25848  */
25849
25850
25851 /**
25852  * g_slist_insert_sorted:
25853  * @list: a #GSList
25854  * @data: the data for the new element
25855  * @func: the function to compare elements in the list.
25856  *     It should return a number > 0 if the first parameter
25857  *     comes after the second parameter in the sort order.
25858  *
25859  * Inserts a new element into the list, using the given
25860  * comparison function to determine its position.
25861  *
25862  * Returns: the new start of the #GSList
25863  */
25864
25865
25866 /**
25867  * g_slist_insert_sorted_with_data:
25868  * @list: a #GSList
25869  * @data: the data for the new element
25870  * @func: the function to compare elements in the list.
25871  *     It should return a number > 0 if the first parameter
25872  *     comes after the second parameter in the sort order.
25873  * @user_data: data to pass to comparison function
25874  *
25875  * Inserts a new element into the list, using the given
25876  * comparison function to determine its position.
25877  *
25878  * Returns: the new start of the #GSList
25879  * Since: 2.10
25880  */
25881
25882
25883 /**
25884  * g_slist_last:
25885  * @list: a #GSList
25886  *
25887  * Gets the last element in a #GSList.
25888  *
25889  * <note><para>
25890  * This function iterates over the whole list.
25891  * </para></note>
25892  *
25893  * Returns: the last element in the #GSList,
25894  *     or %NULL if the #GSList has no elements
25895  */
25896
25897
25898 /**
25899  * g_slist_length:
25900  * @list: a #GSList
25901  *
25902  * Gets the number of elements in a #GSList.
25903  *
25904  * <note><para>
25905  * This function iterates over the whole list to
25906  * count its elements.
25907  * </para></note>
25908  *
25909  * Returns: the number of elements in the #GSList
25910  */
25911
25912
25913 /**
25914  * g_slist_next:
25915  * @slist: an element in a #GSList.
25916  *
25917  * A convenience macro to get the next element in a #GSList.
25918  *
25919  * Returns: the next element, or %NULL if there are no more elements.
25920  */
25921
25922
25923 /**
25924  * g_slist_nth:
25925  * @list: a #GSList
25926  * @n: the position of the element, counting from 0
25927  *
25928  * Gets the element at the given position in a #GSList.
25929  *
25930  * Returns: the element, or %NULL if the position is off
25931  *     the end of the #GSList
25932  */
25933
25934
25935 /**
25936  * g_slist_nth_data:
25937  * @list: a #GSList
25938  * @n: the position of the element
25939  *
25940  * Gets the data of the element at the given position.
25941  *
25942  * Returns: the element's data, or %NULL if the position
25943  *     is off the end of the #GSList
25944  */
25945
25946
25947 /**
25948  * g_slist_position:
25949  * @list: a #GSList
25950  * @llink: an element in the #GSList
25951  *
25952  * Gets the position of the given element
25953  * in the #GSList (starting from 0).
25954  *
25955  * Returns: the position of the element in the #GSList,
25956  *     or -1 if the element is not found
25957  */
25958
25959
25960 /**
25961  * g_slist_prepend:
25962  * @list: a #GSList
25963  * @data: the data for the new element
25964  *
25965  * Adds a new element on to the start of the list.
25966  *
25967  * <note><para>
25968  * The return value is the new start of the list, which
25969  * may have changed, so make sure you store the new value.
25970  * </para></note>
25971  *
25972  * |[
25973  * /&ast; Notice that it is initialized to the empty list. &ast;/
25974  * GSList *list = NULL;
25975  * list = g_slist_prepend (list, "last");
25976  * list = g_slist_prepend (list, "first");
25977  * ]|
25978  *
25979  * Returns: the new start of the #GSList
25980  */
25981
25982
25983 /**
25984  * g_slist_remove:
25985  * @list: a #GSList
25986  * @data: the data of the element to remove
25987  *
25988  * Removes an element from a #GSList.
25989  * If two elements contain the same data, only the first is removed.
25990  * If none of the elements contain the data, the #GSList is unchanged.
25991  *
25992  * Returns: the new start of the #GSList
25993  */
25994
25995
25996 /**
25997  * g_slist_remove_all:
25998  * @list: a #GSList
25999  * @data: data to remove
26000  *
26001  * Removes all list nodes with data equal to @data.
26002  * Returns the new head of the list. Contrast with
26003  * g_slist_remove() which removes only the first node
26004  * matching the given data.
26005  *
26006  * Returns: new head of @list
26007  */
26008
26009
26010 /**
26011  * g_slist_remove_link:
26012  * @list: a #GSList
26013  * @link_: an element in the #GSList
26014  *
26015  * Removes an element from a #GSList, without
26016  * freeing the element. The removed element's next
26017  * link is set to %NULL, so that it becomes a
26018  * self-contained list with one element.
26019  *
26020  * <note>Removing arbitrary nodes from a singly-linked list
26021  * requires time that is proportional to the length of the list
26022  * (ie. O(n)). If you find yourself using g_slist_remove_link()
26023  * frequently, you should consider a different data structure, such
26024  * as the doubly-linked #GList.</note>
26025  *
26026  * Returns: the new start of the #GSList, without the element
26027  */
26028
26029
26030 /**
26031  * g_slist_reverse:
26032  * @list: a #GSList
26033  *
26034  * Reverses a #GSList.
26035  *
26036  * Returns: the start of the reversed #GSList
26037  */
26038
26039
26040 /**
26041  * g_slist_sort:
26042  * @list: a #GSList
26043  * @compare_func: the comparison function used to sort the #GSList.
26044  *     This function is passed the data from 2 elements of the #GSList
26045  *     and should return 0 if they are equal, a negative value if the
26046  *     first element comes before the second, or a positive value if
26047  *     the first element comes after the second.
26048  *
26049  * Sorts a #GSList using the given comparison function.
26050  *
26051  * Returns: the start of the sorted #GSList
26052  */
26053
26054
26055 /**
26056  * g_slist_sort_with_data:
26057  * @list: a #GSList
26058  * @compare_func: comparison function
26059  * @user_data: data to pass to comparison function
26060  *
26061  * Like g_slist_sort(), but the sort function accepts a user data argument.
26062  *
26063  * Returns: new head of the list
26064  */
26065
26066
26067 /**
26068  * g_snprintf:
26069  * @string: the buffer to hold the output.
26070  * @n: the maximum number of bytes to produce (including the
26071  *     terminating nul character).
26072  * @format: a standard printf() format string, but notice
26073  *          <link linkend="string-precision">string precision pitfalls</link>.
26074  * @...: the arguments to insert in the output.
26075  *
26076  * A safer form of the standard sprintf() function. The output is guaranteed
26077  * to not exceed @n characters (including the terminating nul character), so
26078  * it is easy to ensure that a buffer overflow cannot occur.
26079  *
26080  * See also g_strdup_printf().
26081  *
26082  * In versions of GLib prior to 1.2.3, this function may return -1 if the
26083  * output was truncated, and the truncated string may not be nul-terminated.
26084  * In versions prior to 1.3.12, this function returns the length of the output
26085  * string.
26086  *
26087  * The return value of g_snprintf() conforms to the snprintf()
26088  * function as standardized in ISO C99. Note that this is different from
26089  * traditional snprintf(), which returns the length of the output string.
26090  *
26091  * The format string may contain positional parameters, as specified in
26092  * the Single Unix Specification.
26093  *
26094  * Returns: the number of bytes which would be produced if the buffer
26095  *     was large enough.
26096  */
26097
26098
26099 /**
26100  * g_source_add_child_source:
26101  * @source: a #GSource
26102  * @child_source: a second #GSource that @source should "poll"
26103  *
26104  * Adds @child_source to @source as a "polled" source; when @source is
26105  * added to a #GMainContext, @child_source will be automatically added
26106  * with the same priority, when @child_source is triggered, it will
26107  * cause @source to dispatch (in addition to calling its own
26108  * callback), and when @source is destroyed, it will destroy
26109  * @child_source as well. (@source will also still be dispatched if
26110  * its own prepare/check functions indicate that it is ready.)
26111  *
26112  * If you don't need @child_source to do anything on its own when it
26113  * triggers, you can call g_source_set_dummy_callback() on it to set a
26114  * callback that does nothing (except return %TRUE if appropriate).
26115  *
26116  * @source will hold a reference on @child_source while @child_source
26117  * is attached to it.
26118  *
26119  * Since: 2.28
26120  */
26121
26122
26123 /**
26124  * g_source_add_poll:
26125  * @source: a #GSource
26126  * @fd: a #GPollFD structure holding information about a file
26127  *      descriptor to watch.
26128  *
26129  * Adds a file descriptor to the set of file descriptors polled for
26130  * this source. This is usually combined with g_source_new() to add an
26131  * event source. The event source's check function will typically test
26132  * the @revents field in the #GPollFD struct and return %TRUE if events need
26133  * to be processed.
26134  *
26135  * Using this API forces the linear scanning of event sources on each
26136  * main loop iteration.  Newly-written event sources should try to use
26137  * g_source_add_unix_fd() instead of this API.
26138  */
26139
26140
26141 /**
26142  * g_source_add_unix_fd:
26143  * @source: a #GSource
26144  * @fd: the fd to monitor
26145  * @events: an event mask
26146  *
26147  * Monitors @fd for the IO events in @events.
26148  *
26149  * The tag returned by this function can be used to remove or modify the
26150  * monitoring of the fd using g_source_remove_unix_fd() or
26151  * g_source_modify_unix_fd().
26152  *
26153  * It is not necessary to remove the fd before destroying the source; it
26154  * will be cleaned up automatically.
26155  *
26156  * As the name suggests, this function is not available on Windows.
26157  *
26158  * Returns: an opaque tag
26159  * Since: 2.36
26160  */
26161
26162
26163 /**
26164  * g_source_attach:
26165  * @source: a #GSource
26166  * @context: (allow-none): a #GMainContext (if %NULL, the default context will be used)
26167  *
26168  * Adds a #GSource to a @context so that it will be executed within
26169  * that context. Remove it by calling g_source_destroy().
26170  *
26171  * Returns: the ID (greater than 0) for the source within the
26172  *   #GMainContext.
26173  */
26174
26175
26176 /**
26177  * g_source_destroy:
26178  * @source: a #GSource
26179  *
26180  * Removes a source from its #GMainContext, if any, and mark it as
26181  * destroyed.  The source cannot be subsequently added to another
26182  * context.
26183  */
26184
26185
26186 /**
26187  * g_source_get_can_recurse:
26188  * @source: a #GSource
26189  *
26190  * Checks whether a source is allowed to be called recursively.
26191  * see g_source_set_can_recurse().
26192  *
26193  * Returns: whether recursion is allowed.
26194  */
26195
26196
26197 /**
26198  * g_source_get_context:
26199  * @source: a #GSource
26200  *
26201  * Gets the #GMainContext with which the source is associated.
26202  *
26203  * You can call this on a source that has been destroyed, provided
26204  * that the #GMainContext it was attached to still exists (in which
26205  * case it will return that #GMainContext). In particular, you can
26206  * always call this function on the source returned from
26207  * g_main_current_source(). But calling this function on a source
26208  * whose #GMainContext has been destroyed is an error.
26209  *
26210  * Returns: (transfer none) (allow-none): the #GMainContext with which the
26211  *               source is associated, or %NULL if the context has not
26212  *               yet been added to a source.
26213  */
26214
26215
26216 /**
26217  * g_source_get_current_time:
26218  * @source: a #GSource
26219  * @timeval: #GTimeVal structure in which to store current time.
26220  *
26221  * This function ignores @source and is otherwise the same as
26222  * g_get_current_time().
26223  *
26224  * Deprecated: 2.28: use g_source_get_time() instead
26225  */
26226
26227
26228 /**
26229  * g_source_get_id:
26230  * @source: a #GSource
26231  *
26232  * Returns the numeric ID for a particular source. The ID of a source
26233  * is a positive integer which is unique within a particular main loop
26234  * context. The reverse
26235  * mapping from ID to source is done by g_main_context_find_source_by_id().
26236  *
26237  * Returns: the ID (greater than 0) for the source
26238  */
26239
26240
26241 /**
26242  * g_source_get_name:
26243  * @source: a #GSource
26244  *
26245  * Gets a name for the source, used in debugging and profiling.
26246  * The name may be #NULL if it has never been set with
26247  * g_source_set_name().
26248  *
26249  * Returns: the name of the source
26250  * Since: 2.26
26251  */
26252
26253
26254 /**
26255  * g_source_get_priority:
26256  * @source: a #GSource
26257  *
26258  * Gets the priority of a source.
26259  *
26260  * Returns: the priority of the source
26261  */
26262
26263
26264 /**
26265  * g_source_get_ready_time:
26266  * @source: a #GSource
26267  *
26268  * Gets the "ready time" of @source, as set by
26269  * g_source_set_ready_time().
26270  *
26271  * Any time before the current monotonic time (including 0) is an
26272  * indication that the source will fire immediately.
26273  *
26274  * Returns: the monotonic ready time, -1 for "never"
26275  */
26276
26277
26278 /**
26279  * g_source_get_time:
26280  * @source: a #GSource
26281  *
26282  * Gets the time to be used when checking this source. The advantage of
26283  * calling this function over calling g_get_monotonic_time() directly is
26284  * that when checking multiple sources, GLib can cache a single value
26285  * instead of having to repeatedly get the system monotonic time.
26286  *
26287  * The time here is the system monotonic time, if available, or some
26288  * other reasonable alternative otherwise.  See g_get_monotonic_time().
26289  *
26290  * Returns: the monotonic time in microseconds
26291  * Since: 2.28
26292  */
26293
26294
26295 /**
26296  * g_source_is_destroyed:
26297  * @source: a #GSource
26298  *
26299  * Returns whether @source has been destroyed.
26300  *
26301  * This is important when you operate upon your objects
26302  * from within idle handlers, but may have freed the object
26303  * before the dispatch of your idle handler.
26304  *
26305  * |[
26306  * static gboolean
26307  * idle_callback (gpointer data)
26308  * {
26309  *   SomeWidget *self = data;
26310  *    
26311  *   GDK_THREADS_ENTER (<!-- -->);
26312  *   /<!-- -->* do stuff with self *<!-- -->/
26313  *   self->idle_id = 0;
26314  *   GDK_THREADS_LEAVE (<!-- -->);
26315  *    
26316  *   return G_SOURCE_REMOVE;
26317  * }
26318  *  
26319  * static void
26320  * some_widget_do_stuff_later (SomeWidget *self)
26321  * {
26322  *   self->idle_id = g_idle_add (idle_callback, self);
26323  * }
26324  *  
26325  * static void
26326  * some_widget_finalize (GObject *object)
26327  * {
26328  *   SomeWidget *self = SOME_WIDGET (object);
26329  *    
26330  *   if (self->idle_id)
26331  *     g_source_remove (self->idle_id);
26332  *    
26333  *   G_OBJECT_CLASS (parent_class)->finalize (object);
26334  * }
26335  * ]|
26336  *
26337  * This will fail in a multi-threaded application if the
26338  * widget is destroyed before the idle handler fires due
26339  * to the use after free in the callback. A solution, to
26340  * this particular problem, is to check to if the source
26341  * has already been destroy within the callback.
26342  *
26343  * |[
26344  * static gboolean
26345  * idle_callback (gpointer data)
26346  * {
26347  *   SomeWidget *self = data;
26348  *   
26349  *   GDK_THREADS_ENTER ();
26350  *   if (!g_source_is_destroyed (g_main_current_source ()))
26351  *     {
26352  *       /<!-- -->* do stuff with self *<!-- -->/
26353  *     }
26354  *   GDK_THREADS_LEAVE ();
26355  *   
26356  *   return FALSE;
26357  * }
26358  * ]|
26359  *
26360  * Returns: %TRUE if the source has been destroyed
26361  * Since: 2.12
26362  */
26363
26364
26365 /**
26366  * g_source_modify_unix_fd:
26367  * @source: a #GSource
26368  * @tag: the tag from g_source_add_unix_fd()
26369  * @new_events: the new event mask to watch
26370  *
26371  * Updates the event mask to watch for the fd identified by @tag.
26372  *
26373  * @tag is the tag returned from g_source_add_unix_fd().
26374  *
26375  * If you want to remove a fd, don't set its event mask to zero.
26376  * Instead, call g_source_remove_unix_fd().
26377  *
26378  * As the name suggests, this function is not available on Windows.
26379  *
26380  * Since: 2.36
26381  */
26382
26383
26384 /**
26385  * g_source_new:
26386  * @source_funcs: structure containing functions that implement
26387  *                the sources behavior.
26388  * @struct_size: size of the #GSource structure to create.
26389  *
26390  * Creates a new #GSource structure. The size is specified to
26391  * allow creating structures derived from #GSource that contain
26392  * additional data. The size passed in must be at least
26393  * <literal>sizeof (GSource)</literal>.
26394  *
26395  * The source will not initially be associated with any #GMainContext
26396  * and must be added to one with g_source_attach() before it will be
26397  * executed.
26398  *
26399  * Returns: the newly-created #GSource.
26400  */
26401
26402
26403 /**
26404  * g_source_query_unix_fd:
26405  * @source: a #GSource
26406  * @tag: the tag from g_source_add_unix_fd()
26407  *
26408  * Queries the events reported for the fd corresponding to @tag on
26409  * @source during the last poll.
26410  *
26411  * The return value of this function is only defined when the function
26412  * is called from the check or dispatch functions for @source.
26413  *
26414  * As the name suggests, this function is not available on Windows.
26415  *
26416  * Returns: the conditions reported on the fd
26417  * Since: 2.36
26418  */
26419
26420
26421 /**
26422  * g_source_ref:
26423  * @source: a #GSource
26424  *
26425  * Increases the reference count on a source by one.
26426  *
26427  * Returns: @source
26428  */
26429
26430
26431 /**
26432  * g_source_remove:
26433  * @tag: the ID of the source to remove.
26434  *
26435  * Removes the source with the given id from the default main context.
26436  *
26437  * The id of a #GSource is given by g_source_get_id(), or will be
26438  * returned by the functions g_source_attach(), g_idle_add(),
26439  * g_idle_add_full(), g_timeout_add(), g_timeout_add_full(),
26440  * g_child_watch_add(), g_child_watch_add_full(), g_io_add_watch(), and
26441  * g_io_add_watch_full().
26442  *
26443  * See also g_source_destroy(). You must use g_source_destroy() for sources
26444  * added to a non-default main context.
26445  *
26446  * It is a programmer error to attempt to remove a non-existent source.
26447  *
26448  * Returns: For historical reasons, this function always returns %TRUE
26449  */
26450
26451
26452 /**
26453  * g_source_remove_by_funcs_user_data:
26454  * @funcs: The @source_funcs passed to g_source_new()
26455  * @user_data: the user data for the callback
26456  *
26457  * Removes a source from the default main loop context given the
26458  * source functions and user data. If multiple sources exist with the
26459  * same source functions and user data, only one will be destroyed.
26460  *
26461  * Returns: %TRUE if a source was found and removed.
26462  */
26463
26464
26465 /**
26466  * g_source_remove_by_user_data:
26467  * @user_data: the user_data for the callback.
26468  *
26469  * Removes a source from the default main loop context given the user
26470  * data for the callback. If multiple sources exist with the same user
26471  * data, only one will be destroyed.
26472  *
26473  * Returns: %TRUE if a source was found and removed.
26474  */
26475
26476
26477 /**
26478  * g_source_remove_child_source:
26479  * @source: a #GSource
26480  * @child_source: a #GSource previously passed to
26481  *     g_source_add_child_source().
26482  *
26483  * Detaches @child_source from @source and destroys it.
26484  *
26485  * Since: 2.28
26486  */
26487
26488
26489 /**
26490  * g_source_remove_poll:
26491  * @source: a #GSource
26492  * @fd: a #GPollFD structure previously passed to g_source_add_poll().
26493  *
26494  * Removes a file descriptor from the set of file descriptors polled for
26495  * this source.
26496  */
26497
26498
26499 /**
26500  * g_source_remove_unix_fd:
26501  * @source: a #GSource
26502  * @tag: the tag from g_source_add_unix_fd()
26503  *
26504  * Reverses the effect of a previous call to g_source_add_unix_fd().
26505  *
26506  * You only need to call this if you want to remove an fd from being
26507  * watched while keeping the same source around.  In the normal case you
26508  * will just want to destroy the source.
26509  *
26510  * As the name suggests, this function is not available on Windows.
26511  *
26512  * Since: 2.36
26513  */
26514
26515
26516 /**
26517  * g_source_set_callback:
26518  * @source: the source
26519  * @func: a callback function
26520  * @data: the data to pass to callback function
26521  * @notify: (allow-none): a function to call when @data is no longer in use, or %NULL.
26522  *
26523  * Sets the callback function for a source. The callback for a source is
26524  * called from the source's dispatch function.
26525  *
26526  * The exact type of @func depends on the type of source; ie. you
26527  * should not count on @func being called with @data as its first
26528  * parameter.
26529  *
26530  * Typically, you won't use this function. Instead use functions specific
26531  * to the type of source you are using.
26532  */
26533
26534
26535 /**
26536  * g_source_set_callback_indirect:
26537  * @source: the source
26538  * @callback_data: pointer to callback data "object"
26539  * @callback_funcs: functions for reference counting @callback_data
26540  *                  and getting the callback and data
26541  *
26542  * Sets the callback function storing the data as a refcounted callback
26543  * "object". This is used internally. Note that calling
26544  * g_source_set_callback_indirect() assumes
26545  * an initial reference count on @callback_data, and thus
26546  * @callback_funcs->unref will eventually be called once more
26547  * than @callback_funcs->ref.
26548  */
26549
26550
26551 /**
26552  * g_source_set_can_recurse:
26553  * @source: a #GSource
26554  * @can_recurse: whether recursion is allowed for this source
26555  *
26556  * Sets whether a source can be called recursively. If @can_recurse is
26557  * %TRUE, then while the source is being dispatched then this source
26558  * will be processed normally. Otherwise, all processing of this
26559  * source is blocked until the dispatch function returns.
26560  */
26561
26562
26563 /**
26564  * g_source_set_funcs:
26565  * @source: a #GSource
26566  * @funcs: the new #GSourceFuncs
26567  *
26568  * Sets the source functions (can be used to override
26569  * default implementations) of an unattached source.
26570  *
26571  * Since: 2.12
26572  */
26573
26574
26575 /**
26576  * g_source_set_name:
26577  * @source: a #GSource
26578  * @name: debug name for the source
26579  *
26580  * Sets a name for the source, used in debugging and profiling.
26581  * The name defaults to #NULL.
26582  *
26583  * The source name should describe in a human-readable way
26584  * what the source does. For example, "X11 event queue"
26585  * or "GTK+ repaint idle handler" or whatever it is.
26586  *
26587  * It is permitted to call this function multiple times, but is not
26588  * recommended due to the potential performance impact.  For example,
26589  * one could change the name in the "check" function of a #GSourceFuncs
26590  * to include details like the event type in the source name.
26591  *
26592  * Since: 2.26
26593  */
26594
26595
26596 /**
26597  * g_source_set_name_by_id:
26598  * @tag: a #GSource ID
26599  * @name: debug name for the source
26600  *
26601  * Sets the name of a source using its ID.
26602  *
26603  * This is a convenience utility to set source names from the return
26604  * value of g_idle_add(), g_timeout_add(), etc.
26605  *
26606  * Since: 2.26
26607  */
26608
26609
26610 /**
26611  * g_source_set_priority:
26612  * @source: a #GSource
26613  * @priority: the new priority.
26614  *
26615  * Sets the priority of a source. While the main loop is being run, a
26616  * source will be dispatched if it is ready to be dispatched and no
26617  * sources at a higher (numerically smaller) priority are ready to be
26618  * dispatched.
26619  */
26620
26621
26622 /**
26623  * g_source_set_ready_time:
26624  * @source: a #GSource
26625  * @ready_time: the monotonic time at which the source will be ready,
26626  *              0 for "immediately", -1 for "never"
26627  *
26628  * Sets a #GSource to be dispatched when the given monotonic time is
26629  * reached (or passed).  If the monotonic time is in the past (as it
26630  * always will be if @ready_time is 0) then the source will be
26631  * dispatched immediately.
26632  *
26633  * If @ready_time is -1 then the source is never woken up on the basis
26634  * of the passage of time.
26635  *
26636  * Dispatching the source does not reset the ready time.  You should do
26637  * so yourself, from the source dispatch function.
26638  *
26639  * Note that if you have a pair of sources where the ready time of one
26640  * suggests that it will be delivered first but the priority for the
26641  * other suggests that it would be delivered first, and the ready time
26642  * for both sources is reached during the same main context iteration
26643  * then the order of dispatch is undefined.
26644  *
26645  * Since: 2.36
26646  */
26647
26648
26649 /**
26650  * g_source_unref:
26651  * @source: a #GSource
26652  *
26653  * Decreases the reference count of a source by one. If the
26654  * resulting reference count is zero the source and associated
26655  * memory will be destroyed.
26656  */
26657
26658
26659 /**
26660  * g_spaced_primes_closest:
26661  * @num: a #guint
26662  *
26663  * Gets the smallest prime number from a built-in array of primes which
26664  * is larger than @num. This is used within GLib to calculate the optimum
26665  * size of a #GHashTable.
26666  *
26667  * The built-in array of primes ranges from 11 to 13845163 such that
26668  * each prime is approximately 1.5-2 times the previous prime.
26669  *
26670  * Returns: the smallest prime number from a built-in array of primes
26671  *     which is larger than @num
26672  */
26673
26674
26675 /**
26676  * g_spawn_async:
26677  * @working_directory: (allow-none): child's current working directory, or %NULL to inherit parent's
26678  * @argv: (array zero-terminated=1): child's argument vector
26679  * @envp: (array zero-terminated=1) (allow-none): child's environment, or %NULL to inherit parent's
26680  * @flags: flags from #GSpawnFlags
26681  * @child_setup: (scope async) (allow-none): function to run in the child just before exec()
26682  * @user_data: (closure): user data for @child_setup
26683  * @child_pid: (out) (allow-none): return location for child process reference, or %NULL
26684  * @error: return location for error
26685  *
26686  * See g_spawn_async_with_pipes() for a full description; this function
26687  * simply calls the g_spawn_async_with_pipes() without any pipes.
26688  *
26689  * You should call g_spawn_close_pid() on the returned child process
26690  * reference when you don't need it any more.
26691  *
26692  * <note><para>
26693  * If you are writing a GTK+ application, and the program you
26694  * are spawning is a graphical application, too, then you may
26695  * want to use gdk_spawn_on_screen() instead to ensure that
26696  * the spawned program opens its windows on the right screen.
26697  * </para></note>
26698  *
26699  * <note><para> Note that the returned @child_pid on Windows is a
26700  * handle to the child process and not its identifier. Process handles
26701  * and process identifiers are different concepts on Windows.
26702  * </para></note>
26703  *
26704  * Returns: %TRUE on success, %FALSE if error is set
26705  */
26706
26707
26708 /**
26709  * g_spawn_async_with_pipes:
26710  * @working_directory: (allow-none): child's current working directory, or %NULL to inherit parent's, in the GLib file name encoding
26711  * @argv: (array zero-terminated=1): child's argument vector, in the GLib file name encoding
26712  * @envp: (array zero-terminated=1) (allow-none): child's environment, or %NULL to inherit parent's, in the GLib file name encoding
26713  * @flags: flags from #GSpawnFlags
26714  * @child_setup: (scope async) (allow-none): function to run in the child just before exec()
26715  * @user_data: (closure): user data for @child_setup
26716  * @child_pid: (out) (allow-none): return location for child process ID, or %NULL
26717  * @standard_input: (out) (allow-none): return location for file descriptor to write to child's stdin, or %NULL
26718  * @standard_output: (out) (allow-none): return location for file descriptor to read child's stdout, or %NULL
26719  * @standard_error: (out) (allow-none): return location for file descriptor to read child's stderr, or %NULL
26720  * @error: return location for error
26721  *
26722  * Executes a child program asynchronously (your program will not
26723  * block waiting for the child to exit). The child program is
26724  * specified by the only argument that must be provided, @argv. @argv
26725  * should be a %NULL-terminated array of strings, to be passed as the
26726  * argument vector for the child. The first string in @argv is of
26727  * course the name of the program to execute. By default, the name of
26728  * the program must be a full path. If @flags contains the
26729  * %G_SPAWN_SEARCH_PATH flag, the <envar>PATH</envar> environment variable
26730  * is used to search for the executable. If @flags contains the
26731  * %G_SPAWN_SEARCH_PATH_FROM_ENVP flag, the <envar>PATH</envar> variable from
26732  * @envp is used to search for the executable.
26733  * If both the %G_SPAWN_SEARCH_PATH and %G_SPAWN_SEARCH_PATH_FROM_ENVP
26734  * flags are set, the <envar>PATH</envar> variable from @envp takes precedence
26735  * over the environment variable.
26736  *
26737  * If the program name is not a full path and %G_SPAWN_SEARCH_PATH flag is not
26738  * used, then the program will be run from the current directory (or
26739  * @working_directory, if specified); this might be unexpected or even
26740  * dangerous in some cases when the current directory is world-writable.
26741  *
26742  * On Windows, note that all the string or string vector arguments to
26743  * this function and the other g_spawn*() functions are in UTF-8, the
26744  * GLib file name encoding. Unicode characters that are not part of
26745  * the system codepage passed in these arguments will be correctly
26746  * available in the spawned program only if it uses wide character API
26747  * to retrieve its command line. For C programs built with Microsoft's
26748  * tools it is enough to make the program have a wmain() instead of
26749  * main(). wmain() has a wide character argument vector as parameter.
26750  *
26751  * At least currently, mingw doesn't support wmain(), so if you use
26752  * mingw to develop the spawned program, it will have to call the
26753  * undocumented function __wgetmainargs() to get the wide character
26754  * argument vector and environment. See gspawn-win32-helper.c in the
26755  * GLib sources or init.c in the mingw runtime sources for a prototype
26756  * for that function. Alternatively, you can retrieve the Win32 system
26757  * level wide character command line passed to the spawned program
26758  * using the GetCommandLineW() function.
26759  *
26760  * On Windows the low-level child process creation API
26761  * <function>CreateProcess()</function> doesn't use argument vectors,
26762  * but a command line. The C runtime library's
26763  * <function>spawn*()</function> family of functions (which
26764  * g_spawn_async_with_pipes() eventually calls) paste the argument
26765  * vector elements together into a command line, and the C runtime startup code
26766  * does a corresponding reconstruction of an argument vector from the
26767  * command line, to be passed to main(). Complications arise when you have
26768  * argument vector elements that contain spaces of double quotes. The
26769  * <function>spawn*()</function> functions don't do any quoting or
26770  * escaping, but on the other hand the startup code does do unquoting
26771  * and unescaping in order to enable receiving arguments with embedded
26772  * spaces or double quotes. To work around this asymmetry,
26773  * g_spawn_async_with_pipes() will do quoting and escaping on argument
26774  * vector elements that need it before calling the C runtime
26775  * spawn() function.
26776  *
26777  * The returned @child_pid on Windows is a handle to the child
26778  * process, not its identifier. Process handles and process
26779  * identifiers are different concepts on Windows.
26780  *
26781  * @envp is a %NULL-terminated array of strings, where each string
26782  * has the form <literal>KEY=VALUE</literal>. This will become
26783  * the child's environment. If @envp is %NULL, the child inherits its
26784  * parent's environment.
26785  *
26786  * @flags should be the bitwise OR of any flags you want to affect the
26787  * function's behaviour. The %G_SPAWN_DO_NOT_REAP_CHILD means that the
26788  * child will not automatically be reaped; you must use a child watch to
26789  * be notified about the death of the child process. Eventually you must
26790  * call g_spawn_close_pid() on the @child_pid, in order to free
26791  * resources which may be associated with the child process. (On Unix,
26792  * using a child watch is equivalent to calling waitpid() or handling
26793  * the <literal>SIGCHLD</literal> signal manually. On Windows, calling g_spawn_close_pid()
26794  * is equivalent to calling CloseHandle() on the process handle returned
26795  * in @child_pid).  See g_child_watch_add().
26796  *
26797  * %G_SPAWN_LEAVE_DESCRIPTORS_OPEN means that the parent's open file
26798  * descriptors will be inherited by the child; otherwise all
26799  * descriptors except stdin/stdout/stderr will be closed before
26800  * calling exec() in the child. %G_SPAWN_SEARCH_PATH
26801  * means that <literal>argv[0]</literal> need not be an absolute path, it
26802  * will be looked for in the <envar>PATH</envar> environment variable.
26803  * %G_SPAWN_SEARCH_PATH_FROM_ENVP means need not be an absolute path, it
26804  * will be looked for in the <envar>PATH</envar> variable from @envp. If
26805  * both %G_SPAWN_SEARCH_PATH and %G_SPAWN_SEARCH_PATH_FROM_ENVP are used,
26806  * the value from @envp takes precedence over the environment.
26807  * %G_SPAWN_STDOUT_TO_DEV_NULL means that the child's standard output will
26808  * be discarded, instead of going to the same location as the parent's
26809  * standard output. If you use this flag, @standard_output must be %NULL.
26810  * %G_SPAWN_STDERR_TO_DEV_NULL means that the child's standard error
26811  * will be discarded, instead of going to the same location as the parent's
26812  * standard error. If you use this flag, @standard_error must be %NULL.
26813  * %G_SPAWN_CHILD_INHERITS_STDIN means that the child will inherit the parent's
26814  * standard input (by default, the child's standard input is attached to
26815  * /dev/null). If you use this flag, @standard_input must be %NULL.
26816  * %G_SPAWN_FILE_AND_ARGV_ZERO means that the first element of @argv is
26817  * the file to execute, while the remaining elements are the
26818  * actual argument vector to pass to the file. Normally
26819  * g_spawn_async_with_pipes() uses @argv[0] as the file to execute, and
26820  * passes all of @argv to the child.
26821  *
26822  * @child_setup and @user_data are a function and user data. On POSIX
26823  * platforms, the function is called in the child after GLib has
26824  * performed all the setup it plans to perform (including creating
26825  * pipes, closing file descriptors, etc.) but before calling
26826  * exec(). That is, @child_setup is called just
26827  * before calling exec() in the child. Obviously
26828  * actions taken in this function will only affect the child, not the
26829  * parent.
26830  *
26831  * On Windows, there is no separate fork() and exec()
26832  * functionality. Child processes are created and run with a single
26833  * API call, CreateProcess(). There is no sensible thing @child_setup
26834  * could be used for on Windows so it is ignored and not called.
26835  *
26836  * If non-%NULL, @child_pid will on Unix be filled with the child's
26837  * process ID. You can use the process ID to send signals to the
26838  * child, or to use g_child_watch_add() (or waitpid()) if you specified the
26839  * %G_SPAWN_DO_NOT_REAP_CHILD flag. On Windows, @child_pid will be
26840  * filled with a handle to the child process only if you specified the
26841  * %G_SPAWN_DO_NOT_REAP_CHILD flag. You can then access the child
26842  * process using the Win32 API, for example wait for its termination
26843  * with the <function>WaitFor*()</function> functions, or examine its
26844  * exit code with GetExitCodeProcess(). You should close the handle
26845  * with CloseHandle() or g_spawn_close_pid() when you no longer need it.
26846  *
26847  * If non-%NULL, the @standard_input, @standard_output, @standard_error
26848  * locations will be filled with file descriptors for writing to the child's
26849  * standard input or reading from its standard output or standard error.
26850  * The caller of g_spawn_async_with_pipes() must close these file descriptors
26851  * when they are no longer in use. If these parameters are %NULL, the corresponding
26852  * pipe won't be created.
26853  *
26854  * If @standard_input is NULL, the child's standard input is attached to
26855  * /dev/null unless %G_SPAWN_CHILD_INHERITS_STDIN is set.
26856  *
26857  * If @standard_error is NULL, the child's standard error goes to the same
26858  * location as the parent's standard error unless %G_SPAWN_STDERR_TO_DEV_NULL
26859  * is set.
26860  *
26861  * If @standard_output is NULL, the child's standard output goes to the same
26862  * location as the parent's standard output unless %G_SPAWN_STDOUT_TO_DEV_NULL
26863  * is set.
26864  *
26865  * @error can be %NULL to ignore errors, or non-%NULL to report errors.
26866  * If an error is set, the function returns %FALSE. Errors
26867  * are reported even if they occur in the child (for example if the
26868  * executable in <literal>argv[0]</literal> is not found). Typically
26869  * the <literal>message</literal> field of returned errors should be displayed
26870  * to users. Possible errors are those from the #G_SPAWN_ERROR domain.
26871  *
26872  * If an error occurs, @child_pid, @standard_input, @standard_output,
26873  * and @standard_error will not be filled with valid values.
26874  *
26875  * If @child_pid is not %NULL and an error does not occur then the returned
26876  * process reference must be closed using g_spawn_close_pid().
26877  *
26878  * <note><para>
26879  * If you are writing a GTK+ application, and the program you
26880  * are spawning is a graphical application, too, then you may
26881  * want to use gdk_spawn_on_screen_with_pipes() instead to ensure that
26882  * the spawned program opens its windows on the right screen.
26883  * </para></note>
26884  *
26885  * Returns: %TRUE on success, %FALSE if an error was set
26886  */
26887
26888
26889 /**
26890  * g_spawn_check_exit_status:
26891  * @exit_status: An exit code as returned from g_spawn_sync()
26892  * @error: a #GError
26893  *
26894  * Set @error if @exit_status indicates the child exited abnormally
26895  * (e.g. with a nonzero exit code, or via a fatal signal).
26896  *
26897  * The g_spawn_sync() and g_child_watch_add() family of APIs return an
26898  * exit status for subprocesses encoded in a platform-specific way.
26899  * On Unix, this is guaranteed to be in the same format
26900  * <literal>waitpid(2)</literal> returns, and on Windows it is
26901  * guaranteed to be the result of
26902  * <literal>GetExitCodeProcess()</literal>.  Prior to the introduction
26903  * of this function in GLib 2.34, interpreting @exit_status required
26904  * use of platform-specific APIs, which is problematic for software
26905  * using GLib as a cross-platform layer.
26906  *
26907  * Additionally, many programs simply want to determine whether or not
26908  * the child exited successfully, and either propagate a #GError or
26909  * print a message to standard error.  In that common case, this
26910  * function can be used.  Note that the error message in @error will
26911  * contain human-readable information about the exit status.
26912  *
26913  * The <literal>domain</literal> and <literal>code</literal> of @error
26914  * have special semantics in the case where the process has an "exit
26915  * code", as opposed to being killed by a signal.  On Unix, this
26916  * happens if <literal>WIFEXITED</literal> would be true of
26917  * @exit_status.  On Windows, it is always the case.
26918  *
26919  * The special semantics are that the actual exit code will be the
26920  * code set in @error, and the domain will be %G_SPAWN_EXIT_ERROR.
26921  * This allows you to differentiate between different exit codes.
26922  *
26923  * If the process was terminated by some means other than an exit
26924  * status, the domain will be %G_SPAWN_ERROR, and the code will be
26925  * %G_SPAWN_ERROR_FAILED.
26926  *
26927  * This function just offers convenience; you can of course also check
26928  * the available platform via a macro such as %G_OS_UNIX, and use
26929  * <literal>WIFEXITED()</literal> and <literal>WEXITSTATUS()</literal>
26930  * on @exit_status directly.  Do not attempt to scan or parse the
26931  * error message string; it may be translated and/or change in future
26932  * versions of GLib.
26933  *
26934  * Returns: %TRUE if child exited successfully, %FALSE otherwise (and @error will be set)
26935  * Since: 2.34
26936  */
26937
26938
26939 /**
26940  * g_spawn_close_pid:
26941  * @pid: The process reference to close
26942  *
26943  * On some platforms, notably Windows, the #GPid type represents a resource
26944  * which must be closed to prevent resource leaking. g_spawn_close_pid()
26945  * is provided for this purpose. It should be used on all platforms, even
26946  * though it doesn't do anything under UNIX.
26947  */
26948
26949
26950 /**
26951  * g_spawn_command_line_async:
26952  * @command_line: a command line
26953  * @error: return location for errors
26954  *
26955  * A simple version of g_spawn_async() that parses a command line with
26956  * g_shell_parse_argv() and passes it to g_spawn_async(). Runs a
26957  * command line in the background. Unlike g_spawn_async(), the
26958  * %G_SPAWN_SEARCH_PATH flag is enabled, other flags are not. Note
26959  * that %G_SPAWN_SEARCH_PATH can have security implications, so
26960  * consider using g_spawn_async() directly if appropriate. Possible
26961  * errors are those from g_shell_parse_argv() and g_spawn_async().
26962  *
26963  * The same concerns on Windows apply as for g_spawn_command_line_sync().
26964  *
26965  * Returns: %TRUE on success, %FALSE if error is set.
26966  */
26967
26968
26969 /**
26970  * g_spawn_command_line_sync:
26971  * @command_line: a command line
26972  * @standard_output: (out) (array zero-terminated=1) (element-type guint8) (allow-none): return location for child output
26973  * @standard_error: (out) (array zero-terminated=1) (element-type guint8) (allow-none): return location for child errors
26974  * @exit_status: (out) (allow-none): return location for child exit status, as returned by waitpid()
26975  * @error: return location for errors
26976  *
26977  * A simple version of g_spawn_sync() with little-used parameters
26978  * removed, taking a command line instead of an argument vector.  See
26979  * g_spawn_sync() for full details. @command_line will be parsed by
26980  * g_shell_parse_argv(). Unlike g_spawn_sync(), the %G_SPAWN_SEARCH_PATH flag
26981  * is enabled. Note that %G_SPAWN_SEARCH_PATH can have security
26982  * implications, so consider using g_spawn_sync() directly if
26983  * appropriate. Possible errors are those from g_spawn_sync() and those
26984  * from g_shell_parse_argv().
26985  *
26986  * If @exit_status is non-%NULL, the platform-specific exit status of
26987  * the child is stored there; see the documentation of
26988  * g_spawn_check_exit_status() for how to use and interpret this.
26989  *
26990  * On Windows, please note the implications of g_shell_parse_argv()
26991  * parsing @command_line. Parsing is done according to Unix shell rules, not
26992  * Windows command interpreter rules.
26993  * Space is a separator, and backslashes are
26994  * special. Thus you cannot simply pass a @command_line containing
26995  * canonical Windows paths, like "c:\\program files\\app\\app.exe", as
26996  * the backslashes will be eaten, and the space will act as a
26997  * separator. You need to enclose such paths with single quotes, like
26998  * "'c:\\program files\\app\\app.exe' 'e:\\folder\\argument.txt'".
26999  *
27000  * Returns: %TRUE on success, %FALSE if an error was set
27001  */
27002
27003
27004 /**
27005  * g_spawn_sync:
27006  * @working_directory: (allow-none): child's current working directory, or %NULL to inherit parent's
27007  * @argv: (array zero-terminated=1): child's argument vector
27008  * @envp: (array zero-terminated=1) (allow-none): child's environment, or %NULL to inherit parent's
27009  * @flags: flags from #GSpawnFlags
27010  * @child_setup: (scope async) (allow-none): function to run in the child just before exec()
27011  * @user_data: (closure): user data for @child_setup
27012  * @standard_output: (out) (array zero-terminated=1) (element-type guint8) (allow-none): return location for child output, or %NULL
27013  * @standard_error: (out) (array zero-terminated=1) (element-type guint8) (allow-none): return location for child error messages, or %NULL
27014  * @exit_status: (out) (allow-none): return location for child exit status, as returned by waitpid(), or %NULL
27015  * @error: return location for error, or %NULL
27016  *
27017  * Executes a child synchronously (waits for the child to exit before returning).
27018  * All output from the child is stored in @standard_output and @standard_error,
27019  * if those parameters are non-%NULL. Note that you must set the
27020  * %G_SPAWN_STDOUT_TO_DEV_NULL and %G_SPAWN_STDERR_TO_DEV_NULL flags when
27021  * passing %NULL for @standard_output and @standard_error.
27022  *
27023  * If @exit_status is non-%NULL, the platform-specific exit status of
27024  * the child is stored there; see the documentation of
27025  * g_spawn_check_exit_status() for how to use and interpret this.
27026  * Note that it is invalid to pass %G_SPAWN_DO_NOT_REAP_CHILD in
27027  * @flags.
27028  *
27029  * If an error occurs, no data is returned in @standard_output,
27030  * @standard_error, or @exit_status.
27031  *
27032  * This function calls g_spawn_async_with_pipes() internally; see that
27033  * function for full details on the other parameters and details on
27034  * how these functions work on Windows.
27035  *
27036  * Returns: %TRUE on success, %FALSE if an error was set.
27037  */
27038
27039
27040 /**
27041  * g_sprintf:
27042  * @string: A pointer to a memory buffer to contain the resulting string. It
27043  *          is up to the caller to ensure that the allocated buffer is large
27044  *          enough to hold the formatted result
27045  * @format: a standard printf() format string, but notice
27046  *          <link linkend="string-precision">string precision pitfalls</link>.
27047  * @...: the arguments to insert in the output.
27048  *
27049  * An implementation of the standard sprintf() function which supports
27050  * positional parameters, as specified in the Single Unix Specification.
27051  *
27052  * Note that it is usually better to use g_snprintf(), to avoid the
27053  * risk of buffer overflow.
27054  *
27055  * See also g_strdup_printf().
27056  *
27057  * Returns: the number of bytes printed.
27058  * Since: 2.2
27059  */
27060
27061
27062 /**
27063  * g_stat:
27064  * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
27065  * @buf: a pointer to a <structname>stat</structname> struct, which
27066  *    will be filled with the file information
27067  *
27068  * A wrapper for the POSIX stat() function. The stat() function
27069  * returns information about a file. On Windows the stat() function in
27070  * the C library checks only the FAT-style READONLY attribute and does
27071  * not look at the ACL at all. Thus on Windows the protection bits in
27072  * the st_mode field are a fabrication of little use.
27073  *
27074  * On Windows the Microsoft C libraries have several variants of the
27075  * <structname>stat</structname> struct and stat() function with names
27076  * like "_stat", "_stat32", "_stat32i64" and "_stat64i32". The one
27077  * used here is for 32-bit code the one with 32-bit size and time
27078  * fields, specifically called "_stat32".
27079  *
27080  * In Microsoft's compiler, by default "struct stat" means one with
27081  * 64-bit time fields while in MinGW "struct stat" is the legacy one
27082  * with 32-bit fields. To hopefully clear up this messs, the gstdio.h
27083  * header defines a type GStatBuf which is the appropriate struct type
27084  * depending on the platform and/or compiler being used. On POSIX it
27085  * is just "struct stat", but note that even on POSIX platforms,
27086  * "stat" might be a macro.
27087  *
27088  * See your C library manual for more details about stat().
27089  *
27090  * Returns: 0 if the information was successfully retrieved, -1 if an error
27091  *    occurred
27092  * Since: 2.6
27093  */
27094
27095
27096 /**
27097  * g_stpcpy:
27098  * @dest: destination buffer.
27099  * @src: source string.
27100  *
27101  * Copies a nul-terminated string into the dest buffer, include the
27102  * trailing nul, and return a pointer to the trailing nul byte.
27103  * This is useful for concatenating multiple strings together
27104  * without having to repeatedly scan for the end.
27105  *
27106  * Returns: a pointer to trailing nul byte.
27107  */
27108
27109
27110 /**
27111  * g_str_equal:
27112  * @v1: a key
27113  * @v2: a key to compare with @v1
27114  *
27115  * Compares two strings for byte-by-byte equality and returns %TRUE
27116  * if they are equal. It can be passed to g_hash_table_new() as the
27117  * @key_equal_func parameter, when using non-%NULL strings as keys in a
27118  * #GHashTable.
27119  *
27120  * Note that this function is primarily meant as a hash table comparison
27121  * function. For a general-purpose, %NULL-safe string comparison function,
27122  * see g_strcmp0().
27123  *
27124  * Returns: %TRUE if the two keys match
27125  */
27126
27127
27128 /**
27129  * g_str_has_prefix:
27130  * @str: a nul-terminated string
27131  * @prefix: the nul-terminated prefix to look for
27132  *
27133  * Looks whether the string @str begins with @prefix.
27134  *
27135  * Returns: %TRUE if @str begins with @prefix, %FALSE otherwise.
27136  * Since: 2.2
27137  */
27138
27139
27140 /**
27141  * g_str_has_suffix:
27142  * @str: a nul-terminated string
27143  * @suffix: the nul-terminated suffix to look for
27144  *
27145  * Looks whether the string @str ends with @suffix.
27146  *
27147  * Returns: %TRUE if @str end with @suffix, %FALSE otherwise.
27148  * Since: 2.2
27149  */
27150
27151
27152 /**
27153  * g_str_hash:
27154  * @v: a string key
27155  *
27156  * Converts a string to a hash value.
27157  *
27158  * This function implements the widely used "djb" hash apparently posted
27159  * by Daniel Bernstein to comp.lang.c some time ago.  The 32 bit
27160  * unsigned hash value starts at 5381 and for each byte 'c' in the
27161  * string, is updated: <literal>hash = hash * 33 + c</literal>.  This
27162  * function uses the signed value of each byte.
27163  *
27164  * It can be passed to g_hash_table_new() as the @hash_func parameter,
27165  * when using non-%NULL strings as keys in a #GHashTable.
27166  *
27167  * Returns: a hash value corresponding to the key
27168  */
27169
27170
27171 /**
27172  * g_str_is_ascii:
27173  * @string: a string.
27174  *
27175  * Determines if a string is pure ASCII.  A string is pure ASCII if it
27176  * contains no bytes with the high bit set.
27177  *
27178  * Returns: %TRUE if @string is ascii
27179  * Since: 2.40
27180  */
27181
27182
27183 /**
27184  * g_str_match_string:
27185  * @search_term: the search term from the user
27186  * @potential_hit: the text that may be a hit
27187  * @accept_alternates: %TRUE to accept ASCII alternates
27188  *
27189  * Checks if a search conducted for @search_term should match
27190  * @potential_hit.
27191  *
27192  * This function calls g_str_tokenize_and_fold() on both
27193  * @search_term and @potential_hit.  ASCII alternates are never taken
27194  * for @search_term but will be taken for @potential_hit according to
27195  * the value of @accept_alternates.
27196  *
27197  * A hit occurs when each folded token in @search_term is a prefix of a
27198  * folded token from @potential_hit.
27199  *
27200  * Depending on how you're performing the search, it will typically be
27201  * faster to call g_str_tokenize_and_fold() on each string in
27202  * your corpus and build an index on the returned folded tokens, then
27203  * call g_str_tokenize_and_fold() on the search term and
27204  * perform lookups into that index.
27205  *
27206  * As some examples, searching for "fred" would match the potential hit
27207  * "Smith, Fred" and also "Frédéric".  Searching for "Fréd" would match
27208  * "Frédéric" but not "Frederic" (due to the one-directional nature of
27209  * accent matching).  Searching "fo" would match "Foo" and "Bar Foo
27210  * Baz", but not "SFO" (because no word as "fo" as a prefix).
27211  *
27212  * Returns: %TRUE if @potential_hit is a hit
27213  * Since: 2.40
27214  */
27215
27216
27217 /**
27218  * g_str_tokenize_and_fold:
27219  * @string: a string
27220  * @translit_locale: (allow-none): the language code (like 'de' or
27221  *   'en_GB') from which @string originates
27222  * @ascii_alternates: (out) (transfer full) (array zero-terminated=1): a
27223  *   return location for ASCII alternates
27224  *
27225  * Tokenises @string and performs folding on each token.
27226  *
27227  * A token is a non-empty sequence of alphanumeric characters in the
27228  * source string, separated by non-alphanumeric characters.  An
27229  * "alphanumeric" character for this purpose is one that matches
27230  * g_unichar_isalnum() or g_unichar_ismark().
27231  *
27232  * Each token is then (Unicode) normalised and case-folded.  If
27233  * @ascii_alternates is non-%NULL and some of the returned tokens
27234  * contain non-ASCII characters, ASCII alternatives will be generated.
27235  *
27236  * The number of ASCII alternatives that are generated and the method
27237  * for doing so is unspecified, but @translit_locale (if specified) may
27238  * improve the transliteration if the language of the source string is
27239  * known.
27240  *
27241  * Returns: the folded tokens
27242  * Since: 2.40
27243  */
27244
27245
27246 /**
27247  * g_strcanon:
27248  * @string: a nul-terminated array of bytes
27249  * @valid_chars: bytes permitted in @string
27250  * @substitutor: replacement character for disallowed bytes
27251  *
27252  * For each character in @string, if the character is not in
27253  * @valid_chars, replaces the character with @substitutor.
27254  * Modifies @string in place, and return @string itself, not
27255  * a copy. The return value is to allow nesting such as
27256  * |[
27257  *   g_ascii_strup (g_strcanon (str, "abc", '?'))
27258  * ]|
27259  *
27260  * Returns: @string
27261  */
27262
27263
27264 /**
27265  * g_strcasecmp:
27266  * @s1: a string.
27267  * @s2: a string to compare with @s1.
27268  *
27269  * A case-insensitive string comparison, corresponding to the standard
27270  * strcasecmp() function on platforms which support it.
27271  *
27272  * Returns: 0 if the strings match, a negative value if @s1 &lt; @s2,
27273  *   or a positive value if @s1 &gt; @s2.
27274  * Deprecated: 2.2: See g_strncasecmp() for a discussion of why this function
27275  *   is deprecated and how to replace it.
27276  */
27277
27278
27279 /**
27280  * g_strchomp:
27281  * @string: a string to remove the trailing whitespace from
27282  *
27283  * Removes trailing whitespace from a string.
27284  *
27285  * This function doesn't allocate or reallocate any memory;
27286  * it modifies @string in place. The pointer to @string is
27287  * returned to allow the nesting of functions.
27288  *
27289  * Also see g_strchug() and g_strstrip().
27290  *
27291  * Returns: @string.
27292  */
27293
27294
27295 /**
27296  * g_strchug:
27297  * @string: a string to remove the leading whitespace from
27298  *
27299  * Removes leading whitespace from a string, by moving the rest
27300  * of the characters forward.
27301  *
27302  * This function doesn't allocate or reallocate any memory;
27303  * it modifies @string in place. The pointer to @string is
27304  * returned to allow the nesting of functions.
27305  *
27306  * Also see g_strchomp() and g_strstrip().
27307  *
27308  * Returns: @string
27309  */
27310
27311
27312 /**
27313  * g_strcmp0:
27314  * @str1: (allow-none): a C string or %NULL
27315  * @str2: (allow-none): another C string or %NULL
27316  *
27317  * Compares @str1 and @str2 like strcmp(). Handles %NULL
27318  * gracefully by sorting it before non-%NULL strings.
27319  * Comparing two %NULL pointers returns 0.
27320  *
27321  * Returns: an integer less than, equal to, or greater than zero, if @str1 is <, == or > than @str2.
27322  * Since: 2.16
27323  */
27324
27325
27326 /**
27327  * g_strcompress:
27328  * @source: a string to compress
27329  *
27330  * Replaces all escaped characters with their one byte equivalent.
27331  *
27332  * This function does the reverse conversion of g_strescape().
27333  *
27334  * Returns: a newly-allocated copy of @source with all escaped
27335  *     character compressed
27336  */
27337
27338
27339 /**
27340  * g_strconcat:
27341  * @string1: the first string to add, which must not be %NULL
27342  * @...: a %NULL-terminated list of strings to append to the string
27343  *
27344  * Concatenates all of the given strings into one long string.
27345  * The returned string should be freed with g_free() when no longer needed.
27346  *
27347  * Note that this function is usually not the right function to use to
27348  * assemble a translated message from pieces, since proper translation
27349  * often requires the pieces to be reordered.
27350  *
27351  * <warning><para>The variable argument list <emphasis>must</emphasis> end
27352  * with %NULL. If you forget the %NULL, g_strconcat() will start appending
27353  * random memory junk to your string.</para></warning>
27354  *
27355  * Returns: a newly-allocated string containing all the string arguments
27356  */
27357
27358
27359 /**
27360  * g_strdelimit:
27361  * @string: the string to convert
27362  * @delimiters: (allow-none): a string containing the current delimiters, or %NULL
27363  *     to use the standard delimiters defined in #G_STR_DELIMITERS
27364  * @new_delimiter: the new delimiter character
27365  *
27366  * Converts any delimiter characters in @string to @new_delimiter.
27367  * Any characters in @string which are found in @delimiters are
27368  * changed to the @new_delimiter character. Modifies @string in place,
27369  * and returns @string itself, not a copy. The return value is to
27370  * allow nesting such as
27371  * |[
27372  *   g_ascii_strup (g_strdelimit (str, "abc", '?'))
27373  * ]|
27374  *
27375  * Returns: @string
27376  */
27377
27378
27379 /**
27380  * g_strdown:
27381  * @string: the string to convert.
27382  *
27383  * Converts a string to lower case.
27384  *
27385  * Returns: the string
27386  * Deprecated: 2.2: This function is totally broken for the reasons discussed
27387  * in the g_strncasecmp() docs - use g_ascii_strdown() or g_utf8_strdown()
27388  * instead.
27389  */
27390
27391
27392 /**
27393  * g_strdup:
27394  * @str: the string to duplicate
27395  *
27396  * Duplicates a string. If @str is %NULL it returns %NULL.
27397  * The returned string should be freed with g_free()
27398  * when no longer needed.
27399  *
27400  * Returns: a newly-allocated copy of @str
27401  */
27402
27403
27404 /**
27405  * g_strdup_printf:
27406  * @format: a standard printf() format string, but notice
27407  *     <link linkend="string-precision">string precision pitfalls</link>
27408  * @...: the parameters to insert into the format string
27409  *
27410  * Similar to the standard C sprintf() function but safer, since it
27411  * calculates the maximum space required and allocates memory to hold
27412  * the result. The returned string should be freed with g_free() when no
27413  * longer needed.
27414  *
27415  * Returns: a newly-allocated string holding the result
27416  */
27417
27418
27419 /**
27420  * g_strdup_vprintf:
27421  * @format: a standard printf() format string, but notice
27422  *     <link linkend="string-precision">string precision pitfalls</link>
27423  * @args: the list of parameters to insert into the format string
27424  *
27425  * Similar to the standard C vsprintf() function but safer, since it
27426  * calculates the maximum space required and allocates memory to hold
27427  * the result. The returned string should be freed with g_free() when
27428  * no longer needed.
27429  *
27430  * See also g_vasprintf(), which offers the same functionality, but
27431  * additionally returns the length of the allocated string.
27432  *
27433  * Returns: a newly-allocated string holding the result
27434  */
27435
27436
27437 /**
27438  * g_strdupv:
27439  * @str_array: a %NULL-terminated array of strings
27440  *
27441  * Copies %NULL-terminated array of strings. The copy is a deep copy;
27442  * the new array should be freed by first freeing each string, then
27443  * the array itself. g_strfreev() does this for you. If called
27444  * on a %NULL value, g_strdupv() simply returns %NULL.
27445  *
27446  * Returns: a new %NULL-terminated array of strings.
27447  */
27448
27449
27450 /**
27451  * g_strerror:
27452  * @errnum: the system error number. See the standard C %errno
27453  *     documentation
27454  *
27455  * Returns a string corresponding to the given error code, e.g.
27456  * "no such process". You should use this function in preference to
27457  * strerror(), because it returns a string in UTF-8 encoding, and since
27458  * not all platforms support the strerror() function.
27459  *
27460  * Returns: a UTF-8 string describing the error code. If the error code
27461  *     is unknown, it returns "unknown error (&lt;code&gt;)".
27462  */
27463
27464
27465 /**
27466  * g_strescape:
27467  * @source: a string to escape
27468  * @exceptions: a string of characters not to escape in @source
27469  *
27470  * Escapes the special characters '\b', '\f', '\n', '\r', '\t', '\v', '\'
27471  * and '&quot;' in the string @source by inserting a '\' before
27472  * them. Additionally all characters in the range 0x01-0x1F (everything
27473  * below SPACE) and in the range 0x7F-0xFF (all non-ASCII chars) are
27474  * replaced with a '\' followed by their octal representation.
27475  * Characters supplied in @exceptions are not escaped.
27476  *
27477  * g_strcompress() does the reverse conversion.
27478  *
27479  * Returns: a newly-allocated copy of @source with certain
27480  *     characters escaped. See above.
27481  */
27482
27483
27484 /**
27485  * g_strfreev:
27486  * @str_array: a %NULL-terminated array of strings to free
27487  *
27488  * Frees a %NULL-terminated array of strings, and the array itself.
27489  * If called on a %NULL value, g_strfreev() simply returns.
27490  */
27491
27492
27493 /**
27494  * g_string_append:
27495  * @string: a #GString
27496  * @val: the string to append onto the end of @string
27497  *
27498  * Adds a string onto the end of a #GString, expanding
27499  * it if necessary.
27500  *
27501  * Returns: @string
27502  */
27503
27504
27505 /**
27506  * g_string_append_c:
27507  * @string: a #GString
27508  * @c: the byte to append onto the end of @string
27509  *
27510  * Adds a byte onto the end of a #GString, expanding
27511  * it if necessary.
27512  *
27513  * Returns: @string
27514  */
27515
27516
27517 /**
27518  * g_string_append_len:
27519  * @string: a #GString
27520  * @val: bytes to append
27521  * @len: number of bytes of @val to use
27522  *
27523  * Appends @len bytes of @val to @string. Because @len is
27524  * provided, @val may contain embedded nuls and need not
27525  * be nul-terminated.
27526  *
27527  * Since this function does not stop at nul bytes, it is
27528  * the caller's responsibility to ensure that @val has at
27529  * least @len addressable bytes.
27530  *
27531  * Returns: @string
27532  */
27533
27534
27535 /**
27536  * g_string_append_printf:
27537  * @string: a #GString
27538  * @format: the string format. See the printf() documentation
27539  * @...: the parameters to insert into the format string
27540  *
27541  * Appends a formatted string onto the end of a #GString.
27542  * This function is similar to g_string_printf() except
27543  * that the text is appended to the #GString.
27544  */
27545
27546
27547 /**
27548  * g_string_append_unichar:
27549  * @string: a #GString
27550  * @wc: a Unicode character
27551  *
27552  * Converts a Unicode character into UTF-8, and appends it
27553  * to the string.
27554  *
27555  * Returns: @string
27556  */
27557
27558
27559 /**
27560  * g_string_append_uri_escaped:
27561  * @string: a #GString
27562  * @unescaped: a string
27563  * @reserved_chars_allowed: a string of reserved characters allowed
27564  *     to be used, or %NULL
27565  * @allow_utf8: set %TRUE if the escaped string may include UTF8 characters
27566  *
27567  * Appends @unescaped to @string, escaped any characters that
27568  * are reserved in URIs using URI-style escape sequences.
27569  *
27570  * Returns: @string
27571  * Since: 2.16
27572  */
27573
27574
27575 /**
27576  * g_string_append_vprintf:
27577  * @string: a #GString
27578  * @format: the string format. See the printf() documentation
27579  * @args: the list of arguments to insert in the output
27580  *
27581  * Appends a formatted string onto the end of a #GString.
27582  * This function is similar to g_string_append_printf()
27583  * except that the arguments to the format string are passed
27584  * as a va_list.
27585  *
27586  * Since: 2.14
27587  */
27588
27589
27590 /**
27591  * g_string_ascii_down:
27592  * @string: a GString
27593  *
27594  * Converts all uppercase ASCII letters to lowercase ASCII letters.
27595  *
27596  * Returns: passed-in @string pointer, with all the
27597  *     uppercase characters converted to lowercase in place,
27598  *     with semantics that exactly match g_ascii_tolower().
27599  */
27600
27601
27602 /**
27603  * g_string_ascii_up:
27604  * @string: a GString
27605  *
27606  * Converts all lowercase ASCII letters to uppercase ASCII letters.
27607  *
27608  * Returns: passed-in @string pointer, with all the
27609  *     lowercase characters converted to uppercase in place,
27610  *     with semantics that exactly match g_ascii_toupper().
27611  */
27612
27613
27614 /**
27615  * g_string_assign:
27616  * @string: the destination #GString. Its current contents
27617  *          are destroyed.
27618  * @rval: the string to copy into @string
27619  *
27620  * Copies the bytes from a string into a #GString,
27621  * destroying any previous contents. It is rather like
27622  * the standard strcpy() function, except that you do not
27623  * have to worry about having enough space to copy the string.
27624  *
27625  * Returns: @string
27626  */
27627
27628
27629 /**
27630  * g_string_chunk_clear:
27631  * @chunk: a #GStringChunk
27632  *
27633  * Frees all strings contained within the #GStringChunk.
27634  * After calling g_string_chunk_clear() it is not safe to
27635  * access any of the strings which were contained within it.
27636  *
27637  * Since: 2.14
27638  */
27639
27640
27641 /**
27642  * g_string_chunk_free:
27643  * @chunk: a #GStringChunk
27644  *
27645  * Frees all memory allocated by the #GStringChunk.
27646  * After calling g_string_chunk_free() it is not safe to
27647  * access any of the strings which were contained within it.
27648  */
27649
27650
27651 /**
27652  * g_string_chunk_insert:
27653  * @chunk: a #GStringChunk
27654  * @string: the string to add
27655  *
27656  * Adds a copy of @string to the #GStringChunk.
27657  * It returns a pointer to the new copy of the string
27658  * in the #GStringChunk. The characters in the string
27659  * can be changed, if necessary, though you should not
27660  * change anything after the end of the string.
27661  *
27662  * Unlike g_string_chunk_insert_const(), this function
27663  * does not check for duplicates. Also strings added
27664  * with g_string_chunk_insert() will not be searched
27665  * by g_string_chunk_insert_const() when looking for
27666  * duplicates.
27667  *
27668  * Returns: a pointer to the copy of @string within
27669  *     the #GStringChunk
27670  */
27671
27672
27673 /**
27674  * g_string_chunk_insert_const:
27675  * @chunk: a #GStringChunk
27676  * @string: the string to add
27677  *
27678  * Adds a copy of @string to the #GStringChunk, unless the same
27679  * string has already been added to the #GStringChunk with
27680  * g_string_chunk_insert_const().
27681  *
27682  * This function is useful if you need to copy a large number
27683  * of strings but do not want to waste space storing duplicates.
27684  * But you must remember that there may be several pointers to
27685  * the same string, and so any changes made to the strings
27686  * should be done very carefully.
27687  *
27688  * Note that g_string_chunk_insert_const() will not return a
27689  * pointer to a string added with g_string_chunk_insert(), even
27690  * if they do match.
27691  *
27692  * Returns: a pointer to the new or existing copy of @string
27693  *     within the #GStringChunk
27694  */
27695
27696
27697 /**
27698  * g_string_chunk_insert_len:
27699  * @chunk: a #GStringChunk
27700  * @string: bytes to insert
27701  * @len: number of bytes of @string to insert, or -1 to insert a
27702  *     nul-terminated string
27703  *
27704  * Adds a copy of the first @len bytes of @string to the #GStringChunk.
27705  * The copy is nul-terminated.
27706  *
27707  * Since this function does not stop at nul bytes, it is the caller's
27708  * responsibility to ensure that @string has at least @len addressable
27709  * bytes.
27710  *
27711  * The characters in the returned string can be changed, if necessary,
27712  * though you should not change anything after the end of the string.
27713  *
27714  * Returns: a pointer to the copy of @string within the #GStringChunk
27715  * Since: 2.4
27716  */
27717
27718
27719 /**
27720  * g_string_chunk_new:
27721  * @size: the default size of the blocks of memory which are
27722  *     allocated to store the strings. If a particular string
27723  *     is larger than this default size, a larger block of
27724  *     memory will be allocated for it.
27725  *
27726  * Creates a new #GStringChunk.
27727  *
27728  * Returns: a new #GStringChunk
27729  */
27730
27731
27732 /**
27733  * g_string_down:
27734  * @string: a #GString
27735  *
27736  * Converts a #GString to lowercase.
27737  *
27738  * Returns: the #GString
27739  * Deprecated: 2.2: This function uses the locale-specific
27740  *     tolower() function, which is almost never the right thing.
27741  *     Use g_string_ascii_down() or g_utf8_strdown() instead.
27742  */
27743
27744
27745 /**
27746  * g_string_equal:
27747  * @v: a #GString
27748  * @v2: another #GString
27749  *
27750  * Compares two strings for equality, returning %TRUE if they are equal.
27751  * For use with #GHashTable.
27752  *
27753  * Returns: %TRUE if the strings are the same length and contain the
27754  *     same bytes
27755  */
27756
27757
27758 /**
27759  * g_string_erase:
27760  * @string: a #GString
27761  * @pos: the position of the content to remove
27762  * @len: the number of bytes to remove, or -1 to remove all
27763  *       following bytes
27764  *
27765  * Removes @len bytes from a #GString, starting at position @pos.
27766  * The rest of the #GString is shifted down to fill the gap.
27767  *
27768  * Returns: @string
27769  */
27770
27771
27772 /**
27773  * g_string_free:
27774  * @string: a #GString
27775  * @free_segment: if %TRUE, the actual character data is freed as well
27776  *
27777  * Frees the memory allocated for the #GString.
27778  * If @free_segment is %TRUE it also frees the character data.  If
27779  * it's %FALSE, the caller gains ownership of the buffer and must
27780  * free it after use with g_free().
27781  *
27782  * Returns: the character data of @string
27783  *          (i.e. %NULL if @free_segment is %TRUE)
27784  */
27785
27786
27787 /**
27788  * g_string_free_to_bytes:
27789  * @string: (transfer full): a #GString
27790  *
27791  * Transfers ownership of the contents of @string to a newly allocated
27792  * #GBytes.  The #GString structure itself is deallocated, and it is
27793  * therefore invalid to use @string after invoking this function.
27794  *
27795  * Note that while #GString ensures that its buffer always has a
27796  * trailing nul character (not reflected in its "len"), the returned
27797  * #GBytes does not include this extra nul; i.e. it has length exactly
27798  * equal to the "len" member.
27799  *
27800  * Returns: A newly allocated #GBytes containing contents of @string; @string itself is freed
27801  * Since: 2.34
27802  */
27803
27804
27805 /**
27806  * g_string_hash:
27807  * @str: a string to hash
27808  *
27809  * Creates a hash code for @str; for use with #GHashTable.
27810  *
27811  * Returns: hash code for @str
27812  */
27813
27814
27815 /**
27816  * g_string_insert:
27817  * @string: a #GString
27818  * @pos: the position to insert the copy of the string
27819  * @val: the string to insert
27820  *
27821  * Inserts a copy of a string into a #GString,
27822  * expanding it if necessary.
27823  *
27824  * Returns: @string
27825  */
27826
27827
27828 /**
27829  * g_string_insert_c:
27830  * @string: a #GString
27831  * @pos: the position to insert the byte
27832  * @c: the byte to insert
27833  *
27834  * Inserts a byte into a #GString, expanding it if necessary.
27835  *
27836  * Returns: @string
27837  */
27838
27839
27840 /**
27841  * g_string_insert_len:
27842  * @string: a #GString
27843  * @pos: position in @string where insertion should
27844  *       happen, or -1 for at the end
27845  * @val: bytes to insert
27846  * @len: number of bytes of @val to insert
27847  *
27848  * Inserts @len bytes of @val into @string at @pos.
27849  * Because @len is provided, @val may contain embedded
27850  * nuls and need not be nul-terminated. If @pos is -1,
27851  * bytes are inserted at the end of the string.
27852  *
27853  * Since this function does not stop at nul bytes, it is
27854  * the caller's responsibility to ensure that @val has at
27855  * least @len addressable bytes.
27856  *
27857  * Returns: @string
27858  */
27859
27860
27861 /**
27862  * g_string_insert_unichar:
27863  * @string: a #GString
27864  * @pos: the position at which to insert character, or -1
27865  *     to append at the end of the string
27866  * @wc: a Unicode character
27867  *
27868  * Converts a Unicode character into UTF-8, and insert it
27869  * into the string at the given position.
27870  *
27871  * Returns: @string
27872  */
27873
27874
27875 /**
27876  * g_string_new:
27877  * @init: the initial text to copy into the string
27878  *
27879  * Creates a new #GString, initialized with the given string.
27880  *
27881  * Returns: the new #GString
27882  */
27883
27884
27885 /**
27886  * g_string_new_len:
27887  * @init: initial contents of the string
27888  * @len: length of @init to use
27889  *
27890  * Creates a new #GString with @len bytes of the @init buffer.
27891  * Because a length is provided, @init need not be nul-terminated,
27892  * and can contain embedded nul bytes.
27893  *
27894  * Since this function does not stop at nul bytes, it is the caller's
27895  * responsibility to ensure that @init has at least @len addressable
27896  * bytes.
27897  *
27898  * Returns: a new #GString
27899  */
27900
27901
27902 /**
27903  * g_string_overwrite:
27904  * @string: a #GString
27905  * @pos: the position at which to start overwriting
27906  * @val: the string that will overwrite the @string starting at @pos
27907  *
27908  * Overwrites part of a string, lengthening it if necessary.
27909  *
27910  * Returns: @string
27911  * Since: 2.14
27912  */
27913
27914
27915 /**
27916  * g_string_overwrite_len:
27917  * @string: a #GString
27918  * @pos: the position at which to start overwriting
27919  * @val: the string that will overwrite the @string starting at @pos
27920  * @len: the number of bytes to write from @val
27921  *
27922  * Overwrites part of a string, lengthening it if necessary.
27923  * This function will work with embedded nuls.
27924  *
27925  * Returns: @string
27926  * Since: 2.14
27927  */
27928
27929
27930 /**
27931  * g_string_prepend:
27932  * @string: a #GString
27933  * @val: the string to prepend on the start of @string
27934  *
27935  * Adds a string on to the start of a #GString,
27936  * expanding it if necessary.
27937  *
27938  * Returns: @string
27939  */
27940
27941
27942 /**
27943  * g_string_prepend_c:
27944  * @string: a #GString
27945  * @c: the byte to prepend on the start of the #GString
27946  *
27947  * Adds a byte onto the start of a #GString,
27948  * expanding it if necessary.
27949  *
27950  * Returns: @string
27951  */
27952
27953
27954 /**
27955  * g_string_prepend_len:
27956  * @string: a #GString
27957  * @val: bytes to prepend
27958  * @len: number of bytes in @val to prepend
27959  *
27960  * Prepends @len bytes of @val to @string.
27961  * Because @len is provided, @val may contain
27962  * embedded nuls and need not be nul-terminated.
27963  *
27964  * Since this function does not stop at nul bytes,
27965  * it is the caller's responsibility to ensure that
27966  * @val has at least @len addressable bytes.
27967  *
27968  * Returns: @string
27969  */
27970
27971
27972 /**
27973  * g_string_prepend_unichar:
27974  * @string: a #GString
27975  * @wc: a Unicode character
27976  *
27977  * Converts a Unicode character into UTF-8, and prepends it
27978  * to the string.
27979  *
27980  * Returns: @string
27981  */
27982
27983
27984 /**
27985  * g_string_printf:
27986  * @string: a #GString
27987  * @format: the string format. See the printf() documentation
27988  * @...: the parameters to insert into the format string
27989  *
27990  * Writes a formatted string into a #GString.
27991  * This is similar to the standard sprintf() function,
27992  * except that the #GString buffer automatically expands
27993  * to contain the results. The previous contents of the
27994  * #GString are destroyed.
27995  */
27996
27997
27998 /**
27999  * g_string_set_size:
28000  * @string: a #GString
28001  * @len: the new length
28002  *
28003  * Sets the length of a #GString. If the length is less than
28004  * the current length, the string will be truncated. If the
28005  * length is greater than the current length, the contents
28006  * of the newly added area are undefined. (However, as
28007  * always, string->str[string->len] will be a nul byte.)
28008  *
28009  * Returns: @string
28010  */
28011
28012
28013 /**
28014  * g_string_sized_new:
28015  * @dfl_size: the default size of the space allocated to
28016  *     hold the string
28017  *
28018  * Creates a new #GString, with enough space for @dfl_size
28019  * bytes. This is useful if you are going to add a lot of
28020  * text to the string and don't want it to be reallocated
28021  * too often.
28022  *
28023  * Returns: the new #GString
28024  */
28025
28026
28027 /**
28028  * g_string_sprintf:
28029  * @string: a #GString
28030  * @format: the string format. See the sprintf() documentation
28031  * @...: the parameters to insert into the format string
28032  *
28033  * Writes a formatted string into a #GString.
28034  * This is similar to the standard sprintf() function,
28035  * except that the #GString buffer automatically expands
28036  * to contain the results. The previous contents of the
28037  * #GString are destroyed.
28038  *
28039  * Deprecated: This function has been renamed to g_string_printf().
28040  */
28041
28042
28043 /**
28044  * g_string_sprintfa:
28045  * @string: a #GString
28046  * @format: the string format. See the sprintf() documentation
28047  * @...: the parameters to insert into the format string
28048  *
28049  * Appends a formatted string onto the end of a #GString.
28050  * This function is similar to g_string_sprintf() except that
28051  * the text is appended to the #GString.
28052  *
28053  * Deprecated: This function has been renamed to g_string_append_printf()
28054  */
28055
28056
28057 /**
28058  * g_string_truncate:
28059  * @string: a #GString
28060  * @len: the new size of @string
28061  *
28062  * Cuts off the end of the GString, leaving the first @len bytes.
28063  *
28064  * Returns: @string
28065  */
28066
28067
28068 /**
28069  * g_string_up:
28070  * @string: a #GString
28071  *
28072  * Converts a #GString to uppercase.
28073  *
28074  * Returns: @string
28075  * Deprecated: 2.2: This function uses the locale-specific
28076  *     toupper() function, which is almost never the right thing.
28077  *     Use g_string_ascii_up() or g_utf8_strup() instead.
28078  */
28079
28080
28081 /**
28082  * g_string_vprintf:
28083  * @string: a #GString
28084  * @format: the string format. See the printf() documentation
28085  * @args: the parameters to insert into the format string
28086  *
28087  * Writes a formatted string into a #GString.
28088  * This function is similar to g_string_printf() except that
28089  * the arguments to the format string are passed as a va_list.
28090  *
28091  * Since: 2.14
28092  */
28093
28094
28095 /**
28096  * g_strip_context:
28097  * @msgid: a string
28098  * @msgval: another string
28099  *
28100  * An auxiliary function for gettext() support (see Q_()).
28101  *
28102  * Returns: @msgval, unless @msgval is identical to @msgid
28103  *     and contains a '|' character, in which case a pointer to
28104  *     the substring of msgid after the first '|' character is returned.
28105  * Since: 2.4
28106  */
28107
28108
28109 /**
28110  * g_strjoin:
28111  * @separator: (allow-none): a string to insert between each of the strings, or %NULL
28112  * @...: a %NULL-terminated list of strings to join
28113  *
28114  * Joins a number of strings together to form one long string, with the
28115  * optional @separator inserted between each of them. The returned string
28116  * should be freed with g_free().
28117  *
28118  * Returns: a newly-allocated string containing all of the strings joined
28119  *     together, with @separator between them
28120  */
28121
28122
28123 /**
28124  * g_strjoinv:
28125  * @separator: (allow-none): a string to insert between each of the strings, or %NULL
28126  * @str_array: a %NULL-terminated array of strings to join
28127  *
28128  * Joins a number of strings together to form one long string, with the
28129  * optional @separator inserted between each of them. The returned string
28130  * should be freed with g_free().
28131  *
28132  * Returns: a newly-allocated string containing all of the strings joined
28133  *     together, with @separator between them
28134  */
28135
28136
28137 /**
28138  * g_strlcat:
28139  * @dest: destination buffer, already containing one nul-terminated string
28140  * @src: source buffer
28141  * @dest_size: length of @dest buffer in bytes (not length of existing string
28142  *     inside @dest)
28143  *
28144  * Portability wrapper that calls strlcat() on systems which have it,
28145  * and emulates it otherwise. Appends nul-terminated @src string to @dest,
28146  * guaranteeing nul-termination for @dest. The total size of @dest won't
28147  * exceed @dest_size.
28148  *
28149  * At most dest_size - 1 characters will be copied.
28150  * Unlike strncat, dest_size is the full size of dest, not the space left over.
28151  * This function does NOT allocate memory.
28152  * This always NUL terminates (unless siz == 0 or there were no NUL characters
28153  * in the dest_size characters of dest to start with).
28154  *
28155  * <note><para>Caveat: this is supposedly a more secure alternative to
28156  * strcat() or strncat(), but for real security g_strconcat() is harder
28157  * to mess up.</para></note>
28158  *
28159  * Returns: size of attempted result, which is MIN (dest_size, strlen
28160  *          (original dest)) + strlen (src), so if retval >= dest_size,
28161  *          truncation occurred.
28162  */
28163
28164
28165 /**
28166  * g_strlcpy:
28167  * @dest: destination buffer
28168  * @src: source buffer
28169  * @dest_size: length of @dest in bytes
28170  *
28171  * Portability wrapper that calls strlcpy() on systems which have it,
28172  * and emulates strlcpy() otherwise. Copies @src to @dest; @dest is
28173  * guaranteed to be nul-terminated; @src must be nul-terminated;
28174  * @dest_size is the buffer size, not the number of chars to copy.
28175  *
28176  * At most dest_size - 1 characters will be copied. Always nul-terminates
28177  * (unless dest_size == 0). This function does <emphasis>not</emphasis>
28178  * allocate memory. Unlike strncpy(), this function doesn't pad dest (so
28179  * it's often faster). It returns the size of the attempted result,
28180  * strlen (src), so if @retval >= @dest_size, truncation occurred.
28181  *
28182  * <note><para>Caveat: strlcpy() is supposedly more secure than
28183  * strcpy() or strncpy(), but if you really want to avoid screwups,
28184  * g_strdup() is an even better idea.</para></note>
28185  *
28186  * Returns: length of @src
28187  */
28188
28189
28190 /**
28191  * g_strncasecmp:
28192  * @s1: a string.
28193  * @s2: a string to compare with @s1.
28194  * @n: the maximum number of characters to compare.
28195  *
28196  * A case-insensitive string comparison, corresponding to the standard
28197  * strncasecmp() function on platforms which support it.
28198  * It is similar to g_strcasecmp() except it only compares the first @n
28199  * characters of the strings.
28200  *
28201  * Returns: 0 if the strings match, a negative value if @s1 &lt; @s2,
28202  *   or a positive value if @s1 &gt; @s2.
28203  * Deprecated: 2.2: The problem with g_strncasecmp() is that it does the
28204  * comparison by calling toupper()/tolower(). These functions are
28205  * locale-specific and operate on single bytes. However, it is impossible
28206  * to handle things correctly from an I18N standpoint by operating on
28207  * bytes, since characters may be multibyte. Thus g_strncasecmp() is
28208  * broken if your string is guaranteed to be ASCII, since it's
28209  * locale-sensitive, and it's broken if your string is localized, since
28210  * it doesn't work on many encodings at all, including UTF-8, EUC-JP,
28211  * etc.
28212  *
28213  * There are therefore two replacement techniques: g_ascii_strncasecmp(),
28214  * which only works on ASCII and is not locale-sensitive, and
28215  * g_utf8_casefold() followed by strcmp() on the resulting strings, which is
28216  * good for case-insensitive sorting of UTF-8.
28217  */
28218
28219
28220 /**
28221  * g_strndup:
28222  * @str: the string to duplicate
28223  * @n: the maximum number of bytes to copy from @str
28224  *
28225  * Duplicates the first @n bytes of a string, returning a newly-allocated
28226  * buffer @n + 1 bytes long which will always be nul-terminated.
28227  * If @str is less than @n bytes long the buffer is padded with nuls.
28228  * If @str is %NULL it returns %NULL.
28229  * The returned value should be freed when no longer needed.
28230  *
28231  * <note><para>
28232  * To copy a number of characters from a UTF-8 encoded string, use
28233  * g_utf8_strncpy() instead.
28234  * </para></note>
28235  *
28236  * Returns: a newly-allocated buffer containing the first @n bytes
28237  *          of @str, nul-terminated
28238  */
28239
28240
28241 /**
28242  * g_strnfill:
28243  * @length: the length of the new string
28244  * @fill_char: the byte to fill the string with
28245  *
28246  * Creates a new string @length bytes long filled with @fill_char.
28247  * The returned string should be freed when no longer needed.
28248  *
28249  * Returns: a newly-allocated string filled the @fill_char
28250  */
28251
28252
28253 /**
28254  * g_strreverse:
28255  * @string: the string to reverse
28256  *
28257  * Reverses all of the bytes in a string. For example,
28258  * <literal>g_strreverse ("abcdef")</literal> will result
28259  * in "fedcba".
28260  *
28261  * Note that g_strreverse() doesn't work on UTF-8 strings
28262  * containing multibyte characters. For that purpose, use
28263  * g_utf8_strreverse().
28264  *
28265  * Returns: the same pointer passed in as @string
28266  */
28267
28268
28269 /**
28270  * g_strrstr:
28271  * @haystack: a nul-terminated string
28272  * @needle: the nul-terminated string to search for
28273  *
28274  * Searches the string @haystack for the last occurrence
28275  * of the string @needle.
28276  *
28277  * Returns: a pointer to the found occurrence, or
28278  *    %NULL if not found.
28279  */
28280
28281
28282 /**
28283  * g_strrstr_len:
28284  * @haystack: a nul-terminated string
28285  * @haystack_len: the maximum length of @haystack
28286  * @needle: the nul-terminated string to search for
28287  *
28288  * Searches the string @haystack for the last occurrence
28289  * of the string @needle, limiting the length of the search
28290  * to @haystack_len.
28291  *
28292  * Returns: a pointer to the found occurrence, or
28293  *    %NULL if not found.
28294  */
28295
28296
28297 /**
28298  * g_strsignal:
28299  * @signum: the signal number. See the <literal>signal</literal>
28300  *     documentation
28301  *
28302  * Returns a string describing the given signal, e.g. "Segmentation fault".
28303  * You should use this function in preference to strsignal(), because it
28304  * returns a string in UTF-8 encoding, and since not all platforms support
28305  * the strsignal() function.
28306  *
28307  * Returns: a UTF-8 string describing the signal. If the signal is unknown,
28308  *     it returns "unknown signal (&lt;signum&gt;)".
28309  */
28310
28311
28312 /**
28313  * g_strsplit:
28314  * @string: a string to split
28315  * @delimiter: a string which specifies the places at which to split
28316  *     the string. The delimiter is not included in any of the resulting
28317  *     strings, unless @max_tokens is reached.
28318  * @max_tokens: the maximum number of pieces to split @string into.
28319  *     If this is less than 1, the string is split completely.
28320  *
28321  * Splits a string into a maximum of @max_tokens pieces, using the given
28322  * @delimiter. If @max_tokens is reached, the remainder of @string is
28323  * appended to the last token.
28324  *
28325  * As a special case, the result of splitting the empty string "" is an empty
28326  * vector, not a vector containing a single string. The reason for this
28327  * special case is that being able to represent a empty vector is typically
28328  * more useful than consistent handling of empty elements. If you do need
28329  * to represent empty elements, you'll need to check for the empty string
28330  * before calling g_strsplit().
28331  *
28332  * Returns: a newly-allocated %NULL-terminated array of strings. Use
28333  *    g_strfreev() to free it.
28334  */
28335
28336
28337 /**
28338  * g_strsplit_set:
28339  * @string: The string to be tokenized
28340  * @delimiters: A nul-terminated string containing bytes that are used
28341  *     to split the string.
28342  * @max_tokens: The maximum number of tokens to split @string into.
28343  *     If this is less than 1, the string is split completely
28344  *
28345  * Splits @string into a number of tokens not containing any of the characters
28346  * in @delimiter. A token is the (possibly empty) longest string that does not
28347  * contain any of the characters in @delimiters. If @max_tokens is reached, the
28348  * remainder is appended to the last token.
28349  *
28350  * For example the result of g_strsplit_set ("abc:def/ghi", ":/", -1) is a
28351  * %NULL-terminated vector containing the three strings "abc", "def",
28352  * and "ghi".
28353  *
28354  * The result if g_strsplit_set (":def/ghi:", ":/", -1) is a %NULL-terminated
28355  * vector containing the four strings "", "def", "ghi", and "".
28356  *
28357  * As a special case, the result of splitting the empty string "" is an empty
28358  * vector, not a vector containing a single string. The reason for this
28359  * special case is that being able to represent a empty vector is typically
28360  * more useful than consistent handling of empty elements. If you do need
28361  * to represent empty elements, you'll need to check for the empty string
28362  * before calling g_strsplit_set().
28363  *
28364  * Note that this function works on bytes not characters, so it can't be used
28365  * to delimit UTF-8 strings for anything but ASCII characters.
28366  *
28367  * Returns: a newly-allocated %NULL-terminated array of strings. Use
28368  *    g_strfreev() to free it.
28369  * Since: 2.4
28370  */
28371
28372
28373 /**
28374  * g_strstr_len:
28375  * @haystack: a string
28376  * @haystack_len: the maximum length of @haystack. Note that -1 is
28377  *     a valid length, if @haystack is nul-terminated, meaning it will
28378  *     search through the whole string.
28379  * @needle: the string to search for
28380  *
28381  * Searches the string @haystack for the first occurrence
28382  * of the string @needle, limiting the length of the search
28383  * to @haystack_len.
28384  *
28385  * Returns: a pointer to the found occurrence, or
28386  *    %NULL if not found.
28387  */
28388
28389
28390 /**
28391  * g_strstrip:
28392  * @string: a string to remove the leading and trailing whitespace from
28393  *
28394  * Removes leading and trailing whitespace from a string.
28395  * See g_strchomp() and g_strchug().
28396  *
28397  * Returns: @string
28398  */
28399
28400
28401 /**
28402  * g_strtod:
28403  * @nptr: the string to convert to a numeric value.
28404  * @endptr: if non-%NULL, it returns the character after
28405  *           the last character used in the conversion.
28406  *
28407  * Converts a string to a #gdouble value.
28408  * It calls the standard strtod() function to handle the conversion, but
28409  * if the string is not completely converted it attempts the conversion
28410  * again with g_ascii_strtod(), and returns the best match.
28411  *
28412  * This function should seldom be used. The normal situation when reading
28413  * numbers not for human consumption is to use g_ascii_strtod(). Only when
28414  * you know that you must expect both locale formatted and C formatted numbers
28415  * should you use this. Make sure that you don't pass strings such as comma
28416  * separated lists of values, since the commas may be interpreted as a decimal
28417  * point in some locales, causing unexpected results.
28418  *
28419  * Returns: the #gdouble value.
28420  */
28421
28422
28423 /**
28424  * g_strup:
28425  * @string: the string to convert.
28426  *
28427  * Converts a string to upper case.
28428  *
28429  * Returns: the string
28430  * Deprecated: 2.2: This function is totally broken for the reasons discussed
28431  * in the g_strncasecmp() docs - use g_ascii_strup() or g_utf8_strup() instead.
28432  */
28433
28434
28435 /**
28436  * g_strv_length:
28437  * @str_array: a %NULL-terminated array of strings
28438  *
28439  * Returns the length of the given %NULL-terminated
28440  * string array @str_array.
28441  *
28442  * Returns: length of @str_array.
28443  * Since: 2.6
28444  */
28445
28446
28447 /**
28448  * g_test_add:
28449  * @testpath: The test path for a new test case.
28450  * @Fixture: The type of a fixture data structure.
28451  * @tdata: Data argument for the test functions.
28452  * @fsetup: The function to set up the fixture data.
28453  * @ftest: The actual test function.
28454  * @fteardown: The function to tear down the fixture data.
28455  *
28456  * Hook up a new test case at @testpath, similar to g_test_add_func().
28457  * A fixture data structure with setup and teardown function may be provided
28458  * though, similar to g_test_create_case().
28459  * g_test_add() is implemented as a macro, so that the fsetup(), ftest() and
28460  * fteardown() callbacks can expect a @Fixture pointer as first argument in
28461  * a type safe manner.
28462  *
28463  * Since: 2.16
28464  */
28465
28466
28467 /**
28468  * g_test_add_data_func:
28469  * @testpath: /-separated test case path name for the test.
28470  * @test_data: Test data argument for the test function.
28471  * @test_func: The test function to invoke for this test.
28472  *
28473  * Create a new test case, similar to g_test_create_case(). However
28474  * the test is assumed to use no fixture, and test suites are automatically
28475  * created on the fly and added to the root fixture, based on the
28476  * slash-separated portions of @testpath. The @test_data argument
28477  * will be passed as first argument to @test_func.
28478  *
28479  * If @testpath includes the component "subprocess" anywhere in it,
28480  * the test will be skipped by default, and only run if explicitly
28481  * required via the <option>-p</option> command-line option or
28482  * g_test_trap_subprocess().
28483  *
28484  * Since: 2.16
28485  */
28486
28487
28488 /**
28489  * g_test_add_data_func_full:
28490  * @testpath: /-separated test case path name for the test.
28491  * @test_data: Test data argument for the test function.
28492  * @test_func: The test function to invoke for this test.
28493  * @data_free_func: #GDestroyNotify for @test_data.
28494  *
28495  * Create a new test case, as with g_test_add_data_func(), but freeing
28496  * @test_data after the test run is complete.
28497  *
28498  * Since: 2.34
28499  */
28500
28501
28502 /**
28503  * g_test_add_func:
28504  * @testpath: /-separated test case path name for the test.
28505  * @test_func: The test function to invoke for this test.
28506  *
28507  * Create a new test case, similar to g_test_create_case(). However
28508  * the test is assumed to use no fixture, and test suites are automatically
28509  * created on the fly and added to the root fixture, based on the
28510  * slash-separated portions of @testpath.
28511  *
28512  * If @testpath includes the component "subprocess" anywhere in it,
28513  * the test will be skipped by default, and only run if explicitly
28514  * required via the <option>-p</option> command-line option or
28515  * g_test_trap_subprocess().
28516  *
28517  * Since: 2.16
28518  */
28519
28520
28521 /**
28522  * g_test_assert_expected_messages:
28523  *
28524  * Asserts that all messages previously indicated via
28525  * g_test_expect_message() have been seen and suppressed.
28526  *
28527  * If messages at %G_LOG_LEVEL_DEBUG are emitted, but not explicitly
28528  * expected via g_test_expect_message() then they will be ignored.
28529  *
28530  * Since: 2.34
28531  */
28532
28533
28534 /**
28535  * g_test_bug:
28536  * @bug_uri_snippet: Bug specific bug tracker URI portion.
28537  *
28538  * This function adds a message to test reports that
28539  * associates a bug URI with a test case.
28540  * Bug URIs are constructed from a base URI set with g_test_bug_base()
28541  * and @bug_uri_snippet.
28542  *
28543  * Since: 2.16
28544  */
28545
28546
28547 /**
28548  * g_test_bug_base:
28549  * @uri_pattern: the base pattern for bug URIs
28550  *
28551  * Specify the base URI for bug reports.
28552  *
28553  * The base URI is used to construct bug report messages for
28554  * g_test_message() when g_test_bug() is called.
28555  * Calling this function outside of a test case sets the
28556  * default base URI for all test cases. Calling it from within
28557  * a test case changes the base URI for the scope of the test
28558  * case only.
28559  * Bug URIs are constructed by appending a bug specific URI
28560  * portion to @uri_pattern, or by replacing the special string
28561  * '\%s' within @uri_pattern if that is present.
28562  *
28563  * Since: 2.16
28564  */
28565
28566
28567 /**
28568  * g_test_build_filename:
28569  * @file_type: the type of file (built vs. distributed)
28570  * @first_path: the first segment of the pathname
28571  * @...: %NULL-terminated additional path segments
28572  *
28573  * Creates the pathname to a data file that is required for a test.
28574  *
28575  * This function is conceptually similar to g_build_filename() except
28576  * that the first argument has been replaced with a #GTestFileType
28577  * argument.
28578  *
28579  * The data file should either have been distributed with the module
28580  * containing the test (%G_TEST_DIST) or built as part of the build
28581  * system of that module (%G_TEST_BUILT).
28582  *
28583  * In order for this function to work in srcdir != builddir situations,
28584  * the G_TEST_SRCDIR and G_TEST_BUILDDIR environment variables need to
28585  * have been defined.  As of 2.38, this is done by the Makefile.decl
28586  * included in GLib.  Please ensure that your copy is up to date before
28587  * using this function.
28588  *
28589  * In case neither variable is set, this function will fall back to
28590  * using the dirname portion of argv[0], possibly removing ".libs".
28591  * This allows for casual running of tests directly from the commandline
28592  * in the srcdir == builddir case and should also support running of
28593  * installed tests, assuming the data files have been installed in the
28594  * same relative path as the test binary.
28595  *
28596  * Returns: the path of the file, to be freed using g_free()
28597  * Since: 2.38
28598  */
28599
28600
28601 /**
28602  * g_test_create_case:
28603  * @test_name: the name for the test case
28604  * @data_size: the size of the fixture data structure
28605  * @test_data: test data argument for the test functions
28606  * @data_setup: the function to set up the fixture data
28607  * @data_test: the actual test function
28608  * @data_teardown: the function to teardown the fixture data
28609  *
28610  * Create a new #GTestCase, named @test_name, this API is fairly
28611  * low level, calling g_test_add() or g_test_add_func() is preferable.
28612  * When this test is executed, a fixture structure of size @data_size
28613  * will be allocated and filled with 0s. Then @data_setup is called
28614  * to initialize the fixture. After fixture setup, the actual test
28615  * function @data_test is called. Once the test run completed, the
28616  * fixture structure is torn down  by calling @data_teardown and
28617  * after that the memory is released.
28618  *
28619  * Splitting up a test run into fixture setup, test function and
28620  * fixture teardown is most usful if the same fixture is used for
28621  * multiple tests. In this cases, g_test_create_case() will be
28622  * called with the same fixture, but varying @test_name and
28623  * @data_test arguments.
28624  *
28625  * Returns: a newly allocated #GTestCase.
28626  * Since: 2.16
28627  */
28628
28629
28630 /**
28631  * g_test_create_suite:
28632  * @suite_name: a name for the suite
28633  *
28634  * Create a new test suite with the name @suite_name.
28635  *
28636  * Returns: A newly allocated #GTestSuite instance.
28637  * Since: 2.16
28638  */
28639
28640
28641 /**
28642  * g_test_expect_message:
28643  * @log_domain: (allow-none): the log domain of the message
28644  * @log_level: the log level of the message
28645  * @pattern: a glob-style
28646  *     <link linkend="glib-Glob-style-pattern-matching">pattern</link>
28647  *
28648  * Indicates that a message with the given @log_domain and @log_level,
28649  * with text matching @pattern, is expected to be logged. When this
28650  * message is logged, it will not be printed, and the test case will
28651  * not abort.
28652  *
28653  * Use g_test_assert_expected_messages() to assert that all
28654  * previously-expected messages have been seen and suppressed.
28655  *
28656  * You can call this multiple times in a row, if multiple messages are
28657  * expected as a result of a single call. (The messages must appear in
28658  * the same order as the calls to g_test_expect_message().)
28659  *
28660  * For example:
28661  *
28662  * |[
28663  *   /&ast; g_main_context_push_thread_default() should fail if the
28664  *    &ast; context is already owned by another thread.
28665  *    &ast;/
28666  *   g_test_expect_message (G_LOG_DOMAIN,
28667  *                          G_LOG_LEVEL_CRITICAL,
28668  *                          "assertion*acquired_context*failed");
28669  *   g_main_context_push_thread_default (bad_context);
28670  *   g_test_assert_expected_messages ();
28671  * ]|
28672  *
28673  * Note that you cannot use this to test g_error() messages, since
28674  * g_error() intentionally never returns even if the program doesn't
28675  * abort; use g_test_trap_subprocess() in this case.
28676  *
28677  * If messages at %G_LOG_LEVEL_DEBUG are emitted, but not explicitly
28678  * expected via g_test_expect_message() then they will be ignored.
28679  *
28680  * Since: 2.34
28681  */
28682
28683
28684 /**
28685  * g_test_fail:
28686  *
28687  * Indicates that a test failed. This function can be called
28688  * multiple times from the same test. You can use this function
28689  * if your test failed in a recoverable way.
28690  *
28691  * Do not use this function if the failure of a test could cause
28692  * other tests to malfunction.
28693  *
28694  * Calling this function will not stop the test from running, you
28695  * need to return from the test function yourself. So you can
28696  * produce additional diagnostic messages or even continue running
28697  * the test.
28698  *
28699  * If not called from inside a test, this function does nothing.
28700  *
28701  * Since: 2.30
28702  */
28703
28704
28705 /**
28706  * g_test_failed:
28707  *
28708  * Returns whether a test has already failed. This will
28709  * be the case when g_test_fail(), g_test_incomplete()
28710  * or g_test_skip() have been called, but also if an
28711  * assertion has failed.
28712  *
28713  * This can be useful to return early from a test if
28714  * continuing after a failed assertion might be harmful.
28715  *
28716  * The return value of this function is only meaningful
28717  * if it is called from inside a test function.
28718  *
28719  * Returns: %TRUE if the test has failed
28720  * Since: 2.38
28721  */
28722
28723
28724 /**
28725  * g_test_get_dir:
28726  * @file_type: the type of file (built vs. distributed)
28727  *
28728  * Gets the pathname of the directory containing test files of the type
28729  * specified by @file_type.
28730  *
28731  * This is approximately the same as calling g_test_build_filename("."),
28732  * but you don't need to free the return value.
28733  *
28734  * Returns: the path of the directory, owned by GLib
28735  * Since: 2.38
28736  */
28737
28738
28739 /**
28740  * g_test_get_filename:
28741  * @file_type: the type of file (built vs. distributed)
28742  * @first_path: the first segment of the pathname
28743  * @...: %NULL-terminated additional path segments
28744  *
28745  * Gets the pathname to a data file that is required for a test.
28746  *
28747  * This is the same as g_test_build_filename() with two differences.
28748  * The first difference is that must only use this function from within
28749  * a testcase function.  The second difference is that you need not free
28750  * the return value -- it will be automatically freed when the testcase
28751  * finishes running.
28752  *
28753  * It is safe to use this function from a thread inside of a testcase
28754  * but you must ensure that all such uses occur before the main testcase
28755  * function returns (ie: it is best to ensure that all threads have been
28756  * joined).
28757  *
28758  * Returns: the path, automatically freed at the end of the testcase
28759  * Since: 2.38
28760  */
28761
28762
28763 /**
28764  * g_test_get_root:
28765  *
28766  * Get the toplevel test suite for the test path API.
28767  *
28768  * Returns: the toplevel #GTestSuite
28769  * Since: 2.16
28770  */
28771
28772
28773 /**
28774  * g_test_incomplete:
28775  * @msg: (allow-none): explanation
28776  *
28777  * Indicates that a test failed because of some incomplete
28778  * functionality. This function can be called multiple times
28779  * from the same test.
28780  *
28781  * Calling this function will not stop the test from running, you
28782  * need to return from the test function yourself. So you can
28783  * produce additional diagnostic messages or even continue running
28784  * the test.
28785  *
28786  * If not called from inside a test, this function does nothing.
28787  *
28788  * Since: 2.38
28789  */
28790
28791
28792 /**
28793  * g_test_init:
28794  * @argc: Address of the @argc parameter of the main() function.
28795  *        Changed if any arguments were handled.
28796  * @argv: Address of the @argv parameter of main().
28797  *        Any parameters understood by g_test_init() stripped before return.
28798  * @...: Reserved for future extension. Currently, you must pass %NULL.
28799  *
28800  * Initialize the GLib testing framework, e.g. by seeding the
28801  * test random number generator, the name for g_get_prgname()
28802  * and parsing test related command line args.
28803  * So far, the following arguments are understood:
28804  * <variablelist>
28805  *   <varlistentry>
28806  *     <term><option>-l</option></term>
28807  *     <listitem><para>
28808  *       List test cases available in a test executable.
28809  *     </para></listitem>
28810  *   </varlistentry>
28811  *   <varlistentry>
28812  *     <term><option>--seed=<replaceable>RANDOMSEED</replaceable></option></term>
28813  *     <listitem><para>
28814  *       Provide a random seed to reproduce test runs using random numbers.
28815  *     </para></listitem>
28816  *     </varlistentry>
28817  *     <varlistentry>
28818  *       <term><option>--verbose</option></term>
28819  *       <listitem><para>Run tests verbosely.</para></listitem>
28820  *     </varlistentry>
28821  *     <varlistentry>
28822  *       <term><option>-q</option>, <option>--quiet</option></term>
28823  *       <listitem><para>Run tests quietly.</para></listitem>
28824  *     </varlistentry>
28825  *     <varlistentry>
28826  *       <term><option>-p <replaceable>TESTPATH</replaceable></option></term>
28827  *       <listitem><para>
28828  *         Execute all tests matching <replaceable>TESTPATH</replaceable>.
28829  *         This can also be used to force a test to run that would otherwise
28830  *         be skipped (ie, a test whose name contains "/subprocess").
28831  *       </para></listitem>
28832  *     </varlistentry>
28833  *     <varlistentry>
28834  *       <term><option>-m {perf|slow|thorough|quick|undefined|no-undefined}</option></term>
28835  *       <listitem><para>
28836  *         Execute tests according to these test modes:
28837  *         <variablelist>
28838  *           <varlistentry>
28839  *             <term>perf</term>
28840  *             <listitem><para>
28841  *               Performance tests, may take long and report results.
28842  *             </para></listitem>
28843  *           </varlistentry>
28844  *           <varlistentry>
28845  *             <term>slow, thorough</term>
28846  *             <listitem><para>
28847  *               Slow and thorough tests, may take quite long and
28848  *               maximize coverage.
28849  *             </para></listitem>
28850  *           </varlistentry>
28851  *           <varlistentry>
28852  *             <term>quick</term>
28853  *             <listitem><para>
28854  *               Quick tests, should run really quickly and give good coverage.
28855  *             </para></listitem>
28856  *           </varlistentry>
28857  *           <varlistentry>
28858  *             <term>undefined</term>
28859  *             <listitem><para>
28860  *               Tests for undefined behaviour, may provoke programming errors
28861  *               under g_test_trap_subprocess() or g_test_expect_messages() to check
28862  *               that appropriate assertions or warnings are given
28863  *             </para></listitem>
28864  *           </varlistentry>
28865  *           <varlistentry>
28866  *             <term>no-undefined</term>
28867  *             <listitem><para>
28868  *               Avoid tests for undefined behaviour
28869  *             </para></listitem>
28870  *           </varlistentry>
28871  *         </variablelist>
28872  *       </para></listitem>
28873  *     </varlistentry>
28874  *     <varlistentry>
28875  *       <term><option>--debug-log</option></term>
28876  *       <listitem><para>Debug test logging output.</para></listitem>
28877  *     </varlistentry>
28878  *  </variablelist>
28879  *
28880  * Since: 2.16
28881  */
28882
28883
28884 /**
28885  * g_test_initialized:
28886  *
28887  * Returns %TRUE if g_test_init() has been called.
28888  *
28889  * Returns: %TRUE if g_test_init() has been called.
28890  * Since: 2.36
28891  */
28892
28893
28894 /**
28895  * g_test_log_buffer_free:
28896  *
28897  * Internal function for gtester to free test log messages, no ABI guarantees provided.
28898  */
28899
28900
28901 /**
28902  * g_test_log_buffer_new:
28903  *
28904  * Internal function for gtester to decode test log messages, no ABI guarantees provided.
28905  */
28906
28907
28908 /**
28909  * g_test_log_buffer_pop:
28910  *
28911  * Internal function for gtester to retrieve test log messages, no ABI guarantees provided.
28912  */
28913
28914
28915 /**
28916  * g_test_log_buffer_push:
28917  *
28918  * Internal function for gtester to decode test log messages, no ABI guarantees provided.
28919  */
28920
28921
28922 /**
28923  * g_test_log_msg_free:
28924  *
28925  * Internal function for gtester to free test log messages, no ABI guarantees provided.
28926  */
28927
28928
28929 /**
28930  * g_test_log_set_fatal_handler:
28931  * @log_func: the log handler function.
28932  * @user_data: data passed to the log handler.
28933  *
28934  * Installs a non-error fatal log handler which can be
28935  * used to decide whether log messages which are counted
28936  * as fatal abort the program.
28937  *
28938  * The use case here is that you are running a test case
28939  * that depends on particular libraries or circumstances
28940  * and cannot prevent certain known critical or warning
28941  * messages. So you install a handler that compares the
28942  * domain and message to precisely not abort in such a case.
28943  *
28944  * Note that the handler is reset at the beginning of
28945  * any test case, so you have to set it inside each test
28946  * function which needs the special behavior.
28947  *
28948  * This handler has no effect on g_error messages.
28949  *
28950  * Since: 2.22
28951  */
28952
28953
28954 /**
28955  * g_test_maximized_result:
28956  * @maximized_quantity: the reported value
28957  * @format: the format string of the report message
28958  * @...: arguments to pass to the printf() function
28959  *
28960  * Report the result of a performance or measurement test.
28961  * The test should generally strive to maximize the reported
28962  * quantities (larger values are better than smaller ones),
28963  * this and @maximized_quantity can determine sorting
28964  * order for test result reports.
28965  *
28966  * Since: 2.16
28967  */
28968
28969
28970 /**
28971  * g_test_message:
28972  * @format: the format string
28973  * @...: printf-like arguments to @format
28974  *
28975  * Add a message to the test report.
28976  *
28977  * Since: 2.16
28978  */
28979
28980
28981 /**
28982  * g_test_minimized_result:
28983  * @minimized_quantity: the reported value
28984  * @format: the format string of the report message
28985  * @...: arguments to pass to the printf() function
28986  *
28987  * Report the result of a performance or measurement test.
28988  * The test should generally strive to minimize the reported
28989  * quantities (smaller values are better than larger ones),
28990  * this and @minimized_quantity can determine sorting
28991  * order for test result reports.
28992  *
28993  * Since: 2.16
28994  */
28995
28996
28997 /**
28998  * g_test_perf:
28999  *
29000  * Returns %TRUE if tests are run in performance mode.
29001  *
29002  * Returns: %TRUE if in performance mode
29003  */
29004
29005
29006 /**
29007  * g_test_queue_destroy:
29008  * @destroy_func: Destroy callback for teardown phase.
29009  * @destroy_data: Destroy callback data.
29010  *
29011  * This function enqueus a callback @destroy_func to be executed
29012  * during the next test case teardown phase. This is most useful
29013  * to auto destruct allocted test resources at the end of a test run.
29014  * Resources are released in reverse queue order, that means enqueueing
29015  * callback A before callback B will cause B() to be called before
29016  * A() during teardown.
29017  *
29018  * Since: 2.16
29019  */
29020
29021
29022 /**
29023  * g_test_queue_free:
29024  * @gfree_pointer: the pointer to be stored.
29025  *
29026  * Enqueue a pointer to be released with g_free() during the next
29027  * teardown phase. This is equivalent to calling g_test_queue_destroy()
29028  * with a destroy callback of g_free().
29029  *
29030  * Since: 2.16
29031  */
29032
29033
29034 /**
29035  * g_test_queue_unref:
29036  * @gobject: the object to unref
29037  *
29038  * Enqueue an object to be released with g_object_unref() during
29039  * the next teardown phase. This is equivalent to calling
29040  * g_test_queue_destroy() with a destroy callback of g_object_unref().
29041  *
29042  * Since: 2.16
29043  */
29044
29045
29046 /**
29047  * g_test_quick:
29048  *
29049  * Returns %TRUE if tests are run in quick mode.
29050  * Exactly one of g_test_quick() and g_test_slow() is active in any run;
29051  * there is no "medium speed".
29052  *
29053  * Returns: %TRUE if in quick mode
29054  */
29055
29056
29057 /**
29058  * g_test_quiet:
29059  *
29060  * Returns %TRUE if tests are run in quiet mode.
29061  * The default is neither g_test_verbose() nor g_test_quiet().
29062  *
29063  * Returns: %TRUE if in quiet mode
29064  */
29065
29066
29067 /**
29068  * g_test_rand_bit:
29069  *
29070  * Get a reproducible random bit (0 or 1), see g_test_rand_int()
29071  * for details on test case random numbers.
29072  *
29073  * Since: 2.16
29074  */
29075
29076
29077 /**
29078  * g_test_rand_double:
29079  *
29080  * Get a reproducible random floating point number,
29081  * see g_test_rand_int() for details on test case random numbers.
29082  *
29083  * Returns: a random number from the seeded random number generator.
29084  * Since: 2.16
29085  */
29086
29087
29088 /**
29089  * g_test_rand_double_range:
29090  * @range_start: the minimum value returned by this function
29091  * @range_end: the minimum value not returned by this function
29092  *
29093  * Get a reproducible random floating pointer number out of a specified range,
29094  * see g_test_rand_int() for details on test case random numbers.
29095  *
29096  * Returns: a number with @range_start <= number < @range_end.
29097  * Since: 2.16
29098  */
29099
29100
29101 /**
29102  * g_test_rand_int:
29103  *
29104  * Get a reproducible random integer number.
29105  *
29106  * The random numbers generated by the g_test_rand_*() family of functions
29107  * change with every new test program start, unless the --seed option is
29108  * given when starting test programs.
29109  *
29110  * For individual test cases however, the random number generator is
29111  * reseeded, to avoid dependencies between tests and to make --seed
29112  * effective for all test cases.
29113  *
29114  * Returns: a random number from the seeded random number generator.
29115  * Since: 2.16
29116  */
29117
29118
29119 /**
29120  * g_test_rand_int_range:
29121  * @begin: the minimum value returned by this function
29122  * @end: the smallest value not to be returned by this function
29123  *
29124  * Get a reproducible random integer number out of a specified range,
29125  * see g_test_rand_int() for details on test case random numbers.
29126  *
29127  * Returns: a number with @begin <= number < @end.
29128  * Since: 2.16
29129  */
29130
29131
29132 /**
29133  * g_test_run:
29134  *
29135  * Runs all tests under the toplevel suite which can be retrieved
29136  * with g_test_get_root(). Similar to g_test_run_suite(), the test
29137  * cases to be run are filtered according to
29138  * test path arguments (-p <replaceable>testpath</replaceable>) as
29139  * parsed by g_test_init().
29140  * g_test_run_suite() or g_test_run() may only be called once
29141  * in a program.
29142  *
29143  * Returns: 0 on success
29144  * Since: 2.16
29145  */
29146
29147
29148 /**
29149  * g_test_run_suite:
29150  * @suite: a #GTestSuite
29151  *
29152  * Execute the tests within @suite and all nested #GTestSuites.
29153  * The test suites to be executed are filtered according to
29154  * test path arguments (-p <replaceable>testpath</replaceable>)
29155  * as parsed by g_test_init().
29156  * g_test_run_suite() or g_test_run() may only be called once
29157  * in a program.
29158  *
29159  * Returns: 0 on success
29160  * Since: 2.16
29161  */
29162
29163
29164 /**
29165  * g_test_set_nonfatal_assertions:
29166  *
29167  * Changes the behaviour of g_assert_cmpstr(), g_assert_cmpint(),
29168  * g_assert_cmpuint(), g_assert_cmphex(), g_assert_cmpfloat(),
29169  * g_assert_true(), g_assert_false(), g_assert_null(), g_assert_no_error(),
29170  * g_assert_error(), g_test_assert_expected_messages() and the various
29171  * g_test_trap_assert_*() macros to not abort to program, but instead
29172  * call g_test_fail() and continue.
29173  *
29174  * Note that the g_assert_not_reached() and g_assert() are not
29175  * affected by this.
29176  *
29177  * This function can only be called after g_test_init().
29178  *
29179  * Since: 2.38
29180  */
29181
29182
29183 /**
29184  * g_test_skip:
29185  * @msg: (allow-none): explanation
29186  *
29187  * Indicates that a test was skipped.
29188  *
29189  * Calling this function will not stop the test from running, you
29190  * need to return from the test function yourself. So you can
29191  * produce additional diagnostic messages or even continue running
29192  * the test.
29193  *
29194  * If not called from inside a test, this function does nothing.
29195  *
29196  * Since: 2.38
29197  */
29198
29199
29200 /**
29201  * g_test_slow:
29202  *
29203  * Returns %TRUE if tests are run in slow mode.
29204  * Exactly one of g_test_quick() and g_test_slow() is active in any run;
29205  * there is no "medium speed".
29206  *
29207  * Returns: the opposite of g_test_quick()
29208  */
29209
29210
29211 /**
29212  * g_test_subprocess:
29213  *
29214  * Returns %TRUE (after g_test_init() has been called) if the test
29215  * program is running under g_test_trap_subprocess().
29216  *
29217  * Returns: %TRUE if the test program is running under
29218  * g_test_trap_subprocess().
29219  * Since: 2.38
29220  */
29221
29222
29223 /**
29224  * g_test_suite_add:
29225  * @suite: a #GTestSuite
29226  * @test_case: a #GTestCase
29227  *
29228  * Adds @test_case to @suite.
29229  *
29230  * Since: 2.16
29231  */
29232
29233
29234 /**
29235  * g_test_suite_add_suite:
29236  * @suite: a #GTestSuite
29237  * @nestedsuite: another #GTestSuite
29238  *
29239  * Adds @nestedsuite to @suite.
29240  *
29241  * Since: 2.16
29242  */
29243
29244
29245 /**
29246  * g_test_thorough:
29247  *
29248  * Returns %TRUE if tests are run in thorough mode, equivalent to
29249  * g_test_slow().
29250  *
29251  * Returns: the same thing as g_test_slow()
29252  */
29253
29254
29255 /**
29256  * g_test_timer_elapsed:
29257  *
29258  * Get the time since the last start of the timer with g_test_timer_start().
29259  *
29260  * Returns: the time since the last start of the timer, as a double
29261  * Since: 2.16
29262  */
29263
29264
29265 /**
29266  * g_test_timer_last:
29267  *
29268  * Report the last result of g_test_timer_elapsed().
29269  *
29270  * Returns: the last result of g_test_timer_elapsed(), as a double
29271  * Since: 2.16
29272  */
29273
29274
29275 /**
29276  * g_test_timer_start:
29277  *
29278  * Start a timing test. Call g_test_timer_elapsed() when the task is supposed
29279  * to be done. Call this function again to restart the timer.
29280  *
29281  * Since: 2.16
29282  */
29283
29284
29285 /**
29286  * g_test_trap_assert_failed:
29287  *
29288  * Assert that the last test subprocess failed.
29289  * See g_test_trap_subprocess().
29290  *
29291  * This is sometimes used to test situations that are formally considered to
29292  * be undefined behaviour, like inputs that fail a g_return_if_fail()
29293  * check. In these situations you should skip the entire test, including the
29294  * call to g_test_trap_subprocess(), unless g_test_undefined() returns %TRUE
29295  * to indicate that undefined behaviour may be tested.
29296  *
29297  * Since: 2.16
29298  */
29299
29300
29301 /**
29302  * g_test_trap_assert_passed:
29303  *
29304  * Assert that the last test subprocess passed.
29305  * See g_test_trap_subprocess().
29306  *
29307  * Since: 2.16
29308  */
29309
29310
29311 /**
29312  * g_test_trap_assert_stderr:
29313  * @serrpattern: a glob-style
29314  *     <link linkend="glib-Glob-style-pattern-matching">pattern</link>
29315  *
29316  * Assert that the stderr output of the last test subprocess
29317  * matches @serrpattern. See  g_test_trap_subprocess().
29318  *
29319  * This is sometimes used to test situations that are formally
29320  * considered to be undefined behaviour, like code that hits a
29321  * g_assert() or g_error(). In these situations you should skip the
29322  * entire test, including the call to g_test_trap_subprocess(), unless
29323  * g_test_undefined() returns %TRUE to indicate that undefined
29324  * behaviour may be tested.
29325  *
29326  * Since: 2.16
29327  */
29328
29329
29330 /**
29331  * g_test_trap_assert_stderr_unmatched:
29332  * @serrpattern: a glob-style
29333  *     <link linkend="glib-Glob-style-pattern-matching">pattern</link>
29334  *
29335  * Assert that the stderr output of the last test subprocess
29336  * does not match @serrpattern. See g_test_trap_subprocess().
29337  *
29338  * Since: 2.16
29339  */
29340
29341
29342 /**
29343  * g_test_trap_assert_stdout:
29344  * @soutpattern: a glob-style
29345  *     <link linkend="glib-Glob-style-pattern-matching">pattern</link>
29346  *
29347  * Assert that the stdout output of the last test subprocess matches
29348  * @soutpattern. See g_test_trap_subprocess().
29349  *
29350  * Since: 2.16
29351  */
29352
29353
29354 /**
29355  * g_test_trap_assert_stdout_unmatched:
29356  * @soutpattern: a glob-style
29357  *     <link linkend="glib-Glob-style-pattern-matching">pattern</link>
29358  *
29359  * Assert that the stdout output of the last test subprocess
29360  * does not match @soutpattern. See g_test_trap_subprocess().
29361  *
29362  * Since: 2.16
29363  */
29364
29365
29366 /**
29367  * g_test_trap_fork:
29368  * @usec_timeout: Timeout for the forked test in micro seconds.
29369  * @test_trap_flags: Flags to modify forking behaviour.
29370  *
29371  * Fork the current test program to execute a test case that might
29372  * not return or that might abort.
29373  *
29374  * If @usec_timeout is non-0, the forked test case is aborted and
29375  * considered failing if its run time exceeds it.
29376  *
29377  * The forking behavior can be configured with the #GTestTrapFlags flags.
29378  *
29379  * In the following example, the test code forks, the forked child
29380  * process produces some sample output and exits successfully.
29381  * The forking parent process then asserts successful child program
29382  * termination and validates child program outputs.
29383  *
29384  * |[
29385  *   static void
29386  *   test_fork_patterns (void)
29387  *   {
29388  *     if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR))
29389  *       {
29390  *         g_print ("some stdout text: somagic17\n");
29391  *         g_printerr ("some stderr text: semagic43\n");
29392  *         exit (0); /&ast; successful test run &ast;/
29393  *       }
29394  *     g_test_trap_assert_passed ();
29395  *     g_test_trap_assert_stdout ("*somagic17*");
29396  *     g_test_trap_assert_stderr ("*semagic43*");
29397  *   }
29398  * ]|
29399  *
29400  * Returns: %TRUE for the forked child and %FALSE for the executing parent process.
29401  * Since: 2.16
29402  * Deprecated: This function is implemented only on Unix platforms,
29403  * and is not always reliable due to problems inherent in
29404  * fork-without-exec. Use g_test_trap_subprocess() instead.
29405  */
29406
29407
29408 /**
29409  * g_test_trap_has_passed:
29410  *
29411  * Check the result of the last g_test_trap_subprocess() call.
29412  *
29413  * Returns: %TRUE if the last test subprocess terminated successfully.
29414  * Since: 2.16
29415  */
29416
29417
29418 /**
29419  * g_test_trap_reached_timeout:
29420  *
29421  * Check the result of the last g_test_trap_subprocess() call.
29422  *
29423  * Returns: %TRUE if the last test subprocess got killed due to a timeout.
29424  * Since: 2.16
29425  */
29426
29427
29428 /**
29429  * g_test_trap_subprocess:
29430  * @test_path: Test to run in a subprocess
29431  * @usec_timeout: Timeout for the subprocess test in micro seconds.
29432  * @test_flags: Flags to modify subprocess behaviour.
29433  *
29434  * Respawns the test program to run only @test_path in a subprocess.
29435  * This can be used for a test case that might not return, or that
29436  * might abort. @test_path will normally be the name of the parent
29437  * test, followed by "<literal>/subprocess/</literal>" and then a name
29438  * for the specific subtest (or just ending with
29439  * "<literal>/subprocess</literal>" if the test only has one child
29440  * test); tests with names of this form will automatically be skipped
29441  * in the parent process.
29442  *
29443  * If @usec_timeout is non-0, the test subprocess is aborted and
29444  * considered failing if its run time exceeds it.
29445  *
29446  * The subprocess behavior can be configured with the
29447  * #GTestSubprocessFlags flags.
29448  *
29449  * You can use methods such as g_test_trap_assert_passed(),
29450  * g_test_trap_assert_failed(), and g_test_trap_assert_stderr() to
29451  * check the results of the subprocess. (But note that
29452  * g_test_trap_assert_stdout() and g_test_trap_assert_stderr()
29453  * cannot be used if @test_flags specifies that the child should
29454  * inherit the parent stdout/stderr.)
29455  *
29456  * If your <literal>main ()</literal> needs to behave differently in
29457  * the subprocess, you can call g_test_subprocess() (after calling
29458  * g_test_init()) to see whether you are in a subprocess.
29459  *
29460  * The following example tests that calling
29461  * <literal>my_object_new(1000000)</literal> will abort with an error
29462  * message.
29463  *
29464  * |[
29465  *   static void
29466  *   test_create_large_object_subprocess (void)
29467  *   {
29468  *     my_object_new (1000000);
29469  *   }
29470  *
29471  *   static void
29472  *   test_create_large_object (void)
29473  *   {
29474  *     g_test_trap_subprocess ("/myobject/create_large_object/subprocess", 0, 0);
29475  *     g_test_trap_assert_failed ();
29476  *     g_test_trap_assert_stderr ("*ERROR*too large*");
29477  *   }
29478  *
29479  *   int
29480  *   main (int argc, char **argv)
29481  *   {
29482  *     g_test_init (&argc, &argv, NULL);
29483  *
29484  *     g_test_add_func ("/myobject/create_large_object",
29485  *                      test_create_large_object);
29486  *     /&ast; Because of the '/subprocess' in the name, this test will
29487  *      &ast; not be run by the g_test_run () call below.
29488  *      &ast;/
29489  *     g_test_add_func ("/myobject/create_large_object/subprocess",
29490  *                      test_create_large_object_subprocess);
29491  *
29492  *     return g_test_run ();
29493  *   }
29494  * ]|
29495  *
29496  * Since: 2.38
29497  */
29498
29499
29500 /**
29501  * g_test_undefined:
29502  *
29503  * Returns %TRUE if tests may provoke assertions and other formally-undefined
29504  * behaviour, to verify that appropriate warnings are given. It might, in some
29505  * cases, be useful to turn this off if running tests under valgrind.
29506  *
29507  * Returns: %TRUE if tests may provoke programming errors
29508  */
29509
29510
29511 /**
29512  * g_test_verbose:
29513  *
29514  * Returns %TRUE if tests are run in verbose mode.
29515  * The default is neither g_test_verbose() nor g_test_quiet().
29516  *
29517  * Returns: %TRUE if in verbose mode
29518  */
29519
29520
29521 /**
29522  * g_thread_exit:
29523  * @retval: the return value of this thread
29524  *
29525  * Terminates the current thread.
29526  *
29527  * If another thread is waiting for us using g_thread_join() then the
29528  * waiting thread will be woken up and get @retval as the return value
29529  * of g_thread_join().
29530  *
29531  * Calling <literal>g_thread_exit (retval)</literal> is equivalent to
29532  * returning @retval from the function @func, as given to g_thread_new().
29533  *
29534  * <note><para>
29535  *   You must only call g_thread_exit() from a thread that you created
29536  *   yourself with g_thread_new() or related APIs.  You must not call
29537  *   this function from a thread created with another threading library
29538  *   or or from within a #GThreadPool.
29539  * </para></note>
29540  */
29541
29542
29543 /**
29544  * g_thread_join:
29545  * @thread: a #GThread
29546  *
29547  * Waits until @thread finishes, i.e. the function @func, as
29548  * given to g_thread_new(), returns or g_thread_exit() is called.
29549  * If @thread has already terminated, then g_thread_join()
29550  * returns immediately.
29551  *
29552  * Any thread can wait for any other thread by calling g_thread_join(),
29553  * not just its 'creator'. Calling g_thread_join() from multiple threads
29554  * for the same @thread leads to undefined behaviour.
29555  *
29556  * The value returned by @func or given to g_thread_exit() is
29557  * returned by this function.
29558  *
29559  * g_thread_join() consumes the reference to the passed-in @thread.
29560  * This will usually cause the #GThread struct and associated resources
29561  * to be freed. Use g_thread_ref() to obtain an extra reference if you
29562  * want to keep the GThread alive beyond the g_thread_join() call.
29563  *
29564  * Returns: the return value of the thread
29565  */
29566
29567
29568 /**
29569  * g_thread_new:
29570  * @name: (allow-none): an (optional) name for the new thread
29571  * @func: a function to execute in the new thread
29572  * @data: an argument to supply to the new thread
29573  *
29574  * This function creates a new thread. The new thread starts by invoking
29575  * @func with the argument data. The thread will run until @func returns
29576  * or until g_thread_exit() is called from the new thread. The return value
29577  * of @func becomes the return value of the thread, which can be obtained
29578  * with g_thread_join().
29579  *
29580  * The @name can be useful for discriminating threads in a debugger.
29581  * It is not used for other purposes and does not have to be unique.
29582  * Some systems restrict the length of @name to 16 bytes.
29583  *
29584  * If the thread can not be created the program aborts. See
29585  * g_thread_try_new() if you want to attempt to deal with failures.
29586  *
29587  * To free the struct returned by this function, use g_thread_unref().
29588  * Note that g_thread_join() implicitly unrefs the #GThread as well.
29589  *
29590  * Returns: the new #GThread
29591  * Since: 2.32
29592  */
29593
29594
29595 /**
29596  * g_thread_pool_free:
29597  * @pool: a #GThreadPool
29598  * @immediate: should @pool shut down immediately?
29599  * @wait_: should the function wait for all tasks to be finished?
29600  *
29601  * Frees all resources allocated for @pool.
29602  *
29603  * If @immediate is %TRUE, no new task is processed for @pool.
29604  * Otherwise @pool is not freed before the last task is processed.
29605  * Note however, that no thread of this pool is interrupted while
29606  * processing a task. Instead at least all still running threads
29607  * can finish their tasks before the @pool is freed.
29608  *
29609  * If @wait_ is %TRUE, the functions does not return before all
29610  * tasks to be processed (dependent on @immediate, whether all
29611  * or only the currently running) are ready.
29612  * Otherwise the function returns immediately.
29613  *
29614  * After calling this function @pool must not be used anymore.
29615  */
29616
29617
29618 /**
29619  * g_thread_pool_get_max_idle_time:
29620  *
29621  * This function will return the maximum @interval that a
29622  * thread will wait in the thread pool for new tasks before
29623  * being stopped.
29624  *
29625  * If this function returns 0, threads waiting in the thread
29626  * pool for new work are not stopped.
29627  *
29628  * Returns: the maximum @interval (milliseconds) to wait
29629  *     for new tasks in the thread pool before stopping the
29630  *     thread
29631  * Since: 2.10
29632  */
29633
29634
29635 /**
29636  * g_thread_pool_get_max_threads:
29637  * @pool: a #GThreadPool
29638  *
29639  * Returns the maximal number of threads for @pool.
29640  *
29641  * Returns: the maximal number of threads
29642  */
29643
29644
29645 /**
29646  * g_thread_pool_get_max_unused_threads:
29647  *
29648  * Returns the maximal allowed number of unused threads.
29649  *
29650  * Returns: the maximal number of unused threads
29651  */
29652
29653
29654 /**
29655  * g_thread_pool_get_num_threads:
29656  * @pool: a #GThreadPool
29657  *
29658  * Returns the number of threads currently running in @pool.
29659  *
29660  * Returns: the number of threads currently running
29661  */
29662
29663
29664 /**
29665  * g_thread_pool_get_num_unused_threads:
29666  *
29667  * Returns the number of currently unused threads.
29668  *
29669  * Returns: the number of currently unused threads
29670  */
29671
29672
29673 /**
29674  * g_thread_pool_new:
29675  * @func: a function to execute in the threads of the new thread pool
29676  * @user_data: user data that is handed over to @func every time it
29677  *     is called
29678  * @max_threads: the maximal number of threads to execute concurrently
29679  *     in  the new thread pool, -1 means no limit
29680  * @exclusive: should this thread pool be exclusive?
29681  * @error: return location for error, or %NULL
29682  *
29683  * This function creates a new thread pool.
29684  *
29685  * Whenever you call g_thread_pool_push(), either a new thread is
29686  * created or an unused one is reused. At most @max_threads threads
29687  * are running concurrently for this thread pool. @max_threads = -1
29688  * allows unlimited threads to be created for this thread pool. The
29689  * newly created or reused thread now executes the function @func
29690  * with the two arguments. The first one is the parameter to
29691  * g_thread_pool_push() and the second one is @user_data.
29692  *
29693  * The parameter @exclusive determines whether the thread pool owns
29694  * all threads exclusive or shares them with other thread pools.
29695  * If @exclusive is %TRUE, @max_threads threads are started
29696  * immediately and they will run exclusively for this thread pool
29697  * until it is destroyed by g_thread_pool_free(). If @exclusive is
29698  * %FALSE, threads are created when needed and shared between all
29699  * non-exclusive thread pools. This implies that @max_threads may
29700  * not be -1 for exclusive thread pools.
29701  *
29702  * @error can be %NULL to ignore errors, or non-%NULL to report
29703  * errors. An error can only occur when @exclusive is set to %TRUE
29704  * and not all @max_threads threads could be created.
29705  *
29706  * Returns: the new #GThreadPool
29707  */
29708
29709
29710 /**
29711  * g_thread_pool_push:
29712  * @pool: a #GThreadPool
29713  * @data: a new task for @pool
29714  * @error: return location for error, or %NULL
29715  *
29716  * Inserts @data into the list of tasks to be executed by @pool.
29717  *
29718  * When the number of currently running threads is lower than the
29719  * maximal allowed number of threads, a new thread is started (or
29720  * reused) with the properties given to g_thread_pool_new().
29721  * Otherwise, @data stays in the queue until a thread in this pool
29722  * finishes its previous task and processes @data.
29723  *
29724  * @error can be %NULL to ignore errors, or non-%NULL to report
29725  * errors. An error can only occur when a new thread couldn't be
29726  * created. In that case @data is simply appended to the queue of
29727  * work to do.
29728  *
29729  * Before version 2.32, this function did not return a success status.
29730  *
29731  * Returns: %TRUE on success, %FALSE if an error occurred
29732  */
29733
29734
29735 /**
29736  * g_thread_pool_set_max_idle_time:
29737  * @interval: the maximum @interval (in milliseconds)
29738  *     a thread can be idle
29739  *
29740  * This function will set the maximum @interval that a thread
29741  * waiting in the pool for new tasks can be idle for before
29742  * being stopped. This function is similar to calling
29743  * g_thread_pool_stop_unused_threads() on a regular timeout,
29744  * except this is done on a per thread basis.
29745  *
29746  * By setting @interval to 0, idle threads will not be stopped.
29747  *
29748  * The default value is 15000 (15 seconds).
29749  *
29750  * Since: 2.10
29751  */
29752
29753
29754 /**
29755  * g_thread_pool_set_max_threads:
29756  * @pool: a #GThreadPool
29757  * @max_threads: a new maximal number of threads for @pool,
29758  *     or -1 for unlimited
29759  * @error: return location for error, or %NULL
29760  *
29761  * Sets the maximal allowed number of threads for @pool.
29762  * A value of -1 means that the maximal number of threads
29763  * is unlimited. If @pool is an exclusive thread pool, setting
29764  * the maximal number of threads to -1 is not allowed.
29765  *
29766  * Setting @max_threads to 0 means stopping all work for @pool.
29767  * It is effectively frozen until @max_threads is set to a non-zero
29768  * value again.
29769  *
29770  * A thread is never terminated while calling @func, as supplied by
29771  * g_thread_pool_new(). Instead the maximal number of threads only
29772  * has effect for the allocation of new threads in g_thread_pool_push().
29773  * A new thread is allocated, whenever the number of currently
29774  * running threads in @pool is smaller than the maximal number.
29775  *
29776  * @error can be %NULL to ignore errors, or non-%NULL to report
29777  * errors. An error can only occur when a new thread couldn't be
29778  * created.
29779  *
29780  * Before version 2.32, this function did not return a success status.
29781  *
29782  * Returns: %TRUE on success, %FALSE if an error occurred
29783  */
29784
29785
29786 /**
29787  * g_thread_pool_set_max_unused_threads:
29788  * @max_threads: maximal number of unused threads
29789  *
29790  * Sets the maximal number of unused threads to @max_threads.
29791  * If @max_threads is -1, no limit is imposed on the number
29792  * of unused threads.
29793  *
29794  * The default value is 2.
29795  */
29796
29797
29798 /**
29799  * g_thread_pool_set_sort_function:
29800  * @pool: a #GThreadPool
29801  * @func: the #GCompareDataFunc used to sort the list of tasks.
29802  *     This function is passed two tasks. It should return
29803  *     0 if the order in which they are handled does not matter,
29804  *     a negative value if the first task should be processed before
29805  *     the second or a positive value if the second task should be
29806  *     processed first.
29807  * @user_data: user data passed to @func
29808  *
29809  * Sets the function used to sort the list of tasks. This allows the
29810  * tasks to be processed by a priority determined by @func, and not
29811  * just in the order in which they were added to the pool.
29812  *
29813  * Note, if the maximum number of threads is more than 1, the order
29814  * that threads are executed cannot be guaranteed 100%. Threads are
29815  * scheduled by the operating system and are executed at random. It
29816  * cannot be assumed that threads are executed in the order they are
29817  * created.
29818  *
29819  * Since: 2.10
29820  */
29821
29822
29823 /**
29824  * g_thread_pool_stop_unused_threads:
29825  *
29826  * Stops all currently unused threads. This does not change the
29827  * maximal number of unused threads. This function can be used to
29828  * regularly stop all unused threads e.g. from g_timeout_add().
29829  */
29830
29831
29832 /**
29833  * g_thread_pool_unprocessed:
29834  * @pool: a #GThreadPool
29835  *
29836  * Returns the number of tasks still unprocessed in @pool.
29837  *
29838  * Returns: the number of unprocessed tasks
29839  */
29840
29841
29842 /**
29843  * g_thread_ref:
29844  * @thread: a #GThread
29845  *
29846  * Increase the reference count on @thread.
29847  *
29848  * Returns: a new reference to @thread
29849  * Since: 2.32
29850  */
29851
29852
29853 /**
29854  * g_thread_self:
29855  *
29856  * This functions returns the #GThread corresponding to the
29857  * current thread. Note that this function does not increase
29858  * the reference count of the returned struct.
29859  *
29860  * This function will return a #GThread even for threads that
29861  * were not created by GLib (i.e. those created by other threading
29862  * APIs). This may be useful for thread identification purposes
29863  * (i.e. comparisons) but you must not use GLib functions (such
29864  * as g_thread_join()) on these threads.
29865  *
29866  * Returns: the #GThread representing the current thread
29867  */
29868
29869
29870 /**
29871  * g_thread_supported:
29872  *
29873  * This macro returns %TRUE if the thread system is initialized,
29874  * and %FALSE if it is not.
29875  *
29876  * For language bindings, g_thread_get_initialized() provides
29877  * the same functionality as a function.
29878  *
29879  * Returns: %TRUE, if the thread system is initialized
29880  */
29881
29882
29883 /**
29884  * g_thread_try_new:
29885  * @name: (allow-none): an (optional) name for the new thread
29886  * @func: a function to execute in the new thread
29887  * @data: an argument to supply to the new thread
29888  * @error: return location for error, or %NULL
29889  *
29890  * This function is the same as g_thread_new() except that
29891  * it allows for the possibility of failure.
29892  *
29893  * If a thread can not be created (due to resource limits),
29894  * @error is set and %NULL is returned.
29895  *
29896  * Returns: the new #GThread, or %NULL if an error occurred
29897  * Since: 2.32
29898  */
29899
29900
29901 /**
29902  * g_thread_unref:
29903  * @thread: a #GThread
29904  *
29905  * Decrease the reference count on @thread, possibly freeing all
29906  * resources associated with it.
29907  *
29908  * Note that each thread holds a reference to its #GThread while
29909  * it is running, so it is safe to drop your own reference to it
29910  * if you don't need it anymore.
29911  *
29912  * Since: 2.32
29913  */
29914
29915
29916 /**
29917  * g_thread_yield:
29918  *
29919  * Causes the calling thread to voluntarily relinquish the CPU, so
29920  * that other threads can run.
29921  *
29922  * This function is often used as a method to make busy wait less evil.
29923  */
29924
29925
29926 /**
29927  * g_time_val_add:
29928  * @time_: a #GTimeVal
29929  * @microseconds: number of microseconds to add to @time
29930  *
29931  * Adds the given number of microseconds to @time_. @microseconds can
29932  * also be negative to decrease the value of @time_.
29933  */
29934
29935
29936 /**
29937  * g_time_val_from_iso8601:
29938  * @iso_date: an ISO 8601 encoded date string
29939  * @time_: (out): a #GTimeVal
29940  *
29941  * Converts a string containing an ISO 8601 encoded date and time
29942  * to a #GTimeVal and puts it into @time_.
29943  *
29944  * @iso_date must include year, month, day, hours, minutes, and
29945  * seconds. It can optionally include fractions of a second and a time
29946  * zone indicator. (In the absence of any time zone indication, the
29947  * timestamp is assumed to be in local time.)
29948  *
29949  * Returns: %TRUE if the conversion was successful.
29950  * Since: 2.12
29951  */
29952
29953
29954 /**
29955  * g_time_val_to_iso8601:
29956  * @time_: a #GTimeVal
29957  *
29958  * Converts @time_ into an RFC 3339 encoded string, relative to the
29959  * Coordinated Universal Time (UTC). This is one of the many formats
29960  * allowed by ISO 8601.
29961  *
29962  * ISO 8601 allows a large number of date/time formats, with or without
29963  * punctuation and optional elements. The format returned by this function
29964  * is a complete date and time, with optional punctuation included, the
29965  * UTC time zone represented as "Z", and the @tv_usec part included if
29966  * and only if it is nonzero, i.e. either
29967  * "YYYY-MM-DDTHH:MM:SSZ" or "YYYY-MM-DDTHH:MM:SS.fffffZ".
29968  *
29969  * This corresponds to the Internet date/time format defined by
29970  * <ulink url="https://www.ietf.org/rfc/rfc3339.txt">RFC 3339</ulink>, and
29971  * to either of the two most-precise formats defined by
29972  * <ulink url="http://www.w3.org/TR/NOTE-datetime-19980827">the W3C Note
29973  * "Date and Time Formats"</ulink>. Both of these documents are profiles of
29974  * ISO 8601.
29975  *
29976  * Use g_date_time_format() or g_strdup_printf() if a different
29977  * variation of ISO 8601 format is required.
29978  *
29979  * Returns: a newly allocated string containing an ISO 8601 date
29980  * Since: 2.12
29981  */
29982
29983
29984 /**
29985  * g_time_zone_adjust_time:
29986  * @tz: a #GTimeZone
29987  * @type: the #GTimeType of @time_
29988  * @time_: a pointer to a number of seconds since January 1, 1970
29989  *
29990  * Finds an interval within @tz that corresponds to the given @time_,
29991  * possibly adjusting @time_ if required to fit into an interval.
29992  * The meaning of @time_ depends on @type.
29993  *
29994  * This function is similar to g_time_zone_find_interval(), with the
29995  * difference that it always succeeds (by making the adjustments
29996  * described below).
29997  *
29998  * In any of the cases where g_time_zone_find_interval() succeeds then
29999  * this function returns the same value, without modifying @time_.
30000  *
30001  * This function may, however, modify @time_ in order to deal with
30002  * non-existent times.  If the non-existent local @time_ of 02:30 were
30003  * requested on March 14th 2010 in Toronto then this function would
30004  * adjust @time_ to be 03:00 and return the interval containing the
30005  * adjusted time.
30006  *
30007  * Returns: the interval containing @time_, never -1
30008  * Since: 2.26
30009  */
30010
30011
30012 /**
30013  * g_time_zone_find_interval:
30014  * @tz: a #GTimeZone
30015  * @type: the #GTimeType of @time_
30016  * @time_: a number of seconds since January 1, 1970
30017  *
30018  * Finds an the interval within @tz that corresponds to the given @time_.
30019  * The meaning of @time_ depends on @type.
30020  *
30021  * If @type is %G_TIME_TYPE_UNIVERSAL then this function will always
30022  * succeed (since universal time is monotonic and continuous).
30023  *
30024  * Otherwise @time_ is treated is local time.  The distinction between
30025  * %G_TIME_TYPE_STANDARD and %G_TIME_TYPE_DAYLIGHT is ignored except in
30026  * the case that the given @time_ is ambiguous.  In Toronto, for example,
30027  * 01:30 on November 7th 2010 occurred twice (once inside of daylight
30028  * savings time and the next, an hour later, outside of daylight savings
30029  * time).  In this case, the different value of @type would result in a
30030  * different interval being returned.
30031  *
30032  * It is still possible for this function to fail.  In Toronto, for
30033  * example, 02:00 on March 14th 2010 does not exist (due to the leap
30034  * forward to begin daylight savings time).  -1 is returned in that
30035  * case.
30036  *
30037  * Returns: the interval containing @time_, or -1 in case of failure
30038  * Since: 2.26
30039  */
30040
30041
30042 /**
30043  * g_time_zone_get_abbreviation:
30044  * @tz: a #GTimeZone
30045  * @interval: an interval within the timezone
30046  *
30047  * Determines the time zone abbreviation to be used during a particular
30048  * @interval of time in the time zone @tz.
30049  *
30050  * For example, in Toronto this is currently "EST" during the winter
30051  * months and "EDT" during the summer months when daylight savings time
30052  * is in effect.
30053  *
30054  * Returns: the time zone abbreviation, which belongs to @tz
30055  * Since: 2.26
30056  */
30057
30058
30059 /**
30060  * g_time_zone_get_offset:
30061  * @tz: a #GTimeZone
30062  * @interval: an interval within the timezone
30063  *
30064  * Determines the offset to UTC in effect during a particular @interval
30065  * of time in the time zone @tz.
30066  *
30067  * The offset is the number of seconds that you add to UTC time to
30068  * arrive at local time for @tz (ie: negative numbers for time zones
30069  * west of GMT, positive numbers for east).
30070  *
30071  * Returns: the number of seconds that should be added to UTC to get the
30072  *          local time in @tz
30073  * Since: 2.26
30074  */
30075
30076
30077 /**
30078  * g_time_zone_is_dst:
30079  * @tz: a #GTimeZone
30080  * @interval: an interval within the timezone
30081  *
30082  * Determines if daylight savings time is in effect during a particular
30083  * @interval of time in the time zone @tz.
30084  *
30085  * Returns: %TRUE if daylight savings time is in effect
30086  * Since: 2.26
30087  */
30088
30089
30090 /**
30091  * g_time_zone_new:
30092  * @identifier: (allow-none): a timezone identifier
30093  *
30094  * Creates a #GTimeZone corresponding to @identifier.
30095  *
30096  * @identifier can either be an RFC3339/ISO 8601 time offset or
30097  * something that would pass as a valid value for the
30098  * <varname>TZ</varname> environment variable (including %NULL).
30099  *
30100  * In Windows, @identifier can also be the unlocalized name of a time
30101  * zone for standard time, for example "Pacific Standard Time".
30102  *
30103  * Valid RFC3339 time offsets are <literal>"Z"</literal> (for UTC) or
30104  * <literal>"±hh:mm"</literal>.  ISO 8601 additionally specifies
30105  * <literal>"±hhmm"</literal> and <literal>"±hh"</literal>.  Offsets are
30106  * time values to be added to Coordinated Universal Time (UTC) to get
30107  * the local time.
30108  *
30109  * In Unix, the <varname>TZ</varname> environment variable typically
30110  * corresponds to the name of a file in the zoneinfo database, or
30111  * string in "std offset [dst [offset],start[/time],end[/time]]"
30112  * (POSIX) format.  There  are  no spaces in the specification.  The
30113  * name of standard and daylight savings time zone must be three or more
30114  * alphabetic characters.  Offsets are time values to be added to local
30115  * time to get Coordinated Universal Time (UTC) and should be
30116  * <literal>"[±]hh[[:]mm[:ss]]"</literal>.  Dates are either
30117  * <literal>"Jn"</literal> (Julian day with n between 1 and 365, leap
30118  * years not counted), <literal>"n"</literal> (zero-based Julian day
30119  * with n between 0 and 365) or <literal>"Mm.w.d"</literal> (day d
30120  * (0 <= d <= 6) of week w (1 <= w <= 5) of month m (1 <= m <= 12), day
30121  * 0 is a Sunday).  Times are in local wall clock time, the default is
30122  * 02:00:00.
30123  *
30124  * In Windows, the "tzn[+|–]hh[:mm[:ss]][dzn]" format is used, but also
30125  * accepts POSIX format.  The Windows format uses US rules for all time
30126  * zones; daylight savings time is 60 minutes behind the standard time
30127  * with date and time of change taken from Pacific Standard Time.
30128  * Offsets are time values to be added to the local time to get
30129  * Coordinated Universal Time (UTC).
30130  *
30131  * g_time_zone_new_local() calls this function with the value of the
30132  * <varname>TZ</varname> environment variable.  This function itself is
30133  * independent of the value of <varname>TZ</varname>, but if @identifier
30134  * is %NULL then <filename>/etc/localtime</filename> will be consulted
30135  * to discover the correct time zone on Unix and the registry will be
30136  * consulted or GetTimeZoneInformation() will be used to get the local
30137  * time zone on Windows.
30138  *
30139  * If intervals are not available, only time zone rules from
30140  * <varname>TZ</varname> environment variable or other means, then they
30141  * will be computed from year 1900 to 2037.  If the maximum year for the
30142  * rules is available and it is greater than 2037, then it will followed
30143  * instead.
30144  *
30145  * See <ulink
30146  * url='http://tools.ietf.org/html/rfc3339#section-5.6'>RFC3339
30147  * Â§5.6</ulink> for a precise definition of valid RFC3339 time offsets
30148  * (the <varname>time-offset</varname> expansion) and ISO 8601 for the
30149  * full list of valid time offsets.  See <ulink
30150  * url='http://www.gnu.org/s/libc/manual/html_node/TZ-Variable.html'>The
30151  * GNU C Library manual</ulink> for an explanation of the possible
30152  * values of the <varname>TZ</varname> environment variable.  See <ulink
30153  * url='http://msdn.microsoft.com/en-us/library/ms912391%28v=winembedded.11%29.aspx'>
30154  * Microsoft Time Zone Index Values</ulink> for the list of time zones
30155  * on Windows.
30156  *
30157  * You should release the return value by calling g_time_zone_unref()
30158  * when you are done with it.
30159  *
30160  * Returns: the requested timezone
30161  * Since: 2.26
30162  */
30163
30164
30165 /**
30166  * g_time_zone_new_local:
30167  *
30168  * Creates a #GTimeZone corresponding to local time.  The local time
30169  * zone may change between invocations to this function; for example,
30170  * if the system administrator changes it.
30171  *
30172  * This is equivalent to calling g_time_zone_new() with the value of the
30173  * <varname>TZ</varname> environment variable (including the possibility
30174  * of %NULL).
30175  *
30176  * You should release the return value by calling g_time_zone_unref()
30177  * when you are done with it.
30178  *
30179  * Returns: the local timezone
30180  * Since: 2.26
30181  */
30182
30183
30184 /**
30185  * g_time_zone_new_utc:
30186  *
30187  * Creates a #GTimeZone corresponding to UTC.
30188  *
30189  * This is equivalent to calling g_time_zone_new() with a value like
30190  * "Z", "UTC", "+00", etc.
30191  *
30192  * You should release the return value by calling g_time_zone_unref()
30193  * when you are done with it.
30194  *
30195  * Returns: the universal timezone
30196  * Since: 2.26
30197  */
30198
30199
30200 /**
30201  * g_time_zone_ref:
30202  * @tz: a #GTimeZone
30203  *
30204  * Increases the reference count on @tz.
30205  *
30206  * Returns: a new reference to @tz.
30207  * Since: 2.26
30208  */
30209
30210
30211 /**
30212  * g_time_zone_unref:
30213  * @tz: a #GTimeZone
30214  *
30215  * Decreases the reference count on @tz.
30216  *
30217  * Since: 2.26
30218  */
30219
30220
30221 /**
30222  * g_timeout_add:
30223  * @interval: the time between calls to the function, in milliseconds
30224  *             (1/1000ths of a second)
30225  * @function: function to call
30226  * @data: data to pass to @function
30227  *
30228  * Sets a function to be called at regular intervals, with the default
30229  * priority, #G_PRIORITY_DEFAULT.  The function is called repeatedly
30230  * until it returns %FALSE, at which point the timeout is automatically
30231  * destroyed and the function will not be called again.  The first call
30232  * to the function will be at the end of the first @interval.
30233  *
30234  * Note that timeout functions may be delayed, due to the processing of other
30235  * event sources. Thus they should not be relied on for precise timing.
30236  * After each call to the timeout function, the time of the next
30237  * timeout is recalculated based on the current time and the given interval
30238  * (it does not try to 'catch up' time lost in delays).
30239  *
30240  * If you want to have a timer in the "seconds" range and do not care
30241  * about the exact time of the first call of the timer, use the
30242  * g_timeout_add_seconds() function; this function allows for more
30243  * optimizations and more efficient system power usage.
30244  *
30245  * This internally creates a main loop source using g_timeout_source_new()
30246  * and attaches it to the main loop context using g_source_attach(). You can
30247  * do these steps manually if you need greater control.
30248  *
30249  * The interval given is in terms of monotonic time, not wall clock
30250  * time.  See g_get_monotonic_time().
30251  *
30252  * Returns: the ID (greater than 0) of the event source.
30253  */
30254
30255
30256 /**
30257  * g_timeout_add_full: (rename-to g_timeout_add)
30258  * @priority: the priority of the timeout source. Typically this will be in
30259  *            the range between #G_PRIORITY_DEFAULT and #G_PRIORITY_HIGH.
30260  * @interval: the time between calls to the function, in milliseconds
30261  *             (1/1000ths of a second)
30262  * @function: function to call
30263  * @data: data to pass to @function
30264  * @notify: (allow-none): function to call when the timeout is removed, or %NULL
30265  *
30266  * Sets a function to be called at regular intervals, with the given
30267  * priority.  The function is called repeatedly until it returns
30268  * %FALSE, at which point the timeout is automatically destroyed and
30269  * the function will not be called again.  The @notify function is
30270  * called when the timeout is destroyed.  The first call to the
30271  * function will be at the end of the first @interval.
30272  *
30273  * Note that timeout functions may be delayed, due to the processing of other
30274  * event sources. Thus they should not be relied on for precise timing.
30275  * After each call to the timeout function, the time of the next
30276  * timeout is recalculated based on the current time and the given interval
30277  * (it does not try to 'catch up' time lost in delays).
30278  *
30279  * This internally creates a main loop source using g_timeout_source_new()
30280  * and attaches it to the main loop context using g_source_attach(). You can
30281  * do these steps manually if you need greater control.
30282  *
30283  * The interval given in terms of monotonic time, not wall clock time.
30284  * See g_get_monotonic_time().
30285  *
30286  * Returns: the ID (greater than 0) of the event source.
30287  */
30288
30289
30290 /**
30291  * g_timeout_add_seconds:
30292  * @interval: the time between calls to the function, in seconds
30293  * @function: function to call
30294  * @data: data to pass to @function
30295  *
30296  * Sets a function to be called at regular intervals with the default
30297  * priority, #G_PRIORITY_DEFAULT. The function is called repeatedly until
30298  * it returns %FALSE, at which point the timeout is automatically destroyed
30299  * and the function will not be called again.
30300  *
30301  * This internally creates a main loop source using
30302  * g_timeout_source_new_seconds() and attaches it to the main loop context
30303  * using g_source_attach(). You can do these steps manually if you need
30304  * greater control. Also see g_timeout_add_seconds_full().
30305  *
30306  * Note that the first call of the timer may not be precise for timeouts
30307  * of one second. If you need finer precision and have such a timeout,
30308  * you may want to use g_timeout_add() instead.
30309  *
30310  * The interval given is in terms of monotonic time, not wall clock
30311  * time.  See g_get_monotonic_time().
30312  *
30313  * Returns: the ID (greater than 0) of the event source.
30314  * Since: 2.14
30315  */
30316
30317
30318 /**
30319  * g_timeout_add_seconds_full: (rename-to g_timeout_add_seconds)
30320  * @priority: the priority of the timeout source. Typically this will be in
30321  *            the range between #G_PRIORITY_DEFAULT and #G_PRIORITY_HIGH.
30322  * @interval: the time between calls to the function, in seconds
30323  * @function: function to call
30324  * @data: data to pass to @function
30325  * @notify: (allow-none): function to call when the timeout is removed, or %NULL
30326  *
30327  * Sets a function to be called at regular intervals, with @priority.
30328  * The function is called repeatedly until it returns %FALSE, at which
30329  * point the timeout is automatically destroyed and the function will
30330  * not be called again.
30331  *
30332  * Unlike g_timeout_add(), this function operates at whole second granularity.
30333  * The initial starting point of the timer is determined by the implementation
30334  * and the implementation is expected to group multiple timers together so that
30335  * they fire all at the same time.
30336  * To allow this grouping, the @interval to the first timer is rounded
30337  * and can deviate up to one second from the specified interval.
30338  * Subsequent timer iterations will generally run at the specified interval.
30339  *
30340  * Note that timeout functions may be delayed, due to the processing of other
30341  * event sources. Thus they should not be relied on for precise timing.
30342  * After each call to the timeout function, the time of the next
30343  * timeout is recalculated based on the current time and the given @interval
30344  *
30345  * If you want timing more precise than whole seconds, use g_timeout_add()
30346  * instead.
30347  *
30348  * The grouping of timers to fire at the same time results in a more power
30349  * and CPU efficient behavior so if your timer is in multiples of seconds
30350  * and you don't require the first timer exactly one second from now, the
30351  * use of g_timeout_add_seconds() is preferred over g_timeout_add().
30352  *
30353  * This internally creates a main loop source using
30354  * g_timeout_source_new_seconds() and attaches it to the main loop context
30355  * using g_source_attach(). You can do these steps manually if you need
30356  * greater control.
30357  *
30358  * The interval given is in terms of monotonic time, not wall clock
30359  * time.  See g_get_monotonic_time().
30360  *
30361  * Returns: the ID (greater than 0) of the event source.
30362  * Since: 2.14
30363  */
30364
30365
30366 /**
30367  * g_timeout_source_new:
30368  * @interval: the timeout interval in milliseconds.
30369  *
30370  * Creates a new timeout source.
30371  *
30372  * The source will not initially be associated with any #GMainContext
30373  * and must be added to one with g_source_attach() before it will be
30374  * executed.
30375  *
30376  * The interval given is in terms of monotonic time, not wall clock
30377  * time.  See g_get_monotonic_time().
30378  *
30379  * Returns: the newly-created timeout source
30380  */
30381
30382
30383 /**
30384  * g_timeout_source_new_seconds:
30385  * @interval: the timeout interval in seconds
30386  *
30387  * Creates a new timeout source.
30388  *
30389  * The source will not initially be associated with any #GMainContext
30390  * and must be added to one with g_source_attach() before it will be
30391  * executed.
30392  *
30393  * The scheduling granularity/accuracy of this timeout source will be
30394  * in seconds.
30395  *
30396  * The interval given in terms of monotonic time, not wall clock time.
30397  * See g_get_monotonic_time().
30398  *
30399  * Returns: the newly-created timeout source
30400  * Since: 2.14
30401  */
30402
30403
30404 /**
30405  * g_timer_continue:
30406  * @timer: a #GTimer.
30407  *
30408  * Resumes a timer that has previously been stopped with
30409  * g_timer_stop(). g_timer_stop() must be called before using this
30410  * function.
30411  *
30412  * Since: 2.4
30413  */
30414
30415
30416 /**
30417  * g_timer_destroy:
30418  * @timer: a #GTimer to destroy.
30419  *
30420  * Destroys a timer, freeing associated resources.
30421  */
30422
30423
30424 /**
30425  * g_timer_elapsed:
30426  * @timer: a #GTimer.
30427  * @microseconds: return location for the fractional part of seconds
30428  *                elapsed, in microseconds (that is, the total number
30429  *                of microseconds elapsed, modulo 1000000), or %NULL
30430  *
30431  * If @timer has been started but not stopped, obtains the time since
30432  * the timer was started. If @timer has been stopped, obtains the
30433  * elapsed time between the time it was started and the time it was
30434  * stopped. The return value is the number of seconds elapsed,
30435  * including any fractional part. The @microseconds out parameter is
30436  * essentially useless.
30437  *
30438  * Returns: seconds elapsed as a floating point value, including any
30439  *          fractional part.
30440  */
30441
30442
30443 /**
30444  * g_timer_new:
30445  *
30446  * Creates a new timer, and starts timing (i.e. g_timer_start() is
30447  * implicitly called for you).
30448  *
30449  * Returns: a new #GTimer.
30450  */
30451
30452
30453 /**
30454  * g_timer_reset:
30455  * @timer: a #GTimer.
30456  *
30457  * This function is useless; it's fine to call g_timer_start() on an
30458  * already-started timer to reset the start time, so g_timer_reset()
30459  * serves no purpose.
30460  */
30461
30462
30463 /**
30464  * g_timer_start:
30465  * @timer: a #GTimer.
30466  *
30467  * Marks a start time, so that future calls to g_timer_elapsed() will
30468  * report the time since g_timer_start() was called. g_timer_new()
30469  * automatically marks the start time, so no need to call
30470  * g_timer_start() immediately after creating the timer.
30471  */
30472
30473
30474 /**
30475  * g_timer_stop:
30476  * @timer: a #GTimer.
30477  *
30478  * Marks an end time, so calls to g_timer_elapsed() will return the
30479  * difference between this end time and the start time.
30480  */
30481
30482
30483 /**
30484  * g_trash_stack_height:
30485  * @stack_p: a #GTrashStack
30486  *
30487  * Returns the height of a #GTrashStack.
30488  *
30489  * Note that execution of this function is of O(N) complexity
30490  * where N denotes the number of items on the stack.
30491  *
30492  * Returns: the height of the stack
30493  */
30494
30495
30496 /**
30497  * g_trash_stack_peek:
30498  * @stack_p: a #GTrashStack
30499  *
30500  * Returns the element at the top of a #GTrashStack
30501  * which may be %NULL.
30502  *
30503  * Returns: the element at the top of the stack
30504  */
30505
30506
30507 /**
30508  * g_trash_stack_pop:
30509  * @stack_p: a #GTrashStack
30510  *
30511  * Pops a piece of memory off a #GTrashStack.
30512  *
30513  * Returns: the element at the top of the stack
30514  */
30515
30516
30517 /**
30518  * g_trash_stack_push:
30519  * @stack_p: a #GTrashStack
30520  * @data_p: the piece of memory to push on the stack
30521  *
30522  * Pushes a piece of memory onto a #GTrashStack.
30523  */
30524
30525
30526 /**
30527  * g_tree_destroy:
30528  * @tree: a #GTree.
30529  *
30530  * Removes all keys and values from the #GTree and decreases its
30531  * reference count by one. If keys and/or values are dynamically
30532  * allocated, you should either free them first or create the #GTree
30533  * using g_tree_new_full().  In the latter case the destroy functions
30534  * you supplied will be called on all keys and values before destroying
30535  * the #GTree.
30536  */
30537
30538
30539 /**
30540  * g_tree_foreach:
30541  * @tree: a #GTree.
30542  * @func: the function to call for each node visited.
30543  *     If this function returns %TRUE, the traversal is stopped.
30544  * @user_data: user data to pass to the function.
30545  *
30546  * Calls the given function for each of the key/value pairs in the #GTree.
30547  * The function is passed the key and value of each pair, and the given
30548  * @data parameter. The tree is traversed in sorted order.
30549  *
30550  * The tree may not be modified while iterating over it (you can't
30551  * add/remove items). To remove all items matching a predicate, you need
30552  * to add each item to a list in your #GTraverseFunc as you walk over
30553  * the tree, then walk the list and remove each item.
30554  */
30555
30556
30557 /**
30558  * g_tree_height:
30559  * @tree: a #GTree.
30560  *
30561  * Gets the height of a #GTree.
30562  *
30563  * If the #GTree contains no nodes, the height is 0.
30564  * If the #GTree contains only one root node the height is 1.
30565  * If the root node has children the height is 2, etc.
30566  *
30567  * Returns: the height of the #GTree.
30568  */
30569
30570
30571 /**
30572  * g_tree_insert:
30573  * @tree: a #GTree.
30574  * @key: the key to insert.
30575  * @value: the value corresponding to the key.
30576  *
30577  * Inserts a key/value pair into a #GTree. If the given key already exists
30578  * in the #GTree its corresponding value is set to the new value. If you
30579  * supplied a value_destroy_func when creating the #GTree, the old value is
30580  * freed using that function. If you supplied a @key_destroy_func when
30581  * creating the #GTree, the passed key is freed using that function.
30582  *
30583  * The tree is automatically 'balanced' as new key/value pairs are added,
30584  * so that the distance from the root to every leaf is as small as possible.
30585  */
30586
30587
30588 /**
30589  * g_tree_lookup:
30590  * @tree: a #GTree.
30591  * @key: the key to look up.
30592  *
30593  * Gets the value corresponding to the given key. Since a #GTree is
30594  * automatically balanced as key/value pairs are added, key lookup is very
30595  * fast.
30596  *
30597  * Returns: the value corresponding to the key, or %NULL if the key was
30598  * not found.
30599  */
30600
30601
30602 /**
30603  * g_tree_lookup_extended:
30604  * @tree: a #GTree.
30605  * @lookup_key: the key to look up.
30606  * @orig_key: returns the original key.
30607  * @value: returns the value associated with the key.
30608  *
30609  * Looks up a key in the #GTree, returning the original key and the
30610  * associated value and a #gboolean which is %TRUE if the key was found. This
30611  * is useful if you need to free the memory allocated for the original key,
30612  * for example before calling g_tree_remove().
30613  *
30614  * Returns: %TRUE if the key was found in the #GTree.
30615  */
30616
30617
30618 /**
30619  * g_tree_new:
30620  * @key_compare_func: the function used to order the nodes in the #GTree.
30621  *   It should return values similar to the standard strcmp() function -
30622  *   0 if the two arguments are equal, a negative value if the first argument
30623  *   comes before the second, or a positive value if the first argument comes
30624  *   after the second.
30625  *
30626  * Creates a new #GTree.
30627  *
30628  * Returns: a new #GTree.
30629  */
30630
30631
30632 /**
30633  * g_tree_new_full:
30634  * @key_compare_func: qsort()-style comparison function.
30635  * @key_compare_data: data to pass to comparison function.
30636  * @key_destroy_func: a function to free the memory allocated for the key
30637  *   used when removing the entry from the #GTree or %NULL if you don't
30638  *   want to supply such a function.
30639  * @value_destroy_func: a function to free the memory allocated for the
30640  *   value used when removing the entry from the #GTree or %NULL if you
30641  *   don't want to supply such a function.
30642  *
30643  * Creates a new #GTree like g_tree_new() and allows to specify functions
30644  * to free the memory allocated for the key and value that get called when
30645  * removing the entry from the #GTree.
30646  *
30647  * Returns: a new #GTree.
30648  */
30649
30650
30651 /**
30652  * g_tree_new_with_data:
30653  * @key_compare_func: qsort()-style comparison function.
30654  * @key_compare_data: data to pass to comparison function.
30655  *
30656  * Creates a new #GTree with a comparison function that accepts user data.
30657  * See g_tree_new() for more details.
30658  *
30659  * Returns: a new #GTree.
30660  */
30661
30662
30663 /**
30664  * g_tree_nnodes:
30665  * @tree: a #GTree.
30666  *
30667  * Gets the number of nodes in a #GTree.
30668  *
30669  * Returns: the number of nodes in the #GTree.
30670  */
30671
30672
30673 /**
30674  * g_tree_ref:
30675  * @tree: a #GTree.
30676  *
30677  * Increments the reference count of @tree by one.  It is safe to call
30678  * this function from any thread.
30679  *
30680  * Returns: the passed in #GTree.
30681  * Since: 2.22
30682  */
30683
30684
30685 /**
30686  * g_tree_remove:
30687  * @tree: a #GTree.
30688  * @key: the key to remove.
30689  *
30690  * Removes a key/value pair from a #GTree.
30691  *
30692  * If the #GTree was created using g_tree_new_full(), the key and value
30693  * are freed using the supplied destroy functions, otherwise you have to
30694  * make sure that any dynamically allocated values are freed yourself.
30695  * If the key does not exist in the #GTree, the function does nothing.
30696  *
30697  * Returns: %TRUE if the key was found (prior to 2.8, this function returned
30698  *   nothing)
30699  */
30700
30701
30702 /**
30703  * g_tree_replace:
30704  * @tree: a #GTree.
30705  * @key: the key to insert.
30706  * @value: the value corresponding to the key.
30707  *
30708  * Inserts a new key and value into a #GTree similar to g_tree_insert().
30709  * The difference is that if the key already exists in the #GTree, it gets
30710  * replaced by the new key. If you supplied a @value_destroy_func when
30711  * creating the #GTree, the old value is freed using that function. If you
30712  * supplied a @key_destroy_func when creating the #GTree, the old key is
30713  * freed using that function.
30714  *
30715  * The tree is automatically 'balanced' as new key/value pairs are added,
30716  * so that the distance from the root to every leaf is as small as possible.
30717  */
30718
30719
30720 /**
30721  * g_tree_search:
30722  * @tree: a #GTree
30723  * @search_func: a function used to search the #GTree
30724  * @user_data: the data passed as the second argument to @search_func
30725  *
30726  * Searches a #GTree using @search_func.
30727  *
30728  * The @search_func is called with a pointer to the key of a key/value
30729  * pair in the tree, and the passed in @user_data. If @search_func returns
30730  * 0 for a key/value pair, then the corresponding value is returned as
30731  * the result of g_tree_search(). If @search_func returns -1, searching
30732  * will proceed among the key/value pairs that have a smaller key; if
30733  * @search_func returns 1, searching will proceed among the key/value
30734  * pairs that have a larger key.
30735  *
30736  * Returns: the value corresponding to the found key, or %NULL if
30737  * the key was not found.
30738  */
30739
30740
30741 /**
30742  * g_tree_steal:
30743  * @tree: a #GTree.
30744  * @key: the key to remove.
30745  *
30746  * Removes a key and its associated value from a #GTree without calling
30747  * the key and value destroy functions.
30748  *
30749  * If the key does not exist in the #GTree, the function does nothing.
30750  *
30751  * Returns: %TRUE if the key was found (prior to 2.8, this function returned
30752  *    nothing)
30753  */
30754
30755
30756 /**
30757  * g_tree_traverse:
30758  * @tree: a #GTree.
30759  * @traverse_func: the function to call for each node visited. If this
30760  *   function returns %TRUE, the traversal is stopped.
30761  * @traverse_type: the order in which nodes are visited, one of %G_IN_ORDER,
30762  *   %G_PRE_ORDER and %G_POST_ORDER.
30763  * @user_data: user data to pass to the function.
30764  *
30765  * Calls the given function for each node in the #GTree.
30766  *
30767  * Deprecated: 2.2: The order of a balanced tree is somewhat arbitrary. If you
30768  * just want to visit all nodes in sorted order, use g_tree_foreach()
30769  * instead. If you really need to visit nodes in a different order, consider
30770  * using an <link linkend="glib-N-ary-Trees">N-ary Tree</link>.
30771  */
30772
30773
30774 /**
30775  * g_tree_unref:
30776  * @tree: a #GTree.
30777  *
30778  * Decrements the reference count of @tree by one.  If the reference count
30779  * drops to 0, all keys and values will be destroyed (if destroy
30780  * functions were specified) and all memory allocated by @tree will be
30781  * released.
30782  *
30783  * It is safe to call this function from any thread.
30784  *
30785  * Since: 2.22
30786  */
30787
30788
30789 /**
30790  * g_try_malloc:
30791  * @n_bytes: number of bytes to allocate.
30792  *
30793  * Attempts to allocate @n_bytes, and returns %NULL on failure.
30794  * Contrast with g_malloc(), which aborts the program on failure.
30795  *
30796  * Returns: the allocated memory, or %NULL.
30797  */
30798
30799
30800 /**
30801  * g_try_malloc0:
30802  * @n_bytes: number of bytes to allocate
30803  *
30804  * Attempts to allocate @n_bytes, initialized to 0's, and returns %NULL on
30805  * failure. Contrast with g_malloc0(), which aborts the program on failure.
30806  *
30807  * Since: 2.8
30808  * Returns: the allocated memory, or %NULL
30809  */
30810
30811
30812 /**
30813  * g_try_malloc0_n:
30814  * @n_blocks: the number of blocks to allocate
30815  * @n_block_bytes: the size of each block in bytes
30816  *
30817  * This function is similar to g_try_malloc0(), allocating (@n_blocks * @n_block_bytes) bytes,
30818  * but care is taken to detect possible overflow during multiplication.
30819  *
30820  * Since: 2.24
30821  * Returns: the allocated memory, or %NULL
30822  */
30823
30824
30825 /**
30826  * g_try_malloc_n:
30827  * @n_blocks: the number of blocks to allocate
30828  * @n_block_bytes: the size of each block in bytes
30829  *
30830  * This function is similar to g_try_malloc(), allocating (@n_blocks * @n_block_bytes) bytes,
30831  * but care is taken to detect possible overflow during multiplication.
30832  *
30833  * Since: 2.24
30834  * Returns: the allocated memory, or %NULL.
30835  */
30836
30837
30838 /**
30839  * g_try_realloc:
30840  * @mem: (allow-none): previously-allocated memory, or %NULL.
30841  * @n_bytes: number of bytes to allocate.
30842  *
30843  * Attempts to realloc @mem to a new size, @n_bytes, and returns %NULL
30844  * on failure. Contrast with g_realloc(), which aborts the program
30845  * on failure. If @mem is %NULL, behaves the same as g_try_malloc().
30846  *
30847  * Returns: the allocated memory, or %NULL.
30848  */
30849
30850
30851 /**
30852  * g_try_realloc_n:
30853  * @mem: (allow-none): previously-allocated memory, or %NULL.
30854  * @n_blocks: the number of blocks to allocate
30855  * @n_block_bytes: the size of each block in bytes
30856  *
30857  * This function is similar to g_try_realloc(), allocating (@n_blocks * @n_block_bytes) bytes,
30858  * but care is taken to detect possible overflow during multiplication.
30859  *
30860  * Since: 2.24
30861  * Returns: the allocated memory, or %NULL.
30862  */
30863
30864
30865 /**
30866  * g_ucs4_to_utf16:
30867  * @str: a UCS-4 encoded string
30868  * @len: the maximum length (number of characters) of @str to use.
30869  *       If @len < 0, then the string is nul-terminated.
30870  * @items_read: (allow-none): location to store number of bytes read, or %NULL.
30871  *              If an error occurs then the index of the invalid input
30872  *              is stored here.
30873  * @items_written: (allow-none): location to store number of <type>gunichar2</type>
30874  *                 written, or %NULL. The value stored here does not
30875  *                 include the trailing 0.
30876  * @error: location to store the error occurring, or %NULL to ignore
30877  *         errors. Any of the errors in #GConvertError other than
30878  *         %G_CONVERT_ERROR_NO_CONVERSION may occur.
30879  *
30880  * Convert a string from UCS-4 to UTF-16. A 0 character will be
30881  * added to the result after the converted text.
30882  *
30883  * Returns: a pointer to a newly allocated UTF-16 string.
30884  *               This value must be freed with g_free(). If an
30885  *               error occurs, %NULL will be returned and
30886  *               @error set.
30887  */
30888
30889
30890 /**
30891  * g_ucs4_to_utf8:
30892  * @str: a UCS-4 encoded string
30893  * @len: the maximum length (number of characters) of @str to use.
30894  *       If @len < 0, then the string is nul-terminated.
30895  * @items_read: (allow-none): location to store number of characters read, or %NULL.
30896  * @items_written: (allow-none): location to store number of bytes written or %NULL.
30897  *                 The value here stored does not include the trailing 0
30898  *                 byte.
30899  * @error: location to store the error occurring, or %NULL to ignore
30900  *         errors. Any of the errors in #GConvertError other than
30901  *         %G_CONVERT_ERROR_NO_CONVERSION may occur.
30902  *
30903  * Convert a string from a 32-bit fixed width representation as UCS-4.
30904  * to UTF-8. The result will be terminated with a 0 byte.
30905  *
30906  * Returns: a pointer to a newly allocated UTF-8 string.
30907  *               This value must be freed with g_free(). If an
30908  *               error occurs, %NULL will be returned and
30909  *               @error set. In that case, @items_read will be
30910  *               set to the position of the first invalid input
30911  *               character.
30912  */
30913
30914
30915 /**
30916  * g_unichar_break_type:
30917  * @c: a Unicode character
30918  *
30919  * Determines the break type of @c. @c should be a Unicode character
30920  * (to derive a character from UTF-8 encoded text, use
30921  * g_utf8_get_char()). The break type is used to find word and line
30922  * breaks ("text boundaries"), Pango implements the Unicode boundary
30923  * resolution algorithms and normally you would use a function such
30924  * as pango_break() instead of caring about break types yourself.
30925  *
30926  * Returns: the break type of @c
30927  */
30928
30929
30930 /**
30931  * g_unichar_combining_class:
30932  * @uc: a Unicode character
30933  *
30934  * Determines the canonical combining class of a Unicode character.
30935  *
30936  * Returns: the combining class of the character
30937  * Since: 2.14
30938  */
30939
30940
30941 /**
30942  * g_unichar_compose:
30943  * @a: a Unicode character
30944  * @b: a Unicode character
30945  * @ch: return location for the composed character
30946  *
30947  * Performs a single composition step of the
30948  * Unicode canonical composition algorithm.
30949  *
30950  * This function includes algorithmic Hangul Jamo composition,
30951  * but it is not exactly the inverse of g_unichar_decompose().
30952  * No composition can have either of @a or @b equal to zero.
30953  * To be precise, this function composes if and only if
30954  * there exists a Primary Composite P which is canonically
30955  * equivalent to the sequence <@a,@b>.  See the Unicode
30956  * Standard for the definition of Primary Composite.
30957  *
30958  * If @a and @b do not compose a new character, @ch is set to zero.
30959  *
30960  * See <ulink url="http://unicode.org/reports/tr15/">UAX#15</ulink>
30961  * for details.
30962  *
30963  * Returns: %TRUE if the characters could be composed
30964  * Since: 2.30
30965  */
30966
30967
30968 /**
30969  * g_unichar_decompose:
30970  * @ch: a Unicode character
30971  * @a: return location for the first component of @ch
30972  * @b: return location for the second component of @ch
30973  *
30974  * Performs a single decomposition step of the
30975  * Unicode canonical decomposition algorithm.
30976  *
30977  * This function does not include compatibility
30978  * decompositions. It does, however, include algorithmic
30979  * Hangul Jamo decomposition, as well as 'singleton'
30980  * decompositions which replace a character by a single
30981  * other character. In the case of singletons *@b will
30982  * be set to zero.
30983  *
30984  * If @ch is not decomposable, *@a is set to @ch and *@b
30985  * is set to zero.
30986  *
30987  * Note that the way Unicode decomposition pairs are
30988  * defined, it is guaranteed that @b would not decompose
30989  * further, but @a may itself decompose.  To get the full
30990  * canonical decomposition for @ch, one would need to
30991  * recursively call this function on @a.  Or use
30992  * g_unichar_fully_decompose().
30993  *
30994  * See <ulink url="http://unicode.org/reports/tr15/">UAX#15</ulink>
30995  * for details.
30996  *
30997  * Returns: %TRUE if the character could be decomposed
30998  * Since: 2.30
30999  */
31000
31001
31002 /**
31003  * g_unichar_digit_value:
31004  * @c: a Unicode character
31005  *
31006  * Determines the numeric value of a character as a decimal
31007  * digit.
31008  *
31009  * Returns: If @c is a decimal digit (according to
31010  * g_unichar_isdigit()), its numeric value. Otherwise, -1.
31011  */
31012
31013
31014 /**
31015  * g_unichar_fully_decompose:
31016  * @ch: a Unicode character.
31017  * @compat: whether perform canonical or compatibility decomposition
31018  * @result: (allow-none): location to store decomposed result, or %NULL
31019  * @result_len: length of @result
31020  *
31021  * Computes the canonical or compatibility decomposition of a
31022  * Unicode character.  For compatibility decomposition,
31023  * pass %TRUE for @compat; for canonical decomposition
31024  * pass %FALSE for @compat.
31025  *
31026  * The decomposed sequence is placed in @result.  Only up to
31027  * @result_len characters are written into @result.  The length
31028  * of the full decomposition (irrespective of @result_len) is
31029  * returned by the function.  For canonical decomposition,
31030  * currently all decompositions are of length at most 4, but
31031  * this may change in the future (very unlikely though).
31032  * At any rate, Unicode does guarantee that a buffer of length
31033  * 18 is always enough for both compatibility and canonical
31034  * decompositions, so that is the size recommended. This is provided
31035  * as %G_UNICHAR_MAX_DECOMPOSITION_LENGTH.
31036  *
31037  * See <ulink url="http://unicode.org/reports/tr15/">UAX#15</ulink>
31038  * for details.
31039  *
31040  * Returns: the length of the full decomposition.
31041  * Since: 2.30
31042  */
31043
31044
31045 /**
31046  * g_unichar_get_mirror_char:
31047  * @ch: a Unicode character
31048  * @mirrored_ch: location to store the mirrored character
31049  *
31050  * In Unicode, some characters are <firstterm>mirrored</firstterm>. This
31051  * means that their images are mirrored horizontally in text that is laid
31052  * out from right to left. For instance, "(" would become its mirror image,
31053  * ")", in right-to-left text.
31054  *
31055  * If @ch has the Unicode mirrored property and there is another unicode
31056  * character that typically has a glyph that is the mirror image of @ch's
31057  * glyph and @mirrored_ch is set, it puts that character in the address
31058  * pointed to by @mirrored_ch.  Otherwise the original character is put.
31059  *
31060  * Returns: %TRUE if @ch has a mirrored character, %FALSE otherwise
31061  * Since: 2.4
31062  */
31063
31064
31065 /**
31066  * g_unichar_get_script:
31067  * @ch: a Unicode character
31068  *
31069  * Looks up the #GUnicodeScript for a particular character (as defined
31070  * by Unicode Standard Annex \#24). No check is made for @ch being a
31071  * valid Unicode character; if you pass in invalid character, the
31072  * result is undefined.
31073  *
31074  * This function is equivalent to pango_script_for_unichar() and the
31075  * two are interchangeable.
31076  *
31077  * Returns: the #GUnicodeScript for the character.
31078  * Since: 2.14
31079  */
31080
31081
31082 /**
31083  * g_unichar_isalnum:
31084  * @c: a Unicode character
31085  *
31086  * Determines whether a character is alphanumeric.
31087  * Given some UTF-8 text, obtain a character value
31088  * with g_utf8_get_char().
31089  *
31090  * Returns: %TRUE if @c is an alphanumeric character
31091  */
31092
31093
31094 /**
31095  * g_unichar_isalpha:
31096  * @c: a Unicode character
31097  *
31098  * Determines whether a character is alphabetic (i.e. a letter).
31099  * Given some UTF-8 text, obtain a character value with
31100  * g_utf8_get_char().
31101  *
31102  * Returns: %TRUE if @c is an alphabetic character
31103  */
31104
31105
31106 /**
31107  * g_unichar_iscntrl:
31108  * @c: a Unicode character
31109  *
31110  * Determines whether a character is a control character.
31111  * Given some UTF-8 text, obtain a character value with
31112  * g_utf8_get_char().
31113  *
31114  * Returns: %TRUE if @c is a control character
31115  */
31116
31117
31118 /**
31119  * g_unichar_isdefined:
31120  * @c: a Unicode character
31121  *
31122  * Determines if a given character is assigned in the Unicode
31123  * standard.
31124  *
31125  * Returns: %TRUE if the character has an assigned value
31126  */
31127
31128
31129 /**
31130  * g_unichar_isdigit:
31131  * @c: a Unicode character
31132  *
31133  * Determines whether a character is numeric (i.e. a digit).  This
31134  * covers ASCII 0-9 and also digits in other languages/scripts.  Given
31135  * some UTF-8 text, obtain a character value with g_utf8_get_char().
31136  *
31137  * Returns: %TRUE if @c is a digit
31138  */
31139
31140
31141 /**
31142  * g_unichar_isgraph:
31143  * @c: a Unicode character
31144  *
31145  * Determines whether a character is printable and not a space
31146  * (returns %FALSE for control characters, format characters, and
31147  * spaces). g_unichar_isprint() is similar, but returns %TRUE for
31148  * spaces. Given some UTF-8 text, obtain a character value with
31149  * g_utf8_get_char().
31150  *
31151  * Returns: %TRUE if @c is printable unless it's a space
31152  */
31153
31154
31155 /**
31156  * g_unichar_islower:
31157  * @c: a Unicode character
31158  *
31159  * Determines whether a character is a lowercase letter.
31160  * Given some UTF-8 text, obtain a character value with
31161  * g_utf8_get_char().
31162  *
31163  * Returns: %TRUE if @c is a lowercase letter
31164  */
31165
31166
31167 /**
31168  * g_unichar_ismark:
31169  * @c: a Unicode character
31170  *
31171  * Determines whether a character is a mark (non-spacing mark,
31172  * combining mark, or enclosing mark in Unicode speak).
31173  * Given some UTF-8 text, obtain a character value
31174  * with g_utf8_get_char().
31175  *
31176  * Note: in most cases where isalpha characters are allowed,
31177  * ismark characters should be allowed to as they are essential
31178  * for writing most European languages as well as many non-Latin
31179  * scripts.
31180  *
31181  * Returns: %TRUE if @c is a mark character
31182  * Since: 2.14
31183  */
31184
31185
31186 /**
31187  * g_unichar_isprint:
31188  * @c: a Unicode character
31189  *
31190  * Determines whether a character is printable.
31191  * Unlike g_unichar_isgraph(), returns %TRUE for spaces.
31192  * Given some UTF-8 text, obtain a character value with
31193  * g_utf8_get_char().
31194  *
31195  * Returns: %TRUE if @c is printable
31196  */
31197
31198
31199 /**
31200  * g_unichar_ispunct:
31201  * @c: a Unicode character
31202  *
31203  * Determines whether a character is punctuation or a symbol.
31204  * Given some UTF-8 text, obtain a character value with
31205  * g_utf8_get_char().
31206  *
31207  * Returns: %TRUE if @c is a punctuation or symbol character
31208  */
31209
31210
31211 /**
31212  * g_unichar_isspace:
31213  * @c: a Unicode character
31214  *
31215  * Determines whether a character is a space, tab, or line separator
31216  * (newline, carriage return, etc.).  Given some UTF-8 text, obtain a
31217  * character value with g_utf8_get_char().
31218  *
31219  * (Note: don't use this to do word breaking; you have to use
31220  * Pango or equivalent to get word breaking right, the algorithm
31221  * is fairly complex.)
31222  *
31223  * Returns: %TRUE if @c is a space character
31224  */
31225
31226
31227 /**
31228  * g_unichar_istitle:
31229  * @c: a Unicode character
31230  *
31231  * Determines if a character is titlecase. Some characters in
31232  * Unicode which are composites, such as the DZ digraph
31233  * have three case variants instead of just two. The titlecase
31234  * form is used at the beginning of a word where only the
31235  * first letter is capitalized. The titlecase form of the DZ
31236  * digraph is U+01F2 LATIN CAPITAL LETTTER D WITH SMALL LETTER Z.
31237  *
31238  * Returns: %TRUE if the character is titlecase
31239  */
31240
31241
31242 /**
31243  * g_unichar_isupper:
31244  * @c: a Unicode character
31245  *
31246  * Determines if a character is uppercase.
31247  *
31248  * Returns: %TRUE if @c is an uppercase character
31249  */
31250
31251
31252 /**
31253  * g_unichar_iswide:
31254  * @c: a Unicode character
31255  *
31256  * Determines if a character is typically rendered in a double-width
31257  * cell.
31258  *
31259  * Returns: %TRUE if the character is wide
31260  */
31261
31262
31263 /**
31264  * g_unichar_iswide_cjk:
31265  * @c: a Unicode character
31266  *
31267  * Determines if a character is typically rendered in a double-width
31268  * cell under legacy East Asian locales.  If a character is wide according to
31269  * g_unichar_iswide(), then it is also reported wide with this function, but
31270  * the converse is not necessarily true.  See the
31271  * <ulink url="http://www.unicode.org/reports/tr11/">Unicode Standard
31272  * Annex #11</ulink> for details.
31273  *
31274  * If a character passes the g_unichar_iswide() test then it will also pass
31275  * this test, but not the other way around.  Note that some characters may
31276  * pas both this test and g_unichar_iszerowidth().
31277  *
31278  * Returns: %TRUE if the character is wide in legacy East Asian locales
31279  * Since: 2.12
31280  */
31281
31282
31283 /**
31284  * g_unichar_isxdigit:
31285  * @c: a Unicode character.
31286  *
31287  * Determines if a character is a hexidecimal digit.
31288  *
31289  * Returns: %TRUE if the character is a hexadecimal digit
31290  */
31291
31292
31293 /**
31294  * g_unichar_iszerowidth:
31295  * @c: a Unicode character
31296  *
31297  * Determines if a given character typically takes zero width when rendered.
31298  * The return value is %TRUE for all non-spacing and enclosing marks
31299  * (e.g., combining accents), format characters, zero-width
31300  * space, but not U+00AD SOFT HYPHEN.
31301  *
31302  * A typical use of this function is with one of g_unichar_iswide() or
31303  * g_unichar_iswide_cjk() to determine the number of cells a string occupies
31304  * when displayed on a grid display (terminals).  However, note that not all
31305  * terminals support zero-width rendering of zero-width marks.
31306  *
31307  * Returns: %TRUE if the character has zero width
31308  * Since: 2.14
31309  */
31310
31311
31312 /**
31313  * g_unichar_to_utf8:
31314  * @c: a Unicode character code
31315  * @outbuf: output buffer, must have at least 6 bytes of space.
31316  *       If %NULL, the length will be computed and returned
31317  *       and nothing will be written to @outbuf.
31318  *
31319  * Converts a single character to UTF-8.
31320  *
31321  * Returns: number of bytes written
31322  */
31323
31324
31325 /**
31326  * g_unichar_tolower:
31327  * @c: a Unicode character.
31328  *
31329  * Converts a character to lower case.
31330  *
31331  * Returns: the result of converting @c to lower case.
31332  *               If @c is not an upperlower or titlecase character,
31333  *               or has no lowercase equivalent @c is returned unchanged.
31334  */
31335
31336
31337 /**
31338  * g_unichar_totitle:
31339  * @c: a Unicode character
31340  *
31341  * Converts a character to the titlecase.
31342  *
31343  * Returns: the result of converting @c to titlecase.
31344  *               If @c is not an uppercase or lowercase character,
31345  *               @c is returned unchanged.
31346  */
31347
31348
31349 /**
31350  * g_unichar_toupper:
31351  * @c: a Unicode character
31352  *
31353  * Converts a character to uppercase.
31354  *
31355  * Returns: the result of converting @c to uppercase.
31356  *               If @c is not an lowercase or titlecase character,
31357  *               or has no upper case equivalent @c is returned unchanged.
31358  */
31359
31360
31361 /**
31362  * g_unichar_type:
31363  * @c: a Unicode character
31364  *
31365  * Classifies a Unicode character by type.
31366  *
31367  * Returns: the type of the character.
31368  */
31369
31370
31371 /**
31372  * g_unichar_validate:
31373  * @ch: a Unicode character
31374  *
31375  * Checks whether @ch is a valid Unicode character. Some possible
31376  * integer values of @ch will not be valid. 0 is considered a valid
31377  * character, though it's normally a string terminator.
31378  *
31379  * Returns: %TRUE if @ch is a valid Unicode character
31380  */
31381
31382
31383 /**
31384  * g_unichar_xdigit_value:
31385  * @c: a Unicode character
31386  *
31387  * Determines the numeric value of a character as a hexidecimal
31388  * digit.
31389  *
31390  * Returns: If @c is a hex digit (according to
31391  * g_unichar_isxdigit()), its numeric value. Otherwise, -1.
31392  */
31393
31394
31395 /**
31396  * g_unicode_canonical_decomposition:
31397  * @ch: a Unicode character.
31398  * @result_len: location to store the length of the return value.
31399  *
31400  * Computes the canonical decomposition of a Unicode character.
31401  *
31402  * Returns: a newly allocated string of Unicode characters.
31403  *   @result_len is set to the resulting length of the string.
31404  * Deprecated: 2.30: Use the more flexible g_unichar_fully_decompose()
31405  *   instead.
31406  */
31407
31408
31409 /**
31410  * g_unicode_canonical_ordering:
31411  * @string: a UCS-4 encoded string.
31412  * @len: the maximum length of @string to use.
31413  *
31414  * Computes the canonical ordering of a string in-place.
31415  * This rearranges decomposed characters in the string
31416  * according to their combining classes.  See the Unicode
31417  * manual for more information.
31418  */
31419
31420
31421 /**
31422  * g_unicode_script_from_iso15924:
31423  * @iso15924: a Unicode script
31424  *
31425  * Looks up the Unicode script for @iso15924.  ISO 15924 assigns four-letter
31426  * codes to scripts.  For example, the code for Arabic is 'Arab'.
31427  * This function accepts four letter codes encoded as a @guint32 in a
31428  * big-endian fashion.  That is, the code expected for Arabic is
31429  * 0x41726162 (0x41 is ASCII code for 'A', 0x72 is ASCII code for 'r', etc).
31430  *
31431  * See <ulink url="http://unicode.org/iso15924/codelists.html">Codes for the
31432  * representation of names of scripts</ulink> for details.
31433  *
31434  * Returns: the Unicode script for @iso15924, or
31435  *   of %G_UNICODE_SCRIPT_INVALID_CODE if @iso15924 is zero and
31436  *   %G_UNICODE_SCRIPT_UNKNOWN if @iso15924 is unknown.
31437  * Since: 2.30
31438  */
31439
31440
31441 /**
31442  * g_unicode_script_to_iso15924:
31443  * @script: a Unicode script
31444  *
31445  * Looks up the ISO 15924 code for @script.  ISO 15924 assigns four-letter
31446  * codes to scripts.  For example, the code for Arabic is 'Arab'.  The
31447  * four letter codes are encoded as a @guint32 by this function in a
31448  * big-endian fashion.  That is, the code returned for Arabic is
31449  * 0x41726162 (0x41 is ASCII code for 'A', 0x72 is ASCII code for 'r', etc).
31450  *
31451  * See <ulink url="http://unicode.org/iso15924/codelists.html">Codes for the
31452  * representation of names of scripts</ulink> for details.
31453  *
31454  * Returns: the ISO 15924 code for @script, encoded as an integer,
31455  *   of zero if @script is %G_UNICODE_SCRIPT_INVALID_CODE or
31456  *   ISO 15924 code 'Zzzz' (script code for UNKNOWN) if @script is not understood.
31457  * Since: 2.30
31458  */
31459
31460
31461 /**
31462  * g_unix_fd_add:
31463  * @fd: a file descriptor
31464  * @condition: IO conditions to watch for on @fd
31465  * @function: a #GPollFDFunc
31466  * @user_data: data to pass to @function
31467  *
31468  * Sets a function to be called when the IO condition, as specified by
31469  * @condition becomes true for @fd.
31470  *
31471  * @function will be called when the specified IO condition becomes
31472  * %TRUE.  The function is expected to clear whatever event caused the
31473  * IO condition to become true and return %TRUE in order to be notified
31474  * when it happens again.  If @function returns %FALSE then the watch
31475  * will be cancelled.
31476  *
31477  * The return value of this function can be passed to g_source_remove()
31478  * to cancel the watch at any time that it exists.
31479  *
31480  * The source will never close the fd -- you must do it yourself.
31481  *
31482  * Returns: the ID (greater than 0) of the event source
31483  * Since: 2.36
31484  */
31485
31486
31487 /**
31488  * g_unix_fd_add_full:
31489  * @priority: the priority of the source
31490  * @fd: a file descriptor
31491  * @condition: IO conditions to watch for on @fd
31492  * @function: a #GUnixFDSourceFunc
31493  * @user_data: data to pass to @function
31494  * @notify: function to call when the idle is removed, or %NULL
31495  *
31496  * Sets a function to be called when the IO condition, as specified by
31497  * @condition becomes true for @fd.
31498  *
31499  * This is the same as g_unix_fd_add(), except that it allows you to
31500  * specify a non-default priority and a provide a #GDestroyNotify for
31501  * @user_data.
31502  *
31503  * Returns: the ID (greater than 0) of the event source
31504  * Since: 2.36
31505  */
31506
31507
31508 /**
31509  * g_unix_fd_source_new:
31510  * @fd: a file descriptor
31511  * @condition: IO conditions to watch for on @fd
31512  *
31513  * Creates a #GSource to watch for a particular IO condition on a file
31514  * descriptor.
31515  *
31516  * The source will never close the fd -- you must do it yourself.
31517  *
31518  * Returns: the newly created #GSource
31519  * Since: 2.36
31520  */
31521
31522
31523 /**
31524  * g_unix_open_pipe:
31525  * @fds: Array of two integers
31526  * @flags: Bitfield of file descriptor flags, see "man 2 fcntl"
31527  * @error: a #GError
31528  *
31529  * Similar to the UNIX pipe() call, but on modern systems like Linux
31530  * uses the pipe2() system call, which atomically creates a pipe with
31531  * the configured flags.  The only supported flag currently is
31532  * <literal>FD_CLOEXEC</literal>.  If for example you want to configure
31533  * <literal>O_NONBLOCK</literal>, that must still be done separately with
31534  * fcntl().
31535  *
31536  * <note>This function does *not* take <literal>O_CLOEXEC</literal>, it takes
31537  * <literal>FD_CLOEXEC</literal> as if for fcntl(); these are
31538  * different on Linux/glibc.</note>
31539  *
31540  * Returns: %TRUE on success, %FALSE if not (and errno will be set).
31541  * Since: 2.30
31542  */
31543
31544
31545 /**
31546  * g_unix_set_fd_nonblocking:
31547  * @fd: A file descriptor
31548  * @nonblock: If %TRUE, set the descriptor to be non-blocking
31549  * @error: a #GError
31550  *
31551  * Control the non-blocking state of the given file descriptor,
31552  * according to @nonblock.  On most systems this uses <literal>O_NONBLOCK</literal>, but
31553  * on some older ones may use <literal>O_NDELAY</literal>.
31554  *
31555  * Returns: %TRUE if successful
31556  * Since: 2.30
31557  */
31558
31559
31560 /**
31561  * g_unix_signal_add:
31562  * @signum: Signal number
31563  * @handler: Callback
31564  * @user_data: Data for @handler
31565  *
31566  * A convenience function for g_unix_signal_source_new(), which
31567  * attaches to the default #GMainContext.  You can remove the watch
31568  * using g_source_remove().
31569  *
31570  * Returns: An ID (greater than 0) for the event source
31571  * Since: 2.30
31572  */
31573
31574
31575 /**
31576  * g_unix_signal_add_full: (rename-to g_unix_signal_add)
31577  * @priority: the priority of the signal source. Typically this will be in
31578  *            the range between #G_PRIORITY_DEFAULT and #G_PRIORITY_HIGH.
31579  * @signum: Signal number
31580  * @handler: Callback
31581  * @user_data: Data for @handler
31582  * @notify: #GDestroyNotify for @handler
31583  *
31584  * A convenience function for g_unix_signal_source_new(), which
31585  * attaches to the default #GMainContext.  You can remove the watch
31586  * using g_source_remove().
31587  *
31588  * Returns: An ID (greater than 0) for the event source
31589  * Since: 2.30
31590  */
31591
31592
31593 /**
31594  * g_unix_signal_source_new:
31595  * @signum: A signal number
31596  *
31597  * Create a #GSource that will be dispatched upon delivery of the UNIX
31598  * signal @signum.  In GLib versions before 2.36, only
31599  * <literal>SIGHUP</literal>, <literal>SIGINT</literal>,
31600  * <literal>SIGTERM</literal> can be monitored.  In GLib 2.36,
31601  * <literal>SIGUSR1</literal> and <literal>SIGUSR2</literal> were
31602  * added.
31603  *
31604  * Note that unlike the UNIX default, all sources which have created a
31605  * watch will be dispatched, regardless of which underlying thread
31606  * invoked g_unix_signal_source_new().
31607  *
31608  * For example, an effective use of this function is to handle <literal>SIGTERM</literal>
31609  * cleanly; flushing any outstanding files, and then calling
31610  * g_main_loop_quit ().  It is not safe to do any of this a regular
31611  * UNIX signal handler; your handler may be invoked while malloc() or
31612  * another library function is running, causing reentrancy if you
31613  * attempt to use it from the handler.  None of the GLib/GObject API
31614  * is safe against this kind of reentrancy.
31615  *
31616  * The interaction of this source when combined with native UNIX
31617  * functions like sigprocmask() is not defined.
31618  *
31619  * The source will not initially be associated with any #GMainContext
31620  * and must be added to one with g_source_attach() before it will be
31621  * executed.
31622  *
31623  * Returns: A newly created #GSource
31624  * Since: 2.30
31625  */
31626
31627
31628 /**
31629  * g_unlink:
31630  * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
31631  *
31632  * A wrapper for the POSIX unlink() function. The unlink() function
31633  * deletes a name from the filesystem. If this was the last link to the
31634  * file and no processes have it opened, the diskspace occupied by the
31635  * file is freed.
31636  *
31637  * See your C library manual for more details about unlink(). Note
31638  * that on Windows, it is in general not possible to delete files that
31639  * are open to some process, or mapped into memory.
31640  *
31641  * Returns: 0 if the name was successfully deleted, -1 if an error
31642  *    occurred
31643  * Since: 2.6
31644  */
31645
31646
31647 /**
31648  * g_unsetenv:
31649  * @variable: the environment variable to remove, must not contain '='
31650  *
31651  * Removes an environment variable from the environment.
31652  *
31653  * Note that on some systems, when variables are overwritten, the
31654  * memory used for the previous variables and its value isn't reclaimed.
31655  *
31656  * <warning><para>
31657  * Environment variable handling in UNIX is not thread-safe, and your
31658  * program may crash if one thread calls g_unsetenv() while another
31659  * thread is calling getenv(). (And note that many functions, such as
31660  * gettext(), call getenv() internally.) This function is only safe
31661  * to use at the very start of your program, before creating any other
31662  * threads (or creating objects that create worker threads of their
31663  * own).
31664  * </para><para>
31665  * If you need to set up the environment for a child process, you can
31666  * use g_get_environ() to get an environment array, modify that with
31667  * g_environ_setenv() and g_environ_unsetenv(), and then pass that
31668  * array directly to execvpe(), g_spawn_async(), or the like.
31669  * </para></warning>
31670  *
31671  * Since: 2.4
31672  */
31673
31674
31675 /**
31676  * g_uri_escape_string:
31677  * @unescaped: the unescaped input string.
31678  * @reserved_chars_allowed: (allow-none): a string of reserved characters that
31679  *      are allowed to be used, or %NULL.
31680  * @allow_utf8: %TRUE if the result can include UTF-8 characters.
31681  *
31682  * Escapes a string for use in a URI.
31683  *
31684  * Normally all characters that are not "unreserved" (i.e. ASCII alphanumerical
31685  * characters plus dash, dot, underscore and tilde) are escaped.
31686  * But if you specify characters in @reserved_chars_allowed they are not
31687  * escaped. This is useful for the "reserved" characters in the URI
31688  * specification, since those are allowed unescaped in some portions of
31689  * a URI.
31690  *
31691  * Returns: an escaped version of @unescaped. The returned string should be
31692  * freed when no longer needed.
31693  * Since: 2.16
31694  */
31695
31696
31697 /**
31698  * g_uri_list_extract_uris:
31699  * @uri_list: an URI list
31700  *
31701  * Splits an URI list conforming to the text/uri-list
31702  * mime type defined in RFC 2483 into individual URIs,
31703  * discarding any comments. The URIs are not validated.
31704  *
31705  * Returns: (transfer full): a newly allocated %NULL-terminated list
31706  *   of strings holding the individual URIs. The array should be freed
31707  *   with g_strfreev().
31708  * Since: 2.6
31709  */
31710
31711
31712 /**
31713  * g_uri_parse_scheme:
31714  * @uri: a valid URI.
31715  *
31716  * Gets the scheme portion of a URI string. RFC 3986 decodes the scheme as:
31717  * <programlisting>
31718  * URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
31719  * </programlisting>
31720  * Common schemes include "file", "http", "svn+ssh", etc.
31721  *
31722  * Returns: The "Scheme" component of the URI, or %NULL on error.
31723  * The returned string should be freed when no longer needed.
31724  * Since: 2.16
31725  */
31726
31727
31728 /**
31729  * g_uri_unescape_segment:
31730  * @escaped_string: (allow-none): A string, may be %NULL
31731  * @escaped_string_end: (allow-none): Pointer to end of @escaped_string, may be %NULL
31732  * @illegal_characters: (allow-none): An optional string of illegal characters not to be allowed, may be %NULL
31733  *
31734  * Unescapes a segment of an escaped string.
31735  *
31736  * If any of the characters in @illegal_characters or the character zero appears
31737  * as an escaped character in @escaped_string then that is an error and %NULL
31738  * will be returned. This is useful it you want to avoid for instance having a
31739  * slash being expanded in an escaped path element, which might confuse pathname
31740  * handling.
31741  *
31742  * Returns: an unescaped version of @escaped_string or %NULL on error.
31743  * The returned string should be freed when no longer needed.  As a
31744  * special case if %NULL is given for @escaped_string, this function
31745  * will return %NULL.
31746  * Since: 2.16
31747  */
31748
31749
31750 /**
31751  * g_uri_unescape_string:
31752  * @escaped_string: an escaped string to be unescaped.
31753  * @illegal_characters: (allow-none): a string of illegal characters not to be
31754  *      allowed, or %NULL.
31755  *
31756  * Unescapes a whole escaped string.
31757  *
31758  * If any of the characters in @illegal_characters or the character zero appears
31759  * as an escaped character in @escaped_string then that is an error and %NULL
31760  * will be returned. This is useful it you want to avoid for instance having a
31761  * slash being expanded in an escaped path element, which might confuse pathname
31762  * handling.
31763  *
31764  * Returns: an unescaped version of @escaped_string. The returned string
31765  * should be freed when no longer needed.
31766  * Since: 2.16
31767  */
31768
31769
31770 /**
31771  * g_usleep:
31772  * @microseconds: number of microseconds to pause
31773  *
31774  * Pauses the current thread for the given number of microseconds.
31775  *
31776  * There are 1 million microseconds per second (represented by the
31777  * #G_USEC_PER_SEC macro). g_usleep() may have limited precision,
31778  * depending on hardware and operating system; don't rely on the exact
31779  * length of the sleep.
31780  */
31781
31782
31783 /**
31784  * g_utf16_to_ucs4:
31785  * @str: a UTF-16 encoded string
31786  * @len: the maximum length (number of <type>gunichar2</type>) of @str to use.
31787  *       If @len < 0, then the string is nul-terminated.
31788  * @items_read: (allow-none): location to store number of words read, or %NULL.
31789  *              If %NULL, then %G_CONVERT_ERROR_PARTIAL_INPUT will be
31790  *              returned in case @str contains a trailing partial
31791  *              character. If an error occurs then the index of the
31792  *              invalid input is stored here.
31793  * @items_written: (allow-none): location to store number of characters written, or %NULL.
31794  *                 The value stored here does not include the trailing
31795  *                 0 character.
31796  * @error: location to store the error occurring, or %NULL to ignore
31797  *         errors. Any of the errors in #GConvertError other than
31798  *         %G_CONVERT_ERROR_NO_CONVERSION may occur.
31799  *
31800  * Convert a string from UTF-16 to UCS-4. The result will be
31801  * nul-terminated.
31802  *
31803  * Returns: a pointer to a newly allocated UCS-4 string.
31804  *               This value must be freed with g_free(). If an
31805  *               error occurs, %NULL will be returned and
31806  *               @error set.
31807  */
31808
31809
31810 /**
31811  * g_utf16_to_utf8:
31812  * @str: a UTF-16 encoded string
31813  * @len: the maximum length (number of <type>gunichar2</type>) of @str to use.
31814  *       If @len < 0, then the string is nul-terminated.
31815  * @items_read: (allow-none): location to store number of words read, or %NULL.
31816  *              If %NULL, then %G_CONVERT_ERROR_PARTIAL_INPUT will be
31817  *              returned in case @str contains a trailing partial
31818  *              character. If an error occurs then the index of the
31819  *              invalid input is stored here.
31820  * @items_written: (allow-none): location to store number of bytes written, or %NULL.
31821  *                 The value stored here does not include the trailing
31822  *                 0 byte.
31823  * @error: location to store the error occurring, or %NULL to ignore
31824  *         errors. Any of the errors in #GConvertError other than
31825  *         %G_CONVERT_ERROR_NO_CONVERSION may occur.
31826  *
31827  * Convert a string from UTF-16 to UTF-8. The result will be
31828  * terminated with a 0 byte.
31829  *
31830  * Note that the input is expected to be already in native endianness,
31831  * an initial byte-order-mark character is not handled specially.
31832  * g_convert() can be used to convert a byte buffer of UTF-16 data of
31833  * ambiguous endianess.
31834  *
31835  * Further note that this function does not validate the result
31836  * string; it may e.g. include embedded NUL characters. The only
31837  * validation done by this function is to ensure that the input can
31838  * be correctly interpreted as UTF-16, i.e. it doesn't contain
31839  * things unpaired surrogates.
31840  *
31841  * Returns: a pointer to a newly allocated UTF-8 string.
31842  *               This value must be freed with g_free(). If an
31843  *               error occurs, %NULL will be returned and
31844  *               @error set.
31845  */
31846
31847
31848 /**
31849  * g_utf8_casefold:
31850  * @str: a UTF-8 encoded string
31851  * @len: length of @str, in bytes, or -1 if @str is nul-terminated.
31852  *
31853  * Converts a string into a form that is independent of case. The
31854  * result will not correspond to any particular case, but can be
31855  * compared for equality or ordered with the results of calling
31856  * g_utf8_casefold() on other strings.
31857  *
31858  * Note that calling g_utf8_casefold() followed by g_utf8_collate() is
31859  * only an approximation to the correct linguistic case insensitive
31860  * ordering, though it is a fairly good one. Getting this exactly
31861  * right would require a more sophisticated collation function that
31862  * takes case sensitivity into account. GLib does not currently
31863  * provide such a function.
31864  *
31865  * Returns: a newly allocated string, that is a
31866  *   case independent form of @str.
31867  */
31868
31869
31870 /**
31871  * g_utf8_collate:
31872  * @str1: a UTF-8 encoded string
31873  * @str2: a UTF-8 encoded string
31874  *
31875  * Compares two strings for ordering using the linguistically
31876  * correct rules for the <link linkend="setlocale">current locale</link>.
31877  * When sorting a large number of strings, it will be significantly
31878  * faster to obtain collation keys with g_utf8_collate_key() and
31879  * compare the keys with strcmp() when sorting instead of sorting
31880  * the original strings.
31881  *
31882  * Returns: &lt; 0 if @str1 compares before @str2,
31883  *   0 if they compare equal, &gt; 0 if @str1 compares after @str2.
31884  */
31885
31886
31887 /**
31888  * g_utf8_collate_key:
31889  * @str: a UTF-8 encoded string.
31890  * @len: length of @str, in bytes, or -1 if @str is nul-terminated.
31891  *
31892  * Converts a string into a collation key that can be compared
31893  * with other collation keys produced by the same function using
31894  * strcmp().
31895  *
31896  * The results of comparing the collation keys of two strings
31897  * with strcmp() will always be the same as comparing the two
31898  * original keys with g_utf8_collate().
31899  *
31900  * Note that this function depends on the
31901  * <link linkend="setlocale">current locale</link>.
31902  *
31903  * Returns: a newly allocated string. This string should
31904  *   be freed with g_free() when you are done with it.
31905  */
31906
31907
31908 /**
31909  * g_utf8_collate_key_for_filename:
31910  * @str: a UTF-8 encoded string.
31911  * @len: length of @str, in bytes, or -1 if @str is nul-terminated.
31912  *
31913  * Converts a string into a collation key that can be compared
31914  * with other collation keys produced by the same function using strcmp().
31915  *
31916  * In order to sort filenames correctly, this function treats the dot '.'
31917  * as a special case. Most dictionary orderings seem to consider it
31918  * insignificant, thus producing the ordering "event.c" "eventgenerator.c"
31919  * "event.h" instead of "event.c" "event.h" "eventgenerator.c". Also, we
31920  * would like to treat numbers intelligently so that "file1" "file10" "file5"
31921  * is sorted as "file1" "file5" "file10".
31922  *
31923  * Note that this function depends on the
31924  * <link linkend="setlocale">current locale</link>.
31925  *
31926  * Returns: a newly allocated string. This string should
31927  *   be freed with g_free() when you are done with it.
31928  * Since: 2.8
31929  */
31930
31931
31932 /**
31933  * g_utf8_find_next_char:
31934  * @p: a pointer to a position within a UTF-8 encoded string
31935  * @end: a pointer to the byte following the end of the string,
31936  * or %NULL to indicate that the string is nul-terminated.
31937  *
31938  * Finds the start of the next UTF-8 character in the string after @p.
31939  *
31940  * @p does not have to be at the beginning of a UTF-8 character. No check
31941  * is made to see if the character found is actually valid other than
31942  * it starts with an appropriate byte.
31943  *
31944  * Returns: a pointer to the found character or %NULL
31945  */
31946
31947
31948 /**
31949  * g_utf8_find_prev_char:
31950  * @str: pointer to the beginning of a UTF-8 encoded string
31951  * @p: pointer to some position within @str
31952  *
31953  * Given a position @p with a UTF-8 encoded string @str, find the start
31954  * of the previous UTF-8 character starting before @p. Returns %NULL if no
31955  * UTF-8 characters are present in @str before @p.
31956  *
31957  * @p does not have to be at the beginning of a UTF-8 character. No check
31958  * is made to see if the character found is actually valid other than
31959  * it starts with an appropriate byte.
31960  *
31961  * Returns: a pointer to the found character or %NULL.
31962  */
31963
31964
31965 /**
31966  * g_utf8_get_char:
31967  * @p: a pointer to Unicode character encoded as UTF-8
31968  *
31969  * Converts a sequence of bytes encoded as UTF-8 to a Unicode character.
31970  * If @p does not point to a valid UTF-8 encoded character, results are
31971  * undefined. If you are not sure that the bytes are complete
31972  * valid Unicode characters, you should use g_utf8_get_char_validated()
31973  * instead.
31974  *
31975  * Returns: the resulting character
31976  */
31977
31978
31979 /**
31980  * g_utf8_get_char_validated:
31981  * @p: a pointer to Unicode character encoded as UTF-8
31982  * @max_len: the maximum number of bytes to read, or -1, for no maximum or
31983  *           if @p is nul-terminated
31984  *
31985  * Convert a sequence of bytes encoded as UTF-8 to a Unicode character.
31986  * This function checks for incomplete characters, for invalid characters
31987  * such as characters that are out of the range of Unicode, and for
31988  * overlong encodings of valid characters.
31989  *
31990  * Returns: the resulting character. If @p points to a partial
31991  *    sequence at the end of a string that could begin a valid
31992  *    character (or if @max_len is zero), returns (gunichar)-2;
31993  *    otherwise, if @p does not point to a valid UTF-8 encoded
31994  *    Unicode character, returns (gunichar)-1.
31995  */
31996
31997
31998 /**
31999  * g_utf8_normalize:
32000  * @str: a UTF-8 encoded string.
32001  * @len: length of @str, in bytes, or -1 if @str is nul-terminated.
32002  * @mode: the type of normalization to perform.
32003  *
32004  * Converts a string into canonical form, standardizing
32005  * such issues as whether a character with an accent
32006  * is represented as a base character and combining
32007  * accent or as a single precomposed character. The
32008  * string has to be valid UTF-8, otherwise %NULL is
32009  * returned. You should generally call g_utf8_normalize()
32010  * before comparing two Unicode strings.
32011  *
32012  * The normalization mode %G_NORMALIZE_DEFAULT only
32013  * standardizes differences that do not affect the
32014  * text content, such as the above-mentioned accent
32015  * representation. %G_NORMALIZE_ALL also standardizes
32016  * the "compatibility" characters in Unicode, such
32017  * as SUPERSCRIPT THREE to the standard forms
32018  * (in this case DIGIT THREE). Formatting information
32019  * may be lost but for most text operations such
32020  * characters should be considered the same.
32021  *
32022  * %G_NORMALIZE_DEFAULT_COMPOSE and %G_NORMALIZE_ALL_COMPOSE
32023  * are like %G_NORMALIZE_DEFAULT and %G_NORMALIZE_ALL,
32024  * but returned a result with composed forms rather
32025  * than a maximally decomposed form. This is often
32026  * useful if you intend to convert the string to
32027  * a legacy encoding or pass it to a system with
32028  * less capable Unicode handling.
32029  *
32030  * Returns: a newly allocated string, that is the
32031  *   normalized form of @str, or %NULL if @str is not
32032  *   valid UTF-8.
32033  */
32034
32035
32036 /**
32037  * g_utf8_offset_to_pointer:
32038  * @str: a UTF-8 encoded string
32039  * @offset: a character offset within @str
32040  *
32041  * Converts from an integer character offset to a pointer to a position
32042  * within the string.
32043  *
32044  * Since 2.10, this function allows to pass a negative @offset to
32045  * step backwards. It is usually worth stepping backwards from the end
32046  * instead of forwards if @offset is in the last fourth of the string,
32047  * since moving forward is about 3 times faster than moving backward.
32048  *
32049  * <note><para>
32050  * This function doesn't abort when reaching the end of @str. Therefore
32051  * you should be sure that @offset is within string boundaries before
32052  * calling that function. Call g_utf8_strlen() when unsure.
32053  *
32054  * This limitation exists as this function is called frequently during
32055  * text rendering and therefore has to be as fast as possible.
32056  * </para></note>
32057  *
32058  * Returns: the resulting pointer
32059  */
32060
32061
32062 /**
32063  * g_utf8_pointer_to_offset:
32064  * @str: a UTF-8 encoded string
32065  * @pos: a pointer to a position within @str
32066  *
32067  * Converts from a pointer to position within a string to a integer
32068  * character offset.
32069  *
32070  * Since 2.10, this function allows @pos to be before @str, and returns
32071  * a negative offset in this case.
32072  *
32073  * Returns: the resulting character offset
32074  */
32075
32076
32077 /**
32078  * g_utf8_prev_char:
32079  * @p: a pointer to a position within a UTF-8 encoded string
32080  *
32081  * Finds the previous UTF-8 character in the string before @p.
32082  *
32083  * @p does not have to be at the beginning of a UTF-8 character. No check
32084  * is made to see if the character found is actually valid other than
32085  * it starts with an appropriate byte. If @p might be the first
32086  * character of the string, you must use g_utf8_find_prev_char() instead.
32087  *
32088  * Returns: a pointer to the found character.
32089  */
32090
32091
32092 /**
32093  * g_utf8_strchr:
32094  * @p: a nul-terminated UTF-8 encoded string
32095  * @len: the maximum length of @p
32096  * @c: a Unicode character
32097  *
32098  * Finds the leftmost occurrence of the given Unicode character
32099  * in a UTF-8 encoded string, while limiting the search to @len bytes.
32100  * If @len is -1, allow unbounded search.
32101  *
32102  * Returns: %NULL if the string does not contain the character,
32103  *   otherwise, a pointer to the start of the leftmost occurrence of
32104  *   the character in the string.
32105  */
32106
32107
32108 /**
32109  * g_utf8_strdown:
32110  * @str: a UTF-8 encoded string
32111  * @len: length of @str, in bytes, or -1 if @str is nul-terminated.
32112  *
32113  * Converts all Unicode characters in the string that have a case
32114  * to lowercase. The exact manner that this is done depends
32115  * on the current locale, and may result in the number of
32116  * characters in the string changing.
32117  *
32118  * Returns: a newly allocated string, with all characters
32119  *    converted to lowercase.
32120  */
32121
32122
32123 /**
32124  * g_utf8_strlen:
32125  * @p: pointer to the start of a UTF-8 encoded string
32126  * @max: the maximum number of bytes to examine. If @max
32127  *       is less than 0, then the string is assumed to be
32128  *       nul-terminated. If @max is 0, @p will not be examined and
32129  *       may be %NULL. If @max is greater than 0, up to @max
32130  *       bytes are examined
32131  *
32132  * Computes the length of the string in characters, not including
32133  * the terminating nul character. If the @max'th byte falls in the
32134  * middle of a character, the last (partial) character is not counted.
32135  *
32136  * Returns: the length of the string in characters
32137  */
32138
32139
32140 /**
32141  * g_utf8_strncpy:
32142  * @dest: buffer to fill with characters from @src
32143  * @src: UTF-8 encoded string
32144  * @n: character count
32145  *
32146  * Like the standard C strncpy() function, but
32147  * copies a given number of characters instead of a given number of
32148  * bytes. The @src string must be valid UTF-8 encoded text.
32149  * (Use g_utf8_validate() on all text before trying to use UTF-8
32150  * utility functions with it.)
32151  *
32152  * Returns: @dest
32153  */
32154
32155
32156 /**
32157  * g_utf8_strrchr:
32158  * @p: a nul-terminated UTF-8 encoded string
32159  * @len: the maximum length of @p
32160  * @c: a Unicode character
32161  *
32162  * Find the rightmost occurrence of the given Unicode character
32163  * in a UTF-8 encoded string, while limiting the search to @len bytes.
32164  * If @len is -1, allow unbounded search.
32165  *
32166  * Returns: %NULL if the string does not contain the character,
32167  *   otherwise, a pointer to the start of the rightmost occurrence of the
32168  *   character in the string.
32169  */
32170
32171
32172 /**
32173  * g_utf8_strreverse:
32174  * @str: a UTF-8 encoded string
32175  * @len: the maximum length of @str to use, in bytes. If @len < 0,
32176  *       then the string is nul-terminated.
32177  *
32178  * Reverses a UTF-8 string. @str must be valid UTF-8 encoded text.
32179  * (Use g_utf8_validate() on all text before trying to use UTF-8
32180  * utility functions with it.)
32181  *
32182  * This function is intended for programmatic uses of reversed strings.
32183  * It pays no attention to decomposed characters, combining marks, byte
32184  * order marks, directional indicators (LRM, LRO, etc) and similar
32185  * characters which might need special handling when reversing a string
32186  * for display purposes.
32187  *
32188  * Note that unlike g_strreverse(), this function returns
32189  * newly-allocated memory, which should be freed with g_free() when
32190  * no longer needed.
32191  *
32192  * Returns: a newly-allocated string which is the reverse of @str.
32193  * Since: 2.2
32194  */
32195
32196
32197 /**
32198  * g_utf8_strup:
32199  * @str: a UTF-8 encoded string
32200  * @len: length of @str, in bytes, or -1 if @str is nul-terminated.
32201  *
32202  * Converts all Unicode characters in the string that have a case
32203  * to uppercase. The exact manner that this is done depends
32204  * on the current locale, and may result in the number of
32205  * characters in the string increasing. (For instance, the
32206  * German ess-zet will be changed to SS.)
32207  *
32208  * Returns: a newly allocated string, with all characters
32209  *    converted to uppercase.
32210  */
32211
32212
32213 /**
32214  * g_utf8_substring:
32215  * @str: a UTF-8 encoded string
32216  * @start_pos: a character offset within @str
32217  * @end_pos: another character offset within @str
32218  *
32219  * Copies a substring out of a UTF-8 encoded string.
32220  * The substring will contain @end_pos - @start_pos
32221  * characters.
32222  *
32223  * Returns: a newly allocated copy of the requested
32224  *     substring. Free with g_free() when no longer needed.
32225  * Since: 2.30
32226  */
32227
32228
32229 /**
32230  * g_utf8_to_ucs4:
32231  * @str: a UTF-8 encoded string
32232  * @len: the maximum length of @str to use, in bytes. If @len < 0,
32233  *       then the string is nul-terminated.
32234  * @items_read: (allow-none): location to store number of bytes read, or %NULL.
32235  *              If %NULL, then %G_CONVERT_ERROR_PARTIAL_INPUT will be
32236  *              returned in case @str contains a trailing partial
32237  *              character. If an error occurs then the index of the
32238  *              invalid input is stored here.
32239  * @items_written: (allow-none): location to store number of characters written or %NULL.
32240  *                 The value here stored does not include the trailing 0
32241  *                 character.
32242  * @error: location to store the error occurring, or %NULL to ignore
32243  *         errors. Any of the errors in #GConvertError other than
32244  *         %G_CONVERT_ERROR_NO_CONVERSION may occur.
32245  *
32246  * Convert a string from UTF-8 to a 32-bit fixed width
32247  * representation as UCS-4. A trailing 0 character will be added to the
32248  * string after the converted text.
32249  *
32250  * Returns: a pointer to a newly allocated UCS-4 string.
32251  *               This value must be freed with g_free(). If an
32252  *               error occurs, %NULL will be returned and
32253  *               @error set.
32254  */
32255
32256
32257 /**
32258  * g_utf8_to_ucs4_fast:
32259  * @str: a UTF-8 encoded string
32260  * @len: the maximum length of @str to use, in bytes. If @len < 0,
32261  *       then the string is nul-terminated.
32262  * @items_written: (allow-none): location to store the number of characters in the
32263  *                 result, or %NULL.
32264  *
32265  * Convert a string from UTF-8 to a 32-bit fixed width
32266  * representation as UCS-4, assuming valid UTF-8 input.
32267  * This function is roughly twice as fast as g_utf8_to_ucs4()
32268  * but does no error checking on the input. A trailing 0 character
32269  * will be added to the string after the converted text.
32270  *
32271  * Returns: a pointer to a newly allocated UCS-4 string.
32272  *               This value must be freed with g_free().
32273  */
32274
32275
32276 /**
32277  * g_utf8_to_utf16:
32278  * @str: a UTF-8 encoded string
32279  * @len: the maximum length (number of bytes) of @str to use.
32280  *       If @len < 0, then the string is nul-terminated.
32281  * @items_read: (allow-none): location to store number of bytes read, or %NULL.
32282  *              If %NULL, then %G_CONVERT_ERROR_PARTIAL_INPUT will be
32283  *              returned in case @str contains a trailing partial
32284  *              character. If an error occurs then the index of the
32285  *              invalid input is stored here.
32286  * @items_written: (allow-none): location to store number of <type>gunichar2</type> written,
32287  *                 or %NULL.
32288  *                 The value stored here does not include the trailing 0.
32289  * @error: location to store the error occurring, or %NULL to ignore
32290  *         errors. Any of the errors in #GConvertError other than
32291  *         %G_CONVERT_ERROR_NO_CONVERSION may occur.
32292  *
32293  * Convert a string from UTF-8 to UTF-16. A 0 character will be
32294  * added to the result after the converted text.
32295  *
32296  * Returns: a pointer to a newly allocated UTF-16 string.
32297  *               This value must be freed with g_free(). If an
32298  *               error occurs, %NULL will be returned and
32299  *               @error set.
32300  */
32301
32302
32303 /**
32304  * g_utf8_validate:
32305  * @str: (array length=max_len) (element-type guint8): a pointer to character data
32306  * @max_len: max bytes to validate, or -1 to go until NUL
32307  * @end: (allow-none) (out) (transfer none): return location for end of valid data
32308  *
32309  * Validates UTF-8 encoded text. @str is the text to validate;
32310  * if @str is nul-terminated, then @max_len can be -1, otherwise
32311  * @max_len should be the number of bytes to validate.
32312  * If @end is non-%NULL, then the end of the valid range
32313  * will be stored there (i.e. the start of the first invalid
32314  * character if some bytes were invalid, or the end of the text
32315  * being validated otherwise).
32316  *
32317  * Note that g_utf8_validate() returns %FALSE if @max_len is
32318  * positive and any of the @max_len bytes are NUL.
32319  *
32320  * Returns %TRUE if all of @str was valid. Many GLib and GTK+
32321  * routines <emphasis>require</emphasis> valid UTF-8 as input;
32322  * so data read from a file or the network should be checked
32323  * with g_utf8_validate() before doing anything else with it.
32324  *
32325  * Returns: %TRUE if the text was valid UTF-8
32326  */
32327
32328
32329 /**
32330  * g_utime:
32331  * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
32332  * @utb: a pointer to a struct utimbuf.
32333  *
32334  * A wrapper for the POSIX utime() function. The utime() function
32335  * sets the access and modification timestamps of a file.
32336  *
32337  * See your C library manual for more details about how utime() works
32338  * on your system.
32339  *
32340  * Returns: 0 if the operation was successful, -1 if an error
32341  *    occurred
32342  * Since: 2.18
32343  */
32344
32345
32346 /**
32347  * g_variant_builder_add: (skp)
32348  * @builder: a #GVariantBuilder
32349  * @format_string: a #GVariant varargs format string
32350  * @...: arguments, as per @format_string
32351  *
32352  * Adds to a #GVariantBuilder.
32353  *
32354  * This call is a convenience wrapper that is exactly equivalent to
32355  * calling g_variant_new() followed by g_variant_builder_add_value().
32356  *
32357  * This function might be used as follows:
32358  *
32359  * <programlisting>
32360  * GVariant *
32361  * make_pointless_dictionary (void)
32362  * {
32363  *   GVariantBuilder *builder;
32364  *   int i;
32365  *
32366  *   builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
32367  *   for (i = 0; i < 16; i++)
32368  *     {
32369  *       gchar buf[3];
32370  *
32371  *       sprintf (buf, "%d", i);
32372  *       g_variant_builder_add (builder, "{is}", i, buf);
32373  *     }
32374  *
32375  *   return g_variant_builder_end (builder);
32376  * }
32377  * </programlisting>
32378  *
32379  * Since: 2.24
32380  */
32381
32382
32383 /**
32384  * g_variant_builder_add_parsed:
32385  * @builder: a #GVariantBuilder
32386  * @format: a text format #GVariant
32387  * @...: arguments as per @format
32388  *
32389  * Adds to a #GVariantBuilder.
32390  *
32391  * This call is a convenience wrapper that is exactly equivalent to
32392  * calling g_variant_new_parsed() followed by
32393  * g_variant_builder_add_value().
32394  *
32395  * This function might be used as follows:
32396  *
32397  * <programlisting>
32398  * GVariant *
32399  * make_pointless_dictionary (void)
32400  * {
32401  *   GVariantBuilder *builder;
32402  *   int i;
32403  *
32404  *   builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
32405  *   g_variant_builder_add_parsed (builder, "{'width', <%i>}", 600);
32406  *   g_variant_builder_add_parsed (builder, "{'title', <%s>}", "foo");
32407  *   g_variant_builder_add_parsed (builder, "{'transparency', <0.5>}");
32408  *   return g_variant_builder_end (builder);
32409  * }
32410  * </programlisting>
32411  *
32412  * Since: 2.26
32413  */
32414
32415
32416 /**
32417  * g_variant_builder_add_value:
32418  * @builder: a #GVariantBuilder
32419  * @value: a #GVariant
32420  *
32421  * Adds @value to @builder.
32422  *
32423  * It is an error to call this function in any way that would create an
32424  * inconsistent value to be constructed.  Some examples of this are
32425  * putting different types of items into an array, putting the wrong
32426  * types or number of items in a tuple, putting more than one value into
32427  * a variant, etc.
32428  *
32429  * If @value is a floating reference (see g_variant_ref_sink()),
32430  * the @builder instance takes ownership of @value.
32431  *
32432  * Since: 2.24
32433  */
32434
32435
32436 /**
32437  * g_variant_builder_clear: (skip)
32438  * @builder: a #GVariantBuilder
32439  *
32440  * Releases all memory associated with a #GVariantBuilder without
32441  * freeing the #GVariantBuilder structure itself.
32442  *
32443  * It typically only makes sense to do this on a stack-allocated
32444  * #GVariantBuilder if you want to abort building the value part-way
32445  * through.  This function need not be called if you call
32446  * g_variant_builder_end() and it also doesn't need to be called on
32447  * builders allocated with g_variant_builder_new (see
32448  * g_variant_builder_unref() for that).
32449  *
32450  * This function leaves the #GVariantBuilder structure set to all-zeros.
32451  * It is valid to call this function on either an initialised
32452  * #GVariantBuilder or one that is set to all-zeros but it is not valid
32453  * to call this function on uninitialised memory.
32454  *
32455  * Since: 2.24
32456  */
32457
32458
32459 /**
32460  * g_variant_builder_close:
32461  * @builder: a #GVariantBuilder
32462  *
32463  * Closes the subcontainer inside the given @builder that was opened by
32464  * the most recent call to g_variant_builder_open().
32465  *
32466  * It is an error to call this function in any way that would create an
32467  * inconsistent value to be constructed (ie: too few values added to the
32468  * subcontainer).
32469  *
32470  * Since: 2.24
32471  */
32472
32473
32474 /**
32475  * g_variant_builder_end:
32476  * @builder: a #GVariantBuilder
32477  *
32478  * Ends the builder process and returns the constructed value.
32479  *
32480  * It is not permissible to use @builder in any way after this call
32481  * except for reference counting operations (in the case of a
32482  * heap-allocated #GVariantBuilder) or by reinitialising it with
32483  * g_variant_builder_init() (in the case of stack-allocated).
32484  *
32485  * It is an error to call this function in any way that would create an
32486  * inconsistent value to be constructed (ie: insufficient number of
32487  * items added to a container with a specific number of children
32488  * required).  It is also an error to call this function if the builder
32489  * was created with an indefinite array or maybe type and no children
32490  * have been added; in this case it is impossible to infer the type of
32491  * the empty array.
32492  *
32493  * Returns: (transfer none): a new, floating, #GVariant
32494  * Since: 2.24
32495  */
32496
32497
32498 /**
32499  * g_variant_builder_init: (skip)
32500  * @builder: a #GVariantBuilder
32501  * @type: a container type
32502  *
32503  * Initialises a #GVariantBuilder structure.
32504  *
32505  * @type must be non-%NULL.  It specifies the type of container to
32506  * construct.  It can be an indefinite type such as
32507  * %G_VARIANT_TYPE_ARRAY or a definite type such as "as" or "(ii)".
32508  * Maybe, array, tuple, dictionary entry and variant-typed values may be
32509  * constructed.
32510  *
32511  * After the builder is initialised, values are added using
32512  * g_variant_builder_add_value() or g_variant_builder_add().
32513  *
32514  * After all the child values are added, g_variant_builder_end() frees
32515  * the memory associated with the builder and returns the #GVariant that
32516  * was created.
32517  *
32518  * This function completely ignores the previous contents of @builder.
32519  * On one hand this means that it is valid to pass in completely
32520  * uninitialised memory.  On the other hand, this means that if you are
32521  * initialising over top of an existing #GVariantBuilder you need to
32522  * first call g_variant_builder_clear() in order to avoid leaking
32523  * memory.
32524  *
32525  * You must not call g_variant_builder_ref() or
32526  * g_variant_builder_unref() on a #GVariantBuilder that was initialised
32527  * with this function.  If you ever pass a reference to a
32528  * #GVariantBuilder outside of the control of your own code then you
32529  * should assume that the person receiving that reference may try to use
32530  * reference counting; you should use g_variant_builder_new() instead of
32531  * this function.
32532  *
32533  * Since: 2.24
32534  */
32535
32536
32537 /**
32538  * g_variant_builder_new:
32539  * @type: a container type
32540  *
32541  * Allocates and initialises a new #GVariantBuilder.
32542  *
32543  * You should call g_variant_builder_unref() on the return value when it
32544  * is no longer needed.  The memory will not be automatically freed by
32545  * any other call.
32546  *
32547  * In most cases it is easier to place a #GVariantBuilder directly on
32548  * the stack of the calling function and initialise it with
32549  * g_variant_builder_init().
32550  *
32551  * Returns: (transfer full): a #GVariantBuilder
32552  * Since: 2.24
32553  */
32554
32555
32556 /**
32557  * g_variant_builder_open:
32558  * @builder: a #GVariantBuilder
32559  * @type: a #GVariantType
32560  *
32561  * Opens a subcontainer inside the given @builder.  When done adding
32562  * items to the subcontainer, g_variant_builder_close() must be called.
32563  *
32564  * It is an error to call this function in any way that would cause an
32565  * inconsistent value to be constructed (ie: adding too many values or
32566  * a value of an incorrect type).
32567  *
32568  * Since: 2.24
32569  */
32570
32571
32572 /**
32573  * g_variant_builder_ref:
32574  * @builder: a #GVariantBuilder allocated by g_variant_builder_new()
32575  *
32576  * Increases the reference count on @builder.
32577  *
32578  * Don't call this on stack-allocated #GVariantBuilder instances or bad
32579  * things will happen.
32580  *
32581  * Returns: (transfer full): a new reference to @builder
32582  * Since: 2.24
32583  */
32584
32585
32586 /**
32587  * g_variant_builder_unref:
32588  * @builder: (transfer full): a #GVariantBuilder allocated by g_variant_builder_new()
32589  *
32590  * Decreases the reference count on @builder.
32591  *
32592  * In the event that there are no more references, releases all memory
32593  * associated with the #GVariantBuilder.
32594  *
32595  * Don't call this on stack-allocated #GVariantBuilder instances or bad
32596  * things will happen.
32597  *
32598  * Since: 2.24
32599  */
32600
32601
32602 /**
32603  * g_variant_byteswap:
32604  * @value: a #GVariant
32605  *
32606  * Performs a byteswapping operation on the contents of @value.  The
32607  * result is that all multi-byte numeric data contained in @value is
32608  * byteswapped.  That includes 16, 32, and 64bit signed and unsigned
32609  * integers as well as file handles and double precision floating point
32610  * values.
32611  *
32612  * This function is an identity mapping on any value that does not
32613  * contain multi-byte numeric data.  That include strings, booleans,
32614  * bytes and containers containing only these things (recursively).
32615  *
32616  * The returned value is always in normal form and is marked as trusted.
32617  *
32618  * Returns: (transfer full): the byteswapped form of @value
32619  * Since: 2.24
32620  */
32621
32622
32623 /**
32624  * g_variant_check_format_string:
32625  * @value: a #GVariant
32626  * @format_string: a valid #GVariant format string
32627  * @copy_only: %TRUE to ensure the format string makes deep copies
32628  *
32629  * Checks if calling g_variant_get() with @format_string on @value would
32630  * be valid from a type-compatibility standpoint.  @format_string is
32631  * assumed to be a valid format string (from a syntactic standpoint).
32632  *
32633  * If @copy_only is %TRUE then this function additionally checks that it
32634  * would be safe to call g_variant_unref() on @value immediately after
32635  * the call to g_variant_get() without invalidating the result.  This is
32636  * only possible if deep copies are made (ie: there are no pointers to
32637  * the data inside of the soon-to-be-freed #GVariant instance).  If this
32638  * check fails then a g_critical() is printed and %FALSE is returned.
32639  *
32640  * This function is meant to be used by functions that wish to provide
32641  * varargs accessors to #GVariant values of uncertain values (eg:
32642  * g_variant_lookup() or g_menu_model_get_item_attribute()).
32643  *
32644  * Returns: %TRUE if @format_string is safe to use
32645  * Since: 2.34
32646  */
32647
32648
32649 /**
32650  * g_variant_classify:
32651  * @value: a #GVariant
32652  *
32653  * Classifies @value according to its top-level type.
32654  *
32655  * Returns: the #GVariantClass of @value
32656  * Since: 2.24
32657  */
32658
32659
32660 /**
32661  * g_variant_compare:
32662  * @one: (type GVariant): a basic-typed #GVariant instance
32663  * @two: (type GVariant): a #GVariant instance of the same type
32664  *
32665  * Compares @one and @two.
32666  *
32667  * The types of @one and @two are #gconstpointer only to allow use of
32668  * this function with #GTree, #GPtrArray, etc.  They must each be a
32669  * #GVariant.
32670  *
32671  * Comparison is only defined for basic types (ie: booleans, numbers,
32672  * strings).  For booleans, %FALSE is less than %TRUE.  Numbers are
32673  * ordered in the usual way.  Strings are in ASCII lexographical order.
32674  *
32675  * It is a programmer error to attempt to compare container values or
32676  * two values that have types that are not exactly equal.  For example,
32677  * you cannot compare a 32-bit signed integer with a 32-bit unsigned
32678  * integer.  Also note that this function is not particularly
32679  * well-behaved when it comes to comparison of doubles; in particular,
32680  * the handling of incomparable values (ie: NaN) is undefined.
32681  *
32682  * If you only require an equality comparison, g_variant_equal() is more
32683  * general.
32684  *
32685  * Returns: negative value if a &lt; b;
32686  *          zero if a = b;
32687  *          positive value if a &gt; b.
32688  * Since: 2.26
32689  */
32690
32691
32692 /**
32693  * g_variant_dup_bytestring:
32694  * @value: an array-of-bytes #GVariant instance
32695  * @length: (out) (allow-none) (default NULL): a pointer to a #gsize, to store
32696  *          the length (not including the nul terminator)
32697  *
32698  * Similar to g_variant_get_bytestring() except that instead of
32699  * returning a constant string, the string is duplicated.
32700  *
32701  * The return value must be freed using g_free().
32702  *
32703  * Returns: (transfer full) (array zero-terminated=1 length=length) (element-type guint8):
32704  *          a newly allocated string
32705  * Since: 2.26
32706  */
32707
32708
32709 /**
32710  * g_variant_dup_bytestring_array:
32711  * @value: an array of array of bytes #GVariant ('aay')
32712  * @length: (out) (allow-none): the length of the result, or %NULL
32713  *
32714  * Gets the contents of an array of array of bytes #GVariant.  This call
32715  * makes a deep copy; the return result should be released with
32716  * g_strfreev().
32717  *
32718  * If @length is non-%NULL then the number of elements in the result is
32719  * stored there.  In any case, the resulting array will be
32720  * %NULL-terminated.
32721  *
32722  * For an empty array, @length will be set to 0 and a pointer to a
32723  * %NULL pointer will be returned.
32724  *
32725  * Returns: (array length=length) (transfer full): an array of strings
32726  * Since: 2.26
32727  */
32728
32729
32730 /**
32731  * g_variant_dup_objv:
32732  * @value: an array of object paths #GVariant
32733  * @length: (out) (allow-none): the length of the result, or %NULL
32734  *
32735  * Gets the contents of an array of object paths #GVariant.  This call
32736  * makes a deep copy; the return result should be released with
32737  * g_strfreev().
32738  *
32739  * If @length is non-%NULL then the number of elements in the result
32740  * is stored there.  In any case, the resulting array will be
32741  * %NULL-terminated.
32742  *
32743  * For an empty array, @length will be set to 0 and a pointer to a
32744  * %NULL pointer will be returned.
32745  *
32746  * Returns: (array length=length zero-terminated=1) (transfer full): an array of strings
32747  * Since: 2.30
32748  */
32749
32750
32751 /**
32752  * g_variant_dup_string:
32753  * @value: a string #GVariant instance
32754  * @length: (out): a pointer to a #gsize, to store the length
32755  *
32756  * Similar to g_variant_get_string() except that instead of returning
32757  * a constant string, the string is duplicated.
32758  *
32759  * The string will always be utf8 encoded.
32760  *
32761  * The return value must be freed using g_free().
32762  *
32763  * Returns: (transfer full): a newly allocated string, utf8 encoded
32764  * Since: 2.24
32765  */
32766
32767
32768 /**
32769  * g_variant_dup_strv:
32770  * @value: an array of strings #GVariant
32771  * @length: (out) (allow-none): the length of the result, or %NULL
32772  *
32773  * Gets the contents of an array of strings #GVariant.  This call
32774  * makes a deep copy; the return result should be released with
32775  * g_strfreev().
32776  *
32777  * If @length is non-%NULL then the number of elements in the result
32778  * is stored there.  In any case, the resulting array will be
32779  * %NULL-terminated.
32780  *
32781  * For an empty array, @length will be set to 0 and a pointer to a
32782  * %NULL pointer will be returned.
32783  *
32784  * Returns: (array length=length zero-terminated=1) (transfer full): an array of strings
32785  * Since: 2.24
32786  */
32787
32788
32789 /**
32790  * g_variant_equal:
32791  * @one: (type GVariant): a #GVariant instance
32792  * @two: (type GVariant): a #GVariant instance
32793  *
32794  * Checks if @one and @two have the same type and value.
32795  *
32796  * The types of @one and @two are #gconstpointer only to allow use of
32797  * this function with #GHashTable.  They must each be a #GVariant.
32798  *
32799  * Returns: %TRUE if @one and @two are equal
32800  * Since: 2.24
32801  */
32802
32803
32804 /**
32805  * g_variant_get: (skip)
32806  * @value: a #GVariant instance
32807  * @format_string: a #GVariant format string
32808  * @...: arguments, as per @format_string
32809  *
32810  * Deconstructs a #GVariant instance.
32811  *
32812  * Think of this function as an analogue to scanf().
32813  *
32814  * The arguments that are expected by this function are entirely
32815  * determined by @format_string.  @format_string also restricts the
32816  * permissible types of @value.  It is an error to give a value with
32817  * an incompatible type.  See the section on <link
32818  * linkend='gvariant-format-strings'>GVariant Format Strings</link>.
32819  * Please note that the syntax of the format string is very likely to be
32820  * extended in the future.
32821  *
32822  * @format_string determines the C types that are used for unpacking
32823  * the values and also determines if the values are copied or borrowed,
32824  * see the section on
32825  * <link linkend='gvariant-format-strings-pointers'>GVariant Format Strings</link>.
32826  *
32827  * Since: 2.24
32828  */
32829
32830
32831 /**
32832  * g_variant_get_boolean:
32833  * @value: a boolean #GVariant instance
32834  *
32835  * Returns the boolean value of @value.
32836  *
32837  * It is an error to call this function with a @value of any type
32838  * other than %G_VARIANT_TYPE_BOOLEAN.
32839  *
32840  * Returns: %TRUE or %FALSE
32841  * Since: 2.24
32842  */
32843
32844
32845 /**
32846  * g_variant_get_byte:
32847  * @value: a byte #GVariant instance
32848  *
32849  * Returns the byte value of @value.
32850  *
32851  * It is an error to call this function with a @value of any type
32852  * other than %G_VARIANT_TYPE_BYTE.
32853  *
32854  * Returns: a #guchar
32855  * Since: 2.24
32856  */
32857
32858
32859 /**
32860  * g_variant_get_bytestring:
32861  * @value: an array-of-bytes #GVariant instance
32862  *
32863  * Returns the string value of a #GVariant instance with an
32864  * array-of-bytes type.  The string has no particular encoding.
32865  *
32866  * If the array does not end with a nul terminator character, the empty
32867  * string is returned.  For this reason, you can always trust that a
32868  * non-%NULL nul-terminated string will be returned by this function.
32869  *
32870  * If the array contains a nul terminator character somewhere other than
32871  * the last byte then the returned string is the string, up to the first
32872  * such nul character.
32873  *
32874  * It is an error to call this function with a @value that is not an
32875  * array of bytes.
32876  *
32877  * The return value remains valid as long as @value exists.
32878  *
32879  * Returns: (transfer none) (array zero-terminated=1) (element-type guint8):
32880  *          the constant string
32881  * Since: 2.26
32882  */
32883
32884
32885 /**
32886  * g_variant_get_bytestring_array:
32887  * @value: an array of array of bytes #GVariant ('aay')
32888  * @length: (out) (allow-none): the length of the result, or %NULL
32889  *
32890  * Gets the contents of an array of array of bytes #GVariant.  This call
32891  * makes a shallow copy; the return result should be released with
32892  * g_free(), but the individual strings must not be modified.
32893  *
32894  * If @length is non-%NULL then the number of elements in the result is
32895  * stored there.  In any case, the resulting array will be
32896  * %NULL-terminated.
32897  *
32898  * For an empty array, @length will be set to 0 and a pointer to a
32899  * %NULL pointer will be returned.
32900  *
32901  * Returns: (array length=length) (transfer container): an array of constant strings
32902  * Since: 2.26
32903  */
32904
32905
32906 /**
32907  * g_variant_get_child: (skip)
32908  * @value: a container #GVariant
32909  * @index_: the index of the child to deconstruct
32910  * @format_string: a #GVariant format string
32911  * @...: arguments, as per @format_string
32912  *
32913  * Reads a child item out of a container #GVariant instance and
32914  * deconstructs it according to @format_string.  This call is
32915  * essentially a combination of g_variant_get_child_value() and
32916  * g_variant_get().
32917  *
32918  * @format_string determines the C types that are used for unpacking
32919  * the values and also determines if the values are copied or borrowed,
32920  * see the section on
32921  * <link linkend='gvariant-format-strings-pointers'>GVariant Format Strings</link>.
32922  *
32923  * Since: 2.24
32924  */
32925
32926
32927 /**
32928  * g_variant_get_child_value:
32929  * @value: a container #GVariant
32930  * @index_: the index of the child to fetch
32931  *
32932  * Reads a child item out of a container #GVariant instance.  This
32933  * includes variants, maybes, arrays, tuples and dictionary
32934  * entries.  It is an error to call this function on any other type of
32935  * #GVariant.
32936  *
32937  * It is an error if @index_ is greater than the number of child items
32938  * in the container.  See g_variant_n_children().
32939  *
32940  * The returned value is never floating.  You should free it with
32941  * g_variant_unref() when you're done with it.
32942  *
32943  * This function is O(1).
32944  *
32945  * Returns: (transfer full): the child at the specified index
32946  * Since: 2.24
32947  */
32948
32949
32950 /**
32951  * g_variant_get_data:
32952  * @value: a #GVariant instance
32953  *
32954  * Returns a pointer to the serialised form of a #GVariant instance.
32955  * The returned data may not be in fully-normalised form if read from an
32956  * untrusted source.  The returned data must not be freed; it remains
32957  * valid for as long as @value exists.
32958  *
32959  * If @value is a fixed-sized value that was deserialised from a
32960  * corrupted serialised container then %NULL may be returned.  In this
32961  * case, the proper thing to do is typically to use the appropriate
32962  * number of nul bytes in place of @value.  If @value is not fixed-sized
32963  * then %NULL is never returned.
32964  *
32965  * In the case that @value is already in serialised form, this function
32966  * is O(1).  If the value is not already in serialised form,
32967  * serialisation occurs implicitly and is approximately O(n) in the size
32968  * of the result.
32969  *
32970  * To deserialise the data returned by this function, in addition to the
32971  * serialised data, you must know the type of the #GVariant, and (if the
32972  * machine might be different) the endianness of the machine that stored
32973  * it. As a result, file formats or network messages that incorporate
32974  * serialised #GVariant<!---->s must include this information either
32975  * implicitly (for instance "the file always contains a
32976  * %G_VARIANT_TYPE_VARIANT and it is always in little-endian order") or
32977  * explicitly (by storing the type and/or endianness in addition to the
32978  * serialised data).
32979  *
32980  * Returns: (transfer none): the serialised form of @value, or %NULL
32981  * Since: 2.24
32982  */
32983
32984
32985 /**
32986  * g_variant_get_data_as_bytes:
32987  * @value: a #GVariant
32988  *
32989  * Returns a pointer to the serialised form of a #GVariant instance.
32990  * The semantics of this function are exactly the same as
32991  * g_variant_get_data(), except that the returned #GBytes holds
32992  * a reference to the variant data.
32993  *
32994  * Returns: (transfer full): A new #GBytes representing the variant data
32995  * Since: 2.36
32996  */
32997
32998
32999 /**
33000  * g_variant_get_double:
33001  * @value: a double #GVariant instance
33002  *
33003  * Returns the double precision floating point value of @value.
33004  *
33005  * It is an error to call this function with a @value of any type
33006  * other than %G_VARIANT_TYPE_DOUBLE.
33007  *
33008  * Returns: a #gdouble
33009  * Since: 2.24
33010  */
33011
33012
33013 /**
33014  * g_variant_get_fixed_array:
33015  * @value: a #GVariant array with fixed-sized elements
33016  * @n_elements: (out): a pointer to the location to store the number of items
33017  * @element_size: the size of each element
33018  *
33019  * Provides access to the serialised data for an array of fixed-sized
33020  * items.
33021  *
33022  * @value must be an array with fixed-sized elements.  Numeric types are
33023  * fixed-size, as are tuples containing only other fixed-sized types.
33024  *
33025  * @element_size must be the size of a single element in the array,
33026  * as given by the section on
33027  * <link linkend='gvariant-serialised-data-memory'>Serialised Data
33028  * Memory</link>.
33029  *
33030  * In particular, arrays of these fixed-sized types can be interpreted
33031  * as an array of the given C type, with @element_size set to
33032  * <code>sizeof</code> the appropriate type:
33033  *
33034  * <informaltable>
33035  * <tgroup cols='2'>
33036  * <thead><row><entry>element type</entry> <entry>C type</entry></row></thead>
33037  * <tbody>
33038  * <row><entry>%G_VARIANT_TYPE_INT16 (etc.)</entry>
33039  *   <entry>#gint16 (etc.)</entry></row>
33040  * <row><entry>%G_VARIANT_TYPE_BOOLEAN</entry>
33041  *   <entry>#guchar (not #gboolean!)</entry></row>
33042  * <row><entry>%G_VARIANT_TYPE_BYTE</entry> <entry>#guchar</entry></row>
33043  * <row><entry>%G_VARIANT_TYPE_HANDLE</entry> <entry>#guint32</entry></row>
33044  * <row><entry>%G_VARIANT_TYPE_DOUBLE</entry> <entry>#gdouble</entry></row>
33045  * </tbody>
33046  * </tgroup>
33047  * </informaltable>
33048  *
33049  * For example, if calling this function for an array of 32 bit integers,
33050  * you might say <code>sizeof (gint32)</code>.  This value isn't used
33051  * except for the purpose of a double-check that the form of the
33052  * serialised data matches the caller's expectation.
33053  *
33054  * @n_elements, which must be non-%NULL is set equal to the number of
33055  * items in the array.
33056  *
33057  * Returns: (array length=n_elements) (transfer none): a pointer to
33058  *          the fixed array
33059  * Since: 2.24
33060  */
33061
33062
33063 /**
33064  * g_variant_get_handle:
33065  * @value: a handle #GVariant instance
33066  *
33067  * Returns the 32-bit signed integer value of @value.
33068  *
33069  * It is an error to call this function with a @value of any type other
33070  * than %G_VARIANT_TYPE_HANDLE.
33071  *
33072  * By convention, handles are indexes into an array of file descriptors
33073  * that are sent alongside a D-Bus message.  If you're not interacting
33074  * with D-Bus, you probably don't need them.
33075  *
33076  * Returns: a #gint32
33077  * Since: 2.24
33078  */
33079
33080
33081 /**
33082  * g_variant_get_int16:
33083  * @value: a int16 #GVariant instance
33084  *
33085  * Returns the 16-bit signed integer value of @value.
33086  *
33087  * It is an error to call this function with a @value of any type
33088  * other than %G_VARIANT_TYPE_INT16.
33089  *
33090  * Returns: a #gint16
33091  * Since: 2.24
33092  */
33093
33094
33095 /**
33096  * g_variant_get_int32:
33097  * @value: a int32 #GVariant instance
33098  *
33099  * Returns the 32-bit signed integer value of @value.
33100  *
33101  * It is an error to call this function with a @value of any type
33102  * other than %G_VARIANT_TYPE_INT32.
33103  *
33104  * Returns: a #gint32
33105  * Since: 2.24
33106  */
33107
33108
33109 /**
33110  * g_variant_get_int64:
33111  * @value: a int64 #GVariant instance
33112  *
33113  * Returns the 64-bit signed integer value of @value.
33114  *
33115  * It is an error to call this function with a @value of any type
33116  * other than %G_VARIANT_TYPE_INT64.
33117  *
33118  * Returns: a #gint64
33119  * Since: 2.24
33120  */
33121
33122
33123 /**
33124  * g_variant_get_maybe:
33125  * @value: a maybe-typed value
33126  *
33127  * Given a maybe-typed #GVariant instance, extract its value.  If the
33128  * value is Nothing, then this function returns %NULL.
33129  *
33130  * Returns: (allow-none) (transfer full): the contents of @value, or %NULL
33131  * Since: 2.24
33132  */
33133
33134
33135 /**
33136  * g_variant_get_normal_form:
33137  * @value: a #GVariant
33138  *
33139  * Gets a #GVariant instance that has the same value as @value and is
33140  * trusted to be in normal form.
33141  *
33142  * If @value is already trusted to be in normal form then a new
33143  * reference to @value is returned.
33144  *
33145  * If @value is not already trusted, then it is scanned to check if it
33146  * is in normal form.  If it is found to be in normal form then it is
33147  * marked as trusted and a new reference to it is returned.
33148  *
33149  * If @value is found not to be in normal form then a new trusted
33150  * #GVariant is created with the same value as @value.
33151  *
33152  * It makes sense to call this function if you've received #GVariant
33153  * data from untrusted sources and you want to ensure your serialised
33154  * output is definitely in normal form.
33155  *
33156  * Returns: (transfer full): a trusted #GVariant
33157  * Since: 2.24
33158  */
33159
33160
33161 /**
33162  * g_variant_get_objv:
33163  * @value: an array of object paths #GVariant
33164  * @length: (out) (allow-none): the length of the result, or %NULL
33165  *
33166  * Gets the contents of an array of object paths #GVariant.  This call
33167  * makes a shallow copy; the return result should be released with
33168  * g_free(), but the individual strings must not be modified.
33169  *
33170  * If @length is non-%NULL then the number of elements in the result
33171  * is stored there.  In any case, the resulting array will be
33172  * %NULL-terminated.
33173  *
33174  * For an empty array, @length will be set to 0 and a pointer to a
33175  * %NULL pointer will be returned.
33176  *
33177  * Returns: (array length=length zero-terminated=1) (transfer container): an array of constant strings
33178  * Since: 2.30
33179  */
33180
33181
33182 /**
33183  * g_variant_get_size:
33184  * @value: a #GVariant instance
33185  *
33186  * Determines the number of bytes that would be required to store @value
33187  * with g_variant_store().
33188  *
33189  * If @value has a fixed-sized type then this function always returned
33190  * that fixed size.
33191  *
33192  * In the case that @value is already in serialised form or the size has
33193  * already been calculated (ie: this function has been called before)
33194  * then this function is O(1).  Otherwise, the size is calculated, an
33195  * operation which is approximately O(n) in the number of values
33196  * involved.
33197  *
33198  * Returns: the serialised size of @value
33199  * Since: 2.24
33200  */
33201
33202
33203 /**
33204  * g_variant_get_string:
33205  * @value: a string #GVariant instance
33206  * @length: (allow-none) (default 0) (out): a pointer to a #gsize,
33207  *          to store the length
33208  *
33209  * Returns the string value of a #GVariant instance with a string
33210  * type.  This includes the types %G_VARIANT_TYPE_STRING,
33211  * %G_VARIANT_TYPE_OBJECT_PATH and %G_VARIANT_TYPE_SIGNATURE.
33212  *
33213  * The string will always be utf8 encoded.
33214  *
33215  * If @length is non-%NULL then the length of the string (in bytes) is
33216  * returned there.  For trusted values, this information is already
33217  * known.  For untrusted values, a strlen() will be performed.
33218  *
33219  * It is an error to call this function with a @value of any type
33220  * other than those three.
33221  *
33222  * The return value remains valid as long as @value exists.
33223  *
33224  * Returns: (transfer none): the constant string, utf8 encoded
33225  * Since: 2.24
33226  */
33227
33228
33229 /**
33230  * g_variant_get_strv:
33231  * @value: an array of strings #GVariant
33232  * @length: (out) (allow-none): the length of the result, or %NULL
33233  *
33234  * Gets the contents of an array of strings #GVariant.  This call
33235  * makes a shallow copy; the return result should be released with
33236  * g_free(), but the individual strings must not be modified.
33237  *
33238  * If @length is non-%NULL then the number of elements in the result
33239  * is stored there.  In any case, the resulting array will be
33240  * %NULL-terminated.
33241  *
33242  * For an empty array, @length will be set to 0 and a pointer to a
33243  * %NULL pointer will be returned.
33244  *
33245  * Returns: (array length=length zero-terminated=1) (transfer container): an array of constant strings
33246  * Since: 2.24
33247  */
33248
33249
33250 /**
33251  * g_variant_get_type:
33252  * @value: a #GVariant
33253  *
33254  * Determines the type of @value.
33255  *
33256  * The return value is valid for the lifetime of @value and must not
33257  * be freed.
33258  *
33259  * Returns: a #GVariantType
33260  * Since: 2.24
33261  */
33262
33263
33264 /**
33265  * g_variant_get_type_string:
33266  * @value: a #GVariant
33267  *
33268  * Returns the type string of @value.  Unlike the result of calling
33269  * g_variant_type_peek_string(), this string is nul-terminated.  This
33270  * string belongs to #GVariant and must not be freed.
33271  *
33272  * Returns: the type string for the type of @value
33273  * Since: 2.24
33274  */
33275
33276
33277 /**
33278  * g_variant_get_uint16:
33279  * @value: a uint16 #GVariant instance
33280  *
33281  * Returns the 16-bit unsigned integer value of @value.
33282  *
33283  * It is an error to call this function with a @value of any type
33284  * other than %G_VARIANT_TYPE_UINT16.
33285  *
33286  * Returns: a #guint16
33287  * Since: 2.24
33288  */
33289
33290
33291 /**
33292  * g_variant_get_uint32:
33293  * @value: a uint32 #GVariant instance
33294  *
33295  * Returns the 32-bit unsigned integer value of @value.
33296  *
33297  * It is an error to call this function with a @value of any type
33298  * other than %G_VARIANT_TYPE_UINT32.
33299  *
33300  * Returns: a #guint32
33301  * Since: 2.24
33302  */
33303
33304
33305 /**
33306  * g_variant_get_uint64:
33307  * @value: a uint64 #GVariant instance
33308  *
33309  * Returns the 64-bit unsigned integer value of @value.
33310  *
33311  * It is an error to call this function with a @value of any type
33312  * other than %G_VARIANT_TYPE_UINT64.
33313  *
33314  * Returns: a #guint64
33315  * Since: 2.24
33316  */
33317
33318
33319 /**
33320  * g_variant_get_va: (skip)
33321  * @value: a #GVariant
33322  * @format_string: a string that is prefixed with a format string
33323  * @endptr: (allow-none) (default NULL): location to store the end pointer,
33324  *          or %NULL
33325  * @app: a pointer to a #va_list
33326  *
33327  * This function is intended to be used by libraries based on #GVariant
33328  * that want to provide g_variant_get()-like functionality to their
33329  * users.
33330  *
33331  * The API is more general than g_variant_get() to allow a wider range
33332  * of possible uses.
33333  *
33334  * @format_string must still point to a valid format string, but it only
33335  * need to be nul-terminated if @endptr is %NULL.  If @endptr is
33336  * non-%NULL then it is updated to point to the first character past the
33337  * end of the format string.
33338  *
33339  * @app is a pointer to a #va_list.  The arguments, according to
33340  * @format_string, are collected from this #va_list and the list is left
33341  * pointing to the argument following the last.
33342  *
33343  * These two generalisations allow mixing of multiple calls to
33344  * g_variant_new_va() and g_variant_get_va() within a single actual
33345  * varargs call by the user.
33346  *
33347  * @format_string determines the C types that are used for unpacking
33348  * the values and also determines if the values are copied or borrowed,
33349  * see the section on
33350  * <link linkend='gvariant-format-strings-pointers'>GVariant Format Strings</link>.
33351  *
33352  * Since: 2.24
33353  */
33354
33355
33356 /**
33357  * g_variant_get_variant:
33358  * @value: a variant #GVariant instance
33359  *
33360  * Unboxes @value.  The result is the #GVariant instance that was
33361  * contained in @value.
33362  *
33363  * Returns: (transfer full): the item contained in the variant
33364  * Since: 2.24
33365  */
33366
33367
33368 /**
33369  * g_variant_hash:
33370  * @value: (type GVariant): a basic #GVariant value as a #gconstpointer
33371  *
33372  * Generates a hash value for a #GVariant instance.
33373  *
33374  * The output of this function is guaranteed to be the same for a given
33375  * value only per-process.  It may change between different processor
33376  * architectures or even different versions of GLib.  Do not use this
33377  * function as a basis for building protocols or file formats.
33378  *
33379  * The type of @value is #gconstpointer only to allow use of this
33380  * function with #GHashTable.  @value must be a #GVariant.
33381  *
33382  * Returns: a hash value corresponding to @value
33383  * Since: 2.24
33384  */
33385
33386
33387 /**
33388  * g_variant_is_container:
33389  * @value: a #GVariant instance
33390  *
33391  * Checks if @value is a container.
33392  *
33393  * Returns: %TRUE if @value is a container
33394  * Since: 2.24
33395  */
33396
33397
33398 /**
33399  * g_variant_is_floating:
33400  * @value: a #GVariant
33401  *
33402  * Checks whether @value has a floating reference count.
33403  *
33404  * This function should only ever be used to assert that a given variant
33405  * is or is not floating, or for debug purposes. To acquire a reference
33406  * to a variant that might be floating, always use g_variant_ref_sink()
33407  * or g_variant_take_ref().
33408  *
33409  * See g_variant_ref_sink() for more information about floating reference
33410  * counts.
33411  *
33412  * Returns: whether @value is floating
33413  * Since: 2.26
33414  */
33415
33416
33417 /**
33418  * g_variant_is_normal_form:
33419  * @value: a #GVariant instance
33420  *
33421  * Checks if @value is in normal form.
33422  *
33423  * The main reason to do this is to detect if a given chunk of
33424  * serialised data is in normal form: load the data into a #GVariant
33425  * using g_variant_new_from_data() and then use this function to
33426  * check.
33427  *
33428  * If @value is found to be in normal form then it will be marked as
33429  * being trusted.  If the value was already marked as being trusted then
33430  * this function will immediately return %TRUE.
33431  *
33432  * Returns: %TRUE if @value is in normal form
33433  * Since: 2.24
33434  */
33435
33436
33437 /**
33438  * g_variant_is_object_path:
33439  * @string: a normal C nul-terminated string
33440  *
33441  * Determines if a given string is a valid D-Bus object path.  You
33442  * should ensure that a string is a valid D-Bus object path before
33443  * passing it to g_variant_new_object_path().
33444  *
33445  * A valid object path starts with '/' followed by zero or more
33446  * sequences of characters separated by '/' characters.  Each sequence
33447  * must contain only the characters "[A-Z][a-z][0-9]_".  No sequence
33448  * (including the one following the final '/' character) may be empty.
33449  *
33450  * Returns: %TRUE if @string is a D-Bus object path
33451  * Since: 2.24
33452  */
33453
33454
33455 /**
33456  * g_variant_is_of_type:
33457  * @value: a #GVariant instance
33458  * @type: a #GVariantType
33459  *
33460  * Checks if a value has a type matching the provided type.
33461  *
33462  * Returns: %TRUE if the type of @value matches @type
33463  * Since: 2.24
33464  */
33465
33466
33467 /**
33468  * g_variant_is_signature:
33469  * @string: a normal C nul-terminated string
33470  *
33471  * Determines if a given string is a valid D-Bus type signature.  You
33472  * should ensure that a string is a valid D-Bus type signature before
33473  * passing it to g_variant_new_signature().
33474  *
33475  * D-Bus type signatures consist of zero or more definite #GVariantType
33476  * strings in sequence.
33477  *
33478  * Returns: %TRUE if @string is a D-Bus type signature
33479  * Since: 2.24
33480  */
33481
33482
33483 /**
33484  * g_variant_iter_copy:
33485  * @iter: a #GVariantIter
33486  *
33487  * Creates a new heap-allocated #GVariantIter to iterate over the
33488  * container that was being iterated over by @iter.  Iteration begins on
33489  * the new iterator from the current position of the old iterator but
33490  * the two copies are independent past that point.
33491  *
33492  * Use g_variant_iter_free() to free the return value when you no longer
33493  * need it.
33494  *
33495  * A reference is taken to the container that @iter is iterating over
33496  * and will be releated only when g_variant_iter_free() is called.
33497  *
33498  * Returns: (transfer full): a new heap-allocated #GVariantIter
33499  * Since: 2.24
33500  */
33501
33502
33503 /**
33504  * g_variant_iter_free:
33505  * @iter: (transfer full): a heap-allocated #GVariantIter
33506  *
33507  * Frees a heap-allocated #GVariantIter.  Only call this function on
33508  * iterators that were returned by g_variant_iter_new() or
33509  * g_variant_iter_copy().
33510  *
33511  * Since: 2.24
33512  */
33513
33514
33515 /**
33516  * g_variant_iter_init: (skip)
33517  * @iter: a pointer to a #GVariantIter
33518  * @value: a container #GVariant
33519  *
33520  * Initialises (without allocating) a #GVariantIter.  @iter may be
33521  * completely uninitialised prior to this call; its old value is
33522  * ignored.
33523  *
33524  * The iterator remains valid for as long as @value exists, and need not
33525  * be freed in any way.
33526  *
33527  * Returns: the number of items in @value
33528  * Since: 2.24
33529  */
33530
33531
33532 /**
33533  * g_variant_iter_loop: (skip)
33534  * @iter: a #GVariantIter
33535  * @format_string: a GVariant format string
33536  * @...: the arguments to unpack the value into
33537  *
33538  * Gets the next item in the container and unpacks it into the variable
33539  * argument list according to @format_string, returning %TRUE.
33540  *
33541  * If no more items remain then %FALSE is returned.
33542  *
33543  * On the first call to this function, the pointers appearing on the
33544  * variable argument list are assumed to point at uninitialised memory.
33545  * On the second and later calls, it is assumed that the same pointers
33546  * will be given and that they will point to the memory as set by the
33547  * previous call to this function.  This allows the previous values to
33548  * be freed, as appropriate.
33549  *
33550  * This function is intended to be used with a while loop as
33551  * demonstrated in the following example.  This function can only be
33552  * used when iterating over an array.  It is only valid to call this
33553  * function with a string constant for the format string and the same
33554  * string constant must be used each time.  Mixing calls to this
33555  * function and g_variant_iter_next() or g_variant_iter_next_value() on
33556  * the same iterator causes undefined behavior.
33557  *
33558  * If you break out of a such a while loop using g_variant_iter_loop() then
33559  * you must free or unreference all the unpacked values as you would with
33560  * g_variant_get(). Failure to do so will cause a memory leak.
33561  *
33562  * See the section on <link linkend='gvariant-format-strings'>GVariant
33563  * Format Strings</link>.
33564  *
33565  * <example>
33566  *  <title>Memory management with g_variant_iter_loop()</title>
33567  *  <programlisting>
33568  *   /<!-- -->* Iterates a dictionary of type 'a{sv}' *<!-- -->/
33569  *   void
33570  *   iterate_dictionary (GVariant *dictionary)
33571  *   {
33572  *     GVariantIter iter;
33573  *     GVariant *value;
33574  *     gchar *key;
33575  *
33576  *     g_variant_iter_init (&iter, dictionary);
33577  *     while (g_variant_iter_loop (&iter, "{sv}", &key, &value))
33578  *       {
33579  *         g_print ("Item '%s' has type '%s'\n", key,
33580  *                  g_variant_get_type_string (value));
33581  *
33582  *         /<!-- -->* no need to free 'key' and 'value' here *<!-- -->/
33583  *         /<!-- -->* unless breaking out of this loop *<!-- -->/
33584  *       }
33585  *   }
33586  *  </programlisting>
33587  * </example>
33588  *
33589  * For most cases you should use g_variant_iter_next().
33590  *
33591  * This function is really only useful when unpacking into #GVariant or
33592  * #GVariantIter in order to allow you to skip the call to
33593  * g_variant_unref() or g_variant_iter_free().
33594  *
33595  * For example, if you are only looping over simple integer and string
33596  * types, g_variant_iter_next() is definitely preferred.  For string
33597  * types, use the '&' prefix to avoid allocating any memory at all (and
33598  * thereby avoiding the need to free anything as well).
33599  *
33600  * @format_string determines the C types that are used for unpacking
33601  * the values and also determines if the values are copied or borrowed,
33602  * see the section on
33603  * <link linkend='gvariant-format-strings-pointers'>GVariant Format Strings</link>.
33604  *
33605  * Returns: %TRUE if a value was unpacked, or %FALSE if there was no
33606  *          value
33607  * Since: 2.24
33608  */
33609
33610
33611 /**
33612  * g_variant_iter_n_children:
33613  * @iter: a #GVariantIter
33614  *
33615  * Queries the number of child items in the container that we are
33616  * iterating over.  This is the total number of items -- not the number
33617  * of items remaining.
33618  *
33619  * This function might be useful for preallocation of arrays.
33620  *
33621  * Returns: the number of children in the container
33622  * Since: 2.24
33623  */
33624
33625
33626 /**
33627  * g_variant_iter_new:
33628  * @value: a container #GVariant
33629  *
33630  * Creates a heap-allocated #GVariantIter for iterating over the items
33631  * in @value.
33632  *
33633  * Use g_variant_iter_free() to free the return value when you no longer
33634  * need it.
33635  *
33636  * A reference is taken to @value and will be released only when
33637  * g_variant_iter_free() is called.
33638  *
33639  * Returns: (transfer full): a new heap-allocated #GVariantIter
33640  * Since: 2.24
33641  */
33642
33643
33644 /**
33645  * g_variant_iter_next: (skip)
33646  * @iter: a #GVariantIter
33647  * @format_string: a GVariant format string
33648  * @...: the arguments to unpack the value into
33649  *
33650  * Gets the next item in the container and unpacks it into the variable
33651  * argument list according to @format_string, returning %TRUE.
33652  *
33653  * If no more items remain then %FALSE is returned.
33654  *
33655  * All of the pointers given on the variable arguments list of this
33656  * function are assumed to point at uninitialised memory.  It is the
33657  * responsibility of the caller to free all of the values returned by
33658  * the unpacking process.
33659  *
33660  * See the section on <link linkend='gvariant-format-strings'>GVariant
33661  * Format Strings</link>.
33662  *
33663  * <example>
33664  *  <title>Memory management with g_variant_iter_next()</title>
33665  *  <programlisting>
33666  *   /<!-- -->* Iterates a dictionary of type 'a{sv}' *<!-- -->/
33667  *   void
33668  *   iterate_dictionary (GVariant *dictionary)
33669  *   {
33670  *     GVariantIter iter;
33671  *     GVariant *value;
33672  *     gchar *key;
33673  *
33674  *     g_variant_iter_init (&iter, dictionary);
33675  *     while (g_variant_iter_next (&iter, "{sv}", &key, &value))
33676  *       {
33677  *         g_print ("Item '%s' has type '%s'\n", key,
33678  *                  g_variant_get_type_string (value));
33679  *
33680  *         /<!-- -->* must free data for ourselves *<!-- -->/
33681  *         g_variant_unref (value);
33682  *         g_free (key);
33683  *       }
33684  *   }
33685  *  </programlisting>
33686  * </example>
33687  *
33688  * For a solution that is likely to be more convenient to C programmers
33689  * when dealing with loops, see g_variant_iter_loop().
33690  *
33691  * @format_string determines the C types that are used for unpacking
33692  * the values and also determines if the values are copied or borrowed,
33693  * see the section on
33694  * <link linkend='gvariant-format-strings-pointers'>GVariant Format Strings</link>.
33695  *
33696  * Returns: %TRUE if a value was unpacked, or %FALSE if there as no value
33697  * Since: 2.24
33698  */
33699
33700
33701 /**
33702  * g_variant_iter_next_value:
33703  * @iter: a #GVariantIter
33704  *
33705  * Gets the next item in the container.  If no more items remain then
33706  * %NULL is returned.
33707  *
33708  * Use g_variant_unref() to drop your reference on the return value when
33709  * you no longer need it.
33710  *
33711  * <example>
33712  *  <title>Iterating with g_variant_iter_next_value()</title>
33713  *  <programlisting>
33714  *   /<!-- -->* recursively iterate a container *<!-- -->/
33715  *   void
33716  *   iterate_container_recursive (GVariant *container)
33717  *   {
33718  *     GVariantIter iter;
33719  *     GVariant *child;
33720  *
33721  *     g_variant_iter_init (&iter, container);
33722  *     while ((child = g_variant_iter_next_value (&iter)))
33723  *       {
33724  *         g_print ("type '%s'\n", g_variant_get_type_string (child));
33725  *
33726  *         if (g_variant_is_container (child))
33727  *           iterate_container_recursive (child);
33728  *
33729  *         g_variant_unref (child);
33730  *       }
33731  *   }
33732  * </programlisting>
33733  * </example>
33734  *
33735  * Returns: (allow-none) (transfer full): a #GVariant, or %NULL
33736  * Since: 2.24
33737  */
33738
33739
33740 /**
33741  * g_variant_lookup: (skip)
33742  * @dictionary: a dictionary #GVariant
33743  * @key: the key to lookup in the dictionary
33744  * @format_string: a GVariant format string
33745  * @...: the arguments to unpack the value into
33746  *
33747  * Looks up a value in a dictionary #GVariant.
33748  *
33749  * This function is a wrapper around g_variant_lookup_value() and
33750  * g_variant_get().  In the case that %NULL would have been returned,
33751  * this function returns %FALSE.  Otherwise, it unpacks the returned
33752  * value and returns %TRUE.
33753  *
33754  * @format_string determines the C types that are used for unpacking
33755  * the values and also determines if the values are copied or borrowed,
33756  * see the section on
33757  * <link linkend='gvariant-format-strings-pointers'>GVariant Format Strings</link>.
33758  *
33759  * Returns: %TRUE if a value was unpacked
33760  * Since: 2.28
33761  */
33762
33763
33764 /**
33765  * g_variant_lookup_value:
33766  * @dictionary: a dictionary #GVariant
33767  * @key: the key to lookup in the dictionary
33768  * @expected_type: (allow-none): a #GVariantType, or %NULL
33769  *
33770  * Looks up a value in a dictionary #GVariant.
33771  *
33772  * This function works with dictionaries of the type
33773  * <literal>a{s*}</literal> (and equally well with type
33774  * <literal>a{o*}</literal>, but we only further discuss the string case
33775  * for sake of clarity).
33776  *
33777  * In the event that @dictionary has the type <literal>a{sv}</literal>,
33778  * the @expected_type string specifies what type of value is expected to
33779  * be inside of the variant.  If the value inside the variant has a
33780  * different type then %NULL is returned.  In the event that @dictionary
33781  * has a value type other than <literal>v</literal> then @expected_type
33782  * must directly match the key type and it is used to unpack the value
33783  * directly or an error occurs.
33784  *
33785  * In either case, if @key is not found in @dictionary, %NULL is
33786  * returned.
33787  *
33788  * If the key is found and the value has the correct type, it is
33789  * returned.  If @expected_type was specified then any non-%NULL return
33790  * value will have this type.
33791  *
33792  * Returns: (transfer full): the value of the dictionary key, or %NULL
33793  * Since: 2.28
33794  */
33795
33796
33797 /**
33798  * g_variant_n_children:
33799  * @value: a container #GVariant
33800  *
33801  * Determines the number of children in a container #GVariant instance.
33802  * This includes variants, maybes, arrays, tuples and dictionary
33803  * entries.  It is an error to call this function on any other type of
33804  * #GVariant.
33805  *
33806  * For variants, the return value is always 1.  For values with maybe
33807  * types, it is always zero or one.  For arrays, it is the length of the
33808  * array.  For tuples it is the number of tuple items (which depends
33809  * only on the type).  For dictionary entries, it is always 2
33810  *
33811  * This function is O(1).
33812  *
33813  * Returns: the number of children in the container
33814  * Since: 2.24
33815  */
33816
33817
33818 /**
33819  * g_variant_new: (skip)
33820  * @format_string: a #GVariant format string
33821  * @...: arguments, as per @format_string
33822  *
33823  * Creates a new #GVariant instance.
33824  *
33825  * Think of this function as an analogue to g_strdup_printf().
33826  *
33827  * The type of the created instance and the arguments that are
33828  * expected by this function are determined by @format_string.  See the
33829  * section on <link linkend='gvariant-format-strings'>GVariant Format
33830  * Strings</link>.  Please note that the syntax of the format string is
33831  * very likely to be extended in the future.
33832  *
33833  * The first character of the format string must not be '*' '?' '@' or
33834  * 'r'; in essence, a new #GVariant must always be constructed by this
33835  * function (and not merely passed through it unmodified).
33836  *
33837  * Returns: a new floating #GVariant instance
33838  * Since: 2.24
33839  */
33840
33841
33842 /**
33843  * g_variant_new_array:
33844  * @child_type: (allow-none): the element type of the new array
33845  * @children: (allow-none) (array length=n_children): an array of
33846  *            #GVariant pointers, the children
33847  * @n_children: the length of @children
33848  *
33849  * Creates a new #GVariant array from @children.
33850  *
33851  * @child_type must be non-%NULL if @n_children is zero.  Otherwise, the
33852  * child type is determined by inspecting the first element of the
33853  * @children array.  If @child_type is non-%NULL then it must be a
33854  * definite type.
33855  *
33856  * The items of the array are taken from the @children array.  No entry
33857  * in the @children array may be %NULL.
33858  *
33859  * All items in the array must have the same type, which must be the
33860  * same as @child_type, if given.
33861  *
33862  * If the @children are floating references (see g_variant_ref_sink()), the
33863  * new instance takes ownership of them as if via g_variant_ref_sink().
33864  *
33865  * Returns: (transfer none): a floating reference to a new #GVariant array
33866  * Since: 2.24
33867  */
33868
33869
33870 /**
33871  * g_variant_new_boolean:
33872  * @value: a #gboolean value
33873  *
33874  * Creates a new boolean #GVariant instance -- either %TRUE or %FALSE.
33875  *
33876  * Returns: (transfer none): a floating reference to a new boolean #GVariant instance
33877  * Since: 2.24
33878  */
33879
33880
33881 /**
33882  * g_variant_new_byte:
33883  * @value: a #guint8 value
33884  *
33885  * Creates a new byte #GVariant instance.
33886  *
33887  * Returns: (transfer none): a floating reference to a new byte #GVariant instance
33888  * Since: 2.24
33889  */
33890
33891
33892 /**
33893  * g_variant_new_bytestring:
33894  * @string: (array zero-terminated=1) (element-type guint8): a normal
33895  *          nul-terminated string in no particular encoding
33896  *
33897  * Creates an array-of-bytes #GVariant with the contents of @string.
33898  * This function is just like g_variant_new_string() except that the
33899  * string need not be valid utf8.
33900  *
33901  * The nul terminator character at the end of the string is stored in
33902  * the array.
33903  *
33904  * Returns: (transfer none): a floating reference to a new bytestring #GVariant instance
33905  * Since: 2.26
33906  */
33907
33908
33909 /**
33910  * g_variant_new_bytestring_array:
33911  * @strv: (array length=length): an array of strings
33912  * @length: the length of @strv, or -1
33913  *
33914  * Constructs an array of bytestring #GVariant from the given array of
33915  * strings.
33916  *
33917  * If @length is -1 then @strv is %NULL-terminated.
33918  *
33919  * Returns: (transfer none): a new floating #GVariant instance
33920  * Since: 2.26
33921  */
33922
33923
33924 /**
33925  * g_variant_new_dict_entry: (constructor)
33926  * @key: a basic #GVariant, the key
33927  * @value: a #GVariant, the value
33928  *
33929  * Creates a new dictionary entry #GVariant. @key and @value must be
33930  * non-%NULL. @key must be a value of a basic type (ie: not a container).
33931  *
33932  * If the @key or @value are floating references (see g_variant_ref_sink()),
33933  * the new instance takes ownership of them as if via g_variant_ref_sink().
33934  *
33935  * Returns: (transfer none): a floating reference to a new dictionary entry #GVariant
33936  * Since: 2.24
33937  */
33938
33939
33940 /**
33941  * g_variant_new_double:
33942  * @value: a #gdouble floating point value
33943  *
33944  * Creates a new double #GVariant instance.
33945  *
33946  * Returns: (transfer none): a floating reference to a new double #GVariant instance
33947  * Since: 2.24
33948  */
33949
33950
33951 /**
33952  * g_variant_new_fixed_array:
33953  * @element_type: the #GVariantType of each element
33954  * @elements: a pointer to the fixed array of contiguous elements
33955  * @n_elements: the number of elements
33956  * @element_size: the size of each element
33957  *
33958  * Provides access to the serialised data for an array of fixed-sized
33959  * items.
33960  *
33961  * @value must be an array with fixed-sized elements.  Numeric types are
33962  * fixed-size as are tuples containing only other fixed-sized types.
33963  *
33964  * @element_size must be the size of a single element in the array.  For
33965  * example, if calling this function for an array of 32 bit integers,
33966  * you might say <code>sizeof (gint32)</code>.  This value isn't used
33967  * except for the purpose of a double-check that the form of the
33968  * serialised data matches the caller's expectation.
33969  *
33970  * @n_elements, which must be non-%NULL is set equal to the number of
33971  * items in the array.
33972  *
33973  * Returns: (transfer none): a floating reference to a new array #GVariant instance
33974  * Since: 2.32
33975  */
33976
33977
33978 /**
33979  * g_variant_new_from_bytes:
33980  * @type: a #GVariantType
33981  * @bytes: a #GBytes
33982  * @trusted: if the contents of @bytes are trusted
33983  *
33984  * Constructs a new serialised-mode #GVariant instance.  This is the
33985  * inner interface for creation of new serialised values that gets
33986  * called from various functions in gvariant.c.
33987  *
33988  * A reference is taken on @bytes.
33989  *
33990  * Returns: (transfer none): a new #GVariant with a floating reference
33991  * Since: 2.36
33992  */
33993
33994
33995 /**
33996  * g_variant_new_from_data:
33997  * @type: a definite #GVariantType
33998  * @data: (array length=size) (element-type guint8): the serialised data
33999  * @size: the size of @data
34000  * @trusted: %TRUE if @data is definitely in normal form
34001  * @notify: (scope async): function to call when @data is no longer needed
34002  * @user_data: data for @notify
34003  *
34004  * Creates a new #GVariant instance from serialised data.
34005  *
34006  * @type is the type of #GVariant instance that will be constructed.
34007  * The interpretation of @data depends on knowing the type.
34008  *
34009  * @data is not modified by this function and must remain valid with an
34010  * unchanging value until such a time as @notify is called with
34011  * @user_data.  If the contents of @data change before that time then
34012  * the result is undefined.
34013  *
34014  * If @data is trusted to be serialised data in normal form then
34015  * @trusted should be %TRUE.  This applies to serialised data created
34016  * within this process or read from a trusted location on the disk (such
34017  * as a file installed in /usr/lib alongside your application).  You
34018  * should set trusted to %FALSE if @data is read from the network, a
34019  * file in the user's home directory, etc.
34020  *
34021  * If @data was not stored in this machine's native endianness, any multi-byte
34022  * numeric values in the returned variant will also be in non-native
34023  * endianness. g_variant_byteswap() can be used to recover the original values.
34024  *
34025  * @notify will be called with @user_data when @data is no longer
34026  * needed.  The exact time of this call is unspecified and might even be
34027  * before this function returns.
34028  *
34029  * Returns: (transfer none): a new floating #GVariant of type @type
34030  * Since: 2.24
34031  */
34032
34033
34034 /**
34035  * g_variant_new_handle:
34036  * @value: a #gint32 value
34037  *
34038  * Creates a new handle #GVariant instance.
34039  *
34040  * By convention, handles are indexes into an array of file descriptors
34041  * that are sent alongside a D-Bus message.  If you're not interacting
34042  * with D-Bus, you probably don't need them.
34043  *
34044  * Returns: (transfer none): a floating reference to a new handle #GVariant instance
34045  * Since: 2.24
34046  */
34047
34048
34049 /**
34050  * g_variant_new_int16:
34051  * @value: a #gint16 value
34052  *
34053  * Creates a new int16 #GVariant instance.
34054  *
34055  * Returns: (transfer none): a floating reference to a new int16 #GVariant instance
34056  * Since: 2.24
34057  */
34058
34059
34060 /**
34061  * g_variant_new_int32:
34062  * @value: a #gint32 value
34063  *
34064  * Creates a new int32 #GVariant instance.
34065  *
34066  * Returns: (transfer none): a floating reference to a new int32 #GVariant instance
34067  * Since: 2.24
34068  */
34069
34070
34071 /**
34072  * g_variant_new_int64:
34073  * @value: a #gint64 value
34074  *
34075  * Creates a new int64 #GVariant instance.
34076  *
34077  * Returns: (transfer none): a floating reference to a new int64 #GVariant instance
34078  * Since: 2.24
34079  */
34080
34081
34082 /**
34083  * g_variant_new_maybe:
34084  * @child_type: (allow-none): the #GVariantType of the child, or %NULL
34085  * @child: (allow-none): the child value, or %NULL
34086  *
34087  * Depending on if @child is %NULL, either wraps @child inside of a
34088  * maybe container or creates a Nothing instance for the given @type.
34089  *
34090  * At least one of @child_type and @child must be non-%NULL.
34091  * If @child_type is non-%NULL then it must be a definite type.
34092  * If they are both non-%NULL then @child_type must be the type
34093  * of @child.
34094  *
34095  * If @child is a floating reference (see g_variant_ref_sink()), the new
34096  * instance takes ownership of @child.
34097  *
34098  * Returns: (transfer none): a floating reference to a new #GVariant maybe instance
34099  * Since: 2.24
34100  */
34101
34102
34103 /**
34104  * g_variant_new_object_path:
34105  * @object_path: a normal C nul-terminated string
34106  *
34107  * Creates a D-Bus object path #GVariant with the contents of @string.
34108  * @string must be a valid D-Bus object path.  Use
34109  * g_variant_is_object_path() if you're not sure.
34110  *
34111  * Returns: (transfer none): a floating reference to a new object path #GVariant instance
34112  * Since: 2.24
34113  */
34114
34115
34116 /**
34117  * g_variant_new_objv:
34118  * @strv: (array length=length) (element-type utf8): an array of strings
34119  * @length: the length of @strv, or -1
34120  *
34121  * Constructs an array of object paths #GVariant from the given array of
34122  * strings.
34123  *
34124  * Each string must be a valid #GVariant object path; see
34125  * g_variant_is_object_path().
34126  *
34127  * If @length is -1 then @strv is %NULL-terminated.
34128  *
34129  * Returns: (transfer none): a new floating #GVariant instance
34130  * Since: 2.30
34131  */
34132
34133
34134 /**
34135  * g_variant_new_parsed:
34136  * @format: a text format #GVariant
34137  * @...: arguments as per @format
34138  *
34139  * Parses @format and returns the result.
34140  *
34141  * @format must be a text format #GVariant with one extension: at any
34142  * point that a value may appear in the text, a '%' character followed
34143  * by a GVariant format string (as per g_variant_new()) may appear.  In
34144  * that case, the same arguments are collected from the argument list as
34145  * g_variant_new() would have collected.
34146  *
34147  * Consider this simple example:
34148  *
34149  * <informalexample><programlisting>
34150  *  g_variant_new_parsed ("[('one', 1), ('two', %i), (%s, 3)]", 2, "three");
34151  * </programlisting></informalexample>
34152  *
34153  * In the example, the variable argument parameters are collected and
34154  * filled in as if they were part of the original string to produce the
34155  * result of <code>[('one', 1), ('two', 2), ('three', 3)]</code>.
34156  *
34157  * This function is intended only to be used with @format as a string
34158  * literal.  Any parse error is fatal to the calling process.  If you
34159  * want to parse data from untrusted sources, use g_variant_parse().
34160  *
34161  * You may not use this function to return, unmodified, a single
34162  * #GVariant pointer from the argument list.  ie: @format may not solely
34163  * be anything along the lines of "%*", "%?", "\%r", or anything starting
34164  * with "%@".
34165  *
34166  * Returns: a new floating #GVariant instance
34167  */
34168
34169
34170 /**
34171  * g_variant_new_parsed_va:
34172  * @format: a text format #GVariant
34173  * @app: a pointer to a #va_list
34174  *
34175  * Parses @format and returns the result.
34176  *
34177  * This is the version of g_variant_new_parsed() intended to be used
34178  * from libraries.
34179  *
34180  * The return value will be floating if it was a newly created GVariant
34181  * instance.  In the case that @format simply specified the collection
34182  * of a #GVariant pointer (eg: @format was "%*") then the collected
34183  * #GVariant pointer will be returned unmodified, without adding any
34184  * additional references.
34185  *
34186  * In order to behave correctly in all cases it is necessary for the
34187  * calling function to g_variant_ref_sink() the return result before
34188  * returning control to the user that originally provided the pointer.
34189  * At this point, the caller will have their own full reference to the
34190  * result.  This can also be done by adding the result to a container,
34191  * or by passing it to another g_variant_new() call.
34192  *
34193  * Returns: a new, usually floating, #GVariant
34194  */
34195
34196
34197 /**
34198  * g_variant_new_printf: (skip)
34199  * @format_string: a printf-style format string
34200  * @...: arguments for @format_string
34201  *
34202  * Creates a string-type GVariant using printf formatting.
34203  *
34204  * This is similar to calling g_strdup_printf() and then
34205  * g_variant_new_string() but it saves a temporary variable and an
34206  * unnecessary copy.
34207  *
34208  * Returns: (transfer none): a floating reference to a new string
34209  *   #GVariant instance
34210  * Since: 2.38
34211  */
34212
34213
34214 /**
34215  * g_variant_new_signature:
34216  * @signature: a normal C nul-terminated string
34217  *
34218  * Creates a D-Bus type signature #GVariant with the contents of
34219  * @string.  @string must be a valid D-Bus type signature.  Use
34220  * g_variant_is_signature() if you're not sure.
34221  *
34222  * Returns: (transfer none): a floating reference to a new signature #GVariant instance
34223  * Since: 2.24
34224  */
34225
34226
34227 /**
34228  * g_variant_new_string:
34229  * @string: a normal utf8 nul-terminated string
34230  *
34231  * Creates a string #GVariant with the contents of @string.
34232  *
34233  * @string must be valid utf8.
34234  *
34235  * Returns: (transfer none): a floating reference to a new string #GVariant instance
34236  * Since: 2.24
34237  */
34238
34239
34240 /**
34241  * g_variant_new_strv:
34242  * @strv: (array length=length) (element-type utf8): an array of strings
34243  * @length: the length of @strv, or -1
34244  *
34245  * Constructs an array of strings #GVariant from the given array of
34246  * strings.
34247  *
34248  * If @length is -1 then @strv is %NULL-terminated.
34249  *
34250  * Returns: (transfer none): a new floating #GVariant instance
34251  * Since: 2.24
34252  */
34253
34254
34255 /**
34256  * g_variant_new_take_string: (skip)
34257  * @string: a normal utf8 nul-terminated string
34258  *
34259  * Creates a string #GVariant with the contents of @string.
34260  *
34261  * @string must be valid utf8.
34262  *
34263  * This function consumes @string.  g_free() will be called on @string
34264  * when it is no longer required.
34265  *
34266  * You must not modify or access @string in any other way after passing
34267  * it to this function.  It is even possible that @string is immediately
34268  * freed.
34269  *
34270  * Returns: (transfer none): a floating reference to a new string
34271  *   #GVariant instance
34272  * Since: 2.38
34273  */
34274
34275
34276 /**
34277  * g_variant_new_tuple:
34278  * @children: (array length=n_children): the items to make the tuple out of
34279  * @n_children: the length of @children
34280  *
34281  * Creates a new tuple #GVariant out of the items in @children.  The
34282  * type is determined from the types of @children.  No entry in the
34283  * @children array may be %NULL.
34284  *
34285  * If @n_children is 0 then the unit tuple is constructed.
34286  *
34287  * If the @children are floating references (see g_variant_ref_sink()), the
34288  * new instance takes ownership of them as if via g_variant_ref_sink().
34289  *
34290  * Returns: (transfer none): a floating reference to a new #GVariant tuple
34291  * Since: 2.24
34292  */
34293
34294
34295 /**
34296  * g_variant_new_uint16:
34297  * @value: a #guint16 value
34298  *
34299  * Creates a new uint16 #GVariant instance.
34300  *
34301  * Returns: (transfer none): a floating reference to a new uint16 #GVariant instance
34302  * Since: 2.24
34303  */
34304
34305
34306 /**
34307  * g_variant_new_uint32:
34308  * @value: a #guint32 value
34309  *
34310  * Creates a new uint32 #GVariant instance.
34311  *
34312  * Returns: (transfer none): a floating reference to a new uint32 #GVariant instance
34313  * Since: 2.24
34314  */
34315
34316
34317 /**
34318  * g_variant_new_uint64:
34319  * @value: a #guint64 value
34320  *
34321  * Creates a new uint64 #GVariant instance.
34322  *
34323  * Returns: (transfer none): a floating reference to a new uint64 #GVariant instance
34324  * Since: 2.24
34325  */
34326
34327
34328 /**
34329  * g_variant_new_va: (skip)
34330  * @format_string: a string that is prefixed with a format string
34331  * @endptr: (allow-none) (default NULL): location to store the end pointer,
34332  *          or %NULL
34333  * @app: a pointer to a #va_list
34334  *
34335  * This function is intended to be used by libraries based on
34336  * #GVariant that want to provide g_variant_new()-like functionality
34337  * to their users.
34338  *
34339  * The API is more general than g_variant_new() to allow a wider range
34340  * of possible uses.
34341  *
34342  * @format_string must still point to a valid format string, but it only
34343  * needs to be nul-terminated if @endptr is %NULL.  If @endptr is
34344  * non-%NULL then it is updated to point to the first character past the
34345  * end of the format string.
34346  *
34347  * @app is a pointer to a #va_list.  The arguments, according to
34348  * @format_string, are collected from this #va_list and the list is left
34349  * pointing to the argument following the last.
34350  *
34351  * These two generalisations allow mixing of multiple calls to
34352  * g_variant_new_va() and g_variant_get_va() within a single actual
34353  * varargs call by the user.
34354  *
34355  * The return value will be floating if it was a newly created GVariant
34356  * instance (for example, if the format string was "(ii)").  In the case
34357  * that the format_string was '*', '?', 'r', or a format starting with
34358  * '@' then the collected #GVariant pointer will be returned unmodified,
34359  * without adding any additional references.
34360  *
34361  * In order to behave correctly in all cases it is necessary for the
34362  * calling function to g_variant_ref_sink() the return result before
34363  * returning control to the user that originally provided the pointer.
34364  * At this point, the caller will have their own full reference to the
34365  * result.  This can also be done by adding the result to a container,
34366  * or by passing it to another g_variant_new() call.
34367  *
34368  * Returns: a new, usually floating, #GVariant
34369  * Since: 2.24
34370  */
34371
34372
34373 /**
34374  * g_variant_new_variant: (constructor)
34375  * @value: a #GVariant instance
34376  *
34377  * Boxes @value.  The result is a #GVariant instance representing a
34378  * variant containing the original value.
34379  *
34380  * If @child is a floating reference (see g_variant_ref_sink()), the new
34381  * instance takes ownership of @child.
34382  *
34383  * Returns: (transfer none): a floating reference to a new variant #GVariant instance
34384  * Since: 2.24
34385  */
34386
34387
34388 /**
34389  * g_variant_parse:
34390  * @type: (allow-none): a #GVariantType, or %NULL
34391  * @text: a string containing a GVariant in text form
34392  * @limit: (allow-none): a pointer to the end of @text, or %NULL
34393  * @endptr: (allow-none): a location to store the end pointer, or %NULL
34394  * @error: (allow-none): a pointer to a %NULL #GError pointer, or %NULL
34395  *
34396  * Parses a #GVariant from a text representation.
34397  *
34398  * A single #GVariant is parsed from the content of @text.
34399  *
34400  * The format is described <link linkend='gvariant-text'>here</link>.
34401  *
34402  * The memory at @limit will never be accessed and the parser behaves as
34403  * if the character at @limit is the nul terminator.  This has the
34404  * effect of bounding @text.
34405  *
34406  * If @endptr is non-%NULL then @text is permitted to contain data
34407  * following the value that this function parses and @endptr will be
34408  * updated to point to the first character past the end of the text
34409  * parsed by this function.  If @endptr is %NULL and there is extra data
34410  * then an error is returned.
34411  *
34412  * If @type is non-%NULL then the value will be parsed to have that
34413  * type.  This may result in additional parse errors (in the case that
34414  * the parsed value doesn't fit the type) but may also result in fewer
34415  * errors (in the case that the type would have been ambiguous, such as
34416  * with empty arrays).
34417  *
34418  * In the event that the parsing is successful, the resulting #GVariant
34419  * is returned.
34420  *
34421  * In case of any error, %NULL will be returned.  If @error is non-%NULL
34422  * then it will be set to reflect the error that occurred.
34423  *
34424  * Officially, the language understood by the parser is "any string
34425  * produced by g_variant_print()".
34426  *
34427  * Returns: a reference to a #GVariant, or %NULL
34428  */
34429
34430
34431 /**
34432  * g_variant_print:
34433  * @value: a #GVariant
34434  * @type_annotate: %TRUE if type information should be included in
34435  *                 the output
34436  *
34437  * Pretty-prints @value in the format understood by g_variant_parse().
34438  *
34439  * The format is described <link linkend='gvariant-text'>here</link>.
34440  *
34441  * If @type_annotate is %TRUE, then type information is included in
34442  * the output.
34443  *
34444  * Returns: (transfer full): a newly-allocated string holding the result.
34445  * Since: 2.24
34446  */
34447
34448
34449 /**
34450  * g_variant_print_string: (skip)
34451  * @value: a #GVariant
34452  * @string: (allow-none) (default NULL): a #GString, or %NULL
34453  * @type_annotate: %TRUE if type information should be included in
34454  *                 the output
34455  *
34456  * Behaves as g_variant_print(), but operates on a #GString.
34457  *
34458  * If @string is non-%NULL then it is appended to and returned.  Else,
34459  * a new empty #GString is allocated and it is returned.
34460  *
34461  * Returns: a #GString containing the string
34462  * Since: 2.24
34463  */
34464
34465
34466 /**
34467  * g_variant_ref:
34468  * @value: a #GVariant
34469  *
34470  * Increases the reference count of @value.
34471  *
34472  * Returns: the same @value
34473  * Since: 2.24
34474  */
34475
34476
34477 /**
34478  * g_variant_ref_sink:
34479  * @value: a #GVariant
34480  *
34481  * #GVariant uses a floating reference count system.  All functions with
34482  * names starting with <literal>g_variant_new_</literal> return floating
34483  * references.
34484  *
34485  * Calling g_variant_ref_sink() on a #GVariant with a floating reference
34486  * will convert the floating reference into a full reference.  Calling
34487  * g_variant_ref_sink() on a non-floating #GVariant results in an
34488  * additional normal reference being added.
34489  *
34490  * In other words, if the @value is floating, then this call "assumes
34491  * ownership" of the floating reference, converting it to a normal
34492  * reference.  If the @value is not floating, then this call adds a
34493  * new normal reference increasing the reference count by one.
34494  *
34495  * All calls that result in a #GVariant instance being inserted into a
34496  * container will call g_variant_ref_sink() on the instance.  This means
34497  * that if the value was just created (and has only its floating
34498  * reference) then the container will assume sole ownership of the value
34499  * at that point and the caller will not need to unreference it.  This
34500  * makes certain common styles of programming much easier while still
34501  * maintaining normal refcounting semantics in situations where values
34502  * are not floating.
34503  *
34504  * Returns: the same @value
34505  * Since: 2.24
34506  */
34507
34508
34509 /**
34510  * g_variant_store:
34511  * @value: the #GVariant to store
34512  * @data: the location to store the serialised data at
34513  *
34514  * Stores the serialised form of @value at @data.  @data should be
34515  * large enough.  See g_variant_get_size().
34516  *
34517  * The stored data is in machine native byte order but may not be in
34518  * fully-normalised form if read from an untrusted source.  See
34519  * g_variant_get_normal_form() for a solution.
34520  *
34521  * As with g_variant_get_data(), to be able to deserialise the
34522  * serialised variant successfully, its type and (if the destination
34523  * machine might be different) its endianness must also be available.
34524  *
34525  * This function is approximately O(n) in the size of @data.
34526  *
34527  * Since: 2.24
34528  */
34529
34530
34531 /**
34532  * g_variant_take_ref:
34533  * @value: a #GVariant
34534  *
34535  * If @value is floating, sink it.  Otherwise, do nothing.
34536  *
34537  * Typically you want to use g_variant_ref_sink() in order to
34538  * automatically do the correct thing with respect to floating or
34539  * non-floating references, but there is one specific scenario where
34540  * this function is helpful.
34541  *
34542  * The situation where this function is helpful is when creating an API
34543  * that allows the user to provide a callback function that returns a
34544  * #GVariant.  We certainly want to allow the user the flexibility to
34545  * return a non-floating reference from this callback (for the case
34546  * where the value that is being returned already exists).
34547  *
34548  * At the same time, the style of the #GVariant API makes it likely that
34549  * for newly-created #GVariant instances, the user can be saved some
34550  * typing if they are allowed to return a #GVariant with a floating
34551  * reference.
34552  *
34553  * Using this function on the return value of the user's callback allows
34554  * the user to do whichever is more convenient for them.  The caller
34555  * will alway receives exactly one full reference to the value: either
34556  * the one that was returned in the first place, or a floating reference
34557  * that has been converted to a full reference.
34558  *
34559  * This function has an odd interaction when combined with
34560  * g_variant_ref_sink() running at the same time in another thread on
34561  * the same #GVariant instance.  If g_variant_ref_sink() runs first then
34562  * the result will be that the floating reference is converted to a hard
34563  * reference.  If g_variant_take_ref() runs first then the result will
34564  * be that the floating reference is converted to a hard reference and
34565  * an additional reference on top of that one is added.  It is best to
34566  * avoid this situation.
34567  *
34568  * Returns: the same @value
34569  */
34570
34571
34572 /**
34573  * g_variant_type_copy:
34574  * @type: a #GVariantType
34575  *
34576  * Makes a copy of a #GVariantType.  It is appropriate to call
34577  * g_variant_type_free() on the return value.  @type may not be %NULL.
34578  *
34579  * Returns: (transfer full): a new #GVariantType
34580  *
34581  * Since 2.24
34582  */
34583
34584
34585 /**
34586  * g_variant_type_dup_string:
34587  * @type: a #GVariantType
34588  *
34589  * Returns a newly-allocated copy of the type string corresponding to
34590  * @type.  The returned string is nul-terminated.  It is appropriate to
34591  * call g_free() on the return value.
34592  *
34593  * Returns: (transfer full): the corresponding type string
34594  *
34595  * Since 2.24
34596  */
34597
34598
34599 /**
34600  * g_variant_type_element:
34601  * @type: an array or maybe #GVariantType
34602  *
34603  * Determines the element type of an array or maybe type.
34604  *
34605  * This function may only be used with array or maybe types.
34606  *
34607  * Returns: (transfer none): the element type of @type
34608  *
34609  * Since 2.24
34610  */
34611
34612
34613 /**
34614  * g_variant_type_equal:
34615  * @type1: (type GVariantType): a #GVariantType
34616  * @type2: (type GVariantType): a #GVariantType
34617  *
34618  * Compares @type1 and @type2 for equality.
34619  *
34620  * Only returns %TRUE if the types are exactly equal.  Even if one type
34621  * is an indefinite type and the other is a subtype of it, %FALSE will
34622  * be returned if they are not exactly equal.  If you want to check for
34623  * subtypes, use g_variant_type_is_subtype_of().
34624  *
34625  * The argument types of @type1 and @type2 are only #gconstpointer to
34626  * allow use with #GHashTable without function pointer casting.  For
34627  * both arguments, a valid #GVariantType must be provided.
34628  *
34629  * Returns: %TRUE if @type1 and @type2 are exactly equal
34630  *
34631  * Since 2.24
34632  */
34633
34634
34635 /**
34636  * g_variant_type_first:
34637  * @type: a tuple or dictionary entry #GVariantType
34638  *
34639  * Determines the first item type of a tuple or dictionary entry
34640  * type.
34641  *
34642  * This function may only be used with tuple or dictionary entry types,
34643  * but must not be used with the generic tuple type
34644  * %G_VARIANT_TYPE_TUPLE.
34645  *
34646  * In the case of a dictionary entry type, this returns the type of
34647  * the key.
34648  *
34649  * %NULL is returned in case of @type being %G_VARIANT_TYPE_UNIT.
34650  *
34651  * This call, together with g_variant_type_next() provides an iterator
34652  * interface over tuple and dictionary entry types.
34653  *
34654  * Returns: (transfer none): the first item type of @type, or %NULL
34655  *
34656  * Since 2.24
34657  */
34658
34659
34660 /**
34661  * g_variant_type_free:
34662  * @type: (allow-none): a #GVariantType, or %NULL
34663  *
34664  * Frees a #GVariantType that was allocated with
34665  * g_variant_type_copy(), g_variant_type_new() or one of the container
34666  * type constructor functions.
34667  *
34668  * In the case that @type is %NULL, this function does nothing.
34669  *
34670  * Since 2.24
34671  */
34672
34673
34674 /**
34675  * g_variant_type_get_string_length:
34676  * @type: a #GVariantType
34677  *
34678  * Returns the length of the type string corresponding to the given
34679  * @type.  This function must be used to determine the valid extent of
34680  * the memory region returned by g_variant_type_peek_string().
34681  *
34682  * Returns: the length of the corresponding type string
34683  *
34684  * Since 2.24
34685  */
34686
34687
34688 /**
34689  * g_variant_type_hash:
34690  * @type: (type GVariantType): a #GVariantType
34691  *
34692  * Hashes @type.
34693  *
34694  * The argument type of @type is only #gconstpointer to allow use with
34695  * #GHashTable without function pointer casting.  A valid
34696  * #GVariantType must be provided.
34697  *
34698  * Returns: the hash value
34699  *
34700  * Since 2.24
34701  */
34702
34703
34704 /**
34705  * g_variant_type_is_array:
34706  * @type: a #GVariantType
34707  *
34708  * Determines if the given @type is an array type.  This is true if the
34709  * type string for @type starts with an 'a'.
34710  *
34711  * This function returns %TRUE for any indefinite type for which every
34712  * definite subtype is an array type -- %G_VARIANT_TYPE_ARRAY, for
34713  * example.
34714  *
34715  * Returns: %TRUE if @type is an array type
34716  *
34717  * Since 2.24
34718  */
34719
34720
34721 /**
34722  * g_variant_type_is_basic:
34723  * @type: a #GVariantType
34724  *
34725  * Determines if the given @type is a basic type.
34726  *
34727  * Basic types are booleans, bytes, integers, doubles, strings, object
34728  * paths and signatures.
34729  *
34730  * Only a basic type may be used as the key of a dictionary entry.
34731  *
34732  * This function returns %FALSE for all indefinite types except
34733  * %G_VARIANT_TYPE_BASIC.
34734  *
34735  * Returns: %TRUE if @type is a basic type
34736  *
34737  * Since 2.24
34738  */
34739
34740
34741 /**
34742  * g_variant_type_is_container:
34743  * @type: a #GVariantType
34744  *
34745  * Determines if the given @type is a container type.
34746  *
34747  * Container types are any array, maybe, tuple, or dictionary
34748  * entry types plus the variant type.
34749  *
34750  * This function returns %TRUE for any indefinite type for which every
34751  * definite subtype is a container -- %G_VARIANT_TYPE_ARRAY, for
34752  * example.
34753  *
34754  * Returns: %TRUE if @type is a container type
34755  *
34756  * Since 2.24
34757  */
34758
34759
34760 /**
34761  * g_variant_type_is_definite:
34762  * @type: a #GVariantType
34763  *
34764  * Determines if the given @type is definite (ie: not indefinite).
34765  *
34766  * A type is definite if its type string does not contain any indefinite
34767  * type characters ('*', '?', or 'r').
34768  *
34769  * A #GVariant instance may not have an indefinite type, so calling
34770  * this function on the result of g_variant_get_type() will always
34771  * result in %TRUE being returned.  Calling this function on an
34772  * indefinite type like %G_VARIANT_TYPE_ARRAY, however, will result in
34773  * %FALSE being returned.
34774  *
34775  * Returns: %TRUE if @type is definite
34776  *
34777  * Since 2.24
34778  */
34779
34780
34781 /**
34782  * g_variant_type_is_dict_entry:
34783  * @type: a #GVariantType
34784  *
34785  * Determines if the given @type is a dictionary entry type.  This is
34786  * true if the type string for @type starts with a '{'.
34787  *
34788  * This function returns %TRUE for any indefinite type for which every
34789  * definite subtype is a dictionary entry type --
34790  * %G_VARIANT_TYPE_DICT_ENTRY, for example.
34791  *
34792  * Returns: %TRUE if @type is a dictionary entry type
34793  *
34794  * Since 2.24
34795  */
34796
34797
34798 /**
34799  * g_variant_type_is_maybe:
34800  * @type: a #GVariantType
34801  *
34802  * Determines if the given @type is a maybe type.  This is true if the
34803  * type string for @type starts with an 'm'.
34804  *
34805  * This function returns %TRUE for any indefinite type for which every
34806  * definite subtype is a maybe type -- %G_VARIANT_TYPE_MAYBE, for
34807  * example.
34808  *
34809  * Returns: %TRUE if @type is a maybe type
34810  *
34811  * Since 2.24
34812  */
34813
34814
34815 /**
34816  * g_variant_type_is_subtype_of:
34817  * @type: a #GVariantType
34818  * @supertype: a #GVariantType
34819  *
34820  * Checks if @type is a subtype of @supertype.
34821  *
34822  * This function returns %TRUE if @type is a subtype of @supertype.  All
34823  * types are considered to be subtypes of themselves.  Aside from that,
34824  * only indefinite types can have subtypes.
34825  *
34826  * Returns: %TRUE if @type is a subtype of @supertype
34827  *
34828  * Since 2.24
34829  */
34830
34831
34832 /**
34833  * g_variant_type_is_tuple:
34834  * @type: a #GVariantType
34835  *
34836  * Determines if the given @type is a tuple type.  This is true if the
34837  * type string for @type starts with a '(' or if @type is
34838  * %G_VARIANT_TYPE_TUPLE.
34839  *
34840  * This function returns %TRUE for any indefinite type for which every
34841  * definite subtype is a tuple type -- %G_VARIANT_TYPE_TUPLE, for
34842  * example.
34843  *
34844  * Returns: %TRUE if @type is a tuple type
34845  *
34846  * Since 2.24
34847  */
34848
34849
34850 /**
34851  * g_variant_type_is_variant:
34852  * @type: a #GVariantType
34853  *
34854  * Determines if the given @type is the variant type.
34855  *
34856  * Returns: %TRUE if @type is the variant type
34857  *
34858  * Since 2.24
34859  */
34860
34861
34862 /**
34863  * g_variant_type_key:
34864  * @type: a dictionary entry #GVariantType
34865  *
34866  * Determines the key type of a dictionary entry type.
34867  *
34868  * This function may only be used with a dictionary entry type.  Other
34869  * than the additional restriction, this call is equivalent to
34870  * g_variant_type_first().
34871  *
34872  * Returns: (transfer none): the key type of the dictionary entry
34873  *
34874  * Since 2.24
34875  */
34876
34877
34878 /**
34879  * g_variant_type_n_items:
34880  * @type: a tuple or dictionary entry #GVariantType
34881  *
34882  * Determines the number of items contained in a tuple or
34883  * dictionary entry type.
34884  *
34885  * This function may only be used with tuple or dictionary entry types,
34886  * but must not be used with the generic tuple type
34887  * %G_VARIANT_TYPE_TUPLE.
34888  *
34889  * In the case of a dictionary entry type, this function will always
34890  * return 2.
34891  *
34892  * Returns: the number of items in @type
34893  *
34894  * Since 2.24
34895  */
34896
34897
34898 /**
34899  * g_variant_type_new:
34900  * @type_string: a valid GVariant type string
34901  *
34902  * Creates a new #GVariantType corresponding to the type string given
34903  * by @type_string.  It is appropriate to call g_variant_type_free() on
34904  * the return value.
34905  *
34906  * It is a programmer error to call this function with an invalid type
34907  * string.  Use g_variant_type_string_is_valid() if you are unsure.
34908  *
34909  * Returns: (transfer full): a new #GVariantType
34910  * Since: 2.24
34911  */
34912
34913
34914 /**
34915  * g_variant_type_new_array: (constructor)
34916  * @element: a #GVariantType
34917  *
34918  * Constructs the type corresponding to an array of elements of the
34919  * type @type.
34920  *
34921  * It is appropriate to call g_variant_type_free() on the return value.
34922  *
34923  * Returns: (transfer full): a new array #GVariantType
34924  *
34925  * Since 2.24
34926  */
34927
34928
34929 /**
34930  * g_variant_type_new_dict_entry: (constructor)
34931  * @key: a basic #GVariantType
34932  * @value: a #GVariantType
34933  *
34934  * Constructs the type corresponding to a dictionary entry with a key
34935  * of type @key and a value of type @value.
34936  *
34937  * It is appropriate to call g_variant_type_free() on the return value.
34938  *
34939  * Returns: (transfer full): a new dictionary entry #GVariantType
34940  *
34941  * Since 2.24
34942  */
34943
34944
34945 /**
34946  * g_variant_type_new_maybe: (constructor)
34947  * @element: a #GVariantType
34948  *
34949  * Constructs the type corresponding to a maybe instance containing
34950  * type @type or Nothing.
34951  *
34952  * It is appropriate to call g_variant_type_free() on the return value.
34953  *
34954  * Returns: (transfer full): a new maybe #GVariantType
34955  *
34956  * Since 2.24
34957  */
34958
34959
34960 /**
34961  * g_variant_type_new_tuple:
34962  * @items: (array length=length): an array of #GVariantTypes, one for each item
34963  * @length: the length of @items, or -1
34964  *
34965  * Constructs a new tuple type, from @items.
34966  *
34967  * @length is the number of items in @items, or -1 to indicate that
34968  * @items is %NULL-terminated.
34969  *
34970  * It is appropriate to call g_variant_type_free() on the return value.
34971  *
34972  * Returns: (transfer full): a new tuple #GVariantType
34973  *
34974  * Since 2.24
34975  */
34976
34977
34978 /**
34979  * g_variant_type_next:
34980  * @type: a #GVariantType from a previous call
34981  *
34982  * Determines the next item type of a tuple or dictionary entry
34983  * type.
34984  *
34985  * @type must be the result of a previous call to
34986  * g_variant_type_first() or g_variant_type_next().
34987  *
34988  * If called on the key type of a dictionary entry then this call
34989  * returns the value type.  If called on the value type of a dictionary
34990  * entry then this call returns %NULL.
34991  *
34992  * For tuples, %NULL is returned when @type is the last item in a tuple.
34993  *
34994  * Returns: (transfer none): the next #GVariantType after @type, or %NULL
34995  *
34996  * Since 2.24
34997  */
34998
34999
35000 /**
35001  * g_variant_type_peek_string: (skip)
35002  * @type: a #GVariantType
35003  *
35004  * Returns the type string corresponding to the given @type.  The
35005  * result is not nul-terminated; in order to determine its length you
35006  * must call g_variant_type_get_string_length().
35007  *
35008  * To get a nul-terminated string, see g_variant_type_dup_string().
35009  *
35010  * Returns: the corresponding type string (not nul-terminated)
35011  *
35012  * Since 2.24
35013  */
35014
35015
35016 /**
35017  * g_variant_type_string_is_valid:
35018  * @type_string: a pointer to any string
35019  *
35020  * Checks if @type_string is a valid GVariant type string.  This call is
35021  * equivalent to calling g_variant_type_string_scan() and confirming
35022  * that the following character is a nul terminator.
35023  *
35024  * Returns: %TRUE if @type_string is exactly one valid type string
35025  *
35026  * Since 2.24
35027  */
35028
35029
35030 /**
35031  * g_variant_type_string_scan:
35032  * @string: a pointer to any string
35033  * @limit: (allow-none): the end of @string, or %NULL
35034  * @endptr: (out) (allow-none): location to store the end pointer, or %NULL
35035  *
35036  * Scan for a single complete and valid GVariant type string in @string.
35037  * The memory pointed to by @limit (or bytes beyond it) is never
35038  * accessed.
35039  *
35040  * If a valid type string is found, @endptr is updated to point to the
35041  * first character past the end of the string that was found and %TRUE
35042  * is returned.
35043  *
35044  * If there is no valid type string starting at @string, or if the type
35045  * string does not end before @limit then %FALSE is returned.
35046  *
35047  * For the simple case of checking if a string is a valid type string,
35048  * see g_variant_type_string_is_valid().
35049  *
35050  * Returns: %TRUE if a valid type string was found
35051  * Since: 2.24
35052  */
35053
35054
35055 /**
35056  * g_variant_type_value:
35057  * @type: a dictionary entry #GVariantType
35058  *
35059  * Determines the value type of a dictionary entry type.
35060  *
35061  * This function may only be used with a dictionary entry type.
35062  *
35063  * Returns: (transfer none): the value type of the dictionary entry
35064  *
35065  * Since 2.24
35066  */
35067
35068
35069 /**
35070  * g_variant_unref:
35071  * @value: a #GVariant
35072  *
35073  * Decreases the reference count of @value.  When its reference count
35074  * drops to 0, the memory used by the variant is freed.
35075  *
35076  * Since: 2.24
35077  */
35078
35079
35080 /**
35081  * g_vasprintf:
35082  * @string: the return location for the newly-allocated string.
35083  * @format: a standard printf() format string, but notice
35084  *          <link linkend="string-precision">string precision pitfalls</link>.
35085  * @args: the list of arguments to insert in the output.
35086  *
35087  * An implementation of the GNU vasprintf() function which supports
35088  * positional parameters, as specified in the Single Unix Specification.
35089  * This function is similar to g_vsprintf(), except that it allocates a
35090  * string to hold the output, instead of putting the output in a buffer
35091  * you allocate in advance.
35092  *
35093  * Returns: the number of bytes printed.
35094  * Since: 2.4
35095  */
35096
35097
35098 /**
35099  * g_vfprintf:
35100  * @file: the stream to write to.
35101  * @format: a standard printf() format string, but notice
35102  *          <link linkend="string-precision">string precision pitfalls</link>.
35103  * @args: the list of arguments to insert in the output.
35104  *
35105  * An implementation of the standard fprintf() function which supports
35106  * positional parameters, as specified in the Single Unix Specification.
35107  *
35108  * Returns: the number of bytes printed.
35109  * Since: 2.2
35110  */
35111
35112
35113 /**
35114  * g_vprintf:
35115  * @format: a standard printf() format string, but notice
35116  *          <link linkend="string-precision">string precision pitfalls</link>.
35117  * @args: the list of arguments to insert in the output.
35118  *
35119  * An implementation of the standard vprintf() function which supports
35120  * positional parameters, as specified in the Single Unix Specification.
35121  *
35122  * Returns: the number of bytes printed.
35123  * Since: 2.2
35124  */
35125
35126
35127 /**
35128  * g_vsnprintf:
35129  * @string: the buffer to hold the output.
35130  * @n: the maximum number of bytes to produce (including the
35131  *     terminating nul character).
35132  * @format: a standard printf() format string, but notice
35133  *          <link linkend="string-precision">string precision pitfalls</link>.
35134  * @args: the list of arguments to insert in the output.
35135  *
35136  * A safer form of the standard vsprintf() function. The output is guaranteed
35137  * to not exceed @n characters (including the terminating nul character), so
35138  * it is easy to ensure that a buffer overflow cannot occur.
35139  *
35140  * See also g_strdup_vprintf().
35141  *
35142  * In versions of GLib prior to 1.2.3, this function may return -1 if the
35143  * output was truncated, and the truncated string may not be nul-terminated.
35144  * In versions prior to 1.3.12, this function returns the length of the output
35145  * string.
35146  *
35147  * The return value of g_vsnprintf() conforms to the vsnprintf() function
35148  * as standardized in ISO C99. Note that this is different from traditional
35149  * vsnprintf(), which returns the length of the output string.
35150  *
35151  * The format string may contain positional parameters, as specified in
35152  * the Single Unix Specification.
35153  *
35154  * Returns: the number of bytes which would be produced if the buffer
35155  *  was large enough.
35156  */
35157
35158
35159 /**
35160  * g_vsprintf:
35161  * @string: the buffer to hold the output.
35162  * @format: a standard printf() format string, but notice
35163  *          <link linkend="string-precision">string precision pitfalls</link>.
35164  * @args: the list of arguments to insert in the output.
35165  *
35166  * An implementation of the standard vsprintf() function which supports
35167  * positional parameters, as specified in the Single Unix Specification.
35168  *
35169  * Returns: the number of bytes printed.
35170  * Since: 2.2
35171  */
35172
35173
35174 /**
35175  * g_wakeup_acknowledge:
35176  * @wakeup: a #GWakeup
35177  *
35178  * Acknowledges receipt of a wakeup signal on @wakeup.
35179  *
35180  * You must call this after @wakeup polls as ready.  If not, it will
35181  * continue to poll as ready until you do so.
35182  *
35183  * If you call this function and @wakeup is not signaled, nothing
35184  * happens.
35185  *
35186  * Since: 2.30
35187  */
35188
35189
35190 /**
35191  * g_wakeup_free:
35192  * @wakeup: a #GWakeup
35193  *
35194  * Frees @wakeup.
35195  *
35196  * You must not currently be polling on the #GPollFD returned by
35197  * g_wakeup_get_pollfd(), or the result is undefined.
35198  */
35199
35200
35201 /**
35202  * g_wakeup_get_pollfd:
35203  * @wakeup: a #GWakeup
35204  * @poll_fd: a #GPollFD
35205  *
35206  * Prepares a @poll_fd such that polling on it will succeed when
35207  * g_wakeup_signal() has been called on @wakeup.
35208  *
35209  * @poll_fd is valid until @wakeup is freed.
35210  *
35211  * Since: 2.30
35212  */
35213
35214
35215 /**
35216  * g_wakeup_new:
35217  *
35218  * Creates a new #GWakeup.
35219  *
35220  * You should use g_wakeup_free() to free it when you are done.
35221  *
35222  * Returns: a new #GWakeup
35223  * Since: 2.30
35224  */
35225
35226
35227 /**
35228  * g_wakeup_signal:
35229  * @wakeup: a #GWakeup
35230  *
35231  * Signals @wakeup.
35232  *
35233  * Any future (or present) polling on the #GPollFD returned by
35234  * g_wakeup_get_pollfd() will immediately succeed until such a time as
35235  * g_wakeup_acknowledge() is called.
35236  *
35237  * This function is safe to call from a UNIX signal handler.
35238  *
35239  * Since: 2.30
35240  */
35241
35242
35243 /**
35244  * g_warning:
35245  * @...: format string, followed by parameters to insert
35246  *     into the format string (as with printf())
35247  *
35248  * A convenience function/macro to log a warning message.
35249  *
35250  * You can make warnings fatal at runtime by setting the
35251  * <envar>G_DEBUG</envar> environment variable (see
35252  * <ulink url="glib-running.html">Running GLib Applications</ulink>).
35253  *
35254  * If g_log_default_handler() is used as the log handler function, a new-line
35255  * character will automatically be appended to @..., and need not be entered
35256  * manually.
35257  */
35258
35259
35260 /**
35261  * g_win32_error_message:
35262  * @error: error code.
35263  *
35264  * Translate a Win32 error code (as returned by GetLastError()) into
35265  * the corresponding message. The message is either language neutral,
35266  * or in the thread's language, or the user's language, the system's
35267  * language, or US English (see docs for FormatMessage()). The
35268  * returned string is in UTF-8. It should be deallocated with
35269  * g_free().
35270  *
35271  * Returns: newly-allocated error message
35272  */
35273
35274
35275 /**
35276  * g_win32_get_package_installation_directory:
35277  * @package: (allow-none): You should pass %NULL for this.
35278  * @dll_name: (allow-none): The name of a DLL that a package provides in UTF-8, or %NULL.
35279  *
35280  * Try to determine the installation directory for a software package.
35281  *
35282  * This function is deprecated. Use
35283  * g_win32_get_package_installation_directory_of_module() instead.
35284  *
35285  * The use of @package is deprecated. You should always pass %NULL. A
35286  * warning is printed if non-NULL is passed as @package.
35287  *
35288  * The original intended use of @package was for a short identifier of
35289  * the package, typically the same identifier as used for
35290  * <literal>GETTEXT_PACKAGE</literal> in software configured using GNU
35291  * autotools. The function first looks in the Windows Registry for the
35292  * value <literal>&num;InstallationDirectory</literal> in the key
35293  * <literal>&num;HKLM\Software\@package</literal>, and if that value
35294  * exists and is a string, returns that.
35295  *
35296  * It is strongly recommended that packagers of GLib-using libraries
35297  * for Windows do not store installation paths in the Registry to be
35298  * used by this function as that interfers with having several
35299  * parallel installations of the library. Enabling multiple
35300  * installations of different versions of some GLib-using library, or
35301  * GLib itself, is desirable for various reasons.
35302  *
35303  * For this reason it is recommeded to always pass %NULL as
35304  * @package to this function, to avoid the temptation to use the
35305  * Registry. In version 2.20 of GLib the @package parameter
35306  * will be ignored and this function won't look in the Registry at all.
35307  *
35308  * If @package is %NULL, or the above value isn't found in the
35309  * Registry, but @dll_name is non-%NULL, it should name a DLL loaded
35310  * into the current process. Typically that would be the name of the
35311  * DLL calling this function, looking for its installation
35312  * directory. The function then asks Windows what directory that DLL
35313  * was loaded from. If that directory's last component is "bin" or
35314  * "lib", the parent directory is returned, otherwise the directory
35315  * itself. If that DLL isn't loaded, the function proceeds as if
35316  * @dll_name was %NULL.
35317  *
35318  * If both @package and @dll_name are %NULL, the directory from where
35319  * the main executable of the process was loaded is used instead in
35320  * the same way as above.
35321  *
35322  * Returns: a string containing the installation directory for
35323  * @package. The string is in the GLib file name encoding,
35324  * i.e. UTF-8. The return value should be freed with g_free() when not
35325  * needed any longer. If the function fails %NULL is returned.
35326  * Deprecated: 2.18: Pass the HMODULE of a DLL or EXE to
35327  * g_win32_get_package_installation_directory_of_module() instead.
35328  */
35329
35330
35331 /**
35332  * g_win32_get_package_installation_directory_of_module:
35333  * @hmodule: (allow-none): The Win32 handle for a DLL loaded into the current process, or %NULL
35334  *
35335  * This function tries to determine the installation directory of a
35336  * software package based on the location of a DLL of the software
35337  * package.
35338  *
35339  * @hmodule should be the handle of a loaded DLL or %NULL. The
35340  * function looks up the directory that DLL was loaded from. If
35341  * @hmodule is NULL, the directory the main executable of the current
35342  * process is looked up. If that directory's last component is "bin"
35343  * or "lib", its parent directory is returned, otherwise the directory
35344  * itself.
35345  *
35346  * It thus makes sense to pass only the handle to a "public" DLL of a
35347  * software package to this function, as such DLLs typically are known
35348  * to be installed in a "bin" or occasionally "lib" subfolder of the
35349  * installation folder. DLLs that are of the dynamically loaded module
35350  * or plugin variety are often located in more private locations
35351  * deeper down in the tree, from which it is impossible for GLib to
35352  * deduce the root of the package installation.
35353  *
35354  * The typical use case for this function is to have a DllMain() that
35355  * saves the handle for the DLL. Then when code in the DLL needs to
35356  * construct names of files in the installation tree it calls this
35357  * function passing the DLL handle.
35358  *
35359  * Returns: a string containing the guessed installation directory for
35360  * the software package @hmodule is from. The string is in the GLib
35361  * file name encoding, i.e. UTF-8. The return value should be freed
35362  * with g_free() when not needed any longer. If the function fails
35363  * %NULL is returned.
35364  * Since: 2.16
35365  */
35366
35367
35368 /**
35369  * g_win32_get_package_installation_subdirectory:
35370  * @package: (allow-none): You should pass %NULL for this.
35371  * @dll_name: (allow-none): The name of a DLL that a package provides, in UTF-8, or %NULL.
35372  * @subdir: A subdirectory of the package installation directory, also in UTF-8
35373  *
35374  * This function is deprecated. Use
35375  * g_win32_get_package_installation_directory_of_module() and
35376  * g_build_filename() instead.
35377  *
35378  * Returns a newly-allocated string containing the path of the
35379  * subdirectory @subdir in the return value from calling
35380  * g_win32_get_package_installation_directory() with the @package and
35381  * @dll_name parameters. See the documentation for
35382  * g_win32_get_package_installation_directory() for more details. In
35383  * particular, note that it is deprecated to pass anything except NULL
35384  * as @package.
35385  *
35386  * Returns: a string containing the complete path to @subdir inside
35387  * the installation directory of @package. The returned string is in
35388  * the GLib file name encoding, i.e. UTF-8. The return value should be
35389  * freed with g_free() when no longer needed. If something goes wrong,
35390  * %NULL is returned.
35391  * Deprecated: 2.18: Pass the HMODULE of a DLL or EXE to
35392  * g_win32_get_package_installation_directory_of_module() instead, and
35393  * then construct a subdirectory pathname with g_build_filename().
35394  */
35395
35396
35397 /**
35398  * g_win32_get_windows_version:
35399  *
35400  * Returns version information for the Windows operating system the
35401  * code is running on. See MSDN documentation for the GetVersion()
35402  * function. To summarize, the most significant bit is one on Win9x,
35403  * and zero on NT-based systems. Since version 2.14, GLib works only
35404  * on NT-based systems, so checking whether your are running on Win9x
35405  * in your own software is moot. The least significant byte is 4 on
35406  * Windows NT 4, and 5 on Windows XP. Software that needs really
35407  * detailed version and feature information should use Win32 API like
35408  * GetVersionEx() and VerifyVersionInfo().
35409  *
35410  * Returns: The version information.
35411  * Since: 2.6
35412  */
35413
35414
35415 /**
35416  * g_win32_getlocale:
35417  *
35418  * The setlocale() function in the Microsoft C library uses locale
35419  * names of the form "English_United States.1252" etc. We want the
35420  * UNIXish standard form "en_US", "zh_TW" etc. This function gets the
35421  * current thread locale from Windows - without any encoding info -
35422  * and returns it as a string of the above form for use in forming
35423  * file names etc. The returned string should be deallocated with
35424  * g_free().
35425  *
35426  * Returns: newly-allocated locale name.
35427  */
35428
35429
35430 /**
35431  * g_win32_locale_filename_from_utf8:
35432  * @utf8filename: a UTF-8 encoded filename.
35433  *
35434  * Converts a filename from UTF-8 to the system codepage.
35435  *
35436  * On NT-based Windows, on NTFS file systems, file names are in
35437  * Unicode. It is quite possible that Unicode file names contain
35438  * characters not representable in the system codepage. (For instance,
35439  * Greek or Cyrillic characters on Western European or US Windows
35440  * installations, or various less common CJK characters on CJK Windows
35441  * installations.)
35442  *
35443  * In such a case, and if the filename refers to an existing file, and
35444  * the file system stores alternate short (8.3) names for directory
35445  * entries, the short form of the filename is returned. Note that the
35446  * "short" name might in fact be longer than the Unicode name if the
35447  * Unicode name has very short pathname components containing
35448  * non-ASCII characters. If no system codepage name for the file is
35449  * possible, %NULL is returned.
35450  *
35451  * The return value is dynamically allocated and should be freed with
35452  * g_free() when no longer needed.
35453  *
35454  * Returns: The converted filename, or %NULL on conversion
35455  * failure and lack of short names.
35456  * Since: 2.8
35457  */
35458
35459
35460 /**
35461  * gboolean:
35462  *
35463  * A standard boolean type.
35464  * Variables of this type should only contain the value
35465  * %TRUE or %FALSE.
35466  */
35467
35468
35469 /**
35470  * gchar:
35471  *
35472  * Corresponds to the standard C <type>char</type> type.
35473  */
35474
35475
35476 /**
35477  * gconstpointer:
35478  *
35479  * An untyped pointer to constant data.
35480  * The data pointed to should not be changed.
35481  *
35482  * This is typically used in function prototypes to indicate
35483  * that the data pointed to will not be altered by the function.
35484  */
35485
35486
35487 /**
35488  * gdouble:
35489  *
35490  * Corresponds to the standard C <type>double</type> type.
35491  * Values of this type can range from -#G_MAXDOUBLE to #G_MAXDOUBLE.
35492  */
35493
35494
35495 /**
35496  * gfloat:
35497  *
35498  * Corresponds to the standard C <type>float</type> type.
35499  * Values of this type can range from -#G_MAXFLOAT to #G_MAXFLOAT.
35500  */
35501
35502
35503 /**
35504  * gint:
35505  *
35506  * Corresponds to the standard C <type>int</type> type.
35507  * Values of this type can range from #G_MININT to #G_MAXINT.
35508  */
35509
35510
35511 /**
35512  * gint16:
35513  *
35514  * A signed integer guaranteed to be 16 bits on all platforms.
35515  * Values of this type can range from #G_MININT16 (= -32,768) to
35516  * #G_MAXINT16 (= 32,767).
35517  *
35518  * To print or scan values of this type, use
35519  * %G_GINT16_MODIFIER and/or %G_GINT16_FORMAT.
35520  */
35521
35522
35523 /**
35524  * gint32:
35525  *
35526  * A signed integer guaranteed to be 32 bits on all platforms.
35527  * Values of this type can range from #G_MININT32 (= -2,147,483,648)
35528  * to #G_MAXINT32 (= 2,147,483,647).
35529  *
35530  * To print or scan values of this type, use
35531  * %G_GINT32_MODIFIER and/or %G_GINT32_FORMAT.
35532  */
35533
35534
35535 /**
35536  * gint64:
35537  *
35538  * A signed integer guaranteed to be 64 bits on all platforms.
35539  * Values of this type can range from #G_MININT64
35540  * (= -9,223,372,036,854,775,808) to #G_MAXINT64
35541  * (= 9,223,372,036,854,775,807).
35542  *
35543  * To print or scan values of this type, use
35544  * %G_GINT64_MODIFIER and/or %G_GINT64_FORMAT.
35545  */
35546
35547
35548 /**
35549  * gint8:
35550  *
35551  * A signed integer guaranteed to be 8 bits on all platforms.
35552  * Values of this type can range from #G_MININT8 (= -128) to
35553  * #G_MAXINT8 (= 127).
35554  */
35555
35556
35557 /**
35558  * gintptr:
35559  *
35560  * Corresponds to the C99 type <type>intptr_t</type>,
35561  * a signed integer type that can hold any pointer.
35562  *
35563  * To print or scan values of this type, use
35564  * %G_GINTPTR_MODIFIER and/or %G_GINTPTR_FORMAT.
35565  *
35566  * Since: 2.18
35567  */
35568
35569
35570 /**
35571  * glib__private__:
35572  * @arg: Do not use this argument
35573  *
35574  * Do not call this function; it is used to share private
35575  * API between glib, gobject, and gio.
35576  */
35577
35578
35579 /**
35580  * glib_check_version:
35581  * @required_major: the required major version.
35582  * @required_minor: the required minor version.
35583  * @required_micro: the required micro version.
35584  *
35585  * Checks that the GLib library in use is compatible with the
35586  * given version. Generally you would pass in the constants
35587  * #GLIB_MAJOR_VERSION, #GLIB_MINOR_VERSION, #GLIB_MICRO_VERSION
35588  * as the three arguments to this function; that produces
35589  * a check that the library in use is compatible with
35590  * the version of GLib the application or module was compiled
35591  * against.
35592  *
35593  * Compatibility is defined by two things: first the version
35594  * of the running library is newer than the version
35595  * @required_major.required_minor.@required_micro. Second
35596  * the running library must be binary compatible with the
35597  * version @required_major.required_minor.@required_micro
35598  * (same major version.)
35599  *
35600  * Returns: %NULL if the GLib library is compatible with the
35601  *   given version, or a string describing the version mismatch.
35602  *   The returned string is owned by GLib and must not be modified
35603  *   or freed.
35604  * Since: 2.6
35605  */
35606
35607
35608 /**
35609  * glib_gettext:
35610  * @str: The string to be translated
35611  *
35612  * Returns the translated string from the glib translations.
35613  * This is an internal function and should only be used by
35614  * the internals of glib (such as libgio).
35615  *
35616  * Returns: the transation of @str to the current locale
35617  */
35618
35619
35620 /**
35621  * glib_mem_profiler_table:
35622  *
35623  * A #GMemVTable containing profiling variants of the memory
35624  * allocation functions. Use them together with g_mem_profile()
35625  * in order to get information about the memory allocation pattern
35626  * of your program.
35627  */
35628
35629
35630 /**
35631  * glib_pgettext:
35632  * @msgctxtid: a combined message context and message id, separated
35633  *   by a \004 character
35634  * @msgidoffset: the offset of the message id in @msgctxid
35635  *
35636  * This function is a variant of glib_gettext() which supports
35637  * a disambiguating message context. See g_dpgettext() for full
35638  * details.
35639  *
35640  * This is an internal function and should only be used by
35641  * the internals of glib (such as libgio).
35642  *
35643  * Returns: the translation of @str to the current locale
35644  */
35645
35646
35647 /**
35648  * glong:
35649  *
35650  * Corresponds to the standard C <type>long</type> type.
35651  * Values of this type can range from #G_MINLONG to #G_MAXLONG.
35652  */
35653
35654
35655 /**
35656  * goffset:
35657  *
35658  * A signed integer type that is used for file offsets,
35659  * corresponding to the C99 type <type>off64_t</type>.
35660  * Values of this type can range from #G_MINOFFSET to
35661  * #G_MAXOFFSET.
35662  *
35663  * To print or scan values of this type, use
35664  * %G_GOFFSET_MODIFIER and/or %G_GOFFSET_FORMAT.
35665  *
35666  * Since: 2.14
35667  */
35668
35669
35670 /**
35671  * gpointer:
35672  *
35673  * An untyped pointer.
35674  * #gpointer looks better and is easier to use
35675  * than <type>void*</type>.
35676  */
35677
35678
35679 /**
35680  * gshort:
35681  *
35682  * Corresponds to the standard C <type>short</type> type.
35683  * Values of this type can range from #G_MINSHORT to #G_MAXSHORT.
35684  */
35685
35686
35687 /**
35688  * gsize:
35689  *
35690  * An unsigned integer type of the result of the sizeof operator,
35691  * corresponding to the <type>size_t</type> type defined in C99.
35692  * This type is wide enough to hold the numeric value of a pointer,
35693  * so it is usually 32bit wide on a 32bit platform and 64bit wide
35694  * on a 64bit platform. Values of this type can range from 0 to
35695  * #G_MAXSIZE.
35696  *
35697  * To print or scan values of this type, use
35698  * %G_GSIZE_MODIFIER and/or %G_GSIZE_FORMAT.
35699  */
35700
35701
35702 /**
35703  * gssize:
35704  *
35705  * A signed variant of #gsize, corresponding to the
35706  * <type>ssize_t</type> defined on most platforms.
35707  * Values of this type can range from #G_MINSSIZE
35708  * to #G_MAXSSIZE.
35709  *
35710  * To print or scan values of this type, use
35711  * %G_GSIZE_MODIFIER and/or %G_GSSIZE_FORMAT.
35712  */
35713
35714
35715 /**
35716  * guchar:
35717  *
35718  * Corresponds to the standard C <type>unsigned char</type> type.
35719  */
35720
35721
35722 /**
35723  * guint:
35724  *
35725  * Corresponds to the standard C <type>unsigned int</type> type.
35726  * Values of this type can range from 0 to #G_MAXUINT.
35727  */
35728
35729
35730 /**
35731  * guint16:
35732  *
35733  * An unsigned integer guaranteed to be 16 bits on all platforms.
35734  * Values of this type can range from 0 to #G_MAXUINT16 (= 65,535).
35735  *
35736  * To print or scan values of this type, use
35737  * %G_GINT16_MODIFIER and/or %G_GUINT16_FORMAT.
35738  */
35739
35740
35741 /**
35742  * guint32:
35743  *
35744  * An unsigned integer guaranteed to be 32 bits on all platforms.
35745  * Values of this type can range from 0 to #G_MAXUINT32 (= 4,294,967,295).
35746  *
35747  * To print or scan values of this type, use
35748  * %G_GINT32_MODIFIER and/or %G_GUINT32_FORMAT.
35749  */
35750
35751
35752 /**
35753  * guint64:
35754  *
35755  * An unsigned integer guaranteed to be 64 bits on all platforms.
35756  * Values of this type can range from 0 to #G_MAXUINT64
35757  * (= 18,446,744,073,709,551,615).
35758  *
35759  * To print or scan values of this type, use
35760  * %G_GINT64_MODIFIER and/or %G_GUINT64_FORMAT.
35761  */
35762
35763
35764 /**
35765  * guint8:
35766  *
35767  * An unsigned integer guaranteed to be 8 bits on all platforms.
35768  * Values of this type can range from 0 to #G_MAXUINT8 (= 255).
35769  */
35770
35771
35772 /**
35773  * guintptr:
35774  *
35775  * Corresponds to the C99 type <type>uintptr_t</type>,
35776  * an unsigned integer type that can hold any pointer.
35777  *
35778  * To print or scan values of this type, use
35779  * %G_GINTPTR_MODIFIER and/or %G_GUINTPTR_FORMAT.
35780  *
35781  * Since: 2.18
35782  */
35783
35784
35785 /**
35786  * gulong:
35787  *
35788  * Corresponds to the standard C <type>unsigned long</type> type.
35789  * Values of this type can range from 0 to #G_MAXULONG.
35790  */
35791
35792
35793 /**
35794  * gushort:
35795  *
35796  * Corresponds to the standard C <type>unsigned short</type> type.
35797  * Values of this type can range from 0 to #G_MAXUSHORT.
35798  */
35799
35800
35801
35802 /************************************************************/
35803 /* THIS FILE IS GENERATED DO NOT EDIT */
35804 /************************************************************/