Imported Upstream version 1.38.0
[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 elements are added to the #GArray.
72  * @len: the number of elements in the #GArray not including the possible terminating zero element.
73  *
74  * Contains the public fields of an <link linkend="glib-Arrays">Array</link>.
75  */
76
77
78 /**
79  * GAsyncQueue:
80  *
81  * The GAsyncQueue struct is an opaque data structure which represents
82  * an asynchronous queue. It should only be accessed through the
83  * <function>g_async_queue_*</function> functions.
84  */
85
86
87 /**
88  * GByteArray:
89  * @data: a pointer to the element data. The data may be moved as elements are added to the #GByteArray.
90  * @len: the number of elements in the #GByteArray.
91  *
92  * The <structname>GByteArray</structname> struct allows access to the
93  * public fields of a <structname>GByteArray</structname>.
94  */
95
96
97 /**
98  * GBytes:
99  *
100  * A simple refcounted data type representing an immutable byte sequence
101  * from an unspecified origin.
102  *
103  * The purpose of a #GBytes is to keep the memory region that it holds
104  * alive for as long as anyone holds a reference to the bytes.  When
105  * the last reference count is dropped, the memory is released. Multiple
106  * unrelated callers can use byte data in the #GBytes without coordinating
107  * their activities, resting assured that the byte data will not change or
108  * move while they hold a reference.
109  *
110  * A #GBytes can come from many different origins that may have
111  * different procedures for freeing the memory region.  Examples are
112  * memory from g_malloc(), from memory slices, from a #GMappedFile or
113  * memory from other allocators.
114  *
115  * #GBytes work well as keys in #GHashTable. Use g_bytes_equal() and
116  * g_bytes_hash() as parameters to g_hash_table_new() or g_hash_table_new_full().
117  * #GBytes can also be used as keys in a #GTree by passing the g_bytes_compare()
118  * function to g_tree_new().
119  *
120  * The data pointed to by this bytes must not be modified. For a mutable
121  * array of bytes see #GByteArray. Use g_bytes_unref_to_array() to create a
122  * mutable array for a #GBytes sequence. To create an immutable #GBytes from
123  * a mutable #GByteArray, use the g_byte_array_free_to_bytes() function.
124  *
125  * Since: 2.32
126  */
127
128
129 /**
130  * GCompareDataFunc:
131  * @a: a value.
132  * @b: a value to compare with.
133  * @user_data: user data to pass to comparison function.
134  *
135  * Specifies the type of a comparison function used to compare two
136  * values.  The function should return a negative integer if the first
137  * value comes before the second, 0 if they are equal, or a positive
138  * integer if the first value comes after the second.
139  *
140  * Returns: negative value if @a &lt; @b; zero if @a = @b; positive value if @a > @b.
141  */
142
143
144 /**
145  * GCompareFunc:
146  * @a: a value.
147  * @b: a value to compare with.
148  *
149  * Specifies the type of a comparison function used to compare two
150  * values.  The function should return a negative integer if the first
151  * value comes before the second, 0 if they are equal, or a positive
152  * integer if the first value comes after the second.
153  *
154  * Returns: negative value if @a &lt; @b; zero if @a = @b; positive value if @a > @b.
155  */
156
157
158 /**
159  * GCond:
160  *
161  * The #GCond struct is an opaque data structure that represents a
162  * condition. Threads can block on a #GCond if they find a certain
163  * condition to be false. If other threads change the state of this
164  * condition they signal the #GCond, and that causes the waiting
165  * threads to be woken up.
166  *
167  * Consider the following example of a shared variable.  One or more
168  * threads can wait for data to be published to the variable and when
169  * another thread publishes the data, it can signal one of the waiting
170  * threads to wake up to collect the data.
171  *
172  * <example>
173  *  <title>
174  *   Using GCond to block a thread until a condition is satisfied
175  *  </title>
176  *  <programlisting>
177  *   gpointer current_data = NULL;
178  *   GMutex data_mutex;
179  *   GCond data_cond;
180  *
181  *   void
182  *   push_data (gpointer data)
183  *   {
184  *     g_mutex_lock (&data_mutex);
185  *     current_data = data;
186  *     g_cond_signal (&data_cond);
187  *     g_mutex_unlock (&data_mutex);
188  *   }
189  *
190  *   gpointer
191  *   pop_data (void)
192  *   {
193  *     gpointer data;
194  *
195  *     g_mutex_lock (&data_mutex);
196  *     while (!current_data)
197  *       g_cond_wait (&data_cond, &data_mutex);
198  *     data = current_data;
199  *     current_data = NULL;
200  *     g_mutex_unlock (&data_mutex);
201  *
202  *     return data;
203  *   }
204  *  </programlisting>
205  * </example>
206  *
207  * Whenever a thread calls pop_data() now, it will wait until
208  * current_data is non-%NULL, i.e. until some other thread
209  * has called push_data().
210  *
211  * The example shows that use of a condition variable must always be
212  * paired with a mutex.  Without the use of a mutex, there would be a
213  * race between the check of <varname>current_data</varname> by the
214  * while loop in <function>pop_data</function> and waiting.
215  * Specifically, another thread could set <varname>pop_data</varname>
216  * after the check, and signal the cond (with nobody waiting on it)
217  * before the first thread goes to sleep.  #GCond is specifically useful
218  * for its ability to release the mutex and go to sleep atomically.
219  *
220  * It is also important to use the g_cond_wait() and g_cond_wait_until()
221  * functions only inside a loop which checks for the condition to be
222  * true.  See g_cond_wait() for an explanation of why the condition may
223  * not be true even after it returns.
224  *
225  * If a #GCond is allocated in static storage then it can be used
226  * without initialisation.  Otherwise, you should call g_cond_init() on
227  * it and g_cond_clear() when done.
228  *
229  * A #GCond should only be accessed via the <function>g_cond_</function>
230  * functions.
231  */
232
233
234 /**
235  * GData:
236  *
237  * The #GData struct is an opaque data structure to represent a <link
238  * linkend="glib-Keyed-Data-Lists">Keyed Data List</link>. It should
239  * only be accessed via the following functions.
240  */
241
242
243 /**
244  * GDataForeachFunc:
245  * @key_id: the #GQuark id to identifying the data element.
246  * @data: the data element.
247  * @user_data: user data passed to g_dataset_foreach().
248  *
249  * Specifies the type of function passed to g_dataset_foreach(). It is
250  * called with each #GQuark id and associated data element, together
251  * with the @user_data parameter supplied to g_dataset_foreach().
252  */
253
254
255 /**
256  * GDate:
257  * @julian_days: the Julian representation of the date
258  * @julian: this bit is set if @julian_days is valid
259  * @dmy: this is set if @day, @month and @year are valid
260  * @day: the day of the day-month-year representation of the date, as a number between 1 and 31
261  * @month: the day of the day-month-year representation of the date, as a number between 1 and 12
262  * @year: the day of the day-month-year representation of the date
263  *
264  * Represents a day between January 1, Year 1 and a few thousand years in
265  * the future. None of its members should be accessed directly. If the
266  * <structname>GDate</structname> is obtained from g_date_new(), it will
267  * be safe to mutate but invalid and thus not safe for calendrical
268  * computations. If it's declared on the stack, it will contain garbage
269  * so must be initialized with g_date_clear(). g_date_clear() makes the
270  * date invalid but sane. An invalid date doesn't represent a day, it's
271  * "empty." A date becomes valid after you set it to a Julian day or you
272  * set a day, month, and year.
273  */
274
275
276 /**
277  * GDateDMY:
278  * @G_DATE_DAY: a day
279  * @G_DATE_MONTH: a month
280  * @G_DATE_YEAR: a year
281  *
282  * This enumeration isn't used in the API, but may be useful if you need
283  * to mark a number as a day, month, or year.
284  */
285
286
287 /**
288  * GDateDay:
289  *
290  * Integer representing a day of the month; between 1 and
291  * 31. #G_DATE_BAD_DAY represents an invalid day of the month.
292  */
293
294
295 /**
296  * GDateMonth:
297  * @G_DATE_BAD_MONTH: invalid value
298  * @G_DATE_JANUARY: January
299  * @G_DATE_FEBRUARY: February
300  * @G_DATE_MARCH: March
301  * @G_DATE_APRIL: April
302  * @G_DATE_MAY: May
303  * @G_DATE_JUNE: June
304  * @G_DATE_JULY: July
305  * @G_DATE_AUGUST: August
306  * @G_DATE_SEPTEMBER: September
307  * @G_DATE_OCTOBER: October
308  * @G_DATE_NOVEMBER: November
309  * @G_DATE_DECEMBER: December
310  *
311  * Enumeration representing a month; values are #G_DATE_JANUARY,
312  * #G_DATE_FEBRUARY, etc. #G_DATE_BAD_MONTH is the invalid value.
313  */
314
315
316 /**
317  * GDateWeekday:
318  * @G_DATE_BAD_WEEKDAY: invalid value
319  * @G_DATE_MONDAY: Monday
320  * @G_DATE_TUESDAY: Tuesday
321  * @G_DATE_WEDNESDAY: Wednesday
322  * @G_DATE_THURSDAY: Thursday
323  * @G_DATE_FRIDAY: Friday
324  * @G_DATE_SATURDAY: Saturday
325  * @G_DATE_SUNDAY: Sunday
326  *
327  * Enumeration representing a day of the week; #G_DATE_MONDAY,
328  * #G_DATE_TUESDAY, etc. #G_DATE_BAD_WEEKDAY is an invalid weekday.
329  */
330
331
332 /**
333  * GDateYear:
334  *
335  * Integer representing a year; #G_DATE_BAD_YEAR is the invalid
336  * value. The year must be 1 or higher; negative (BC) years are not
337  * allowed. The year is represented with four digits.
338  */
339
340
341 /**
342  * GDestroyNotify:
343  * @data: the data element.
344  *
345  * Specifies the type of function which is called when a data element
346  * is destroyed. It is passed the pointer to the data element and
347  * should free any memory and resources allocated for it.
348  */
349
350
351 /**
352  * GDir:
353  *
354  * An opaque structure representing an opened directory.
355  */
356
357
358 /**
359  * GDoubleIEEE754:
360  * @v_double: the double value
361  *
362  * The #GFloatIEEE754 and #GDoubleIEEE754 unions are used to access the sign,
363  * mantissa and exponent of IEEE floats and doubles. These unions are defined
364  * as appropriate for a given platform. IEEE floats and doubles are supported
365  * (used for storage) by at least Intel, PPC and Sparc.
366  */
367
368
369 /**
370  * GDuplicateFunc:
371  * @data: the data to duplicate
372  * @user_data: user data that was specified in g_datalist_id_dup_data()
373  *
374  * The type of functions that are used to 'duplicate' an object.
375  * What this means depends on the context, it could just be
376  * incrementing the reference count, if @data is a ref-counted
377  * object.
378  *
379  * Returns: a duplicate of data
380  */
381
382
383 /**
384  * GEqualFunc:
385  * @a: a value
386  * @b: a value to compare with
387  *
388  * Specifies the type of a function used to test two values for
389  * equality. The function should return %TRUE if both values are equal
390  * and %FALSE otherwise.
391  *
392  * Returns: %TRUE if @a = @b; %FALSE otherwise
393  */
394
395
396 /**
397  * GErrorType:
398  * @G_ERR_UNKNOWN: unknown error
399  * @G_ERR_UNEXP_EOF: unexpected end of file
400  * @G_ERR_UNEXP_EOF_IN_STRING: unterminated string constant
401  * @G_ERR_UNEXP_EOF_IN_COMMENT: unterminated comment
402  * @G_ERR_NON_DIGIT_IN_CONST: non-digit character in a number
403  * @G_ERR_DIGIT_RADIX: digit beyond radix in a number
404  * @G_ERR_FLOAT_RADIX: non-decimal floating point number
405  * @G_ERR_FLOAT_MALFORMED: malformed floating point number
406  *
407  * The possible errors, used in the @v_error field
408  * of #GTokenValue, when the token is a %G_TOKEN_ERROR.
409  */
410
411
412 /**
413  * GFileError:
414  * @G_FILE_ERROR_EXIST: Operation not permitted; only the owner of the file (or other resource) or processes with special privileges can perform the operation.
415  * @G_FILE_ERROR_ISDIR: File is a directory; you cannot open a directory for writing, or create or remove hard links to it.
416  * @G_FILE_ERROR_ACCES: Permission denied; the file permissions do not allow the attempted operation.
417  * @G_FILE_ERROR_NAMETOOLONG: Filename too long.
418  * @G_FILE_ERROR_NOENT: No such file or directory. This is a "file doesn't exist" error for ordinary files that are referenced in contexts where they are expected to already exist.
419  * @G_FILE_ERROR_NOTDIR: A file that isn't a directory was specified when a directory is required.
420  * @G_FILE_ERROR_NXIO: No such device or address. The system tried to use the device represented by a file you specified, and it couldn't find the device. This can mean that the device file was installed incorrectly, or that the physical device is missing or not correctly attached to the computer.
421  * @G_FILE_ERROR_NODEV: The underlying file system of the specified file does not support memory mapping.
422  * @G_FILE_ERROR_ROFS: The directory containing the new link can't be modified because it's on a read-only file system.
423  * @G_FILE_ERROR_TXTBSY: Text file busy.
424  * @G_FILE_ERROR_FAULT: You passed in a pointer to bad memory. (GLib won't reliably return this, don't pass in pointers to bad memory.)
425  * @G_FILE_ERROR_LOOP: Too many levels of symbolic links were encountered in looking up a file name. This often indicates a cycle of symbolic links.
426  * @G_FILE_ERROR_NOSPC: No space left on device; write operation on a file failed because the disk is full.
427  * @G_FILE_ERROR_NOMEM: No memory available. The system cannot allocate more virtual memory because its capacity is full.
428  * @G_FILE_ERROR_MFILE: The current process has too many files open and can't open any more. Duplicate descriptors do count toward this limit.
429  * @G_FILE_ERROR_NFILE: There are too many distinct file openings in the entire system.
430  * @G_FILE_ERROR_BADF: Bad file descriptor; for example, I/O on a descriptor that has been closed or reading from a descriptor open only for writing (or vice versa).
431  * @G_FILE_ERROR_INVAL: Invalid argument. This is used to indicate various kinds of problems with passing the wrong argument to a library function.
432  * @G_FILE_ERROR_PIPE: Broken pipe; there is no process reading from the other end of a pipe. Every library function that returns this error code also generates a 'SIGPIPE' signal; this signal terminates the program if not handled or blocked. Thus, your program will never actually see this code unless it has handled or blocked 'SIGPIPE'.
433  * @G_FILE_ERROR_AGAIN: Resource temporarily unavailable; the call might work if you try again later.
434  * @G_FILE_ERROR_INTR: Interrupted function call; an asynchronous signal occurred and prevented completion of the call. When this happens, you should try the call again.
435  * @G_FILE_ERROR_IO: Input/output error; usually used for physical read or write errors. i.e. the disk or other physical device hardware is returning errors.
436  * @G_FILE_ERROR_PERM: Operation not permitted; only the owner of the file (or other resource) or processes with special privileges can perform the operation.
437  * @G_FILE_ERROR_NOSYS: Function not implemented; this indicates that the system is missing some functionality.
438  * @G_FILE_ERROR_FAILED: Does not correspond to a UNIX error code; this is the standard "failed for unspecified reason" error code present in all #GError error code enumerations. Returned if no specific code applies.
439  *
440  * Values corresponding to @errno codes returned from file operations
441  * on UNIX. Unlike @errno codes, GFileError values are available on
442  * all systems, even Windows. The exact meaning of each code depends
443  * on what sort of file operation you were performing; the UNIX
444  * documentation gives more details. The following error code descriptions
445  * come from the GNU C Library manual, and are under the copyright
446  * of that manual.
447  *
448  * It's not very portable to make detailed assumptions about exactly
449  * which errors will be returned from a given operation. Some errors
450  * don't occur on some systems, etc., sometimes there are subtle
451  * differences in when a system will report a given error, etc.
452  */
453
454
455 /**
456  * GFileTest:
457  * @G_FILE_TEST_IS_REGULAR: %TRUE if the file is a regular file (not a directory). Note that this test will also return %TRUE if the tested file is a symlink to a regular file.
458  * @G_FILE_TEST_IS_SYMLINK: %TRUE if the file is a symlink.
459  * @G_FILE_TEST_IS_DIR: %TRUE if the file is a directory.
460  * @G_FILE_TEST_IS_EXECUTABLE: %TRUE if the file is executable.
461  * @G_FILE_TEST_EXISTS: %TRUE if the file exists. It may or may not be a regular file.
462  *
463  * A test to perform on a file using g_file_test().
464  */
465
466
467 /**
468  * GFloatIEEE754:
469  * @v_float: the double value
470  *
471  * The #GFloatIEEE754 and #GDoubleIEEE754 unions are used to access the sign,
472  * mantissa and exponent of IEEE floats and doubles. These unions are defined
473  * as appropriate for a given platform. IEEE floats and doubles are supported
474  * (used for storage) by at least Intel, PPC and Sparc.
475  */
476
477
478 /**
479  * GFormatSizeFlags:
480  * @G_FORMAT_SIZE_DEFAULT: behave the same as g_format_size()
481  * @G_FORMAT_SIZE_LONG_FORMAT: include the exact number of bytes as part of the returned string.  For example, "45.6 kB (45,612 bytes)".
482  * @G_FORMAT_SIZE_IEC_UNITS: use IEC (base 1024) units with "KiB"-style suffixes. IEC units should only be used for reporting things with a strong "power of 2" basis, like RAM sizes or RAID stripe sizes. Network and storage sizes should be reported in the normal SI units.
483  *
484  * Flags to modify the format of the string returned by g_format_size_full().
485  */
486
487
488 /**
489  * GFunc:
490  * @data: the element's data.
491  * @user_data: user data passed to g_list_foreach() or g_slist_foreach().
492  *
493  * Specifies the type of functions passed to g_list_foreach() and
494  * g_slist_foreach().
495  */
496
497
498 /**
499  * GHFunc:
500  * @key: a key
501  * @value: the value corresponding to the key
502  * @user_data: user data passed to g_hash_table_foreach()
503  *
504  * Specifies the type of the function passed to g_hash_table_foreach().
505  * It is called with each key/value pair, together with the @user_data
506  * parameter which is passed to g_hash_table_foreach().
507  */
508
509
510 /**
511  * GHRFunc:
512  * @key: a key
513  * @value: the value associated with the key
514  * @user_data: user data passed to g_hash_table_remove()
515  *
516  * Specifies the type of the function passed to
517  * g_hash_table_foreach_remove(). It is called with each key/value
518  * pair, together with the @user_data parameter passed to
519  * g_hash_table_foreach_remove(). It should return %TRUE if the
520  * key/value pair should be removed from the #GHashTable.
521  *
522  * Returns: %TRUE if the key/value pair should be removed from the #GHashTable
523  */
524
525
526 /**
527  * GHashFunc:
528  * @key: a key
529  *
530  * Specifies the type of the hash function which is passed to
531  * g_hash_table_new() when a #GHashTable is created.
532  *
533  * The function is passed a key and should return a #guint hash value.
534  * The functions g_direct_hash(), g_int_hash() and g_str_hash() provide
535  * hash functions which can be used when the key is a #gpointer, #gint*,
536  * and #gchar* respectively.
537  *
538  * g_direct_hash() is also the appropriate hash function for keys
539  * of the form <literal>GINT_TO_POINTER (n)</literal> (or similar macros).
540  *
541  * <!-- FIXME: Need more here. --> A good hash functions should produce
542  * hash values that are evenly distributed over a fairly large range.
543  * The modulus is taken with the hash table size (a prime number) to
544  * find the 'bucket' to place each key into. The function should also
545  * be very fast, since it is called for each key lookup.
546  *
547  * Note that the hash functions provided by GLib have these qualities,
548  * but are not particularly robust against manufactured keys that
549  * cause hash collisions. Therefore, you should consider choosing
550  * a more secure hash function when using a GHashTable with keys
551  * that originate in untrusted data (such as HTTP requests).
552  * Using g_str_hash() in that situation might make your application
553  * vulerable to <ulink url="https://lwn.net/Articles/474912/">Algorithmic Complexity Attacks</ulink>.
554  *
555  * The key to choosing a good hash is unpredictability.  Even
556  * cryptographic hashes are very easy to find collisions for when the
557  * remainder is taken modulo a somewhat predictable prime number.  There
558  * must be an element of randomness that an attacker is unable to guess.
559  *
560  * Returns: the hash value corresponding to the key
561  */
562
563
564 /**
565  * GHashTable:
566  *
567  * The #GHashTable struct is an opaque data structure to represent a
568  * <link linkend="glib-Hash-Tables">Hash Table</link>. It should only be
569  * accessed via the following functions.
570  */
571
572
573 /**
574  * GHashTableIter:
575  *
576  * A GHashTableIter structure represents an iterator that can be used
577  * to iterate over the elements of a #GHashTable. GHashTableIter
578  * structures are typically allocated on the stack and then initialized
579  * with g_hash_table_iter_init().
580  */
581
582
583 /**
584  * GHook:
585  * @data: data which is passed to func when this hook is invoked
586  * @next: pointer to the next hook in the list
587  * @prev: pointer to the previous hook in the list
588  * @ref_count: the reference count of this hook
589  * @hook_id: the id of this hook, which is unique within its list
590  * @flags: flags which are set for this hook. See #GHookFlagMask for predefined flags
591  * @func: the function to call when this hook is invoked. The possible signatures for this function are #GHookFunc and #GHookCheckFunc
592  * @destroy: the default @finalize_hook function of a #GHookList calls this member of the hook that is being finalized
593  *
594  * The <structname>GHook</structname> struct represents a single hook
595  * function in a #GHookList.
596  */
597
598
599 /**
600  * GHookCheckFunc:
601  * @data: the data field of the #GHook is passed to the hook function here
602  *
603  * Defines the type of a hook function that can be invoked
604  * by g_hook_list_invoke_check().
605  *
606  * Returns: %FALSE if the #GHook should be destroyed
607  */
608
609
610 /**
611  * GHookCheckMarshaller:
612  * @hook: a #GHook
613  * @marshal_data: user data
614  *
615  * Defines the type of function used by g_hook_list_marshal_check().
616  *
617  * Returns: %FALSE if @hook should be destroyed
618  */
619
620
621 /**
622  * GHookCompareFunc:
623  * @new_hook: the #GHook being inserted
624  * @sibling: the #GHook to compare with @new_hook
625  *
626  * Defines the type of function used to compare #GHook elements in
627  * g_hook_insert_sorted().
628  *
629  * Returns: a value &lt;= 0 if @new_hook should be before @sibling
630  */
631
632
633 /**
634  * GHookFinalizeFunc:
635  * @hook_list: a #GHookList
636  * @hook: the hook in @hook_list that gets finalized
637  *
638  * Defines the type of function to be called when a hook in a
639  * list of hooks gets finalized.
640  */
641
642
643 /**
644  * GHookFindFunc:
645  * @hook: a #GHook
646  * @data: user data passed to g_hook_find_func()
647  *
648  * Defines the type of the function passed to g_hook_find().
649  *
650  * Returns: %TRUE if the required #GHook has been found
651  */
652
653
654 /**
655  * GHookFlagMask:
656  * @G_HOOK_FLAG_ACTIVE: set if the hook has not been destroyed
657  * @G_HOOK_FLAG_IN_CALL: set if the hook is currently being run
658  * @G_HOOK_FLAG_MASK: A mask covering all bits reserved for hook flags; see %G_HOOK_FLAG_USER_SHIFT
659  *
660  * Flags used internally in the #GHook implementation.
661  */
662
663
664 /**
665  * GHookFunc:
666  * @data: the data field of the #GHook is passed to the hook function here
667  *
668  * Defines the type of a hook function that can be invoked
669  * by g_hook_list_invoke().
670  */
671
672
673 /**
674  * GHookList:
675  * @seq_id: the next free #GHook id
676  * @hook_size: the size of the #GHookList elements, in bytes
677  * @is_setup: 1 if the #GHookList has been initialized
678  * @hooks: the first #GHook element in the list
679  * @dummy3: unused
680  * @finalize_hook: the function to call to finalize a #GHook element. The default behaviour is to call the hooks @destroy function
681  * @dummy: unused
682  *
683  * The <structname>GHookList</structname> struct represents a
684  * list of hook functions.
685  */
686
687
688 /**
689  * GHookMarshaller:
690  * @hook: a #GHook
691  * @marshal_data: user data
692  *
693  * Defines the type of function used by g_hook_list_marshal().
694  */
695
696
697 /**
698  * GINT16_FROM_BE:
699  * @val: a #gint16 value in big-endian byte order
700  *
701  * Converts a #gint16 value from big-endian to host byte order.
702  *
703  * Returns: @val converted to host byte order
704  */
705
706
707 /**
708  * GINT16_FROM_LE:
709  * @val: a #gint16 value in little-endian byte order
710  *
711  * Converts a #gint16 value from little-endian to host byte order.
712  *
713  * Returns: @val converted to host byte order
714  */
715
716
717 /**
718  * GINT16_TO_BE:
719  * @val: a #gint16 value in host byte order
720  *
721  * Converts a #gint16 value from host byte order to big-endian.
722  *
723  * Returns: @val converted to big-endian
724  */
725
726
727 /**
728  * GINT16_TO_LE:
729  * @val: a #gint16 value in host byte order
730  *
731  * Converts a #gint16 value from host byte order to little-endian.
732  *
733  * Returns: @val converted to little-endian
734  */
735
736
737 /**
738  * GINT32_FROM_BE:
739  * @val: a #gint32 value in big-endian byte order
740  *
741  * Converts a #gint32 value from big-endian to host byte order.
742  *
743  * Returns: @val converted to host byte order
744  */
745
746
747 /**
748  * GINT32_FROM_LE:
749  * @val: a #gint32 value in little-endian byte order
750  *
751  * Converts a #gint32 value from little-endian to host byte order.
752  *
753  * Returns: @val converted to host byte order
754  */
755
756
757 /**
758  * GINT32_TO_BE:
759  * @val: a #gint32 value in host byte order
760  *
761  * Converts a #gint32 value from host byte order to big-endian.
762  *
763  * Returns: @val converted to big-endian
764  */
765
766
767 /**
768  * GINT32_TO_LE:
769  * @val: a #gint32 value in host byte order
770  *
771  * Converts a #gint32 value from host byte order to little-endian.
772  *
773  * Returns: @val converted to little-endian
774  */
775
776
777 /**
778  * GINT64_FROM_BE:
779  * @val: a #gint64 value in big-endian byte order
780  *
781  * Converts a #gint64 value from big-endian to host byte order.
782  *
783  * Returns: @val converted to host byte order
784  */
785
786
787 /**
788  * GINT64_FROM_LE:
789  * @val: a #gint64 value in little-endian byte order
790  *
791  * Converts a #gint64 value from little-endian to host byte order.
792  *
793  * Returns: @val converted to host byte order
794  */
795
796
797 /**
798  * GINT64_TO_BE:
799  * @val: a #gint64 value in host byte order
800  *
801  * Converts a #gint64 value from host byte order to big-endian.
802  *
803  * Returns: @val converted to big-endian
804  */
805
806
807 /**
808  * GINT64_TO_LE:
809  * @val: a #gint64 value in host byte order
810  *
811  * Converts a #gint64 value from host byte order to little-endian.
812  *
813  * Returns: @val converted to little-endian
814  */
815
816
817 /**
818  * GINT_FROM_BE:
819  * @val: a #gint value in big-endian byte order
820  *
821  * Converts a #gint value from big-endian to host byte order.
822  *
823  * Returns: @val converted to host byte order
824  */
825
826
827 /**
828  * GINT_FROM_LE:
829  * @val: a #gint value in little-endian byte order
830  *
831  * Converts a #gint value from little-endian to host byte order.
832  *
833  * Returns: @val converted to host byte order
834  */
835
836
837 /**
838  * GINT_TO_BE:
839  * @val: a #gint value in host byte order
840  *
841  * Converts a #gint value from host byte order to big-endian.
842  *
843  * Returns: @val converted to big-endian byte order
844  */
845
846
847 /**
848  * GINT_TO_LE:
849  * @val: a #gint value in host byte order
850  *
851  * Converts a #gint value from host byte order to little-endian.
852  *
853  * Returns: @val converted to little-endian byte order
854  */
855
856
857 /**
858  * GINT_TO_POINTER:
859  * @i: integer to stuff into a pointer
860  *
861  * Stuffs an integer into a pointer type.
862  *
863  * Remember, you may not store pointers in integers. This is not portable
864  * in any way, shape or form. These macros <emphasis>only</emphasis> allow
865  * storing integers in pointers, and only preserve 32 bits of the
866  * integer; values outside the range of a 32-bit integer will be mangled.
867  */
868
869
870 /**
871  * GIOChannel:
872  *
873  * A data structure representing an IO Channel. The fields should be
874  * considered private and should only be accessed with the following
875  * functions.
876  */
877
878
879 /**
880  * GIOChannelError:
881  * @G_IO_CHANNEL_ERROR_FBIG: File too large.
882  * @G_IO_CHANNEL_ERROR_INVAL: Invalid argument.
883  * @G_IO_CHANNEL_ERROR_IO: IO error.
884  * @G_IO_CHANNEL_ERROR_ISDIR: File is a directory.
885  * @G_IO_CHANNEL_ERROR_NOSPC: No space left on device.
886  * @G_IO_CHANNEL_ERROR_NXIO: No such device or address.
887  * @G_IO_CHANNEL_ERROR_OVERFLOW: Value too large for defined datatype.
888  * @G_IO_CHANNEL_ERROR_PIPE: Broken pipe.
889  * @G_IO_CHANNEL_ERROR_FAILED: Some other error.
890  *
891  * Error codes returned by #GIOChannel operations.
892  */
893
894
895 /**
896  * GIOCondition:
897  * @G_IO_IN: There is data to read.
898  * @G_IO_OUT: Data can be written (without blocking).
899  * @G_IO_PRI: There is urgent data to read.
900  * @G_IO_ERR: Error condition.
901  * @G_IO_HUP: Hung up (the connection has been broken, usually for pipes and sockets).
902  * @G_IO_NVAL: Invalid request. The file descriptor is not open.
903  *
904  * A bitwise combination representing a condition to watch for on an
905  * event source.
906  */
907
908
909 /**
910  * GIOError:
911  * @G_IO_ERROR_NONE: no error
912  * @G_IO_ERROR_AGAIN: an EAGAIN error occurred
913  * @G_IO_ERROR_INVAL: an EINVAL error occurred
914  * @G_IO_ERROR_UNKNOWN: another error occurred
915  *
916  * #GIOError is only used by the deprecated functions
917  * g_io_channel_read(), g_io_channel_write(), and g_io_channel_seek().
918  */
919
920
921 /**
922  * GIOFlags:
923  * @G_IO_FLAG_APPEND: turns on append mode, corresponds to <literal>O_APPEND</literal> (see the documentation of the UNIX open() syscall).
924  * @G_IO_FLAG_NONBLOCK: turns on nonblocking mode, corresponds to <literal>O_NONBLOCK</literal>/<literal>O_NDELAY</literal> (see the documentation of the UNIX open() syscall).
925  * @G_IO_FLAG_IS_READABLE: indicates that the io channel is readable. This flag cannot be changed.
926  * @G_IO_FLAG_IS_WRITABLE: indicates that the io channel is writable. This flag cannot be changed.
927  * @G_IO_FLAG_IS_SEEKABLE: indicates that the io channel is seekable, i.e. that g_io_channel_seek_position() can be used on it.  This flag cannot be changed.
928  * @G_IO_FLAG_MASK: the mask that specifies all the valid flags.
929  * @G_IO_FLAG_GET_MASK: the mask of the flags that are returned from g_io_channel_get_flags().
930  * @G_IO_FLAG_SET_MASK: the mask of the flags that the user can modify with g_io_channel_set_flags().
931  *
932  * Specifies properties of a #GIOChannel. Some of the flags can only be
933  * read with g_io_channel_get_flags(), but not changed with
934  * g_io_channel_set_flags().
935  */
936
937
938 /**
939  * GIOFunc:
940  * @source: the #GIOChannel event source
941  * @condition: the condition which has been satisfied
942  * @data: user data set in g_io_add_watch() or g_io_add_watch_full()
943  *
944  * Specifies the type of function passed to g_io_add_watch() or
945  * g_io_add_watch_full(), which is called when the requested condition
946  * on a #GIOChannel is satisfied.
947  *
948  * Returns: the function should return %FALSE if the event source should be removed
949  */
950
951
952 /**
953  * GIOFuncs:
954  * @io_read: reads raw bytes from the channel.  This is called from various functions such as g_io_channel_read_chars() to read raw bytes from the channel.  Encoding and buffering issues are dealt with at a higher level.
955  * @io_write: writes raw bytes to the channel.  This is called from various functions such as g_io_channel_write_chars() to write raw bytes to the channel.  Encoding and buffering issues are dealt with at a higher level.
956  * @io_seek: &lpar;optional&rpar; seeks the channel.  This is called from g_io_channel_seek() on channels that support it.
957  * @io_close: closes the channel.  This is called from g_io_channel_close() after flushing the buffers.
958  * @io_create_watch: creates a watch on the channel.  This call corresponds directly to g_io_create_watch().
959  * @io_free: called from g_io_channel_unref() when the channel needs to be freed.  This function must free the memory associated with the channel, including freeing the #GIOChannel structure itself.  The channel buffers have been flushed and possibly @io_close has been called by the time this function is called.
960  * @io_set_flags: sets the #GIOFlags on the channel.  This is called from g_io_channel_set_flags() with all flags except for %G_IO_FLAG_APPEND and %G_IO_FLAG_NONBLOCK masked out.
961  * @io_get_flags: gets the #GIOFlags for the channel.  This function need only return the %G_IO_FLAG_APPEND and %G_IO_FLAG_NONBLOCK flags; g_io_channel_get_flags() automatically adds the others as appropriate.
962  *
963  * A table of functions used to handle different types of #GIOChannel
964  * in a generic way.
965  */
966
967
968 /**
969  * GIOStatus:
970  * @G_IO_STATUS_ERROR: An error occurred.
971  * @G_IO_STATUS_NORMAL: Success.
972  * @G_IO_STATUS_EOF: End of file.
973  * @G_IO_STATUS_AGAIN: Resource temporarily unavailable.
974  *
975  * Stati returned by most of the #GIOFuncs functions.
976  */
977
978
979 /**
980  * GKeyFile:
981  *
982  * The GKeyFile struct contains only private data
983  * and should not be accessed directly.
984  */
985
986
987 /**
988  * GKeyFileError:
989  * @G_KEY_FILE_ERROR_UNKNOWN_ENCODING: the text being parsed was in an unknown encoding
990  * @G_KEY_FILE_ERROR_PARSE: document was ill-formed
991  * @G_KEY_FILE_ERROR_NOT_FOUND: the file was not found
992  * @G_KEY_FILE_ERROR_KEY_NOT_FOUND: a requested key was not found
993  * @G_KEY_FILE_ERROR_GROUP_NOT_FOUND: a requested group was not found
994  * @G_KEY_FILE_ERROR_INVALID_VALUE: a value could not be parsed
995  *
996  * Error codes returned by key file parsing.
997  */
998
999
1000 /**
1001  * GKeyFileFlags:
1002  * @G_KEY_FILE_NONE: No flags, default behaviour
1003  * @G_KEY_FILE_KEEP_COMMENTS: Use this flag if you plan to write the (possibly modified) contents of the key file back to a file; otherwise all comments will be lost when the key file is written back.
1004  * @G_KEY_FILE_KEEP_TRANSLATIONS: Use this flag if you plan to write the (possibly modified) contents of the key file back to a file; otherwise only the translations for the current language will be written back.
1005  *
1006  * Flags which influence the parsing.
1007  */
1008
1009
1010 /**
1011  * GLIB_CHECK_VERSION:
1012  * @major: the major version to check for
1013  * @minor: the minor version to check for
1014  * @micro: the micro version to check for
1015  *
1016  * Checks the version of the GLib library that is being compiled
1017  * against.
1018  *
1019  * <example>
1020  * <title>Checking the version of the GLib library</title>
1021  * <programlisting>
1022  *   if (!GLIB_CHECK_VERSION (1, 2, 0))
1023  *     g_error ("GLib version 1.2.0 or above is needed");
1024  * </programlisting>
1025  * </example>
1026  *
1027  * See glib_check_version() for a runtime check.
1028  *
1029  * Returns: %TRUE if the version of the GLib header files is the same as or newer than the passed-in version.
1030  */
1031
1032
1033 /**
1034  * GLIB_DISABLE_DEPRECATION_WARNINGS:
1035  *
1036  * A macro that should be defined before including the glib.h header.
1037  * If it is defined, no compiler warnings will be produced for uses
1038  * of deprecated GLib APIs.
1039  */
1040
1041
1042 /**
1043  * GLIB_MAJOR_VERSION:
1044  *
1045  * The major version number of the GLib library.
1046  *
1047  * Like #glib_major_version, but from the headers used at
1048  * application compile time, rather than from the library
1049  * linked against at application run time.
1050  */
1051
1052
1053 /**
1054  * GLIB_MICRO_VERSION:
1055  *
1056  * The micro version number of the GLib library.
1057  *
1058  * Like #gtk_micro_version, but from the headers used at
1059  * application compile time, rather than from the library
1060  * linked against at application run time.
1061  */
1062
1063
1064 /**
1065  * GLIB_MINOR_VERSION:
1066  *
1067  * The minor version number of the GLib library.
1068  *
1069  * Like #gtk_minor_version, but from the headers used at
1070  * application compile time, rather than from the library
1071  * linked against at application run time.
1072  */
1073
1074
1075 /**
1076  * GLONG_FROM_BE:
1077  * @val: a #glong value in big-endian byte order
1078  *
1079  * Converts a #glong value from big-endian to the host byte order.
1080  *
1081  * Returns: @val converted to host byte order
1082  */
1083
1084
1085 /**
1086  * GLONG_FROM_LE:
1087  * @val: a #glong value in little-endian byte order
1088  *
1089  * Converts a #glong value from little-endian to host byte order.
1090  *
1091  * Returns: @val converted to host byte order
1092  */
1093
1094
1095 /**
1096  * GLONG_TO_BE:
1097  * @val: a #glong value in host byte order
1098  *
1099  * Converts a #glong value from host byte order to big-endian.
1100  *
1101  * Returns: @val converted to big-endian byte order
1102  */
1103
1104
1105 /**
1106  * GLONG_TO_LE:
1107  * @val: a #glong value in host byte order
1108  *
1109  * Converts a #glong value from host byte order to little-endian.
1110  *
1111  * Returns: @val converted to little-endian
1112  */
1113
1114
1115 /**
1116  * GList:
1117  * @data: holds the element's data, which can be a pointer to any kind of data, or any integer value using the <link linkend="glib-Type-Conversion-Macros">Type Conversion Macros</link>.
1118  * @next: contains the link to the next element in the list.
1119  * @prev: contains the link to the previous element in the list.
1120  *
1121  * The #GList struct is used for each element in a doubly-linked list.
1122  */
1123
1124
1125 /**
1126  * GLogFunc:
1127  * @log_domain: the log domain of the message
1128  * @log_level: the log level of the message (including the fatal and recursion flags)
1129  * @message: the message to process
1130  * @user_data: user data, set in g_log_set_handler()
1131  *
1132  * Specifies the prototype of log handler functions.
1133  */
1134
1135
1136 /**
1137  * GLogLevelFlags:
1138  * @G_LOG_FLAG_RECURSION: internal flag
1139  * @G_LOG_FLAG_FATAL: internal flag
1140  * @G_LOG_LEVEL_ERROR: log level for errors, see g_error(). This level is also used for messages produced by g_assert().
1141  * @G_LOG_LEVEL_CRITICAL: log level for critical messages, see g_critical(). This level is also used for messages produced by g_return_if_fail() and g_return_val_if_fail().
1142  * @G_LOG_LEVEL_WARNING: log level for warnings, see g_warning()
1143  * @G_LOG_LEVEL_MESSAGE: log level for messages, see g_message()
1144  * @G_LOG_LEVEL_INFO: log level for informational messages
1145  * @G_LOG_LEVEL_DEBUG: log level for debug messages, see g_debug()
1146  * @G_LOG_LEVEL_MASK: a mask including all log levels
1147  *
1148  * Flags specifying the level of log messages.
1149  *
1150  * It is possible to change how GLib treats messages of the various
1151  * levels using g_log_set_handler() and g_log_set_fatal_mask().
1152  */
1153
1154
1155 /**
1156  * GMappedFile:
1157  *
1158  * The #GMappedFile represents a file mapping created with
1159  * g_mapped_file_new(). It has only private members and should
1160  * not be accessed directly.
1161  */
1162
1163
1164 /**
1165  * GMarkupCollectType:
1166  * @G_MARKUP_COLLECT_INVALID: used to terminate the list of attributes to collect
1167  * @G_MARKUP_COLLECT_STRING: collect the string pointer directly from the attribute_values[] array. Expects a parameter of type (const char **). If %G_MARKUP_COLLECT_OPTIONAL is specified and the attribute isn't present then the pointer will be set to %NULL
1168  * @G_MARKUP_COLLECT_STRDUP: as with %G_MARKUP_COLLECT_STRING, but expects a parameter of type (char **) and g_strdup()s the returned pointer. The pointer must be freed with g_free()
1169  * @G_MARKUP_COLLECT_BOOLEAN: expects a parameter of type (gboolean *) and parses the attribute value as a boolean. Sets %FALSE if the attribute isn't present. Valid boolean values consist of (case-insensitive) "false", "f", "no", "n", "0" and "true", "t", "yes", "y", "1"
1170  * @G_MARKUP_COLLECT_TRISTATE: as with %G_MARKUP_COLLECT_BOOLEAN, but in the case of a missing attribute a value is set that compares equal to neither %FALSE nor %TRUE G_MARKUP_COLLECT_OPTIONAL is implied
1171  * @G_MARKUP_COLLECT_OPTIONAL: can be bitwise ORed with the other fields. If present, allows the attribute not to appear. A default value is set depending on what value type is used
1172  *
1173  * A mixed enumerated type and flags field. You must specify one type
1174  * (string, strdup, boolean, tristate).  Additionally, you may  optionally
1175  * bitwise OR the type with the flag %G_MARKUP_COLLECT_OPTIONAL.
1176  *
1177  * It is likely that this enum will be extended in the future to
1178  * support other types.
1179  */
1180
1181
1182 /**
1183  * GMutex:
1184  *
1185  * The #GMutex struct is an opaque data structure to represent a mutex
1186  * (mutual exclusion). It can be used to protect data against shared
1187  * access. Take for example the following function:
1188  *
1189  * <example>
1190  *  <title>A function which will not work in a threaded environment</title>
1191  *  <programlisting>
1192  *   int
1193  *   give_me_next_number (void)
1194  *   {
1195  *     static int current_number = 0;
1196  *
1197  *     /<!-- -->* now do a very complicated calculation to calculate the new
1198  *      * number, this might for example be a random number generator
1199  *      *<!-- -->/
1200  *     current_number = calc_next_number (current_number);
1201  *
1202  *     return current_number;
1203  *   }
1204  *  </programlisting>
1205  * </example>
1206  *
1207  * It is easy to see that this won't work in a multi-threaded
1208  * application. There current_number must be protected against shared
1209  * access. A #GMutex can be used as a solution to this problem:
1210  *
1211  * <example>
1212  *  <title>Using GMutex to protected a shared variable</title>
1213  *  <programlisting>
1214  *   int
1215  *   give_me_next_number (void)
1216  *   {
1217  *     static GMutex mutex;
1218  *     static int current_number = 0;
1219  *     int ret_val;
1220  *
1221  *     g_mutex_lock (&amp;mutex);
1222  *     ret_val = current_number = calc_next_number (current_number);
1223  *     g_mutex_unlock (&amp;mutex);
1224  *
1225  *     return ret_val;
1226  *   }
1227  *  </programlisting>
1228  * </example>
1229  *
1230  * Notice that the #GMutex is not initialised to any particular value.
1231  * Its placement in static storage ensures that it will be initialised
1232  * to all-zeros, which is appropriate.
1233  *
1234  * If a #GMutex is placed in other contexts (eg: embedded in a struct)
1235  * then it must be explicitly initialised using g_mutex_init().
1236  *
1237  * A #GMutex should only be accessed via <function>g_mutex_</function>
1238  * functions.
1239  */
1240
1241
1242 /**
1243  * GNode:
1244  * @data: contains the actual data of the node.
1245  * @next: points to the node's next sibling (a sibling is another #GNode with the same parent).
1246  * @prev: points to the node's previous sibling.
1247  * @parent: points to the parent of the #GNode, or is %NULL if the #GNode is the root of the tree.
1248  * @children: points to the first child of the #GNode.  The other children are accessed by using the @next pointer of each child.
1249  *
1250  * The #GNode struct represents one node in a
1251  * <link linkend="glib-N-ary-Trees">N-ary Tree</link>. fields
1252  */
1253
1254
1255 /**
1256  * GNodeForeachFunc:
1257  * @node: a #GNode.
1258  * @data: user data passed to g_node_children_foreach().
1259  *
1260  * Specifies the type of function passed to g_node_children_foreach().
1261  * The function is called with each child node, together with the user
1262  * data passed to g_node_children_foreach().
1263  */
1264
1265
1266 /**
1267  * GNodeTraverseFunc:
1268  * @node: a #GNode.
1269  * @data: user data passed to g_node_traverse().
1270  *
1271  * Specifies the type of function passed to g_node_traverse(). The
1272  * function is called with each of the nodes visited, together with the
1273  * user data passed to g_node_traverse(). If the function returns
1274  * %TRUE, then the traversal is stopped.
1275  *
1276  * Returns: %TRUE to stop the traversal.
1277  */
1278
1279
1280 /**
1281  * GOnce:
1282  * @status: the status of the #GOnce
1283  * @retval: the value returned by the call to the function, if @status is %G_ONCE_STATUS_READY
1284  *
1285  * A #GOnce struct controls a one-time initialization function. Any
1286  * one-time initialization function must have its own unique #GOnce
1287  * struct.
1288  *
1289  * Since: 2.4
1290  */
1291
1292
1293 /**
1294  * GOnceStatus:
1295  * @G_ONCE_STATUS_NOTCALLED: the function has not been called yet.
1296  * @G_ONCE_STATUS_PROGRESS: the function call is currently in progress.
1297  * @G_ONCE_STATUS_READY: the function has been called.
1298  *
1299  * The possible statuses of a one-time initialization function
1300  * controlled by a #GOnce struct.
1301  *
1302  * Since: 2.4
1303  */
1304
1305
1306 /**
1307  * GPOINTER_TO_INT:
1308  * @p: pointer containing an integer
1309  *
1310  * Extracts an integer from a pointer. The integer must have
1311  * been stored in the pointer with GINT_TO_POINTER().
1312  *
1313  * Remember, you may not store pointers in integers. This is not portable
1314  * in any way, shape or form. These macros <emphasis>only</emphasis> allow
1315  * storing integers in pointers, and only preserve 32 bits of the
1316  * integer; values outside the range of a 32-bit integer will be mangled.
1317  */
1318
1319
1320 /**
1321  * GPOINTER_TO_SIZE:
1322  * @p: pointer to extract a #gsize from
1323  *
1324  * Extracts a #gsize from a pointer. The #gsize must have
1325  * been stored in the pointer with GSIZE_TO_POINTER().
1326  */
1327
1328
1329 /**
1330  * GPOINTER_TO_UINT:
1331  * @p: pointer to extract an unsigned integer from
1332  *
1333  * Extracts an unsigned integer from a pointer. The integer must have
1334  * been stored in the pointer with GUINT_TO_POINTER().
1335  */
1336
1337
1338 /**
1339  * GPatternSpec:
1340  *
1341  * A <structname>GPatternSpec</structname> is the 'compiled' form of a
1342  * pattern. This structure is opaque and its fields cannot be accessed
1343  * directly.
1344  */
1345
1346
1347 /**
1348  * GPrivate:
1349  *
1350  * The #GPrivate struct is an opaque data structure to represent a
1351  * thread-local data key. It is approximately equivalent to the
1352  * pthread_setspecific()/pthread_getspecific() APIs on POSIX and to
1353  * TlsSetValue()/TlsGetValue() on Windows.
1354  *
1355  * If you don't already know why you might want this functionality,
1356  * then you probably don't need it.
1357  *
1358  * #GPrivate is a very limited resource (as far as 128 per program,
1359  * shared between all libraries). It is also not possible to destroy a
1360  * #GPrivate after it has been used. As such, it is only ever acceptable
1361  * to use #GPrivate in static scope, and even then sparingly so.
1362  *
1363  * See G_PRIVATE_INIT() for a couple of examples.
1364  *
1365  * The #GPrivate structure should be considered opaque.  It should only
1366  * be accessed via the <function>g_private_</function> functions.
1367  */
1368
1369
1370 /**
1371  * GPtrArray:
1372  * @pdata: points to the array of pointers, which may be moved when the array grows.
1373  * @len: number of pointers in the array.
1374  *
1375  * Contains the public fields of a pointer array.
1376  */
1377
1378
1379 /**
1380  * GQuark:
1381  *
1382  * A GQuark is a non-zero integer which uniquely identifies a
1383  * particular string. A GQuark value of zero is associated to %NULL.
1384  */
1385
1386
1387 /**
1388  * GRWLock:
1389  *
1390  * The GRWLock struct is an opaque data structure to represent a
1391  * reader-writer lock. It is similar to a #GMutex in that it allows
1392  * multiple threads to coordinate access to a shared resource.
1393  *
1394  * The difference to a mutex is that a reader-writer lock discriminates
1395  * between read-only ('reader') and full ('writer') access. While only
1396  * one thread at a time is allowed write access (by holding the 'writer'
1397  * lock via g_rw_lock_writer_lock()), multiple threads can gain
1398  * simultaneous read-only access (by holding the 'reader' lock via
1399  * g_rw_lock_reader_lock()).
1400  *
1401  * <example>
1402  *  <title>An array with access functions</title>
1403  *  <programlisting>
1404  *   GRWLock lock;
1405  *   GPtrArray *array;
1406  *
1407  *   gpointer
1408  *   my_array_get (guint index)
1409  *   {
1410  *     gpointer retval = NULL;
1411  *
1412  *     if (!array)
1413  *       return NULL;
1414  *
1415  *     g_rw_lock_reader_lock (&amp;lock);
1416  *     if (index &lt; array->len)
1417  *       retval = g_ptr_array_index (array, index);
1418  *     g_rw_lock_reader_unlock (&amp;lock);
1419  *
1420  *     return retval;
1421  *   }
1422  *
1423  *   void
1424  *   my_array_set (guint index, gpointer data)
1425  *   {
1426  *     g_rw_lock_writer_lock (&amp;lock);
1427  *
1428  *     if (!array)
1429  *       array = g_ptr_array_new (<!-- -->);
1430  *
1431  *     if (index >= array->len)
1432  *       g_ptr_array_set_size (array, index+1);
1433  *     g_ptr_array_index (array, index) = data;
1434  *
1435  *     g_rw_lock_writer_unlock (&amp;lock);
1436  *   }
1437  *  </programlisting>
1438  *  <para>
1439  *    This example shows an array which can be accessed by many readers
1440  *    (the <function>my_array_get()</function> function) simultaneously,
1441  *    whereas the writers (the <function>my_array_set()</function>
1442  *    function) will only be allowed once at a time and only if no readers
1443  *    currently access the array. This is because of the potentially
1444  *    dangerous resizing of the array. Using these functions is fully
1445  *    multi-thread safe now.
1446  *  </para>
1447  * </example>
1448  *
1449  * If a #GRWLock is allocated in static storage then it can be used
1450  * without initialisation.  Otherwise, you should call
1451  * g_rw_lock_init() on it and g_rw_lock_clear() when done.
1452  *
1453  * A GRWLock should only be accessed with the
1454  * <function>g_rw_lock_</function> functions.
1455  *
1456  * Since: 2.32
1457  */
1458
1459
1460 /**
1461  * GRand:
1462  *
1463  * The #GRand struct is an opaque data structure. It should only be
1464  * accessed through the <function>g_rand_*</function> functions.
1465  */
1466
1467
1468 /**
1469  * GRecMutex:
1470  *
1471  * The GRecMutex struct is an opaque data structure to represent a
1472  * recursive mutex. It is similar to a #GMutex with the difference
1473  * that it is possible to lock a GRecMutex multiple times in the same
1474  * thread without deadlock. When doing so, care has to be taken to
1475  * unlock the recursive mutex as often as it has been locked.
1476  *
1477  * If a #GRecMutex is allocated in static storage then it can be used
1478  * without initialisation.  Otherwise, you should call
1479  * g_rec_mutex_init() on it and g_rec_mutex_clear() when done.
1480  *
1481  * A GRecMutex should only be accessed with the
1482  * <function>g_rec_mutex_</function> functions.
1483  *
1484  * Since: 2.32
1485  */
1486
1487
1488 /**
1489  * GSIZE_FROM_BE:
1490  * @val: a #gsize value in big-endian byte order
1491  *
1492  * Converts a #gsize value from big-endian to the host byte order.
1493  *
1494  * Returns: @val converted to host byte order
1495  */
1496
1497
1498 /**
1499  * GSIZE_FROM_LE:
1500  * @val: a #gsize value in little-endian byte order
1501  *
1502  * Converts a #gsize value from little-endian to host byte order.
1503  *
1504  * Returns: @val converted to host byte order
1505  */
1506
1507
1508 /**
1509  * GSIZE_TO_BE:
1510  * @val: a #gsize value in host byte order
1511  *
1512  * Converts a #gsize value from host byte order to big-endian.
1513  *
1514  * Returns: @val converted to big-endian byte order
1515  */
1516
1517
1518 /**
1519  * GSIZE_TO_LE:
1520  * @val: a #gsize value in host byte order
1521  *
1522  * Converts a #gsize value from host byte order to little-endian.
1523  *
1524  * Returns: @val converted to little-endian
1525  */
1526
1527
1528 /**
1529  * GSIZE_TO_POINTER:
1530  * @s: #gsize to stuff into the pointer
1531  *
1532  * Stuffs a #gsize into a pointer type.
1533  */
1534
1535
1536 /**
1537  * GSList:
1538  * @data: holds the element's data, which can be a pointer to any kind of data, or any integer value using the <link linkend="glib-Type-Conversion-Macros">Type Conversion Macros</link>.
1539  * @next: contains the link to the next element in the list.
1540  *
1541  * The #GSList struct is used for each element in the singly-linked
1542  * list.
1543  */
1544
1545
1546 /**
1547  * GSSIZE_FROM_BE:
1548  * @val: a #gssize value in big-endian byte order
1549  *
1550  * Converts a #gssize value from big-endian to host byte order.
1551  *
1552  * Returns: @val converted to host byte order
1553  */
1554
1555
1556 /**
1557  * GSSIZE_FROM_LE:
1558  * @val: a #gssize value in little-endian byte order
1559  *
1560  * Converts a #gssize value from little-endian to host byte order.
1561  *
1562  * Returns: @val converted to host byte order
1563  */
1564
1565
1566 /**
1567  * GSSIZE_TO_BE:
1568  * @val: a #gssize value in host byte order
1569  *
1570  * Converts a #gssize value from host byte order to big-endian.
1571  *
1572  * Returns: @val converted to big-endian
1573  */
1574
1575
1576 /**
1577  * GSSIZE_TO_LE:
1578  * @val: a #gssize value in host byte order
1579  *
1580  * Converts a #gssize value from host byte order to little-endian.
1581  *
1582  * Returns: @val converted to little-endian
1583  */
1584
1585
1586 /**
1587  * GScanner:
1588  * @user_data: unused
1589  * @max_parse_errors: unused
1590  * @parse_errors: g_scanner_error() increments this field
1591  * @input_name: name of input stream, featured by the default message handler
1592  * @qdata: quarked data
1593  * @config: link into the scanner configuration
1594  * @token: token parsed by the last g_scanner_get_next_token()
1595  * @value: value of the last token from g_scanner_get_next_token()
1596  * @line: line number of the last token from g_scanner_get_next_token()
1597  * @position: char number of the last token from g_scanner_get_next_token()
1598  * @next_token: token parsed by the last g_scanner_peek_next_token()
1599  * @next_value: value of the last token from g_scanner_peek_next_token()
1600  * @next_line: line number of the last token from g_scanner_peek_next_token()
1601  * @next_position: char number of the last token from g_scanner_peek_next_token()
1602  * @msg_handler: handler function for _warn and _error
1603  *
1604  * The data structure representing a lexical scanner.
1605  *
1606  * You should set @input_name after creating the scanner, since
1607  * it is used by the default message handler when displaying
1608  * warnings and errors. If you are scanning a file, the filename
1609  * would be a good choice.
1610  *
1611  * The @user_data and @max_parse_errors fields are not used.
1612  * If you need to associate extra data with the scanner you
1613  * can place them here.
1614  *
1615  * If you want to use your own message handler you can set the
1616  * @msg_handler field. The type of the message handler function
1617  * is declared by #GScannerMsgFunc.
1618  */
1619
1620
1621 /**
1622  * GScannerConfig:
1623  * @cset_skip_characters: specifies which characters should be skipped by the scanner (the default is the whitespace characters: space, tab, carriage-return and line-feed).
1624  * @cset_identifier_first: specifies the characters which can start identifiers (the default is #G_CSET_a_2_z, "_", and #G_CSET_A_2_Z).
1625  * @cset_identifier_nth: specifies the characters which can be used in identifiers, after the first character (the default is #G_CSET_a_2_z, "_0123456789", #G_CSET_A_2_Z, #G_CSET_LATINS, #G_CSET_LATINC).
1626  * @cpair_comment_single: specifies the characters at the start and end of single-line comments. The default is "#\n" which means that single-line comments start with a '#' and continue until a '\n' (end of line).
1627  * @case_sensitive: specifies if symbols are case sensitive (the default is %FALSE).
1628  * @skip_comment_multi: specifies if multi-line comments are skipped and not returned as tokens (the default is %TRUE).
1629  * @skip_comment_single: specifies if single-line comments are skipped and not returned as tokens (the default is %TRUE).
1630  * @scan_comment_multi: specifies if multi-line comments are recognized (the default is %TRUE).
1631  * @scan_identifier: specifies if identifiers are recognized (the default is %TRUE).
1632  * @scan_identifier_1char: specifies if single-character identifiers are recognized (the default is %FALSE).
1633  * @scan_identifier_NULL: specifies if %NULL is reported as %G_TOKEN_IDENTIFIER_NULL (the default is %FALSE).
1634  * @scan_symbols: specifies if symbols are recognized (the default is %TRUE).
1635  * @scan_binary: specifies if binary numbers are recognized (the default is %FALSE).
1636  * @scan_octal: specifies if octal numbers are recognized (the default is %TRUE).
1637  * @scan_float: specifies if floating point numbers are recognized (the default is %TRUE).
1638  * @scan_hex: specifies if hexadecimal numbers are recognized (the default is %TRUE).
1639  * @scan_hex_dollar: specifies if '$' is recognized as a prefix for hexadecimal numbers (the default is %FALSE).
1640  * @scan_string_sq: specifies if strings can be enclosed in single quotes (the default is %TRUE).
1641  * @scan_string_dq: specifies if strings can be enclosed in double quotes (the default is %TRUE).
1642  * @numbers_2_int: specifies if binary, octal and hexadecimal numbers are reported as #G_TOKEN_INT (the default is %TRUE).
1643  * @int_2_float: specifies if all numbers are reported as %G_TOKEN_FLOAT (the default is %FALSE).
1644  * @identifier_2_string: specifies if identifiers are reported as strings (the default is %FALSE).
1645  * @char_2_token: specifies if characters are reported by setting <literal>token = ch</literal> or as %G_TOKEN_CHAR (the default is %TRUE).
1646  * @symbol_2_token: specifies if symbols are reported by setting <literal>token = v_symbol</literal> or as %G_TOKEN_SYMBOL (the default is %FALSE).
1647  * @scope_0_fallback: specifies if a symbol is searched for in the default scope in addition to the current scope (the default is %FALSE).
1648  * @store_int64: use value.v_int64 rather than v_int
1649  *
1650  * Specifies the #GScanner parser configuration. Most settings can
1651  * be changed during the parsing phase and will affect the lexical
1652  * parsing of the next unpeeked token.
1653  */
1654
1655
1656 /**
1657  * GScannerMsgFunc:
1658  * @scanner: a #GScanner
1659  * @message: the message
1660  * @error: %TRUE if the message signals an error, %FALSE if it signals a warning.
1661  *
1662  * Specifies the type of the message handler function.
1663  */
1664
1665
1666 /**
1667  * GSeekType:
1668  * @G_SEEK_CUR: the current position in the file.
1669  * @G_SEEK_SET: the start of the file.
1670  * @G_SEEK_END: the end of the file.
1671  *
1672  * An enumeration specifying the base position for a
1673  * g_io_channel_seek_position() operation.
1674  */
1675
1676
1677 /**
1678  * GSequence:
1679  *
1680  * The #GSequence struct is an opaque data type representing a
1681  * <link linkend="glib-Sequences">Sequence</link> data type.
1682  */
1683
1684
1685 /**
1686  * GSequenceIter:
1687  *
1688  * The #GSequenceIter struct is an opaque data type representing an
1689  * iterator pointing into a #GSequence.
1690  */
1691
1692
1693 /**
1694  * GSequenceIterCompareFunc:
1695  * @a: a #GSequenceIter
1696  * @b: a #GSequenceIter
1697  * @data: user data
1698  *
1699  * A #GSequenceIterCompareFunc is a function used to compare iterators.
1700  * It must return zero if the iterators compare equal, a negative value
1701  * if @a comes before @b, and a positive value if @b comes before @a.
1702  *
1703  * Returns: zero if the iterators are equal, a negative value if @a comes before @b, and a positive value if @b comes before @a.
1704  */
1705
1706
1707 /**
1708  * GShellError:
1709  * @G_SHELL_ERROR_BAD_QUOTING: Mismatched or otherwise mangled quoting.
1710  * @G_SHELL_ERROR_EMPTY_STRING: String to be parsed was empty.
1711  * @G_SHELL_ERROR_FAILED: Some other error.
1712  *
1713  * Error codes returned by shell functions.
1714  */
1715
1716
1717 /**
1718  * GStatBuf:
1719  *
1720  * A type corresponding to the appropriate struct type for the stat
1721  * system call, depending on the platform and/or compiler being used.
1722  *
1723  * See g_stat() for more information.
1724  */
1725
1726
1727 /**
1728  * GString:
1729  * @str: points to the character data. It may move as text is added. The @str field is null-terminated and so can be used as an ordinary C string.
1730  * @len: contains the length of the string, not including the terminating nul byte.
1731  * @allocated_len: the number of bytes that can be stored in the string before it needs to be reallocated. May be larger than @len.
1732  *
1733  * The GString struct contains the public fields of a GString.
1734  */
1735
1736
1737 /**
1738  * GStringChunk:
1739  *
1740  * An opaque data structure representing String Chunks.
1741  * It should only be accessed by using the following functions.
1742  */
1743
1744
1745 /**
1746  * GTestCase:
1747  *
1748  * An opaque structure representing a test case.
1749  */
1750
1751
1752 /**
1753  * GTestDataFunc:
1754  * @user_data: the data provided when registering the test
1755  *
1756  * The type used for test case functions that take an extra pointer
1757  * argument.
1758  *
1759  * Since: 2.28
1760  */
1761
1762
1763 /**
1764  * GTestFileType:
1765  * @G_TEST_DIST: a file that was included in the distribution tarball
1766  * @G_TEST_BUILT: a file that was built on the compiling machine
1767  *
1768  * The type of file to return the filename for, when used with
1769  * g_test_build_filename().
1770  *
1771  * These two options correspond rather directly to the 'dist' and
1772  * 'built' terminology that automake uses and are explicitly used to
1773  * distinguish between the 'srcdir' and 'builddir' being separate.  All
1774  * files in your project should either be dist (in the
1775  * <literal>DIST_EXTRA</literal> or <literal>dist_schema_DATA</literal>
1776  * sense, in which case they will always be in the srcdir) or built (in
1777  * the <literal>BUILT_SOURCES</literal> sense, in which case they will
1778  * always be in the builddir).
1779  *
1780  * Note: as a general rule of automake, files that are generated only as
1781  * part of the build-from-git process (but then are distributed with the
1782  * tarball) always go in srcdir (even if doing a srcdir != builddir
1783  * build from git) and are considered as distributed files.
1784  *
1785  * Since: 2.38
1786  */
1787
1788
1789 /**
1790  * GTestFixtureFunc:
1791  * @fixture: the test fixture
1792  * @user_data: the data provided when registering the test
1793  *
1794  * The type used for functions that operate on test fixtures.  This is
1795  * used for the fixture setup and teardown functions as well as for the
1796  * testcases themselves.
1797  *
1798  * @user_data is a pointer to the data that was given when registering
1799  * the test case.
1800  *
1801  * @fixture will be a pointer to the area of memory allocated by the
1802  * test framework, of the size requested.  If the requested size was
1803  * zero then @fixture will be equal to @user_data.
1804  *
1805  * Since: 2.28
1806  */
1807
1808
1809 /**
1810  * GTestFunc:
1811  *
1812  * The type used for test case functions.
1813  *
1814  * Since: 2.28
1815  */
1816
1817
1818 /**
1819  * GTestSubprocessFlags:
1820  * @G_TEST_SUBPROCESS_INHERIT_STDIN: If this flag is given, the child process will inherit the parent's stdin. Otherwise, the child's stdin is redirected to <filename>/dev/null</filename>.
1821  * @G_TEST_SUBPROCESS_INHERIT_STDOUT: If this flag is given, the child process will inherit the parent's stdout. Otherwise, the child's stdout will not be visible, but it will be captured to allow later tests with g_test_trap_assert_stdout().
1822  * @G_TEST_SUBPROCESS_INHERIT_STDERR: If this flag is given, the child process will inherit the parent's stderr. Otherwise, the child's stderr will not be visible, but it will be captured to allow later tests with g_test_trap_assert_stderr().
1823  *
1824  * Flags to pass to g_test_trap_subprocess() to control input and output.
1825  *
1826  * Note that in contrast with g_test_trap_fork(), the default is to
1827  * not show stdout and stderr.
1828  */
1829
1830
1831 /**
1832  * GTestSuite:
1833  *
1834  * An opaque structure representing a test suite.
1835  */
1836
1837
1838 /**
1839  * GTestTrapFlags:
1840  * @G_TEST_TRAP_SILENCE_STDOUT: Redirect stdout of the test child to <filename>/dev/null</filename> so it cannot be observed on the console during test runs. The actual output is still captured though to allow later tests with g_test_trap_assert_stdout().
1841  * @G_TEST_TRAP_SILENCE_STDERR: Redirect stderr of the test child to <filename>/dev/null</filename> so it cannot be observed on the console during test runs. The actual output is still captured though to allow later tests with g_test_trap_assert_stderr().
1842  * @G_TEST_TRAP_INHERIT_STDIN: If this flag is given, stdin of the child process is shared with stdin of its parent process. It is redirected to <filename>/dev/null</filename> otherwise.
1843  *
1844  * Test traps are guards around forked tests.
1845  * These flags determine what traps to set.
1846  *
1847  * Deprecated: #GTestTrapFlags is used only with g_test_trap_fork(), which is deprecated. g_test_trap_subprocess() uses #GTestTrapSubprocessFlags.
1848  */
1849
1850
1851 /**
1852  * GThread:
1853  *
1854  * The #GThread struct represents a running thread. This struct
1855  * is returned by g_thread_new() or g_thread_try_new(). You can
1856  * obtain the #GThread struct representing the current thead by
1857  * calling g_thread_self().
1858  *
1859  * GThread is refcounted, see g_thread_ref() and g_thread_unref().
1860  * The thread represented by it holds a reference while it is running,
1861  * and g_thread_join() consumes the reference that it is given, so
1862  * it is normally not necessary to manage GThread references
1863  * explicitly.
1864  *
1865  * The structure is opaque -- none of its fields may be directly
1866  * accessed.
1867  */
1868
1869
1870 /**
1871  * GThreadError:
1872  * @G_THREAD_ERROR_AGAIN: a thread couldn't be created due to resource shortage. Try again later.
1873  *
1874  * Possible errors of thread related functions.
1875  */
1876
1877
1878 /**
1879  * GThreadFunc:
1880  * @data: data passed to the thread
1881  *
1882  * Specifies the type of the @func functions passed to g_thread_new()
1883  * or g_thread_try_new().
1884  *
1885  * Returns: the return value of the thread
1886  */
1887
1888
1889 /**
1890  * GThreadPool:
1891  * @func: the function to execute in the threads of this pool
1892  * @user_data: the user data for the threads of this pool
1893  * @exclusive: are all threads exclusive to this pool
1894  *
1895  * The #GThreadPool struct represents a thread pool. It has three
1896  * public read-only members, but the underlying struct is bigger,
1897  * so you must not copy this struct.
1898  */
1899
1900
1901 /**
1902  * GTime:
1903  *
1904  * Simply a replacement for <type>time_t</type>. It has been deprecated
1905  * since it is <emphasis>not</emphasis> equivalent to <type>time_t</type>
1906  * on 64-bit platforms with a 64-bit <type>time_t</type>.
1907  * Unrelated to #GTimer.
1908  *
1909  * Note that <type>GTime</type> is defined to always be a 32bit integer,
1910  * unlike <type>time_t</type> which may be 64bit on some systems.
1911  * Therefore, <type>GTime</type> will overflow in the year 2038, and
1912  * you cannot use the address of a <type>GTime</type> variable as argument
1913  * to the UNIX time() function. Instead, do the following:
1914  * |[
1915  * time_t ttime;
1916  * GTime gtime;
1917  *
1918  * time (&amp;ttime);
1919  * gtime = (GTime)ttime;
1920  * ]|
1921  */
1922
1923
1924 /**
1925  * GTimeVal:
1926  * @tv_sec: seconds
1927  * @tv_usec: microseconds
1928  *
1929  * Represents a precise time, with seconds and microseconds.
1930  * Similar to the <structname>struct timeval</structname> returned by
1931  * the gettimeofday() UNIX system call.
1932  *
1933  * GLib is attempting to unify around the use of 64bit integers to
1934  * represent microsecond-precision time. As such, this type will be
1935  * removed from a future version of GLib.
1936  */
1937
1938
1939 /**
1940  * GTimeZone:
1941  *
1942  * #GTimeZone is an opaque structure whose members cannot be accessed
1943  * directly.
1944  *
1945  * Since: 2.26
1946  */
1947
1948
1949 /**
1950  * GTimer:
1951  *
1952  * Opaque datatype that records a start time.
1953  */
1954
1955
1956 /**
1957  * GTokenType:
1958  * @G_TOKEN_EOF: the end of the file
1959  * @G_TOKEN_LEFT_PAREN: a '(' character
1960  * @G_TOKEN_LEFT_CURLY: a '{' character
1961  * @G_TOKEN_LEFT_BRACE: a '[' character
1962  * @G_TOKEN_RIGHT_CURLY: a '}' character
1963  * @G_TOKEN_RIGHT_PAREN: a ')' character
1964  * @G_TOKEN_RIGHT_BRACE: a ']' character
1965  * @G_TOKEN_EQUAL_SIGN: a '=' character
1966  * @G_TOKEN_COMMA: a ',' character
1967  * @G_TOKEN_NONE: not a token
1968  * @G_TOKEN_ERROR: an error occurred
1969  * @G_TOKEN_CHAR: a character
1970  * @G_TOKEN_BINARY: a binary integer
1971  * @G_TOKEN_OCTAL: an octal integer
1972  * @G_TOKEN_INT: an integer
1973  * @G_TOKEN_HEX: a hex integer
1974  * @G_TOKEN_FLOAT: a floating point number
1975  * @G_TOKEN_STRING: a string
1976  * @G_TOKEN_SYMBOL: a symbol
1977  * @G_TOKEN_IDENTIFIER: an identifier
1978  * @G_TOKEN_IDENTIFIER_NULL: a null identifier
1979  * @G_TOKEN_COMMENT_SINGLE: one line comment
1980  * @G_TOKEN_COMMENT_MULTI: multi line comment
1981  *
1982  * The possible types of token returned from each
1983  * g_scanner_get_next_token() call.
1984  */
1985
1986
1987 /**
1988  * GTokenValue:
1989  * @v_symbol: token symbol value
1990  * @v_identifier: token identifier value
1991  * @v_binary: token binary integer value
1992  * @v_octal: octal integer value
1993  * @v_int: integer value
1994  * @v_int64: 64-bit integer value
1995  * @v_float: floating point value
1996  * @v_hex: hex integer value
1997  * @v_string: string value
1998  * @v_comment: comment value
1999  * @v_char: character value
2000  * @v_error: error value
2001  *
2002  * A union holding the value of the token.
2003  */
2004
2005
2006 /**
2007  * GTrashStack:
2008  * @next: pointer to the previous element of the stack, gets stored in the first <literal>sizeof (gpointer)</literal> bytes of the element
2009  *
2010  * Each piece of memory that is pushed onto the stack
2011  * is cast to a <structname>GTrashStack*</structname>.
2012  */
2013
2014
2015 /**
2016  * GTraverseFlags:
2017  * @G_TRAVERSE_LEAVES: only leaf nodes should be visited. This name has been introduced in 2.6, for older version use %G_TRAVERSE_LEAFS.
2018  * @G_TRAVERSE_NON_LEAVES: only non-leaf nodes should be visited. This name has been introduced in 2.6, for older version use %G_TRAVERSE_NON_LEAFS.
2019  * @G_TRAVERSE_ALL: all nodes should be visited.
2020  * @G_TRAVERSE_MASK: a mask of all traverse flags.
2021  * @G_TRAVERSE_LEAFS: identical to %G_TRAVERSE_LEAVES.
2022  * @G_TRAVERSE_NON_LEAFS: identical to %G_TRAVERSE_NON_LEAVES.
2023  *
2024  * Specifies which nodes are visited during several of the tree
2025  * functions, including g_node_traverse() and g_node_find().
2026  */
2027
2028
2029 /**
2030  * GTraverseFunc:
2031  * @key: a key of a #GTree node.
2032  * @value: the value corresponding to the key.
2033  * @data: user data passed to g_tree_traverse().
2034  *
2035  * Specifies the type of function passed to g_tree_traverse(). It is
2036  * passed the key and value of each node, together with the @user_data
2037  * parameter passed to g_tree_traverse(). If the function returns
2038  * %TRUE, the traversal is stopped.
2039  *
2040  * Returns: %TRUE to stop the traversal.
2041  */
2042
2043
2044 /**
2045  * GTraverseType:
2046  * @G_IN_ORDER: vists a node's left child first, then the node itself, then its right child. This is the one to use if you want the output sorted according to the compare function.
2047  * @G_PRE_ORDER: visits a node, then its children.
2048  * @G_POST_ORDER: visits the node's children, then the node itself.
2049  * @G_LEVEL_ORDER: is not implemented for <link linkend="glib-Balanced-Binary-Trees">Balanced Binary Trees</link>.  For <link linkend="glib-N-ary-Trees">N-ary Trees</link>, it vists the root node first, then its children, then its grandchildren, and so on. Note that this is less efficient than the other orders.
2050  *
2051  * Specifies the type of traveral performed by g_tree_traverse(),
2052  * g_node_traverse() and g_node_find().
2053  */
2054
2055
2056 /**
2057  * GTree:
2058  *
2059  * The <structname>GTree</structname> struct is an opaque data
2060  * structure representing a <link
2061  * linkend="glib-Balanced-Binary-Trees">Balanced Binary Tree</link>. It
2062  * should be accessed only by using the following functions.
2063  */
2064
2065
2066 /**
2067  * GUINT16_FROM_BE:
2068  * @val: a #guint16 value in big-endian byte order
2069  *
2070  * Converts a #guint16 value from big-endian to host byte order.
2071  *
2072  * Returns: @val converted to host byte order
2073  */
2074
2075
2076 /**
2077  * GUINT16_FROM_LE:
2078  * @val: a #guint16 value in little-endian byte order
2079  *
2080  * Converts a #guint16 value from little-endian to host byte order.
2081  *
2082  * Returns: @val converted to host byte order
2083  */
2084
2085
2086 /**
2087  * GUINT16_SWAP_BE_PDP:
2088  * @val: a #guint16 value in big-endian or pdp-endian byte order
2089  *
2090  * Converts a #guint16 value between big-endian and pdp-endian byte order.
2091  * The conversion is symmetric so it can be used both ways.
2092  *
2093  * Returns: @val converted to the opposite byte order
2094  */
2095
2096
2097 /**
2098  * GUINT16_SWAP_LE_BE:
2099  * @val: a #guint16 value in little-endian or big-endian byte order
2100  *
2101  * Converts a #guint16 value between little-endian and big-endian byte order.
2102  * The conversion is symmetric so it can be used both ways.
2103  *
2104  * Returns: @val converted to the opposite byte order
2105  */
2106
2107
2108 /**
2109  * GUINT16_SWAP_LE_PDP:
2110  * @val: a #guint16 value in little-endian or pdp-endian byte order
2111  *
2112  * Converts a #guint16 value between little-endian and pdp-endian byte order.
2113  * The conversion is symmetric so it can be used both ways.
2114  *
2115  * Returns: @val converted to the opposite byte order
2116  */
2117
2118
2119 /**
2120  * GUINT16_TO_BE:
2121  * @val: a #guint16 value in host byte order
2122  *
2123  * Converts a #guint16 value from host byte order to big-endian.
2124  *
2125  * Returns: @val converted to big-endian
2126  */
2127
2128
2129 /**
2130  * GUINT16_TO_LE:
2131  * @val: a #guint16 value in host byte order
2132  *
2133  * Converts a #guint16 value from host byte order to little-endian.
2134  *
2135  * Returns: @val converted to little-endian
2136  */
2137
2138
2139 /**
2140  * GUINT32_FROM_BE:
2141  * @val: a #guint32 value in big-endian byte order
2142  *
2143  * Converts a #guint32 value from big-endian to host byte order.
2144  *
2145  * Returns: @val converted to host byte order
2146  */
2147
2148
2149 /**
2150  * GUINT32_FROM_LE:
2151  * @val: a #guint32 value in little-endian byte order
2152  *
2153  * Converts a #guint32 value from little-endian to host byte order.
2154  *
2155  * Returns: @val converted to host byte order
2156  */
2157
2158
2159 /**
2160  * GUINT32_SWAP_BE_PDP:
2161  * @val: a #guint32 value in big-endian or pdp-endian byte order
2162  *
2163  * Converts a #guint32 value between big-endian and pdp-endian byte order.
2164  * The conversion is symmetric so it can be used both ways.
2165  *
2166  * Returns: @val converted to the opposite byte order
2167  */
2168
2169
2170 /**
2171  * GUINT32_SWAP_LE_BE:
2172  * @val: a #guint32 value in little-endian or big-endian byte order
2173  *
2174  * Converts a #guint32 value between little-endian and big-endian byte order.
2175  * The conversion is symmetric so it can be used both ways.
2176  *
2177  * Returns: @val converted to the opposite byte order
2178  */
2179
2180
2181 /**
2182  * GUINT32_SWAP_LE_PDP:
2183  * @val: a #guint32 value in little-endian or pdp-endian byte order
2184  *
2185  * Converts a #guint32 value between little-endian and pdp-endian byte order.
2186  * The conversion is symmetric so it can be used both ways.
2187  *
2188  * Returns: @val converted to the opposite byte order
2189  */
2190
2191
2192 /**
2193  * GUINT32_TO_BE:
2194  * @val: a #guint32 value in host byte order
2195  *
2196  * Converts a #guint32 value from host byte order to big-endian.
2197  *
2198  * Returns: @val converted to big-endian
2199  */
2200
2201
2202 /**
2203  * GUINT32_TO_LE:
2204  * @val: a #guint32 value in host byte order
2205  *
2206  * Converts a #guint32 value from host byte order to little-endian.
2207  *
2208  * Returns: @val converted to little-endian
2209  */
2210
2211
2212 /**
2213  * GUINT64_FROM_BE:
2214  * @val: a #guint64 value in big-endian byte order
2215  *
2216  * Converts a #guint64 value from big-endian to host byte order.
2217  *
2218  * Returns: @val converted to host byte order
2219  */
2220
2221
2222 /**
2223  * GUINT64_FROM_LE:
2224  * @val: a #guint64 value in little-endian byte order
2225  *
2226  * Converts a #guint64 value from little-endian to host byte order.
2227  *
2228  * Returns: @val converted to host byte order
2229  */
2230
2231
2232 /**
2233  * GUINT64_SWAP_LE_BE:
2234  * @val: a #guint64 value in little-endian or big-endian byte order
2235  *
2236  * Converts a #guint64 value between little-endian and big-endian byte order.
2237  * The conversion is symmetric so it can be used both ways.
2238  *
2239  * Returns: @val converted to the opposite byte order
2240  */
2241
2242
2243 /**
2244  * GUINT64_TO_BE:
2245  * @val: a #guint64 value in host byte order
2246  *
2247  * Converts a #guint64 value from host byte order to big-endian.
2248  *
2249  * Returns: @val converted to big-endian
2250  */
2251
2252
2253 /**
2254  * GUINT64_TO_LE:
2255  * @val: a #guint64 value in host byte order
2256  *
2257  * Converts a #guint64 value from host byte order to little-endian.
2258  *
2259  * Returns: @val converted to little-endian
2260  */
2261
2262
2263 /**
2264  * GUINT_FROM_BE:
2265  * @val: a #guint value in big-endian byte order
2266  *
2267  * Converts a #guint value from big-endian to host byte order.
2268  *
2269  * Returns: @val converted to host byte order
2270  */
2271
2272
2273 /**
2274  * GUINT_FROM_LE:
2275  * @val: a #guint value in little-endian byte order
2276  *
2277  * Converts a #guint value from little-endian to host byte order.
2278  *
2279  * Returns: @val converted to host byte order
2280  */
2281
2282
2283 /**
2284  * GUINT_TO_BE:
2285  * @val: a #guint value in host byte order
2286  *
2287  * Converts a #guint value from host byte order to big-endian.
2288  *
2289  * Returns: @val converted to big-endian byte order
2290  */
2291
2292
2293 /**
2294  * GUINT_TO_LE:
2295  * @val: a #guint value in host byte order
2296  *
2297  * Converts a #guint value from host byte order to little-endian.
2298  *
2299  * Returns: @val converted to little-endian byte order.
2300  */
2301
2302
2303 /**
2304  * GUINT_TO_POINTER:
2305  * @u: unsigned integer to stuff into the pointer
2306  *
2307  * Stuffs an unsigned integer into a pointer type.
2308  */
2309
2310
2311 /**
2312  * GULONG_FROM_BE:
2313  * @val: a #gulong value in big-endian byte order
2314  *
2315  * Converts a #gulong value from big-endian to host byte order.
2316  *
2317  * Returns: @val converted to host byte order
2318  */
2319
2320
2321 /**
2322  * GULONG_FROM_LE:
2323  * @val: a #gulong value in little-endian byte order
2324  *
2325  * Converts a #gulong value from little-endian to host byte order.
2326  *
2327  * Returns: @val converted to host byte order
2328  */
2329
2330
2331 /**
2332  * GULONG_TO_BE:
2333  * @val: a #gulong value in host byte order
2334  *
2335  * Converts a #gulong value from host byte order to big-endian.
2336  *
2337  * Returns: @val converted to big-endian
2338  */
2339
2340
2341 /**
2342  * GULONG_TO_LE:
2343  * @val: a #gulong value in host byte order
2344  *
2345  * Converts a #gulong value from host byte order to little-endian.
2346  *
2347  * Returns: @val converted to little-endian
2348  */
2349
2350
2351 /**
2352  * GVariant:
2353  *
2354  * #GVariant is an opaque data structure and can only be accessed
2355  * using the following functions.
2356  *
2357  * Since: 2.24
2358  */
2359
2360
2361 /**
2362  * GVariantBuilder:
2363  *
2364  * A utility type for constructing container-type #GVariant instances.
2365  *
2366  * This is an opaque structure and may only be accessed using the
2367  * following functions.
2368  *
2369  * #GVariantBuilder is not threadsafe in any way.  Do not attempt to
2370  * access it from more than one thread.
2371  */
2372
2373
2374 /**
2375  * GVariantClass:
2376  * @G_VARIANT_CLASS_BOOLEAN: The #GVariant is a boolean.
2377  * @G_VARIANT_CLASS_BYTE: The #GVariant is a byte.
2378  * @G_VARIANT_CLASS_INT16: The #GVariant is a signed 16 bit integer.
2379  * @G_VARIANT_CLASS_UINT16: The #GVariant is an unsigned 16 bit integer.
2380  * @G_VARIANT_CLASS_INT32: The #GVariant is a signed 32 bit integer.
2381  * @G_VARIANT_CLASS_UINT32: The #GVariant is an unsigned 32 bit integer.
2382  * @G_VARIANT_CLASS_INT64: The #GVariant is a signed 64 bit integer.
2383  * @G_VARIANT_CLASS_UINT64: The #GVariant is an unsigned 64 bit integer.
2384  * @G_VARIANT_CLASS_HANDLE: The #GVariant is a file handle index.
2385  * @G_VARIANT_CLASS_DOUBLE: The #GVariant is a double precision floating point value.
2386  * @G_VARIANT_CLASS_STRING: The #GVariant is a normal string.
2387  * @G_VARIANT_CLASS_OBJECT_PATH: The #GVariant is a D-Bus object path string.
2388  * @G_VARIANT_CLASS_SIGNATURE: The #GVariant is a D-Bus signature string.
2389  * @G_VARIANT_CLASS_VARIANT: The #GVariant is a variant.
2390  * @G_VARIANT_CLASS_MAYBE: The #GVariant is a maybe-typed value.
2391  * @G_VARIANT_CLASS_ARRAY: The #GVariant is an array.
2392  * @G_VARIANT_CLASS_TUPLE: The #GVariant is a tuple.
2393  * @G_VARIANT_CLASS_DICT_ENTRY: The #GVariant is a dictionary entry.
2394  *
2395  * The range of possible top-level types of #GVariant instances.
2396  *
2397  * Since: 2.24
2398  */
2399
2400
2401 /**
2402  * GVariantIter: (skip)
2403  *
2404  * #GVariantIter is an opaque data structure and can only be accessed
2405  * using the following functions.
2406  */
2407
2408
2409 /**
2410  * GVariantParseError:
2411  * @G_VARIANT_PARSE_ERROR_FAILED: generic error (unused)
2412  * @G_VARIANT_PARSE_ERROR_BASIC_TYPE_EXPECTED: a non-basic #GVariantType was given where a basic type was expected
2413  * @G_VARIANT_PARSE_ERROR_CANNOT_INFER_TYPE: cannot infer the #GVariantType
2414  * @G_VARIANT_PARSE_ERROR_DEFINITE_TYPE_EXPECTED: an indefinite #GVariantType was given where a definite type was expected
2415  * @G_VARIANT_PARSE_ERROR_INPUT_NOT_AT_END: extra data after parsing finished
2416  * @G_VARIANT_PARSE_ERROR_INVALID_CHARACTER: invalid character in number or unicode escape
2417  * @G_VARIANT_PARSE_ERROR_INVALID_FORMAT_STRING: not a valid #GVariant format string
2418  * @G_VARIANT_PARSE_ERROR_INVALID_OBJECT_PATH: not a valid object path
2419  * @G_VARIANT_PARSE_ERROR_INVALID_SIGNATURE: not a valid type signature
2420  * @G_VARIANT_PARSE_ERROR_INVALID_TYPE_STRING: not a valid #GVariant type string
2421  * @G_VARIANT_PARSE_ERROR_NO_COMMON_TYPE: could not find a common type for array entries
2422  * @G_VARIANT_PARSE_ERROR_NUMBER_OUT_OF_RANGE: the numerical value is out of range of the given type
2423  * @G_VARIANT_PARSE_ERROR_NUMBER_TOO_BIG: the numerical value is out of range for any type
2424  * @G_VARIANT_PARSE_ERROR_TYPE_ERROR: cannot parse as variant of the specified type
2425  * @G_VARIANT_PARSE_ERROR_UNEXPECTED_TOKEN: an unexpected token was encountered
2426  * @G_VARIANT_PARSE_ERROR_UNKNOWN_KEYWORD: an unknown keyword was encountered
2427  * @G_VARIANT_PARSE_ERROR_UNTERMINATED_STRING_CONSTANT: unterminated string constant
2428  * @G_VARIANT_PARSE_ERROR_VALUE_EXPECTED: no value given
2429  *
2430  * Error codes returned by parsing text-format GVariants.
2431  */
2432
2433
2434 /**
2435  * G_ASCII_DTOSTR_BUF_SIZE:
2436  *
2437  * A good size for a buffer to be passed into g_ascii_dtostr().
2438  * It is guaranteed to be enough for all output of that function
2439  * on systems with 64bit IEEE-compatible doubles.
2440  *
2441  * The typical usage would be something like:
2442  * |[
2443  *   char buf[G_ASCII_DTOSTR_BUF_SIZE];
2444  *
2445  *   fprintf (out, "value=&percnt;s\n", g_ascii_dtostr (buf, sizeof (buf), value));
2446  * ]|
2447  */
2448
2449
2450 /**
2451  * G_ATOMIC_LOCK_FREE:
2452  *
2453  * This macro is defined if the atomic operations of GLib are
2454  * implemented using real hardware atomic operations.  This means that
2455  * the GLib atomic API can be used between processes and safely mixed
2456  * with other (hardware) atomic APIs.
2457  *
2458  * If this macro is not defined, the atomic operations may be
2459  * emulated using a mutex.  In that case, the GLib atomic operations are
2460  * only atomic relative to themselves and within a single process.
2461  */
2462
2463
2464 /**
2465  * G_BEGIN_DECLS:
2466  *
2467  * Used (along with #G_END_DECLS) to bracket header files. If the
2468  * compiler in use is a C++ compiler, adds <literal>extern "C"</literal>
2469  * around the header.
2470  */
2471
2472
2473 /**
2474  * G_BIG_ENDIAN:
2475  *
2476  * Specifies one of the possible types of byte order.
2477  * See #G_BYTE_ORDER.
2478  */
2479
2480
2481 /**
2482  * G_BYTE_ORDER:
2483  *
2484  * The host byte order.
2485  * This can be either #G_LITTLE_ENDIAN or #G_BIG_ENDIAN (support for
2486  * #G_PDP_ENDIAN may be added in future.)
2487  */
2488
2489
2490 /**
2491  * G_CONST_RETURN:
2492  *
2493  * If <literal>G_DISABLE_CONST_RETURNS</literal> is defined, this macro expands
2494  * to nothing. By default, the macro expands to <literal>const</literal>.
2495  * The macro should be used in place of <literal>const</literal> for
2496  * functions that return a value that should not be modified. The
2497  * purpose of this macro is to allow us to turn on <literal>const</literal>
2498  * for returned constant strings by default, while allowing programmers
2499  * who find that annoying to turn it off. This macro should only be used
2500  * for return values and for <emphasis>out</emphasis> parameters, it doesn't
2501  * make sense for <emphasis>in</emphasis> parameters.
2502  *
2503  * Deprecated: 2.30: API providers should replace all existing uses with <literal>const</literal> and API consumers should adjust their code accordingly
2504  */
2505
2506
2507 /**
2508  * G_CSET_A_2_Z:
2509  *
2510  * The set of uppercase ASCII alphabet characters.
2511  * Used for specifying valid identifier characters
2512  * in #GScannerConfig.
2513  */
2514
2515
2516 /**
2517  * G_CSET_LATINC:
2518  *
2519  * The set of uppercase ISO 8859-1 alphabet characters
2520  * which are not ASCII characters.
2521  * Used for specifying valid identifier characters
2522  * in #GScannerConfig.
2523  */
2524
2525
2526 /**
2527  * G_CSET_LATINS:
2528  *
2529  * The set of lowercase ISO 8859-1 alphabet characters
2530  * which are not ASCII characters.
2531  * Used for specifying valid identifier characters
2532  * in #GScannerConfig.
2533  */
2534
2535
2536 /**
2537  * G_CSET_a_2_z:
2538  *
2539  * The set of lowercase ASCII alphabet characters.
2540  * Used for specifying valid identifier characters
2541  * in #GScannerConfig.
2542  */
2543
2544
2545 /**
2546  * G_DATE_BAD_DAY:
2547  *
2548  * Represents an invalid #GDateDay.
2549  */
2550
2551
2552 /**
2553  * G_DATE_BAD_JULIAN:
2554  *
2555  * Represents an invalid Julian day number.
2556  */
2557
2558
2559 /**
2560  * G_DATE_BAD_YEAR:
2561  *
2562  * Represents an invalid year.
2563  */
2564
2565
2566 /**
2567  * G_DEFINE_QUARK:
2568  * @QN: the name to return a #GQuark for
2569  * @q_n: prefix for the function name
2570  *
2571  * A convenience macro which defines a function returning the
2572  * #GQuark for the name @QN. The function will be named
2573  * @q_n<!-- -->_quark().
2574  * Note that the quark name will be stringified automatically in the
2575  * macro, so you shouldn't use double quotes.
2576  *
2577  * Since: 2.34
2578  */
2579
2580
2581 /**
2582  * G_DEPRECATED:
2583  *
2584  * This macro is similar to %G_GNUC_DEPRECATED, and can be used to mark
2585  * functions declarations as deprecated. Unlike %G_GNUC_DEPRECATED, it is
2586  * meant to be portable across different compilers and must be placed
2587  * before the function declaration.
2588  *
2589  * Since: 2.32
2590  */
2591
2592
2593 /**
2594  * G_DEPRECATED_FOR:
2595  * @f: the name of the function that this function was deprecated for
2596  *
2597  * This macro is similar to %G_GNUC_DEPRECATED_FOR, and can be used to mark
2598  * functions declarations as deprecated. Unlike %G_GNUC_DEPRECATED_FOR, it is
2599  * meant to be portable across different compilers and must be placed
2600  * before the function declaration.
2601  *
2602  * Since: 2.32
2603  */
2604
2605
2606 /**
2607  * G_DIR_SEPARATOR:
2608  *
2609  * The directory separator character.
2610  * This is '/' on UNIX machines and '\' under Windows.
2611  */
2612
2613
2614 /**
2615  * G_DIR_SEPARATOR_S:
2616  *
2617  * The directory separator as a string.
2618  * This is "/" on UNIX machines and "\" under Windows.
2619  */
2620
2621
2622 /**
2623  * G_E:
2624  *
2625  * The base of natural logarithms.
2626  */
2627
2628
2629 /**
2630  * G_END_DECLS:
2631  *
2632  * Used (along with #G_BEGIN_DECLS) to bracket header files. If the
2633  * compiler in use is a C++ compiler, adds <literal>extern "C"</literal>
2634  * around the header.
2635  */
2636
2637
2638 /**
2639  * G_FILE_ERROR:
2640  *
2641  * Error domain for file operations. Errors in this domain will
2642  * be from the #GFileError enumeration. See #GError for information
2643  * on error domains.
2644  */
2645
2646
2647 /**
2648  * G_GINT16_FORMAT:
2649  *
2650  * This is the platform dependent conversion specifier for scanning and
2651  * printing values of type #gint16. It is a string literal, but doesn't
2652  * include the percent-sign, such that you can add precision and length
2653  * modifiers between percent-sign and conversion specifier.
2654  *
2655  * |[
2656  * gint16 in;
2657  * gint32 out;
2658  * sscanf ("42", "%" G_GINT16_FORMAT, &amp;in)
2659  * out = in * 1000;
2660  * g_print ("%" G_GINT32_FORMAT, out);
2661  * ]|
2662  */
2663
2664
2665 /**
2666  * G_GINT16_MODIFIER:
2667  *
2668  * The platform dependent length modifier for conversion specifiers
2669  * for scanning and printing values of type #gint16 or #guint16. It
2670  * is a string literal, but doesn't include the percent-sign, such
2671  * that you can add precision and length modifiers between percent-sign
2672  * and conversion specifier and append a conversion specifier.
2673  *
2674  * The following example prints "0x7b";
2675  * |[
2676  * gint16 value = 123;
2677  * g_print ("%#" G_GINT16_MODIFIER "x", value);
2678  * ]|
2679  *
2680  * Since: 2.4
2681  */
2682
2683
2684 /**
2685  * G_GINT32_FORMAT:
2686  *
2687  * This is the platform dependent conversion specifier for scanning
2688  * and printing values of type #gint32. See also #G_GINT16_FORMAT.
2689  */
2690
2691
2692 /**
2693  * G_GINT32_MODIFIER:
2694  *
2695  * The platform dependent length modifier for conversion specifiers
2696  * for scanning and printing values of type #gint32 or #guint32. It
2697  * is a string literal. See also #G_GINT16_MODIFIER.
2698  *
2699  * Since: 2.4
2700  */
2701
2702
2703 /**
2704  * G_GINT64_CONSTANT:
2705  * @val: a literal integer value, e.g. 0x1d636b02300a7aa7
2706  *
2707  * This macro is used to insert 64-bit integer literals
2708  * into the source code.
2709  */
2710
2711
2712 /**
2713  * G_GINT64_FORMAT:
2714  *
2715  * This is the platform dependent conversion specifier for scanning
2716  * and printing values of type #gint64. See also #G_GINT16_FORMAT.
2717  *
2718  * <note><para>
2719  * Some platforms do not support scanning and printing 64 bit integers,
2720  * even though the types are supported. On such platforms #G_GINT64_FORMAT
2721  * is not defined. Note that scanf() may not support 64 bit integers, even
2722  * if #G_GINT64_FORMAT is defined. Due to its weak error handling, scanf()
2723  * is not recommended for parsing anyway; consider using g_ascii_strtoull()
2724  * instead.
2725  * </para></note>
2726  */
2727
2728
2729 /**
2730  * G_GINT64_MODIFIER:
2731  *
2732  * The platform dependent length modifier for conversion specifiers
2733  * for scanning and printing values of type #gint64 or #guint64.
2734  * It is a string literal.
2735  *
2736  * <note><para>
2737  * Some platforms do not support printing 64 bit integers, even
2738  * though the types are supported. On such platforms #G_GINT64_MODIFIER
2739  * is not defined.
2740  * </para></note>
2741  *
2742  * Since: 2.4
2743  */
2744
2745
2746 /**
2747  * G_GINTPTR_FORMAT:
2748  *
2749  * This is the platform dependent conversion specifier for scanning
2750  * and printing values of type #gintptr.
2751  *
2752  * Since: 2.22
2753  */
2754
2755
2756 /**
2757  * G_GINTPTR_MODIFIER:
2758  *
2759  * The platform dependent length modifier for conversion specifiers
2760  * for scanning and printing values of type #gintptr or #guintptr.
2761  * It is a string literal.
2762  *
2763  * Since: 2.22
2764  */
2765
2766
2767 /**
2768  * G_GNUC_ALLOC_SIZE:
2769  * @x: the index of the argument specifying the allocation size
2770  *
2771  * Expands to the GNU C <literal>alloc_size</literal> function attribute
2772  * if the compiler is a new enough <command>gcc</command>. This attribute
2773  * tells the compiler that the function returns a pointer to memory of a
2774  * size that is specified by the @x<!-- -->th function parameter.
2775  *
2776  * Place the attribute after the function declaration, just before the
2777  * semicolon.
2778  *
2779  * See the GNU C documentation for more details.
2780  *
2781  * Since: 2.18
2782  */
2783
2784
2785 /**
2786  * G_GNUC_ALLOC_SIZE2:
2787  * @x: the index of the argument specifying one factor of the allocation size
2788  * @y: the index of the argument specifying the second factor of the allocation size
2789  *
2790  * Expands to the GNU C <literal>alloc_size</literal> function attribute
2791  * if the compiler is a new enough <command>gcc</command>. This attribute
2792  * tells the compiler that the function returns a pointer to memory of a
2793  * size that is specified by the product of two function parameters.
2794  *
2795  * Place the attribute after the function declaration, just before the
2796  * semicolon.
2797  *
2798  * See the GNU C documentation for more details.
2799  *
2800  * Since: 2.18
2801  */
2802
2803
2804 /**
2805  * G_GNUC_BEGIN_IGNORE_DEPRECATIONS:
2806  *
2807  * Tells <command>gcc</command> (if it is a new enough version) to
2808  * temporarily stop emitting warnings when functions marked with
2809  * %G_GNUC_DEPRECATED or %G_GNUC_DEPRECATED_FOR are called. This is
2810  * useful for when you have one deprecated function calling another
2811  * one, or when you still have regression tests for deprecated
2812  * functions.
2813  *
2814  * Use %G_GNUC_END_IGNORE_DEPRECATIONS to begin warning again. (If you
2815  * are not compiling with <literal>-Wdeprecated-declarations</literal>
2816  * then neither macro has any effect.)
2817  *
2818  * This macro can be used either inside or outside of a function body,
2819  * but must appear on a line by itself.
2820  *
2821  * Since: 2.32
2822  */
2823
2824
2825 /**
2826  * G_GNUC_CONST:
2827  *
2828  * Expands to the GNU C <literal>const</literal> function attribute if
2829  * the compiler is <command>gcc</command>. Declaring a function as const
2830  * enables better optimization of calls to the function. A const function
2831  * doesn't examine any values except its parameters, and has no effects
2832  * except its return value.
2833  *
2834  * Place the attribute after the declaration, just before the semicolon.
2835  *
2836  * See the GNU C documentation for more details.
2837  *
2838  * <note><para>
2839  * A function that has pointer arguments and examines the data pointed to
2840  * must <emphasis>not</emphasis> be declared const. Likewise, a function
2841  * that calls a non-const function usually must not be const. It doesn't
2842  * make sense for a const function to return void.
2843  * </para></note>
2844  */
2845
2846
2847 /**
2848  * G_GNUC_DEPRECATED:
2849  *
2850  * Expands to the GNU C <literal>deprecated</literal> attribute if the
2851  * compiler is <command>gcc</command>. It can be used to mark typedefs,
2852  * variables and functions as deprecated. When called with the
2853  * <option>-Wdeprecated-declarations</option> option, the compiler will
2854  * generate warnings when deprecated interfaces are used.
2855  *
2856  * Place the attribute after the declaration, just before the semicolon.
2857  *
2858  * See the GNU C documentation for more details.
2859  *
2860  * Since: 2.2
2861  */
2862
2863
2864 /**
2865  * G_GNUC_DEPRECATED_FOR:
2866  * @f: the intended replacement for the deprecated symbol, such as the name of a function
2867  *
2868  * Like %G_GNUC_DEPRECATED, but names the intended replacement for the
2869  * deprecated symbol if the version of <command>gcc</command> in use is
2870  * new enough to support custom deprecation messages.
2871  *
2872  * Place the attribute after the declaration, just before the semicolon.
2873  *
2874  * See the GNU C documentation for more details.
2875  *
2876  * Note that if @f is a macro, it will be expanded in the warning message.
2877  * You can enclose it in quotes to prevent this. (The quotes will show up
2878  * in the warning, but it's better than showing the macro expansion.)
2879  *
2880  * Since: 2.26
2881  */
2882
2883
2884 /**
2885  * G_GNUC_END_IGNORE_DEPRECATIONS:
2886  *
2887  * Undoes the effect of %G_GNUC_BEGIN_IGNORE_DEPRECATIONS, telling
2888  * <command>gcc</command> to begin outputting warnings again
2889  * (assuming those warnings had been enabled to begin with).
2890  *
2891  * This macro can be used either inside or outside of a function body,
2892  * but must appear on a line by itself.
2893  *
2894  * Since: 2.32
2895  */
2896
2897
2898 /**
2899  * G_GNUC_EXTENSION:
2900  *
2901  * Expands to <literal>__extension__</literal> when <command>gcc</command>
2902  * is used as the compiler. This simply tells <command>gcc</command> not
2903  * to warn about the following non-standard code when compiling with the
2904  * <option>-pedantic</option> option.
2905  */
2906
2907
2908 /**
2909  * G_GNUC_FORMAT:
2910  * @arg_idx: the index of the argument
2911  *
2912  * Expands to the GNU C <literal>format_arg</literal> function attribute
2913  * if the compiler is <command>gcc</command>. This function attribute
2914  * specifies that a function takes a format string for a printf(),
2915  * scanf(), strftime() or strfmon() style function and modifies it,
2916  * so that the result can be passed to a printf(), scanf(), strftime()
2917  * or strfmon() style function (with the remaining arguments to the
2918  * format function the same as they would have been for the unmodified
2919  * string).
2920  *
2921  * Place the attribute after the function declaration, just before the
2922  * semicolon.
2923  *
2924  * See the GNU C documentation for more details.
2925  *
2926  * |[
2927  * gchar *g_dgettext (gchar *domain_name, gchar *msgid) G_GNUC_FORMAT (2);
2928  * ]|
2929  */
2930
2931
2932 /**
2933  * G_GNUC_FUNCTION:
2934  *
2935  * Expands to "" on all modern compilers, and to
2936  * <literal>__FUNCTION__</literal> on <command>gcc</command> version 2.x.
2937  * Don't use it.
2938  *
2939  * Deprecated: 2.16: Use #G_STRFUNC instead
2940  */
2941
2942
2943 /**
2944  * G_GNUC_INTERNAL:
2945  *
2946  * This attribute can be used for marking library functions as being used
2947  * internally to the library only, which may allow the compiler to handle
2948  * function calls more efficiently. Note that static functions do not need
2949  * to be marked as internal in this way. See the GNU C documentation for
2950  * details.
2951  *
2952  * When using a compiler that supports the GNU C hidden visibility attribute,
2953  * this macro expands to <literal>__attribute__((visibility("hidden")))</literal>.
2954  * When using the Sun Studio compiler, it expands to <literal>__hidden</literal>.
2955  *
2956  * Note that for portability, the attribute should be placed before the
2957  * function declaration. While GCC allows the macro after the declaration,
2958  * Sun Studio does not.
2959  *
2960  * |[
2961  * G_GNUC_INTERNAL
2962  * void _g_log_fallback_handler (const gchar    *log_domain,
2963  *                               GLogLevelFlags  log_level,
2964  *                               const gchar    *message,
2965  *                               gpointer        unused_data);
2966  * ]|
2967  *
2968  * Since: 2.6
2969  */
2970
2971
2972 /**
2973  * G_GNUC_MALLOC:
2974  *
2975  * Expands to the GNU C <literal>malloc</literal> function attribute if the
2976  * compiler is <command>gcc</command>. Declaring a function as malloc enables
2977  * better optimization of the function. A function can have the malloc
2978  * attribute if it returns a pointer which is guaranteed to not alias with
2979  * any other pointer when the function returns (in practice, this means newly
2980  * allocated memory).
2981  *
2982  * Place the attribute after the declaration, just before the semicolon.
2983  *
2984  * See the GNU C documentation for more details.
2985  *
2986  * Since: 2.6
2987  */
2988
2989
2990 /**
2991  * G_GNUC_MAY_ALIAS:
2992  *
2993  * Expands to the GNU C <literal>may_alias</literal> type attribute
2994  * if the compiler is <command>gcc</command>. Types with this attribute
2995  * will not be subjected to type-based alias analysis, but are assumed
2996  * to alias with any other type, just like char.
2997  * See the GNU C documentation for details.
2998  *
2999  * Since: 2.14
3000  */
3001
3002
3003 /**
3004  * G_GNUC_NORETURN:
3005  *
3006  * Expands to the GNU C <literal>noreturn</literal> function attribute
3007  * if the compiler is <command>gcc</command>. It is used for declaring
3008  * functions which never return. It enables optimization of the function,
3009  * and avoids possible compiler warnings.
3010  *
3011  * Place the attribute after the declaration, just before the semicolon.
3012  *
3013  * See the GNU C documentation for more details.
3014  */
3015
3016
3017 /**
3018  * G_GNUC_NO_INSTRUMENT:
3019  *
3020  * Expands to the GNU C <literal>no_instrument_function</literal> function
3021  * attribute if the compiler is <command>gcc</command>. Functions with this
3022  * attribute will not be instrumented for profiling, when the compiler is
3023  * called with the <option>-finstrument-functions</option> option.
3024  *
3025  * Place the attribute after the declaration, just before the semicolon.
3026  *
3027  * See the GNU C documentation for more details.
3028  */
3029
3030
3031 /**
3032  * G_GNUC_NULL_TERMINATED:
3033  *
3034  * Expands to the GNU C <literal>sentinel</literal> function attribute
3035  * if the compiler is <command>gcc</command>, or "" if it isn't. This
3036  * function attribute only applies to variadic functions and instructs
3037  * the compiler to check that the argument list is terminated with an
3038  * explicit %NULL.
3039  *
3040  * Place the attribute after the declaration, just before the semicolon.
3041  *
3042  * See the GNU C documentation for more details.
3043  *
3044  * Since: 2.8
3045  */
3046
3047
3048 /**
3049  * G_GNUC_PRETTY_FUNCTION:
3050  *
3051  * Expands to "" on all modern compilers, and to
3052  * <literal>__PRETTY_FUNCTION__</literal> on <command>gcc</command>
3053  * version 2.x. Don't use it.
3054  *
3055  * Deprecated: 2.16: Use #G_STRFUNC instead
3056  */
3057
3058
3059 /**
3060  * G_GNUC_PRINTF:
3061  * @format_idx: the index of the argument corresponding to the format string (The arguments are numbered from 1)
3062  * @arg_idx: the index of the first of the format arguments
3063  *
3064  * Expands to the GNU C <literal>format</literal> function attribute
3065  * if the compiler is <command>gcc</command>. This is used for declaring
3066  * functions which take a variable number of arguments, with the same
3067  * syntax as printf(). It allows the compiler to type-check the arguments
3068  * passed to the function.
3069  *
3070  * Place the attribute after the function declaration, just before the
3071  * semicolon.
3072  *
3073  * See the GNU C documentation for more details.
3074  *
3075  * |[
3076  * gint g_snprintf (gchar  *string,
3077  *                  gulong       n,
3078  *                  gchar const *format,
3079  *                  ...) G_GNUC_PRINTF (3, 4);
3080  * ]|
3081  */
3082
3083
3084 /**
3085  * G_GNUC_PURE:
3086  *
3087  * Expands to the GNU C <literal>pure</literal> function attribute if the
3088  * compiler is <command>gcc</command>. Declaring a function as pure enables
3089  * better optimization of calls to the function. A pure function has no
3090  * effects except its return value and the return value depends only on
3091  * the parameters and/or global variables.
3092  *
3093  * Place the attribute after the declaration, just before the semicolon.
3094  *
3095  * See the GNU C documentation for more details.
3096  */
3097
3098
3099 /**
3100  * G_GNUC_SCANF:
3101  * @format_idx: the index of the argument corresponding to the format string (The arguments are numbered from 1)
3102  * @arg_idx: the index of the first of the format arguments
3103  *
3104  * Expands to the GNU C <literal>format</literal> function attribute
3105  * if the compiler is <command>gcc</command>. This is used for declaring
3106  * functions which take a variable number of arguments, with the same
3107  * syntax as scanf(). It allows the compiler to type-check the arguments
3108  * passed to the function. See the GNU C documentation for details.
3109  */
3110
3111
3112 /**
3113  * G_GNUC_UNUSED:
3114  *
3115  * Expands to the GNU C <literal>unused</literal> function attribute if
3116  * the compiler is <command>gcc</command>. It is used for declaring
3117  * functions and arguments which may never be used. It avoids possible compiler
3118  * warnings.
3119  *
3120  * For functions, place the attribute after the declaration, just before the
3121  * semicolon. For arguments, place the attribute at the beginning of the
3122  * argument declaration.
3123  *
3124  * |[
3125  * void my_unused_function (G_GNUC_UNUSED gint unused_argument,
3126  *                          gint other_argument) G_GNUC_UNUSED;
3127  * ]|
3128  *
3129  * See the GNU C documentation for more details.
3130  */
3131
3132
3133 /**
3134  * G_GNUC_WARN_UNUSED_RESULT:
3135  *
3136  * Expands to the GNU C <literal>warn_unused_result</literal> function
3137  * attribute if the compiler is <command>gcc</command>, or "" if it isn't.
3138  * This function attribute makes the compiler emit a warning if the result
3139  * of a function call is ignored.
3140  *
3141  * Place the attribute after the declaration, just before the semicolon.
3142  *
3143  * See the GNU C documentation for more details.
3144  *
3145  * Since: 2.10
3146  */
3147
3148
3149 /**
3150  * G_GOFFSET_CONSTANT:
3151  * @val: a literal integer value, e.g. 0x1d636b02300a7aa7
3152  *
3153  * This macro is used to insert #goffset 64-bit integer literals
3154  * into the source code.
3155  *
3156  * See also #G_GINT64_CONSTANT.
3157  *
3158  * Since: 2.20
3159  */
3160
3161
3162 /**
3163  * G_GOFFSET_FORMAT:
3164  *
3165  * This is the platform dependent conversion specifier for scanning
3166  * and printing values of type #goffset. See also #G_GINT64_FORMAT.
3167  *
3168  * Since: 2.20
3169  */
3170
3171
3172 /**
3173  * G_GOFFSET_MODIFIER:
3174  *
3175  * The platform dependent length modifier for conversion specifiers
3176  * for scanning and printing values of type #goffset. It is a string
3177  * literal. See also #G_GINT64_MODIFIER.
3178  *
3179  * Since: 2.20
3180  */
3181
3182
3183 /**
3184  * G_GSIZE_FORMAT:
3185  *
3186  * This is the platform dependent conversion specifier for scanning
3187  * and printing values of type #gsize. See also #G_GINT16_FORMAT.
3188  *
3189  * Since: 2.6
3190  */
3191
3192
3193 /**
3194  * G_GSIZE_MODIFIER:
3195  *
3196  * The platform dependent length modifier for conversion specifiers
3197  * for scanning and printing values of type #gsize or #gssize. It
3198  * is a string literal.
3199  *
3200  * Since: 2.6
3201  */
3202
3203
3204 /**
3205  * G_GSSIZE_FORMAT:
3206  *
3207  * This is the platform dependent conversion specifier for scanning
3208  * and printing values of type #gssize. See also #G_GINT16_FORMAT.
3209  *
3210  * Since: 2.6
3211  */
3212
3213
3214 /**
3215  * G_GUINT16_FORMAT:
3216  *
3217  * This is the platform dependent conversion specifier for scanning
3218  * and printing values of type #guint16. See also #G_GINT16_FORMAT
3219  */
3220
3221
3222 /**
3223  * G_GUINT32_FORMAT:
3224  *
3225  * This is the platform dependent conversion specifier for scanning
3226  * and printing values of type #guint32. See also #G_GINT16_FORMAT.
3227  */
3228
3229
3230 /**
3231  * G_GUINT64_CONSTANT:
3232  * @val: a literal integer value, e.g. 0x1d636b02300a7aa7U
3233  *
3234  * This macro is used to insert 64-bit unsigned integer
3235  * literals into the source code.
3236  *
3237  * Since: 2.10
3238  */
3239
3240
3241 /**
3242  * G_GUINT64_FORMAT:
3243  *
3244  * This is the platform dependent conversion specifier for scanning
3245  * and printing values of type #guint64. See also #G_GINT16_FORMAT.
3246  *
3247  * <note><para>
3248  * Some platforms do not support scanning and printing 64 bit integers,
3249  * even though the types are supported. On such platforms #G_GUINT64_FORMAT
3250  * is not defined.  Note that scanf() may not support 64 bit integers, even
3251  * if #G_GINT64_FORMAT is defined. Due to its weak error handling, scanf()
3252  * is not recommended for parsing anyway; consider using g_ascii_strtoull()
3253  * instead.
3254  * </para></note>
3255  */
3256
3257
3258 /**
3259  * G_GUINTPTR_FORMAT:
3260  *
3261  * This is the platform dependent conversion specifier
3262  * for scanning and printing values of type #guintptr.
3263  *
3264  * Since: 2.22
3265  */
3266
3267
3268 /**
3269  * G_HOOK:
3270  * @hook: a pointer
3271  *
3272  * Casts a pointer to a <literal>GHook*</literal>.
3273  */
3274
3275
3276 /**
3277  * G_HOOK_ACTIVE:
3278  * @hook: a #GHook
3279  *
3280  * Returns %TRUE if the #GHook is active, which is normally the case
3281  * until the #GHook is destroyed.
3282  *
3283  * Returns: %TRUE if the #GHook is active
3284  */
3285
3286
3287 /**
3288  * G_HOOK_FLAGS:
3289  * @hook: a #GHook
3290  *
3291  * Gets the flags of a hook.
3292  */
3293
3294
3295 /**
3296  * G_HOOK_FLAG_USER_SHIFT:
3297  *
3298  * The position of the first bit which is not reserved for internal
3299  * use be the #GHook implementation, i.e.
3300  * <literal>1 &lt;&lt; G_HOOK_FLAG_USER_SHIFT</literal> is the first
3301  * bit which can be used for application-defined flags.
3302  */
3303
3304
3305 /**
3306  * G_HOOK_IN_CALL:
3307  * @hook: a #GHook
3308  *
3309  * Returns %TRUE if the #GHook function is currently executing.
3310  *
3311  * Returns: %TRUE if the #GHook function is currently executing
3312  */
3313
3314
3315 /**
3316  * G_HOOK_IS_UNLINKED:
3317  * @hook: a #GHook
3318  *
3319  * Returns %TRUE if the #GHook is not in a #GHookList.
3320  *
3321  * Returns: %TRUE if the #GHook is not in a #GHookList
3322  */
3323
3324
3325 /**
3326  * G_HOOK_IS_VALID:
3327  * @hook: a #GHook
3328  *
3329  * Returns %TRUE if the #GHook is valid, i.e. it is in a #GHookList,
3330  * it is active and it has not been destroyed.
3331  *
3332  * Returns: %TRUE if the #GHook is valid
3333  */
3334
3335
3336 /**
3337  * G_IEEE754_DOUBLE_BIAS:
3338  *
3339  * The bias by which exponents in double-precision floats are offset.
3340  */
3341
3342
3343 /**
3344  * G_IEEE754_FLOAT_BIAS:
3345  *
3346  * The bias by which exponents in single-precision floats are offset.
3347  */
3348
3349
3350 /**
3351  * G_INLINE_FUNC:
3352  *
3353  * This macro is used to export function prototypes so they can be linked
3354  * with an external version when no inlining is performed. The file which
3355  * implements the functions should define <literal>G_IMPLEMENTS_INLINES</literal>
3356  * before including the headers which contain %G_INLINE_FUNC declarations.
3357  * Since inlining is very compiler-dependent using these macros correctly
3358  * is very difficult. Their use is strongly discouraged.
3359  *
3360  * This macro is often mistaken for a replacement for the inline keyword;
3361  * inline is already declared in a portable manner in the GLib headers
3362  * and can be used normally.
3363  */
3364
3365
3366 /**
3367  * G_IO_CHANNEL_ERROR:
3368  *
3369  * Error domain for #GIOChannel operations. Errors in this domain will
3370  * be from the #GIOChannelError enumeration. See #GError for
3371  * information on error domains.
3372  */
3373
3374
3375 /**
3376  * G_IO_FLAG_IS_WRITEABLE:
3377  *
3378  * This is a misspelled version of G_IO_FLAG_IS_WRITABLE that existed
3379  * before the spelling was fixed in GLib 2.30.  It is kept here for
3380  * compatibility reasons.
3381  *
3382  * Deprecated: 2.30:Use G_IO_FLAG_IS_WRITABLE instead.
3383  */
3384
3385
3386 /**
3387  * G_IS_DIR_SEPARATOR:
3388  * @c: a character
3389  *
3390  * Checks whether a character is a directory
3391  * separator. It returns %TRUE for '/' on UNIX
3392  * machines and for '\' or '/' under Windows.
3393  *
3394  * Since: 2.6
3395  */
3396
3397
3398 /**
3399  * G_KEY_FILE_DESKTOP_GROUP:
3400  *
3401  * The name of the main group of a desktop entry file, as defined in the
3402  * <ulink url="http://freedesktop.org/Standards/desktop-entry-spec">Desktop
3403  * Entry Specification</ulink>. Consult the specification for more
3404  * details about the meanings of the keys below.
3405  *
3406  * Since: 2.14
3407  */
3408
3409
3410 /**
3411  * G_KEY_FILE_DESKTOP_KEY_CATEGORIES:
3412  *
3413  * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a list
3414  * of strings giving the categories in which the desktop entry
3415  * should be shown in a menu.
3416  *
3417  * Since: 2.14
3418  */
3419
3420
3421 /**
3422  * G_KEY_FILE_DESKTOP_KEY_COMMENT:
3423  *
3424  * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a localized
3425  * string giving the tooltip for the desktop entry.
3426  *
3427  * Since: 2.14
3428  */
3429
3430
3431 /**
3432  * G_KEY_FILE_DESKTOP_KEY_EXEC:
3433  *
3434  * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a string
3435  * giving the command line to execute. It is only valid for desktop
3436  * entries with the <literal>Application</literal> type.
3437  *
3438  * Since: 2.14
3439  */
3440
3441
3442 /**
3443  * G_KEY_FILE_DESKTOP_KEY_GENERIC_NAME:
3444  *
3445  * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a localized
3446  * string giving the generic name of the desktop entry.
3447  *
3448  * Since: 2.14
3449  */
3450
3451
3452 /**
3453  * G_KEY_FILE_DESKTOP_KEY_HIDDEN:
3454  *
3455  * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a boolean
3456  * stating whether the desktop entry has been deleted by the user.
3457  *
3458  * Since: 2.14
3459  */
3460
3461
3462 /**
3463  * G_KEY_FILE_DESKTOP_KEY_ICON:
3464  *
3465  * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a localized
3466  * string giving the name of the icon to be displayed for the desktop
3467  * entry.
3468  *
3469  * Since: 2.14
3470  */
3471
3472
3473 /**
3474  * G_KEY_FILE_DESKTOP_KEY_MIME_TYPE:
3475  *
3476  * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a list
3477  * of strings giving the MIME types supported by this desktop entry.
3478  *
3479  * Since: 2.14
3480  */
3481
3482
3483 /**
3484  * G_KEY_FILE_DESKTOP_KEY_NAME:
3485  *
3486  * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a localized
3487  * string giving the specific name of the desktop entry.
3488  *
3489  * Since: 2.14
3490  */
3491
3492
3493 /**
3494  * G_KEY_FILE_DESKTOP_KEY_NOT_SHOW_IN:
3495  *
3496  * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a list of
3497  * strings identifying the environments that should not display the
3498  * desktop entry.
3499  *
3500  * Since: 2.14
3501  */
3502
3503
3504 /**
3505  * G_KEY_FILE_DESKTOP_KEY_NO_DISPLAY:
3506  *
3507  * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a boolean
3508  * stating whether the desktop entry should be shown in menus.
3509  *
3510  * Since: 2.14
3511  */
3512
3513
3514 /**
3515  * G_KEY_FILE_DESKTOP_KEY_ONLY_SHOW_IN:
3516  *
3517  * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a list of
3518  * strings identifying the environments that should display the
3519  * desktop entry.
3520  *
3521  * Since: 2.14
3522  */
3523
3524
3525 /**
3526  * G_KEY_FILE_DESKTOP_KEY_PATH:
3527  *
3528  * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a string
3529  * containing the working directory to run the program in. It is only
3530  * valid for desktop entries with the <literal>Application</literal> type.
3531  *
3532  * Since: 2.14
3533  */
3534
3535
3536 /**
3537  * G_KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY:
3538  *
3539  * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a boolean
3540  * stating whether the application supports the <ulink
3541  * url="http://www.freedesktop.org/Standards/startup-notification-spec">Startup
3542  * Notification Protocol Specification</ulink>.
3543  *
3544  * Since: 2.14
3545  */
3546
3547
3548 /**
3549  * G_KEY_FILE_DESKTOP_KEY_STARTUP_WM_CLASS:
3550  *
3551  * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is string
3552  * identifying the WM class or name hint of a window that the application
3553  * will create, which can be used to emulate Startup Notification with
3554  * older applications.
3555  *
3556  * Since: 2.14
3557  */
3558
3559
3560 /**
3561  * G_KEY_FILE_DESKTOP_KEY_TERMINAL:
3562  *
3563  * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a boolean
3564  * stating whether the program should be run in a terminal window.
3565  * It is only valid for desktop entries with the
3566  * <literal>Application</literal> type.
3567  *
3568  * Since: 2.14
3569  */
3570
3571
3572 /**
3573  * G_KEY_FILE_DESKTOP_KEY_TRY_EXEC:
3574  *
3575  * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a string
3576  * giving the file name of a binary on disk used to determine if the
3577  * program is actually installed. It is only valid for desktop entries
3578  * with the <literal>Application</literal> type.
3579  *
3580  * Since: 2.14
3581  */
3582
3583
3584 /**
3585  * G_KEY_FILE_DESKTOP_KEY_TYPE:
3586  *
3587  * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a string
3588  * giving the type of the desktop entry. Usually
3589  * #G_KEY_FILE_DESKTOP_TYPE_APPLICATION,
3590  * #G_KEY_FILE_DESKTOP_TYPE_LINK, or
3591  * #G_KEY_FILE_DESKTOP_TYPE_DIRECTORY.
3592  *
3593  * Since: 2.14
3594  */
3595
3596
3597 /**
3598  * G_KEY_FILE_DESKTOP_KEY_URL:
3599  *
3600  * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a string
3601  * giving the URL to access. It is only valid for desktop entries
3602  * with the <literal>Link</literal> type.
3603  *
3604  * Since: 2.14
3605  */
3606
3607
3608 /**
3609  * G_KEY_FILE_DESKTOP_KEY_VERSION:
3610  *
3611  * A key under #G_KEY_FILE_DESKTOP_GROUP, whose value is a string
3612  * giving the version of the Desktop Entry Specification used for
3613  * the desktop entry file.
3614  *
3615  * Since: 2.14
3616  */
3617
3618
3619 /**
3620  * G_KEY_FILE_DESKTOP_TYPE_APPLICATION:
3621  *
3622  * The value of the #G_KEY_FILE_DESKTOP_KEY_TYPE, key for desktop
3623  * entries representing applications.
3624  *
3625  * Since: 2.14
3626  */
3627
3628
3629 /**
3630  * G_KEY_FILE_DESKTOP_TYPE_DIRECTORY:
3631  *
3632  * The value of the #G_KEY_FILE_DESKTOP_KEY_TYPE, key for desktop
3633  * entries representing directories.
3634  *
3635  * Since: 2.14
3636  */
3637
3638
3639 /**
3640  * G_KEY_FILE_DESKTOP_TYPE_LINK:
3641  *
3642  * The value of the #G_KEY_FILE_DESKTOP_KEY_TYPE, key for desktop
3643  * entries representing links to documents.
3644  *
3645  * Since: 2.14
3646  */
3647
3648
3649 /**
3650  * G_KEY_FILE_ERROR:
3651  *
3652  * Error domain for key file parsing. Errors in this domain will
3653  * be from the #GKeyFileError enumeration.
3654  *
3655  * See #GError for information on error domains.
3656  */
3657
3658
3659 /**
3660  * G_LIKELY:
3661  * @expr: the expression
3662  *
3663  * Hints the compiler that the expression is likely to evaluate to
3664  * a true value. The compiler may use this information for optimizations.
3665  *
3666  * |[
3667  * if (G_LIKELY (random () != 1))
3668  *   g_print ("not one");
3669  * ]|
3670  *
3671  * Returns: the value of @expr
3672  * Since: 2.2
3673  */
3674
3675
3676 /**
3677  * G_LITTLE_ENDIAN:
3678  *
3679  * Specifies one of the possible types of byte order.
3680  * See #G_BYTE_ORDER.
3681  */
3682
3683
3684 /**
3685  * G_LN10:
3686  *
3687  * The natural logarithm of 10.
3688  */
3689
3690
3691 /**
3692  * G_LN2:
3693  *
3694  * The natural logarithm of 2.
3695  */
3696
3697
3698 /**
3699  * G_LOCK:
3700  * @name: the name of the lock
3701  *
3702  * Works like g_mutex_lock(), but for a lock defined with
3703  * #G_LOCK_DEFINE.
3704  */
3705
3706
3707 /**
3708  * G_LOCK_DEFINE:
3709  * @name: the name of the lock
3710  *
3711  * The <literal>G_LOCK_*</literal> macros provide a convenient interface to #GMutex.
3712  * #G_LOCK_DEFINE defines a lock. It can appear in any place where
3713  * variable definitions may appear in programs, i.e. in the first block
3714  * of a function or outside of functions. The @name parameter will be
3715  * mangled to get the name of the #GMutex. This means that you
3716  * can use names of existing variables as the parameter - e.g. the name
3717  * of the variable you intend to protect with the lock. Look at our
3718  * <function>give_me_next_number()</function> example using the
3719  * <literal>G_LOCK_*</literal> macros:
3720  *
3721  * <example>
3722  *  <title>Using the <literal>G_LOCK_*</literal> convenience macros</title>
3723  *  <programlisting>
3724  *   G_LOCK_DEFINE (current_number);
3725  *
3726  *   int
3727  *   give_me_next_number (void)
3728  *   {
3729  *     static int current_number = 0;
3730  *     int ret_val;
3731  *
3732  *     G_LOCK (current_number);
3733  *     ret_val = current_number = calc_next_number (current_number);
3734  *     G_UNLOCK (current_number);
3735  *
3736  *     return ret_val;
3737  *   }
3738  *  </programlisting>
3739  * </example>
3740  */
3741
3742
3743 /**
3744  * G_LOCK_DEFINE_STATIC:
3745  * @name: the name of the lock
3746  *
3747  * This works like #G_LOCK_DEFINE, but it creates a static object.
3748  */
3749
3750
3751 /**
3752  * G_LOCK_EXTERN:
3753  * @name: the name of the lock
3754  *
3755  * This declares a lock, that is defined with #G_LOCK_DEFINE in another
3756  * module.
3757  */
3758
3759
3760 /**
3761  * G_LOG_2_BASE_10:
3762  *
3763  * Multiplying the base 2 exponent by this number yields the base 10 exponent.
3764  */
3765
3766
3767 /**
3768  * G_LOG_DOMAIN:
3769  *
3770  * Defines the log domain.
3771  *
3772  * For applications, this is typically left as the default %NULL
3773  * (or "") domain. Libraries should define this so that any messages
3774  * which they log can be differentiated from messages from other
3775  * libraries and application code. But be careful not to define
3776  * it in any public header files.
3777  *
3778  * For example, GTK+ uses this in its Makefile.am:
3779  * |[
3780  * INCLUDES = -DG_LOG_DOMAIN=\"Gtk\"
3781  * ]|
3782  */
3783
3784
3785 /**
3786  * G_LOG_FATAL_MASK:
3787  *
3788  * GLib log levels that are considered fatal by default.
3789  */
3790
3791
3792 /**
3793  * G_MAXDOUBLE:
3794  *
3795  * The maximum value which can be held in a #gdouble.
3796  */
3797
3798
3799 /**
3800  * G_MAXFLOAT:
3801  *
3802  * The maximum value which can be held in a #gfloat.
3803  */
3804
3805
3806 /**
3807  * G_MAXINT:
3808  *
3809  * The maximum value which can be held in a #gint.
3810  */
3811
3812
3813 /**
3814  * G_MAXINT16:
3815  *
3816  * The maximum value which can be held in a #gint16.
3817  *
3818  * Since: 2.4
3819  */
3820
3821
3822 /**
3823  * G_MAXINT32:
3824  *
3825  * The maximum value which can be held in a #gint32.
3826  *
3827  * Since: 2.4
3828  */
3829
3830
3831 /**
3832  * G_MAXINT64:
3833  *
3834  * The maximum value which can be held in a #gint64.
3835  */
3836
3837
3838 /**
3839  * G_MAXINT8:
3840  *
3841  * The maximum value which can be held in a #gint8.
3842  *
3843  * Since: 2.4
3844  */
3845
3846
3847 /**
3848  * G_MAXLONG:
3849  *
3850  * The maximum value which can be held in a #glong.
3851  */
3852
3853
3854 /**
3855  * G_MAXOFFSET:
3856  *
3857  * The maximum value which can be held in a #goffset.
3858  */
3859
3860
3861 /**
3862  * G_MAXSHORT:
3863  *
3864  * The maximum value which can be held in a #gshort.
3865  */
3866
3867
3868 /**
3869  * G_MAXSIZE:
3870  *
3871  * The maximum value which can be held in a #gsize.
3872  *
3873  * Since: 2.4
3874  */
3875
3876
3877 /**
3878  * G_MAXSSIZE:
3879  *
3880  * The maximum value which can be held in a #gssize.
3881  *
3882  * Since: 2.14
3883  */
3884
3885
3886 /**
3887  * G_MAXUINT:
3888  *
3889  * The maximum value which can be held in a #guint.
3890  */
3891
3892
3893 /**
3894  * G_MAXUINT16:
3895  *
3896  * The maximum value which can be held in a #guint16.
3897  *
3898  * Since: 2.4
3899  */
3900
3901
3902 /**
3903  * G_MAXUINT32:
3904  *
3905  * The maximum value which can be held in a #guint32.
3906  *
3907  * Since: 2.4
3908  */
3909
3910
3911 /**
3912  * G_MAXUINT64:
3913  *
3914  * The maximum value which can be held in a #guint64.
3915  */
3916
3917
3918 /**
3919  * G_MAXUINT8:
3920  *
3921  * The maximum value which can be held in a #guint8.
3922  *
3923  * Since: 2.4
3924  */
3925
3926
3927 /**
3928  * G_MAXULONG:
3929  *
3930  * The maximum value which can be held in a #gulong.
3931  */
3932
3933
3934 /**
3935  * G_MAXUSHORT:
3936  *
3937  * The maximum value which can be held in a #gushort.
3938  */
3939
3940
3941 /**
3942  * G_MINDOUBLE:
3943  *
3944  * The minimum positive value which can be held in a #gdouble.
3945  *
3946  * If you are interested in the smallest value which can be held
3947  * in a #gdouble, use -G_MAXDOUBLE.
3948  */
3949
3950
3951 /**
3952  * G_MINFLOAT:
3953  *
3954  * The minimum positive value which can be held in a #gfloat.
3955  *
3956  * If you are interested in the smallest value which can be held
3957  * in a #gfloat, use -G_MAXFLOAT.
3958  */
3959
3960
3961 /**
3962  * G_MININT:
3963  *
3964  * The minimum value which can be held in a #gint.
3965  */
3966
3967
3968 /**
3969  * G_MININT16:
3970  *
3971  * The minimum value which can be held in a #gint16.
3972  *
3973  * Since: 2.4
3974  */
3975
3976
3977 /**
3978  * G_MININT32:
3979  *
3980  * The minimum value which can be held in a #gint32.
3981  *
3982  * Since: 2.4
3983  */
3984
3985
3986 /**
3987  * G_MININT64:
3988  *
3989  * The minimum value which can be held in a #gint64.
3990  */
3991
3992
3993 /**
3994  * G_MININT8:
3995  *
3996  * The minimum value which can be held in a #gint8.
3997  *
3998  * Since: 2.4
3999  */
4000
4001
4002 /**
4003  * G_MINLONG:
4004  *
4005  * The minimum value which can be held in a #glong.
4006  */
4007
4008
4009 /**
4010  * G_MINOFFSET:
4011  *
4012  * The minimum value which can be held in a #goffset.
4013  */
4014
4015
4016 /**
4017  * G_MINSHORT:
4018  *
4019  * The minimum value which can be held in a #gshort.
4020  */
4021
4022
4023 /**
4024  * G_MINSSIZE:
4025  *
4026  * The minimum value which can be held in a #gssize.
4027  *
4028  * Since: 2.14
4029  */
4030
4031
4032 /**
4033  * G_N_ELEMENTS:
4034  * @arr: the array
4035  *
4036  * Determines the number of elements in an array. The array must be
4037  * declared so the compiler knows its size at compile-time; this
4038  * macro will not work on an array allocated on the heap, only static
4039  * arrays or arrays on the stack.
4040  */
4041
4042
4043 /**
4044  * G_ONCE_INIT:
4045  *
4046  * A #GOnce must be initialized with this macro before it can be used.
4047  *
4048  * |[
4049  *   GOnce my_once = G_ONCE_INIT;
4050  * ]|
4051  *
4052  * Since: 2.4
4053  */
4054
4055
4056 /**
4057  * G_OS_BEOS:
4058  *
4059  * This macro is defined only on BeOS. So you can bracket
4060  * BeOS-specific code in "&num;ifdef G_OS_BEOS".
4061  */
4062
4063
4064 /**
4065  * G_OS_UNIX:
4066  *
4067  * This macro is defined only on UNIX. So you can bracket
4068  * UNIX-specific code in "&num;ifdef G_OS_UNIX".
4069  */
4070
4071
4072 /**
4073  * G_OS_WIN32:
4074  *
4075  * This macro is defined only on Windows. So you can bracket
4076  * Windows-specific code in "&num;ifdef G_OS_WIN32".
4077  */
4078
4079
4080 /**
4081  * G_PASTE:
4082  * @identifier1: an identifier
4083  * @identifier2: an identifier
4084  *
4085  * Yields a new preprocessor pasted identifier
4086  * <code>identifier1identifier2</code> from its expanded
4087  * arguments @identifier1 and @identifier2. For example,
4088  * the following code:
4089  * |[
4090  * #define GET(traveller,method) G_PASTE(traveller_get_, method) (traveller)
4091  * const gchar *name = GET (traveller, name);
4092  * const gchar *quest = GET (traveller, quest);
4093  * GdkColor *favourite = GET (traveller, favourite_colour);
4094  * ]|
4095  *
4096  * is transformed by the preprocessor into:
4097  * |[
4098  * const gchar *name = traveller_get_name (traveller);
4099  * const gchar *quest = traveller_get_quest (traveller);
4100  * GdkColor *favourite = traveller_get_favourite_colour (traveller);
4101  * ]|
4102  *
4103  * Since: 2.20
4104  */
4105
4106
4107 /**
4108  * G_PDP_ENDIAN:
4109  *
4110  * Specifies one of the possible types of byte order
4111  * (currently unused). See #G_BYTE_ORDER.
4112  */
4113
4114
4115 /**
4116  * G_PI:
4117  *
4118  * The value of pi (ratio of circle's circumference to its diameter).
4119  */
4120
4121
4122 /**
4123  * G_PI_2:
4124  *
4125  * Pi divided by 2.
4126  */
4127
4128
4129 /**
4130  * G_PI_4:
4131  *
4132  * Pi divided by 4.
4133  */
4134
4135
4136 /**
4137  * G_PRIVATE_INIT:
4138  * @notify: a #GDestroyNotify
4139  *
4140  * A macro to assist with the static initialisation of a #GPrivate.
4141  *
4142  * This macro is useful for the case that a #GDestroyNotify function
4143  * should be associated the key.  This is needed when the key will be
4144  * used to point at memory that should be deallocated when the thread
4145  * exits.
4146  *
4147  * Additionally, the #GDestroyNotify will also be called on the previous
4148  * value stored in the key when g_private_replace() is used.
4149  *
4150  * If no #GDestroyNotify is needed, then use of this macro is not
4151  * required -- if the #GPrivate is declared in static scope then it will
4152  * be properly initialised by default (ie: to all zeros).  See the
4153  * examples below.
4154  *
4155  * |[
4156  * static GPrivate name_key = G_PRIVATE_INIT (g_free);
4157  *
4158  * // return value should not be freed
4159  * const gchar *
4160  * get_local_name (void)
4161  * {
4162  *   return g_private_get (&name_key);
4163  * }
4164  *
4165  * void
4166  * set_local_name (const gchar *name)
4167  * {
4168  *   g_private_replace (&name_key, g_strdup (name));
4169  * }
4170  *
4171  *
4172  * static GPrivate count_key;   // no free function
4173  *
4174  * gint
4175  * get_local_count (void)
4176  * {
4177  *   return GPOINTER_TO_INT (g_private_get (&count_key));
4178  * }
4179  *
4180  * void
4181  * set_local_count (gint count)
4182  * {
4183  *   g_private_set (&count_key, GINT_TO_POINTER (count));
4184  * }
4185  * ]|
4186  *
4187  * Since: 2.32
4188  */
4189
4190
4191 /**
4192  * G_SEARCHPATH_SEPARATOR:
4193  *
4194  * The search path separator character.
4195  * This is ':' on UNIX machines and ';' under Windows.
4196  */
4197
4198
4199 /**
4200  * G_SEARCHPATH_SEPARATOR_S:
4201  *
4202  * The search path separator as a string.
4203  * This is ":" on UNIX machines and ";" under Windows.
4204  */
4205
4206
4207 /**
4208  * G_SHELL_ERROR:
4209  *
4210  * Error domain for shell functions. Errors in this domain will be from
4211  * the #GShellError enumeration. See #GError for information on error
4212  * domains.
4213  */
4214
4215
4216 /**
4217  * G_SQRT2:
4218  *
4219  * The square root of two.
4220  */
4221
4222
4223 /**
4224  * G_STATIC_ASSERT:
4225  * @expr: a constant expression
4226  *
4227  * The G_STATIC_ASSERT macro lets the programmer check
4228  * a condition at compile time, the condition needs to
4229  * be compile time computable. The macro can be used in
4230  * any place where a <literal>typedef</literal> is valid.
4231  *
4232  * <note><para>
4233  * A <literal>typedef</literal> is generally allowed in
4234  * exactly the same places that a variable declaration is
4235  * allowed. For this reason, you should not use
4236  * <literal>G_STATIC_ASSERT</literal> in the middle of
4237  * blocks of code.
4238  * </para></note>
4239  *
4240  * The macro should only be used once per source code line.
4241  *
4242  * Since: 2.20
4243  */
4244
4245
4246 /**
4247  * G_STATIC_ASSERT_EXPR:
4248  * @expr: a constant expression
4249  *
4250  * The G_STATIC_ASSERT_EXPR macro lets the programmer check
4251  * a condition at compile time. The condition needs to be
4252  * compile time computable.
4253  *
4254  * Unlike <literal>G_STATIC_ASSERT</literal>, this macro
4255  * evaluates to an expression and, as such, can be used in
4256  * the middle of other expressions. Its value should be
4257  * ignored. This can be accomplished by placing it as
4258  * the first argument of a comma expression.
4259  *
4260  * |[
4261  * #define ADD_ONE_TO_INT(x) \
4262  *   (G_STATIC_ASSERT_EXPR(sizeof (x) == sizeof (int)), ((x) + 1))
4263  * ]|
4264  *
4265  * Since: 2.30
4266  */
4267
4268
4269 /**
4270  * G_STMT_END:
4271  *
4272  * Used within multi-statement macros so that they can be used in places
4273  * where only one statement is expected by the compiler.
4274  */
4275
4276
4277 /**
4278  * G_STMT_START:
4279  *
4280  * Used within multi-statement macros so that they can be used in places
4281  * where only one statement is expected by the compiler.
4282  */
4283
4284
4285 /**
4286  * G_STRFUNC:
4287  *
4288  * Expands to a string identifying the current function.
4289  *
4290  * Since: 2.4
4291  */
4292
4293
4294 /**
4295  * G_STRINGIFY:
4296  * @macro_or_string: a macro or a string
4297  *
4298  * Accepts a macro or a string and converts it into a string after
4299  * preprocessor argument expansion. For example, the following code:
4300  *
4301  * |[
4302  * #define AGE 27
4303  * const gchar *greeting = G_STRINGIFY (AGE) " today!";
4304  * ]|
4305  *
4306  * is transformed by the preprocessor into (code equivalent to):
4307  *
4308  * |[
4309  * const gchar *greeting = "27 today!";
4310  * ]|
4311  */
4312
4313
4314 /**
4315  * G_STRLOC:
4316  *
4317  * Expands to a string identifying the current code position.
4318  */
4319
4320
4321 /**
4322  * G_STRUCT_MEMBER:
4323  * @member_type: the type of the struct field
4324  * @struct_p: a pointer to a struct
4325  * @struct_offset: the offset of the field from the start of the struct, in bytes
4326  *
4327  * Returns a member of a structure at a given offset, using the given type.
4328  *
4329  * Returns: the struct member
4330  */
4331
4332
4333 /**
4334  * G_STRUCT_MEMBER_P:
4335  * @struct_p: a pointer to a struct
4336  * @struct_offset: the offset from the start of the struct, in bytes
4337  *
4338  * Returns an untyped pointer to a given offset of a struct.
4339  *
4340  * Returns: an untyped pointer to @struct_p plus @struct_offset bytes
4341  */
4342
4343
4344 /**
4345  * G_STRUCT_OFFSET:
4346  * @struct_type: a structure type, e.g. <structname>GtkWidget</structname>
4347  * @member: a field in the structure, e.g. <structfield>window</structfield>
4348  *
4349  * Returns the offset, in bytes, of a member of a struct.
4350  *
4351  * Returns: the offset of @member from the start of @struct_type
4352  */
4353
4354
4355 /**
4356  * G_STR_DELIMITERS:
4357  *
4358  * The standard delimiters, used in g_strdelimit().
4359  */
4360
4361
4362 /**
4363  * G_THREAD_ERROR:
4364  *
4365  * The error domain of the GLib thread subsystem.
4366  */
4367
4368
4369 /**
4370  * G_TRYLOCK:
4371  * @name: the name of the lock
4372  *
4373  * Works like g_mutex_trylock(), but for a lock defined with
4374  * #G_LOCK_DEFINE.
4375  *
4376  * Returns: %TRUE, if the lock could be locked.
4377  */
4378
4379
4380 /**
4381  * G_UNAVAILABLE:
4382  * @maj: the major version that introduced the symbol
4383  * @min: the minor version that introduced the symbol
4384  *
4385  * This macro can be used to mark a function declaration as unavailable.
4386  * It must be placed before the function declaration. Use of a function
4387  * that has been annotated with this macros will produce a compiler warning.
4388  *
4389  * Since: 2.32
4390  */
4391
4392
4393 /**
4394  * G_UNLIKELY:
4395  * @expr: the expression
4396  *
4397  * Hints the compiler that the expression is unlikely to evaluate to
4398  * a true value. The compiler may use this information for optimizations.
4399  *
4400  * |[
4401  * if (G_UNLIKELY (random () == 1))
4402  *   g_print ("a random one");
4403  * ]|
4404  *
4405  * Returns: the value of @expr
4406  * Since: 2.2
4407  */
4408
4409
4410 /**
4411  * G_UNLOCK:
4412  * @name: the name of the lock
4413  *
4414  * Works like g_mutex_unlock(), but for a lock defined with
4415  * #G_LOCK_DEFINE.
4416  */
4417
4418
4419 /**
4420  * G_USEC_PER_SEC:
4421  *
4422  * Number of microseconds in one second (1 million).
4423  * This macro is provided for code readability.
4424  */
4425
4426
4427 /**
4428  * G_VARIANT_PARSE_ERROR:
4429  *
4430  * Error domain for GVariant text format parsing.  Specific error codes
4431  * are not currently defined for this domain.  See #GError for
4432  * information on error domains.
4433  */
4434
4435
4436 /**
4437  * G_VA_COPY:
4438  * @ap1: the <type>va_list</type> variable to place a copy of @ap2 in
4439  * @ap2: a <type>va_list</type>
4440  *
4441  * Portable way to copy <type>va_list</type> variables.
4442  *
4443  * In order to use this function, you must include
4444  * <filename>string.h</filename> yourself, because this macro may
4445  * use memmove() and GLib does not include <filename>string.h</filename>
4446  * for you.
4447  */
4448
4449
4450 /**
4451  * G_WIN32_DLLMAIN_FOR_DLL_NAME:
4452  * @static: empty or "static"
4453  * @dll_name: the name of the (pointer to the) char array where the DLL name will be stored. If this is used, you must also include <filename>windows.h</filename>. If you need a more complex DLL entry point function, you cannot use this
4454  *
4455  * On Windows, this macro defines a DllMain() function that stores
4456  * the actual DLL name that the code being compiled will be included in.
4457  *
4458  * On non-Windows platforms, expands to nothing.
4459  */
4460
4461
4462 /**
4463  * G_WIN32_HAVE_WIDECHAR_API:
4464  *
4465  * On Windows, this macro defines an expression which evaluates to
4466  * %TRUE if the code is running on a version of Windows where the wide
4467  * character versions of the Win32 API functions, and the wide character
4468  * versions of the C library functions work. (They are always present in
4469  * the DLLs, but don't work on Windows 9x and Me.)
4470  *
4471  * On non-Windows platforms, it is not defined.
4472  *
4473  * Since: 2.6
4474  */
4475
4476
4477 /**
4478  * G_WIN32_IS_NT_BASED:
4479  *
4480  * On Windows, this macro defines an expression which evaluates to
4481  * %TRUE if the code is running on an NT-based Windows operating system.
4482  *
4483  * On non-Windows platforms, it is not defined.
4484  *
4485  * Since: 2.6
4486  */
4487
4488
4489 /**
4490  * MAX:
4491  * @a: a numeric value
4492  * @b: a numeric value
4493  *
4494  * Calculates the maximum of @a and @b.
4495  *
4496  * Returns: the maximum of @a and @b.
4497  */
4498
4499
4500 /**
4501  * MAXPATHLEN:
4502  *
4503  * Provided for UNIX emulation on Windows; equivalent to UNIX
4504  * macro %MAXPATHLEN, which is the maximum length of a filename
4505  * (including full path).
4506  */
4507
4508
4509 /**
4510  * MIN:
4511  * @a: a numeric value
4512  * @b: a numeric value
4513  *
4514  * Calculates the minimum of @a and @b.
4515  *
4516  * Returns: the minimum of @a and @b.
4517  */
4518
4519
4520 /**
4521  * NC_:
4522  * @Context: a message context, must be a string literal
4523  * @String: a message id, must be a string literal
4524  *
4525  * Only marks a string for translation, with context.
4526  * This is useful in situations where the translated strings can't
4527  * be directly used, e.g. in string array initializers. To get the
4528  * translated string, you should call g_dpgettext2() at runtime.
4529  *
4530  * |[
4531  * {
4532  *   static const char *messages[] = {
4533  *     NC_("some context", "some very meaningful message"),
4534  *     NC_("some context", "and another one")
4535  *   };
4536  *   const char *string;
4537  *   ...
4538  *   string
4539  *     = index &gt; 1 ? g_dpgettext2 (NULL, "some context", "a default message")
4540  *                    : g_dpgettext2 (NULL, "some context", messages[index]);
4541  *
4542  *   fputs (string);
4543  *   ...
4544  * }
4545  * ]|
4546  *
4547  * <note><para>If you are using the NC_() macro, you need to make sure
4548  * that you pass <option>--keyword=NC_:1c,2</option> to xgettext when
4549  * extracting messages. Note that this only works with GNU gettext >= 0.15.
4550  * Intltool has support for the NC_() macro since version 0.40.1.
4551  * </para></note>
4552  *
4553  * Since: 2.18
4554  */
4555
4556
4557 /**
4558  * NULL:
4559  *
4560  * Defines the standard %NULL pointer.
4561  */
4562
4563
4564 /**
4565  * N_:
4566  * @String: the string to be translated
4567  *
4568  * Only marks a string for translation. This is useful in situations
4569  * where the translated strings can't be directly used, e.g. in string
4570  * array initializers. To get the translated string, call gettext()
4571  * at runtime.
4572  * |[
4573  * {
4574  *   static const char *messages[] = {
4575  *     N_("some very meaningful message"),
4576  *     N_("and another one")
4577  *   };
4578  *   const char *string;
4579  *   ...
4580  *   string
4581  *     = index &gt; 1 ? _("a default message") : gettext (messages[index]);
4582  *
4583  *   fputs (string);
4584  *   ...
4585  * }
4586  * ]|
4587  *
4588  * Since: 2.4
4589  */
4590
4591
4592 /**
4593  * Q_:
4594  * @String: the string to be translated, with a '|'-separated prefix which must not be translated
4595  *
4596  * Like _(), but handles context in message ids. This has the advantage
4597  * that the string can be adorned with a prefix to guarantee uniqueness
4598  * and provide context to the translator.
4599  *
4600  * One use case given in the gettext manual is GUI translation, where one
4601  * could e.g. disambiguate two "Open" menu entries as "File|Open" and
4602  * "Printer|Open". Another use case is the string "Russian" which may
4603  * have to be translated differently depending on whether it's the name
4604  * of a character set or a language. This could be solved by using
4605  * "charset|Russian" and "language|Russian".
4606  *
4607  * See the C_() macro for a different way to mark up translatable strings
4608  * with context.
4609  *
4610  * <note><para>If you are using the Q_() macro, you need to make sure
4611  * that you pass <option>--keyword=Q_</option> to xgettext when extracting
4612  * messages. If you are using GNU gettext >= 0.15, you can also use
4613  * <option>--keyword=Q_:1g</option> to let xgettext split the context
4614  * string off into a msgctxt line in the po file.</para></note>
4615  *
4616  * Returns: the translated message
4617  * Since: 2.4
4618  */
4619
4620
4621 /**
4622  * SECTION:arrays
4623  * @title: Arrays
4624  * @short_description: arrays of arbitrary elements which grow automatically as elements are added
4625  *
4626  * Arrays are similar to standard C arrays, except that they grow
4627  * automatically as elements are added.
4628  *
4629  * Array elements can be of any size (though all elements of one array
4630  * are the same size), and the array can be automatically cleared to
4631  * '0's and zero-terminated.
4632  *
4633  * To create a new array use g_array_new().
4634  *
4635  * To add elements to an array, use g_array_append_val(),
4636  * g_array_append_vals(), g_array_prepend_val(), and
4637  * g_array_prepend_vals().
4638  *
4639  * To access an element of an array, use g_array_index().
4640  *
4641  * To set the size of an array, use g_array_set_size().
4642  *
4643  * To free an array, use g_array_free().
4644  *
4645  * <example>
4646  *  <title>Using a #GArray to store #gint values</title>
4647  *  <programlisting>
4648  *   GArray *garray;
4649  *   gint i;
4650  *   /<!-- -->* We create a new array to store gint values.
4651  *      We don't want it zero-terminated or cleared to 0's. *<!-- -->/
4652  *   garray = g_array_new (FALSE, FALSE, sizeof (gint));
4653  *   for (i = 0; i &lt; 10000; i++)
4654  *     g_array_append_val (garray, i);
4655  *   for (i = 0; i &lt; 10000; i++)
4656  *     if (g_array_index (garray, gint, i) != i)
4657  *       g_print ("ERROR: got &percnt;d instead of &percnt;d\n",
4658  *                g_array_index (garray, gint, i), i);
4659  *   g_array_free (garray, TRUE);
4660  *  </programlisting>
4661  * </example>
4662  */
4663
4664
4665 /**
4666  * SECTION:arrays_byte
4667  * @title: Byte Arrays
4668  * @short_description: arrays of bytes
4669  *
4670  * #GByteArray is a mutable array of bytes based on #GArray, to provide arrays
4671  * of bytes which grow automatically as elements are added.
4672  *
4673  * To create a new #GByteArray use g_byte_array_new(). To add elements to a
4674  * #GByteArray, use g_byte_array_append(), and g_byte_array_prepend().
4675  *
4676  * To set the size of a #GByteArray, use g_byte_array_set_size().
4677  *
4678  * To free a #GByteArray, use g_byte_array_free().
4679  *
4680  * <example>
4681  *  <title>Using a #GByteArray</title>
4682  *  <programlisting>
4683  *   GByteArray *gbarray;
4684  *   gint i;
4685  *
4686  *   gbarray = g_byte_array_new (<!-- -->);
4687  *   for (i = 0; i &lt; 10000; i++)
4688  *     g_byte_array_append (gbarray, (guint8*) "abcd", 4);
4689  *
4690  *   for (i = 0; i &lt; 10000; i++)
4691  *     {
4692  *       g_assert (gbarray->data[4*i] == 'a');
4693  *       g_assert (gbarray->data[4*i+1] == 'b');
4694  *       g_assert (gbarray->data[4*i+2] == 'c');
4695  *       g_assert (gbarray->data[4*i+3] == 'd');
4696  *     }
4697  *
4698  *   g_byte_array_free (gbarray, TRUE);
4699  *  </programlisting>
4700  * </example>
4701  *
4702  * See #GBytes if you are interested in an immutable object representing a
4703  * sequence of bytes.
4704  */
4705
4706
4707 /**
4708  * SECTION:arrays_pointer
4709  * @title: Pointer Arrays
4710  * @short_description: arrays of pointers to any type of data, which grow automatically as new elements are added
4711  *
4712  * Pointer Arrays are similar to Arrays but are used only for storing
4713  * pointers.
4714  *
4715  * <note><para>If you remove elements from the array, elements at the
4716  * end of the array are moved into the space previously occupied by the
4717  * removed element. This means that you should not rely on the index of
4718  * particular elements remaining the same. You should also be careful
4719  * when deleting elements while iterating over the array.</para></note>
4720  *
4721  * To create a pointer array, use g_ptr_array_new().
4722  *
4723  * To add elements to a pointer array, use g_ptr_array_add().
4724  *
4725  * To remove elements from a pointer array, use g_ptr_array_remove(),
4726  * g_ptr_array_remove_index() or g_ptr_array_remove_index_fast().
4727  *
4728  * To access an element of a pointer array, use g_ptr_array_index().
4729  *
4730  * To set the size of a pointer array, use g_ptr_array_set_size().
4731  *
4732  * To free a pointer array, use g_ptr_array_free().
4733  *
4734  * <example>
4735  *  <title>Using a #GPtrArray</title>
4736  *  <programlisting>
4737  *   GPtrArray *gparray;
4738  *   gchar *string1 = "one", *string2 = "two", *string3 = "three";
4739  *
4740  *   gparray = g_ptr_array_new (<!-- -->);
4741  *   g_ptr_array_add (gparray, (gpointer) string1);
4742  *   g_ptr_array_add (gparray, (gpointer) string2);
4743  *   g_ptr_array_add (gparray, (gpointer) string3);
4744  *
4745  *   if (g_ptr_array_index (gparray, 0) != (gpointer) string1)
4746  *     g_print ("ERROR: got &percnt;p instead of &percnt;p\n",
4747  *              g_ptr_array_index (gparray, 0), string1);
4748  *
4749  *   g_ptr_array_free (gparray, TRUE);
4750  *  </programlisting>
4751  * </example>
4752  */
4753
4754
4755 /**
4756  * SECTION:async_queues
4757  * @title: Asynchronous Queues
4758  * @short_description: asynchronous communication between threads
4759  * @see_also: #GThreadPool
4760  *
4761  * Often you need to communicate between different threads. In general
4762  * it's safer not to do this by shared memory, but by explicit message
4763  * passing. These messages only make sense asynchronously for
4764  * multi-threaded applications though, as a synchronous operation could
4765  * as well be done in the same thread.
4766  *
4767  * Asynchronous queues are an exception from most other GLib data
4768  * structures, as they can be used simultaneously from multiple threads
4769  * without explicit locking and they bring their own builtin reference
4770  * counting. This is because the nature of an asynchronous queue is that
4771  * it will always be used by at least 2 concurrent threads.
4772  *
4773  * For using an asynchronous queue you first have to create one with
4774  * g_async_queue_new(). #GAsyncQueue structs are reference counted,
4775  * use g_async_queue_ref() and g_async_queue_unref() to manage your
4776  * references.
4777  *
4778  * A thread which wants to send a message to that queue simply calls
4779  * g_async_queue_push() to push the message to the queue.
4780  *
4781  * A thread which is expecting messages from an asynchronous queue
4782  * simply calls g_async_queue_pop() for that queue. If no message is
4783  * available in the queue at that point, the thread is now put to sleep
4784  * until a message arrives. The message will be removed from the queue
4785  * and returned. The functions g_async_queue_try_pop() and
4786  * g_async_queue_timeout_pop() can be used to only check for the presence
4787  * of messages or to only wait a certain time for messages respectively.
4788  *
4789  * For almost every function there exist two variants, one that locks
4790  * the queue and one that doesn't. That way you can hold the queue lock
4791  * (acquire it with g_async_queue_lock() and release it with
4792  * g_async_queue_unlock()) over multiple queue accessing instructions.
4793  * This can be necessary to ensure the integrity of the queue, but should
4794  * only be used when really necessary, as it can make your life harder
4795  * if used unwisely. Normally you should only use the locking function
4796  * variants (those without the _unlocked suffix).
4797  *
4798  * In many cases, it may be more convenient to use #GThreadPool when
4799  * you need to distribute work to a set of worker threads instead of
4800  * using #GAsyncQueue manually. #GThreadPool uses a GAsyncQueue
4801  * internally.
4802  */
4803
4804
4805 /**
4806  * SECTION:atomic_operations
4807  * @title: Atomic Operations
4808  * @short_description: basic atomic integer and pointer operations
4809  * @see_also: #GMutex
4810  *
4811  * The following is a collection of compiler macros to provide atomic
4812  * access to integer and pointer-sized values.
4813  *
4814  * The macros that have 'int' in the name will operate on pointers to
4815  * #gint and #guint.  The macros with 'pointer' in the name will operate
4816  * on pointers to any pointer-sized value, including #gsize.  There is
4817  * no support for 64bit operations on platforms with 32bit pointers
4818  * because it is not generally possible to perform these operations
4819  * atomically.
4820  *
4821  * The get, set and exchange operations for integers and pointers
4822  * nominally operate on #gint and #gpointer, respectively.  Of the
4823  * arithmetic operations, the 'add' operation operates on (and returns)
4824  * signed integer values (#gint and #gssize) and the 'and', 'or', and
4825  * 'xor' operations operate on (and return) unsigned integer values
4826  * (#guint and #gsize).
4827  *
4828  * All of the operations act as a full compiler and (where appropriate)
4829  * hardware memory barrier.  Acquire and release or producer and
4830  * consumer barrier semantics are not available through this API.
4831  *
4832  * It is very important that all accesses to a particular integer or
4833  * pointer be performed using only this API and that different sizes of
4834  * operation are not mixed or used on overlapping memory regions.  Never
4835  * read or assign directly from or to a value -- always use this API.
4836  *
4837  * For simple reference counting purposes you should use
4838  * g_atomic_int_inc() and g_atomic_int_dec_and_test().  Other uses that
4839  * fall outside of simple reference counting patterns are prone to
4840  * subtle bugs and occasionally undefined behaviour.  It is also worth
4841  * noting that since all of these operations require global
4842  * synchronisation of the entire machine, they can be quite slow.  In
4843  * the case of performing multiple atomic operations it can often be
4844  * faster to simply acquire a mutex lock around the critical area,
4845  * perform the operations normally and then release the lock.
4846  */
4847
4848
4849 /**
4850  * SECTION:base64
4851  * @title: Base64 Encoding
4852  * @short_description: encodes and decodes data in Base64 format
4853  *
4854  * Base64 is an encoding that allows a sequence of arbitrary bytes to be
4855  * encoded as a sequence of printable ASCII characters. For the definition
4856  * of Base64, see <ulink url="http://www.ietf.org/rfc/rfc1421.txt">RFC
4857  * 1421</ulink> or <ulink url="http://www.ietf.org/rfc/rfc2045.txt">RFC
4858  * 2045</ulink>. Base64 is most commonly used as a MIME transfer encoding
4859  * for email.
4860  *
4861  * GLib supports incremental encoding using g_base64_encode_step() and
4862  * g_base64_encode_close(). Incremental decoding can be done with
4863  * g_base64_decode_step(). To encode or decode data in one go, use
4864  * g_base64_encode() or g_base64_decode(). To avoid memory allocation when
4865  * decoding, you can use g_base64_decode_inplace().
4866  *
4867  * Support for Base64 encoding has been added in GLib 2.12.
4868  */
4869
4870
4871 /**
4872  * SECTION:bookmarkfile
4873  * @title: Bookmark file parser
4874  * @short_description: parses files containing bookmarks
4875  *
4876  * GBookmarkFile lets you parse, edit or create files containing bookmarks
4877  * to URI, along with some meta-data about the resource pointed by the URI
4878  * like its MIME type, the application that is registering the bookmark and
4879  * the icon that should be used to represent the bookmark. The data is stored
4880  * using the
4881  * <ulink url="http://www.gnome.org/~ebassi/bookmark-spec">Desktop Bookmark
4882  * Specification</ulink>.
4883  *
4884  * The syntax of the bookmark files is described in detail inside the Desktop
4885  * Bookmark Specification, here is a quick summary: bookmark files use a
4886  * sub-class of the <ulink url="">XML Bookmark Exchange Language</ulink>
4887  * specification, consisting of valid UTF-8 encoded XML, under the
4888  * <literal>xbel</literal> root element; each bookmark is stored inside a
4889  * <literal>bookmark</literal> element, using its URI: no relative paths can
4890  * be used inside a bookmark file. The bookmark may have a user defined title
4891  * and description, to be used instead of the URI. Under the
4892  * <literal>metadata</literal> element, with its <literal>owner</literal>
4893  * attribute set to <literal>http://freedesktop.org</literal>, is stored the
4894  * meta-data about a resource pointed by its URI. The meta-data consists of
4895  * the resource's MIME type; the applications that have registered a bookmark;
4896  * the groups to which a bookmark belongs to; a visibility flag, used to set
4897  * the bookmark as "private" to the applications and groups that has it
4898  * registered; the URI and MIME type of an icon, to be used when displaying
4899  * the bookmark inside a GUI.
4900  * |[<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" href="../../../../glib/tests/bookmarks.xbel"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include>]|
4901  *
4902  * A bookmark file might contain more than one bookmark; each bookmark
4903  * is accessed through its URI.
4904  *
4905  * The important caveat of bookmark files is that when you add a new
4906  * bookmark you must also add the application that is registering it, using
4907  * g_bookmark_file_add_application() or g_bookmark_file_set_app_info().
4908  * If a bookmark has no applications then it won't be dumped when creating
4909  * the on disk representation, using g_bookmark_file_to_data() or
4910  * g_bookmark_file_to_file().
4911  *
4912  * The #GBookmarkFile parser was added in GLib 2.12.
4913  */
4914
4915
4916 /**
4917  * SECTION:byte_order
4918  * @title: Byte Order Macros
4919  * @short_description: a portable way to convert between different byte orders
4920  *
4921  * These macros provide a portable way to determine the host byte order
4922  * and to convert values between different byte orders.
4923  *
4924  * The byte order is the order in which bytes are stored to create larger
4925  * data types such as the #gint and #glong values.
4926  * The host byte order is the byte order used on the current machine.
4927  *
4928  * Some processors store the most significant bytes (i.e. the bytes that
4929  * hold the largest part of the value) first. These are known as big-endian
4930  * processors. Other processors (notably the x86 family) store the most
4931  * significant byte last. These are known as little-endian processors.
4932  *
4933  * Finally, to complicate matters, some other processors store the bytes in
4934  * a rather curious order known as PDP-endian. For a 4-byte word, the 3rd
4935  * most significant byte is stored first, then the 4th, then the 1st and
4936  * finally the 2nd.
4937  *
4938  * Obviously there is a problem when these different processors communicate
4939  * with each other, for example over networks or by using binary file formats.
4940  * This is where these macros come in. They are typically used to convert
4941  * values into a byte order which has been agreed on for use when
4942  * communicating between different processors. The Internet uses what is
4943  * known as 'network byte order' as the standard byte order (which is in
4944  * fact the big-endian byte order).
4945  *
4946  * Note that the byte order conversion macros may evaluate their arguments
4947  * multiple times, thus you should not use them with arguments which have
4948  * side-effects.
4949  */
4950
4951
4952 /**
4953  * SECTION:checksum
4954  * @title: Data Checksums
4955  * @short_description: computes the checksum for data
4956  *
4957  * GLib provides a generic API for computing checksums (or "digests")
4958  * for a sequence of arbitrary bytes, using various hashing algorithms
4959  * like MD5, SHA-1 and SHA-256. Checksums are commonly used in various
4960  * environments and specifications.
4961  *
4962  * GLib supports incremental checksums using the GChecksum data
4963  * structure, by calling g_checksum_update() as long as there's data
4964  * available and then using g_checksum_get_string() or
4965  * g_checksum_get_digest() to compute the checksum and return it either
4966  * as a string in hexadecimal form, or as a raw sequence of bytes. To
4967  * compute the checksum for binary blobs and NUL-terminated strings in
4968  * one go, use the convenience functions g_compute_checksum_for_data()
4969  * and g_compute_checksum_for_string(), respectively.
4970  *
4971  * Support for checksums has been added in GLib 2.16
4972  */
4973
4974
4975 /**
4976  * SECTION:conversions
4977  * @title: Character Set Conversion
4978  * @short_description: convert strings between different character sets
4979  *
4980  * The g_convert() family of function wraps the functionality of iconv(). In
4981  * addition to pure character set conversions, GLib has functions to deal
4982  * with the extra complications of encodings for file names.
4983  *
4984  * <refsect2 id="file-name-encodings">
4985  * <title>File Name Encodings</title>
4986  * <para>
4987  * Historically, Unix has not had a defined encoding for file
4988  * names:  a file name is valid as long as it does not have path
4989  * separators in it ("/").  However, displaying file names may
4990  * require conversion:  from the character set in which they were
4991  * created, to the character set in which the application
4992  * operates.  Consider the Spanish file name
4993  * "<filename>Presentaci&oacute;n.sxi</filename>".  If the
4994  * application which created it uses ISO-8859-1 for its encoding,
4995  * </para>
4996  * <programlisting id="filename-iso8859-1">
4997  * Character:  P  r  e  s  e  n  t  a  c  i  &oacute;  n  .  s  x  i
4998  * Hex code:   50 72 65 73 65 6e 74 61 63 69 f3 6e 2e 73 78 69
4999  * </programlisting>
5000  * <para>
5001  * However, if the application use UTF-8, the actual file name on
5002  * disk would look like this:
5003  * </para>
5004  * <programlisting id="filename-utf-8">
5005  * Character:  P  r  e  s  e  n  t  a  c  i  &oacute;     n  .  s  x  i
5006  * Hex code:   50 72 65 73 65 6e 74 61 63 69 c3 b3 6e 2e 73 78 69
5007  * </programlisting>
5008  * <para>
5009  * Glib uses UTF-8 for its strings, and GUI toolkits like GTK+
5010  * that use Glib do the same thing.  If you get a file name from
5011  * the file system, for example, from readdir(3) or from g_dir_read_name(),
5012  * and you wish to display the file name to the user, you
5013  * <emphasis>will</emphasis> need to convert it into UTF-8.  The
5014  * opposite case is when the user types the name of a file he
5015  * wishes to save:  the toolkit will give you that string in
5016  * UTF-8 encoding, and you will need to convert it to the
5017  * character set used for file names before you can create the
5018  * file with open(2) or fopen(3).
5019  * </para>
5020  * <para>
5021  * By default, Glib assumes that file names on disk are in UTF-8
5022  * encoding.  This is a valid assumption for file systems which
5023  * were created relatively recently:  most applications use UTF-8
5024  * encoding for their strings, and that is also what they use for
5025  * the file names they create.  However, older file systems may
5026  * still contain file names created in "older" encodings, such as
5027  * ISO-8859-1. In this case, for compatibility reasons, you may
5028  * want to instruct Glib to use that particular encoding for file
5029  * names rather than UTF-8.  You can do this by specifying the
5030  * encoding for file names in the <link
5031  * linkend="G_FILENAME_ENCODING"><envar>G_FILENAME_ENCODING</envar></link>
5032  * environment variable.  For example, if your installation uses
5033  * ISO-8859-1 for file names, you can put this in your
5034  * <filename>~/.profile</filename>:
5035  * </para>
5036  * <programlisting>
5037  * export G_FILENAME_ENCODING=ISO-8859-1
5038  * </programlisting>
5039  * <para>
5040  * Glib provides the functions g_filename_to_utf8() and
5041  * g_filename_from_utf8() to perform the necessary conversions. These
5042  * functions convert file names from the encoding specified in
5043  * <envar>G_FILENAME_ENCODING</envar> to UTF-8 and vice-versa.
5044  * <xref linkend="file-name-encodings-diagram"/> illustrates how
5045  * these functions are used to convert between UTF-8 and the
5046  * encoding for file names in the file system.
5047  * </para>
5048  * <figure id="file-name-encodings-diagram">
5049  * <title>Conversion between File Name Encodings</title>
5050  * <graphic fileref="file-name-encodings.png" format="PNG"/>
5051  * </figure>
5052  * <refsect3 id="file-name-encodings-checklist">
5053  * <title>Checklist for Application Writers</title>
5054  * <para>
5055  * This section is a practical summary of the detailed
5056  * description above.  You can use this as a checklist of
5057  * things to do to make sure your applications process file
5058  * name encodings correctly.
5059  * </para>
5060  * <orderedlist>
5061  * <listitem><para>
5062  * If you get a file name from the file system from a function
5063  * such as readdir(3) or gtk_file_chooser_get_filename(),
5064  * you do not need to do any conversion to pass that
5065  * file name to functions like open(2), rename(2), or
5066  * fopen(3) &mdash; those are "raw" file names which the file
5067  * system understands.
5068  * </para></listitem>
5069  * <listitem><para>
5070  * If you need to display a file name, convert it to UTF-8 first by
5071  * using g_filename_to_utf8(). If conversion fails, display a string like
5072  * "<literal>Unknown file name</literal>". <emphasis>Do not</emphasis>
5073  * convert this string back into the encoding used for file names if you
5074  * wish to pass it to the file system; use the original file name instead.
5075  * For example, the document window of a word processor could display
5076  * "Unknown file name" in its title bar but still let the user save the
5077  * file, as it would keep the raw file name internally. This can happen
5078  * if the user has not set the <envar>G_FILENAME_ENCODING</envar>
5079  * environment variable even though he has files whose names are not
5080  * encoded in UTF-8.
5081  * </para></listitem>
5082  * <listitem><para>
5083  * If your user interface lets the user type a file name for saving or
5084  * renaming, convert it to the encoding used for file names in the file
5085  * system by using g_filename_from_utf8(). Pass the converted file name
5086  * to functions like fopen(3). If conversion fails, ask the user to enter
5087  * a different file name. This can happen if the user types Japanese
5088  * characters when <envar>G_FILENAME_ENCODING</envar> is set to
5089  * <literal>ISO-8859-1</literal>, for example.
5090  * </para></listitem>
5091  * </orderedlist>
5092  * </refsect3>
5093  * </refsect2>
5094  */
5095
5096
5097 /**
5098  * SECTION:datalist
5099  * @title: Keyed Data Lists
5100  * @short_description: lists of data elements which are accessible by a string or GQuark identifier
5101  *
5102  * Keyed data lists provide lists of arbitrary data elements which can
5103  * be accessed either with a string or with a #GQuark corresponding to
5104  * the string.
5105  *
5106  * The #GQuark methods are quicker, since the strings have to be
5107  * converted to #GQuarks anyway.
5108  *
5109  * Data lists are used for associating arbitrary data with #GObjects,
5110  * using g_object_set_data() and related functions.
5111  *
5112  * To create a datalist, use g_datalist_init().
5113  *
5114  * To add data elements to a datalist use g_datalist_id_set_data(),
5115  * g_datalist_id_set_data_full(), g_datalist_set_data() and
5116  * g_datalist_set_data_full().
5117  *
5118  * To get data elements from a datalist use g_datalist_id_get_data()
5119  * and g_datalist_get_data().
5120  *
5121  * To iterate over all data elements in a datalist use
5122  * g_datalist_foreach() (not thread-safe).
5123  *
5124  * To remove data elements from a datalist use
5125  * g_datalist_id_remove_data() and g_datalist_remove_data().
5126  *
5127  * To remove all data elements from a datalist, use g_datalist_clear().
5128  */
5129
5130
5131 /**
5132  * SECTION:datasets
5133  * @title: Datasets
5134  * @short_description: associate groups of data elements with particular memory locations
5135  *
5136  * Datasets associate groups of data elements with particular memory
5137  * locations. These are useful if you need to associate data with a
5138  * structure returned from an external library. Since you cannot modify
5139  * the structure, you use its location in memory as the key into a
5140  * dataset, where you can associate any number of data elements with it.
5141  *
5142  * There are two forms of most of the dataset functions. The first form
5143  * uses strings to identify the data elements associated with a
5144  * location. The second form uses #GQuark identifiers, which are
5145  * created with a call to g_quark_from_string() or
5146  * g_quark_from_static_string(). The second form is quicker, since it
5147  * does not require looking up the string in the hash table of #GQuark
5148  * identifiers.
5149  *
5150  * There is no function to create a dataset. It is automatically
5151  * created as soon as you add elements to it.
5152  *
5153  * To add data elements to a dataset use g_dataset_id_set_data(),
5154  * g_dataset_id_set_data_full(), g_dataset_set_data() and
5155  * g_dataset_set_data_full().
5156  *
5157  * To get data elements from a dataset use g_dataset_id_get_data() and
5158  * g_dataset_get_data().
5159  *
5160  * To iterate over all data elements in a dataset use
5161  * g_dataset_foreach() (not thread-safe).
5162  *
5163  * To remove data elements from a dataset use
5164  * g_dataset_id_remove_data() and g_dataset_remove_data().
5165  *
5166  * To destroy a dataset, use g_dataset_destroy().
5167  */
5168
5169
5170 /**
5171  * SECTION:date
5172  * @title: Date and Time Functions
5173  * @short_description: calendrical calculations and miscellaneous time stuff
5174  *
5175  * The #GDate data structure represents a day between January 1, Year 1,
5176  * and sometime a few thousand years in the future (right now it will go
5177  * to the year 65535 or so, but g_date_set_parse() only parses up to the
5178  * year 8000 or so - just count on "a few thousand"). #GDate is meant to
5179  * represent everyday dates, not astronomical dates or historical dates
5180  * or ISO timestamps or the like. It extrapolates the current Gregorian
5181  * calendar forward and backward in time; there is no attempt to change
5182  * the calendar to match time periods or locations. #GDate does not store
5183  * time information; it represents a <emphasis>day</emphasis>.
5184  *
5185  * The #GDate implementation has several nice features; it is only a
5186  * 64-bit struct, so storing large numbers of dates is very efficient. It
5187  * can keep both a Julian and day-month-year representation of the date,
5188  * since some calculations are much easier with one representation or the
5189  * other. A Julian representation is simply a count of days since some
5190  * fixed day in the past; for #GDate the fixed day is January 1, 1 AD.
5191  * ("Julian" dates in the #GDate API aren't really Julian dates in the
5192  * technical sense; technically, Julian dates count from the start of the
5193  * Julian period, Jan 1, 4713 BC).
5194  *
5195  * #GDate is simple to use. First you need a "blank" date; you can get a
5196  * dynamically allocated date from g_date_new(), or you can declare an
5197  * automatic variable or array and initialize it to a sane state by
5198  * calling g_date_clear(). A cleared date is sane; it's safe to call
5199  * g_date_set_dmy() and the other mutator functions to initialize the
5200  * value of a cleared date. However, a cleared date is initially
5201  * <emphasis>invalid</emphasis>, meaning that it doesn't represent a day
5202  * that exists. It is undefined to call any of the date calculation
5203  * routines on an invalid date. If you obtain a date from a user or other
5204  * unpredictable source, you should check its validity with the
5205  * g_date_valid() predicate. g_date_valid() is also used to check for
5206  * errors with g_date_set_parse() and other functions that can
5207  * fail. Dates can be invalidated by calling g_date_clear() again.
5208  *
5209  * <emphasis>It is very important to use the API to access the #GDate
5210  * struct.</emphasis> Often only the day-month-year or only the Julian
5211  * representation is valid. Sometimes neither is valid. Use the API.
5212  *
5213  * GLib also features #GDateTime which represents a precise time.
5214  */
5215
5216
5217 /**
5218  * SECTION:date-time
5219  * @title: GDateTime
5220  * @short_description: a structure representing Date and Time
5221  * @see_also: #GTimeZone
5222  *
5223  * #GDateTime is a structure that combines a Gregorian date and time
5224  * into a single structure.  It provides many conversion and methods to
5225  * manipulate dates and times.  Time precision is provided down to
5226  * microseconds and the time can range (proleptically) from 0001-01-01
5227  * 00:00:00 to 9999-12-31 23:59:59.999999.  #GDateTime follows POSIX
5228  * time in the sense that it is oblivious to leap seconds.
5229  *
5230  * #GDateTime is an immutable object; once it has been created it cannot
5231  * be modified further.  All modifiers will create a new #GDateTime.
5232  * Nearly all such functions can fail due to the date or time going out
5233  * of range, in which case %NULL will be returned.
5234  *
5235  * #GDateTime is reference counted: the reference count is increased by calling
5236  * g_date_time_ref() and decreased by calling g_date_time_unref(). When the
5237  * reference count drops to 0, the resources allocated by the #GDateTime
5238  * structure are released.
5239  *
5240  * Many parts of the API may produce non-obvious results.  As an
5241  * example, adding two months to January 31st will yield March 31st
5242  * whereas adding one month and then one month again will yield either
5243  * March 28th or March 29th.  Also note that adding 24 hours is not
5244  * always the same as adding one day (since days containing daylight
5245  * savings time transitions are either 23 or 25 hours in length).
5246  *
5247  * #GDateTime is available since GLib 2.26.
5248  */
5249
5250
5251 /**
5252  * SECTION:error_reporting
5253  * @Title: Error Reporting
5254  * @Short_description: a system for reporting errors
5255  *
5256  * GLib provides a standard method of reporting errors from a called
5257  * function to the calling code. (This is the same problem solved by
5258  * exceptions in other languages.) It's important to understand that
5259  * this method is both a <emphasis>data type</emphasis> (the #GError
5260  * object) and a <emphasis>set of rules.</emphasis> If you use #GError
5261  * incorrectly, then your code will not properly interoperate with other
5262  * code that uses #GError, and users of your API will probably get confused.
5263  *
5264  * First and foremost: <emphasis>#GError should only be used to report
5265  * recoverable runtime errors, never to report programming
5266  * errors.</emphasis> If the programmer has screwed up, then you should
5267  * use g_warning(), g_return_if_fail(), g_assert(), g_error(), or some
5268  * similar facility. (Incidentally, remember that the g_error() function
5269  * should <emphasis>only</emphasis> be used for programming errors, it
5270  * should not be used to print any error reportable via #GError.)
5271  *
5272  * Examples of recoverable runtime errors are "file not found" or
5273  * "failed to parse input." Examples of programming errors are "NULL
5274  * passed to strcmp()" or "attempted to free the same pointer twice."
5275  * These two kinds of errors are fundamentally different: runtime errors
5276  * should be handled or reported to the user, programming errors should
5277  * be eliminated by fixing the bug in the program. This is why most
5278  * functions in GLib and GTK+ do not use the #GError facility.
5279  *
5280  * Functions that can fail take a return location for a #GError as their
5281  * last argument. For example:
5282  * |[
5283  * gboolean g_file_get_contents (const gchar  *filename,
5284  *                               gchar       **contents,
5285  *                               gsize        *length,
5286  *                               GError      **error);
5287  * ]|
5288  * If you pass a non-%NULL value for the <literal>error</literal>
5289  * argument, it should point to a location where an error can be placed.
5290  * For example:
5291  * |[
5292  * gchar *contents;
5293  * GError *err = NULL;
5294  * g_file_get_contents ("foo.txt", &amp;contents, NULL, &amp;err);
5295  * g_assert ((contents == NULL &amp;&amp; err != NULL) || (contents != NULL &amp;&amp; err == NULL));
5296  * if (err != NULL)
5297  *   {
5298  *     /&ast; Report error to user, and free error &ast;/
5299  *     g_assert (contents == NULL);
5300  *     fprintf (stderr, "Unable to read file: &percnt;s\n", err->message);
5301  *     g_error_free (err);
5302  *   }
5303  * else
5304  *   {
5305  *     /&ast; Use file contents &ast;/
5306  *     g_assert (contents != NULL);
5307  *   }
5308  * ]|
5309  * Note that <literal>err != NULL</literal> in this example is a
5310  * <emphasis>reliable</emphasis> indicator of whether
5311  * g_file_get_contents() failed. Additionally, g_file_get_contents()
5312  * returns a boolean which indicates whether it was successful.
5313  *
5314  * Because g_file_get_contents() returns %FALSE on failure, if you
5315  * are only interested in whether it failed and don't need to display
5316  * an error message, you can pass %NULL for the <literal>error</literal>
5317  * argument:
5318  * |[
5319  * if (g_file_get_contents ("foo.txt", &amp;contents, NULL, NULL)) /&ast; ignore errors &ast;/
5320  *   /&ast; no error occurred &ast;/ ;
5321  * else
5322  *   /&ast; error &ast;/ ;
5323  * ]|
5324  *
5325  * The #GError object contains three fields: <literal>domain</literal>
5326  * indicates the module the error-reporting function is located in,
5327  * <literal>code</literal> indicates the specific error that occurred,
5328  * and <literal>message</literal> is a user-readable error message with
5329  * as many details as possible. Several functions are provided to deal
5330  * with an error received from a called function: g_error_matches()
5331  * returns %TRUE if the error matches a given domain and code,
5332  * g_propagate_error() copies an error into an error location (so the
5333  * calling function will receive it), and g_clear_error() clears an
5334  * error location by freeing the error and resetting the location to
5335  * %NULL. To display an error to the user, simply display
5336  * <literal>error-&gt;message</literal>, perhaps along with additional
5337  * context known only to the calling function (the file being opened,
5338  * or whatever -- though in the g_file_get_contents() case,
5339  * <literal>error-&gt;message</literal> already contains a filename).
5340  *
5341  * When implementing a function that can report errors, the basic
5342  * tool is g_set_error(). Typically, if a fatal error occurs you
5343  * want to g_set_error(), then return immediately. g_set_error()
5344  * does nothing if the error location passed to it is %NULL.
5345  * Here's an example:
5346  * |[
5347  * gint
5348  * foo_open_file (GError **error)
5349  * {
5350  *   gint fd;
5351  *
5352  *   fd = open ("file.txt", O_RDONLY);
5353  *
5354  *   if (fd &lt; 0)
5355  *     {
5356  *       g_set_error (error,
5357  *                    FOO_ERROR,                 /&ast; error domain &ast;/
5358  *                    FOO_ERROR_BLAH,            /&ast; error code &ast;/
5359  *                    "Failed to open file: &percnt;s", /&ast; error message format string &ast;/
5360  *                    g_strerror (errno));
5361  *       return -1;
5362  *     }
5363  *   else
5364  *     return fd;
5365  * }
5366  * ]|
5367  *
5368  * Things are somewhat more complicated if you yourself call another
5369  * function that can report a #GError. If the sub-function indicates
5370  * fatal errors in some way other than reporting a #GError, such as
5371  * by returning %TRUE on success, you can simply do the following:
5372  * |[
5373  * gboolean
5374  * my_function_that_can_fail (GError **err)
5375  * {
5376  *   g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
5377  *
5378  *   if (!sub_function_that_can_fail (err))
5379  *     {
5380  *       /&ast; assert that error was set by the sub-function &ast;/
5381  *       g_assert (err == NULL || *err != NULL);
5382  *       return FALSE;
5383  *     }
5384  *
5385  *   /&ast; otherwise continue, no error occurred &ast;/
5386  *   g_assert (err == NULL || *err == NULL);
5387  * }
5388  * ]|
5389  *
5390  * If the sub-function does not indicate errors other than by
5391  * reporting a #GError, you need to create a temporary #GError
5392  * since the passed-in one may be %NULL. g_propagate_error() is
5393  * intended for use in this case.
5394  * |[
5395  * gboolean
5396  * my_function_that_can_fail (GError **err)
5397  * {
5398  *   GError *tmp_error;
5399  *
5400  *   g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
5401  *
5402  *   tmp_error = NULL;
5403  *   sub_function_that_can_fail (&amp;tmp_error);
5404  *
5405  *   if (tmp_error != NULL)
5406  *     {
5407  *       /&ast; store tmp_error in err, if err != NULL,
5408  *        &ast; otherwise call g_error_free() on tmp_error
5409  *        &ast;/
5410  *       g_propagate_error (err, tmp_error);
5411  *       return FALSE;
5412  *     }
5413  *
5414  *   /&ast; otherwise continue, no error occurred &ast;/
5415  * }
5416  * ]|
5417  *
5418  * Error pileups are always a bug. For example, this code is incorrect:
5419  * |[
5420  * gboolean
5421  * my_function_that_can_fail (GError **err)
5422  * {
5423  *   GError *tmp_error;
5424  *
5425  *   g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
5426  *
5427  *   tmp_error = NULL;
5428  *   sub_function_that_can_fail (&amp;tmp_error);
5429  *   other_function_that_can_fail (&amp;tmp_error);
5430  *
5431  *   if (tmp_error != NULL)
5432  *     {
5433  *       g_propagate_error (err, tmp_error);
5434  *       return FALSE;
5435  *     }
5436  * }
5437  * ]|
5438  * <literal>tmp_error</literal> should be checked immediately after
5439  * sub_function_that_can_fail(), and either cleared or propagated
5440  * upward. The rule is: <emphasis>after each error, you must either
5441  * handle the error, or return it to the calling function</emphasis>.
5442  * Note that passing %NULL for the error location is the equivalent
5443  * of handling an error by always doing nothing about it. So the
5444  * following code is fine, assuming errors in sub_function_that_can_fail()
5445  * are not fatal to my_function_that_can_fail():
5446  * |[
5447  * gboolean
5448  * my_function_that_can_fail (GError **err)
5449  * {
5450  *   GError *tmp_error;
5451  *
5452  *   g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
5453  *
5454  *   sub_function_that_can_fail (NULL); /&ast; ignore errors &ast;/
5455  *
5456  *   tmp_error = NULL;
5457  *   other_function_that_can_fail (&amp;tmp_error);
5458  *
5459  *   if (tmp_error != NULL)
5460  *     {
5461  *       g_propagate_error (err, tmp_error);
5462  *       return FALSE;
5463  *     }
5464  * }
5465  * ]|
5466  *
5467  * Note that passing %NULL for the error location
5468  * <emphasis>ignores</emphasis> errors; it's equivalent to
5469  * <literal>try { sub_function_that_can_fail (); } catch (...) {}</literal>
5470  * in C++. It does <emphasis>not</emphasis> mean to leave errors
5471  * unhandled; it means to handle them by doing nothing.
5472  *
5473  * Error domains and codes are conventionally named as follows:
5474  * <itemizedlist>
5475  * <listitem><para>
5476  *   The error domain is called
5477  *   <literal>&lt;NAMESPACE&gt;_&lt;MODULE&gt;_ERROR</literal>,
5478  *   for example %G_SPAWN_ERROR or %G_THREAD_ERROR:
5479  *   |[
5480  * #define G_SPAWN_ERROR g_spawn_error_quark ()
5481  *
5482  * GQuark
5483  * g_spawn_error_quark (void)
5484  * {
5485  *   return g_quark_from_static_string ("g-spawn-error-quark");
5486  * }
5487  *   ]|
5488  * </para></listitem>
5489  * <listitem><para>
5490  *   The quark function for the error domain is called
5491  *   <literal>&lt;namespace&gt;_&lt;module&gt;_error_quark</literal>,
5492  *   for example g_spawn_error_quark() or g_thread_error_quark().
5493  * </para></listitem>
5494  * <listitem><para>
5495  *   The error codes are in an enumeration called
5496  *   <literal>&lt;Namespace&gt;&lt;Module&gt;Error</literal>;
5497  *   for example,#GThreadError or #GSpawnError.
5498  * </para></listitem>
5499  * <listitem><para>
5500  *   Members of the error code enumeration are called
5501  *   <literal>&lt;NAMESPACE&gt;_&lt;MODULE&gt;_ERROR_&lt;CODE&gt;</literal>,
5502  *   for example %G_SPAWN_ERROR_FORK or %G_THREAD_ERROR_AGAIN.
5503  * </para></listitem>
5504  * <listitem><para>
5505  *   If there's a "generic" or "unknown" error code for unrecoverable
5506  *   errors it doesn't make sense to distinguish with specific codes,
5507  *   it should be called <literal>&lt;NAMESPACE&gt;_&lt;MODULE&gt;_ERROR_FAILED</literal>,
5508  *   for example %G_SPAWN_ERROR_FAILED.
5509  * </para></listitem>
5510  * </itemizedlist>
5511  *
5512  * Summary of rules for use of #GError:
5513  * <itemizedlist>
5514  * <listitem><para>
5515  *   Do not report programming errors via #GError.
5516  * </para></listitem>
5517  * <listitem><para>
5518  *   The last argument of a function that returns an error should
5519  *   be a location where a #GError can be placed (i.e. "#GError** error").
5520  *   If #GError is used with varargs, the #GError** should be the last
5521  *   argument before the "...".
5522  * </para></listitem>
5523  * <listitem><para>
5524  *   The caller may pass %NULL for the #GError** if they are not interested
5525  *   in details of the exact error that occurred.
5526  * </para></listitem>
5527  * <listitem><para>
5528  *   If %NULL is passed for the #GError** argument, then errors should
5529  *   not be returned to the caller, but your function should still
5530  *   abort and return if an error occurs. That is, control flow should
5531  *   not be affected by whether the caller wants to get a #GError.
5532  * </para></listitem>
5533  * <listitem><para>
5534  *   If a #GError is reported, then your function by definition
5535  *   <emphasis>had a fatal failure and did not complete whatever
5536  *   it was supposed to do</emphasis>. If the failure was not fatal,
5537  *   then you handled it and you should not report it. If it was fatal,
5538  *   then you must report it and discontinue whatever you were doing
5539  *   immediately.
5540  * </para></listitem>
5541  * <listitem><para>
5542  *   If a #GError is reported, out parameters are not guaranteed to
5543  *   be set to any defined value.
5544  * </para></listitem>
5545  * <listitem><para>
5546  *   A #GError* must be initialized to %NULL before passing its address
5547  *   to a function that can report errors.
5548  * </para></listitem>
5549  * <listitem><para>
5550  *   "Piling up" errors is always a bug. That is, if you assign a
5551  *   new #GError to a #GError* that is non-%NULL, thus overwriting
5552  *   the previous error, it indicates that you should have aborted
5553  *   the operation instead of continuing. If you were able to continue,
5554  *   you should have cleared the previous error with g_clear_error().
5555  *   g_set_error() will complain if you pile up errors.
5556  * </para></listitem>
5557  * <listitem><para>
5558  *   By convention, if you return a boolean value indicating success
5559  *   then %TRUE means success and %FALSE means failure. If %FALSE is
5560  *   returned, the error <emphasis>must</emphasis> be set to a non-%NULL
5561  *   value.
5562  * </para></listitem>
5563  * <listitem><para>
5564  *   A %NULL return value is also frequently used to mean that an error
5565  *   occurred. You should make clear in your documentation whether %NULL
5566  *   is a valid return value in non-error cases; if %NULL is a valid value,
5567  *   then users must check whether an error was returned to see if the
5568  *   function succeeded.
5569  * </para></listitem>
5570  * <listitem><para>
5571  *   When implementing a function that can report errors, you may want
5572  *   to add a check at the top of your function that the error return
5573  *   location is either %NULL or contains a %NULL error (e.g.
5574  *   <literal>g_return_if_fail (error == NULL || *error == NULL);</literal>).
5575  * </para></listitem>
5576  * </itemizedlist>
5577  */
5578
5579
5580 /**
5581  * SECTION:fileutils
5582  * @title: File Utilities
5583  * @short_description: various file-related functions
5584  *
5585  * There is a group of functions which wrap the common POSIX functions
5586  * dealing with filenames (g_open(), g_rename(), g_mkdir(), g_stat(),
5587  * g_unlink(), g_remove(), g_fopen(), g_freopen()). The point of these
5588  * wrappers is to make it possible to handle file names with any Unicode
5589  * characters in them on Windows without having to use ifdefs and the
5590  * wide character API in the application code.
5591  *
5592  * The pathname argument should be in the GLib file name encoding.
5593  * On POSIX this is the actual on-disk encoding which might correspond
5594  * to the locale settings of the process (or the
5595  * <envar>G_FILENAME_ENCODING</envar> environment variable), or not.
5596  *
5597  * On Windows the GLib file name encoding is UTF-8. Note that the
5598  * Microsoft C library does not use UTF-8, but has separate APIs for
5599  * current system code page and wide characters (UTF-16). The GLib
5600  * wrappers call the wide character API if present (on modern Windows
5601  * systems), otherwise convert to/from the system code page.
5602  *
5603  * Another group of functions allows to open and read directories
5604  * in the GLib file name encoding. These are g_dir_open(),
5605  * g_dir_read_name(), g_dir_rewind(), g_dir_close().
5606  */
5607
5608
5609 /**
5610  * SECTION:ghostutils
5611  * @short_description: Internet hostname utilities
5612  *
5613  * Functions for manipulating internet hostnames; in particular, for
5614  * converting between Unicode and ASCII-encoded forms of
5615  * Internationalized Domain Names (IDNs).
5616  *
5617  * The <ulink
5618  * url="http://www.ietf.org/rfc/rfc3490.txt">Internationalized Domain
5619  * Names for Applications (IDNA)</ulink> standards allow for the use
5620  * of Unicode domain names in applications, while providing
5621  * backward-compatibility with the old ASCII-only DNS, by defining an
5622  * ASCII-Compatible Encoding of any given Unicode name, which can be
5623  * used with non-IDN-aware applications and protocols. (For example,
5624  * "Παν語.org" maps to "xn--4wa8awb4637h.org".)
5625  */
5626
5627
5628 /**
5629  * SECTION:gregex
5630  * @title: Perl-compatible regular expressions
5631  * @short_description: matches strings against regular expressions
5632  * @see_also: <xref linkend="glib-regex-syntax"/>
5633  *
5634  * The <function>g_regex_*()</function> functions implement regular
5635  * expression pattern matching using syntax and semantics similar to
5636  * Perl regular expression.
5637  *
5638  * Some functions accept a @start_position argument, setting it differs
5639  * from just passing over a shortened string and setting #G_REGEX_MATCH_NOTBOL
5640  * in the case of a pattern that begins with any kind of lookbehind assertion.
5641  * For example, consider the pattern "\Biss\B" which finds occurrences of "iss"
5642  * in the middle of words. ("\B" matches only if the current position in the
5643  * subject is not a word boundary.) When applied to the string "Mississipi"
5644  * from the fourth byte, namely "issipi", it does not match, because "\B" is
5645  * always false at the start of the subject, which is deemed to be a word
5646  * boundary. However, if the entire string is passed , but with
5647  * @start_position set to 4, it finds the second occurrence of "iss" because
5648  * it is able to look behind the starting point to discover that it is
5649  * preceded by a letter.
5650  *
5651  * Note that, unless you set the #G_REGEX_RAW flag, all the strings passed
5652  * to these functions must be encoded in UTF-8. The lengths and the positions
5653  * inside the strings are in bytes and not in characters, so, for instance,
5654  * "\xc3\xa0" (i.e. "&agrave;") is two bytes long but it is treated as a
5655  * single character. If you set #G_REGEX_RAW the strings can be non-valid
5656  * UTF-8 strings and a byte is treated as a character, so "\xc3\xa0" is two
5657  * bytes and two characters long.
5658  *
5659  * When matching a pattern, "\n" matches only against a "\n" character in
5660  * the string, and "\r" matches only a "\r" character. To match any newline
5661  * sequence use "\R". This particular group matches either the two-character
5662  * sequence CR + LF ("\r\n"), or one of the single characters LF (linefeed,
5663  * U+000A, "\n"), VT vertical tab, U+000B, "\v"), FF (formfeed, U+000C, "\f"),
5664  * CR (carriage return, U+000D, "\r"), NEL (next line, U+0085), LS (line
5665  * separator, U+2028), or PS (paragraph separator, U+2029).
5666  *
5667  * The behaviour of the dot, circumflex, and dollar metacharacters are
5668  * affected by newline characters, the default is to recognize any newline
5669  * character (the same characters recognized by "\R"). This can be changed
5670  * with #G_REGEX_NEWLINE_CR, #G_REGEX_NEWLINE_LF and #G_REGEX_NEWLINE_CRLF
5671  * compile options, and with #G_REGEX_MATCH_NEWLINE_ANY,
5672  * #G_REGEX_MATCH_NEWLINE_CR, #G_REGEX_MATCH_NEWLINE_LF and
5673  * #G_REGEX_MATCH_NEWLINE_CRLF match options. These settings are also
5674  * relevant when compiling a pattern if #G_REGEX_EXTENDED is set, and an
5675  * unescaped "#" outside a character class is encountered. This indicates
5676  * a comment that lasts until after the next newline.
5677  *
5678  * When setting the %G_REGEX_JAVASCRIPT_COMPAT flag, pattern syntax and pattern
5679  * matching is changed to be compatible with the way that regular expressions
5680  * work in JavaScript. More precisely, a lonely ']' character in the pattern
5681  * is a syntax error; the '\x' escape only allows 0 to 2 hexadecimal digits, and
5682  * you must use the '\u' escape sequence with 4 hex digits to specify a unicode
5683  * codepoint instead of '\x' or 'x{....}'. If '\x' or '\u' are not followed by
5684  * the specified number of hex digits, they match 'x' and 'u' literally; also
5685  * '\U' always matches 'U' instead of being an error in the pattern. Finally,
5686  * pattern matching is modified so that back references to an unset subpattern
5687  * group produces a match with the empty string instead of an error. See
5688  * <ulink>man:pcreapi(3)</ulink> for more information.
5689  *
5690  * Creating and manipulating the same #GRegex structure from different
5691  * threads is not a problem as #GRegex does not modify its internal
5692  * state between creation and destruction, on the other hand #GMatchInfo
5693  * is not threadsafe.
5694  *
5695  * The regular expressions low-level functionalities are obtained through
5696  * the excellent <ulink url="http://www.pcre.org/">PCRE</ulink> library
5697  * written by Philip Hazel.
5698  */
5699
5700
5701 /**
5702  * SECTION:gunix
5703  * @title: UNIX-specific utilities and integration
5704  * @short_description: pipes, signal handling
5705  * @include: glib-unix.h
5706  *
5707  * Most of GLib is intended to be portable; in contrast, this set of
5708  * functions is designed for programs which explicitly target UNIX,
5709  * or are using it to build higher level abstractions which would be
5710  * conditionally compiled if the platform matches G_OS_UNIX.
5711  *
5712  * To use these functions, you must explicitly include the
5713  * "glib-unix.h" header.
5714  */
5715
5716
5717 /**
5718  * SECTION:gurifuncs
5719  * @title: URI Functions
5720  * @short_description: manipulating URIs
5721  *
5722  * Functions for manipulating Universal Resource Identifiers (URIs) as
5723  * defined by <ulink url="http://www.ietf.org/rfc/rfc3986.txt">
5724  * RFC 3986</ulink>. It is highly recommended that you have read and
5725  * understand RFC 3986 for understanding this API.
5726  */
5727
5728
5729 /**
5730  * SECTION:gvariant
5731  * @title: GVariant
5732  * @short_description: strongly typed value datatype
5733  * @see_also: GVariantType
5734  *
5735  * #GVariant is a variant datatype; it stores a value along with
5736  * information about the type of that value.  The range of possible
5737  * values is determined by the type.  The type system used by #GVariant
5738  * is #GVariantType.
5739  *
5740  * #GVariant instances always have a type and a value (which are given
5741  * at construction time).  The type and value of a #GVariant instance
5742  * can never change other than by the #GVariant itself being
5743  * destroyed.  A #GVariant cannot contain a pointer.
5744  *
5745  * #GVariant is reference counted using g_variant_ref() and
5746  * g_variant_unref().  #GVariant also has floating reference counts --
5747  * see g_variant_ref_sink().
5748  *
5749  * #GVariant is completely threadsafe.  A #GVariant instance can be
5750  * concurrently accessed in any way from any number of threads without
5751  * problems.
5752  *
5753  * #GVariant is heavily optimised for dealing with data in serialised
5754  * form.  It works particularly well with data located in memory-mapped
5755  * files.  It can perform nearly all deserialisation operations in a
5756  * small constant time, usually touching only a single memory page.
5757  * Serialised #GVariant data can also be sent over the network.
5758  *
5759  * #GVariant is largely compatible with D-Bus.  Almost all types of
5760  * #GVariant instances can be sent over D-Bus.  See #GVariantType for
5761  * exceptions.  (However, #GVariant's serialisation format is not the same
5762  * as the serialisation format of a D-Bus message body: use #GDBusMessage,
5763  * in the gio library, for those.)
5764  *
5765  * For space-efficiency, the #GVariant serialisation format does not
5766  * automatically include the variant's type or endianness, which must
5767  * either be implied from context (such as knowledge that a particular
5768  * file format always contains a little-endian %G_VARIANT_TYPE_VARIANT)
5769  * or supplied out-of-band (for instance, a type and/or endianness
5770  * indicator could be placed at the beginning of a file, network message
5771  * or network stream).
5772  *
5773  * A #GVariant's size is limited mainly by any lower level operating
5774  * system constraints, such as the number of bits in #gsize.  For
5775  * example, it is reasonable to have a 2GB file mapped into memory
5776  * with #GMappedFile, and call g_variant_new_from_data() on it.
5777  *
5778  * For convenience to C programmers, #GVariant features powerful
5779  * varargs-based value construction and destruction.  This feature is
5780  * designed to be embedded in other libraries.
5781  *
5782  * There is a Python-inspired text language for describing #GVariant
5783  * values.  #GVariant includes a printer for this language and a parser
5784  * with type inferencing.
5785  *
5786  * <refsect2>
5787  *  <title>Memory Use</title>
5788  *  <para>
5789  *   #GVariant tries to be quite efficient with respect to memory use.
5790  *   This section gives a rough idea of how much memory is used by the
5791  *   current implementation.  The information here is subject to change
5792  *   in the future.
5793  *  </para>
5794  *  <para>
5795  *   The memory allocated by #GVariant can be grouped into 4 broad
5796  *   purposes: memory for serialised data, memory for the type
5797  *   information cache, buffer management memory and memory for the
5798  *   #GVariant structure itself.
5799  *  </para>
5800  *  <refsect3 id="gvariant-serialised-data-memory">
5801  *   <title>Serialised Data Memory</title>
5802  *   <para>
5803  *    This is the memory that is used for storing GVariant data in
5804  *    serialised form.  This is what would be sent over the network or
5805  *    what would end up on disk.
5806  *   </para>
5807  *   <para>
5808  *    The amount of memory required to store a boolean is 1 byte.  16,
5809  *    32 and 64 bit integers and double precision floating point numbers
5810  *    use their "natural" size.  Strings (including object path and
5811  *    signature strings) are stored with a nul terminator, and as such
5812  *    use the length of the string plus 1 byte.
5813  *   </para>
5814  *   <para>
5815  *    Maybe types use no space at all to represent the null value and
5816  *    use the same amount of space (sometimes plus one byte) as the
5817  *    equivalent non-maybe-typed value to represent the non-null case.
5818  *   </para>
5819  *   <para>
5820  *    Arrays use the amount of space required to store each of their
5821  *    members, concatenated.  Additionally, if the items stored in an
5822  *    array are not of a fixed-size (ie: strings, other arrays, etc)
5823  *    then an additional framing offset is stored for each item.  The
5824  *    size of this offset is either 1, 2 or 4 bytes depending on the
5825  *    overall size of the container.  Additionally, extra padding bytes
5826  *    are added as required for alignment of child values.
5827  *   </para>
5828  *   <para>
5829  *    Tuples (including dictionary entries) use the amount of space
5830  *    required to store each of their members, concatenated, plus one
5831  *    framing offset (as per arrays) for each non-fixed-sized item in
5832  *    the tuple, except for the last one.  Additionally, extra padding
5833  *    bytes are added as required for alignment of child values.
5834  *   </para>
5835  *   <para>
5836  *    Variants use the same amount of space as the item inside of the
5837  *    variant, plus 1 byte, plus the length of the type string for the
5838  *    item inside the variant.
5839  *   </para>
5840  *   <para>
5841  *    As an example, consider a dictionary mapping strings to variants.
5842  *    In the case that the dictionary is empty, 0 bytes are required for
5843  *    the serialisation.
5844  *   </para>
5845  *   <para>
5846  *    If we add an item "width" that maps to the int32 value of 500 then
5847  *    we will use 4 byte to store the int32 (so 6 for the variant
5848  *    containing it) and 6 bytes for the string.  The variant must be
5849  *    aligned to 8 after the 6 bytes of the string, so that's 2 extra
5850  *    bytes.  6 (string) + 2 (padding) + 6 (variant) is 14 bytes used
5851  *    for the dictionary entry.  An additional 1 byte is added to the
5852  *    array as a framing offset making a total of 15 bytes.
5853  *   </para>
5854  *   <para>
5855  *    If we add another entry, "title" that maps to a nullable string
5856  *    that happens to have a value of null, then we use 0 bytes for the
5857  *    null value (and 3 bytes for the variant to contain it along with
5858  *    its type string) plus 6 bytes for the string.  Again, we need 2
5859  *    padding bytes.  That makes a total of 6 + 2 + 3 = 11 bytes.
5860  *   </para>
5861  *   <para>
5862  *    We now require extra padding between the two items in the array.
5863  *    After the 14 bytes of the first item, that's 2 bytes required.  We
5864  *    now require 2 framing offsets for an extra two bytes.  14 + 2 + 11
5865  *    + 2 = 29 bytes to encode the entire two-item dictionary.
5866  *   </para>
5867  *  </refsect3>
5868  *  <refsect3>
5869  *   <title>Type Information Cache</title>
5870  *   <para>
5871  *    For each GVariant type that currently exists in the program a type
5872  *    information structure is kept in the type information cache.  The
5873  *    type information structure is required for rapid deserialisation.
5874  *   </para>
5875  *   <para>
5876  *    Continuing with the above example, if a #GVariant exists with the
5877  *    type "a{sv}" then a type information struct will exist for
5878  *    "a{sv}", "{sv}", "s", and "v".  Multiple uses of the same type
5879  *    will share the same type information.  Additionally, all
5880  *    single-digit types are stored in read-only static memory and do
5881  *    not contribute to the writable memory footprint of a program using
5882  *    #GVariant.
5883  *   </para>
5884  *   <para>
5885  *    Aside from the type information structures stored in read-only
5886  *    memory, there are two forms of type information.  One is used for
5887  *    container types where there is a single element type: arrays and
5888  *    maybe types.  The other is used for container types where there
5889  *    are multiple element types: tuples and dictionary entries.
5890  *   </para>
5891  *   <para>
5892  *    Array type info structures are 6 * sizeof (void *), plus the
5893  *    memory required to store the type string itself.  This means that
5894  *    on 32bit systems, the cache entry for "a{sv}" would require 30
5895  *    bytes of memory (plus malloc overhead).
5896  *   </para>
5897  *   <para>
5898  *    Tuple type info structures are 6 * sizeof (void *), plus 4 *
5899  *    sizeof (void *) for each item in the tuple, plus the memory
5900  *    required to store the type string itself.  A 2-item tuple, for
5901  *    example, would have a type information structure that consumed
5902  *    writable memory in the size of 14 * sizeof (void *) (plus type
5903  *    string)  This means that on 32bit systems, the cache entry for
5904  *    "{sv}" would require 61 bytes of memory (plus malloc overhead).
5905  *   </para>
5906  *   <para>
5907  *    This means that in total, for our "a{sv}" example, 91 bytes of
5908  *    type information would be allocated.
5909  *   </para>
5910  *   <para>
5911  *    The type information cache, additionally, uses a #GHashTable to
5912  *    store and lookup the cached items and stores a pointer to this
5913  *    hash table in static storage.  The hash table is freed when there
5914  *    are zero items in the type cache.
5915  *   </para>
5916  *   <para>
5917  *    Although these sizes may seem large it is important to remember
5918  *    that a program will probably only have a very small number of
5919  *    different types of values in it and that only one type information
5920  *    structure is required for many different values of the same type.
5921  *   </para>
5922  *  </refsect3>
5923  *  <refsect3>
5924  *   <title>Buffer Management Memory</title>
5925  *   <para>
5926  *    #GVariant uses an internal buffer management structure to deal
5927  *    with the various different possible sources of serialised data
5928  *    that it uses.  The buffer is responsible for ensuring that the
5929  *    correct call is made when the data is no longer in use by
5930  *    #GVariant.  This may involve a g_free() or a g_slice_free() or
5931  *    even g_mapped_file_unref().
5932  *   </para>
5933  *   <para>
5934  *    One buffer management structure is used for each chunk of
5935  *    serialised data.  The size of the buffer management structure is 4
5936  *    * (void *).  On 32bit systems, that's 16 bytes.
5937  *   </para>
5938  *  </refsect3>
5939  *  <refsect3>
5940  *   <title>GVariant structure</title>
5941  *   <para>
5942  *    The size of a #GVariant structure is 6 * (void *).  On 32 bit
5943  *    systems, that's 24 bytes.
5944  *   </para>
5945  *   <para>
5946  *    #GVariant structures only exist if they are explicitly created
5947  *    with API calls.  For example, if a #GVariant is constructed out of
5948  *    serialised data for the example given above (with the dictionary)
5949  *    then although there are 9 individual values that comprise the
5950  *    entire dictionary (two keys, two values, two variants containing
5951  *    the values, two dictionary entries, plus the dictionary itself),
5952  *    only 1 #GVariant instance exists -- the one referring to the
5953  *    dictionary.
5954  *   </para>
5955  *   <para>
5956  *    If calls are made to start accessing the other values then
5957  *    #GVariant instances will exist for those values only for as long
5958  *    as they are in use (ie: until you call g_variant_unref()).  The
5959  *    type information is shared.  The serialised data and the buffer
5960  *    management structure for that serialised data is shared by the
5961  *    child.
5962  *   </para>
5963  *  </refsect3>
5964  *  <refsect3>
5965  *   <title>Summary</title>
5966  *   <para>
5967  *    To put the entire example together, for our dictionary mapping
5968  *    strings to variants (with two entries, as given above), we are
5969  *    using 91 bytes of memory for type information, 29 byes of memory
5970  *    for the serialised data, 16 bytes for buffer management and 24
5971  *    bytes for the #GVariant instance, or a total of 160 bytes, plus
5972  *    malloc overhead.  If we were to use g_variant_get_child_value() to
5973  *    access the two dictionary entries, we would use an additional 48
5974  *    bytes.  If we were to have other dictionaries of the same type, we
5975  *    would use more memory for the serialised data and buffer
5976  *    management for those dictionaries, but the type information would
5977  *    be shared.
5978  *   </para>
5979  *  </refsect3>
5980  * </refsect2>
5981  */
5982
5983
5984 /**
5985  * SECTION:gvarianttype
5986  * @title: GVariantType
5987  * @short_description: introduction to the GVariant type system
5988  * @see_also: #GVariantType, #GVariant
5989  *
5990  * This section introduces the GVariant type system.  It is based, in
5991  * large part, on the D-Bus type system, with two major changes and some minor
5992  * lifting of restrictions.  The <ulink
5993  * url='http://dbus.freedesktop.org/doc/dbus-specification.html'>DBus
5994  * specification</ulink>, therefore, provides a significant amount of
5995  * information that is useful when working with GVariant.
5996  *
5997  * The first major change with respect to the D-Bus type system is the
5998  * introduction of maybe (or "nullable") types.  Any type in GVariant can be
5999  * converted to a maybe type, in which case, "nothing" (or "null") becomes a
6000  * valid value.  Maybe types have been added by introducing the
6001  * character "<literal>m</literal>" to type strings.
6002  *
6003  * The second major change is that the GVariant type system supports the
6004  * concept of "indefinite types" -- types that are less specific than
6005  * the normal types found in D-Bus.  For example, it is possible to speak
6006  * of "an array of any type" in GVariant, where the D-Bus type system
6007  * would require you to speak of "an array of integers" or "an array of
6008  * strings".  Indefinite types have been added by introducing the
6009  * characters "<literal>*</literal>", "<literal>?</literal>" and
6010  * "<literal>r</literal>" to type strings.
6011  *
6012  * Finally, all arbitrary restrictions relating to the complexity of
6013  * types are lifted along with the restriction that dictionary entries
6014  * may only appear nested inside of arrays.
6015  *
6016  * Just as in D-Bus, GVariant types are described with strings ("type
6017  * strings").  Subject to the differences mentioned above, these strings
6018  * are of the same form as those found in DBus.  Note, however: D-Bus
6019  * always works in terms of messages and therefore individual type
6020  * strings appear nowhere in its interface.  Instead, "signatures"
6021  * are a concatenation of the strings of the type of each argument in a
6022  * message.  GVariant deals with single values directly so GVariant type
6023  * strings always describe the type of exactly one value.  This means
6024  * that a D-Bus signature string is generally not a valid GVariant type
6025  * string -- except in the case that it is the signature of a message
6026  * containing exactly one argument.
6027  *
6028  * An indefinite type is similar in spirit to what may be called an
6029  * abstract type in other type systems.  No value can exist that has an
6030  * indefinite type as its type, but values can exist that have types
6031  * that are subtypes of indefinite types.  That is to say,
6032  * g_variant_get_type() will never return an indefinite type, but
6033  * calling g_variant_is_of_type() with an indefinite type may return
6034  * %TRUE.  For example, you cannot have a value that represents "an
6035  * array of no particular type", but you can have an "array of integers"
6036  * which certainly matches the type of "an array of no particular type",
6037  * since "array of integers" is a subtype of "array of no particular
6038  * type".
6039  *
6040  * This is similar to how instances of abstract classes may not
6041  * directly exist in other type systems, but instances of their
6042  * non-abstract subtypes may.  For example, in GTK, no object that has
6043  * the type of #GtkBin can exist (since #GtkBin is an abstract class),
6044  * but a #GtkWindow can certainly be instantiated, and you would say
6045  * that the #GtkWindow is a #GtkBin (since #GtkWindow is a subclass of
6046  * #GtkBin).
6047  *
6048  * A detailed description of GVariant type strings is given here:
6049  *
6050  * <refsect2 id='gvariant-typestrings'>
6051  *  <title>GVariant Type Strings</title>
6052  *  <para>
6053  *   A GVariant type string can be any of the following:
6054  *  </para>
6055  *  <itemizedlist>
6056  *   <listitem>
6057  *    <para>
6058  *     any basic type string (listed below)
6059  *    </para>
6060  *   </listitem>
6061  *   <listitem>
6062  *    <para>
6063  *     "<literal>v</literal>", "<literal>r</literal>" or
6064  *     "<literal>*</literal>"
6065  *    </para>
6066  *   </listitem>
6067  *   <listitem>
6068  *    <para>
6069  *     one of the characters '<literal>a</literal>' or
6070  *     '<literal>m</literal>', followed by another type string
6071  *    </para>
6072  *   </listitem>
6073  *   <listitem>
6074  *    <para>
6075  *     the character '<literal>(</literal>', followed by a concatenation
6076  *     of zero or more other type strings, followed by the character
6077  *     '<literal>)</literal>'
6078  *    </para>
6079  *   </listitem>
6080  *   <listitem>
6081  *    <para>
6082  *     the character '<literal>{</literal>', followed by a basic type
6083  *     string (see below), followed by another type string, followed by
6084  *     the character '<literal>}</literal>'
6085  *    </para>
6086  *   </listitem>
6087  *  </itemizedlist>
6088  *  <para>
6089  *   A basic type string describes a basic type (as per
6090  *   g_variant_type_is_basic()) and is always a single
6091  *   character in length.  The valid basic type strings are
6092  *   "<literal>b</literal>", "<literal>y</literal>",
6093  *   "<literal>n</literal>", "<literal>q</literal>",
6094  *   "<literal>i</literal>", "<literal>u</literal>",
6095  *   "<literal>x</literal>", "<literal>t</literal>",
6096  *   "<literal>h</literal>", "<literal>d</literal>",
6097  *   "<literal>s</literal>", "<literal>o</literal>",
6098  *   "<literal>g</literal>" and "<literal>?</literal>".
6099  *  </para>
6100  *  <para>
6101  *   The above definition is recursive to arbitrary depth.
6102  *   "<literal>aaaaai</literal>" and "<literal>(ui(nq((y)))s)</literal>"
6103  *   are both valid type strings, as is
6104  *   "<literal>a(aa(ui)(qna{ya(yd)}))</literal>".
6105  *  </para>
6106  *  <para>
6107  *   The meaning of each of the characters is as follows:
6108  *  </para>
6109  *  <informaltable>
6110  *   <tgroup cols='2'>
6111  *    <tbody>
6112  *     <row>
6113  *      <entry>
6114  *       <para>
6115  *        <emphasis role='strong'>Character</emphasis>
6116  *       </para>
6117  *      </entry>
6118  *      <entry>
6119  *       <para>
6120  *        <emphasis role='strong'>Meaning</emphasis>
6121  *       </para>
6122  *      </entry>
6123  *     </row>
6124  *     <row>
6125  *      <entry>
6126  *       <para>
6127  *        <literal>b</literal>
6128  *       </para>
6129  *      </entry>
6130  *      <entry>
6131  *       <para>
6132  *        the type string of %G_VARIANT_TYPE_BOOLEAN; a boolean value.
6133  *       </para>
6134  *      </entry>
6135  *     </row>
6136  *     <row>
6137  *      <entry>
6138  *       <para>
6139  *        <literal>y</literal>
6140  *       </para>
6141  *      </entry>
6142  *      <entry>
6143  *       <para>
6144  *        the type string of %G_VARIANT_TYPE_BYTE; a byte.
6145  *       </para>
6146  *      </entry>
6147  *     </row>
6148  *     <row>
6149  *      <entry>
6150  *       <para>
6151  *        <literal>n</literal>
6152  *       </para>
6153  *      </entry>
6154  *      <entry>
6155  *       <para>
6156  *        the type string of %G_VARIANT_TYPE_INT16; a signed 16 bit
6157  *        integer.
6158  *       </para>
6159  *      </entry>
6160  *     </row>
6161  *     <row>
6162  *      <entry>
6163  *       <para>
6164  *        <literal>q</literal>
6165  *       </para>
6166  *      </entry>
6167  *      <entry>
6168  *       <para>
6169  *        the type string of %G_VARIANT_TYPE_UINT16; an unsigned 16 bit
6170  *        integer.
6171  *       </para>
6172  *      </entry>
6173  *     </row>
6174  *     <row>
6175  *      <entry>
6176  *       <para>
6177  *        <literal>i</literal>
6178  *       </para>
6179  *      </entry>
6180  *      <entry>
6181  *       <para>
6182  *        the type string of %G_VARIANT_TYPE_INT32; a signed 32 bit
6183  *        integer.
6184  *       </para>
6185  *      </entry>
6186  *     </row>
6187  *     <row>
6188  *      <entry>
6189  *       <para>
6190  *        <literal>u</literal>
6191  *       </para>
6192  *      </entry>
6193  *      <entry>
6194  *       <para>
6195  *        the type string of %G_VARIANT_TYPE_UINT32; an unsigned 32 bit
6196  *        integer.
6197  *       </para>
6198  *      </entry>
6199  *     </row>
6200  *     <row>
6201  *      <entry>
6202  *       <para>
6203  *        <literal>x</literal>
6204  *       </para>
6205  *      </entry>
6206  *      <entry>
6207  *       <para>
6208  *        the type string of %G_VARIANT_TYPE_INT64; a signed 64 bit
6209  *        integer.
6210  *       </para>
6211  *      </entry>
6212  *     </row>
6213  *     <row>
6214  *      <entry>
6215  *       <para>
6216  *        <literal>t</literal>
6217  *       </para>
6218  *      </entry>
6219  *      <entry>
6220  *       <para>
6221  *        the type string of %G_VARIANT_TYPE_UINT64; an unsigned 64 bit
6222  *        integer.
6223  *       </para>
6224  *      </entry>
6225  *     </row>
6226  *     <row>
6227  *      <entry>
6228  *       <para>
6229  *        <literal>h</literal>
6230  *       </para>
6231  *      </entry>
6232  *      <entry>
6233  *       <para>
6234  *        the type string of %G_VARIANT_TYPE_HANDLE; a signed 32 bit
6235  *        value that, by convention, is used as an index into an array
6236  *        of file descriptors that are sent alongside a D-Bus message.
6237  *       </para>
6238  *      </entry>
6239  *     </row>
6240  *     <row>
6241  *      <entry>
6242  *       <para>
6243  *        <literal>d</literal>
6244  *       </para>
6245  *      </entry>
6246  *      <entry>
6247  *       <para>
6248  *        the type string of %G_VARIANT_TYPE_DOUBLE; a double precision
6249  *        floating point value.
6250  *       </para>
6251  *      </entry>
6252  *     </row>
6253  *     <row>
6254  *      <entry>
6255  *       <para>
6256  *        <literal>s</literal>
6257  *       </para>
6258  *      </entry>
6259  *      <entry>
6260  *       <para>
6261  *        the type string of %G_VARIANT_TYPE_STRING; a string.
6262  *       </para>
6263  *      </entry>
6264  *     </row>
6265  *     <row>
6266  *      <entry>
6267  *       <para>
6268  *        <literal>o</literal>
6269  *       </para>
6270  *      </entry>
6271  *      <entry>
6272  *       <para>
6273  *        the type string of %G_VARIANT_TYPE_OBJECT_PATH; a string in
6274  *        the form of a D-Bus object path.
6275  *       </para>
6276  *      </entry>
6277  *     </row>
6278  *     <row>
6279  *      <entry>
6280  *       <para>
6281  *        <literal>g</literal>
6282  *       </para>
6283  *      </entry>
6284  *      <entry>
6285  *       <para>
6286  *        the type string of %G_VARIANT_TYPE_STRING; a string in the
6287  *        form of a D-Bus type signature.
6288  *       </para>
6289  *      </entry>
6290  *     </row>
6291  *     <row>
6292  *      <entry>
6293  *       <para>
6294  *        <literal>?</literal>
6295  *       </para>
6296  *      </entry>
6297  *      <entry>
6298  *       <para>
6299  *        the type string of %G_VARIANT_TYPE_BASIC; an indefinite type
6300  *        that is a supertype of any of the basic types.
6301  *       </para>
6302  *      </entry>
6303  *     </row>
6304  *     <row>
6305  *      <entry>
6306  *       <para>
6307  *        <literal>v</literal>
6308  *       </para>
6309  *      </entry>
6310  *      <entry>
6311  *       <para>
6312  *        the type string of %G_VARIANT_TYPE_VARIANT; a container type
6313  *        that contain any other type of value.
6314  *       </para>
6315  *      </entry>
6316  *     </row>
6317  *     <row>
6318  *      <entry>
6319  *       <para>
6320  *        <literal>a</literal>
6321  *       </para>
6322  *      </entry>
6323  *      <entry>
6324  *       <para>
6325  *        used as a prefix on another type string to mean an array of
6326  *        that type; the type string "<literal>ai</literal>", for
6327  *        example, is the type of an array of 32 bit signed integers.
6328  *       </para>
6329  *      </entry>
6330  *     </row>
6331  *     <row>
6332  *      <entry>
6333  *       <para>
6334  *        <literal>m</literal>
6335  *       </para>
6336  *      </entry>
6337  *      <entry>
6338  *       <para>
6339  *        used as a prefix on another type string to mean a "maybe", or
6340  *        "nullable", version of that type; the type string
6341  *        "<literal>ms</literal>", for example, is the type of a value
6342  *        that maybe contains a string, or maybe contains nothing.
6343  *       </para>
6344  *      </entry>
6345  *     </row>
6346  *     <row>
6347  *      <entry>
6348  *       <para>
6349  *        <literal>()</literal>
6350  *       </para>
6351  *      </entry>
6352  *      <entry>
6353  *       <para>
6354  *        used to enclose zero or more other concatenated type strings
6355  *        to create a tuple type; the type string
6356  *        "<literal>(is)</literal>", for example, is the type of a pair
6357  *        of an integer and a string.
6358  *       </para>
6359  *      </entry>
6360  *     </row>
6361  *     <row>
6362  *      <entry>
6363  *       <para>
6364  *        <literal>r</literal>
6365  *       </para>
6366  *      </entry>
6367  *      <entry>
6368  *       <para>
6369  *        the type string of %G_VARIANT_TYPE_TUPLE; an indefinite type
6370  *        that is a supertype of any tuple type, regardless of the
6371  *        number of items.
6372  *       </para>
6373  *      </entry>
6374  *     </row>
6375  *     <row>
6376  *      <entry>
6377  *       <para>
6378  *        <literal>{}</literal>
6379  *       </para>
6380  *      </entry>
6381  *      <entry>
6382  *       <para>
6383  *        used to enclose a basic type string concatenated with another
6384  *        type string to create a dictionary entry type, which usually
6385  *        appears inside of an array to form a dictionary; the type
6386  *        string "<literal>a{sd}</literal>", for example, is the type of
6387  *        a dictionary that maps strings to double precision floating
6388  *        point values.
6389  *       </para>
6390  *       <para>
6391  *        The first type (the basic type) is the key type and the second
6392  *        type is the value type.  The reason that the first type is
6393  *        restricted to being a basic type is so that it can easily be
6394  *        hashed.
6395  *       </para>
6396  *      </entry>
6397  *     </row>
6398  *     <row>
6399  *      <entry>
6400  *       <para>
6401  *        <literal>*</literal>
6402  *       </para>
6403  *      </entry>
6404  *      <entry>
6405  *       <para>
6406  *        the type string of %G_VARIANT_TYPE_ANY; the indefinite type
6407  *        that is a supertype of all types.  Note that, as with all type
6408  *        strings, this character represents exactly one type.  It
6409  *        cannot be used inside of tuples to mean "any number of items".
6410  *       </para>
6411  *      </entry>
6412  *     </row>
6413  *    </tbody>
6414  *   </tgroup>
6415  *  </informaltable>
6416  *  <para>
6417  *   Any type string of a container that contains an indefinite type is,
6418  *   itself, an indefinite type.  For example, the type string
6419  *   "<literal>a*</literal>" (corresponding to %G_VARIANT_TYPE_ARRAY) is
6420  *   an indefinite type that is a supertype of every array type.
6421  *   "<literal>(*s)</literal>" is a supertype of all tuples that
6422  *   contain exactly two items where the second item is a string.
6423  *  </para>
6424  *  <para>
6425  *   "<literal>a{?*}</literal>" is an indefinite type that is a
6426  *   supertype of all arrays containing dictionary entries where the key
6427  *   is any basic type and the value is any type at all.  This is, by
6428  *   definition, a dictionary, so this type string corresponds to
6429  *   %G_VARIANT_TYPE_DICTIONARY.  Note that, due to the restriction that
6430  *   the key of a dictionary entry must be a basic type,
6431  *   "<literal>{**}</literal>" is not a valid type string.
6432  *  </para>
6433  * </refsect2>
6434  */
6435
6436
6437 /**
6438  * SECTION:hash_tables
6439  * @title: Hash Tables
6440  * @short_description: associations between keys and values so that given a key the value can be found quickly
6441  *
6442  * A #GHashTable provides associations between keys and values which is
6443  * optimized so that given a key, the associated value can be found
6444  * very quickly.
6445  *
6446  * Note that neither keys nor values are copied when inserted into the
6447  * #GHashTable, so they must exist for the lifetime of the #GHashTable.
6448  * This means that the use of static strings is OK, but temporary
6449  * strings (i.e. those created in buffers and those returned by GTK+
6450  * widgets) should be copied with g_strdup() before being inserted.
6451  *
6452  * If keys or values are dynamically allocated, you must be careful to
6453  * ensure that they are freed when they are removed from the
6454  * #GHashTable, and also when they are overwritten by new insertions
6455  * into the #GHashTable. It is also not advisable to mix static strings
6456  * and dynamically-allocated strings in a #GHashTable, because it then
6457  * becomes difficult to determine whether the string should be freed.
6458  *
6459  * To create a #GHashTable, use g_hash_table_new().
6460  *
6461  * To insert a key and value into a #GHashTable, use
6462  * g_hash_table_insert().
6463  *
6464  * To lookup a value corresponding to a given key, use
6465  * g_hash_table_lookup() and g_hash_table_lookup_extended().
6466  *
6467  * g_hash_table_lookup_extended() can also be used to simply
6468  * check if a key is present in the hash table.
6469  *
6470  * To remove a key and value, use g_hash_table_remove().
6471  *
6472  * To call a function for each key and value pair use
6473  * g_hash_table_foreach() or use a iterator to iterate over the
6474  * key/value pairs in the hash table, see #GHashTableIter.
6475  *
6476  * To destroy a #GHashTable use g_hash_table_destroy().
6477  *
6478  * A common use-case for hash tables is to store information about a
6479  * set of keys, without associating any particular value with each
6480  * key. GHashTable optimizes one way of doing so: If you store only
6481  * key-value pairs where key == value, then GHashTable does not
6482  * allocate memory to store the values, which can be a considerable
6483  * space saving, if your set is large. The functions
6484  * g_hash_table_add() and g_hash_table_contains() are designed to be
6485  * used when using #GHashTable this way.
6486  */
6487
6488
6489 /**
6490  * SECTION:hmac
6491  * @title: Secure HMAC Digests
6492  * @short_description: computes the HMAC for data
6493  *
6494  * HMACs should be used when producing a cookie or hash based on data
6495  * and a key. Simple mechanisms for using SHA1 and other algorithms to
6496  * digest a key and data together are vulnerable to various security
6497  * issues. <ulink url="http://en.wikipedia.org/wiki/HMAC">HMAC</ulink>
6498  * uses algorithms like SHA1 in a secure way to produce a digest of a
6499  * key and data.
6500  *
6501  * Both the key and data are arbitrary byte arrays of bytes or characters.
6502  *
6503  * Support for HMAC Digests has been added in GLib 2.30.
6504  */
6505
6506
6507 /**
6508  * SECTION:hooks
6509  * @title: Hook Functions
6510  * @short_description: support for manipulating lists of hook functions
6511  *
6512  * The #GHookList, #GHook and their related functions provide support for
6513  * lists of hook functions. Functions can be added and removed from the lists,
6514  * and the list of hook functions can be invoked.
6515  */
6516
6517
6518 /**
6519  * SECTION:i18n
6520  * @title: Internationalization
6521  * @short_description: gettext support macros
6522  * @see_also: the gettext manual
6523  *
6524  * GLib doesn't force any particular localization method upon its users.
6525  * But since GLib itself is localized using the gettext() mechanism, it seems
6526  * natural to offer the de-facto standard gettext() support macros in an
6527  * easy-to-use form.
6528  *
6529  * In order to use these macros in an application, you must include
6530  * <filename>glib/gi18n.h</filename>. For use in a library, you must include
6531  * <filename>glib/gi18n-lib.h</filename> <emphasis>after</emphasis> defining
6532  * the GETTEXT_PACKAGE macro suitably for your library:
6533  * |[
6534  * &num;define GETTEXT_PACKAGE "gtk20"
6535  * &num;include &lt;glib/gi18n-lib.h&gt;
6536  * ]|
6537  * For an application, note that you also have to call bindtextdomain(),
6538  * bind_textdomain_codeset(), textdomain() and setlocale() early on in your
6539  * main() to make gettext() work.
6540  *
6541  * For a library, you only have to call bindtextdomain() and
6542  * bind_textdomain_codeset() in your initialization function. If your library
6543  * doesn't have an initialization function, you can call the functions before
6544  * the first translated message.
6545  *
6546  * The gettext manual covers details of how to set up message extraction
6547  * with xgettext.
6548  */
6549
6550
6551 /**
6552  * SECTION:iochannels
6553  * @title: IO Channels
6554  * @short_description: portable support for using files, pipes and sockets
6555  * @see_also: <para> <variablelist> <varlistentry> <term>g_io_add_watch(), g_io_add_watch_full(), g_source_remove()</term> <listitem><para> Convenience functions for creating #GIOChannel instances and adding them to the <link linkend="glib-The-Main-Event-Loop">main event loop</link>. </para></listitem> </varlistentry> </variablelist> </para>
6556  *
6557  * The #GIOChannel data type aims to provide a portable method for
6558  * using file descriptors, pipes, and sockets, and integrating them
6559  * into the <link linkend="glib-The-Main-Event-Loop">main event
6560  * loop</link>. Currently full support is available on UNIX platforms,
6561  * support for Windows is only partially complete.
6562  *
6563  * To create a new #GIOChannel on UNIX systems use
6564  * g_io_channel_unix_new(). This works for plain file descriptors,
6565  * pipes and sockets. Alternatively, a channel can be created for a
6566  * file in a system independent manner using g_io_channel_new_file().
6567  *
6568  * Once a #GIOChannel has been created, it can be used in a generic
6569  * manner with the functions g_io_channel_read_chars(),
6570  * g_io_channel_write_chars(), g_io_channel_seek_position(), and
6571  * g_io_channel_shutdown().
6572  *
6573  * To add a #GIOChannel to the <link
6574  * linkend="glib-The-Main-Event-Loop">main event loop</link> use
6575  * g_io_add_watch() or g_io_add_watch_full(). Here you specify which
6576  * events you are interested in on the #GIOChannel, and provide a
6577  * function to be called whenever these events occur.
6578  *
6579  * #GIOChannel instances are created with an initial reference count of
6580  * 1. g_io_channel_ref() and g_io_channel_unref() can be used to
6581  * increment or decrement the reference count respectively. When the
6582  * reference count falls to 0, the #GIOChannel is freed. (Though it
6583  * isn't closed automatically, unless it was created using
6584  * g_io_channel_new_file().) Using g_io_add_watch() or
6585  * g_io_add_watch_full() increments a channel's reference count.
6586  *
6587  * The new functions g_io_channel_read_chars(),
6588  * g_io_channel_read_line(), g_io_channel_read_line_string(),
6589  * g_io_channel_read_to_end(), g_io_channel_write_chars(),
6590  * g_io_channel_seek_position(), and g_io_channel_flush() should not be
6591  * mixed with the deprecated functions g_io_channel_read(),
6592  * g_io_channel_write(), and g_io_channel_seek() on the same channel.
6593  */
6594
6595
6596 /**
6597  * SECTION:keyfile
6598  * @title: Key-value file parser
6599  * @short_description: parses .ini-like config files
6600  *
6601  * #GKeyFile lets you parse, edit or create files containing groups of
6602  * key-value pairs, which we call <firstterm>key files</firstterm> for
6603  * lack of a better name. Several freedesktop.org specifications use
6604  * key files now, e.g the
6605  * <ulink url="http://freedesktop.org/Standards/desktop-entry-spec">Desktop
6606  * Entry Specification</ulink> and the
6607  * <ulink url="http://freedesktop.org/Standards/icon-theme-spec">Icon
6608  * Theme Specification</ulink>.
6609  *
6610  * The syntax of key files is described in detail in the
6611  * <ulink url="http://freedesktop.org/Standards/desktop-entry-spec">Desktop
6612  * Entry Specification</ulink>, here is a quick summary: Key files
6613  * consists of groups of key-value pairs, interspersed with comments.
6614  *
6615  * |[
6616  * # this is just an example
6617  * # there can be comments before the first group
6618  *
6619  * [First Group]
6620  *
6621  * Name=Key File Example\tthis value shows\nescaping
6622  *
6623  * # localized strings are stored in multiple key-value pairs
6624  * Welcome=Hello
6625  * Welcome[de]=Hallo
6626  * Welcome[fr_FR]=Bonjour
6627  * Welcome[it]=Ciao
6628  * Welcome[be@latin]=Hello
6629  *
6630  * [Another Group]
6631  *
6632  * Numbers=2;20;-200;0
6633  *
6634  * Booleans=true;false;true;true
6635  * ]|
6636  *
6637  * Lines beginning with a '#' and blank lines are considered comments.
6638  *
6639  * Groups are started by a header line containing the group name enclosed
6640  * in '[' and ']', and ended implicitly by the start of the next group or
6641  * the end of the file. Each key-value pair must be contained in a group.
6642  *
6643  * Key-value pairs generally have the form <literal>key=value</literal>,
6644  * with the exception of localized strings, which have the form
6645  * <literal>key[locale]=value</literal>, with a locale identifier of the
6646  * form <literal>lang_COUNTRY@MODIFIER</literal> where
6647  * <literal>COUNTRY</literal> and <literal>MODIFIER</literal> are optional.
6648  * Space before and after the '=' character are ignored. Newline, tab,
6649  * carriage return and backslash characters in value are escaped as \n,
6650  * \t, \r, and \\, respectively. To preserve leading spaces in values,
6651  * these can also be escaped as \s.
6652  *
6653  * Key files can store strings (possibly with localized variants), integers,
6654  * booleans and lists of these. Lists are separated by a separator character,
6655  * typically ';' or ','. To use the list separator character in a value in
6656  * a list, it has to be escaped by prefixing it with a backslash.
6657  *
6658  * This syntax is obviously inspired by the .ini files commonly met
6659  * on Windows, but there are some important differences:
6660  * <itemizedlist>
6661  *   <listitem>.ini files use the ';' character to begin comments,
6662  *     key files use the '#' character.</listitem>
6663  *   <listitem>Key files do not allow for ungrouped keys meaning only
6664  *     comments can precede the first group.</listitem>
6665  *   <listitem>Key files are always encoded in UTF-8.</listitem>
6666  *   <listitem>Key and Group names are case-sensitive. For example, a
6667  *     group called <literal>[GROUP]</literal> is a different from
6668  *     <literal>[group]</literal>.</listitem>
6669  *   <listitem>.ini files don't have a strongly typed boolean entry type,
6670  *     they only have GetProfileInt(). In key files, only
6671  *     <literal>true</literal> and <literal>false</literal> (in lower case)
6672  *     are allowed.</listitem>
6673  *  </itemizedlist>
6674  *
6675  * Note that in contrast to the
6676  * <ulink url="http://freedesktop.org/Standards/desktop-entry-spec">Desktop
6677  * Entry Specification</ulink>, groups in key files may contain the same
6678  * key multiple times; the last entry wins. Key files may also contain
6679  * multiple groups with the same name; they are merged together.
6680  * Another difference is that keys and group names in key files are not
6681  * restricted to ASCII characters.
6682  */
6683
6684
6685 /**
6686  * SECTION:linked_lists_double
6687  * @title: Doubly-Linked Lists
6688  * @short_description: linked lists that can be iterated over in both directions
6689  *
6690  * The #GList structure and its associated functions provide a standard
6691  * doubly-linked list data structure.
6692  *
6693  * Each element in the list contains a piece of data, together with
6694  * pointers which link to the previous and next elements in the list.
6695  * Using these pointers it is possible to move through the list in both
6696  * directions (unlike the <link
6697  * linkend="glib-Singly-Linked-Lists">Singly-Linked Lists</link> which
6698  * only allows movement through the list in the forward direction).
6699  *
6700  * The data contained in each element can be either integer values, by
6701  * using one of the <link linkend="glib-Type-Conversion-Macros">Type
6702  * Conversion Macros</link>, or simply pointers to any type of data.
6703  *
6704  * List elements are allocated from the <link
6705  * linkend="glib-Memory-Slices">slice allocator</link>, which is more
6706  * efficient than allocating elements individually.
6707  *
6708  * Note that most of the #GList functions expect to be passed a pointer
6709  * to the first element in the list. The functions which insert
6710  * elements return the new start of the list, which may have changed.
6711  *
6712  * There is no function to create a #GList. %NULL is considered to be
6713  * the empty list so you simply set a #GList* to %NULL.
6714  *
6715  * To add elements, use g_list_append(), g_list_prepend(),
6716  * g_list_insert() and g_list_insert_sorted().
6717  *
6718  * To remove elements, use g_list_remove().
6719  *
6720  * To find elements in the list use g_list_first(), g_list_last(),
6721  * g_list_next(), g_list_previous(), g_list_nth(), g_list_nth_data(),
6722  * g_list_find() and g_list_find_custom().
6723  *
6724  * To find the index of an element use g_list_position() and
6725  * g_list_index().
6726  *
6727  * To call a function for each element in the list use g_list_foreach().
6728  *
6729  * To free the entire list, use g_list_free().
6730  */
6731
6732
6733 /**
6734  * SECTION:linked_lists_single
6735  * @title: Singly-Linked Lists
6736  * @short_description: linked lists that can be iterated in one direction
6737  *
6738  * The #GSList structure and its associated functions provide a
6739  * standard singly-linked list data structure.
6740  *
6741  * Each element in the list contains a piece of data, together with a
6742  * pointer which links to the next element in the list. Using this
6743  * pointer it is possible to move through the list in one direction
6744  * only (unlike the <link
6745  * linkend="glib-Doubly-Linked-Lists">Doubly-Linked Lists</link> which
6746  * allow movement in both directions).
6747  *
6748  * The data contained in each element can be either integer values, by
6749  * using one of the <link linkend="glib-Type-Conversion-Macros">Type
6750  * Conversion Macros</link>, or simply pointers to any type of data.
6751  *
6752  * List elements are allocated from the <link
6753  * linkend="glib-Memory-Slices">slice allocator</link>, which is more
6754  * efficient than allocating elements individually.
6755  *
6756  * Note that most of the #GSList functions expect to be passed a
6757  * pointer to the first element in the list. The functions which insert
6758  * elements return the new start of the list, which may have changed.
6759  *
6760  * There is no function to create a #GSList. %NULL is considered to be
6761  * the empty list so you simply set a #GSList* to %NULL.
6762  *
6763  * To add elements, use g_slist_append(), g_slist_prepend(),
6764  * g_slist_insert() and g_slist_insert_sorted().
6765  *
6766  * To remove elements, use g_slist_remove().
6767  *
6768  * To find elements in the list use g_slist_last(), g_slist_next(),
6769  * g_slist_nth(), g_slist_nth_data(), g_slist_find() and
6770  * g_slist_find_custom().
6771  *
6772  * To find the index of an element use g_slist_position() and
6773  * g_slist_index().
6774  *
6775  * To call a function for each element in the list use
6776  * g_slist_foreach().
6777  *
6778  * To free the entire list, use g_slist_free().
6779  */
6780
6781
6782 /**
6783  * SECTION:macros
6784  * @title: Standard Macros
6785  * @short_description: commonly-used macros
6786  *
6787  * These macros provide a few commonly-used features.
6788  */
6789
6790
6791 /**
6792  * SECTION:macros_misc
6793  * @title: Miscellaneous Macros
6794  * @short_description: specialized macros which are not used often
6795  *
6796  * These macros provide more specialized features which are not
6797  * needed so often by application programmers.
6798  */
6799
6800
6801 /**
6802  * SECTION:main
6803  * @title: The Main Event Loop
6804  * @short_description: manages all available sources of events
6805  *
6806  * The main event loop manages all the available sources of events for
6807  * GLib and GTK+ applications. These events can come from any number of
6808  * different types of sources such as file descriptors (plain files,
6809  * pipes or sockets) and timeouts. New types of event sources can also
6810  * be added using g_source_attach().
6811  *
6812  * To allow multiple independent sets of sources to be handled in
6813  * different threads, each source is associated with a #GMainContext.
6814  * A GMainContext can only be running in a single thread, but
6815  * sources can be added to it and removed from it from other threads.
6816  *
6817  * Each event source is assigned a priority. The default priority,
6818  * #G_PRIORITY_DEFAULT, is 0. Values less than 0 denote higher priorities.
6819  * Values greater than 0 denote lower priorities. Events from high priority
6820  * sources are always processed before events from lower priority sources.
6821  *
6822  * Idle functions can also be added, and assigned a priority. These will
6823  * be run whenever no events with a higher priority are ready to be processed.
6824  *
6825  * The #GMainLoop data type represents a main event loop. A GMainLoop is
6826  * created with g_main_loop_new(). After adding the initial event sources,
6827  * g_main_loop_run() is called. This continuously checks for new events from
6828  * each of the event sources and dispatches them. Finally, the processing of
6829  * an event from one of the sources leads to a call to g_main_loop_quit() to
6830  * exit the main loop, and g_main_loop_run() returns.
6831  *
6832  * It is possible to create new instances of #GMainLoop recursively.
6833  * This is often used in GTK+ applications when showing modal dialog
6834  * boxes. Note that event sources are associated with a particular
6835  * #GMainContext, and will be checked and dispatched for all main
6836  * loops associated with that GMainContext.
6837  *
6838  * GTK+ contains wrappers of some of these functions, e.g. gtk_main(),
6839  * gtk_main_quit() and gtk_events_pending().
6840  *
6841  * <refsect2><title>Creating new source types</title>
6842  * <para>One of the unusual features of the #GMainLoop functionality
6843  * is that new types of event source can be created and used in
6844  * addition to the builtin type of event source. A new event source
6845  * type is used for handling GDK events. A new source type is created
6846  * by <firstterm>deriving</firstterm> from the #GSource structure.
6847  * The derived type of source is represented by a structure that has
6848  * the #GSource structure as a first element, and other elements specific
6849  * to the new source type. To create an instance of the new source type,
6850  * call g_source_new() passing in the size of the derived structure and
6851  * a table of functions. These #GSourceFuncs determine the behavior of
6852  * the new source type.</para>
6853  * <para>New source types basically interact with the main context
6854  * in two ways. Their prepare function in #GSourceFuncs can set a timeout
6855  * to determine the maximum amount of time that the main loop will sleep
6856  * before checking the source again. In addition, or as well, the source
6857  * can add file descriptors to the set that the main context checks using
6858  * g_source_add_poll().</para>
6859  * </refsect2>
6860  * <refsect2><title>Customizing the main loop iteration</title>
6861  * <para>Single iterations of a #GMainContext can be run with
6862  * g_main_context_iteration(). In some cases, more detailed control
6863  * of exactly how the details of the main loop work is desired, for
6864  * instance, when integrating the #GMainLoop with an external main loop.
6865  * In such cases, you can call the component functions of
6866  * g_main_context_iteration() directly. These functions are
6867  * g_main_context_prepare(), g_main_context_query(),
6868  * g_main_context_check() and g_main_context_dispatch().</para>
6869  * <para>The operation of these functions can best be seen in terms
6870  * of a state diagram, as shown in <xref linkend="mainloop-states"/>.</para>
6871  * <figure id="mainloop-states"><title>States of a Main Context</title>
6872  * <graphic fileref="mainloop-states.gif" format="GIF"></graphic>
6873  * </figure>
6874  * </refsect2>
6875  *
6876  * On Unix, the GLib mainloop is incompatible with fork().  Any program
6877  * using the mainloop must either exec() or exit() from the child
6878  * without returning to the mainloop.
6879  */
6880
6881
6882 /**
6883  * SECTION:markup
6884  * @Title: Simple XML Subset Parser
6885  * @Short_description: parses a subset of XML
6886  * @See_also: <ulink url="http://www.w3.org/TR/REC-xml/">XML Specification</ulink>
6887  *
6888  * The "GMarkup" parser is intended to parse a simple markup format
6889  * that's a subset of XML. This is a small, efficient, easy-to-use
6890  * parser. It should not be used if you expect to interoperate with
6891  * other applications generating full-scale XML. However, it's very
6892  * useful for application data files, config files, etc. where you
6893  * know your application will be the only one writing the file.
6894  * Full-scale XML parsers should be able to parse the subset used by
6895  * GMarkup, so you can easily migrate to full-scale XML at a later
6896  * time if the need arises.
6897  *
6898  * GMarkup is not guaranteed to signal an error on all invalid XML;
6899  * the parser may accept documents that an XML parser would not.
6900  * However, XML documents which are not well-formed<footnote
6901  * id="wellformed">Being wellformed is a weaker condition than being
6902  * valid. See the <ulink url="http://www.w3.org/TR/REC-xml/">XML
6903  * specification</ulink> for definitions of these terms.</footnote>
6904  * are not considered valid GMarkup documents.
6905  *
6906  * Simplifications to XML include:
6907  * <itemizedlist>
6908  * <listitem>Only UTF-8 encoding is allowed</listitem>
6909  * <listitem>No user-defined entities</listitem>
6910  * <listitem>Processing instructions, comments and the doctype declaration
6911  * are "passed through" but are not interpreted in any way</listitem>
6912  * <listitem>No DTD or validation.</listitem>
6913  * </itemizedlist>
6914  *
6915  * The markup format does support:
6916  * <itemizedlist>
6917  * <listitem>Elements</listitem>
6918  * <listitem>Attributes</listitem>
6919  * <listitem>5 standard entities:
6920  *   <literal>&amp;amp; &amp;lt; &amp;gt; &amp;quot; &amp;apos;</literal>
6921  * </listitem>
6922  * <listitem>Character references</listitem>
6923  * <listitem>Sections marked as CDATA</listitem>
6924  * </itemizedlist>
6925  */
6926
6927
6928 /**
6929  * SECTION:memory
6930  * @Short_Description: general memory-handling
6931  * @Title: Memory Allocation
6932  *
6933  * These functions provide support for allocating and freeing memory.
6934  *
6935  * <note>
6936  * If any call to allocate memory fails, the application is terminated.
6937  * This also means that there is no need to check if the call succeeded.
6938  * </note>
6939  *
6940  * <note>
6941  * It's important to match g_malloc() with g_free(), plain malloc() with free(),
6942  * and (if you're using C++) new with delete and new[] with delete[]. Otherwise
6943  * bad things can happen, since these allocators may use different memory
6944  * pools (and new/delete call constructors and destructors). See also
6945  * g_mem_set_vtable().
6946  * </note>
6947  */
6948
6949
6950 /**
6951  * SECTION:memory_slices
6952  * @title: Memory Slices
6953  * @short_description: efficient way to allocate groups of equal-sized chunks of memory
6954  *
6955  * Memory slices provide a space-efficient and multi-processing scalable
6956  * way to allocate equal-sized pieces of memory, just like the original
6957  * #GMemChunks (from GLib 2.8), while avoiding their excessive
6958  * memory-waste, scalability and performance problems.
6959  *
6960  * To achieve these goals, the slice allocator uses a sophisticated,
6961  * layered design that has been inspired by Bonwick's slab allocator
6962  * <footnote><para>
6963  * <ulink url="http://citeseer.ist.psu.edu/bonwick94slab.html">[Bonwick94]</ulink> Jeff Bonwick, The slab allocator: An object-caching kernel
6964  * memory allocator. USENIX 1994, and
6965  * <ulink url="http://citeseer.ist.psu.edu/bonwick01magazines.html">[Bonwick01]</ulink> Bonwick and Jonathan Adams, Magazines and vmem: Extending the
6966  * slab allocator to many cpu's and arbitrary resources. USENIX 2001
6967  * </para></footnote>.
6968  * It uses posix_memalign() to optimize allocations of many equally-sized
6969  * chunks, and has per-thread free lists (the so-called magazine layer)
6970  * to quickly satisfy allocation requests of already known structure sizes.
6971  * This is accompanied by extra caching logic to keep freed memory around
6972  * for some time before returning it to the system. Memory that is unused
6973  * due to alignment constraints is used for cache colorization (random
6974  * distribution of chunk addresses) to improve CPU cache utilization. The
6975  * caching layer of the slice allocator adapts itself to high lock contention
6976  * to improve scalability.
6977  *
6978  * The slice allocator can allocate blocks as small as two pointers, and
6979  * unlike malloc(), it does not reserve extra space per block. For large block
6980  * sizes, g_slice_new() and g_slice_alloc() will automatically delegate to the
6981  * system malloc() implementation. For newly written code it is recommended
6982  * to use the new <literal>g_slice</literal> API instead of g_malloc() and
6983  * friends, as long as objects are not resized during their lifetime and the
6984  * object size used at allocation time is still available when freeing.
6985  *
6986  * <example>
6987  * <title>Using the slice allocator</title>
6988  * <programlisting>
6989  * gchar *mem[10000];
6990  * gint i;
6991  *
6992  * /&ast; Allocate 10000 blocks. &ast;/
6993  * for (i = 0; i &lt; 10000; i++)
6994  *   {
6995  *     mem[i] = g_slice_alloc (50);
6996  *
6997  *     /&ast; Fill in the memory with some junk. &ast;/
6998  *     for (j = 0; j &lt; 50; j++)
6999  *       mem[i][j] = i * j;
7000  *   }
7001  *
7002  * /&ast; Now free all of the blocks. &ast;/
7003  * for (i = 0; i &lt; 10000; i++)
7004  *   {
7005  *     g_slice_free1 (50, mem[i]);
7006  *   }
7007  * </programlisting></example>
7008  *
7009  * <example>
7010  * <title>Using the slice allocator with data structures</title>
7011  * <programlisting>
7012  * GRealArray *array;
7013  *
7014  * /&ast; Allocate one block, using the g_slice_new() macro. &ast;/
7015  * array = g_slice_new (GRealArray);
7016  *
7017  * /&ast; We can now use array just like a normal pointer to a structure. &ast;/
7018  * array->data            = NULL;
7019  * array->len             = 0;
7020  * array->alloc           = 0;
7021  * array->zero_terminated = (zero_terminated ? 1 : 0);
7022  * array->clear           = (clear ? 1 : 0);
7023  * array->elt_size        = elt_size;
7024  *
7025  * /&ast; We can free the block, so it can be reused. &ast;/
7026  * g_slice_free (GRealArray, array);
7027  * </programlisting></example>
7028  */
7029
7030
7031 /**
7032  * SECTION:messages
7033  * @title: Message Logging
7034  * @short_description: versatile support for logging messages with different levels of importance
7035  *
7036  * These functions provide support for logging error messages
7037  * or messages used for debugging.
7038  *
7039  * There are several built-in levels of messages, defined in
7040  * #GLogLevelFlags. These can be extended with user-defined levels.
7041  */
7042
7043
7044 /**
7045  * SECTION:misc_utils
7046  * @title: Miscellaneous Utility Functions
7047  * @short_description: a selection of portable utility functions
7048  *
7049  * These are portable utility functions.
7050  */
7051
7052
7053 /**
7054  * SECTION:numerical
7055  * @title: Numerical Definitions
7056  * @short_description: mathematical constants, and floating point decomposition
7057  *
7058  * GLib offers mathematical constants such as #G_PI for the value of pi;
7059  * many platforms have these in the C library, but some don't, the GLib
7060  * versions always exist.
7061  *
7062  * The #GFloatIEEE754 and #GDoubleIEEE754 unions are used to access the
7063  * sign, mantissa and exponent of IEEE floats and doubles. These unions are
7064  * defined as appropriate for a given platform. IEEE floats and doubles are
7065  * supported (used for storage) by at least Intel, PPC and Sparc. See
7066  * <ulink url="http://en.wikipedia.org/wiki/IEEE_float">IEEE 754-2008</ulink>
7067  * for more information about IEEE number formats.
7068  */
7069
7070
7071 /**
7072  * SECTION:option
7073  * @Short_description: parses commandline options
7074  * @Title: Commandline option parser
7075  *
7076  * The GOption commandline parser is intended to be a simpler replacement
7077  * for the popt library. It supports short and long commandline options,
7078  * as shown in the following example:
7079  *
7080  * <literal>testtreemodel -r 1 --max-size 20 --rand --display=:1.0 -vb -- file1 file2</literal>
7081  *
7082  * The example demonstrates a number of features of the GOption
7083  * commandline parser
7084  * <itemizedlist><listitem><para>
7085  *   Options can be single letters, prefixed by a single dash. Multiple
7086  *   short options can be grouped behind a single dash.
7087  * </para></listitem><listitem><para>
7088  *   Long options are prefixed by two consecutive dashes.
7089  * </para></listitem><listitem><para>
7090  *   Options can have an extra argument, which can be a number, a string or
7091  *   a filename. For long options, the extra argument can be appended with
7092  *   an equals sign after the option name, which is useful if the extra
7093  *   argument starts with a dash, which would otherwise cause it to be
7094  *   interpreted as another option.
7095  * </para></listitem><listitem><para>
7096  *   Non-option arguments are returned to the application as rest arguments.
7097  * </para></listitem><listitem><para>
7098  *   An argument consisting solely of two dashes turns off further parsing,
7099  *   any remaining arguments (even those starting with a dash) are returned
7100  *   to the application as rest arguments.
7101  * </para></listitem></itemizedlist>
7102  *
7103  * Another important feature of GOption is that it can automatically
7104  * generate nicely formatted help output. Unless it is explicitly turned
7105  * off with g_option_context_set_help_enabled(), GOption will recognize
7106  * the <option>--help</option>, <option>-?</option>,
7107  * <option>--help-all</option> and
7108  * <option>--help-</option><replaceable>groupname</replaceable> options
7109  * (where <replaceable>groupname</replaceable> is the name of a
7110  * #GOptionGroup) and write a text similar to the one shown in the
7111  * following example to stdout.
7112  *
7113  * <informalexample><screen>
7114  * Usage:
7115  *   testtreemodel [OPTION...] - test tree model performance
7116  *
7117  * Help Options:
7118  *   -h, --help               Show help options
7119  *   --help-all               Show all help options
7120  *   --help-gtk               Show GTK+ Options
7121  *
7122  * Application Options:
7123  *   -r, --repeats=N          Average over N repetitions
7124  *   -m, --max-size=M         Test up to 2^M items
7125  *   --display=DISPLAY        X display to use
7126  *   -v, --verbose            Be verbose
7127  *   -b, --beep               Beep when done
7128  *   --rand                   Randomize the data
7129  * </screen></informalexample>
7130  *
7131  * GOption groups options in #GOptionGroup<!-- -->s, which makes it easy to
7132  * incorporate options from multiple sources. The intended use for this is
7133  * to let applications collect option groups from the libraries it uses,
7134  * add them to their #GOptionContext, and parse all options by a single call
7135  * to g_option_context_parse(). See gtk_get_option_group() for an example.
7136  *
7137  * If an option is declared to be of type string or filename, GOption takes
7138  * care of converting it to the right encoding; strings are returned in
7139  * UTF-8, filenames are returned in the GLib filename encoding. Note that
7140  * this only works if setlocale() has been called before
7141  * g_option_context_parse().
7142  *
7143  * Here is a complete example of setting up GOption to parse the example
7144  * commandline above and produce the example help output.
7145  *
7146  * <informalexample><programlisting>
7147  * static gint repeats = 2;
7148  * static gint max_size = 8;
7149  * static gboolean verbose = FALSE;
7150  * static gboolean beep = FALSE;
7151  * static gboolean rand = FALSE;
7152  *
7153  * static GOptionEntry entries[] =
7154  * {
7155  *   { "repeats", 'r', 0, G_OPTION_ARG_INT, &repeats, "Average over N repetitions", "N" },
7156  *   { "max-size", 'm', 0, G_OPTION_ARG_INT, &max_size, "Test up to 2^M items", "M" },
7157  *   { "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, "Be verbose", NULL },
7158  *   { "beep", 'b', 0, G_OPTION_ARG_NONE, &beep, "Beep when done", NULL },
7159  *   { "rand", 0, 0, G_OPTION_ARG_NONE, &rand, "Randomize the data", NULL },
7160  *   { NULL }
7161  * };
7162  *
7163  * int
7164  * main (int argc, char *argv[])
7165  * {
7166  *   GError *error = NULL;
7167  *   GOptionContext *context;
7168  *
7169  *   context = g_option_context_new ("- test tree model performance");
7170  *   g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
7171  *   g_option_context_add_group (context, gtk_get_option_group (TRUE));
7172  *   if (!g_option_context_parse (context, &argc, &argv, &error))
7173  *     {
7174  *       g_print ("option parsing failed: %s\n", error->message);
7175  *       exit (1);
7176  *     }
7177  *
7178  *   /&ast; ... &ast;/
7179  *
7180  * }
7181  * </programlisting></informalexample>
7182  */
7183
7184
7185 /**
7186  * SECTION:patterns
7187  * @title: Glob-style pattern matching
7188  * @short_description: matches strings against patterns containing '*' (wildcard) and '?' (joker)
7189  *
7190  * The <function>g_pattern_match*</function> functions match a string
7191  * against a pattern containing '*' and '?' wildcards with similar
7192  * semantics as the standard glob() function: '*' matches an arbitrary,
7193  * possibly empty, string, '?' matches an arbitrary character.
7194  *
7195  * Note that in contrast to glob(), the '/' character
7196  * <emphasis>can</emphasis> be matched by the wildcards, there are no
7197  * '[...]' character ranges and '*' and '?' can
7198  * <emphasis>not</emphasis> be escaped to include them literally in a
7199  * pattern.
7200  *
7201  * When multiple strings must be matched against the same pattern, it
7202  * is better to compile the pattern to a #GPatternSpec using
7203  * g_pattern_spec_new() and use g_pattern_match_string() instead of
7204  * g_pattern_match_simple(). This avoids the overhead of repeated
7205  * pattern compilation.
7206  */
7207
7208
7209 /**
7210  * SECTION:quarks
7211  * @title: Quarks
7212  * @short_description: a 2-way association between a string and a unique integer identifier
7213  *
7214  * Quarks are associations between strings and integer identifiers.
7215  * Given either the string or the #GQuark identifier it is possible to
7216  * retrieve the other.
7217  *
7218  * Quarks are used for both <link
7219  * linkend="glib-Datasets">Datasets</link> and <link
7220  * linkend="glib-Keyed-Data-Lists">Keyed Data Lists</link>.
7221  *
7222  * To create a new quark from a string, use g_quark_from_string() or
7223  * g_quark_from_static_string().
7224  *
7225  * To find the string corresponding to a given #GQuark, use
7226  * g_quark_to_string().
7227  *
7228  * To find the #GQuark corresponding to a given string, use
7229  * g_quark_try_string().
7230  *
7231  * Another use for the string pool maintained for the quark functions
7232  * is string interning, using g_intern_string() or
7233  * g_intern_static_string(). An interned string is a canonical
7234  * representation for a string. One important advantage of interned
7235  * strings is that they can be compared for equality by a simple
7236  * pointer comparison, rather than using strcmp().
7237  */
7238
7239
7240 /**
7241  * SECTION:queue
7242  * @Title: Double-ended Queues
7243  * @Short_description: double-ended queue data structure
7244  *
7245  * The #GQueue structure and its associated functions provide a standard
7246  * queue data structure. Internally, GQueue uses the same data structure
7247  * as #GList to store elements.
7248  *
7249  * The data contained in each element can be either integer values, by
7250  * using one of the <link linkend="glib-Type-Conversion-Macros">Type
7251  * Conversion Macros</link>, or simply pointers to any type of data.
7252  *
7253  * To create a new GQueue, use g_queue_new().
7254  *
7255  * To initialize a statically-allocated GQueue, use #G_QUEUE_INIT or
7256  * g_queue_init().
7257  *
7258  * To add elements, use g_queue_push_head(), g_queue_push_head_link(),
7259  * g_queue_push_tail() and g_queue_push_tail_link().
7260  *
7261  * To remove elements, use g_queue_pop_head() and g_queue_pop_tail().
7262  *
7263  * To free the entire queue, use g_queue_free().
7264  */
7265
7266
7267 /**
7268  * SECTION:random_numbers
7269  * @title: Random Numbers
7270  * @short_description: pseudo-random number generator
7271  *
7272  * The following functions allow you to use a portable, fast and good
7273  * pseudo-random number generator (PRNG). It uses the Mersenne Twister
7274  * PRNG, which was originally developed by Makoto Matsumoto and Takuji
7275  * Nishimura. Further information can be found at
7276  * <ulink url="http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html">
7277  * http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html</ulink>.
7278  *
7279  * If you just need a random number, you simply call the
7280  * <function>g_random_*</function> functions, which will create a
7281  * globally used #GRand and use the according
7282  * <function>g_rand_*</function> functions internally. Whenever you
7283  * need a stream of reproducible random numbers, you better create a
7284  * #GRand yourself and use the <function>g_rand_*</function> functions
7285  * directly, which will also be slightly faster. Initializing a #GRand
7286  * with a certain seed will produce exactly the same series of random
7287  * numbers on all platforms. This can thus be used as a seed for e.g.
7288  * games.
7289  *
7290  * The <function>g_rand*_range</function> functions will return high
7291  * quality equally distributed random numbers, whereas for example the
7292  * <literal>(g_random_int()&percnt;max)</literal> approach often
7293  * doesn't yield equally distributed numbers.
7294  *
7295  * GLib changed the seeding algorithm for the pseudo-random number
7296  * generator Mersenne Twister, as used by
7297  * <structname>GRand</structname> and <structname>GRandom</structname>.
7298  * This was necessary, because some seeds would yield very bad
7299  * pseudo-random streams.  Also the pseudo-random integers generated by
7300  * <function>g_rand*_int_range()</function> will have a slightly better
7301  * equal distribution with the new version of GLib.
7302  *
7303  * The original seeding and generation algorithms, as found in GLib
7304  * 2.0.x, can be used instead of the new ones by setting the
7305  * environment variable <envar>G_RANDOM_VERSION</envar> to the value of
7306  * '2.0'. Use the GLib-2.0 algorithms only if you have sequences of
7307  * numbers generated with Glib-2.0 that you need to reproduce exactly.
7308  */
7309
7310
7311 /**
7312  * SECTION:scanner
7313  * @title: Lexical Scanner
7314  * @short_description: a general purpose lexical scanner
7315  *
7316  * The #GScanner and its associated functions provide a
7317  * general purpose lexical scanner.
7318  */
7319
7320
7321 /**
7322  * SECTION:sequence
7323  * @title: Sequences
7324  * @short_description: scalable lists
7325  *
7326  * The #GSequence data structure has the API of a list, but is
7327  * implemented internally with a balanced binary tree. This means that
7328  * it is possible to maintain a sorted list of n elements in time O(n
7329  * log n). The data contained in each element can be either integer
7330  * values, by using of the <link
7331  * linkend="glib-Type-Conversion-Macros">Type Conversion Macros</link>,
7332  * or simply pointers to any type of data.
7333  *
7334  * A #GSequence is accessed through <firstterm>iterators</firstterm>,
7335  * represented by a #GSequenceIter. An iterator represents a position
7336  * between two elements of the sequence. For example, the
7337  * <firstterm>begin</firstterm> iterator represents the gap immediately
7338  * before the first element of the sequence, and the
7339  * <firstterm>end</firstterm> iterator represents the gap immediately
7340  * after the last element. In an empty sequence, the begin and end
7341  * iterators are the same.
7342  *
7343  * Some methods on #GSequence operate on ranges of items. For example
7344  * g_sequence_foreach_range() will call a user-specified function on
7345  * each element with the given range. The range is delimited by the
7346  * gaps represented by the passed-in iterators, so if you pass in the
7347  * begin and end iterators, the range in question is the entire
7348  * sequence.
7349  *
7350  * The function g_sequence_get() is used with an iterator to access the
7351  * element immediately following the gap that the iterator represents.
7352  * The iterator is said to <firstterm>point</firstterm> to that element.
7353  *
7354  * Iterators are stable across most operations on a #GSequence. For
7355  * example an iterator pointing to some element of a sequence will
7356  * continue to point to that element even after the sequence is sorted.
7357  * Even moving an element to another sequence using for example
7358  * g_sequence_move_range() will not invalidate the iterators pointing
7359  * to it. The only operation that will invalidate an iterator is when
7360  * the element it points to is removed from any sequence.
7361  */
7362
7363
7364 /**
7365  * SECTION:shell
7366  * @title: Shell-related Utilities
7367  * @short_description: shell-like commandline handling
7368  */
7369
7370
7371 /**
7372  * SECTION:spawn
7373  * @Short_description: process launching
7374  * @Title: Spawning Processes
7375  */
7376
7377
7378 /**
7379  * SECTION:string_chunks
7380  * @title: String Chunks
7381  * @short_description: efficient storage of groups of strings
7382  *
7383  * String chunks are used to store groups of strings. Memory is
7384  * allocated in blocks, and as strings are added to the #GStringChunk
7385  * they are copied into the next free position in a block. When a block
7386  * is full a new block is allocated.
7387  *
7388  * When storing a large number of strings, string chunks are more
7389  * efficient than using g_strdup() since fewer calls to malloc() are
7390  * needed, and less memory is wasted in memory allocation overheads.
7391  *
7392  * By adding strings with g_string_chunk_insert_const() it is also
7393  * possible to remove duplicates.
7394  *
7395  * To create a new #GStringChunk use g_string_chunk_new().
7396  *
7397  * To add strings to a #GStringChunk use g_string_chunk_insert().
7398  *
7399  * To add strings to a #GStringChunk, but without duplicating strings
7400  * which are already in the #GStringChunk, use
7401  * g_string_chunk_insert_const().
7402  *
7403  * To free the entire #GStringChunk use g_string_chunk_free(). It is
7404  * not possible to free individual strings.
7405  */
7406
7407
7408 /**
7409  * SECTION:string_utils
7410  * @title: String Utility Functions
7411  * @short_description: various string-related functions
7412  *
7413  * This section describes a number of utility functions for creating,
7414  * duplicating, and manipulating strings.
7415  *
7416  * Note that the functions g_printf(), g_fprintf(), g_sprintf(),
7417  * g_snprintf(), g_vprintf(), g_vfprintf(), g_vsprintf() and g_vsnprintf()
7418  * are declared in the header <filename>gprintf.h</filename> which is
7419  * <emphasis>not</emphasis> included in <filename>glib.h</filename>
7420  * (otherwise using <filename>glib.h</filename> would drag in
7421  * <filename>stdio.h</filename>), so you'll have to explicitly include
7422  * <literal>&lt;glib/gprintf.h&gt;</literal> in order to use the GLib
7423  * printf() functions.
7424  *
7425  * <para id="string-precision">While you may use the printf() functions
7426  * to format UTF-8 strings, notice that the precision of a
7427  * <literal>&percnt;Ns</literal> parameter is interpreted as the
7428  * number of <emphasis>bytes</emphasis>, not <emphasis>characters</emphasis>
7429  * to print. On top of that, the GNU libc implementation of the printf()
7430  * functions has the "feature" that it checks that the string given for
7431  * the <literal>&percnt;Ns</literal> parameter consists of a whole number
7432  * of characters in the current encoding. So, unless you are sure you are
7433  * always going to be in an UTF-8 locale or your know your text is restricted
7434  * to ASCII, avoid using <literal>&percnt;Ns</literal>. If your intention is
7435  * to format strings for a certain number of columns, then
7436  * <literal>&percnt;Ns</literal> is not a correct solution anyway, since it
7437  * fails to take wide characters (see g_unichar_iswide()) into account.
7438  * </para>
7439  */
7440
7441
7442 /**
7443  * SECTION:strings
7444  * @title: Strings
7445  * @short_description: text buffers which grow automatically as text is added
7446  *
7447  * A #GString is an object that handles the memory management of a C
7448  * string for you.  The emphasis of #GString is on text, typically
7449  * UTF-8.  Crucially, the "str" member of a #GString is guaranteed to
7450  * have a trailing nul character, and it is therefore always safe to
7451  * call functions such as strchr() or g_strdup() on it.
7452  *
7453  * However, a #GString can also hold arbitrary binary data, because it
7454  * has a "len" member, which includes any possible embedded nul
7455  * characters in the data.  Conceptually then, #GString is like a
7456  * #GByteArray with the addition of many convenience methods for text,
7457  * and a guaranteed nul terminator.
7458  */
7459
7460
7461 /**
7462  * SECTION:testing
7463  * @title: Testing
7464  * @short_description: a test framework
7465  * @see_also: <link linkend="gtester">gtester</link>, <link linkend="gtester-report">gtester-report</link>
7466  *
7467  * GLib provides a framework for writing and maintaining unit tests
7468  * in parallel to the code they are testing. The API is designed according
7469  * to established concepts found in the other test frameworks (JUnit, NUnit,
7470  * RUnit), which in turn is based on smalltalk unit testing concepts.
7471  *
7472  * <variablelist>
7473  *   <varlistentry>
7474  *     <term>Test case</term>
7475  *     <listitem>Tests (test methods) are grouped together with their
7476  *       fixture into test cases.</listitem>
7477  *   </varlistentry>
7478  *   <varlistentry>
7479  *     <term>Fixture</term>
7480  *     <listitem>A test fixture consists of fixture data and setup and
7481  *       teardown methods to establish the environment for the test
7482  *       functions. We use fresh fixtures, i.e. fixtures are newly set
7483  *       up and torn down around each test invocation to avoid dependencies
7484  *       between tests.</listitem>
7485  *   </varlistentry>
7486  *   <varlistentry>
7487  *     <term>Test suite</term>
7488  *     <listitem>Test cases can be grouped into test suites, to allow
7489  *       subsets of the available tests to be run. Test suites can be
7490  *       grouped into other test suites as well.</listitem>
7491  *   </varlistentry>
7492  * </variablelist>
7493  * The API is designed to handle creation and registration of test suites
7494  * and test cases implicitly. A simple call like
7495  * |[
7496  *   g_test_add_func ("/misc/assertions", test_assertions);
7497  * ]|
7498  * creates a test suite called "misc" with a single test case named
7499  * "assertions", which consists of running the test_assertions function.
7500  *
7501  * In addition to the traditional g_assert(), the test framework provides
7502  * an extended set of assertions for string and numerical comparisons:
7503  * g_assert_cmpfloat(), g_assert_cmpint(), g_assert_cmpuint(),
7504  * g_assert_cmphex(), g_assert_cmpstr(). The advantage of these variants
7505  * over plain g_assert() is that the assertion messages can be more
7506  * elaborate, and include the values of the compared entities.
7507  *
7508  * GLib ships with two utilities called gtester and gtester-report to
7509  * facilitate running tests and producing nicely formatted test reports.
7510  */
7511
7512
7513 /**
7514  * SECTION:thread_pools
7515  * @title: Thread Pools
7516  * @short_description: pools of threads to execute work concurrently
7517  * @see_also: #GThread
7518  *
7519  * Sometimes you wish to asynchronously fork out the execution of work
7520  * and continue working in your own thread. If that will happen often,
7521  * the overhead of starting and destroying a thread each time might be
7522  * too high. In such cases reusing already started threads seems like a
7523  * good idea. And it indeed is, but implementing this can be tedious
7524  * and error-prone.
7525  *
7526  * Therefore GLib provides thread pools for your convenience. An added
7527  * advantage is, that the threads can be shared between the different
7528  * subsystems of your program, when they are using GLib.
7529  *
7530  * To create a new thread pool, you use g_thread_pool_new().
7531  * It is destroyed by g_thread_pool_free().
7532  *
7533  * If you want to execute a certain task within a thread pool,
7534  * you call g_thread_pool_push().
7535  *
7536  * To get the current number of running threads you call
7537  * g_thread_pool_get_num_threads(). To get the number of still
7538  * unprocessed tasks you call g_thread_pool_unprocessed(). To control
7539  * the maximal number of threads for a thread pool, you use
7540  * g_thread_pool_get_max_threads() and g_thread_pool_set_max_threads().
7541  *
7542  * Finally you can control the number of unused threads, that are kept
7543  * alive by GLib for future use. The current number can be fetched with
7544  * g_thread_pool_get_num_unused_threads(). The maximal number can be
7545  * controlled by g_thread_pool_get_max_unused_threads() and
7546  * g_thread_pool_set_max_unused_threads(). All currently unused threads
7547  * can be stopped by calling g_thread_pool_stop_unused_threads().
7548  */
7549
7550
7551 /**
7552  * SECTION:threads
7553  * @title: Threads
7554  * @short_description: portable support for threads, mutexes, locks, conditions and thread private data
7555  * @see_also: #GThreadPool, #GAsyncQueue
7556  *
7557  * Threads act almost like processes, but unlike processes all threads
7558  * of one process share the same memory. This is good, as it provides
7559  * easy communication between the involved threads via this shared
7560  * memory, and it is bad, because strange things (so called
7561  * "Heisenbugs") might happen if the program is not carefully designed.
7562  * In particular, due to the concurrent nature of threads, no
7563  * assumptions on the order of execution of code running in different
7564  * threads can be made, unless order is explicitly forced by the
7565  * programmer through synchronization primitives.
7566  *
7567  * The aim of the thread-related functions in GLib is to provide a
7568  * portable means for writing multi-threaded software. There are
7569  * primitives for mutexes to protect the access to portions of memory
7570  * (#GMutex, #GRecMutex and #GRWLock). There is a facility to use
7571  * individual bits for locks (g_bit_lock()). There are primitives
7572  * for condition variables to allow synchronization of threads (#GCond).
7573  * There are primitives for thread-private data - data that every
7574  * thread has a private instance of (#GPrivate). There are facilities
7575  * for one-time initialization (#GOnce, g_once_init_enter()). Finally,
7576  * there are primitives to create and manage threads (#GThread).
7577  *
7578  * The GLib threading system used to be initialized with g_thread_init().
7579  * This is no longer necessary. Since version 2.32, the GLib threading
7580  * system is automatically initialized at the start of your program,
7581  * and all thread-creation functions and synchronization primitives
7582  * are available right away.
7583  *
7584  * Note that it is not safe to assume that your program has no threads
7585  * even if you don't call g_thread_new() yourself. GLib and GIO can
7586  * and will create threads for their own purposes in some cases, such
7587  * as when using g_unix_signal_source_new() or when using GDBus.
7588  *
7589  * Originally, UNIX did not have threads, and therefore some traditional
7590  * UNIX APIs are problematic in threaded programs. Some notable examples
7591  * are
7592  * <itemizedlist>
7593  *   <listitem>
7594  *     C library functions that return data in statically allocated
7595  *     buffers, such as strtok() or strerror(). For many of these,
7596  *     there are thread-safe variants with a _r suffix, or you can
7597  *     look at corresponding GLib APIs (like g_strsplit() or g_strerror()).
7598  *   </listitem>
7599  *   <listitem>
7600  *     setenv() and unsetenv() manipulate the process environment in
7601  *     a not thread-safe way, and may interfere with getenv() calls
7602  *     in other threads. Note that getenv() calls may be
7603  *     <quote>hidden</quote> behind other APIs. For example, GNU gettext()
7604  *     calls getenv() under the covers. In general, it is best to treat
7605  *     the environment as readonly. If you absolutely have to modify the
7606  *     environment, do it early in main(), when no other threads are around yet.
7607  *   </listitem>
7608  *   <listitem>
7609  *     setlocale() changes the locale for the entire process, affecting
7610  *     all threads. Temporary changes to the locale are often made to
7611  *     change the behavior of string scanning or formatting functions
7612  *     like scanf() or printf(). GLib offers a number of string APIs
7613  *     (like g_ascii_formatd() or g_ascii_strtod()) that can often be
7614  *     used as an alternative. Or you can use the uselocale() function
7615  *     to change the locale only for the current thread.
7616  *   </listitem>
7617  *   <listitem>
7618  *     fork() only takes the calling thread into the child's copy of the
7619  *     process image.  If other threads were executing in critical
7620  *     sections they could have left mutexes locked which could easily
7621  *     cause deadlocks in the new child.  For this reason, you should
7622  *     call exit() or exec() as soon as possible in the child and only
7623  *     make signal-safe library calls before that.
7624  *   </listitem>
7625  *   <listitem>
7626  *     daemon() uses fork() in a way contrary to what is described
7627  *     above.  It should not be used with GLib programs.
7628  *   </listitem>
7629  * </itemizedlist>
7630  *
7631  * GLib itself is internally completely thread-safe (all global data is
7632  * automatically locked), but individual data structure instances are
7633  * not automatically locked for performance reasons. For example,
7634  * you must coordinate accesses to the same #GHashTable from multiple
7635  * threads. The two notable exceptions from this rule are #GMainLoop
7636  * and #GAsyncQueue, which <emphasis>are</emphasis> thread-safe and
7637  * need no further application-level locking to be accessed from
7638  * multiple threads. Most refcounting functions such as g_object_ref()
7639  * are also thread-safe.
7640  */
7641
7642
7643 /**
7644  * SECTION:timers
7645  * @title: Timers
7646  * @short_description: keep track of elapsed time
7647  *
7648  * #GTimer records a start time, and counts microseconds elapsed since
7649  * that time. This is done somewhat differently on different platforms,
7650  * and can be tricky to get exactly right, so #GTimer provides a
7651  * portable/convenient interface.
7652  */
7653
7654
7655 /**
7656  * SECTION:timezone
7657  * @title: GTimeZone
7658  * @short_description: a structure representing a time zone
7659  * @see_also: #GDateTime
7660  *
7661  * #GTimeZone is a structure that represents a time zone, at no
7662  * particular point in time.  It is refcounted and immutable.
7663  *
7664  * A time zone contains a number of intervals.  Each interval has
7665  * an abbreviation to describe it, an offet to UTC and a flag indicating
7666  * if the daylight savings time is in effect during that interval.  A
7667  * time zone always has at least one interval -- interval 0.
7668  *
7669  * Every UTC time is contained within exactly one interval, but a given
7670  * local time may be contained within zero, one or two intervals (due to
7671  * incontinuities associated with daylight savings time).
7672  *
7673  * An interval may refer to a specific period of time (eg: the duration
7674  * of daylight savings time during 2010) or it may refer to many periods
7675  * of time that share the same properties (eg: all periods of daylight
7676  * savings time).  It is also possible (usually for political reasons)
7677  * that some properties (like the abbreviation) change between intervals
7678  * without other properties changing.
7679  *
7680  * #GTimeZone is available since GLib 2.26.
7681  */
7682
7683
7684 /**
7685  * SECTION:trash_stack
7686  * @title: Trash Stacks
7687  * @short_description: maintain a stack of unused allocated memory chunks
7688  *
7689  * A #GTrashStack is an efficient way to keep a stack of unused allocated
7690  * memory chunks. Each memory chunk is required to be large enough to hold
7691  * a #gpointer. This allows the stack to be maintained without any space
7692  * overhead, since the stack pointers can be stored inside the memory chunks.
7693  *
7694  * There is no function to create a #GTrashStack. A %NULL #GTrashStack*
7695  * is a perfectly valid empty stack.
7696  */
7697
7698
7699 /**
7700  * SECTION:trees-binary
7701  * @title: Balanced Binary Trees
7702  * @short_description: a sorted collection of key/value pairs optimized for searching and traversing in order
7703  *
7704  * The #GTree structure and its associated functions provide a sorted
7705  * collection of key/value pairs optimized for searching and traversing
7706  * in order.
7707  *
7708  * To create a new #GTree use g_tree_new().
7709  *
7710  * To insert a key/value pair into a #GTree use g_tree_insert().
7711  *
7712  * To lookup the value corresponding to a given key, use
7713  * g_tree_lookup() and g_tree_lookup_extended().
7714  *
7715  * To find out the number of nodes in a #GTree, use g_tree_nnodes(). To
7716  * get the height of a #GTree, use g_tree_height().
7717  *
7718  * To traverse a #GTree, calling a function for each node visited in
7719  * the traversal, use g_tree_foreach().
7720  *
7721  * To remove a key/value pair use g_tree_remove().
7722  *
7723  * To destroy a #GTree, use g_tree_destroy().
7724  */
7725
7726
7727 /**
7728  * SECTION:trees-nary
7729  * @title: N-ary Trees
7730  * @short_description: trees of data with any number of branches
7731  *
7732  * The #GNode struct and its associated functions provide a N-ary tree
7733  * data structure, where nodes in the tree can contain arbitrary data.
7734  *
7735  * To create a new tree use g_node_new().
7736  *
7737  * To insert a node into a tree use g_node_insert(),
7738  * g_node_insert_before(), g_node_append() and g_node_prepend().
7739  *
7740  * To create a new node and insert it into a tree use
7741  * g_node_insert_data(), g_node_insert_data_after(),
7742  * g_node_insert_data_before(), g_node_append_data()
7743  * and g_node_prepend_data().
7744  *
7745  * To reverse the children of a node use g_node_reverse_children().
7746  *
7747  * To find a node use g_node_get_root(), g_node_find(),
7748  * g_node_find_child(), g_node_child_index(), g_node_child_position(),
7749  * g_node_first_child(), g_node_last_child(), g_node_nth_child(),
7750  * g_node_first_sibling(), g_node_prev_sibling(), g_node_next_sibling()
7751  * or g_node_last_sibling().
7752  *
7753  * To get information about a node or tree use G_NODE_IS_LEAF(),
7754  * G_NODE_IS_ROOT(), g_node_depth(), g_node_n_nodes(),
7755  * g_node_n_children(), g_node_is_ancestor() or g_node_max_height().
7756  *
7757  * To traverse a tree, calling a function for each node visited in the
7758  * traversal, use g_node_traverse() or g_node_children_foreach().
7759  *
7760  * To remove a node or subtree from a tree use g_node_unlink() or
7761  * g_node_destroy().
7762  */
7763
7764
7765 /**
7766  * SECTION:type_conversion
7767  * @title: Type Conversion Macros
7768  * @short_description: portably storing integers in pointer variables
7769  *
7770  * Many times GLib, GTK+, and other libraries allow you to pass "user
7771  * data" to a callback, in the form of a void pointer. From time to time
7772  * you want to pass an integer instead of a pointer. You could allocate
7773  * an integer, with something like:
7774  * |[
7775  *   int *ip = g_new (int, 1);
7776  *   *ip = 42;
7777  * ]|
7778  * But this is inconvenient, and it's annoying to have to free the
7779  * memory at some later time.
7780  *
7781  * Pointers are always at least 32 bits in size (on all platforms GLib
7782  * intends to support). Thus you can store at least 32-bit integer values
7783  * in a pointer value. Naively, you might try this, but it's incorrect:
7784  * |[
7785  *   gpointer p;
7786  *   int i;
7787  *   p = (void*) 42;
7788  *   i = (int) p;
7789  * ]|
7790  * Again, that example was <emphasis>not</emphasis> correct, don't copy it.
7791  * The problem is that on some systems you need to do this:
7792  * |[
7793  *   gpointer p;
7794  *   int i;
7795  *   p = (void*) (long) 42;
7796  *   i = (int) (long) p;
7797  * ]|
7798  * The GLib macros GPOINTER_TO_INT(), GINT_TO_POINTER(), etc. take care
7799  * to do the right thing on the every platform.
7800  *
7801  * <warning><para>You may not store pointers in integers. This is not
7802  * portable in any way, shape or form. These macros <emphasis>only</emphasis>
7803  * allow storing integers in pointers, and only preserve 32 bits of the
7804  * integer; values outside the range of a 32-bit integer will be mangled.
7805  * </para></warning>
7806  */
7807
7808
7809 /**
7810  * SECTION:types
7811  * @title: Basic Types
7812  * @short_description: standard GLib types, defined for ease-of-use and portability
7813  *
7814  * GLib defines a number of commonly used types, which can be divided
7815  * into 4 groups:
7816  * - New types which are not part of standard C (but are defined in
7817  *   various C standard library header files) - #gboolean, #gsize,
7818  *   #gssize, #goffset, #gintptr, #guintptr.
7819  * - Integer types which are guaranteed to be the same size across
7820  *   all platforms - #gint8, #guint8, #gint16, #guint16, #gint32,
7821  *   #guint32, #gint64, #guint64.
7822  * - Types which are easier to use than their standard C counterparts -
7823  *   #gpointer, #gconstpointer, #guchar, #guint, #gushort, #gulong.
7824  * - Types which correspond exactly to standard C types, but are
7825  *   included for completeness - #gchar, #gint, #gshort, #glong,
7826  *   #gfloat, #gdouble.
7827  *
7828  * GLib also defines macros for the limits of some of the standard
7829  * integer and floating point types, as well as macros for suitable
7830  * printf() formats for these types.
7831  */
7832
7833
7834 /**
7835  * SECTION:unicode
7836  * @Title: Unicode Manipulation
7837  * @Short_description: functions operating on Unicode characters and UTF-8 strings
7838  * @See_also: g_locale_to_utf8(), g_locale_from_utf8()
7839  *
7840  * This section describes a number of functions for dealing with
7841  * Unicode characters and strings.  There are analogues of the
7842  * traditional <filename>ctype.h</filename> character classification
7843  * and case conversion functions, UTF-8 analogues of some string utility
7844  * functions, functions to perform normalization, case conversion and
7845  * collation on UTF-8 strings and finally functions to convert between
7846  * the UTF-8, UTF-16 and UCS-4 encodings of Unicode.
7847  *
7848  * The implementations of the Unicode functions in GLib are based
7849  * on the Unicode Character Data tables, which are available from
7850  * <ulink url="http://www.unicode.org/">www.unicode.org</ulink>.
7851  * GLib 2.8 supports Unicode 4.0, GLib 2.10 supports Unicode 4.1,
7852  * GLib 2.12 supports Unicode 5.0, GLib 2.16.3 supports Unicode 5.1,
7853  * GLib 2.30 supports Unicode 6.0.
7854  */
7855
7856
7857 /**
7858  * SECTION:version
7859  * @Title: Version Information
7860  * @Short_description: variables and functions to check the GLib version
7861  *
7862  * GLib provides version information, primarily useful in configure
7863  * checks for builds that have a configure script. Applications will
7864  * not typically use the features described here.
7865  *
7866  * The GLib headers annotate deprecated APIs in a way that produces
7867  * compiler warnings if these deprecated APIs are used. The warnings
7868  * can be turned off by defining the macro %GLIB_DISABLE_DEPRECATION_WARNINGS
7869  * before including the glib.h header.
7870  *
7871  * GLib also provides support for building applications against
7872  * defined subsets of deprecated or new GLib APIs. Define the macro
7873  * %GLIB_VERSION_MIN_REQUIRED to specify up to what version of GLib
7874  * you want to receive warnings about deprecated APIs. Define the
7875  * macro %GLIB_VERSION_MAX_ALLOWED to specify the newest version of
7876  * GLib whose API you want to use.
7877  */
7878
7879
7880 /**
7881  * SECTION:warnings
7882  * @Title: Message Output and Debugging Functions
7883  * @Short_description: functions to output messages and help debug applications
7884  *
7885  * These functions provide support for outputting messages.
7886  *
7887  * The <function>g_return</function> family of macros (g_return_if_fail(),
7888  * g_return_val_if_fail(), g_return_if_reached(), g_return_val_if_reached())
7889  * should only be used for programming errors, a typical use case is
7890  * checking for invalid parameters at the beginning of a public function.
7891  * They should not be used if you just mean "if (error) return", they
7892  * should only be used if you mean "if (bug in program) return".
7893  * The program behavior is generally considered undefined after one
7894  * of these checks fails. They are not intended for normal control
7895  * flow, only to give a perhaps-helpful warning before giving up.
7896  */
7897
7898
7899 /**
7900  * SECTION:windows
7901  * @title: Windows Compatibility Functions
7902  * @short_description: UNIX emulation on Windows
7903  *
7904  * These functions provide some level of UNIX emulation on the
7905  * Windows platform. If your application really needs the POSIX
7906  * APIs, we suggest you try the Cygwin project.
7907  */
7908
7909
7910 /**
7911  * TRUE:
7912  *
7913  * Defines the %TRUE value for the #gboolean type.
7914  */
7915
7916
7917 /**
7918  * _:
7919  * @String: the string to be translated
7920  *
7921  * Marks a string for translation, gets replaced with the translated string
7922  * at runtime.
7923  *
7924  * Since: 2.4
7925  */
7926
7927
7928 /**
7929  * _glib_get_locale_dir:
7930  *
7931  * Return the path to the share\locale or lib\locale subfolder of the
7932  * GLib installation folder. The path is in the system codepage. We
7933  * have to use system codepage as bindtextdomain() doesn't have a
7934  * UTF-8 interface.
7935  */
7936
7937
7938 /**
7939  * g_access:
7940  * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
7941  * @mode: as in access()
7942  *
7943  * A wrapper for the POSIX access() function. This function is used to
7944  * test a pathname for one or several of read, write or execute
7945  * permissions, or just existence.
7946  *
7947  * On Windows, the file protection mechanism is not at all POSIX-like,
7948  * and the underlying function in the C library only checks the
7949  * FAT-style READONLY attribute, and does not look at the ACL of a
7950  * file at all. This function is this in practise almost useless on
7951  * Windows. Software that needs to handle file permissions on Windows
7952  * more exactly should use the Win32 API.
7953  *
7954  * See your C library manual for more details about access().
7955  *
7956  * Returns: zero if the pathname refers to an existing file system object that has all the tested permissions, or -1 otherwise or on error.
7957  * Since: 2.8
7958  */
7959
7960
7961 /**
7962  * g_array_append_val:
7963  * @a: a #GArray.
7964  * @v: the value to append to the #GArray.
7965  *
7966  * Adds the value on to the end of the array. The array will grow in
7967  * size automatically if necessary.
7968  *
7969  * <note><para>g_array_append_val() is a macro which uses a reference
7970  * to the value parameter @v. This means that you cannot use it with
7971  * literal values such as "27". You must use variables.</para></note>
7972  *
7973  * Returns: the #GArray.
7974  */
7975
7976
7977 /**
7978  * g_array_append_vals:
7979  * @array: a #GArray.
7980  * @data: a pointer to the elements to append to the end of the array.
7981  * @len: the number of elements to append.
7982  *
7983  * Adds @len elements onto the end of the array.
7984  *
7985  * Returns: the #GArray.
7986  */
7987
7988
7989 /**
7990  * g_array_free:
7991  * @array: a #GArray.
7992  * @free_segment: if %TRUE the actual element data is freed as well.
7993  *
7994  * Frees the memory allocated for the #GArray. If @free_segment is
7995  * %TRUE it frees the memory block holding the elements as well and
7996  * also each element if @array has a @element_free_func set. Pass
7997  * %FALSE if you want to free the #GArray wrapper but preserve the
7998  * underlying array for use elsewhere. If the reference count of @array
7999  * is greater than one, the #GArray wrapper is preserved but the size
8000  * of @array will be set to zero.
8001  *
8002  * <note><para>If array elements contain dynamically-allocated memory,
8003  * they should be freed separately.</para></note>
8004  *
8005  * Returns: the element data if @free_segment is %FALSE, otherwise %NULL.  The element data should be freed using g_free().
8006  */
8007
8008
8009 /**
8010  * g_array_get_element_size:
8011  * @array: A #GArray.
8012  *
8013  * Gets the size of the elements in @array.
8014  *
8015  * Returns: Size of each element, in bytes.
8016  * Since: 2.22
8017  */
8018
8019
8020 /**
8021  * g_array_index:
8022  * @a: a #GArray.
8023  * @t: the type of the elements.
8024  * @i: the index of the element to return.
8025  *
8026  * Returns the element of a #GArray at the given index. The return
8027  * value is cast to the given type.
8028  *
8029  * <example>
8030  *  <title>Getting a pointer to an element in a #GArray</title>
8031  *  <programlisting>
8032  *   EDayViewEvent *event;
8033  *   /<!-- -->* This gets a pointer to the 4th element
8034  *      in the array of EDayViewEvent structs. *<!-- -->/
8035  *   event = &amp;g_array_index (events, EDayViewEvent, 3);
8036  *  </programlisting>
8037  * </example>
8038  *
8039  * Returns: the element of the #GArray at the index given by @i.
8040  */
8041
8042
8043 /**
8044  * g_array_insert_val:
8045  * @a: a #GArray.
8046  * @i: the index to place the element at.
8047  * @v: the value to insert into the array.
8048  *
8049  * Inserts an element into an array at the given index.
8050  *
8051  * <note><para>g_array_insert_val() is a macro which uses a reference
8052  * to the value parameter @v. This means that you cannot use it with
8053  * literal values such as "27". You must use variables.</para></note>
8054  *
8055  * Returns: the #GArray.
8056  */
8057
8058
8059 /**
8060  * g_array_insert_vals:
8061  * @array: a #GArray.
8062  * @index_: the index to place the elements at.
8063  * @data: a pointer to the elements to insert.
8064  * @len: the number of elements to insert.
8065  *
8066  * Inserts @len elements into a #GArray at the given index.
8067  *
8068  * Returns: the #GArray.
8069  */
8070
8071
8072 /**
8073  * g_array_new:
8074  * @zero_terminated: %TRUE if the array should have an extra element at the end which is set to 0.
8075  * @clear_: %TRUE if #GArray elements should be automatically cleared to 0 when they are allocated.
8076  * @element_size: the size of each element in bytes.
8077  *
8078  * Creates a new #GArray with a reference count of 1.
8079  *
8080  * Returns: the new #GArray.
8081  */
8082
8083
8084 /**
8085  * g_array_prepend_val:
8086  * @a: a #GArray.
8087  * @v: the value to prepend to the #GArray.
8088  *
8089  * Adds the value on to the start of the array. The array will grow in
8090  * size automatically if necessary.
8091  *
8092  * This operation is slower than g_array_append_val() since the
8093  * existing elements in the array have to be moved to make space for
8094  * the new element.
8095  *
8096  * <note><para>g_array_prepend_val() is a macro which uses a reference
8097  * to the value parameter @v. This means that you cannot use it with
8098  * literal values such as "27". You must use variables.</para></note>
8099  *
8100  * Returns: the #GArray.
8101  */
8102
8103
8104 /**
8105  * g_array_prepend_vals:
8106  * @array: a #GArray.
8107  * @data: a pointer to the elements to prepend to the start of the array.
8108  * @len: the number of elements to prepend.
8109  *
8110  * Adds @len elements onto the start of the array.
8111  *
8112  * This operation is slower than g_array_append_vals() since the
8113  * existing elements in the array have to be moved to make space for
8114  * the new elements.
8115  *
8116  * Returns: the #GArray.
8117  */
8118
8119
8120 /**
8121  * g_array_ref:
8122  * @array: A #GArray.
8123  *
8124  * Atomically increments the reference count of @array by one. This
8125  * function is MT-safe and may be called from any thread.
8126  *
8127  * Returns: The passed in #GArray.
8128  * Since: 2.22
8129  */
8130
8131
8132 /**
8133  * g_array_remove_index:
8134  * @array: a #GArray.
8135  * @index_: the index of the element to remove.
8136  *
8137  * Removes the element at the given index from a #GArray. The following
8138  * elements are moved down one place.
8139  *
8140  * Returns: the #GArray.
8141  */
8142
8143
8144 /**
8145  * g_array_remove_index_fast:
8146  * @array: a @GArray.
8147  * @index_: the index of the element to remove.
8148  *
8149  * Removes the element at the given index from a #GArray. The last
8150  * element in the array is used to fill in the space, so this function
8151  * does not preserve the order of the #GArray. But it is faster than
8152  * g_array_remove_index().
8153  *
8154  * Returns: the #GArray.
8155  */
8156
8157
8158 /**
8159  * g_array_remove_range:
8160  * @array: a @GArray.
8161  * @index_: the index of the first element to remove.
8162  * @length: the number of elements to remove.
8163  *
8164  * Removes the given number of elements starting at the given index
8165  * from a #GArray.  The following elements are moved to close the gap.
8166  *
8167  * Returns: the #GArray.
8168  * Since: 2.4
8169  */
8170
8171
8172 /**
8173  * g_array_set_clear_func:
8174  * @array: A #GArray
8175  * @clear_func: a function to clear an element of @array
8176  *
8177  * Sets a function to clear an element of @array.
8178  *
8179  * The @clear_func will be called when an element in the array
8180  * data segment is removed and when the array is freed and data
8181  * segment is deallocated as well.
8182  *
8183  * Note that in contrast with other uses of #GDestroyNotify
8184  * functions, @clear_func is expected to clear the contents of
8185  * the array element it is given, but not free the element itself.
8186  *
8187  * Since: 2.32
8188  */
8189
8190
8191 /**
8192  * g_array_set_size:
8193  * @array: a #GArray.
8194  * @length: the new size of the #GArray.
8195  *
8196  * Sets the size of the array, expanding it if necessary. If the array
8197  * was created with @clear_ set to %TRUE, the new elements are set to 0.
8198  *
8199  * Returns: the #GArray.
8200  */
8201
8202
8203 /**
8204  * g_array_sized_new:
8205  * @zero_terminated: %TRUE if the array should have an extra element at the end with all bits cleared.
8206  * @clear_: %TRUE if all bits in the array should be cleared to 0 on allocation.
8207  * @element_size: size of each element in the array.
8208  * @reserved_size: number of elements preallocated.
8209  *
8210  * Creates a new #GArray with @reserved_size elements preallocated and
8211  * a reference count of 1. This avoids frequent reallocation, if you
8212  * are going to add many elements to the array. Note however that the
8213  * size of the array is still 0.
8214  *
8215  * Returns: the new #GArray.
8216  */
8217
8218
8219 /**
8220  * g_array_sort:
8221  * @array: a #GArray.
8222  * @compare_func: comparison function.
8223  *
8224  * Sorts a #GArray using @compare_func which should be a qsort()-style
8225  * comparison function (returns less than zero for first arg is less
8226  * than second arg, zero for equal, greater zero if first arg is
8227  * greater than second arg).
8228  *
8229  * This is guaranteed to be a stable sort since version 2.32.
8230  */
8231
8232
8233 /**
8234  * g_array_sort_with_data:
8235  * @array: a #GArray.
8236  * @compare_func: comparison function.
8237  * @user_data: data to pass to @compare_func.
8238  *
8239  * Like g_array_sort(), but the comparison function receives an extra
8240  * user data argument.
8241  *
8242  * This is guaranteed to be a stable sort since version 2.32.
8243  *
8244  * There used to be a comment here about making the sort stable by
8245  * using the addresses of the elements in the comparison function.
8246  * This did not actually work, so any such code should be removed.
8247  */
8248
8249
8250 /**
8251  * g_array_unref:
8252  * @array: A #GArray.
8253  *
8254  * Atomically decrements the reference count of @array by one. If the
8255  * reference count drops to 0, all memory allocated by the array is
8256  * released. This function is MT-safe and may be called from any
8257  * thread.
8258  *
8259  * Since: 2.22
8260  */
8261
8262
8263 /**
8264  * g_ascii_digit_value:
8265  * @c: an ASCII character.
8266  *
8267  * Determines the numeric value of a character as a decimal
8268  * digit. Differs from g_unichar_digit_value() because it takes
8269  * a char, so there's no worry about sign extension if characters
8270  * are signed.
8271  *
8272  * Returns: If @c is a decimal digit (according to g_ascii_isdigit()), its numeric value. Otherwise, -1.
8273  */
8274
8275
8276 /**
8277  * g_ascii_dtostr:
8278  * @buffer: A buffer to place the resulting string in
8279  * @buf_len: The length of the buffer.
8280  * @d: The #gdouble to convert
8281  *
8282  * Converts a #gdouble to a string, using the '.' as
8283  * decimal point.
8284  *
8285  * This functions generates enough precision that converting
8286  * the string back using g_ascii_strtod() gives the same machine-number
8287  * (on machines with IEEE compatible 64bit doubles). It is
8288  * guaranteed that the size of the resulting string will never
8289  * be larger than @G_ASCII_DTOSTR_BUF_SIZE bytes.
8290  *
8291  * Returns: The pointer to the buffer with the converted string.
8292  */
8293
8294
8295 /**
8296  * g_ascii_formatd:
8297  * @buffer: A buffer to place the resulting string in
8298  * @buf_len: The length of the buffer.
8299  * @format: The printf()-style format to use for the code to use for converting.
8300  * @d: The #gdouble to convert
8301  *
8302  * Converts a #gdouble to a string, using the '.' as
8303  * decimal point. To format the number you pass in
8304  * a printf()-style format string. Allowed conversion
8305  * specifiers are 'e', 'E', 'f', 'F', 'g' and 'G'.
8306  *
8307  * If you just want to want to serialize the value into a
8308  * string, use g_ascii_dtostr().
8309  *
8310  * Returns: The pointer to the buffer with the converted string.
8311  */
8312
8313
8314 /**
8315  * g_ascii_isalnum:
8316  * @c: any character
8317  *
8318  * Determines whether a character is alphanumeric.
8319  *
8320  * Unlike the standard C library isalnum() function, this only
8321  * recognizes standard ASCII letters and ignores the locale,
8322  * returning %FALSE for all non-ASCII characters. Also, unlike
8323  * the standard library function, this takes a <type>char</type>,
8324  * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need to
8325  * cast to #guchar before passing a possibly non-ASCII character in.
8326  *
8327  * Returns: %TRUE if @c is an ASCII alphanumeric character
8328  */
8329
8330
8331 /**
8332  * g_ascii_isalpha:
8333  * @c: any character
8334  *
8335  * Determines whether a character is alphabetic (i.e. a letter).
8336  *
8337  * Unlike the standard C library isalpha() function, this only
8338  * recognizes standard ASCII letters and ignores the locale,
8339  * returning %FALSE for all non-ASCII characters. Also, unlike
8340  * the standard library function, this takes a <type>char</type>,
8341  * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need to
8342  * cast to #guchar before passing a possibly non-ASCII character in.
8343  *
8344  * Returns: %TRUE if @c is an ASCII alphabetic character
8345  */
8346
8347
8348 /**
8349  * g_ascii_iscntrl:
8350  * @c: any character
8351  *
8352  * Determines whether a character is a control character.
8353  *
8354  * Unlike the standard C library iscntrl() function, this only
8355  * recognizes standard ASCII control characters and ignores the
8356  * locale, returning %FALSE for all non-ASCII characters. Also,
8357  * unlike the standard library function, this takes a <type>char</type>,
8358  * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need to
8359  * cast to #guchar before passing a possibly non-ASCII character in.
8360  *
8361  * Returns: %TRUE if @c is an ASCII control character.
8362  */
8363
8364
8365 /**
8366  * g_ascii_isdigit:
8367  * @c: any character
8368  *
8369  * Determines whether a character is digit (0-9).
8370  *
8371  * Unlike the standard C library isdigit() function, this takes
8372  * a <type>char</type>, not an <type>int</type>, so don't call it
8373  * on <literal>EOF</literal>, but no need to cast to #guchar before passing a possibly
8374  * non-ASCII character in.
8375  *
8376  * Returns: %TRUE if @c is an ASCII digit.
8377  */
8378
8379
8380 /**
8381  * g_ascii_isgraph:
8382  * @c: any character
8383  *
8384  * Determines whether a character is a printing character and not a space.
8385  *
8386  * Unlike the standard C library isgraph() function, this only
8387  * recognizes standard ASCII characters and ignores the locale,
8388  * returning %FALSE for all non-ASCII characters. Also, unlike
8389  * the standard library function, this takes a <type>char</type>,
8390  * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need
8391  * to cast to #guchar before passing a possibly non-ASCII character in.
8392  *
8393  * Returns: %TRUE if @c is an ASCII printing character other than space.
8394  */
8395
8396
8397 /**
8398  * g_ascii_islower:
8399  * @c: any character
8400  *
8401  * Determines whether a character is an ASCII lower case letter.
8402  *
8403  * Unlike the standard C library islower() function, this only
8404  * recognizes standard ASCII letters and ignores the locale,
8405  * returning %FALSE for all non-ASCII characters. Also, unlike
8406  * the standard library function, this takes a <type>char</type>,
8407  * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need
8408  * to worry about casting to #guchar before passing a possibly
8409  * non-ASCII character in.
8410  *
8411  * Returns: %TRUE if @c is an ASCII lower case letter
8412  */
8413
8414
8415 /**
8416  * g_ascii_isprint:
8417  * @c: any character
8418  *
8419  * Determines whether a character is a printing character.
8420  *
8421  * Unlike the standard C library isprint() function, this only
8422  * recognizes standard ASCII characters and ignores the locale,
8423  * returning %FALSE for all non-ASCII characters. Also, unlike
8424  * the standard library function, this takes a <type>char</type>,
8425  * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need
8426  * to cast to #guchar before passing a possibly non-ASCII character in.
8427  *
8428  * Returns: %TRUE if @c is an ASCII printing character.
8429  */
8430
8431
8432 /**
8433  * g_ascii_ispunct:
8434  * @c: any character
8435  *
8436  * Determines whether a character is a punctuation character.
8437  *
8438  * Unlike the standard C library ispunct() function, this only
8439  * recognizes standard ASCII letters and ignores the locale,
8440  * returning %FALSE for all non-ASCII characters. Also, unlike
8441  * the standard library function, this takes a <type>char</type>,
8442  * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need to
8443  * cast to #guchar before passing a possibly non-ASCII character in.
8444  *
8445  * Returns: %TRUE if @c is an ASCII punctuation character.
8446  */
8447
8448
8449 /**
8450  * g_ascii_isspace:
8451  * @c: any character
8452  *
8453  * Determines whether a character is a white-space character.
8454  *
8455  * Unlike the standard C library isspace() function, this only
8456  * recognizes standard ASCII white-space and ignores the locale,
8457  * returning %FALSE for all non-ASCII characters. Also, unlike
8458  * the standard library function, this takes a <type>char</type>,
8459  * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need to
8460  * cast to #guchar before passing a possibly non-ASCII character in.
8461  *
8462  * Returns: %TRUE if @c is an ASCII white-space character
8463  */
8464
8465
8466 /**
8467  * g_ascii_isupper:
8468  * @c: any character
8469  *
8470  * Determines whether a character is an ASCII upper case letter.
8471  *
8472  * Unlike the standard C library isupper() function, this only
8473  * recognizes standard ASCII letters and ignores the locale,
8474  * returning %FALSE for all non-ASCII characters. Also, unlike
8475  * the standard library function, this takes a <type>char</type>,
8476  * not an <type>int</type>, so don't call it on <literal>EOF</literal>, but no need to
8477  * worry about casting to #guchar before passing a possibly non-ASCII
8478  * character in.
8479  *
8480  * Returns: %TRUE if @c is an ASCII upper case letter
8481  */
8482
8483
8484 /**
8485  * g_ascii_isxdigit:
8486  * @c: any character
8487  *
8488  * Determines whether a character is a hexadecimal-digit character.
8489  *
8490  * Unlike the standard C library isxdigit() function, this takes
8491  * a <type>char</type>, not an <type>int</type>, so don't call it
8492  * on <literal>EOF</literal>, but no need to cast to #guchar before passing a
8493  * possibly non-ASCII character in.
8494  *
8495  * Returns: %TRUE if @c is an ASCII hexadecimal-digit character.
8496  */
8497
8498
8499 /**
8500  * g_ascii_strcasecmp:
8501  * @s1: string to compare with @s2.
8502  * @s2: string to compare with @s1.
8503  *
8504  * Compare two strings, ignoring the case of ASCII characters.
8505  *
8506  * Unlike the BSD strcasecmp() function, this only recognizes standard
8507  * ASCII letters and ignores the locale, treating all non-ASCII
8508  * bytes as if they are not letters.
8509  *
8510  * This function should be used only on strings that are known to be
8511  * in encodings where the bytes corresponding to ASCII letters always
8512  * represent themselves. This includes UTF-8 and the ISO-8859-*
8513  * charsets, but not for instance double-byte encodings like the
8514  * Windows Codepage 932, where the trailing bytes of double-byte
8515  * characters include all ASCII letters. If you compare two CP932
8516  * strings using this function, you will get false matches.
8517  *
8518  * Returns: 0 if the strings match, a negative value if @s1 &lt; @s2, or a positive value if @s1 &gt; @s2.
8519  */
8520
8521
8522 /**
8523  * g_ascii_strdown:
8524  * @str: a string.
8525  * @len: length of @str in bytes, or -1 if @str is nul-terminated.
8526  *
8527  * Converts all upper case ASCII letters to lower case ASCII letters.
8528  *
8529  * Returns: a newly-allocated string, with all the upper case characters in @str converted to lower case, with semantics that exactly match g_ascii_tolower(). (Note that this is unlike the old g_strdown(), which modified the string in place.)
8530  */
8531
8532
8533 /**
8534  * g_ascii_strncasecmp:
8535  * @s1: string to compare with @s2.
8536  * @s2: string to compare with @s1.
8537  * @n: number of characters to compare.
8538  *
8539  * Compare @s1 and @s2, ignoring the case of ASCII characters and any
8540  * characters after the first @n in each string.
8541  *
8542  * Unlike the BSD strcasecmp() function, this only recognizes standard
8543  * ASCII letters and ignores the locale, treating all non-ASCII
8544  * characters as if they are not letters.
8545  *
8546  * The same warning as in g_ascii_strcasecmp() applies: Use this
8547  * function only on strings known to be in encodings where bytes
8548  * corresponding to ASCII letters always represent themselves.
8549  *
8550  * Returns: 0 if the strings match, a negative value if @s1 &lt; @s2, or a positive value if @s1 &gt; @s2.
8551  */
8552
8553
8554 /**
8555  * g_ascii_strtod:
8556  * @nptr: the string to convert to a numeric value.
8557  * @endptr: if non-%NULL, it returns the character after the last character used in the conversion.
8558  *
8559  * Converts a string to a #gdouble value.
8560  *
8561  * This function behaves like the standard strtod() function
8562  * does in the C locale. It does this without actually changing
8563  * the current locale, since that would not be thread-safe.
8564  * A limitation of the implementation is that this function
8565  * will still accept localized versions of infinities and NANs.
8566  *
8567  * This function is typically used when reading configuration
8568  * files or other non-user input that should be locale independent.
8569  * To handle input from the user you should normally use the
8570  * locale-sensitive system strtod() function.
8571  *
8572  * To convert from a #gdouble to a string in a locale-insensitive
8573  * way, use g_ascii_dtostr().
8574  *
8575  * If the correct value would cause overflow, plus or minus <literal>HUGE_VAL</literal>
8576  * is returned (according to the sign of the value), and <literal>ERANGE</literal> is
8577  * stored in <literal>errno</literal>. If the correct value would cause underflow,
8578  * zero is returned and <literal>ERANGE</literal> is stored in <literal>errno</literal>.
8579  *
8580  * This function resets <literal>errno</literal> before calling strtod() so that
8581  * you can reliably detect overflow and underflow.
8582  *
8583  * Returns: the #gdouble value.
8584  */
8585
8586
8587 /**
8588  * g_ascii_strtoll:
8589  * @nptr: the string to convert to a numeric value.
8590  * @endptr: if non-%NULL, it returns the character after the last character used in the conversion.
8591  * @base: to be used for the conversion, 2..36 or 0
8592  *
8593  * Converts a string to a #gint64 value.
8594  * This function behaves like the standard strtoll() function
8595  * does in the C locale. It does this without actually
8596  * changing the current locale, since that would not be
8597  * thread-safe.
8598  *
8599  * This function is typically used when reading configuration
8600  * files or other non-user input that should be locale independent.
8601  * To handle input from the user you should normally use the
8602  * locale-sensitive system strtoll() function.
8603  *
8604  * If the correct value would cause overflow, %G_MAXINT64 or %G_MININT64
8605  * is returned, and <literal>ERANGE</literal> is stored in <literal>errno</literal>.
8606  * If the base is outside the valid range, zero is returned, and
8607  * <literal>EINVAL</literal> is stored in <literal>errno</literal>. If the
8608  * string conversion fails, zero is returned, and @endptr returns @nptr
8609  * (if @endptr is non-%NULL).
8610  *
8611  * Returns: the #gint64 value or zero on error.
8612  * Since: 2.12
8613  */
8614
8615
8616 /**
8617  * g_ascii_strtoull:
8618  * @nptr: the string to convert to a numeric value.
8619  * @endptr: if non-%NULL, it returns the character after the last character used in the conversion.
8620  * @base: to be used for the conversion, 2..36 or 0
8621  *
8622  * Converts a string to a #guint64 value.
8623  * This function behaves like the standard strtoull() function
8624  * does in the C locale. It does this without actually
8625  * changing the current locale, since that would not be
8626  * thread-safe.
8627  *
8628  * This function is typically used when reading configuration
8629  * files or other non-user input that should be locale independent.
8630  * To handle input from the user you should normally use the
8631  * locale-sensitive system strtoull() function.
8632  *
8633  * If the correct value would cause overflow, %G_MAXUINT64
8634  * is returned, and <literal>ERANGE</literal> is stored in <literal>errno</literal>.
8635  * If the base is outside the valid range, zero is returned, and
8636  * <literal>EINVAL</literal> is stored in <literal>errno</literal>.
8637  * If the string conversion fails, zero is returned, and @endptr returns
8638  * @nptr (if @endptr is non-%NULL).
8639  *
8640  * Returns: the #guint64 value or zero on error.
8641  * Since: 2.2
8642  */
8643
8644
8645 /**
8646  * g_ascii_strup:
8647  * @str: a string.
8648  * @len: length of @str in bytes, or -1 if @str is nul-terminated.
8649  *
8650  * Converts all lower case ASCII letters to upper case ASCII letters.
8651  *
8652  * Returns: a newly allocated string, with all the lower case characters in @str converted to upper case, with semantics that exactly match g_ascii_toupper(). (Note that this is unlike the old g_strup(), which modified the string in place.)
8653  */
8654
8655
8656 /**
8657  * g_ascii_tolower:
8658  * @c: any character.
8659  *
8660  * Convert a character to ASCII lower case.
8661  *
8662  * Unlike the standard C library tolower() function, this only
8663  * recognizes standard ASCII letters and ignores the locale, returning
8664  * all non-ASCII characters unchanged, even if they are lower case
8665  * letters in a particular character set. Also unlike the standard
8666  * library function, this takes and returns a char, not an int, so
8667  * don't call it on <literal>EOF</literal> but no need to worry about casting to #guchar
8668  * before passing a possibly non-ASCII character in.
8669  *
8670  * Returns: the result of converting @c to lower case. If @c is not an ASCII upper case letter, @c is returned unchanged.
8671  */
8672
8673
8674 /**
8675  * g_ascii_toupper:
8676  * @c: any character.
8677  *
8678  * Convert a character to ASCII upper case.
8679  *
8680  * Unlike the standard C library toupper() function, this only
8681  * recognizes standard ASCII letters and ignores the locale, returning
8682  * all non-ASCII characters unchanged, even if they are upper case
8683  * letters in a particular character set. Also unlike the standard
8684  * library function, this takes and returns a char, not an int, so
8685  * don't call it on <literal>EOF</literal> but no need to worry about casting to #guchar
8686  * before passing a possibly non-ASCII character in.
8687  *
8688  * Returns: the result of converting @c to upper case. If @c is not an ASCII lower case letter, @c is returned unchanged.
8689  */
8690
8691
8692 /**
8693  * g_ascii_xdigit_value:
8694  * @c: an ASCII character.
8695  *
8696  * Determines the numeric value of a character as a hexidecimal
8697  * digit. Differs from g_unichar_xdigit_value() because it takes
8698  * a char, so there's no worry about sign extension if characters
8699  * are signed.
8700  *
8701  * Returns: If @c is a hex digit (according to g_ascii_isxdigit()), its numeric value. Otherwise, -1.
8702  */
8703
8704
8705 /**
8706  * g_assert:
8707  * @expr: the expression to check
8708  *
8709  * Debugging macro to terminate the application if the assertion
8710  * fails. If the assertion fails (i.e. the expression is not true),
8711  * an error message is logged and the application is terminated.
8712  *
8713  * The macro can be turned off in final releases of code by defining
8714  * <envar>G_DISABLE_ASSERT</envar> when compiling the application.
8715  */
8716
8717
8718 /**
8719  * g_assert_cmpfloat:
8720  * @n1: an floating point number
8721  * @cmp: The comparison operator to use. One of ==, !=, &lt;, &gt;, &lt;=, &gt;=.
8722  * @n2: another floating point number
8723  *
8724  * Debugging macro to compare two floating point numbers.
8725  *
8726  * The effect of <literal>g_assert_cmpfloat (n1, op, n2)</literal> is
8727  * the same as <literal>g_assert_true (n1 op n2)</literal>. The advantage
8728  * of this macro is that it can produce a message that includes the
8729  * actual values of @n1 and @n2.
8730  *
8731  * Since: 2.16
8732  */
8733
8734
8735 /**
8736  * g_assert_cmphex:
8737  * @n1: an unsigned integer
8738  * @cmp: The comparison operator to use. One of ==, !=, &lt;, &gt;, &lt;=, &gt;=.
8739  * @n2: another unsigned integer
8740  *
8741  * Debugging macro to compare to unsigned integers.
8742  *
8743  * This is a variant of g_assert_cmpuint() that displays the numbers
8744  * in hexadecimal notation in the message.
8745  *
8746  * Since: 2.16
8747  */
8748
8749
8750 /**
8751  * g_assert_cmpint:
8752  * @n1: an integer
8753  * @cmp: The comparison operator to use. One of ==, !=, &lt;, &gt;, &lt;=, &gt;=.
8754  * @n2: another integer
8755  *
8756  * Debugging macro to compare two integers.
8757  *
8758  * The effect of <literal>g_assert_cmpint (n1, op, n2)</literal> is
8759  * the same as <literal>g_assert_true (n1 op n2)</literal>. The advantage
8760  * of this macro is that it can produce a message that includes the
8761  * actual values of @n1 and @n2.
8762  *
8763  * Since: 2.16
8764  */
8765
8766
8767 /**
8768  * g_assert_cmpstr:
8769  * @s1: a string (may be %NULL)
8770  * @cmp: The comparison operator to use. One of ==, !=, &lt;, &gt;, &lt;=, &gt;=.
8771  * @s2: another string (may be %NULL)
8772  *
8773  * Debugging macro to compare two strings. If the comparison fails,
8774  * an error message is logged and the application is either terminated
8775  * or the testcase marked as failed.
8776  * The strings are compared using g_strcmp0().
8777  *
8778  * The effect of <literal>g_assert_cmpstr (s1, op, s2)</literal> is
8779  * the same as <literal>g_assert_true (g_strcmp0 (s1, s2) op 0)</literal>.
8780  * The advantage of this macro is that it can produce a message that
8781  * includes the actual values of @s1 and @s2.
8782  *
8783  * |[
8784  *   g_assert_cmpstr (mystring, ==, "fubar");
8785  * ]|
8786  *
8787  * Since: 2.16
8788  */
8789
8790
8791 /**
8792  * g_assert_cmpuint:
8793  * @n1: an unsigned integer
8794  * @cmp: The comparison operator to use. One of ==, !=, &lt;, &gt;, &lt;=, &gt;=.
8795  * @n2: another unsigned integer
8796  *
8797  * Debugging macro to compare two unsigned integers.
8798  *
8799  * The effect of <literal>g_assert_cmpuint (n1, op, n2)</literal> is
8800  * the same as <literal>g_assert_true (n1 op n2)</literal>. The advantage
8801  * of this macro is that it can produce a message that includes the
8802  * actual values of @n1 and @n2.
8803  *
8804  * Since: 2.16
8805  */
8806
8807
8808 /**
8809  * g_assert_error:
8810  * @err: a #GError, possibly %NULL
8811  * @dom: the expected error domain (a #GQuark)
8812  * @c: the expected error code
8813  *
8814  * Debugging macro to check that a method has returned
8815  * the correct #GError.
8816  *
8817  * The effect of <literal>g_assert_error (err, dom, c)</literal> is
8818  * the same as <literal>g_assert_true (err != NULL &amp;&amp; err->domain
8819  * == dom &amp;&amp; err->code == c)</literal>. The advantage of this
8820  * macro is that it can produce a message that includes the incorrect
8821  * error message and code.
8822  *
8823  * This can only be used to test for a specific error. If you want to
8824  * test that @err is set, but don't care what it's set to, just use
8825  * <literal>g_assert (err != NULL)</literal>
8826  *
8827  * Since: 2.20
8828  */
8829
8830
8831 /**
8832  * g_assert_false:
8833  * @expr: the expression to check
8834  *
8835  * Debugging macro to check an expression is false.
8836  *
8837  * If the assertion fails (i.e. the expression is not false),
8838  * an error message is logged and the application is either
8839  * terminated or the testcase marked as failed.
8840  *
8841  * See g_test_set_nonfatal_assertions().
8842  *
8843  * Since: 2.38
8844  */
8845
8846
8847 /**
8848  * g_assert_no_error:
8849  * @err: a #GError, possibly %NULL
8850  *
8851  * Debugging macro to check that a #GError is not set.
8852  *
8853  * The effect of <literal>g_assert_no_error (err)</literal> is
8854  * the same as <literal>g_assert_true (err == NULL)</literal>. The advantage
8855  * of this macro is that it can produce a message that includes
8856  * the error message and code.
8857  *
8858  * Since: 2.20
8859  */
8860
8861
8862 /**
8863  * g_assert_not_reached:
8864  *
8865  * Debugging macro to terminate the application if it is ever
8866  * reached. If it is reached, an error message is logged and the
8867  * application is terminated.
8868  *
8869  * The macro can be turned off in final releases of code by defining
8870  * <envar>G_DISABLE_ASSERT</envar> when compiling the application.
8871  */
8872
8873
8874 /**
8875  * g_assert_null:
8876  * @expr: the expression to check
8877  *
8878  * Debugging macro to check an expression is %NULL.
8879  *
8880  * If the assertion fails (i.e. the expression is not %NULL),
8881  * an error message is logged and the application is either
8882  * terminated or the testcase marked as failed.
8883  *
8884  * See g_test_set_nonfatal_assertions().
8885  *
8886  * Since: 2.38
8887  */
8888
8889
8890 /**
8891  * g_assert_true:
8892  * @expr: the expression to check
8893  *
8894  * Debugging macro to check that an expression is true.
8895  *
8896  * If the assertion fails (i.e. the expression is not true),
8897  * an error message is logged and the application is either
8898  * terminated or the testcase marked as failed.
8899  *
8900  * See g_test_set_nonfatal_assertions().
8901  *
8902  * Since: 2.38
8903  */
8904
8905
8906 /**
8907  * g_async_queue_length:
8908  * @queue: a #GAsyncQueue.
8909  *
8910  * Returns the length of the queue.
8911  *
8912  * Actually this function returns the number of data items in
8913  * the queue minus the number of waiting threads, so a negative
8914  * value means waiting threads, and a positive value means available
8915  * entries in the @queue. A return value of 0 could mean n entries
8916  * in the queue and n threads waiting. This can happen due to locking
8917  * of the queue or due to scheduling.
8918  *
8919  * Returns: the length of the @queue
8920  */
8921
8922
8923 /**
8924  * g_async_queue_length_unlocked:
8925  * @queue: a #GAsyncQueue
8926  *
8927  * Returns the length of the queue.
8928  *
8929  * Actually this function returns the number of data items in
8930  * the queue minus the number of waiting threads, so a negative
8931  * value means waiting threads, and a positive value means available
8932  * entries in the @queue. A return value of 0 could mean n entries
8933  * in the queue and n threads waiting. This can happen due to locking
8934  * of the queue or due to scheduling.
8935  *
8936  * This function must be called while holding the @queue's lock.
8937  *
8938  * Returns: the length of the @queue.
8939  */
8940
8941
8942 /**
8943  * g_async_queue_lock:
8944  * @queue: a #GAsyncQueue
8945  *
8946  * Acquires the @queue's lock. If another thread is already
8947  * holding the lock, this call will block until the lock
8948  * becomes available.
8949  *
8950  * Call g_async_queue_unlock() to drop the lock again.
8951  *
8952  * While holding the lock, you can only call the
8953  * <function>g_async_queue_*_unlocked()</function> functions
8954  * on @queue. Otherwise, deadlock may occur.
8955  */
8956
8957
8958 /**
8959  * g_async_queue_new:
8960  *
8961  * Creates a new asynchronous queue.
8962  *
8963  * Returns: a new #GAsyncQueue. Free with g_async_queue_unref()
8964  */
8965
8966
8967 /**
8968  * g_async_queue_new_full:
8969  * @item_free_func: function to free queue elements
8970  *
8971  * Creates a new asynchronous queue and sets up a destroy notify
8972  * function that is used to free any remaining queue items when
8973  * the queue is destroyed after the final unref.
8974  *
8975  * Returns: a new #GAsyncQueue. Free with g_async_queue_unref()
8976  * Since: 2.16
8977  */
8978
8979
8980 /**
8981  * g_async_queue_pop:
8982  * @queue: a #GAsyncQueue
8983  *
8984  * Pops data from the @queue. If @queue is empty, this function
8985  * blocks until data becomes available.
8986  *
8987  * Returns: data from the queue
8988  */
8989
8990
8991 /**
8992  * g_async_queue_pop_unlocked:
8993  * @queue: a #GAsyncQueue
8994  *
8995  * Pops data from the @queue. If @queue is empty, this function
8996  * blocks until data becomes available.
8997  *
8998  * This function must be called while holding the @queue's lock.
8999  *
9000  * Returns: data from the queue.
9001  */
9002
9003
9004 /**
9005  * g_async_queue_push:
9006  * @queue: a #GAsyncQueue
9007  * @data: @data to push into the @queue
9008  *
9009  * Pushes the @data into the @queue. @data must not be %NULL.
9010  */
9011
9012
9013 /**
9014  * g_async_queue_push_sorted:
9015  * @queue: a #GAsyncQueue
9016  * @data: the @data to push into the @queue
9017  * @func: the #GCompareDataFunc is used to sort @queue
9018  * @user_data: user data passed to @func.
9019  *
9020  * Inserts @data into @queue using @func to determine the new
9021  * position.
9022  *
9023  * This function requires that the @queue is sorted before pushing on
9024  * new elements, see g_async_queue_sort().
9025  *
9026  * This function will lock @queue before it sorts the queue and unlock
9027  * it when it is finished.
9028  *
9029  * For an example of @func see g_async_queue_sort().
9030  *
9031  * Since: 2.10
9032  */
9033
9034
9035 /**
9036  * g_async_queue_push_sorted_unlocked:
9037  * @queue: a #GAsyncQueue
9038  * @data: the @data to push into the @queue
9039  * @func: the #GCompareDataFunc is used to sort @queue
9040  * @user_data: user data passed to @func.
9041  *
9042  * Inserts @data into @queue using @func to determine the new
9043  * position.
9044  *
9045  * The sort function @func is passed two elements of the @queue.
9046  * It should return 0 if they are equal, a negative value if the
9047  * first element should be higher in the @queue or a positive value
9048  * if the first element should be lower in the @queue than the second
9049  * element.
9050  *
9051  * This function requires that the @queue is sorted before pushing on
9052  * new elements, see g_async_queue_sort().
9053  *
9054  * This function must be called while holding the @queue's lock.
9055  *
9056  * For an example of @func see g_async_queue_sort().
9057  *
9058  * Since: 2.10
9059  */
9060
9061
9062 /**
9063  * g_async_queue_push_unlocked:
9064  * @queue: a #GAsyncQueue
9065  * @data: @data to push into the @queue
9066  *
9067  * Pushes the @data into the @queue. @data must not be %NULL.
9068  *
9069  * This function must be called while holding the @queue's lock.
9070  */
9071
9072
9073 /**
9074  * g_async_queue_ref:
9075  * @queue: a #GAsyncQueue
9076  *
9077  * Increases the reference count of the asynchronous @queue by 1.
9078  * You do not need to hold the lock to call this function.
9079  *
9080  * Returns: the @queue that was passed in (since 2.6)
9081  */
9082
9083
9084 /**
9085  * g_async_queue_ref_unlocked:
9086  * @queue: a #GAsyncQueue
9087  *
9088  * Increases the reference count of the asynchronous @queue by 1.
9089  *
9090  * Deprecated: 2.8: Reference counting is done atomically. so g_async_queue_ref() can be used regardless of the @queue's lock.
9091  */
9092
9093
9094 /**
9095  * g_async_queue_sort:
9096  * @queue: a #GAsyncQueue
9097  * @func: the #GCompareDataFunc is used to sort @queue
9098  * @user_data: user data passed to @func
9099  *
9100  * Sorts @queue using @func.
9101  *
9102  * The sort function @func is passed two elements of the @queue.
9103  * It should return 0 if they are equal, a negative value if the
9104  * first element should be higher in the @queue or a positive value
9105  * if the first element should be lower in the @queue than the second
9106  * element.
9107  *
9108  * This function will lock @queue before it sorts the queue and unlock
9109  * it when it is finished.
9110  *
9111  * If you were sorting a list of priority numbers to make sure the
9112  * lowest priority would be at the top of the queue, you could use:
9113  * |[
9114  *  gint32 id1;
9115  *  gint32 id2;
9116  *
9117  *  id1 = GPOINTER_TO_INT (element1);
9118  *  id2 = GPOINTER_TO_INT (element2);
9119  *
9120  *  return (id1 > id2 ? +1 : id1 == id2 ? 0 : -1);
9121  * ]|
9122  *
9123  * Since: 2.10
9124  */
9125
9126
9127 /**
9128  * g_async_queue_sort_unlocked:
9129  * @queue: a #GAsyncQueue
9130  * @func: the #GCompareDataFunc is used to sort @queue
9131  * @user_data: user data passed to @func
9132  *
9133  * Sorts @queue using @func.
9134  *
9135  * The sort function @func is passed two elements of the @queue.
9136  * It should return 0 if they are equal, a negative value if the
9137  * first element should be higher in the @queue or a positive value
9138  * if the first element should be lower in the @queue than the second
9139  * element.
9140  *
9141  * This function must be called while holding the @queue's lock.
9142  *
9143  * Since: 2.10
9144  */
9145
9146
9147 /**
9148  * g_async_queue_timed_pop:
9149  * @queue: a #GAsyncQueue
9150  * @end_time: a #GTimeVal, determining the final time
9151  *
9152  * Pops data from the @queue. If the queue is empty, blocks until
9153  * @end_time or until data becomes available.
9154  *
9155  * If no data is received before @end_time, %NULL is returned.
9156  *
9157  * To easily calculate @end_time, a combination of g_get_current_time()
9158  * and g_time_val_add() can be used.
9159  *
9160  * Returns: data from the queue or %NULL, when no data is received before @end_time.
9161  * Deprecated: use g_async_queue_timeout_pop().
9162  */
9163
9164
9165 /**
9166  * g_async_queue_timed_pop_unlocked:
9167  * @queue: a #GAsyncQueue
9168  * @end_time: a #GTimeVal, determining the final time
9169  *
9170  * Pops data from the @queue. If the queue is empty, blocks until
9171  * @end_time or until data becomes available.
9172  *
9173  * If no data is received before @end_time, %NULL is returned.
9174  *
9175  * To easily calculate @end_time, a combination of g_get_current_time()
9176  * and g_time_val_add() can be used.
9177  *
9178  * This function must be called while holding the @queue's lock.
9179  *
9180  * Returns: data from the queue or %NULL, when no data is received before @end_time.
9181  * Deprecated: use g_async_queue_timeout_pop_unlocked().
9182  */
9183
9184
9185 /**
9186  * g_async_queue_timeout_pop:
9187  * @queue: a #GAsyncQueue
9188  * @timeout: the number of microseconds to wait
9189  *
9190  * Pops data from the @queue. If the queue is empty, blocks for
9191  * @timeout microseconds, or until data becomes available.
9192  *
9193  * If no data is received before the timeout, %NULL is returned.
9194  *
9195  * Returns: data from the queue or %NULL, when no data is received before the timeout.
9196  */
9197
9198
9199 /**
9200  * g_async_queue_timeout_pop_unlocked:
9201  * @queue: a #GAsyncQueue
9202  * @timeout: the number of microseconds to wait
9203  *
9204  * Pops data from the @queue. If the queue is empty, blocks for
9205  * @timeout microseconds, or until data becomes available.
9206  *
9207  * If no data is received before the timeout, %NULL is returned.
9208  *
9209  * This function must be called while holding the @queue's lock.
9210  *
9211  * Returns: data from the queue or %NULL, when no data is received before the timeout.
9212  */
9213
9214
9215 /**
9216  * g_async_queue_try_pop:
9217  * @queue: a #GAsyncQueue
9218  *
9219  * Tries to pop data from the @queue. If no data is available,
9220  * %NULL is returned.
9221  *
9222  * Returns: data from the queue or %NULL, when no data is available immediately.
9223  */
9224
9225
9226 /**
9227  * g_async_queue_try_pop_unlocked:
9228  * @queue: a #GAsyncQueue
9229  *
9230  * Tries to pop data from the @queue. If no data is available,
9231  * %NULL is returned.
9232  *
9233  * This function must be called while holding the @queue's lock.
9234  *
9235  * Returns: data from the queue or %NULL, when no data is available immediately.
9236  */
9237
9238
9239 /**
9240  * g_async_queue_unlock:
9241  * @queue: a #GAsyncQueue
9242  *
9243  * Releases the queue's lock.
9244  *
9245  * Calling this function when you have not acquired
9246  * the with g_async_queue_lock() leads to undefined
9247  * behaviour.
9248  */
9249
9250
9251 /**
9252  * g_async_queue_unref:
9253  * @queue: a #GAsyncQueue.
9254  *
9255  * Decreases the reference count of the asynchronous @queue by 1.
9256  *
9257  * If the reference count went to 0, the @queue will be destroyed
9258  * and the memory allocated will be freed. So you are not allowed
9259  * to use the @queue afterwards, as it might have disappeared.
9260  * You do not need to hold the lock to call this function.
9261  */
9262
9263
9264 /**
9265  * g_async_queue_unref_and_unlock:
9266  * @queue: a #GAsyncQueue
9267  *
9268  * Decreases the reference count of the asynchronous @queue by 1
9269  * and releases the lock. This function must be called while holding
9270  * the @queue's lock. If the reference count went to 0, the @queue
9271  * will be destroyed and the memory allocated will be freed.
9272  *
9273  * Deprecated: 2.8: Reference counting is done atomically. so g_async_queue_unref() can be used regardless of the @queue's lock.
9274  */
9275
9276
9277 /**
9278  * g_atexit:
9279  * @func: (scope async): the function to call on normal program termination.
9280  *
9281  * Specifies a function to be called at normal program termination.
9282  *
9283  * Since GLib 2.8.2, on Windows g_atexit() actually is a preprocessor
9284  * macro that maps to a call to the atexit() function in the C
9285  * library. This means that in case the code that calls g_atexit(),
9286  * i.e. atexit(), is in a DLL, the function will be called when the
9287  * DLL is detached from the program. This typically makes more sense
9288  * than that the function is called when the GLib DLL is detached,
9289  * which happened earlier when g_atexit() was a function in the GLib
9290  * DLL.
9291  *
9292  * The behaviour of atexit() in the context of dynamically loaded
9293  * modules is not formally specified and varies wildly.
9294  *
9295  * On POSIX systems, calling g_atexit() (or atexit()) in a dynamically
9296  * loaded module which is unloaded before the program terminates might
9297  * well cause a crash at program exit.
9298  *
9299  * Some POSIX systems implement atexit() like Windows, and have each
9300  * dynamically loaded module maintain an own atexit chain that is
9301  * called when the module is unloaded.
9302  *
9303  * On other POSIX systems, before a dynamically loaded module is
9304  * unloaded, the registered atexit functions (if any) residing in that
9305  * module are called, regardless where the code that registered them
9306  * resided. This is presumably the most robust approach.
9307  *
9308  * As can be seen from the above, for portability it's best to avoid
9309  * calling g_atexit() (or atexit()) except in the main executable of a
9310  * program.
9311  *
9312  * Deprecated: 2.32: It is best to avoid g_atexit().
9313  */
9314
9315
9316 /**
9317  * g_atomic_int_add:
9318  * @atomic: a pointer to a #gint or #guint
9319  * @val: the value to add
9320  *
9321  * Atomically adds @val to the value of @atomic.
9322  *
9323  * Think of this operation as an atomic version of
9324  * <literal>{ tmp = *atomic; *@atomic += @val; return tmp; }</literal>
9325  *
9326  * This call acts as a full compiler and hardware memory barrier.
9327  *
9328  * Before version 2.30, this function did not return a value
9329  * (but g_atomic_int_exchange_and_add() did, and had the same meaning).
9330  *
9331  * Returns: the value of @atomic before the add, signed
9332  * Since: 2.4
9333  */
9334
9335
9336 /**
9337  * g_atomic_int_and:
9338  * @atomic: a pointer to a #gint or #guint
9339  * @val: the value to 'and'
9340  *
9341  * Performs an atomic bitwise 'and' of the value of @atomic and @val,
9342  * storing the result back in @atomic.
9343  *
9344  * This call acts as a full compiler and hardware memory barrier.
9345  *
9346  * Think of this operation as an atomic version of
9347  * <literal>{ tmp = *atomic; *@atomic &= @val; return tmp; }</literal>
9348  *
9349  * Returns: the value of @atomic before the operation, unsigned
9350  * Since: 2.30
9351  */
9352
9353
9354 /**
9355  * g_atomic_int_compare_and_exchange:
9356  * @atomic: a pointer to a #gint or #guint
9357  * @oldval: the value to compare with
9358  * @newval: the value to conditionally replace with
9359  *
9360  * Compares @atomic to @oldval and, if equal, sets it to @newval.
9361  * If @atomic was not equal to @oldval then no change occurs.
9362  *
9363  * This compare and exchange is done atomically.
9364  *
9365  * Think of this operation as an atomic version of
9366  * <literal>{ if (*@atomic == @oldval) { *@atomic = @newval; return TRUE; } else return FALSE; }</literal>
9367  *
9368  * This call acts as a full compiler and hardware memory barrier.
9369  *
9370  * Returns: %TRUE if the exchange took place
9371  * Since: 2.4
9372  */
9373
9374
9375 /**
9376  * g_atomic_int_dec_and_test:
9377  * @atomic: a pointer to a #gint or #guint
9378  *
9379  * Decrements the value of @atomic by 1.
9380  *
9381  * Think of this operation as an atomic version of
9382  * <literal>{ *@atomic -= 1; return (*@atomic == 0); }</literal>
9383  *
9384  * This call acts as a full compiler and hardware memory barrier.
9385  *
9386  * Returns: %TRUE if the resultant value is zero
9387  * Since: 2.4
9388  */
9389
9390
9391 /**
9392  * g_atomic_int_exchange_and_add:
9393  * @atomic: a pointer to a #gint
9394  * @val: the value to add
9395  *
9396  * This function existed before g_atomic_int_add() returned the prior
9397  * value of the integer (which it now does).  It is retained only for
9398  * compatibility reasons.  Don't use this function in new code.
9399  *
9400  * Returns: the value of @atomic before the add, signed
9401  * Since: 2.4
9402  * Deprecated: 2.30: Use g_atomic_int_add() instead.
9403  */
9404
9405
9406 /**
9407  * g_atomic_int_get:
9408  * @atomic: a pointer to a #gint or #guint
9409  *
9410  * Gets the current value of @atomic.
9411  *
9412  * This call acts as a full compiler and hardware
9413  * memory barrier (before the get).
9414  *
9415  * Returns: the value of the integer
9416  * Since: 2.4
9417  */
9418
9419
9420 /**
9421  * g_atomic_int_inc:
9422  * @atomic: a pointer to a #gint or #guint
9423  *
9424  * Increments the value of @atomic by 1.
9425  *
9426  * Think of this operation as an atomic version of
9427  * <literal>{ *@atomic += 1; }</literal>
9428  *
9429  * This call acts as a full compiler and hardware memory barrier.
9430  *
9431  * Since: 2.4
9432  */
9433
9434
9435 /**
9436  * g_atomic_int_or:
9437  * @atomic: a pointer to a #gint or #guint
9438  * @val: the value to 'or'
9439  *
9440  * Performs an atomic bitwise 'or' of the value of @atomic and @val,
9441  * storing the result back in @atomic.
9442  *
9443  * Think of this operation as an atomic version of
9444  * <literal>{ tmp = *atomic; *@atomic |= @val; return tmp; }</literal>
9445  *
9446  * This call acts as a full compiler and hardware memory barrier.
9447  *
9448  * Returns: the value of @atomic before the operation, unsigned
9449  * Since: 2.30
9450  */
9451
9452
9453 /**
9454  * g_atomic_int_set:
9455  * @atomic: a pointer to a #gint or #guint
9456  * @newval: a new value to store
9457  *
9458  * Sets the value of @atomic to @newval.
9459  *
9460  * This call acts as a full compiler and hardware
9461  * memory barrier (after the set).
9462  *
9463  * Since: 2.4
9464  */
9465
9466
9467 /**
9468  * g_atomic_int_xor:
9469  * @atomic: a pointer to a #gint or #guint
9470  * @val: the value to 'xor'
9471  *
9472  * Performs an atomic bitwise 'xor' of the value of @atomic and @val,
9473  * storing the result back in @atomic.
9474  *
9475  * Think of this operation as an atomic version of
9476  * <literal>{ tmp = *atomic; *@atomic ^= @val; return tmp; }</literal>
9477  *
9478  * This call acts as a full compiler and hardware memory barrier.
9479  *
9480  * Returns: the value of @atomic before the operation, unsigned
9481  * Since: 2.30
9482  */
9483
9484
9485 /**
9486  * g_atomic_pointer_add:
9487  * @atomic: a pointer to a #gpointer-sized value
9488  * @val: the value to add
9489  *
9490  * Atomically adds @val to the value of @atomic.
9491  *
9492  * Think of this operation as an atomic version of
9493  * <literal>{ tmp = *atomic; *@atomic += @val; return tmp; }</literal>
9494  *
9495  * This call acts as a full compiler and hardware memory barrier.
9496  *
9497  * Returns: the value of @atomic before the add, signed
9498  * Since: 2.30
9499  */
9500
9501
9502 /**
9503  * g_atomic_pointer_and:
9504  * @atomic: a pointer to a #gpointer-sized value
9505  * @val: the value to 'and'
9506  *
9507  * Performs an atomic bitwise 'and' of the value of @atomic and @val,
9508  * storing the result back in @atomic.
9509  *
9510  * Think of this operation as an atomic version of
9511  * <literal>{ tmp = *atomic; *@atomic &= @val; return tmp; }</literal>
9512  *
9513  * This call acts as a full compiler and hardware memory barrier.
9514  *
9515  * Returns: the value of @atomic before the operation, unsigned
9516  * Since: 2.30
9517  */
9518
9519
9520 /**
9521  * g_atomic_pointer_compare_and_exchange:
9522  * @atomic: a pointer to a #gpointer-sized value
9523  * @oldval: the value to compare with
9524  * @newval: the value to conditionally replace with
9525  *
9526  * Compares @atomic to @oldval and, if equal, sets it to @newval.
9527  * If @atomic was not equal to @oldval then no change occurs.
9528  *
9529  * This compare and exchange is done atomically.
9530  *
9531  * Think of this operation as an atomic version of
9532  * <literal>{ if (*@atomic == @oldval) { *@atomic = @newval; return TRUE; } else return FALSE; }</literal>
9533  *
9534  * This call acts as a full compiler and hardware memory barrier.
9535  *
9536  * Returns: %TRUE if the exchange took place
9537  * Since: 2.4
9538  */
9539
9540
9541 /**
9542  * g_atomic_pointer_get:
9543  * @atomic: a pointer to a #gpointer-sized value
9544  *
9545  * Gets the current value of @atomic.
9546  *
9547  * This call acts as a full compiler and hardware
9548  * memory barrier (before the get).
9549  *
9550  * Returns: the value of the pointer
9551  * Since: 2.4
9552  */
9553
9554
9555 /**
9556  * g_atomic_pointer_or:
9557  * @atomic: a pointer to a #gpointer-sized value
9558  * @val: the value to 'or'
9559  *
9560  * Performs an atomic bitwise 'or' of the value of @atomic and @val,
9561  * storing the result back in @atomic.
9562  *
9563  * Think of this operation as an atomic version of
9564  * <literal>{ tmp = *atomic; *@atomic |= @val; return tmp; }</literal>
9565  *
9566  * This call acts as a full compiler and hardware memory barrier.
9567  *
9568  * Returns: the value of @atomic before the operation, unsigned
9569  * Since: 2.30
9570  */
9571
9572
9573 /**
9574  * g_atomic_pointer_set:
9575  * @atomic: a pointer to a #gpointer-sized value
9576  * @newval: a new value to store
9577  *
9578  * Sets the value of @atomic to @newval.
9579  *
9580  * This call acts as a full compiler and hardware
9581  * memory barrier (after the set).
9582  *
9583  * Since: 2.4
9584  */
9585
9586
9587 /**
9588  * g_atomic_pointer_xor:
9589  * @atomic: a pointer to a #gpointer-sized value
9590  * @val: the value to 'xor'
9591  *
9592  * Performs an atomic bitwise 'xor' of the value of @atomic and @val,
9593  * storing the result back in @atomic.
9594  *
9595  * Think of this operation as an atomic version of
9596  * <literal>{ tmp = *atomic; *@atomic ^= @val; return tmp; }</literal>
9597  *
9598  * This call acts as a full compiler and hardware memory barrier.
9599  *
9600  * Returns: the value of @atomic before the operation, unsigned
9601  * Since: 2.30
9602  */
9603
9604
9605 /**
9606  * g_base64_decode:
9607  * @text: zero-terminated string with base64 text to decode
9608  * @out_len: (out): The length of the decoded data is written here
9609  *
9610  * Decode a sequence of Base-64 encoded text into binary data.  Note
9611  * that the returned binary data is not necessarily zero-terminated,
9612  * so it should not be used as a character string.
9613  *
9614  * Returns: (transfer full) (array length=out_len) (element-type guint8): newly allocated buffer containing the binary data that @text represents. The returned buffer must be freed with g_free().
9615  * Since: 2.12
9616  */
9617
9618
9619 /**
9620  * g_base64_decode_inplace:
9621  * @text: (inout) (array length=out_len) (element-type guint8): zero-terminated string with base64 text to decode
9622  * @out_len: (inout): The length of the decoded data is written here
9623  *
9624  * Decode a sequence of Base-64 encoded text into binary data
9625  * by overwriting the input data.
9626  *
9627  * Returns: (transfer none): The binary data that @text responds. This pointer is the same as the input @text.
9628  * Since: 2.20
9629  */
9630
9631
9632 /**
9633  * g_base64_decode_step:
9634  * @in: (array length=len) (element-type guint8): binary input data
9635  * @len: max length of @in data to decode
9636  * @out: (out) (array) (element-type guint8): output buffer
9637  * @state: (inout): Saved state between steps, initialize to 0
9638  * @save: (inout): Saved state between steps, initialize to 0
9639  *
9640  * Incrementally decode a sequence of binary data from its Base-64 stringified
9641  * representation. By calling this function multiple times you can convert
9642  * data in chunks to avoid having to have the full encoded data in memory.
9643  *
9644  * The output buffer must be large enough to fit all the data that will
9645  * be written to it. Since base64 encodes 3 bytes in 4 chars you need
9646  * at least: (@len / 4) * 3 + 3 bytes (+ 3 may be needed in case of non-zero
9647  * state).
9648  *
9649  * Returns: The number of bytes of output that was written
9650  * Since: 2.12
9651  */
9652
9653
9654 /**
9655  * g_base64_encode:
9656  * @data: (array length=len) (element-type guint8): the binary data to encode
9657  * @len: the length of @data
9658  *
9659  * Encode a sequence of binary data into its Base-64 stringified
9660  * representation.
9661  *
9662  * Returns: (transfer full): a newly allocated, zero-terminated Base-64 encoded string representing @data. The returned string must be freed with g_free().
9663  * Since: 2.12
9664  */
9665
9666
9667 /**
9668  * g_base64_encode_close:
9669  * @break_lines: whether to break long lines
9670  * @out: (out) (array) (element-type guint8): pointer to destination buffer
9671  * @state: (inout): Saved state from g_base64_encode_step()
9672  * @save: (inout): Saved state from g_base64_encode_step()
9673  *
9674  * Flush the status from a sequence of calls to g_base64_encode_step().
9675  *
9676  * The output buffer must be large enough to fit all the data that will
9677  * be written to it. It will need up to 4 bytes, or up to 5 bytes if
9678  * line-breaking is enabled.
9679  *
9680  * Returns: The number of bytes of output that was written
9681  * Since: 2.12
9682  */
9683
9684
9685 /**
9686  * g_base64_encode_step:
9687  * @in: (array length=len) (element-type guint8): the binary data to encode
9688  * @len: the length of @in
9689  * @break_lines: whether to break long lines
9690  * @out: (out) (array) (element-type guint8): pointer to destination buffer
9691  * @state: (inout): Saved state between steps, initialize to 0
9692  * @save: (inout): Saved state between steps, initialize to 0
9693  *
9694  * Incrementally encode a sequence of binary data into its Base-64 stringified
9695  * representation. By calling this function multiple times you can convert
9696  * data in chunks to avoid having to have the full encoded data in memory.
9697  *
9698  * When all of the data has been converted you must call
9699  * g_base64_encode_close() to flush the saved state.
9700  *
9701  * The output buffer must be large enough to fit all the data that will
9702  * be written to it. Due to the way base64 encodes you will need
9703  * at least: (@len / 3 + 1) * 4 + 4 bytes (+ 4 may be needed in case of
9704  * non-zero state). If you enable line-breaking you will need at least:
9705  * ((@len / 3 + 1) * 4 + 4) / 72 + 1 bytes of extra space.
9706  *
9707  * @break_lines is typically used when putting base64-encoded data in emails.
9708  * It breaks the lines at 72 columns instead of putting all of the text on
9709  * the same line. This avoids problems with long lines in the email system.
9710  * Note however that it breaks the lines with <literal>LF</literal>
9711  * characters, not <literal>CR LF</literal> sequences, so the result cannot
9712  * be passed directly to SMTP or certain other protocols.
9713  *
9714  * Returns: The number of bytes of output that was written
9715  * Since: 2.12
9716  */
9717
9718
9719 /**
9720  * g_basename:
9721  * @file_name: the name of the file
9722  *
9723  * Gets the name of the file without any leading directory
9724  * components. It returns a pointer into the given file name
9725  * string.
9726  *
9727  * Returns: the name of the file without any leading directory components
9728  * Deprecated: 2.2: Use g_path_get_basename() instead, but notice that g_path_get_basename() allocates new memory for the returned string, unlike this function which returns a pointer into the argument.
9729  */
9730
9731
9732 /**
9733  * g_bit_lock:
9734  * @address: a pointer to an integer
9735  * @lock_bit: a bit value between 0 and 31
9736  *
9737  * Sets the indicated @lock_bit in @address.  If the bit is already
9738  * set, this call will block until g_bit_unlock() unsets the
9739  * corresponding bit.
9740  *
9741  * Attempting to lock on two different bits within the same integer is
9742  * not supported and will very probably cause deadlocks.
9743  *
9744  * The value of the bit that is set is (1u << @bit).  If @bit is not
9745  * between 0 and 31 then the result is undefined.
9746  *
9747  * This function accesses @address atomically.  All other accesses to
9748  * @address must be atomic in order for this function to work
9749  * reliably.
9750  *
9751  * Since: 2.24
9752  */
9753
9754
9755 /**
9756  * g_bit_nth_lsf:
9757  * @mask: a #gulong containing flags
9758  * @nth_bit: the index of the bit to start the search from
9759  *
9760  * Find the position of the first bit set in @mask, searching
9761  * from (but not including) @nth_bit upwards. Bits are numbered
9762  * from 0 (least significant) to sizeof(#gulong) * 8 - 1 (31 or 63,
9763  * usually). To start searching from the 0th bit, set @nth_bit to -1.
9764  *
9765  * Returns: the index of the first bit set which is higher than @nth_bit
9766  */
9767
9768
9769 /**
9770  * g_bit_nth_msf:
9771  * @mask: a #gulong containing flags
9772  * @nth_bit: the index of the bit to start the search from
9773  *
9774  * Find the position of the first bit set in @mask, searching
9775  * from (but not including) @nth_bit downwards. Bits are numbered
9776  * from 0 (least significant) to sizeof(#gulong) * 8 - 1 (31 or 63,
9777  * usually). To start searching from the last bit, set @nth_bit to
9778  * -1 or GLIB_SIZEOF_LONG * 8.
9779  *
9780  * Returns: the index of the first bit set which is lower than @nth_bit
9781  */
9782
9783
9784 /**
9785  * g_bit_storage:
9786  * @number: a #guint
9787  *
9788  * Gets the number of bits used to hold @number,
9789  * e.g. if @number is 4, 3 bits are needed.
9790  *
9791  * Returns: the number of bits used to hold @number
9792  */
9793
9794
9795 /**
9796  * g_bit_trylock:
9797  * @address: a pointer to an integer
9798  * @lock_bit: a bit value between 0 and 31
9799  *
9800  * Sets the indicated @lock_bit in @address, returning %TRUE if
9801  * successful.  If the bit is already set, returns %FALSE immediately.
9802  *
9803  * Attempting to lock on two different bits within the same integer is
9804  * not supported.
9805  *
9806  * The value of the bit that is set is (1u << @bit).  If @bit is not
9807  * between 0 and 31 then the result is undefined.
9808  *
9809  * This function accesses @address atomically.  All other accesses to
9810  * @address must be atomic in order for this function to work
9811  * reliably.
9812  *
9813  * Returns: %TRUE if the lock was acquired
9814  * Since: 2.24
9815  */
9816
9817
9818 /**
9819  * g_bit_unlock:
9820  * @address: a pointer to an integer
9821  * @lock_bit: a bit value between 0 and 31
9822  *
9823  * Clears the indicated @lock_bit in @address.  If another thread is
9824  * currently blocked in g_bit_lock() on this same bit then it will be
9825  * woken up.
9826  *
9827  * This function accesses @address atomically.  All other accesses to
9828  * @address must be atomic in order for this function to work
9829  * reliably.
9830  *
9831  * Since: 2.24
9832  */
9833
9834
9835 /**
9836  * g_bookmark_file_add_application:
9837  * @bookmark: a #GBookmarkFile
9838  * @uri: a valid URI
9839  * @name: (allow-none): the name of the application registering the bookmark or %NULL
9840  * @exec: (allow-none): command line to be used to launch the bookmark or %NULL
9841  *
9842  * Adds the application with @name and @exec to the list of
9843  * applications that have registered a bookmark for @uri into
9844  * @bookmark.
9845  *
9846  * Every bookmark inside a #GBookmarkFile must have at least an
9847  * application registered.  Each application must provide a name, a
9848  * command line useful for launching the bookmark, the number of times
9849  * the bookmark has been registered by the application and the last
9850  * time the application registered this bookmark.
9851  *
9852  * If @name is %NULL, the name of the application will be the
9853  * same returned by g_get_application_name(); if @exec is %NULL, the
9854  * command line will be a composition of the program name as
9855  * returned by g_get_prgname() and the "\%u" modifier, which will be
9856  * expanded to the bookmark's URI.
9857  *
9858  * This function will automatically take care of updating the
9859  * registrations count and timestamping in case an application
9860  * with the same @name had already registered a bookmark for
9861  * @uri inside @bookmark.
9862  *
9863  * If no bookmark for @uri is found, one is created.
9864  *
9865  * Since: 2.12
9866  */
9867
9868
9869 /**
9870  * g_bookmark_file_add_group:
9871  * @bookmark: a #GBookmarkFile
9872  * @uri: a valid URI
9873  * @group: the group name to be added
9874  *
9875  * Adds @group to the list of groups to which the bookmark for @uri
9876  * belongs to.
9877  *
9878  * If no bookmark for @uri is found then it is created.
9879  *
9880  * Since: 2.12
9881  */
9882
9883
9884 /**
9885  * g_bookmark_file_free:
9886  * @bookmark: a #GBookmarkFile
9887  *
9888  * Frees a #GBookmarkFile.
9889  *
9890  * Since: 2.12
9891  */
9892
9893
9894 /**
9895  * g_bookmark_file_get_added:
9896  * @bookmark: a #GBookmarkFile
9897  * @uri: a valid URI
9898  * @error: return location for a #GError, or %NULL
9899  *
9900  * Gets the time the bookmark for @uri was added to @bookmark
9901  *
9902  * In the event the URI cannot be found, -1 is returned and
9903  * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
9904  *
9905  * Returns: a timestamp
9906  * Since: 2.12
9907  */
9908
9909
9910 /**
9911  * g_bookmark_file_get_app_info:
9912  * @bookmark: a #GBookmarkFile
9913  * @uri: a valid URI
9914  * @name: an application's name
9915  * @exec: (allow-none) (out): return location for the command line of the application, or %NULL
9916  * @count: (allow-none) (out): return location for the registration count, or %NULL
9917  * @stamp: (allow-none) (out): return location for the last registration time, or %NULL
9918  * @error: return location for a #GError, or %NULL
9919  *
9920  * Gets the registration informations of @app_name for the bookmark for
9921  * @uri.  See g_bookmark_file_set_app_info() for more informations about
9922  * the returned data.
9923  *
9924  * The string returned in @app_exec must be freed.
9925  *
9926  * In the event the URI cannot be found, %FALSE is returned and
9927  * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.  In the
9928  * event that no application with name @app_name has registered a bookmark
9929  * for @uri,  %FALSE is returned and error is set to
9930  * #G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED. In the event that unquoting
9931  * the command line fails, an error of the #G_SHELL_ERROR domain is
9932  * set and %FALSE is returned.
9933  *
9934  * Returns: %TRUE on success.
9935  * Since: 2.12
9936  */
9937
9938
9939 /**
9940  * g_bookmark_file_get_applications:
9941  * @bookmark: a #GBookmarkFile
9942  * @uri: a valid URI
9943  * @length: (allow-none) (out): return location of the length of the returned list, or %NULL
9944  * @error: return location for a #GError, or %NULL
9945  *
9946  * Retrieves the names of the applications that have registered the
9947  * bookmark for @uri.
9948  *
9949  * In the event the URI cannot be found, %NULL is returned and
9950  * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
9951  *
9952  * Returns: (array length=length) (transfer full): a newly allocated %NULL-terminated array of strings. Use g_strfreev() to free it.
9953  * Since: 2.12
9954  */
9955
9956
9957 /**
9958  * g_bookmark_file_get_description:
9959  * @bookmark: a #GBookmarkFile
9960  * @uri: a valid URI
9961  * @error: return location for a #GError, or %NULL
9962  *
9963  * Retrieves the description of the bookmark for @uri.
9964  *
9965  * In the event the URI cannot be found, %NULL is returned and
9966  * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
9967  *
9968  * Returns: a newly allocated string or %NULL if the specified URI cannot be found.
9969  * Since: 2.12
9970  */
9971
9972
9973 /**
9974  * g_bookmark_file_get_groups:
9975  * @bookmark: a #GBookmarkFile
9976  * @uri: a valid URI
9977  * @length: (allow-none) (out): return location for the length of the returned string, or %NULL
9978  * @error: return location for a #GError, or %NULL
9979  *
9980  * Retrieves the list of group names of the bookmark for @uri.
9981  *
9982  * In the event the URI cannot be found, %NULL is returned and
9983  * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
9984  *
9985  * The returned array is %NULL terminated, so @length may optionally
9986  * be %NULL.
9987  *
9988  * Returns: (array length=length) (transfer full): a newly allocated %NULL-terminated array of group names. Use g_strfreev() to free it.
9989  * Since: 2.12
9990  */
9991
9992
9993 /**
9994  * g_bookmark_file_get_icon:
9995  * @bookmark: a #GBookmarkFile
9996  * @uri: a valid URI
9997  * @href: (allow-none) (out): return location for the icon's location or %NULL
9998  * @mime_type: (allow-none) (out): return location for the icon's MIME type or %NULL
9999  * @error: return location for a #GError or %NULL
10000  *
10001  * Gets the icon of the bookmark for @uri.
10002  *
10003  * In the event the URI cannot be found, %FALSE is returned and
10004  * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10005  *
10006  * Returns: %TRUE if the icon for the bookmark for the URI was found. You should free the returned strings.
10007  * Since: 2.12
10008  */
10009
10010
10011 /**
10012  * g_bookmark_file_get_is_private:
10013  * @bookmark: a #GBookmarkFile
10014  * @uri: a valid URI
10015  * @error: return location for a #GError, or %NULL
10016  *
10017  * Gets whether the private flag of the bookmark for @uri is set.
10018  *
10019  * In the event the URI cannot be found, %FALSE is returned and
10020  * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.  In the
10021  * event that the private flag cannot be found, %FALSE is returned and
10022  * @error is set to #G_BOOKMARK_FILE_ERROR_INVALID_VALUE.
10023  *
10024  * Returns: %TRUE if the private flag is set, %FALSE otherwise.
10025  * Since: 2.12
10026  */
10027
10028
10029 /**
10030  * g_bookmark_file_get_mime_type:
10031  * @bookmark: a #GBookmarkFile
10032  * @uri: a valid URI
10033  * @error: return location for a #GError, or %NULL
10034  *
10035  * Retrieves the MIME type of the resource pointed by @uri.
10036  *
10037  * In the event the URI cannot be found, %NULL is returned and
10038  * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.  In the
10039  * event that the MIME type cannot be found, %NULL is returned and
10040  * @error is set to #G_BOOKMARK_FILE_ERROR_INVALID_VALUE.
10041  *
10042  * Returns: a newly allocated string or %NULL if the specified URI cannot be found.
10043  * Since: 2.12
10044  */
10045
10046
10047 /**
10048  * g_bookmark_file_get_modified:
10049  * @bookmark: a #GBookmarkFile
10050  * @uri: a valid URI
10051  * @error: return location for a #GError, or %NULL
10052  *
10053  * Gets the time when the bookmark for @uri was last modified.
10054  *
10055  * In the event the URI cannot be found, -1 is returned and
10056  * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10057  *
10058  * Returns: a timestamp
10059  * Since: 2.12
10060  */
10061
10062
10063 /**
10064  * g_bookmark_file_get_size:
10065  * @bookmark: a #GBookmarkFile
10066  *
10067  * Gets the number of bookmarks inside @bookmark.
10068  *
10069  * Returns: the number of bookmarks
10070  * Since: 2.12
10071  */
10072
10073
10074 /**
10075  * g_bookmark_file_get_title:
10076  * @bookmark: a #GBookmarkFile
10077  * @uri: (allow-none): a valid URI or %NULL
10078  * @error: return location for a #GError, or %NULL
10079  *
10080  * Returns the title of the bookmark for @uri.
10081  *
10082  * If @uri is %NULL, the title of @bookmark is returned.
10083  *
10084  * In the event the URI cannot be found, %NULL is returned and
10085  * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10086  *
10087  * Returns: a newly allocated string or %NULL if the specified URI cannot be found.
10088  * Since: 2.12
10089  */
10090
10091
10092 /**
10093  * g_bookmark_file_get_uris:
10094  * @bookmark: a #GBookmarkFile
10095  * @length: (allow-none) (out): return location for the number of returned URIs, or %NULL
10096  *
10097  * Returns all URIs of the bookmarks in the bookmark file @bookmark.
10098  * The array of returned URIs will be %NULL-terminated, so @length may
10099  * optionally be %NULL.
10100  *
10101  * Returns: (array length=length) (transfer full): a newly allocated %NULL-terminated array of strings. Use g_strfreev() to free it.
10102  * Since: 2.12
10103  */
10104
10105
10106 /**
10107  * g_bookmark_file_get_visited:
10108  * @bookmark: a #GBookmarkFile
10109  * @uri: a valid URI
10110  * @error: return location for a #GError, or %NULL
10111  *
10112  * Gets the time the bookmark for @uri was last visited.
10113  *
10114  * In the event the URI cannot be found, -1 is returned and
10115  * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10116  *
10117  * Returns: a timestamp.
10118  * Since: 2.12
10119  */
10120
10121
10122 /**
10123  * g_bookmark_file_has_application:
10124  * @bookmark: a #GBookmarkFile
10125  * @uri: a valid URI
10126  * @name: the name of the application
10127  * @error: return location for a #GError or %NULL
10128  *
10129  * Checks whether the bookmark for @uri inside @bookmark has been
10130  * registered by application @name.
10131  *
10132  * In the event the URI cannot be found, %FALSE is returned and
10133  * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10134  *
10135  * Returns: %TRUE if the application @name was found
10136  * Since: 2.12
10137  */
10138
10139
10140 /**
10141  * g_bookmark_file_has_group:
10142  * @bookmark: a #GBookmarkFile
10143  * @uri: a valid URI
10144  * @group: the group name to be searched
10145  * @error: return location for a #GError, or %NULL
10146  *
10147  * Checks whether @group appears in the list of groups to which
10148  * the bookmark for @uri belongs to.
10149  *
10150  * In the event the URI cannot be found, %FALSE is returned and
10151  * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10152  *
10153  * Returns: %TRUE if @group was found.
10154  * Since: 2.12
10155  */
10156
10157
10158 /**
10159  * g_bookmark_file_has_item:
10160  * @bookmark: a #GBookmarkFile
10161  * @uri: a valid URI
10162  *
10163  * Looks whether the desktop bookmark has an item with its URI set to @uri.
10164  *
10165  * Returns: %TRUE if @uri is inside @bookmark, %FALSE otherwise
10166  * Since: 2.12
10167  */
10168
10169
10170 /**
10171  * g_bookmark_file_load_from_data:
10172  * @bookmark: an empty #GBookmarkFile struct
10173  * @data: desktop bookmarks loaded in memory
10174  * @length: the length of @data in bytes
10175  * @error: return location for a #GError, or %NULL
10176  *
10177  * Loads a bookmark file from memory into an empty #GBookmarkFile
10178  * structure.  If the object cannot be created then @error is set to a
10179  * #GBookmarkFileError.
10180  *
10181  * Returns: %TRUE if a desktop bookmark could be loaded.
10182  * Since: 2.12
10183  */
10184
10185
10186 /**
10187  * g_bookmark_file_load_from_data_dirs:
10188  * @bookmark: a #GBookmarkFile
10189  * @file: a relative path to a filename to open and parse
10190  * @full_path: (allow-none): return location for a string containing the full path of the file, or %NULL
10191  * @error: return location for a #GError, or %NULL
10192  *
10193  * This function looks for a desktop bookmark file named @file in the
10194  * paths returned from g_get_user_data_dir() and g_get_system_data_dirs(),
10195  * loads the file into @bookmark and returns the file's full path in
10196  * @full_path.  If the file could not be loaded then an %error is
10197  * set to either a #GFileError or #GBookmarkFileError.
10198  *
10199  * Returns: %TRUE if a key file could be loaded, %FALSE otherwise
10200  * Since: 2.12
10201  */
10202
10203
10204 /**
10205  * g_bookmark_file_load_from_file:
10206  * @bookmark: an empty #GBookmarkFile struct
10207  * @filename: the path of a filename to load, in the GLib file name encoding
10208  * @error: return location for a #GError, or %NULL
10209  *
10210  * Loads a desktop bookmark file into an empty #GBookmarkFile structure.
10211  * If the file could not be loaded then @error is set to either a #GFileError
10212  * or #GBookmarkFileError.
10213  *
10214  * Returns: %TRUE if a desktop bookmark file could be loaded
10215  * Since: 2.12
10216  */
10217
10218
10219 /**
10220  * g_bookmark_file_move_item:
10221  * @bookmark: a #GBookmarkFile
10222  * @old_uri: a valid URI
10223  * @new_uri: (allow-none): a valid URI, or %NULL
10224  * @error: return location for a #GError or %NULL
10225  *
10226  * Changes the URI of a bookmark item from @old_uri to @new_uri.  Any
10227  * existing bookmark for @new_uri will be overwritten.  If @new_uri is
10228  * %NULL, then the bookmark is removed.
10229  *
10230  * In the event the URI cannot be found, %FALSE is returned and
10231  * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10232  *
10233  * Returns: %TRUE if the URI was successfully changed
10234  * Since: 2.12
10235  */
10236
10237
10238 /**
10239  * g_bookmark_file_new:
10240  *
10241  * Creates a new empty #GBookmarkFile object.
10242  *
10243  * Use g_bookmark_file_load_from_file(), g_bookmark_file_load_from_data()
10244  * or g_bookmark_file_load_from_data_dirs() to read an existing bookmark
10245  * file.
10246  *
10247  * Returns: an empty #GBookmarkFile
10248  * Since: 2.12
10249  */
10250
10251
10252 /**
10253  * g_bookmark_file_remove_application:
10254  * @bookmark: a #GBookmarkFile
10255  * @uri: a valid URI
10256  * @name: the name of the application
10257  * @error: return location for a #GError or %NULL
10258  *
10259  * Removes application registered with @name from the list of applications
10260  * that have registered a bookmark for @uri inside @bookmark.
10261  *
10262  * In the event the URI cannot be found, %FALSE is returned and
10263  * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10264  * In the event that no application with name @app_name has registered
10265  * a bookmark for @uri,  %FALSE is returned and error is set to
10266  * #G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED.
10267  *
10268  * Returns: %TRUE if the application was successfully removed.
10269  * Since: 2.12
10270  */
10271
10272
10273 /**
10274  * g_bookmark_file_remove_group:
10275  * @bookmark: a #GBookmarkFile
10276  * @uri: a valid URI
10277  * @group: the group name to be removed
10278  * @error: return location for a #GError, or %NULL
10279  *
10280  * Removes @group from the list of groups to which the bookmark
10281  * for @uri belongs to.
10282  *
10283  * In the event the URI cannot be found, %FALSE is returned and
10284  * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
10285  * In the event no group was defined, %FALSE is returned and
10286  * @error is set to #G_BOOKMARK_FILE_ERROR_INVALID_VALUE.
10287  *
10288  * Returns: %TRUE if @group was successfully removed.
10289  * Since: 2.12
10290  */
10291
10292
10293 /**
10294  * g_bookmark_file_remove_item:
10295  * @bookmark: a #GBookmarkFile
10296  * @uri: a valid URI
10297  * @error: return location for a #GError, or %NULL
10298  *
10299  * Removes the bookmark for @uri from the bookmark file @bookmark.
10300  *
10301  * Returns: %TRUE if the bookmark was removed successfully.
10302  * Since: 2.12
10303  */
10304
10305
10306 /**
10307  * g_bookmark_file_set_added:
10308  * @bookmark: a #GBookmarkFile
10309  * @uri: a valid URI
10310  * @added: a timestamp or -1 to use the current time
10311  *
10312  * Sets the time the bookmark for @uri was added into @bookmark.
10313  *
10314  * If no bookmark for @uri is found then it is created.
10315  *
10316  * Since: 2.12
10317  */
10318
10319
10320 /**
10321  * g_bookmark_file_set_app_info:
10322  * @bookmark: a #GBookmarkFile
10323  * @uri: a valid URI
10324  * @name: an application's name
10325  * @exec: an application's command line
10326  * @count: the number of registrations done for this application
10327  * @stamp: the time of the last registration for this application
10328  * @error: return location for a #GError or %NULL
10329  *
10330  * Sets the meta-data of application @name inside the list of
10331  * applications that have registered a bookmark for @uri inside
10332  * @bookmark.
10333  *
10334  * You should rarely use this function; use g_bookmark_file_add_application()
10335  * and g_bookmark_file_remove_application() instead.
10336  *
10337  * @name can be any UTF-8 encoded string used to identify an
10338  * application.
10339  * @exec can have one of these two modifiers: "\%f", which will
10340  * be expanded as the local file name retrieved from the bookmark's
10341  * URI; "\%u", which will be expanded as the bookmark's URI.
10342  * The expansion is done automatically when retrieving the stored
10343  * command line using the g_bookmark_file_get_app_info() function.
10344  * @count is the number of times the application has registered the
10345  * bookmark; if is < 0, the current registration count will be increased
10346  * by one, if is 0, the application with @name will be removed from
10347  * the list of registered applications.
10348  * @stamp is the Unix time of the last registration; if it is -1, the
10349  * current time will be used.
10350  *
10351  * If you try to remove an application by setting its registration count to
10352  * zero, and no bookmark for @uri is found, %FALSE is returned and
10353  * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND; similarly,
10354  * in the event that no application @name has registered a bookmark
10355  * for @uri,  %FALSE is returned and error is set to
10356  * #G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED.  Otherwise, if no bookmark
10357  * for @uri is found, one is created.
10358  *
10359  * Returns: %TRUE if the application's meta-data was successfully changed.
10360  * Since: 2.12
10361  */
10362
10363
10364 /**
10365  * g_bookmark_file_set_description:
10366  * @bookmark: a #GBookmarkFile
10367  * @uri: (allow-none): a valid URI or %NULL
10368  * @description: a string
10369  *
10370  * Sets @description as the description of the bookmark for @uri.
10371  *
10372  * If @uri is %NULL, the description of @bookmark is set.
10373  *
10374  * If a bookmark for @uri cannot be found then it is created.
10375  *
10376  * Since: 2.12
10377  */
10378
10379
10380 /**
10381  * g_bookmark_file_set_groups:
10382  * @bookmark: a #GBookmarkFile
10383  * @uri: an item's URI
10384  * @groups: (allow-none): an array of group names, or %NULL to remove all groups
10385  * @length: number of group name values in @groups
10386  *
10387  * Sets a list of group names for the item with URI @uri.  Each previously
10388  * set group name list is removed.
10389  *
10390  * If @uri cannot be found then an item for it is created.
10391  *
10392  * Since: 2.12
10393  */
10394
10395
10396 /**
10397  * g_bookmark_file_set_icon:
10398  * @bookmark: a #GBookmarkFile
10399  * @uri: a valid URI
10400  * @href: (allow-none): the URI of the icon for the bookmark, or %NULL
10401  * @mime_type: the MIME type of the icon for the bookmark
10402  *
10403  * Sets the icon for the bookmark for @uri. If @href is %NULL, unsets
10404  * the currently set icon. @href can either be a full URL for the icon
10405  * file or the icon name following the Icon Naming specification.
10406  *
10407  * If no bookmark for @uri is found one is created.
10408  *
10409  * Since: 2.12
10410  */
10411
10412
10413 /**
10414  * g_bookmark_file_set_is_private:
10415  * @bookmark: a #GBookmarkFile
10416  * @uri: a valid URI
10417  * @is_private: %TRUE if the bookmark should be marked as private
10418  *
10419  * Sets the private flag of the bookmark for @uri.
10420  *
10421  * If a bookmark for @uri cannot be found then it is created.
10422  *
10423  * Since: 2.12
10424  */
10425
10426
10427 /**
10428  * g_bookmark_file_set_mime_type:
10429  * @bookmark: a #GBookmarkFile
10430  * @uri: a valid URI
10431  * @mime_type: a MIME type
10432  *
10433  * Sets @mime_type as the MIME type of the bookmark for @uri.
10434  *
10435  * If a bookmark for @uri cannot be found then it is created.
10436  *
10437  * Since: 2.12
10438  */
10439
10440
10441 /**
10442  * g_bookmark_file_set_modified:
10443  * @bookmark: a #GBookmarkFile
10444  * @uri: a valid URI
10445  * @modified: a timestamp or -1 to use the current time
10446  *
10447  * Sets the last time the bookmark for @uri was last modified.
10448  *
10449  * If no bookmark for @uri is found then it is created.
10450  *
10451  * The "modified" time should only be set when the bookmark's meta-data
10452  * was actually changed.  Every function of #GBookmarkFile that
10453  * modifies a bookmark also changes the modification time, except for
10454  * g_bookmark_file_set_visited().
10455  *
10456  * Since: 2.12
10457  */
10458
10459
10460 /**
10461  * g_bookmark_file_set_title:
10462  * @bookmark: a #GBookmarkFile
10463  * @uri: (allow-none): a valid URI or %NULL
10464  * @title: a UTF-8 encoded string
10465  *
10466  * Sets @title as the title of the bookmark for @uri inside the
10467  * bookmark file @bookmark.
10468  *
10469  * If @uri is %NULL, the title of @bookmark is set.
10470  *
10471  * If a bookmark for @uri cannot be found then it is created.
10472  *
10473  * Since: 2.12
10474  */
10475
10476
10477 /**
10478  * g_bookmark_file_set_visited:
10479  * @bookmark: a #GBookmarkFile
10480  * @uri: a valid URI
10481  * @visited: a timestamp or -1 to use the current time
10482  *
10483  * Sets the time the bookmark for @uri was last visited.
10484  *
10485  * If no bookmark for @uri is found then it is created.
10486  *
10487  * The "visited" time should only be set if the bookmark was launched,
10488  * either using the command line retrieved by g_bookmark_file_get_app_info()
10489  * or by the default application for the bookmark's MIME type, retrieved
10490  * using g_bookmark_file_get_mime_type().  Changing the "visited" time
10491  * does not affect the "modified" time.
10492  *
10493  * Since: 2.12
10494  */
10495
10496
10497 /**
10498  * g_bookmark_file_to_data:
10499  * @bookmark: a #GBookmarkFile
10500  * @length: (allow-none) (out): return location for the length of the returned string, or %NULL
10501  * @error: return location for a #GError, or %NULL
10502  *
10503  * This function outputs @bookmark as a string.
10504  *
10505  * Returns: a newly allocated string holding the contents of the #GBookmarkFile
10506  * Since: 2.12
10507  */
10508
10509
10510 /**
10511  * g_bookmark_file_to_file:
10512  * @bookmark: a #GBookmarkFile
10513  * @filename: path of the output file
10514  * @error: return location for a #GError, or %NULL
10515  *
10516  * This function outputs @bookmark into a file.  The write process is
10517  * guaranteed to be atomic by using g_file_set_contents() internally.
10518  *
10519  * Returns: %TRUE if the file was successfully written.
10520  * Since: 2.12
10521  */
10522
10523
10524 /**
10525  * g_build_filename:
10526  * @first_element: the first element in the path
10527  * @...: remaining elements in path, terminated by %NULL
10528  *
10529  * Creates a filename from a series of elements using the correct
10530  * separator for filenames.
10531  *
10532  * On Unix, this function behaves identically to <literal>g_build_path
10533  * (G_DIR_SEPARATOR_S, first_element, ....)</literal>.
10534  *
10535  * On Windows, it takes into account that either the backslash
10536  * (<literal>\</literal> or slash (<literal>/</literal>) can be used
10537  * as separator in filenames, but otherwise behaves as on Unix. When
10538  * file pathname separators need to be inserted, the one that last
10539  * previously occurred in the parameters (reading from left to right)
10540  * is used.
10541  *
10542  * No attempt is made to force the resulting filename to be an absolute
10543  * path. If the first element is a relative path, the result will
10544  * be a relative path.
10545  *
10546  * Returns: a newly-allocated string that must be freed with g_free().
10547  */
10548
10549
10550 /**
10551  * g_build_filenamev:
10552  * @args: (array zero-terminated=1): %NULL-terminated array of strings containing the path elements.
10553  *
10554  * Behaves exactly like g_build_filename(), but takes the path elements
10555  * as a string array, instead of varargs. This function is mainly
10556  * meant for language bindings.
10557  *
10558  * Returns: a newly-allocated string that must be freed with g_free().
10559  * Since: 2.8
10560  */
10561
10562
10563 /**
10564  * g_build_path:
10565  * @separator: a string used to separator the elements of the path.
10566  * @first_element: the first element in the path
10567  * @...: remaining elements in path, terminated by %NULL
10568  *
10569  * Creates a path from a series of elements using @separator as the
10570  * separator between elements. At the boundary between two elements,
10571  * any trailing occurrences of separator in the first element, or
10572  * leading occurrences of separator in the second element are removed
10573  * and exactly one copy of the separator is inserted.
10574  *
10575  * Empty elements are ignored.
10576  *
10577  * The number of leading copies of the separator on the result is
10578  * the same as the number of leading copies of the separator on
10579  * the first non-empty element.
10580  *
10581  * The number of trailing copies of the separator on the result is
10582  * the same as the number of trailing copies of the separator on
10583  * the last non-empty element. (Determination of the number of
10584  * trailing copies is done without stripping leading copies, so
10585  * if the separator is <literal>ABA</literal>, <literal>ABABA</literal>
10586  * has 1 trailing copy.)
10587  *
10588  * However, if there is only a single non-empty element, and there
10589  * are no characters in that element not part of the leading or
10590  * trailing separators, then the result is exactly the original value
10591  * of that element.
10592  *
10593  * Other than for determination of the number of leading and trailing
10594  * copies of the separator, elements consisting only of copies
10595  * of the separator are ignored.
10596  *
10597  * Returns: a newly-allocated string that must be freed with g_free().
10598  */
10599
10600
10601 /**
10602  * g_build_pathv:
10603  * @separator: a string used to separator the elements of the path.
10604  * @args: (array zero-terminated=1): %NULL-terminated array of strings containing the path elements.
10605  *
10606  * Behaves exactly like g_build_path(), but takes the path elements
10607  * as a string array, instead of varargs. This function is mainly
10608  * meant for language bindings.
10609  *
10610  * Returns: a newly-allocated string that must be freed with g_free().
10611  * Since: 2.8
10612  */
10613
10614
10615 /**
10616  * g_byte_array_append:
10617  * @array: a #GByteArray.
10618  * @data: the byte data to be added.
10619  * @len: the number of bytes to add.
10620  *
10621  * Adds the given bytes to the end of the #GByteArray. The array will
10622  * grow in size automatically if necessary.
10623  *
10624  * Returns: the #GByteArray.
10625  */
10626
10627
10628 /**
10629  * g_byte_array_free:
10630  * @array: a #GByteArray.
10631  * @free_segment: if %TRUE the actual byte data is freed as well.
10632  *
10633  * Frees the memory allocated by the #GByteArray. If @free_segment is
10634  * %TRUE it frees the actual byte data. If the reference count of
10635  * @array is greater than one, the #GByteArray wrapper is preserved but
10636  * the size of @array will be set to zero.
10637  *
10638  * Returns: the element data if @free_segment is %FALSE, otherwise %NULL.  The element data should be freed using g_free().
10639  */
10640
10641
10642 /**
10643  * g_byte_array_free_to_bytes:
10644  * @array: (transfer full): a #GByteArray
10645  *
10646  * Transfers the data from the #GByteArray into a new immutable #GBytes.
10647  *
10648  * The #GByteArray is freed unless the reference count of @array is greater
10649  * than one, the #GByteArray wrapper is preserved but the size of @array
10650  * will be set to zero.
10651  *
10652  * This is identical to using g_bytes_new_take() and g_byte_array_free()
10653  * together.
10654  *
10655  * Since: 2.32
10656  * Returns: (transfer full): a new immutable #GBytes representing same byte data that was in the array
10657  */
10658
10659
10660 /**
10661  * g_byte_array_new:
10662  *
10663  * Creates a new #GByteArray with a reference count of 1.
10664  *
10665  * Returns: (transfer full): the new #GByteArray.
10666  */
10667
10668
10669 /**
10670  * g_byte_array_new_take:
10671  * @data: (transfer full) (array length=len): byte data for the array
10672  * @len: length of @data
10673  *
10674  * Create byte array containing the data. The data will be owned by the array
10675  * and will be freed with g_free(), i.e. it could be allocated using g_strdup().
10676  *
10677  * Since: 2.32
10678  * Returns: (transfer full): a new #GByteArray
10679  */
10680
10681
10682 /**
10683  * g_byte_array_prepend:
10684  * @array: a #GByteArray.
10685  * @data: the byte data to be added.
10686  * @len: the number of bytes to add.
10687  *
10688  * Adds the given data to the start of the #GByteArray. The array will
10689  * grow in size automatically if necessary.
10690  *
10691  * Returns: the #GByteArray.
10692  */
10693
10694
10695 /**
10696  * g_byte_array_ref:
10697  * @array: A #GByteArray.
10698  *
10699  * Atomically increments the reference count of @array by one. This
10700  * function is MT-safe and may be called from any thread.
10701  *
10702  * Returns: The passed in #GByteArray.
10703  * Since: 2.22
10704  */
10705
10706
10707 /**
10708  * g_byte_array_remove_index:
10709  * @array: a #GByteArray.
10710  * @index_: the index of the byte to remove.
10711  *
10712  * Removes the byte at the given index from a #GByteArray. The
10713  * following bytes are moved down one place.
10714  *
10715  * Returns: the #GByteArray.
10716  */
10717
10718
10719 /**
10720  * g_byte_array_remove_index_fast:
10721  * @array: a #GByteArray.
10722  * @index_: the index of the byte to remove.
10723  *
10724  * Removes the byte at the given index from a #GByteArray. The last
10725  * element in the array is used to fill in the space, so this function
10726  * does not preserve the order of the #GByteArray. But it is faster
10727  * than g_byte_array_remove_index().
10728  *
10729  * Returns: the #GByteArray.
10730  */
10731
10732
10733 /**
10734  * g_byte_array_remove_range:
10735  * @array: a @GByteArray.
10736  * @index_: the index of the first byte to remove.
10737  * @length: the number of bytes to remove.
10738  *
10739  * Removes the given number of bytes starting at the given index from a
10740  * #GByteArray.  The following elements are moved to close the gap.
10741  *
10742  * Returns: the #GByteArray.
10743  * Since: 2.4
10744  */
10745
10746
10747 /**
10748  * g_byte_array_set_size:
10749  * @array: a #GByteArray.
10750  * @length: the new size of the #GByteArray.
10751  *
10752  * Sets the size of the #GByteArray, expanding it if necessary.
10753  *
10754  * Returns: the #GByteArray.
10755  */
10756
10757
10758 /**
10759  * g_byte_array_sized_new:
10760  * @reserved_size: number of bytes preallocated.
10761  *
10762  * Creates a new #GByteArray with @reserved_size bytes preallocated.
10763  * This avoids frequent reallocation, if you are going to add many
10764  * bytes to the array. Note however that the size of the array is still
10765  * 0.
10766  *
10767  * Returns: the new #GByteArray.
10768  */
10769
10770
10771 /**
10772  * g_byte_array_sort:
10773  * @array: a #GByteArray.
10774  * @compare_func: comparison function.
10775  *
10776  * Sorts a byte array, using @compare_func which should be a
10777  * qsort()-style comparison function (returns less than zero for first
10778  * arg is less than second arg, zero for equal, greater than zero if
10779  * first arg is greater than second arg).
10780  *
10781  * If two array elements compare equal, their order in the sorted array
10782  * is undefined. If you want equal elements to keep their order (i.e.
10783  * you want a stable sort) you can write a comparison function that,
10784  * if two elements would otherwise compare equal, compares them by
10785  * their addresses.
10786  */
10787
10788
10789 /**
10790  * g_byte_array_sort_with_data:
10791  * @array: a #GByteArray.
10792  * @compare_func: comparison function.
10793  * @user_data: data to pass to @compare_func.
10794  *
10795  * Like g_byte_array_sort(), but the comparison function takes an extra
10796  * user data argument.
10797  */
10798
10799
10800 /**
10801  * g_byte_array_unref:
10802  * @array: A #GByteArray.
10803  *
10804  * Atomically decrements the reference count of @array by one. If the
10805  * reference count drops to 0, all memory allocated by the array is
10806  * released. This function is MT-safe and may be called from any
10807  * thread.
10808  *
10809  * Since: 2.22
10810  */
10811
10812
10813 /**
10814  * g_bytes_compare:
10815  * @bytes1: (type GLib.Bytes): a pointer to a #GBytes
10816  * @bytes2: (type GLib.Bytes): a pointer to a #GBytes to compare with @bytes1
10817  *
10818  * Compares the two #GBytes values.
10819  *
10820  * This function can be used to sort GBytes instances in lexographical order.
10821  *
10822  * Returns: a negative value if bytes2 is lesser, a positive value if bytes2 is greater, and zero if bytes2 is equal to bytes1
10823  * Since: 2.32
10824  */
10825
10826
10827 /**
10828  * g_bytes_equal:
10829  * @bytes1: (type GLib.Bytes): a pointer to a #GBytes
10830  * @bytes2: (type GLib.Bytes): a pointer to a #GBytes to compare with @bytes1
10831  *
10832  * Compares the two #GBytes values being pointed to and returns
10833  * %TRUE if they are equal.
10834  *
10835  * This function can be passed to g_hash_table_new() as the @key_equal_func
10836  * parameter, when using non-%NULL #GBytes pointers as keys in a #GHashTable.
10837  *
10838  * Returns: %TRUE if the two keys match.
10839  * Since: 2.32
10840  */
10841
10842
10843 /**
10844  * g_bytes_get_data:
10845  * @bytes: a #GBytes
10846  * @size: (out) (allow-none): location to return size of byte data
10847  *
10848  * Get the byte data in the #GBytes. This data should not be modified.
10849  *
10850  * This function will always return the same pointer for a given #GBytes.
10851  *
10852  * Returns: (transfer none) (array length=size) (type guint8): a pointer to the byte data
10853  * Since: 2.32
10854  */
10855
10856
10857 /**
10858  * g_bytes_get_size:
10859  * @bytes: a #GBytes
10860  *
10861  * Get the size of the byte data in the #GBytes.
10862  *
10863  * This function will always return the same value for a given #GBytes.
10864  *
10865  * Returns: the size
10866  * Since: 2.32
10867  */
10868
10869
10870 /**
10871  * g_bytes_hash:
10872  * @bytes: (type GLib.Bytes): a pointer to a #GBytes key
10873  *
10874  * Creates an integer hash code for the byte data in the #GBytes.
10875  *
10876  * This function can be passed to g_hash_table_new() as the @key_equal_func
10877  * parameter, when using non-%NULL #GBytes pointers as keys in a #GHashTable.
10878  *
10879  * Returns: a hash value corresponding to the key.
10880  * Since: 2.32
10881  */
10882
10883
10884 /**
10885  * g_bytes_new:
10886  * @data: (transfer none) (array length=size) (element-type guint8): the data to be used for the bytes
10887  * @size: the size of @data
10888  *
10889  * Creates a new #GBytes from @data.
10890  *
10891  * @data is copied.
10892  *
10893  * Returns: (transfer full): a new #GBytes
10894  * Since: 2.32
10895  */
10896
10897
10898 /**
10899  * g_bytes_new_from_bytes:
10900  * @bytes: a #GBytes
10901  * @offset: offset which subsection starts at
10902  * @length: length of subsection
10903  *
10904  * Creates a #GBytes which is a subsection of another #GBytes. The @offset +
10905  * @length may not be longer than the size of @bytes.
10906  *
10907  * A reference to @bytes will be held by the newly created #GBytes until
10908  * the byte data is no longer needed.
10909  *
10910  * Returns: (transfer full): a new #GBytes
10911  * Since: 2.32
10912  */
10913
10914
10915 /**
10916  * g_bytes_new_static: (skip)
10917  * @data: (transfer full) (array length=size) (element-type guint8): the data to be used for the bytes
10918  * @size: the size of @data
10919  *
10920  * Creates a new #GBytes from static data.
10921  *
10922  * @data must be static (ie: never modified or freed).
10923  *
10924  * Returns: (transfer full): a new #GBytes
10925  * Since: 2.32
10926  */
10927
10928
10929 /**
10930  * g_bytes_new_take:
10931  * @data: (transfer full) (array length=size) (element-type guint8): the data to be used for the bytes
10932  * @size: the size of @data
10933  *
10934  * Creates a new #GBytes from @data.
10935  *
10936  * After this call, @data belongs to the bytes and may no longer be
10937  * modified by the caller.  g_free() will be called on @data when the
10938  * bytes is no longer in use. Because of this @data must have been created by
10939  * a call to g_malloc(), g_malloc0() or g_realloc() or by one of the many
10940  * functions that wrap these calls (such as g_new(), g_strdup(), etc).
10941  *
10942  * For creating #GBytes with memory from other allocators, see
10943  * g_bytes_new_with_free_func().
10944  *
10945  * Returns: (transfer full): a new #GBytes
10946  * Since: 2.32
10947  */
10948
10949
10950 /**
10951  * g_bytes_new_with_free_func:
10952  * @data: (array length=size): the data to be used for the bytes
10953  * @size: the size of @data
10954  * @free_func: the function to call to release the data
10955  * @user_data: data to pass to @free_func
10956  *
10957  * Creates a #GBytes from @data.
10958  *
10959  * When the last reference is dropped, @free_func will be called with the
10960  * @user_data argument.
10961  *
10962  * @data must not be modified after this call is made until @free_func has
10963  * been called to indicate that the bytes is no longer in use.
10964  *
10965  * Returns: (transfer full): a new #GBytes
10966  * Since: 2.32
10967  */
10968
10969
10970 /**
10971  * g_bytes_ref:
10972  * @bytes: a #GBytes
10973  *
10974  * Increase the reference count on @bytes.
10975  *
10976  * Returns: the #GBytes
10977  * Since: 2.32
10978  */
10979
10980
10981 /**
10982  * g_bytes_unref:
10983  * @bytes: (allow-none): a #GBytes
10984  *
10985  * Releases a reference on @bytes.  This may result in the bytes being
10986  * freed.
10987  *
10988  * Since: 2.32
10989  */
10990
10991
10992 /**
10993  * g_bytes_unref_to_array:
10994  * @bytes: (transfer full): a #GBytes
10995  *
10996  * Unreferences the bytes, and returns a new mutable #GByteArray containing
10997  * the same byte data.
10998  *
10999  * As an optimization, the byte data is transferred to the array without copying
11000  * if this was the last reference to bytes and bytes was created with
11001  * g_bytes_new(), g_bytes_new_take() or g_byte_array_free_to_bytes(). In all
11002  * other cases the data is copied.
11003  *
11004  * Returns: (transfer full): a new mutable #GByteArray containing the same byte data
11005  * Since: 2.32
11006  */
11007
11008
11009 /**
11010  * g_bytes_unref_to_data:
11011  * @bytes: (transfer full): a #GBytes
11012  * @size: location to place the length of the returned data
11013  *
11014  * Unreferences the bytes, and returns a pointer the same byte data
11015  * contents.
11016  *
11017  * As an optimization, the byte data is returned without copying if this was
11018  * the last reference to bytes and bytes was created with g_bytes_new(),
11019  * g_bytes_new_take() or g_byte_array_free_to_bytes(). In all other cases the
11020  * data is copied.
11021  *
11022  * Returns: (transfer full): a pointer to the same byte data, which should be freed with g_free()
11023  * Since: 2.32
11024  */
11025
11026
11027 /**
11028  * g_chdir:
11029  * @path: a pathname in the GLib file name encoding (UTF-8 on Windows)
11030  *
11031  * A wrapper for the POSIX chdir() function. The function changes the
11032  * current directory of the process to @path.
11033  *
11034  * See your C library manual for more details about chdir().
11035  *
11036  * Returns: 0 on success, -1 if an error occurred.
11037  * Since: 2.8
11038  */
11039
11040
11041 /**
11042  * g_checksum_copy:
11043  * @checksum: the #GChecksum to copy
11044  *
11045  * Copies a #GChecksum. If @checksum has been closed, by calling
11046  * g_checksum_get_string() or g_checksum_get_digest(), the copied
11047  * checksum will be closed as well.
11048  *
11049  * Returns: the copy of the passed #GChecksum. Use g_checksum_free() when finished using it.
11050  * Since: 2.16
11051  */
11052
11053
11054 /**
11055  * g_checksum_free:
11056  * @checksum: a #GChecksum
11057  *
11058  * Frees the memory allocated for @checksum.
11059  *
11060  * Since: 2.16
11061  */
11062
11063
11064 /**
11065  * g_checksum_get_digest: (skip)
11066  * @checksum: a #GChecksum
11067  * @buffer: output buffer
11068  * @digest_len: an inout parameter. The caller initializes it to the size of @buffer. After the call it contains the length of the digest.
11069  *
11070  * Gets the digest from @checksum as a raw binary vector and places it
11071  * into @buffer. The size of the digest depends on the type of checksum.
11072  *
11073  * Once this function has been called, the #GChecksum is closed and can
11074  * no longer be updated with g_checksum_update().
11075  *
11076  * Since: 2.16
11077  */
11078
11079
11080 /**
11081  * g_checksum_get_string:
11082  * @checksum: a #GChecksum
11083  *
11084  * Gets the digest as an hexadecimal string.
11085  *
11086  * Once this function has been called the #GChecksum can no longer be
11087  * updated with g_checksum_update().
11088  *
11089  * The hexadecimal characters will be lower case.
11090  *
11091  * Returns: the hexadecimal representation of the checksum. The returned string is owned by the checksum and should not be modified or freed.
11092  * Since: 2.16
11093  */
11094
11095
11096 /**
11097  * g_checksum_new:
11098  * @checksum_type: the desired type of checksum
11099  *
11100  * Creates a new #GChecksum, using the checksum algorithm @checksum_type.
11101  * If the @checksum_type is not known, %NULL is returned.
11102  * A #GChecksum can be used to compute the checksum, or digest, of an
11103  * arbitrary binary blob, using different hashing algorithms.
11104  *
11105  * A #GChecksum works by feeding a binary blob through g_checksum_update()
11106  * until there is data to be checked; the digest can then be extracted
11107  * using g_checksum_get_string(), which will return the checksum as a
11108  * hexadecimal string; or g_checksum_get_digest(), which will return a
11109  * vector of raw bytes. Once either g_checksum_get_string() or
11110  * g_checksum_get_digest() have been called on a #GChecksum, the checksum
11111  * will be closed and it won't be possible to call g_checksum_update()
11112  * on it anymore.
11113  *
11114  * Returns: (transfer full): the newly created #GChecksum, or %NULL. Use g_checksum_free() to free the memory allocated by it.
11115  * Since: 2.16
11116  */
11117
11118
11119 /**
11120  * g_checksum_reset:
11121  * @checksum: the #GChecksum to reset
11122  *
11123  * Resets the state of the @checksum back to its initial state.
11124  *
11125  * Since: 2.18
11126  */
11127
11128
11129 /**
11130  * g_checksum_type_get_length:
11131  * @checksum_type: a #GChecksumType
11132  *
11133  * Gets the length in bytes of digests of type @checksum_type
11134  *
11135  * Returns: the checksum length, or -1 if @checksum_type is not supported.
11136  * Since: 2.16
11137  */
11138
11139
11140 /**
11141  * g_checksum_update:
11142  * @checksum: a #GChecksum
11143  * @data: (array length=length) (element-type guint8): buffer used to compute the checksum
11144  * @length: size of the buffer, or -1 if it is a null-terminated string.
11145  *
11146  * Feeds @data into an existing #GChecksum. The checksum must still be
11147  * open, that is g_checksum_get_string() or g_checksum_get_digest() must
11148  * not have been called on @checksum.
11149  *
11150  * Since: 2.16
11151  */
11152
11153
11154 /**
11155  * g_child_watch_add:
11156  * @pid: process id to watch. On POSIX the pid of a child process. On Windows a handle for a process (which doesn't have to be a child).
11157  * @function: function to call
11158  * @data: data to pass to @function
11159  *
11160  * Sets a function to be called when the child indicated by @pid
11161  * exits, at a default priority, #G_PRIORITY_DEFAULT.
11162  *
11163  * If you obtain @pid from g_spawn_async() or g_spawn_async_with_pipes()
11164  * you will need to pass #G_SPAWN_DO_NOT_REAP_CHILD as flag to
11165  * the spawn function for the child watching to work.
11166  *
11167  * Note that on platforms where #GPid must be explicitly closed
11168  * (see g_spawn_close_pid()) @pid must not be closed while the
11169  * source is still active. Typically, you will want to call
11170  * g_spawn_close_pid() in the callback function for the source.
11171  *
11172  * GLib supports only a single callback per process id.
11173  *
11174  * This internally creates a main loop source using
11175  * g_child_watch_source_new() and attaches it to the main loop context
11176  * using g_source_attach(). You can do these steps manually if you
11177  * need greater control.
11178  *
11179  * Returns: the ID (greater than 0) of the event source.
11180  * Since: 2.4
11181  */
11182
11183
11184 /**
11185  * g_child_watch_add_full:
11186  * @priority: the priority of the idle source. Typically this will be in the range between #G_PRIORITY_DEFAULT_IDLE and #G_PRIORITY_HIGH_IDLE.
11187  * @pid: process to watch. On POSIX the pid of a child process. On Windows a handle for a process (which doesn't have to be a child).
11188  * @function: function to call
11189  * @data: data to pass to @function
11190  * @notify: (allow-none): function to call when the idle is removed, or %NULL
11191  *
11192  * Sets a function to be called when the child indicated by @pid
11193  * exits, at the priority @priority.
11194  *
11195  * If you obtain @pid from g_spawn_async() or g_spawn_async_with_pipes()
11196  * you will need to pass #G_SPAWN_DO_NOT_REAP_CHILD as flag to
11197  * the spawn function for the child watching to work.
11198  *
11199  * In many programs, you will want to call g_spawn_check_exit_status()
11200  * in the callback to determine whether or not the child exited
11201  * successfully.
11202  *
11203  * Also, note that on platforms where #GPid must be explicitly closed
11204  * (see g_spawn_close_pid()) @pid must not be closed while the source
11205  * is still active.  Typically, you should invoke g_spawn_close_pid()
11206  * in the callback function for the source.
11207  *
11208  * GLib supports only a single callback per process id.
11209  *
11210  * This internally creates a main loop source using
11211  * g_child_watch_source_new() and attaches it to the main loop context
11212  * using g_source_attach(). You can do these steps manually if you
11213  * need greater control.
11214  *
11215  * Returns: the ID (greater than 0) of the event source.
11216  * Rename to: g_child_watch_add
11217  * Since: 2.4
11218  */
11219
11220
11221 /**
11222  * g_child_watch_source_new:
11223  * @pid: process to watch. On POSIX the pid of a child process. On Windows a handle for a process (which doesn't have to be a child).
11224  *
11225  * Creates a new child_watch source.
11226  *
11227  * The source will not initially be associated with any #GMainContext
11228  * and must be added to one with g_source_attach() before it will be
11229  * executed.
11230  *
11231  * Note that child watch sources can only be used in conjunction with
11232  * <literal>g_spawn...</literal> when the %G_SPAWN_DO_NOT_REAP_CHILD
11233  * flag is used.
11234  *
11235  * Note that on platforms where #GPid must be explicitly closed
11236  * (see g_spawn_close_pid()) @pid must not be closed while the
11237  * source is still active. Typically, you will want to call
11238  * g_spawn_close_pid() in the callback function for the source.
11239  *
11240  * Note further that using g_child_watch_source_new() is not
11241  * compatible with calling <literal>waitpid</literal> with a
11242  * nonpositive first argument in the application. Calling waitpid()
11243  * for individual pids will still work fine.
11244  *
11245  * Returns: the newly-created child watch source
11246  * Since: 2.4
11247  */
11248
11249
11250 /**
11251  * g_chmod:
11252  * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
11253  * @mode: as in chmod()
11254  *
11255  * A wrapper for the POSIX chmod() function. The chmod() function is
11256  * used to set the permissions of a file system object.
11257  *
11258  * On Windows the file protection mechanism is not at all POSIX-like,
11259  * and the underlying chmod() function in the C library just sets or
11260  * clears the FAT-style READONLY attribute. It does not touch any
11261  * ACL. Software that needs to manage file permissions on Windows
11262  * exactly should use the Win32 API.
11263  *
11264  * See your C library manual for more details about chmod().
11265  *
11266  * Returns: zero if the operation succeeded, -1 on error.
11267  * Since: 2.8
11268  */
11269
11270
11271 /**
11272  * g_clear_error:
11273  * @err: a #GError return location
11274  *
11275  * If @err is %NULL, does nothing. If @err is non-%NULL,
11276  * calls g_error_free() on *@err and sets *@err to %NULL.
11277  */
11278
11279
11280 /**
11281  * g_clear_pointer: (skip)
11282  * @pp: a pointer to a variable, struct member etc. holding a pointer
11283  * @destroy: a function to which a gpointer can be passed, to destroy *@pp
11284  *
11285  * Clears a reference to a variable.
11286  *
11287  * @pp must not be %NULL.
11288  *
11289  * If the reference is %NULL then this function does nothing.
11290  * Otherwise, the variable is destroyed using @destroy and the
11291  * pointer is set to %NULL.
11292  *
11293  * This function is threadsafe and modifies the pointer atomically,
11294  * using memory barriers where needed.
11295  *
11296  * A macro is also included that allows this function to be used without
11297  * pointer casts.
11298  *
11299  * Since: 2.34
11300  */
11301
11302
11303 /**
11304  * g_close:
11305  * @fd: A file descriptor
11306  * @error: a #GError
11307  *
11308  * This wraps the close() call; in case of error, %errno will be
11309  * preserved, but the error will also be stored as a #GError in @error.
11310  *
11311  * Besides using #GError, there is another major reason to prefer this
11312  * function over the call provided by the system; on Unix, it will
11313  * attempt to correctly handle %EINTR, which has platform-specific
11314  * semantics.
11315  *
11316  * Since: 2.36
11317  */
11318
11319
11320 /**
11321  * g_compute_checksum_for_bytes:
11322  * @checksum_type: a #GChecksumType
11323  * @data: binary blob to compute the digest of
11324  *
11325  * Computes the checksum for a binary @data. This is a
11326  * convenience wrapper for g_checksum_new(), g_checksum_get_string()
11327  * and g_checksum_free().
11328  *
11329  * The hexadecimal string returned will be in lower case.
11330  *
11331  * Returns: the digest of the binary data as a string in hexadecimal. The returned string should be freed with g_free() when done using it.
11332  * Since: 2.34
11333  */
11334
11335
11336 /**
11337  * g_compute_checksum_for_data:
11338  * @checksum_type: a #GChecksumType
11339  * @data: (array length=length) (element-type guint8): binary blob to compute the digest of
11340  * @length: length of @data
11341  *
11342  * Computes the checksum for a binary @data of @length. This is a
11343  * convenience wrapper for g_checksum_new(), g_checksum_get_string()
11344  * and g_checksum_free().
11345  *
11346  * The hexadecimal string returned will be in lower case.
11347  *
11348  * Returns: the digest of the binary data as a string in hexadecimal. The returned string should be freed with g_free() when done using it.
11349  * Since: 2.16
11350  */
11351
11352
11353 /**
11354  * g_compute_checksum_for_string:
11355  * @checksum_type: a #GChecksumType
11356  * @str: the string to compute the checksum of
11357  * @length: the length of the string, or -1 if the string is null-terminated.
11358  *
11359  * Computes the checksum of a string.
11360  *
11361  * The hexadecimal string returned will be in lower case.
11362  *
11363  * Returns: the checksum as a hexadecimal string. The returned string should be freed with g_free() when done using it.
11364  * Since: 2.16
11365  */
11366
11367
11368 /**
11369  * g_compute_hmac_for_data:
11370  * @digest_type: a #GChecksumType to use for the HMAC
11371  * @key: (array length=key_len): the key to use in the HMAC
11372  * @key_len: the length of the key
11373  * @data: binary blob to compute the HMAC of
11374  * @length: length of @data
11375  *
11376  * Computes the HMAC for a binary @data of @length. This is a
11377  * convenience wrapper for g_hmac_new(), g_hmac_get_string()
11378  * and g_hmac_unref().
11379  *
11380  * The hexadecimal string returned will be in lower case.
11381  *
11382  * Returns: the HMAC of the binary data as a string in hexadecimal. The returned string should be freed with g_free() when done using it.
11383  * Since: 2.30
11384  */
11385
11386
11387 /**
11388  * g_compute_hmac_for_string:
11389  * @digest_type: a #GChecksumType to use for the HMAC
11390  * @key: (array length=key_len): the key to use in the HMAC
11391  * @key_len: the length of the key
11392  * @str: the string to compute the HMAC for
11393  * @length: the length of the string, or -1 if the string is nul-terminated
11394  *
11395  * Computes the HMAC for a string.
11396  *
11397  * The hexadecimal string returned will be in lower case.
11398  *
11399  * Returns: the HMAC as a hexadecimal string. The returned string should be freed with g_free() when done using it.
11400  * Since: 2.30
11401  */
11402
11403
11404 /**
11405  * g_cond_broadcast:
11406  * @cond: a #GCond
11407  *
11408  * If threads are waiting for @cond, all of them are unblocked.
11409  * If no threads are waiting for @cond, this function has no effect.
11410  * It is good practice to lock the same mutex as the waiting threads
11411  * while calling this function, though not required.
11412  */
11413
11414
11415 /**
11416  * g_cond_clear:
11417  * @cond: an initialised #GCond
11418  *
11419  * Frees the resources allocated to a #GCond with g_cond_init().
11420  *
11421  * This function should not be used with a #GCond that has been
11422  * statically allocated.
11423  *
11424  * Calling g_cond_clear() for a #GCond on which threads are
11425  * blocking leads to undefined behaviour.
11426  *
11427  * Since: 2.32
11428  */
11429
11430
11431 /**
11432  * g_cond_init:
11433  * @cond: an uninitialized #GCond
11434  *
11435  * Initialises a #GCond so that it can be used.
11436  *
11437  * This function is useful to initialise a #GCond that has been
11438  * allocated as part of a larger structure.  It is not necessary to
11439  * initialise a #GCond that has been statically allocated.
11440  *
11441  * To undo the effect of g_cond_init() when a #GCond is no longer
11442  * needed, use g_cond_clear().
11443  *
11444  * Calling g_cond_init() on an already-initialised #GCond leads
11445  * to undefined behaviour.
11446  *
11447  * Since: 2.32
11448  */
11449
11450
11451 /**
11452  * g_cond_signal:
11453  * @cond: a #GCond
11454  *
11455  * If threads are waiting for @cond, at least one of them is unblocked.
11456  * If no threads are waiting for @cond, this function has no effect.
11457  * It is good practice to hold the same lock as the waiting thread
11458  * while calling this function, though not required.
11459  */
11460
11461
11462 /**
11463  * g_cond_wait:
11464  * @cond: a #GCond
11465  * @mutex: a #GMutex that is currently locked
11466  *
11467  * Atomically releases @mutex and waits until @cond is signalled.
11468  * When this function returns, @mutex is locked again and owned by the
11469  * calling thread.
11470  *
11471  * When using condition variables, it is possible that a spurious wakeup
11472  * may occur (ie: g_cond_wait() returns even though g_cond_signal() was
11473  * not called).  It's also possible that a stolen wakeup may occur.
11474  * This is when g_cond_signal() is called, but another thread acquires
11475  * @mutex before this thread and modifies the state of the program in
11476  * such a way that when g_cond_wait() is able to return, the expected
11477  * condition is no longer met.
11478  *
11479  * For this reason, g_cond_wait() must always be used in a loop.  See
11480  * the documentation for #GCond for a complete example.
11481  */
11482
11483
11484 /**
11485  * g_cond_wait_until:
11486  * @cond: a #GCond
11487  * @mutex: a #GMutex that is currently locked
11488  * @end_time: the monotonic time to wait until
11489  *
11490  * Waits until either @cond is signalled or @end_time has passed.
11491  *
11492  * As with g_cond_wait() it is possible that a spurious or stolen wakeup
11493  * could occur.  For that reason, waiting on a condition variable should
11494  * always be in a loop, based on an explicitly-checked predicate.
11495  *
11496  * %TRUE is returned if the condition variable was signalled (or in the
11497  * case of a spurious wakeup).  %FALSE is returned if @end_time has
11498  * passed.
11499  *
11500  * The following code shows how to correctly perform a timed wait on a
11501  * condition variable (extended the example presented in the
11502  * documentation for #GCond):
11503  *
11504  * |[
11505  * gpointer
11506  * pop_data_timed (void)
11507  * {
11508  *   gint64 end_time;
11509  *   gpointer data;
11510  *
11511  *   g_mutex_lock (&data_mutex);
11512  *
11513  *   end_time = g_get_monotonic_time () + 5 * G_TIME_SPAN_SECOND;
11514  *   while (!current_data)
11515  *     if (!g_cond_wait_until (&data_cond, &data_mutex, end_time))
11516  *       {
11517  *         // timeout has passed.
11518  *         g_mutex_unlock (&data_mutex);
11519  *         return NULL;
11520  *       }
11521  *
11522  *   // there is data for us
11523  *   data = current_data;
11524  *   current_data = NULL;
11525  *
11526  *   g_mutex_unlock (&data_mutex);
11527  *
11528  *   return data;
11529  * }
11530  * ]|
11531  *
11532  * Notice that the end time is calculated once, before entering the
11533  * loop and reused.  This is the motivation behind the use of absolute
11534  * time on this API -- if a relative time of 5 seconds were passed
11535  * directly to the call and a spurious wakeup occurred, the program would
11536  * have to start over waiting again (which would lead to a total wait
11537  * time of more than 5 seconds).
11538  *
11539  * Returns: %TRUE on a signal, %FALSE on a timeout
11540  * Since: 2.32
11541  */
11542
11543
11544 /**
11545  * g_convert:
11546  * @str: the string to convert
11547  * @len: the length of the string, or -1 if the string is nul-terminated<footnote id="nul-unsafe"> <para> Note that some encodings may allow nul bytes to occur inside strings. In that case, using -1 for the @len parameter is unsafe. </para> </footnote>.
11548  * @to_codeset: name of character set into which to convert @str
11549  * @from_codeset: character set of @str.
11550  * @bytes_read: (out): location to store the number of bytes in the input string that were successfully converted, or %NULL. Even if the conversion was successful, this may be less than @len if there were partial characters at the end of the input. If the error #G_CONVERT_ERROR_ILLEGAL_SEQUENCE occurs, the value stored will the byte offset after the last valid input sequence.
11551  * @bytes_written: (out): the number of bytes stored in the output buffer (not including the terminating nul).
11552  * @error: location to store the error occurring, or %NULL to ignore errors. Any of the errors in #GConvertError may occur.
11553  *
11554  * Converts a string from one character set to another.
11555  *
11556  * Note that you should use g_iconv() for streaming
11557  * conversions<footnoteref linkend="streaming-state"/>.
11558  *
11559  * Returns: If the conversion was successful, a newly allocated nul-terminated string, which must be freed with g_free(). Otherwise %NULL and @error will be set.
11560  */
11561
11562
11563 /**
11564  * g_convert_with_fallback:
11565  * @str: the string to convert
11566  * @len: the length of the string, or -1 if the string is nul-terminated<footnoteref linkend="nul-unsafe"/>.
11567  * @to_codeset: name of character set into which to convert @str
11568  * @from_codeset: character set of @str.
11569  * @fallback: UTF-8 string to use in place of character not present in the target encoding. (The string must be representable in the target encoding). If %NULL, characters not in the target encoding will be represented as Unicode escapes \uxxxx or \Uxxxxyyyy.
11570  * @bytes_read: location to store the number of bytes in the input string that were successfully converted, or %NULL. Even if the conversion was successful, this may be less than @len if there were partial characters at the end of the input.
11571  * @bytes_written: the number of bytes stored in the output buffer (not including the terminating nul).
11572  * @error: location to store the error occurring, or %NULL to ignore errors. Any of the errors in #GConvertError may occur.
11573  *
11574  * Converts a string from one character set to another, possibly
11575  * including fallback sequences for characters not representable
11576  * in the output. Note that it is not guaranteed that the specification
11577  * for the fallback sequences in @fallback will be honored. Some
11578  * systems may do an approximate conversion from @from_codeset
11579  * to @to_codeset in their iconv() functions,
11580  * in which case GLib will simply return that approximate conversion.
11581  *
11582  * Note that you should use g_iconv() for streaming
11583  * conversions<footnoteref linkend="streaming-state"/>.
11584  *
11585  * Returns: If the conversion was successful, a newly allocated nul-terminated string, which must be freed with g_free(). Otherwise %NULL and @error will be set.
11586  */
11587
11588
11589 /**
11590  * g_convert_with_iconv:
11591  * @str: the string to convert
11592  * @len: the length of the string, or -1 if the string is nul-terminated<footnoteref linkend="nul-unsafe"/>.
11593  * @converter: conversion descriptor from g_iconv_open()
11594  * @bytes_read: location to store the number of bytes in the input string that were successfully converted, or %NULL. Even if the conversion was successful, this may be less than @len if there were partial characters at the end of the input. If the error #G_CONVERT_ERROR_ILLEGAL_SEQUENCE occurs, the value stored will the byte offset after the last valid input sequence.
11595  * @bytes_written: the number of bytes stored in the output buffer (not including the terminating nul).
11596  * @error: location to store the error occurring, or %NULL to ignore errors. Any of the errors in #GConvertError may occur.
11597  *
11598  * Converts a string from one character set to another.
11599  *
11600  * Note that you should use g_iconv() for streaming
11601  * conversions<footnote id="streaming-state">
11602  *  <para>
11603  * Despite the fact that @byes_read can return information about partial
11604  * characters, the <literal>g_convert_...</literal> functions
11605  * are not generally suitable for streaming. If the underlying converter
11606  * being used maintains internal state, then this won't be preserved
11607  * across successive calls to g_convert(), g_convert_with_iconv() or
11608  * g_convert_with_fallback(). (An example of this is the GNU C converter
11609  * for CP1255 which does not emit a base character until it knows that
11610  * the next character is not a mark that could combine with the base
11611  * character.)
11612  *  </para>
11613  * </footnote>.
11614  *
11615  * Returns: If the conversion was successful, a newly allocated nul-terminated string, which must be freed with g_free(). Otherwise %NULL and @error will be set.
11616  */
11617
11618
11619 /**
11620  * g_creat:
11621  * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
11622  * @mode: as in creat()
11623  *
11624  * A wrapper for the POSIX creat() function. The creat() function is
11625  * used to convert a pathname into a file descriptor, creating a file
11626  * if necessary.
11627  *
11628  * On POSIX systems file descriptors are implemented by the operating
11629  * system. On Windows, it's the C library that implements creat() and
11630  * file descriptors. The actual Windows API for opening files is
11631  * different, see MSDN documentation for CreateFile(). The Win32 API
11632  * uses file handles, which are more randomish integers, not small
11633  * integers like file descriptors.
11634  *
11635  * Because file descriptors are specific to the C library on Windows,
11636  * the file descriptor returned by this function makes sense only to
11637  * functions in the same C library. Thus if the GLib-using code uses a
11638  * different C library than GLib does, the file descriptor returned by
11639  * this function cannot be passed to C library functions like write()
11640  * or read().
11641  *
11642  * See your C library manual for more details about creat().
11643  *
11644  * Returns: a new file descriptor, or -1 if an error occurred. The return value can be used exactly like the return value from creat().
11645  * Since: 2.8
11646  */
11647
11648
11649 /**
11650  * g_critical:
11651  * @...: format string, followed by parameters to insert into the format string (as with printf())
11652  *
11653  * Logs a "critical warning" (#G_LOG_LEVEL_CRITICAL).
11654  * It's more or less application-defined what constitutes
11655  * a critical vs. a regular warning. You could call
11656  * g_log_set_always_fatal() to make critical warnings exit
11657  * the program, then use g_critical() for fatal errors, for
11658  * example.
11659  *
11660  * You can also make critical warnings fatal at runtime by
11661  * setting the <envar>G_DEBUG</envar> environment variable (see
11662  * <ulink url="glib-running.html">Running GLib Applications</ulink>).
11663  */
11664
11665
11666 /**
11667  * g_datalist_clear:
11668  * @datalist: a datalist.
11669  *
11670  * Frees all the data elements of the datalist.
11671  * The data elements' destroy functions are called
11672  * if they have been set.
11673  */
11674
11675
11676 /**
11677  * g_datalist_foreach:
11678  * @datalist: a datalist.
11679  * @func: the function to call for each data element.
11680  * @user_data: user data to pass to the function.
11681  *
11682  * Calls the given function for each data element of the datalist. The
11683  * function is called with each data element's #GQuark id and data,
11684  * together with the given @user_data parameter. Note that this
11685  * function is NOT thread-safe. So unless @datalist can be protected
11686  * from any modifications during invocation of this function, it should
11687  * not be called.
11688  */
11689
11690
11691 /**
11692  * g_datalist_get_data:
11693  * @datalist: a datalist.
11694  * @key: the string identifying a data element.
11695  *
11696  * Gets a data element, using its string identifier. This is slower than
11697  * g_datalist_id_get_data() because it compares strings.
11698  *
11699  * Returns: the data element, or %NULL if it is not found.
11700  */
11701
11702
11703 /**
11704  * g_datalist_get_flags:
11705  * @datalist: pointer to the location that holds a list
11706  *
11707  * Gets flags values packed in together with the datalist.
11708  * See g_datalist_set_flags().
11709  *
11710  * Returns: the flags of the datalist
11711  * Since: 2.8
11712  */
11713
11714
11715 /**
11716  * g_datalist_id_dup_data:
11717  * @datalist: location of a datalist
11718  * @key_id: the #GQuark identifying a data element
11719  * @dup_func: (allow-none): function to duplicate the old value
11720  * @user_data: (allow-none): passed as user_data to @dup_func
11721  *
11722  * This is a variant of g_datalist_id_get_data() which
11723  * returns a 'duplicate' of the value. @dup_func defines the
11724  * meaning of 'duplicate' in this context, it could e.g.
11725  * take a reference on a ref-counted object.
11726  *
11727  * If the @key_id is not set in the datalist then @dup_func
11728  * will be called with a %NULL argument.
11729  *
11730  * Note that @dup_func is called while the datalist is locked, so it
11731  * is not allowed to read or modify the datalist.
11732  *
11733  * This function can be useful to avoid races when multiple
11734  * threads are using the same datalist and the same key.
11735  *
11736  * Returns: the result of calling @dup_func on the value associated with @key_id in @datalist, or %NULL if not set. If @dup_func is %NULL, the value is returned unmodified.
11737  * Since: 2.34
11738  */
11739
11740
11741 /**
11742  * g_datalist_id_get_data:
11743  * @datalist: a datalist.
11744  * @key_id: the #GQuark identifying a data element.
11745  *
11746  * Retrieves the data element corresponding to @key_id.
11747  *
11748  * Returns: the data element, or %NULL if it is not found.
11749  */
11750
11751
11752 /**
11753  * g_datalist_id_remove_data:
11754  * @dl: a datalist.
11755  * @q: the #GQuark identifying the data element.
11756  *
11757  * Removes an element, using its #GQuark identifier.
11758  */
11759
11760
11761 /**
11762  * g_datalist_id_remove_no_notify:
11763  * @datalist: a datalist.
11764  * @key_id: the #GQuark identifying a data element.
11765  *
11766  * Removes an element, without calling its destroy notification
11767  * function.
11768  *
11769  * Returns: the data previously stored at @key_id, or %NULL if none.
11770  */
11771
11772
11773 /**
11774  * g_datalist_id_replace_data:
11775  * @datalist: location of a datalist
11776  * @key_id: the #GQuark identifying a data element
11777  * @oldval: (allow-none): the old value to compare against
11778  * @newval: (allow-none): the new value to replace it with
11779  * @destroy: (allow-none): destroy notify for the new value
11780  * @old_destroy: (allow-none): destroy notify for the existing value
11781  *
11782  * Compares the member that is associated with @key_id in
11783  * @datalist to @oldval, and if they are the same, replace
11784  * @oldval with @newval.
11785  *
11786  * This is like a typical atomic compare-and-exchange
11787  * operation, for a member of @datalist.
11788  *
11789  * If the previous value was replaced then ownership of the
11790  * old value (@oldval) is passed to the caller, including
11791  * the registred destroy notify for it (passed out in @old_destroy).
11792  * Its up to the caller to free this as he wishes, which may
11793  * or may not include using @old_destroy as sometimes replacement
11794  * should not destroy the object in the normal way.
11795  *
11796  * Return: %TRUE if the existing value for @key_id was replaced
11797  *  by @newval, %FALSE otherwise.
11798  *
11799  * Since: 2.34
11800  */
11801
11802
11803 /**
11804  * g_datalist_id_set_data:
11805  * @dl: a datalist.
11806  * @q: the #GQuark to identify the data element.
11807  * @d: (allow-none): the data element, or %NULL to remove any previous element corresponding to @q.
11808  *
11809  * Sets the data corresponding to the given #GQuark id. Any previous
11810  * data with the same key is removed, and its destroy function is
11811  * called.
11812  */
11813
11814
11815 /**
11816  * g_datalist_id_set_data_full:
11817  * @datalist: a datalist.
11818  * @key_id: the #GQuark to identify the data element.
11819  * @data: (allow-none): the data element or %NULL to remove any previous element corresponding to @key_id.
11820  * @destroy_func: the function to call when the data element is removed. This function will be called with the data element and can be used to free any memory allocated for it. If @data is %NULL, then @destroy_func must also be %NULL.
11821  *
11822  * Sets the data corresponding to the given #GQuark id, and the
11823  * function to be called when the element is removed from the datalist.
11824  * Any previous data with the same key is removed, and its destroy
11825  * function is called.
11826  */
11827
11828
11829 /**
11830  * g_datalist_init:
11831  * @datalist: a pointer to a pointer to a datalist.
11832  *
11833  * Resets the datalist to %NULL. It does not free any memory or call
11834  * any destroy functions.
11835  */
11836
11837
11838 /**
11839  * g_datalist_remove_data:
11840  * @dl: a datalist.
11841  * @k: the string identifying the data element.
11842  *
11843  * Removes an element using its string identifier. The data element's
11844  * destroy function is called if it has been set.
11845  */
11846
11847
11848 /**
11849  * g_datalist_remove_no_notify:
11850  * @dl: a datalist.
11851  * @k: the string identifying the data element.
11852  *
11853  * Removes an element, without calling its destroy notifier.
11854  */
11855
11856
11857 /**
11858  * g_datalist_set_data:
11859  * @dl: a datalist.
11860  * @k: the string to identify the data element.
11861  * @d: (allow-none): the data element, or %NULL to remove any previous element corresponding to @k.
11862  *
11863  * Sets the data element corresponding to the given string identifier.
11864  */
11865
11866
11867 /**
11868  * g_datalist_set_data_full:
11869  * @dl: a datalist.
11870  * @k: the string to identify the data element.
11871  * @d: (allow-none): the data element, or %NULL to remove any previous element corresponding to @k.
11872  * @f: the function to call when the data element is removed. This function will be called with the data element and can be used to free any memory allocated for it. If @d is %NULL, then @f must also be %NULL.
11873  *
11874  * Sets the data element corresponding to the given string identifier,
11875  * and the function to be called when the data element is removed.
11876  */
11877
11878
11879 /**
11880  * g_datalist_set_flags:
11881  * @datalist: pointer to the location that holds a list
11882  * @flags: the flags to turn on. The values of the flags are restricted by %G_DATALIST_FLAGS_MASK (currently 3; giving two possible boolean flags). A value for @flags that doesn't fit within the mask is an error.
11883  *
11884  * Turns on flag values for a data list. This function is used
11885  * to keep a small number of boolean flags in an object with
11886  * a data list without using any additional space. It is
11887  * not generally useful except in circumstances where space
11888  * is very tight. (It is used in the base #GObject type, for
11889  * example.)
11890  *
11891  * Since: 2.8
11892  */
11893
11894
11895 /**
11896  * g_datalist_unset_flags:
11897  * @datalist: pointer to the location that holds a list
11898  * @flags: the flags to turn off. The values of the flags are restricted by %G_DATALIST_FLAGS_MASK (currently 3: giving two possible boolean flags). A value for @flags that doesn't fit within the mask is an error.
11899  *
11900  * Turns off flag values for a data list. See g_datalist_unset_flags()
11901  *
11902  * Since: 2.8
11903  */
11904
11905
11906 /**
11907  * g_dataset_destroy:
11908  * @dataset_location: the location identifying the dataset.
11909  *
11910  * Destroys the dataset, freeing all memory allocated, and calling any
11911  * destroy functions set for data elements.
11912  */
11913
11914
11915 /**
11916  * g_dataset_foreach:
11917  * @dataset_location: the location identifying the dataset.
11918  * @func: the function to call for each data element.
11919  * @user_data: user data to pass to the function.
11920  *
11921  * Calls the given function for each data element which is associated
11922  * with the given location. Note that this function is NOT thread-safe.
11923  * So unless @datalist can be protected from any modifications during
11924  * invocation of this function, it should not be called.
11925  */
11926
11927
11928 /**
11929  * g_dataset_get_data:
11930  * @l: the location identifying the dataset.
11931  * @k: the string identifying the data element.
11932  *
11933  * Gets the data element corresponding to a string.
11934  *
11935  * Returns: the data element corresponding to the string, or %NULL if it is not found.
11936  */
11937
11938
11939 /**
11940  * g_dataset_id_get_data:
11941  * @dataset_location: the location identifying the dataset.
11942  * @key_id: the #GQuark id to identify the data element.
11943  *
11944  * Gets the data element corresponding to a #GQuark.
11945  *
11946  * Returns: the data element corresponding to the #GQuark, or %NULL if it is not found.
11947  */
11948
11949
11950 /**
11951  * g_dataset_id_remove_data:
11952  * @l: the location identifying the dataset.
11953  * @k: the #GQuark id identifying the data element.
11954  *
11955  * Removes a data element from a dataset. The data element's destroy
11956  * function is called if it has been set.
11957  */
11958
11959
11960 /**
11961  * g_dataset_id_remove_no_notify:
11962  * @dataset_location: the location identifying the dataset.
11963  * @key_id: the #GQuark ID identifying the data element.
11964  *
11965  * Removes an element, without calling its destroy notification
11966  * function.
11967  *
11968  * Returns: the data previously stored at @key_id, or %NULL if none.
11969  */
11970
11971
11972 /**
11973  * g_dataset_id_set_data:
11974  * @l: the location identifying the dataset.
11975  * @k: the #GQuark id to identify the data element.
11976  * @d: the data element.
11977  *
11978  * Sets the data element associated with the given #GQuark id. Any
11979  * previous data with the same key is removed, and its destroy function
11980  * is called.
11981  */
11982
11983
11984 /**
11985  * g_dataset_id_set_data_full:
11986  * @dataset_location: the location identifying the dataset.
11987  * @key_id: the #GQuark id to identify the data element.
11988  * @data: the data element.
11989  * @destroy_func: the function to call when the data element is removed. This function will be called with the data element and can be used to free any memory allocated for it.
11990  *
11991  * Sets the data element associated with the given #GQuark id, and also
11992  * the function to call when the data element is destroyed. Any
11993  * previous data with the same key is removed, and its destroy function
11994  * is called.
11995  */
11996
11997
11998 /**
11999  * g_dataset_remove_data:
12000  * @l: the location identifying the dataset.
12001  * @k: the string identifying the data element.
12002  *
12003  * Removes a data element corresponding to a string. Its destroy
12004  * function is called if it has been set.
12005  */
12006
12007
12008 /**
12009  * g_dataset_remove_no_notify:
12010  * @l: the location identifying the dataset.
12011  * @k: the string identifying the data element.
12012  *
12013  * Removes an element, without calling its destroy notifier.
12014  */
12015
12016
12017 /**
12018  * g_dataset_set_data:
12019  * @l: the location identifying the dataset.
12020  * @k: the string to identify the data element.
12021  * @d: the data element.
12022  *
12023  * Sets the data corresponding to the given string identifier.
12024  */
12025
12026
12027 /**
12028  * g_dataset_set_data_full:
12029  * @l: the location identifying the dataset.
12030  * @k: the string to identify the data element.
12031  * @d: the data element.
12032  * @f: the function to call when the data element is removed. This function will be called with the data element and can be used to free any memory allocated for it.
12033  *
12034  * Sets the data corresponding to the given string identifier, and the
12035  * function to call when the data element is destroyed.
12036  */
12037
12038
12039 /**
12040  * g_date_add_days:
12041  * @date: a #GDate to increment
12042  * @n_days: number of days to move the date forward
12043  *
12044  * Increments a date some number of days.
12045  * To move forward by weeks, add weeks*7 days.
12046  * The date must be valid.
12047  */
12048
12049
12050 /**
12051  * g_date_add_months:
12052  * @date: a #GDate to increment
12053  * @n_months: number of months to move forward
12054  *
12055  * Increments a date by some number of months.
12056  * If the day of the month is greater than 28,
12057  * this routine may change the day of the month
12058  * (because the destination month may not have
12059  * the current day in it). The date must be valid.
12060  */
12061
12062
12063 /**
12064  * g_date_add_years:
12065  * @date: a #GDate to increment
12066  * @n_years: number of years to move forward
12067  *
12068  * Increments a date by some number of years.
12069  * If the date is February 29, and the destination
12070  * year is not a leap year, the date will be changed
12071  * to February 28. The date must be valid.
12072  */
12073
12074
12075 /**
12076  * g_date_clamp:
12077  * @date: a #GDate to clamp
12078  * @min_date: minimum accepted value for @date
12079  * @max_date: maximum accepted value for @date
12080  *
12081  * If @date is prior to @min_date, sets @date equal to @min_date.
12082  * If @date falls after @max_date, sets @date equal to @max_date.
12083  * Otherwise, @date is unchanged.
12084  * Either of @min_date and @max_date may be %NULL.
12085  * All non-%NULL dates must be valid.
12086  */
12087
12088
12089 /**
12090  * g_date_clear:
12091  * @date: pointer to one or more dates to clear
12092  * @n_dates: number of dates to clear
12093  *
12094  * Initializes one or more #GDate structs to a sane but invalid
12095  * state. The cleared dates will not represent an existing date, but will
12096  * not contain garbage. Useful to init a date declared on the stack.
12097  * Validity can be tested with g_date_valid().
12098  */
12099
12100
12101 /**
12102  * g_date_compare:
12103  * @lhs: first date to compare
12104  * @rhs: second date to compare
12105  *
12106  * qsort()-style comparison function for dates.
12107  * Both dates must be valid.
12108  *
12109  * Returns: 0 for equal, less than zero if @lhs is less than @rhs, greater than zero if @lhs is greater than @rhs
12110  */
12111
12112
12113 /**
12114  * g_date_days_between:
12115  * @date1: the first date
12116  * @date2: the second date
12117  *
12118  * Computes the number of days between two dates.
12119  * If @date2 is prior to @date1, the returned value is negative.
12120  * Both dates must be valid.
12121  *
12122  * Returns: the number of days between @date1 and @date2
12123  */
12124
12125
12126 /**
12127  * g_date_free:
12128  * @date: a #GDate to free
12129  *
12130  * Frees a #GDate returned from g_date_new().
12131  */
12132
12133
12134 /**
12135  * g_date_get_day:
12136  * @date: a #GDate to extract the day of the month from
12137  *
12138  * Returns the day of the month. The date must be valid.
12139  *
12140  * Returns: day of the month
12141  */
12142
12143
12144 /**
12145  * g_date_get_day_of_year:
12146  * @date: a #GDate to extract day of year from
12147  *
12148  * Returns the day of the year, where Jan 1 is the first day of the
12149  * year. The date must be valid.
12150  *
12151  * Returns: day of the year
12152  */
12153
12154
12155 /**
12156  * g_date_get_days_in_month:
12157  * @month: month
12158  * @year: year
12159  *
12160  * Returns the number of days in a month, taking leap
12161  * years into account.
12162  *
12163  * Returns: number of days in @month during the @year
12164  */
12165
12166
12167 /**
12168  * g_date_get_iso8601_week_of_year:
12169  * @date: a valid #GDate
12170  *
12171  * Returns the week of the year, where weeks are interpreted according
12172  * to ISO 8601.
12173  *
12174  * Returns: ISO 8601 week number of the year.
12175  * Since: 2.6
12176  */
12177
12178
12179 /**
12180  * g_date_get_julian:
12181  * @date: a #GDate to extract the Julian day from
12182  *
12183  * Returns the Julian day or "serial number" of the #GDate. The
12184  * Julian day is simply the number of days since January 1, Year 1; i.e.,
12185  * January 1, Year 1 is Julian day 1; January 2, Year 1 is Julian day 2,
12186  * etc. The date must be valid.
12187  *
12188  * Returns: Julian day
12189  */
12190
12191
12192 /**
12193  * g_date_get_monday_week_of_year:
12194  * @date: a #GDate
12195  *
12196  * Returns the week of the year, where weeks are understood to start on
12197  * Monday. If the date is before the first Monday of the year, return
12198  * 0. The date must be valid.
12199  *
12200  * Returns: week of the year
12201  */
12202
12203
12204 /**
12205  * g_date_get_monday_weeks_in_year:
12206  * @year: a year
12207  *
12208  * Returns the number of weeks in the year, where weeks
12209  * are taken to start on Monday. Will be 52 or 53. The
12210  * date must be valid. (Years always have 52 7-day periods,
12211  * plus 1 or 2 extra days depending on whether it's a leap
12212  * year. This function is basically telling you how many
12213  * Mondays are in the year, i.e. there are 53 Mondays if
12214  * one of the extra days happens to be a Monday.)
12215  *
12216  * Returns: number of Mondays in the year
12217  */
12218
12219
12220 /**
12221  * g_date_get_month:
12222  * @date: a #GDate to get the month from
12223  *
12224  * Returns the month of the year. The date must be valid.
12225  *
12226  * Returns: month of the year as a #GDateMonth
12227  */
12228
12229
12230 /**
12231  * g_date_get_sunday_week_of_year:
12232  * @date: a #GDate
12233  *
12234  * Returns the week of the year during which this date falls, if weeks
12235  * are understood to being on Sunday. The date must be valid. Can return
12236  * 0 if the day is before the first Sunday of the year.
12237  *
12238  * Returns: week number
12239  */
12240
12241
12242 /**
12243  * g_date_get_sunday_weeks_in_year:
12244  * @year: year to count weeks in
12245  *
12246  * Returns the number of weeks in the year, where weeks
12247  * are taken to start on Sunday. Will be 52 or 53. The
12248  * date must be valid. (Years always have 52 7-day periods,
12249  * plus 1 or 2 extra days depending on whether it's a leap
12250  * year. This function is basically telling you how many
12251  * Sundays are in the year, i.e. there are 53 Sundays if
12252  * one of the extra days happens to be a Sunday.)
12253  *
12254  * Returns: the number of weeks in @year
12255  */
12256
12257
12258 /**
12259  * g_date_get_weekday:
12260  * @date: a #GDate
12261  *
12262  * Returns the day of the week for a #GDate. The date must be valid.
12263  *
12264  * Returns: day of the week as a #GDateWeekday.
12265  */
12266
12267
12268 /**
12269  * g_date_get_year:
12270  * @date: a #GDate
12271  *
12272  * Returns the year of a #GDate. The date must be valid.
12273  *
12274  * Returns: year in which the date falls
12275  */
12276
12277
12278 /**
12279  * g_date_is_first_of_month:
12280  * @date: a #GDate to check
12281  *
12282  * Returns %TRUE if the date is on the first of a month.
12283  * The date must be valid.
12284  *
12285  * Returns: %TRUE if the date is the first of the month
12286  */
12287
12288
12289 /**
12290  * g_date_is_last_of_month:
12291  * @date: a #GDate to check
12292  *
12293  * Returns %TRUE if the date is the last day of the month.
12294  * The date must be valid.
12295  *
12296  * Returns: %TRUE if the date is the last day of the month
12297  */
12298
12299
12300 /**
12301  * g_date_is_leap_year:
12302  * @year: year to check
12303  *
12304  * Returns %TRUE if the year is a leap year.
12305  * <footnote><para>For the purposes of this function,
12306  * leap year is every year divisible by 4 unless that year
12307  * is divisible by 100. If it is divisible by 100 it would
12308  * be a leap year only if that year is also divisible
12309  * by 400.</para></footnote>
12310  *
12311  * Returns: %TRUE if the year is a leap year
12312  */
12313
12314
12315 /**
12316  * g_date_new:
12317  *
12318  * Allocates a #GDate and initializes
12319  * it to a sane state. The new date will
12320  * be cleared (as if you'd called g_date_clear()) but invalid (it won't
12321  * represent an existing day). Free the return value with g_date_free().
12322  *
12323  * Returns: a newly-allocated #GDate
12324  */
12325
12326
12327 /**
12328  * g_date_new_dmy:
12329  * @day: day of the month
12330  * @month: month of the year
12331  * @year: year
12332  *
12333  * Like g_date_new(), but also sets the value of the date. Assuming the
12334  * day-month-year triplet you pass in represents an existing day, the
12335  * returned date will be valid.
12336  *
12337  * Returns: a newly-allocated #GDate initialized with @day, @month, and @year
12338  */
12339
12340
12341 /**
12342  * g_date_new_julian:
12343  * @julian_day: days since January 1, Year 1
12344  *
12345  * Like g_date_new(), but also sets the value of the date. Assuming the
12346  * Julian day number you pass in is valid (greater than 0, less than an
12347  * unreasonably large number), the returned date will be valid.
12348  *
12349  * Returns: a newly-allocated #GDate initialized with @julian_day
12350  */
12351
12352
12353 /**
12354  * g_date_order:
12355  * @date1: the first date
12356  * @date2: the second date
12357  *
12358  * Checks if @date1 is less than or equal to @date2,
12359  * and swap the values if this is not the case.
12360  */
12361
12362
12363 /**
12364  * g_date_set_day:
12365  * @date: a #GDate
12366  * @day: day to set
12367  *
12368  * Sets the day of the month for a #GDate. If the resulting
12369  * day-month-year triplet is invalid, the date will be invalid.
12370  */
12371
12372
12373 /**
12374  * g_date_set_dmy:
12375  * @date: a #GDate
12376  * @day: day
12377  * @month: month
12378  * @y: year
12379  *
12380  * Sets the value of a #GDate from a day, month, and year.
12381  * The day-month-year triplet must be valid; if you aren't
12382  * sure it is, call g_date_valid_dmy() to check before you
12383  * set it.
12384  */
12385
12386
12387 /**
12388  * g_date_set_julian:
12389  * @date: a #GDate
12390  * @julian_date: Julian day number (days since January 1, Year 1)
12391  *
12392  * Sets the value of a #GDate from a Julian day number.
12393  */
12394
12395
12396 /**
12397  * g_date_set_month:
12398  * @date: a #GDate
12399  * @month: month to set
12400  *
12401  * Sets the month of the year for a #GDate.  If the resulting
12402  * day-month-year triplet is invalid, the date will be invalid.
12403  */
12404
12405
12406 /**
12407  * g_date_set_parse:
12408  * @date: a #GDate to fill in
12409  * @str: string to parse
12410  *
12411  * Parses a user-inputted string @str, and try to figure out what date it
12412  * represents, taking the <link linkend="setlocale">current locale</link>
12413  * into account. If the string is successfully parsed, the date will be
12414  * valid after the call. Otherwise, it will be invalid. You should check
12415  * using g_date_valid() to see whether the parsing succeeded.
12416  *
12417  * This function is not appropriate for file formats and the like; it
12418  * isn't very precise, and its exact behavior varies with the locale.
12419  * It's intended to be a heuristic routine that guesses what the user
12420  * means by a given string (and it does work pretty well in that
12421  * capacity).
12422  */
12423
12424
12425 /**
12426  * g_date_set_time:
12427  * @date: a #GDate.
12428  * @time_: #GTime value to set.
12429  *
12430  * Sets the value of a date from a #GTime value.
12431  * The time to date conversion is done using the user's current timezone.
12432  *
12433  * Deprecated: 2.10: Use g_date_set_time_t() instead.
12434  */
12435
12436
12437 /**
12438  * g_date_set_time_t:
12439  * @date: a #GDate
12440  * @timet: <type>time_t</type> value to set
12441  *
12442  * Sets the value of a date to the date corresponding to a time
12443  * specified as a time_t. The time to date conversion is done using
12444  * the user's current timezone.
12445  *
12446  * To set the value of a date to the current day, you could write:
12447  * |[
12448  *  g_date_set_time_t (date, time (NULL));
12449  * ]|
12450  *
12451  * Since: 2.10
12452  */
12453
12454
12455 /**
12456  * g_date_set_time_val:
12457  * @date: a #GDate
12458  * @timeval: #GTimeVal value to set
12459  *
12460  * Sets the value of a date from a #GTimeVal value.  Note that the
12461  * @tv_usec member is ignored, because #GDate can't make use of the
12462  * additional precision.
12463  *
12464  * The time to date conversion is done using the user's current timezone.
12465  *
12466  * Since: 2.10
12467  */
12468
12469
12470 /**
12471  * g_date_set_year:
12472  * @date: a #GDate
12473  * @year: year to set
12474  *
12475  * Sets the year for a #GDate. If the resulting day-month-year
12476  * triplet is invalid, the date will be invalid.
12477  */
12478
12479
12480 /**
12481  * g_date_strftime:
12482  * @s: destination buffer
12483  * @slen: buffer size
12484  * @format: format string
12485  * @date: valid #GDate
12486  *
12487  * Generates a printed representation of the date, in a
12488  * <link linkend="setlocale">locale</link>-specific way.
12489  * Works just like the platform's C library strftime() function,
12490  * but only accepts date-related formats; time-related formats
12491  * give undefined results. Date must be valid. Unlike strftime()
12492  * (which uses the locale encoding), works on a UTF-8 format
12493  * string and stores a UTF-8 result.
12494  *
12495  * This function does not provide any conversion specifiers in
12496  * addition to those implemented by the platform's C library.
12497  * For example, don't expect that using g_date_strftime() would
12498  * make the \%F provided by the C99 strftime() work on Windows
12499  * where the C library only complies to C89.
12500  *
12501  * Returns: number of characters written to the buffer, or 0 the buffer was too small
12502  */
12503
12504
12505 /**
12506  * g_date_subtract_days:
12507  * @date: a #GDate to decrement
12508  * @n_days: number of days to move
12509  *
12510  * Moves a date some number of days into the past.
12511  * To move by weeks, just move by weeks*7 days.
12512  * The date must be valid.
12513  */
12514
12515
12516 /**
12517  * g_date_subtract_months:
12518  * @date: a #GDate to decrement
12519  * @n_months: number of months to move
12520  *
12521  * Moves a date some number of months into the past.
12522  * If the current day of the month doesn't exist in
12523  * the destination month, the day of the month
12524  * may change. The date must be valid.
12525  */
12526
12527
12528 /**
12529  * g_date_subtract_years:
12530  * @date: a #GDate to decrement
12531  * @n_years: number of years to move
12532  *
12533  * Moves a date some number of years into the past.
12534  * If the current day doesn't exist in the destination
12535  * year (i.e. it's February 29 and you move to a non-leap-year)
12536  * then the day is changed to February 29. The date
12537  * must be valid.
12538  */
12539
12540
12541 /**
12542  * g_date_time_add:
12543  * @datetime: a #GDateTime
12544  * @timespan: a #GTimeSpan
12545  *
12546  * Creates a copy of @datetime and adds the specified timespan to the copy.
12547  *
12548  * Returns: the newly created #GDateTime which should be freed with g_date_time_unref().
12549  * Since: 2.26
12550  */
12551
12552
12553 /**
12554  * g_date_time_add_days:
12555  * @datetime: a #GDateTime
12556  * @days: the number of days
12557  *
12558  * Creates a copy of @datetime and adds the specified number of days to the
12559  * copy.
12560  *
12561  * Returns: the newly created #GDateTime which should be freed with g_date_time_unref().
12562  * Since: 2.26
12563  */
12564
12565
12566 /**
12567  * g_date_time_add_full:
12568  * @datetime: a #GDateTime
12569  * @years: the number of years to add
12570  * @months: the number of months to add
12571  * @days: the number of days to add
12572  * @hours: the number of hours to add
12573  * @minutes: the number of minutes to add
12574  * @seconds: the number of seconds to add
12575  *
12576  * Creates a new #GDateTime adding the specified values to the current date and
12577  * time in @datetime.
12578  *
12579  * Returns: the newly created #GDateTime that should be freed with g_date_time_unref().
12580  * Since: 2.26
12581  */
12582
12583
12584 /**
12585  * g_date_time_add_hours:
12586  * @datetime: a #GDateTime
12587  * @hours: the number of hours to add
12588  *
12589  * Creates a copy of @datetime and adds the specified number of hours
12590  *
12591  * Returns: the newly created #GDateTime which should be freed with g_date_time_unref().
12592  * Since: 2.26
12593  */
12594
12595
12596 /**
12597  * g_date_time_add_minutes:
12598  * @datetime: a #GDateTime
12599  * @minutes: the number of minutes to add
12600  *
12601  * Creates a copy of @datetime adding the specified number of minutes.
12602  *
12603  * Returns: the newly created #GDateTime which should be freed with g_date_time_unref().
12604  * Since: 2.26
12605  */
12606
12607
12608 /**
12609  * g_date_time_add_months:
12610  * @datetime: a #GDateTime
12611  * @months: the number of months
12612  *
12613  * Creates a copy of @datetime and adds the specified number of months to the
12614  * copy.
12615  *
12616  * Returns: the newly created #GDateTime which should be freed with g_date_time_unref().
12617  * Since: 2.26
12618  */
12619
12620
12621 /**
12622  * g_date_time_add_seconds:
12623  * @datetime: a #GDateTime
12624  * @seconds: the number of seconds to add
12625  *
12626  * Creates a copy of @datetime and adds the specified number of seconds.
12627  *
12628  * Returns: the newly created #GDateTime which should be freed with g_date_time_unref().
12629  * Since: 2.26
12630  */
12631
12632
12633 /**
12634  * g_date_time_add_weeks:
12635  * @datetime: a #GDateTime
12636  * @weeks: the number of weeks
12637  *
12638  * Creates a copy of @datetime and adds the specified number of weeks to the
12639  * copy.
12640  *
12641  * Returns: the newly created #GDateTime which should be freed with g_date_time_unref().
12642  * Since: 2.26
12643  */
12644
12645
12646 /**
12647  * g_date_time_add_years:
12648  * @datetime: a #GDateTime
12649  * @years: the number of years
12650  *
12651  * Creates a copy of @datetime and adds the specified number of years to the
12652  * copy.
12653  *
12654  * Returns: the newly created #GDateTime which should be freed with g_date_time_unref().
12655  * Since: 2.26
12656  */
12657
12658
12659 /**
12660  * g_date_time_compare:
12661  * @dt1: first #GDateTime to compare
12662  * @dt2: second #GDateTime to compare
12663  *
12664  * A comparison function for #GDateTimes that is suitable
12665  * as a #GCompareFunc. Both #GDateTimes must be non-%NULL.
12666  *
12667  * Returns: -1, 0 or 1 if @dt1 is less than, equal to or greater than @dt2.
12668  * Since: 2.26
12669  */
12670
12671
12672 /**
12673  * g_date_time_difference:
12674  * @end: a #GDateTime
12675  * @begin: a #GDateTime
12676  *
12677  * Calculates the difference in time between @end and @begin.  The
12678  * #GTimeSpan that is returned is effectively @end - @begin (ie:
12679  * positive if the first parameter is larger).
12680  *
12681  * Returns: the difference between the two #GDateTime, as a time span expressed in microseconds.
12682  * Since: 2.26
12683  */
12684
12685
12686 /**
12687  * g_date_time_equal:
12688  * @dt1: a #GDateTime
12689  * @dt2: a #GDateTime
12690  *
12691  * Checks to see if @dt1 and @dt2 are equal.
12692  *
12693  * Equal here means that they represent the same moment after converting
12694  * them to the same time zone.
12695  *
12696  * Returns: %TRUE if @dt1 and @dt2 are equal
12697  * Since: 2.26
12698  */
12699
12700
12701 /**
12702  * g_date_time_format:
12703  * @datetime: A #GDateTime
12704  * @format: a valid UTF-8 string, containing the format for the #GDateTime
12705  *
12706  * Creates a newly allocated string representing the requested @format.
12707  *
12708  * The format strings understood by this function are a subset of the
12709  * strftime() format language as specified by C99.  The \%D, \%U and \%W
12710  * conversions are not supported, nor is the 'E' modifier.  The GNU
12711  * extensions \%k, \%l, \%s and \%P are supported, however, as are the
12712  * '0', '_' and '-' modifiers.
12713  *
12714  * In contrast to strftime(), this function always produces a UTF-8
12715  * string, regardless of the current locale.  Note that the rendering of
12716  * many formats is locale-dependent and may not match the strftime()
12717  * output exactly.
12718  *
12719  * The following format specifiers are supported:
12720  *
12721  * <variablelist>
12722  *  <varlistentry><term>
12723  *    <literal>\%a</literal>:
12724  *   </term><listitem><simpara>
12725  *    the abbreviated weekday name according to the current locale
12726  *  </simpara></listitem></varlistentry>
12727  *  <varlistentry><term>
12728  *    <literal>\%A</literal>:
12729  *   </term><listitem><simpara>
12730  *    the full weekday name according to the current locale
12731  *  </simpara></listitem></varlistentry>
12732  *  <varlistentry><term>
12733  *    <literal>\%b</literal>:
12734  *   </term><listitem><simpara>
12735  *    the abbreviated month name according to the current locale
12736  *  </simpara></listitem></varlistentry>
12737  *  <varlistentry><term>
12738  *    <literal>\%B</literal>:
12739  *   </term><listitem><simpara>
12740  *    the full month name according to the current locale
12741  *  </simpara></listitem></varlistentry>
12742  *  <varlistentry><term>
12743  *    <literal>\%c</literal>:
12744  *   </term><listitem><simpara>
12745  *    the  preferred  date  and  time  representation  for the current locale
12746  *  </simpara></listitem></varlistentry>
12747  *  <varlistentry><term>
12748  *    <literal>\%C</literal>:
12749  *   </term><listitem><simpara>
12750  *    The century number (year/100) as a 2-digit integer (00-99)
12751  *  </simpara></listitem></varlistentry>
12752  *  <varlistentry><term>
12753  *    <literal>\%d</literal>:
12754  *   </term><listitem><simpara>
12755  *    the day of the month as a decimal number (range 01 to 31)
12756  *  </simpara></listitem></varlistentry>
12757  *  <varlistentry><term>
12758  *    <literal>\%e</literal>:
12759  *   </term><listitem><simpara>
12760  *    the day of the month as a decimal number (range  1 to 31)
12761  *  </simpara></listitem></varlistentry>
12762  *  <varlistentry><term>
12763  *    <literal>\%F</literal>:
12764  *   </term><listitem><simpara>
12765  *    equivalent to <literal>\%Y-\%m-\%d</literal> (the ISO 8601 date
12766  *    format)
12767  *  </simpara></listitem></varlistentry>
12768  *  <varlistentry><term>
12769  *    <literal>\%g</literal>:
12770  *   </term><listitem><simpara>
12771  *    the last two digits of the ISO 8601 week-based year as a decimal
12772  *    number (00-99).  This works well with \%V and \%u.
12773  *  </simpara></listitem></varlistentry>
12774  *  <varlistentry><term>
12775  *    <literal>\%G</literal>:
12776  *   </term><listitem><simpara>
12777  *    the ISO 8601 week-based year as a decimal number.  This works well
12778  *    with \%V and \%u.
12779  *  </simpara></listitem></varlistentry>
12780  *  <varlistentry><term>
12781  *    <literal>\%h</literal>:
12782  *   </term><listitem><simpara>
12783  *    equivalent to <literal>\%b</literal>
12784  *  </simpara></listitem></varlistentry>
12785  *  <varlistentry><term>
12786  *    <literal>\%H</literal>:
12787  *   </term><listitem><simpara>
12788  *    the hour as a decimal number using a 24-hour clock (range 00 to
12789  *    23)
12790  *  </simpara></listitem></varlistentry>
12791  *  <varlistentry><term>
12792  *    <literal>\%I</literal>:
12793  *   </term><listitem><simpara>
12794  *    the hour as a decimal number using a 12-hour clock (range 01 to
12795  *    12)
12796  *  </simpara></listitem></varlistentry>
12797  *  <varlistentry><term>
12798  *    <literal>\%j</literal>:
12799  *   </term><listitem><simpara>
12800  *    the day of the year as a decimal number (range 001 to 366)
12801  *  </simpara></listitem></varlistentry>
12802  *  <varlistentry><term>
12803  *    <literal>\%k</literal>:
12804  *   </term><listitem><simpara>
12805  *    the hour (24-hour clock) as a decimal number (range 0 to 23);
12806  *    single digits are preceded by a blank
12807  *  </simpara></listitem></varlistentry>
12808  *  <varlistentry><term>
12809  *    <literal>\%l</literal>:
12810  *   </term><listitem><simpara>
12811  *    the hour (12-hour clock) as a decimal number (range 1 to 12);
12812  *    single digits are preceded by a blank
12813  *  </simpara></listitem></varlistentry>
12814  *  <varlistentry><term>
12815  *    <literal>\%m</literal>:
12816  *   </term><listitem><simpara>
12817  *    the month as a decimal number (range 01 to 12)
12818  *  </simpara></listitem></varlistentry>
12819  *  <varlistentry><term>
12820  *    <literal>\%M</literal>:
12821  *   </term><listitem><simpara>
12822  *    the minute as a decimal number (range 00 to 59)
12823  *  </simpara></listitem></varlistentry>
12824  *  <varlistentry><term>
12825  *    <literal>\%p</literal>:
12826  *   </term><listitem><simpara>
12827  *    either "AM" or "PM" according to the given time value, or the
12828  *    corresponding  strings for the current locale.  Noon is treated as
12829  *    "PM" and midnight as "AM".
12830  *  </simpara></listitem></varlistentry>
12831  *  <varlistentry><term>
12832  *    <literal>\%P</literal>:
12833  *   </term><listitem><simpara>
12834  *    like \%p but lowercase: "am" or "pm" or a corresponding string for
12835  *    the current locale
12836  *  </simpara></listitem></varlistentry>
12837  *  <varlistentry><term>
12838  *    <literal>\%r</literal>:
12839  *   </term><listitem><simpara>
12840  *    the time in a.m. or p.m. notation
12841  *  </simpara></listitem></varlistentry>
12842  *  <varlistentry><term>
12843  *    <literal>\%R</literal>:
12844  *   </term><listitem><simpara>
12845  *    the time in 24-hour notation (<literal>\%H:\%M</literal>)
12846  *  </simpara></listitem></varlistentry>
12847  *  <varlistentry><term>
12848  *    <literal>\%s</literal>:
12849  *   </term><listitem><simpara>
12850  *    the number of seconds since the Epoch, that is, since 1970-01-01
12851  *    00:00:00 UTC
12852  *  </simpara></listitem></varlistentry>
12853  *  <varlistentry><term>
12854  *    <literal>\%S</literal>:
12855  *   </term><listitem><simpara>
12856  *    the second as a decimal number (range 00 to 60)
12857  *  </simpara></listitem></varlistentry>
12858  *  <varlistentry><term>
12859  *    <literal>\%t</literal>:
12860  *   </term><listitem><simpara>
12861  *    a tab character
12862  *  </simpara></listitem></varlistentry>
12863  *  <varlistentry><term>
12864  *    <literal>\%T</literal>:
12865  *   </term><listitem><simpara>
12866  *    the time in 24-hour notation with seconds (<literal>\%H:\%M:\%S</literal>)
12867  *  </simpara></listitem></varlistentry>
12868  *  <varlistentry><term>
12869  *    <literal>\%u</literal>:
12870  *   </term><listitem><simpara>
12871  *    the ISO 8601 standard day of the week as a decimal, range 1 to 7,
12872  *    Monday being 1.  This works well with \%G and \%V.
12873  *  </simpara></listitem></varlistentry>
12874  *  <varlistentry><term>
12875  *    <literal>\%V</literal>:
12876  *   </term><listitem><simpara>
12877  *    the ISO 8601 standard week number of the current year as a decimal
12878  *    number, range 01 to 53, where week 1 is the first week that has at
12879  *    least 4 days in the new year. See g_date_time_get_week_of_year().
12880  *    This works well with \%G and \%u.
12881  *  </simpara></listitem></varlistentry>
12882  *  <varlistentry><term>
12883  *    <literal>\%w</literal>:
12884  *   </term><listitem><simpara>
12885  *    the day of the week as a decimal, range 0 to 6, Sunday being 0.
12886  *    This is not the ISO 8601 standard format -- use \%u instead.
12887  *  </simpara></listitem></varlistentry>
12888  *  <varlistentry><term>
12889  *    <literal>\%x</literal>:
12890  *   </term><listitem><simpara>
12891  *    the preferred date representation for the current locale without
12892  *    the time
12893  *  </simpara></listitem></varlistentry>
12894  *  <varlistentry><term>
12895  *    <literal>\%X</literal>:
12896  *   </term><listitem><simpara>
12897  *    the preferred time representation for the current locale without
12898  *    the date
12899  *  </simpara></listitem></varlistentry>
12900  *  <varlistentry><term>
12901  *    <literal>\%y</literal>:
12902  *   </term><listitem><simpara>
12903  *    the year as a decimal number without the century
12904  *  </simpara></listitem></varlistentry>
12905  *  <varlistentry><term>
12906  *    <literal>\%Y</literal>:
12907  *   </term><listitem><simpara>
12908  *    the year as a decimal number including the century
12909  *  </simpara></listitem></varlistentry>
12910  *  <varlistentry><term>
12911  *    <literal>\%z</literal>:
12912  *   </term><listitem><simpara>
12913  *    the time zone as an offset from UTC (+hhmm)
12914  *  </simpara></listitem></varlistentry>
12915  *  <varlistentry><term>
12916  *    <literal>\%:z</literal>:
12917  *   </term><listitem><simpara>
12918  *    the time zone as an offset from UTC (+hh:mm). This is a gnulib strftime extension. Since: 2.38
12919  *  </simpara></listitem></varlistentry>
12920  *  <varlistentry><term>
12921  *    <literal>\%::z</literal>:
12922  *   </term><listitem><simpara>
12923  *    the time zone as an offset from UTC (+hh:mm:ss). This is a gnulib strftime extension. Since: 2.38
12924  *  </simpara></listitem></varlistentry>
12925  *  <varlistentry><term>
12926  *    <literal>\%:::z</literal>:
12927  *   </term><listitem><simpara>
12928  *    the time zone as an offset from UTC, with : to necessary precision
12929  *    (e.g., -04, +05:30). This is a gnulib strftime extension. Since: 2.38
12930  *  </simpara></listitem></varlistentry>
12931  *  <varlistentry><term>
12932  *    <literal>\%Z</literal>:
12933  *   </term><listitem><simpara>
12934  *    the time zone or name or abbreviation
12935  *  </simpara></listitem></varlistentry>
12936  *  <varlistentry><term>
12937  *    <literal>\%\%</literal>:
12938  *   </term><listitem><simpara>
12939  *    a literal <literal>\%</literal> character
12940  *  </simpara></listitem></varlistentry>
12941  * </variablelist>
12942  *
12943  * Some conversion specifications can be modified by preceding the
12944  * conversion specifier by one or more modifier characters. The
12945  * following modifiers are supported for many of the numeric
12946  * conversions:
12947  * <variablelist>
12948  *   <varlistentry>
12949  *     <term>O</term>
12950  *     <listitem>
12951  *       Use alternative numeric symbols, if the current locale
12952  *       supports those.
12953  *     </listitem>
12954  *   </varlistentry>
12955  *   <varlistentry>
12956  *     <term>_</term>
12957  *     <listitem>
12958  *       Pad a numeric result with spaces.
12959  *       This overrides the default padding for the specifier.
12960  *     </listitem>
12961  *   </varlistentry>
12962  *   <varlistentry>
12963  *     <term>-</term>
12964  *     <listitem>
12965  *       Do not pad a numeric result.
12966  *       This overrides the default padding for the specifier.
12967  *     </listitem>
12968  *   </varlistentry>
12969  *   <varlistentry>
12970  *     <term>0</term>
12971  *     <listitem>
12972  *       Pad a numeric result with zeros.
12973  *       This overrides the default padding for the specifier.
12974  *     </listitem>
12975  *   </varlistentry>
12976  * </variablelist>
12977  *
12978  * Returns: a newly allocated string formatted to the requested format or %NULL in the case that there was an error.  The string should be freed with g_free().
12979  * Since: 2.26
12980  */
12981
12982
12983 /**
12984  * g_date_time_get_day_of_month:
12985  * @datetime: a #GDateTime
12986  *
12987  * Retrieves the day of the month represented by @datetime in the gregorian
12988  * calendar.
12989  *
12990  * Returns: the day of the month
12991  * Since: 2.26
12992  */
12993
12994
12995 /**
12996  * g_date_time_get_day_of_week:
12997  * @datetime: a #GDateTime
12998  *
12999  * Retrieves the ISO 8601 day of the week on which @datetime falls (1 is
13000  * Monday, 2 is Tuesday... 7 is Sunday).
13001  *
13002  * Returns: the day of the week
13003  * Since: 2.26
13004  */
13005
13006
13007 /**
13008  * g_date_time_get_day_of_year:
13009  * @datetime: a #GDateTime
13010  *
13011  * Retrieves the day of the year represented by @datetime in the Gregorian
13012  * calendar.
13013  *
13014  * Returns: the day of the year
13015  * Since: 2.26
13016  */
13017
13018
13019 /**
13020  * g_date_time_get_hour:
13021  * @datetime: a #GDateTime
13022  *
13023  * Retrieves the hour of the day represented by @datetime
13024  *
13025  * Returns: the hour of the day
13026  * Since: 2.26
13027  */
13028
13029
13030 /**
13031  * g_date_time_get_microsecond:
13032  * @datetime: a #GDateTime
13033  *
13034  * Retrieves the microsecond of the date represented by @datetime
13035  *
13036  * Returns: the microsecond of the second
13037  * Since: 2.26
13038  */
13039
13040
13041 /**
13042  * g_date_time_get_minute:
13043  * @datetime: a #GDateTime
13044  *
13045  * Retrieves the minute of the hour represented by @datetime
13046  *
13047  * Returns: the minute of the hour
13048  * Since: 2.26
13049  */
13050
13051
13052 /**
13053  * g_date_time_get_month:
13054  * @datetime: a #GDateTime
13055  *
13056  * Retrieves the month of the year represented by @datetime in the Gregorian
13057  * calendar.
13058  *
13059  * Returns: the month represented by @datetime
13060  * Since: 2.26
13061  */
13062
13063
13064 /**
13065  * g_date_time_get_second:
13066  * @datetime: a #GDateTime
13067  *
13068  * Retrieves the second of the minute represented by @datetime
13069  *
13070  * Returns: the second represented by @datetime
13071  * Since: 2.26
13072  */
13073
13074
13075 /**
13076  * g_date_time_get_seconds:
13077  * @datetime: a #GDateTime
13078  *
13079  * Retrieves the number of seconds since the start of the last minute,
13080  * including the fractional part.
13081  *
13082  * Returns: the number of seconds
13083  * Since: 2.26
13084  */
13085
13086
13087 /**
13088  * g_date_time_get_timezone_abbreviation:
13089  * @datetime: a #GDateTime
13090  *
13091  * Determines the time zone abbreviation to be used at the time and in
13092  * the time zone of @datetime.
13093  *
13094  * For example, in Toronto this is currently "EST" during the winter
13095  * months and "EDT" during the summer months when daylight savings
13096  * time is in effect.
13097  *
13098  * Returns: (transfer none): the time zone abbreviation. The returned string is owned by the #GDateTime and it should not be modified or freed
13099  * Since: 2.26
13100  */
13101
13102
13103 /**
13104  * g_date_time_get_utc_offset:
13105  * @datetime: a #GDateTime
13106  *
13107  * Determines the offset to UTC in effect at the time and in the time
13108  * zone of @datetime.
13109  *
13110  * The offset is the number of microseconds that you add to UTC time to
13111  * arrive at local time for the time zone (ie: negative numbers for time
13112  * zones west of GMT, positive numbers for east).
13113  *
13114  * If @datetime represents UTC time, then the offset is always zero.
13115  *
13116  * Returns: the number of microseconds that should be added to UTC to get the local time
13117  * Since: 2.26
13118  */
13119
13120
13121 /**
13122  * g_date_time_get_week_numbering_year:
13123  * @datetime: a #GDateTime
13124  *
13125  * Returns the ISO 8601 week-numbering year in which the week containing
13126  * @datetime falls.
13127  *
13128  * This function, taken together with g_date_time_get_week_of_year() and
13129  * g_date_time_get_day_of_week() can be used to determine the full ISO
13130  * week date on which @datetime falls.
13131  *
13132  * This is usually equal to the normal Gregorian year (as returned by
13133  * g_date_time_get_year()), except as detailed below:
13134  *
13135  * For Thursday, the week-numbering year is always equal to the usual
13136  * calendar year.  For other days, the number is such that every day
13137  * within a complete week (Monday to Sunday) is contained within the
13138  * same week-numbering year.
13139  *
13140  * For Monday, Tuesday and Wednesday occurring near the end of the year,
13141  * this may mean that the week-numbering year is one greater than the
13142  * calendar year (so that these days have the same week-numbering year
13143  * as the Thursday occurring early in the next year).
13144  *
13145  * For Friday, Saturaday and Sunday occurring near the start of the year,
13146  * this may mean that the week-numbering year is one less than the
13147  * calendar year (so that these days have the same week-numbering year
13148  * as the Thursday occurring late in the previous year).
13149  *
13150  * An equivalent description is that the week-numbering year is equal to
13151  * the calendar year containing the majority of the days in the current
13152  * week (Monday to Sunday).
13153  *
13154  * Note that January 1 0001 in the proleptic Gregorian calendar is a
13155  * Monday, so this function never returns 0.
13156  *
13157  * Returns: the ISO 8601 week-numbering year for @datetime
13158  * Since: 2.26
13159  */
13160
13161
13162 /**
13163  * g_date_time_get_week_of_year:
13164  * @datetime: a #GDateTime
13165  *
13166  * Returns the ISO 8601 week number for the week containing @datetime.
13167  * The ISO 8601 week number is the same for every day of the week (from
13168  * Moday through Sunday).  That can produce some unusual results
13169  * (described below).
13170  *
13171  * The first week of the year is week 1.  This is the week that contains
13172  * the first Thursday of the year.  Equivalently, this is the first week
13173  * that has more than 4 of its days falling within the calendar year.
13174  *
13175  * The value 0 is never returned by this function.  Days contained
13176  * within a year but occurring before the first ISO 8601 week of that
13177  * year are considered as being contained in the last week of the
13178  * previous year.  Similarly, the final days of a calendar year may be
13179  * considered as being part of the first ISO 8601 week of the next year
13180  * if 4 or more days of that week are contained within the new year.
13181  *
13182  * Returns: the ISO 8601 week number for @datetime.
13183  * Since: 2.26
13184  */
13185
13186
13187 /**
13188  * g_date_time_get_year:
13189  * @datetime: A #GDateTime
13190  *
13191  * Retrieves the year represented by @datetime in the Gregorian calendar.
13192  *
13193  * Returns: the year represented by @datetime
13194  * Since: 2.26
13195  */
13196
13197
13198 /**
13199  * g_date_time_get_ymd:
13200  * @datetime: a #GDateTime.
13201  * @year: (out) (allow-none): the return location for the gregorian year, or %NULL.
13202  * @month: (out) (allow-none): the return location for the month of the year, or %NULL.
13203  * @day: (out) (allow-none): the return location for the day of the month, or %NULL.
13204  *
13205  * Retrieves the Gregorian day, month, and year of a given #GDateTime.
13206  *
13207  * Since: 2.26
13208  */
13209
13210
13211 /**
13212  * g_date_time_hash:
13213  * @datetime: a #GDateTime
13214  *
13215  * Hashes @datetime into a #guint, suitable for use within #GHashTable.
13216  *
13217  * Returns: a #guint containing the hash
13218  * Since: 2.26
13219  */
13220
13221
13222 /**
13223  * g_date_time_is_daylight_savings:
13224  * @datetime: a #GDateTime
13225  *
13226  * Determines if daylight savings time is in effect at the time and in
13227  * the time zone of @datetime.
13228  *
13229  * Returns: %TRUE if daylight savings time is in effect
13230  * Since: 2.26
13231  */
13232
13233
13234 /**
13235  * g_date_time_new:
13236  * @tz: a #GTimeZone
13237  * @year: the year component of the date
13238  * @month: the month component of the date
13239  * @day: the day component of the date
13240  * @hour: the hour component of the date
13241  * @minute: the minute component of the date
13242  * @seconds: the number of seconds past the minute
13243  *
13244  * Creates a new #GDateTime corresponding to the given date and time in
13245  * the time zone @tz.
13246  *
13247  * The @year must be between 1 and 9999, @month between 1 and 12 and @day
13248  * between 1 and 28, 29, 30 or 31 depending on the month and the year.
13249  *
13250  * @hour must be between 0 and 23 and @minute must be between 0 and 59.
13251  *
13252  * @seconds must be at least 0.0 and must be strictly less than 60.0.
13253  * It will be rounded down to the nearest microsecond.
13254  *
13255  * If the given time is not representable in the given time zone (for
13256  * example, 02:30 on March 14th 2010 in Toronto, due to daylight savings
13257  * time) then the time will be rounded up to the nearest existing time
13258  * (in this case, 03:00).  If this matters to you then you should verify
13259  * the return value for containing the same as the numbers you gave.
13260  *
13261  * In the case that the given time is ambiguous in the given time zone
13262  * (for example, 01:30 on November 7th 2010 in Toronto, due to daylight
13263  * savings time) then the time falling within standard (ie:
13264  * non-daylight) time is taken.
13265  *
13266  * It not considered a programmer error for the values to this function
13267  * to be out of range, but in the case that they are, the function will
13268  * return %NULL.
13269  *
13270  * You should release the return value by calling g_date_time_unref()
13271  * when you are done with it.
13272  *
13273  * Returns: a new #GDateTime, or %NULL
13274  * Since: 2.26
13275  */
13276
13277
13278 /**
13279  * g_date_time_new_from_timeval_local:
13280  * @tv: a #GTimeVal
13281  *
13282  * Creates a #GDateTime corresponding to the given #GTimeVal @tv in the
13283  * local time zone.
13284  *
13285  * The time contained in a #GTimeVal is always stored in the form of
13286  * seconds elapsed since 1970-01-01 00:00:00 UTC, regardless of the
13287  * local time offset.
13288  *
13289  * This call can fail (returning %NULL) if @tv represents a time outside
13290  * of the supported range of #GDateTime.
13291  *
13292  * You should release the return value by calling g_date_time_unref()
13293  * when you are done with it.
13294  *
13295  * Returns: a new #GDateTime, or %NULL
13296  * Since: 2.26
13297  */
13298
13299
13300 /**
13301  * g_date_time_new_from_timeval_utc:
13302  * @tv: a #GTimeVal
13303  *
13304  * Creates a #GDateTime corresponding to the given #GTimeVal @tv in UTC.
13305  *
13306  * The time contained in a #GTimeVal is always stored in the form of
13307  * seconds elapsed since 1970-01-01 00:00:00 UTC.
13308  *
13309  * This call can fail (returning %NULL) if @tv represents a time outside
13310  * of the supported range of #GDateTime.
13311  *
13312  * You should release the return value by calling g_date_time_unref()
13313  * when you are done with it.
13314  *
13315  * Returns: a new #GDateTime, or %NULL
13316  * Since: 2.26
13317  */
13318
13319
13320 /**
13321  * g_date_time_new_from_unix_local:
13322  * @t: the Unix time
13323  *
13324  * Creates a #GDateTime corresponding to the given Unix time @t in the
13325  * local time zone.
13326  *
13327  * Unix time is the number of seconds that have elapsed since 1970-01-01
13328  * 00:00:00 UTC, regardless of the local time offset.
13329  *
13330  * This call can fail (returning %NULL) if @t represents a time outside
13331  * of the supported range of #GDateTime.
13332  *
13333  * You should release the return value by calling g_date_time_unref()
13334  * when you are done with it.
13335  *
13336  * Returns: a new #GDateTime, or %NULL
13337  * Since: 2.26
13338  */
13339
13340
13341 /**
13342  * g_date_time_new_from_unix_utc:
13343  * @t: the Unix time
13344  *
13345  * Creates a #GDateTime corresponding to the given Unix time @t in UTC.
13346  *
13347  * Unix time is the number of seconds that have elapsed since 1970-01-01
13348  * 00:00:00 UTC.
13349  *
13350  * This call can fail (returning %NULL) if @t represents a time outside
13351  * of the supported range of #GDateTime.
13352  *
13353  * You should release the return value by calling g_date_time_unref()
13354  * when you are done with it.
13355  *
13356  * Returns: a new #GDateTime, or %NULL
13357  * Since: 2.26
13358  */
13359
13360
13361 /**
13362  * g_date_time_new_local:
13363  * @year: the year component of the date
13364  * @month: the month component of the date
13365  * @day: the day component of the date
13366  * @hour: the hour component of the date
13367  * @minute: the minute component of the date
13368  * @seconds: the number of seconds past the minute
13369  *
13370  * Creates a new #GDateTime corresponding to the given date and time in
13371  * the local time zone.
13372  *
13373  * This call is equivalent to calling g_date_time_new() with the time
13374  * zone returned by g_time_zone_new_local().
13375  *
13376  * Returns: a #GDateTime, or %NULL
13377  * Since: 2.26
13378  */
13379
13380
13381 /**
13382  * g_date_time_new_now:
13383  * @tz: a #GTimeZone
13384  *
13385  * Creates a #GDateTime corresponding to this exact instant in the given
13386  * time zone @tz.  The time is as accurate as the system allows, to a
13387  * maximum accuracy of 1 microsecond.
13388  *
13389  * This function will always succeed unless the system clock is set to
13390  * truly insane values (or unless GLib is still being used after the
13391  * year 9999).
13392  *
13393  * You should release the return value by calling g_date_time_unref()
13394  * when you are done with it.
13395  *
13396  * Returns: a new #GDateTime, or %NULL
13397  * Since: 2.26
13398  */
13399
13400
13401 /**
13402  * g_date_time_new_now_local:
13403  *
13404  * Creates a #GDateTime corresponding to this exact instant in the local
13405  * time zone.
13406  *
13407  * This is equivalent to calling g_date_time_new_now() with the time
13408  * zone returned by g_time_zone_new_local().
13409  *
13410  * Returns: a new #GDateTime, or %NULL
13411  * Since: 2.26
13412  */
13413
13414
13415 /**
13416  * g_date_time_new_now_utc:
13417  *
13418  * Creates a #GDateTime corresponding to this exact instant in UTC.
13419  *
13420  * This is equivalent to calling g_date_time_new_now() with the time
13421  * zone returned by g_time_zone_new_utc().
13422  *
13423  * Returns: a new #GDateTime, or %NULL
13424  * Since: 2.26
13425  */
13426
13427
13428 /**
13429  * g_date_time_new_utc:
13430  * @year: the year component of the date
13431  * @month: the month component of the date
13432  * @day: the day component of the date
13433  * @hour: the hour component of the date
13434  * @minute: the minute component of the date
13435  * @seconds: the number of seconds past the minute
13436  *
13437  * Creates a new #GDateTime corresponding to the given date and time in
13438  * UTC.
13439  *
13440  * This call is equivalent to calling g_date_time_new() with the time
13441  * zone returned by g_time_zone_new_utc().
13442  *
13443  * Returns: a #GDateTime, or %NULL
13444  * Since: 2.26
13445  */
13446
13447
13448 /**
13449  * g_date_time_ref:
13450  * @datetime: a #GDateTime
13451  *
13452  * Atomically increments the reference count of @datetime by one.
13453  *
13454  * Returns: the #GDateTime with the reference count increased
13455  * Since: 2.26
13456  */
13457
13458
13459 /**
13460  * g_date_time_to_local:
13461  * @datetime: a #GDateTime
13462  *
13463  * Creates a new #GDateTime corresponding to the same instant in time as
13464  * @datetime, but in the local time zone.
13465  *
13466  * This call is equivalent to calling g_date_time_to_timezone() with the
13467  * time zone returned by g_time_zone_new_local().
13468  *
13469  * Returns: the newly created #GDateTime
13470  * Since: 2.26
13471  */
13472
13473
13474 /**
13475  * g_date_time_to_timeval:
13476  * @datetime: a #GDateTime
13477  * @tv: a #GTimeVal to modify
13478  *
13479  * Stores the instant in time that @datetime represents into @tv.
13480  *
13481  * The time contained in a #GTimeVal is always stored in the form of
13482  * seconds elapsed since 1970-01-01 00:00:00 UTC, regardless of the time
13483  * zone associated with @datetime.
13484  *
13485  * On systems where 'long' is 32bit (ie: all 32bit systems and all
13486  * Windows systems), a #GTimeVal is incapable of storing the entire
13487  * range of values that #GDateTime is capable of expressing.  On those
13488  * systems, this function returns %FALSE to indicate that the time is
13489  * out of range.
13490  *
13491  * On systems where 'long' is 64bit, this function never fails.
13492  *
13493  * Returns: %TRUE if successful, else %FALSE
13494  * Since: 2.26
13495  */
13496
13497
13498 /**
13499  * g_date_time_to_timezone:
13500  * @datetime: a #GDateTime
13501  * @tz: the new #GTimeZone
13502  *
13503  * Create a new #GDateTime corresponding to the same instant in time as
13504  * @datetime, but in the time zone @tz.
13505  *
13506  * This call can fail in the case that the time goes out of bounds.  For
13507  * example, converting 0001-01-01 00:00:00 UTC to a time zone west of
13508  * Greenwich will fail (due to the year 0 being out of range).
13509  *
13510  * You should release the return value by calling g_date_time_unref()
13511  * when you are done with it.
13512  *
13513  * Returns: a new #GDateTime, or %NULL
13514  * Since: 2.26
13515  */
13516
13517
13518 /**
13519  * g_date_time_to_unix:
13520  * @datetime: a #GDateTime
13521  *
13522  * Gives the Unix time corresponding to @datetime, rounding down to the
13523  * nearest second.
13524  *
13525  * Unix time is the number of seconds that have elapsed since 1970-01-01
13526  * 00:00:00 UTC, regardless of the time zone associated with @datetime.
13527  *
13528  * Returns: the Unix time corresponding to @datetime
13529  * Since: 2.26
13530  */
13531
13532
13533 /**
13534  * g_date_time_to_utc:
13535  * @datetime: a #GDateTime
13536  *
13537  * Creates a new #GDateTime corresponding to the same instant in time as
13538  * @datetime, but in UTC.
13539  *
13540  * This call is equivalent to calling g_date_time_to_timezone() with the
13541  * time zone returned by g_time_zone_new_utc().
13542  *
13543  * Returns: the newly created #GDateTime
13544  * Since: 2.26
13545  */
13546
13547
13548 /**
13549  * g_date_time_unref:
13550  * @datetime: a #GDateTime
13551  *
13552  * Atomically decrements the reference count of @datetime by one.
13553  *
13554  * When the reference count reaches zero, the resources allocated by
13555  * @datetime are freed
13556  *
13557  * Since: 2.26
13558  */
13559
13560
13561 /**
13562  * g_date_to_struct_tm:
13563  * @date: a #GDate to set the <structname>struct tm</structname> from
13564  * @tm: <structname>struct tm</structname> to fill
13565  *
13566  * Fills in the date-related bits of a <structname>struct tm</structname>
13567  * using the @date value. Initializes the non-date parts with something
13568  * sane but meaningless.
13569  */
13570
13571
13572 /**
13573  * g_date_valid:
13574  * @date: a #GDate to check
13575  *
13576  * Returns %TRUE if the #GDate represents an existing day. The date must not
13577  * contain garbage; it should have been initialized with g_date_clear()
13578  * if it wasn't allocated by one of the g_date_new() variants.
13579  *
13580  * Returns: Whether the date is valid
13581  */
13582
13583
13584 /**
13585  * g_date_valid_day:
13586  * @day: day to check
13587  *
13588  * Returns %TRUE if the day of the month is valid (a day is valid if it's
13589  * between 1 and 31 inclusive).
13590  *
13591  * Returns: %TRUE if the day is valid
13592  */
13593
13594
13595 /**
13596  * g_date_valid_dmy:
13597  * @day: day
13598  * @month: month
13599  * @year: year
13600  *
13601  * Returns %TRUE if the day-month-year triplet forms a valid, existing day
13602  * in the range of days #GDate understands (Year 1 or later, no more than
13603  * a few thousand years in the future).
13604  *
13605  * Returns: %TRUE if the date is a valid one
13606  */
13607
13608
13609 /**
13610  * g_date_valid_julian:
13611  * @julian_date: Julian day to check
13612  *
13613  * Returns %TRUE if the Julian day is valid. Anything greater than zero
13614  * is basically a valid Julian, though there is a 32-bit limit.
13615  *
13616  * Returns: %TRUE if the Julian day is valid
13617  */
13618
13619
13620 /**
13621  * g_date_valid_month:
13622  * @month: month
13623  *
13624  * Returns %TRUE if the month value is valid. The 12 #GDateMonth
13625  * enumeration values are the only valid months.
13626  *
13627  * Returns: %TRUE if the month is valid
13628  */
13629
13630
13631 /**
13632  * g_date_valid_weekday:
13633  * @weekday: weekday
13634  *
13635  * Returns %TRUE if the weekday is valid. The seven #GDateWeekday enumeration
13636  * values are the only valid weekdays.
13637  *
13638  * Returns: %TRUE if the weekday is valid
13639  */
13640
13641
13642 /**
13643  * g_date_valid_year:
13644  * @year: year
13645  *
13646  * Returns %TRUE if the year is valid. Any year greater than 0 is valid,
13647  * though there is a 16-bit limit to what #GDate will understand.
13648  *
13649  * Returns: %TRUE if the year is valid
13650  */
13651
13652
13653 /**
13654  * g_dcgettext:
13655  * @domain: (allow-none): the translation domain to use, or %NULL to use the domain set with textdomain()
13656  * @msgid: message to translate
13657  * @category: a locale category
13658  *
13659  * This is a variant of g_dgettext() that allows specifying a locale
13660  * category instead of always using <envar>LC_MESSAGES</envar>. See g_dgettext() for
13661  * more information about how this functions differs from calling
13662  * dcgettext() directly.
13663  *
13664  * Returns: the translated string for the given locale category
13665  * Since: 2.26
13666  */
13667
13668
13669 /**
13670  * g_debug:
13671  * @...: format string, followed by parameters to insert into the format string (as with printf())
13672  *
13673  * A convenience function/macro to log a debug message.
13674  *
13675  * Since: 2.6
13676  */
13677
13678
13679 /**
13680  * g_dgettext:
13681  * @domain: (allow-none): the translation domain to use, or %NULL to use the domain set with textdomain()
13682  * @msgid: message to translate
13683  *
13684  * This function is a wrapper of dgettext() which does not translate
13685  * the message if the default domain as set with textdomain() has no
13686  * translations for the current locale.
13687  *
13688  * The advantage of using this function over dgettext() proper is that
13689  * libraries using this function (like GTK+) will not use translations
13690  * if the application using the library does not have translations for
13691  * the current locale.  This results in a consistent English-only
13692  * interface instead of one having partial translations.  For this
13693  * feature to work, the call to textdomain() and setlocale() should
13694  * precede any g_dgettext() invocations.  For GTK+, it means calling
13695  * textdomain() before gtk_init or its variants.
13696  *
13697  * This function disables translations if and only if upon its first
13698  * call all the following conditions hold:
13699  * <itemizedlist>
13700  * <listitem>@domain is not %NULL</listitem>
13701  * <listitem>textdomain() has been called to set a default text domain</listitem>
13702  * <listitem>there is no translations available for the default text domain
13703  *           and the current locale</listitem>
13704  * <listitem>current locale is not "C" or any English locales (those
13705  *           starting with "en_")</listitem>
13706  * </itemizedlist>
13707  *
13708  * Note that this behavior may not be desired for example if an application
13709  * has its untranslated messages in a language other than English.  In those
13710  * cases the application should call textdomain() after initializing GTK+.
13711  *
13712  * Applications should normally not use this function directly,
13713  * but use the _() macro for translations.
13714  *
13715  * Returns: The translated string
13716  * Since: 2.18
13717  */
13718
13719
13720 /**
13721  * g_dir_close:
13722  * @dir: a #GDir* created by g_dir_open()
13723  *
13724  * Closes the directory and deallocates all related resources.
13725  */
13726
13727
13728 /**
13729  * g_dir_make_tmp:
13730  * @tmpl: (type filename) (allow-none): Template for directory name, as in g_mkdtemp(), basename only, or %NULL for a default template
13731  * @error: return location for a #GError
13732  *
13733  * Creates a subdirectory in the preferred directory for temporary
13734  * files (as returned by g_get_tmp_dir()).
13735  *
13736  * @tmpl should be a string in the GLib file name encoding containing
13737  * a sequence of six 'X' characters, as the parameter to g_mkstemp().
13738  * However, unlike these functions, the template should only be a
13739  * basename, no directory components are allowed. If template is
13740  * %NULL, a default template is used.
13741  *
13742  * Note that in contrast to g_mkdtemp() (and mkdtemp()) @tmpl is not
13743  * modified, and might thus be a read-only literal string.
13744  *
13745  * Returns: (type filename): The actual name used. This string should be freed with g_free() when not needed any longer and is is in the GLib file name encoding. In case of errors, %NULL is returned and @error will be set.
13746  * Since: 2.30
13747  */
13748
13749
13750 /**
13751  * g_dir_open:
13752  * @path: the path to the directory you are interested in. On Unix in the on-disk encoding. On Windows in UTF-8
13753  * @flags: Currently must be set to 0. Reserved for future use.
13754  * @error: return location for a #GError, or %NULL. If non-%NULL, an error will be set if and only if g_dir_open() fails.
13755  *
13756  * Opens a directory for reading. The names of the files in the
13757  * directory can then be retrieved using g_dir_read_name().  Note
13758  * that the ordering is not defined.
13759  *
13760  * Returns: a newly allocated #GDir on success, %NULL on failure. If non-%NULL, you must free the result with g_dir_close() when you are finished with it.
13761  */
13762
13763
13764 /**
13765  * g_dir_read_name:
13766  * @dir: a #GDir* created by g_dir_open()
13767  *
13768  * Retrieves the name of another entry in the directory, or %NULL.
13769  * The order of entries returned from this function is not defined,
13770  * and may vary by file system or other operating-system dependent
13771  * factors.
13772  *
13773  * %NULL may also be returned in case of errors. On Unix, you can
13774  * check <literal>errno</literal> to find out if %NULL was returned
13775  * because of an error.
13776  *
13777  * On Unix, the '.' and '..' entries are omitted, and the returned
13778  * name is in the on-disk encoding.
13779  *
13780  * On Windows, as is true of all GLib functions which operate on
13781  * filenames, the returned name is in UTF-8.
13782  *
13783  * Returns: The entry's name or %NULL if there are no more entries. The return value is owned by GLib and must not be modified or freed.
13784  */
13785
13786
13787 /**
13788  * g_dir_rewind:
13789  * @dir: a #GDir* created by g_dir_open()
13790  *
13791  * Resets the given directory. The next call to g_dir_read_name()
13792  * will return the first entry again.
13793  */
13794
13795
13796 /**
13797  * g_direct_equal:
13798  * @v1: (allow-none): a key
13799  * @v2: (allow-none): a key to compare with @v1
13800  *
13801  * Compares two #gpointer arguments and returns %TRUE if they are equal.
13802  * It can be passed to g_hash_table_new() as the @key_equal_func
13803  * parameter, when using opaque pointers compared by pointer value as keys
13804  * in a #GHashTable.
13805  *
13806  * This equality function is also appropriate for keys that are integers stored
13807  * in pointers, such as <literal>GINT_TO_POINTER (n)</literal>.
13808  *
13809  * Returns: %TRUE if the two keys match.
13810  */
13811
13812
13813 /**
13814  * g_direct_hash:
13815  * @v: (allow-none): a #gpointer key
13816  *
13817  * Converts a gpointer to a hash value.
13818  * It can be passed to g_hash_table_new() as the @hash_func parameter,
13819  * when using opaque pointers compared by pointer value as keys in a
13820  * #GHashTable.
13821  *
13822  * This hash function is also appropriate for keys that are integers stored
13823  * in pointers, such as <literal>GINT_TO_POINTER (n)</literal>.
13824  *
13825  * Returns: a hash value corresponding to the key.
13826  */
13827
13828
13829 /**
13830  * g_dirname:
13831  * @file_name: the name of the file
13832  *
13833  * Gets the directory components of a file name.
13834  *
13835  * If the file name has no directory components "." is returned.
13836  * The returned string should be freed when no longer needed.
13837  *
13838  * Returns: the directory components of the file
13839  * Deprecated: use g_path_get_dirname() instead
13840  */
13841
13842
13843 /**
13844  * g_dngettext:
13845  * @domain: (allow-none): the translation domain to use, or %NULL to use the domain set with textdomain()
13846  * @msgid: message to translate
13847  * @msgid_plural: plural form of the message
13848  * @n: the quantity for which translation is needed
13849  *
13850  * This function is a wrapper of dngettext() which does not translate
13851  * the message if the default domain as set with textdomain() has no
13852  * translations for the current locale.
13853  *
13854  * See g_dgettext() for details of how this differs from dngettext()
13855  * proper.
13856  *
13857  * Returns: The translated string
13858  * Since: 2.18
13859  */
13860
13861
13862 /**
13863  * g_double_equal:
13864  * @v1: a pointer to a #gdouble key
13865  * @v2: a pointer to a #gdouble key to compare with @v1
13866  *
13867  * Compares the two #gdouble values being pointed to and returns
13868  * %TRUE if they are equal.
13869  * It can be passed to g_hash_table_new() as the @key_equal_func
13870  * parameter, when using non-%NULL pointers to doubles as keys in a
13871  * #GHashTable.
13872  *
13873  * Returns: %TRUE if the two keys match.
13874  * Since: 2.22
13875  */
13876
13877
13878 /**
13879  * g_double_hash:
13880  * @v: a pointer to a #gdouble key
13881  *
13882  * Converts a pointer to a #gdouble to a hash value.
13883  * It can be passed to g_hash_table_new() as the @hash_func parameter,
13884  * It can be passed to g_hash_table_new() as the @hash_func parameter,
13885  * when using non-%NULL pointers to doubles as keys in a #GHashTable.
13886  *
13887  * Returns: a hash value corresponding to the key.
13888  * Since: 2.22
13889  */
13890
13891
13892 /**
13893  * g_dpgettext:
13894  * @domain: (allow-none): the translation domain to use, or %NULL to use the domain set with textdomain()
13895  * @msgctxtid: a combined message context and message id, separated by a \004 character
13896  * @msgidoffset: the offset of the message id in @msgctxid
13897  *
13898  * This function is a variant of g_dgettext() which supports
13899  * a disambiguating message context. GNU gettext uses the
13900  * '\004' character to separate the message context and
13901  * message id in @msgctxtid.
13902  * If 0 is passed as @msgidoffset, this function will fall back to
13903  * trying to use the deprecated convention of using "|" as a separation
13904  * character.
13905  *
13906  * This uses g_dgettext() internally. See that functions for differences
13907  * with dgettext() proper.
13908  *
13909  * Applications should normally not use this function directly,
13910  * but use the C_() macro for translations with context.
13911  *
13912  * Returns: The translated string
13913  * Since: 2.16
13914  */
13915
13916
13917 /**
13918  * g_dpgettext2:
13919  * @domain: (allow-none): the translation domain to use, or %NULL to use the domain set with textdomain()
13920  * @context: the message context
13921  * @msgid: the message
13922  *
13923  * This function is a variant of g_dgettext() which supports
13924  * a disambiguating message context. GNU gettext uses the
13925  * '\004' character to separate the message context and
13926  * message id in @msgctxtid.
13927  *
13928  * This uses g_dgettext() internally. See that functions for differences
13929  * with dgettext() proper.
13930  *
13931  * This function differs from C_() in that it is not a macro and
13932  * thus you may use non-string-literals as context and msgid arguments.
13933  *
13934  * Returns: The translated string
13935  * Since: 2.18
13936  */
13937
13938
13939 /**
13940  * g_environ_getenv:
13941  * @envp: (allow-none) (array zero-terminated=1) (transfer none): an environment list (eg, as returned from g_get_environ()), or %NULL for an empty environment list
13942  * @variable: the environment variable to get, in the GLib file name encoding
13943  *
13944  * Returns the value of the environment variable @variable in the
13945  * provided list @envp.
13946  *
13947  * The name and value are in the GLib file name encoding.
13948  * On UNIX, this means the actual bytes which might or might not
13949  * be in some consistent character set and encoding. On Windows,
13950  * it is in UTF-8. On Windows, in case the environment variable's
13951  * value contains references to other environment variables, they
13952  * are expanded.
13953  *
13954  * Returns: the value of the environment variable, or %NULL if the environment variable is not set in @envp. The returned string is owned by @envp, and will be freed if @variable is set or unset again.
13955  * Since: 2.32
13956  */
13957
13958
13959 /**
13960  * g_environ_setenv:
13961  * @envp: (allow-none) (array zero-terminated=1) (transfer full): an environment list that can be freed using g_strfreev() (e.g., as returned from g_get_environ()), or %NULL for an empty environment list
13962  * @variable: the environment variable to set, must not contain '='
13963  * @value: the value for to set the variable to
13964  * @overwrite: whether to change the variable if it already exists
13965  *
13966  * Sets the environment variable @variable in the provided list
13967  * @envp to @value.
13968  *
13969  * Both the variable's name and value should be in the GLib
13970  * file name encoding. On UNIX, this means that they can be
13971  * arbitrary byte strings. On Windows, they should be in UTF-8.
13972  *
13973  * Returns: (array zero-terminated=1) (transfer full): the updated environment list. Free it using g_strfreev().
13974  * Since: 2.32
13975  */
13976
13977
13978 /**
13979  * g_environ_unsetenv:
13980  * @envp: (allow-none) (array zero-terminated=1) (transfer full): an environment list that can be freed using g_strfreev() (e.g., as returned from g_get_environ()), or %NULL for an empty environment list
13981  * @variable: the environment variable to remove, must not contain '='
13982  *
13983  * Removes the environment variable @variable from the provided
13984  * environment @envp.
13985  *
13986  * Returns: (array zero-terminated=1) (transfer full): the updated environment list. Free it using g_strfreev().
13987  * Since: 2.32
13988  */
13989
13990
13991 /**
13992  * g_error:
13993  * @...: format string, followed by parameters to insert into the format string (as with printf())
13994  *
13995  * A convenience function/macro to log an error message.
13996  *
13997  * Error messages are always fatal, resulting in a call to
13998  * abort() to terminate the application. This function will
13999  * result in a core dump; don't use it for errors you expect.
14000  * Using this function indicates a bug in your program, i.e.
14001  * an assertion failure.
14002  */
14003
14004
14005 /**
14006  * g_error_copy:
14007  * @error: a #GError
14008  *
14009  * Makes a copy of @error.
14010  *
14011  * Returns: a new #GError
14012  */
14013
14014
14015 /**
14016  * g_error_free:
14017  * @error: a #GError
14018  *
14019  * Frees a #GError and associated resources.
14020  */
14021
14022
14023 /**
14024  * g_error_matches:
14025  * @error: (allow-none): a #GError or %NULL
14026  * @domain: an error domain
14027  * @code: an error code
14028  *
14029  * Returns %TRUE if @error matches @domain and @code, %FALSE
14030  * otherwise. In particular, when @error is %NULL, %FALSE will
14031  * be returned.
14032  *
14033  * Returns: whether @error has @domain and @code
14034  */
14035
14036
14037 /**
14038  * g_error_new:
14039  * @domain: error domain
14040  * @code: error code
14041  * @format: printf()-style format for error message
14042  * @...: parameters for message format
14043  *
14044  * Creates a new #GError with the given @domain and @code,
14045  * and a message formatted with @format.
14046  *
14047  * Returns: a new #GError
14048  */
14049
14050
14051 /**
14052  * g_error_new_literal:
14053  * @domain: error domain
14054  * @code: error code
14055  * @message: error message
14056  *
14057  * Creates a new #GError; unlike g_error_new(), @message is
14058  * not a printf()-style format string. Use this function if
14059  * @message contains text you don't have control over,
14060  * that could include printf() escape sequences.
14061  *
14062  * Returns: a new #GError
14063  */
14064
14065
14066 /**
14067  * g_error_new_valist:
14068  * @domain: error domain
14069  * @code: error code
14070  * @format: printf()-style format for error message
14071  * @args: #va_list of parameters for the message format
14072  *
14073  * Creates a new #GError with the given @domain and @code,
14074  * and a message formatted with @format.
14075  *
14076  * Returns: a new #GError
14077  * Since: 2.22
14078  */
14079
14080
14081 /**
14082  * g_file_error_from_errno:
14083  * @err_no: an "errno" value
14084  *
14085  * Gets a #GFileError constant based on the passed-in @err_no.
14086  * For example, if you pass in <literal>EEXIST</literal> this function returns
14087  * #G_FILE_ERROR_EXIST. Unlike <literal>errno</literal> values, you can portably
14088  * assume that all #GFileError values will exist.
14089  *
14090  * Normally a #GFileError value goes into a #GError returned
14091  * from a function that manipulates files. So you would use
14092  * g_file_error_from_errno() when constructing a #GError.
14093  *
14094  * Returns: #GFileError corresponding to the given @errno
14095  */
14096
14097
14098 /**
14099  * g_file_get_contents:
14100  * @filename: (type filename): name of a file to read contents from, in the GLib file name encoding
14101  * @contents: (out) (array length=length) (element-type guint8): location to store an allocated string, use g_free() to free the returned string
14102  * @length: (allow-none): location to store length in bytes of the contents, or %NULL
14103  * @error: return location for a #GError, or %NULL
14104  *
14105  * Reads an entire file into allocated memory, with good error
14106  * checking.
14107  *
14108  * If the call was successful, it returns %TRUE and sets @contents to the file
14109  * contents and @length to the length of the file contents in bytes. The string
14110  * stored in @contents will be nul-terminated, so for text files you can pass
14111  * %NULL for the @length argument. If the call was not successful, it returns
14112  * %FALSE and sets @error. The error domain is #G_FILE_ERROR. Possible error
14113  * codes are those in the #GFileError enumeration. In the error case,
14114  * @contents is set to %NULL and @length is set to zero.
14115  *
14116  * Returns: %TRUE on success, %FALSE if an error occurred
14117  */
14118
14119
14120 /**
14121  * g_file_open_tmp:
14122  * @tmpl: (type filename) (allow-none): Template for file name, as in g_mkstemp(), basename only, or %NULL for a default template
14123  * @name_used: (out) (type filename): location to store actual name used, or %NULL
14124  * @error: return location for a #GError
14125  *
14126  * Opens a file for writing in the preferred directory for temporary
14127  * files (as returned by g_get_tmp_dir()).
14128  *
14129  * @tmpl should be a string in the GLib file name encoding containing
14130  * a sequence of six 'X' characters, as the parameter to g_mkstemp().
14131  * However, unlike these functions, the template should only be a
14132  * basename, no directory components are allowed. If template is
14133  * %NULL, a default template is used.
14134  *
14135  * Note that in contrast to g_mkstemp() (and mkstemp()) @tmpl is not
14136  * modified, and might thus be a read-only literal string.
14137  *
14138  * Upon success, and if @name_used is non-%NULL, the actual name used
14139  * is returned in @name_used. This string should be freed with g_free()
14140  * when not needed any longer. The returned name is in the GLib file
14141  * name encoding.
14142  *
14143  * Returns: A file handle (as from open()) to the file opened for reading and writing. The file is opened in binary mode on platforms where there is a difference. The file handle should be closed with close(). In case of errors, -1 is returned and @error will be set.
14144  */
14145
14146
14147 /**
14148  * g_file_read_link:
14149  * @filename: the symbolic link
14150  * @error: return location for a #GError
14151  *
14152  * Reads the contents of the symbolic link @filename like the POSIX
14153  * readlink() function.  The returned string is in the encoding used
14154  * for filenames. Use g_filename_to_utf8() to convert it to UTF-8.
14155  *
14156  * Returns: A newly-allocated string with the contents of the symbolic link, or %NULL if an error occurred.
14157  * Since: 2.4
14158  */
14159
14160
14161 /**
14162  * g_file_set_contents:
14163  * @filename: (type filename): name of a file to write @contents to, in the GLib file name encoding
14164  * @contents: (array length=length) (element-type guint8): string to write to the file
14165  * @length: length of @contents, or -1 if @contents is a nul-terminated string
14166  * @error: return location for a #GError, or %NULL
14167  *
14168  * Writes all of @contents to a file named @filename, with good error checking.
14169  * If a file called @filename already exists it will be overwritten.
14170  *
14171  * This write is atomic in the sense that it is first written to a temporary
14172  * file which is then renamed to the final name. Notes:
14173  * <itemizedlist>
14174  * <listitem>
14175  *    On Unix, if @filename already exists hard links to @filename will break.
14176  *    Also since the file is recreated, existing permissions, access control
14177  *    lists, metadata etc. may be lost. If @filename is a symbolic link,
14178  *    the link itself will be replaced, not the linked file.
14179  * </listitem>
14180  * <listitem>
14181  *   On Windows renaming a file will not remove an existing file with the
14182  *   new name, so on Windows there is a race condition between the existing
14183  *   file being removed and the temporary file being renamed.
14184  * </listitem>
14185  * <listitem>
14186  *   On Windows there is no way to remove a file that is open to some
14187  *   process, or mapped into memory. Thus, this function will fail if
14188  *   @filename already exists and is open.
14189  * </listitem>
14190  * </itemizedlist>
14191  *
14192  * If the call was successful, it returns %TRUE. If the call was not successful,
14193  * it returns %FALSE and sets @error. The error domain is #G_FILE_ERROR.
14194  * Possible error codes are those in the #GFileError enumeration.
14195  *
14196  * Note that the name for the temporary file is constructed by appending up
14197  * to 7 characters to @filename.
14198  *
14199  * Returns: %TRUE on success, %FALSE if an error occurred
14200  * Since: 2.8
14201  */
14202
14203
14204 /**
14205  * g_file_test:
14206  * @filename: a filename to test in the GLib file name encoding
14207  * @test: bitfield of #GFileTest flags
14208  *
14209  * Returns %TRUE if any of the tests in the bitfield @test are
14210  * %TRUE. For example, <literal>(G_FILE_TEST_EXISTS |
14211  * G_FILE_TEST_IS_DIR)</literal> will return %TRUE if the file exists;
14212  * the check whether it's a directory doesn't matter since the existence
14213  * test is %TRUE. With the current set of available tests, there's no point
14214  * passing in more than one test at a time.
14215  *
14216  * Apart from %G_FILE_TEST_IS_SYMLINK all tests follow symbolic links,
14217  * so for a symbolic link to a regular file g_file_test() will return
14218  * %TRUE for both %G_FILE_TEST_IS_SYMLINK and %G_FILE_TEST_IS_REGULAR.
14219  *
14220  * Note, that for a dangling symbolic link g_file_test() will return
14221  * %TRUE for %G_FILE_TEST_IS_SYMLINK and %FALSE for all other flags.
14222  *
14223  * You should never use g_file_test() to test whether it is safe
14224  * to perform an operation, because there is always the possibility
14225  * of the condition changing before you actually perform the operation.
14226  * For example, you might think you could use %G_FILE_TEST_IS_SYMLINK
14227  * to know whether it is safe to write to a file without being
14228  * tricked into writing into a different location. It doesn't work!
14229  * |[
14230  * /&ast; DON'T DO THIS &ast;/
14231  *  if (!g_file_test (filename, G_FILE_TEST_IS_SYMLINK))
14232  *    {
14233  *      fd = g_open (filename, O_WRONLY);
14234  *      /&ast; write to fd &ast;/
14235  *    }
14236  * ]|
14237  *
14238  * Another thing to note is that %G_FILE_TEST_EXISTS and
14239  * %G_FILE_TEST_IS_EXECUTABLE are implemented using the access()
14240  * system call. This usually doesn't matter, but if your program
14241  * is setuid or setgid it means that these tests will give you
14242  * the answer for the real user ID and group ID, rather than the
14243  * effective user ID and group ID.
14244  *
14245  * On Windows, there are no symlinks, so testing for
14246  * %G_FILE_TEST_IS_SYMLINK will always return %FALSE. Testing for
14247  * %G_FILE_TEST_IS_EXECUTABLE will just check that the file exists and
14248  * its name indicates that it is executable, checking for well-known
14249  * extensions and those listed in the <envar>PATHEXT</envar> environment variable.
14250  *
14251  * Returns: whether a test was %TRUE
14252  */
14253
14254
14255 /**
14256  * g_filename_display_basename:
14257  * @filename: an absolute pathname in the GLib file name encoding
14258  *
14259  * Returns the display basename for the particular filename, guaranteed
14260  * to be valid UTF-8. The display name might not be identical to the filename,
14261  * for instance there might be problems converting it to UTF-8, and some files
14262  * can be translated in the display.
14263  *
14264  * If GLib cannot make sense of the encoding of @filename, as a last resort it
14265  * replaces unknown characters with U+FFFD, the Unicode replacement character.
14266  * You can search the result for the UTF-8 encoding of this character (which is
14267  * "\357\277\275" in octal notation) to find out if @filename was in an invalid
14268  * encoding.
14269  *
14270  * You must pass the whole absolute pathname to this functions so that
14271  * translation of well known locations can be done.
14272  *
14273  * This function is preferred over g_filename_display_name() if you know the
14274  * whole path, as it allows translation.
14275  *
14276  * Returns: a newly allocated string containing a rendition of the basename of the filename in valid UTF-8
14277  * Since: 2.6
14278  */
14279
14280
14281 /**
14282  * g_filename_display_name:
14283  * @filename: a pathname hopefully in the GLib file name encoding
14284  *
14285  * Converts a filename into a valid UTF-8 string. The conversion is
14286  * not necessarily reversible, so you should keep the original around
14287  * and use the return value of this function only for display purposes.
14288  * Unlike g_filename_to_utf8(), the result is guaranteed to be non-%NULL
14289  * even if the filename actually isn't in the GLib file name encoding.
14290  *
14291  * If GLib cannot make sense of the encoding of @filename, as a last resort it
14292  * replaces unknown characters with U+FFFD, the Unicode replacement character.
14293  * You can search the result for the UTF-8 encoding of this character (which is
14294  * "\357\277\275" in octal notation) to find out if @filename was in an invalid
14295  * encoding.
14296  *
14297  * If you know the whole pathname of the file you should use
14298  * g_filename_display_basename(), since that allows location-based
14299  * translation of filenames.
14300  *
14301  * Returns: a newly allocated string containing a rendition of the filename in valid UTF-8
14302  * Since: 2.6
14303  */
14304
14305
14306 /**
14307  * g_filename_from_uri:
14308  * @uri: a uri describing a filename (escaped, encoded in ASCII).
14309  * @hostname: (out) (allow-none): Location to store hostname for the URI, or %NULL. If there is no hostname in the URI, %NULL will be stored in this location.
14310  * @error: location to store the error occurring, or %NULL to ignore errors. Any of the errors in #GConvertError may occur.
14311  *
14312  * Converts an escaped ASCII-encoded URI to a local filename in the
14313  * encoding used for filenames.
14314  *
14315  * Returns: (type filename): a newly-allocated string holding the resulting filename, or %NULL on an error.
14316  */
14317
14318
14319 /**
14320  * g_filename_from_utf8:
14321  * @utf8string: a UTF-8 encoded string.
14322  * @len: the length of the string, or -1 if the string is nul-terminated.
14323  * @bytes_read: (out) (allow-none): location to store the number of bytes in the input string that were successfully converted, or %NULL. Even if the conversion was successful, this may be less than @len if there were partial characters at the end of the input. If the error #G_CONVERT_ERROR_ILLEGAL_SEQUENCE occurs, the value stored will the byte offset after the last valid input sequence.
14324  * @bytes_written: (out): the number of bytes stored in the output buffer (not including the terminating nul).
14325  * @error: location to store the error occurring, or %NULL to ignore errors. Any of the errors in #GConvertError may occur.
14326  *
14327  * Converts a string from UTF-8 to the encoding GLib uses for
14328  * filenames. Note that on Windows GLib uses UTF-8 for filenames;
14329  * on other platforms, this function indirectly depends on the
14330  * <link linkend="setlocale">current locale</link>.
14331  *
14332  * Returns: (array length=bytes_written) (element-type guint8) (transfer full): The converted string, or %NULL on an error.
14333  */
14334
14335
14336 /**
14337  * g_filename_to_uri:
14338  * @filename: an absolute filename specified in the GLib file name encoding, which is the on-disk file name bytes on Unix, and UTF-8 on Windows
14339  * @hostname: (allow-none): A UTF-8 encoded hostname, or %NULL for none.
14340  * @error: location to store the error occurring, or %NULL to ignore errors. Any of the errors in #GConvertError may occur.
14341  *
14342  * Converts an absolute filename to an escaped ASCII-encoded URI, with the path
14343  * component following Section 3.3. of RFC 2396.
14344  *
14345  * Returns: a newly-allocated string holding the resulting URI, or %NULL on an error.
14346  */
14347
14348
14349 /**
14350  * g_filename_to_utf8:
14351  * @opsysstring: a string in the encoding for filenames
14352  * @len: the length of the string, or -1 if the string is nul-terminated<footnoteref linkend="nul-unsafe"/>.
14353  * @bytes_read: location to store the number of bytes in the input string that were successfully converted, or %NULL. Even if the conversion was successful, this may be less than @len if there were partial characters at the end of the input. If the error #G_CONVERT_ERROR_ILLEGAL_SEQUENCE occurs, the value stored will the byte offset after the last valid input sequence.
14354  * @bytes_written: the number of bytes stored in the output buffer (not including the terminating nul).
14355  * @error: location to store the error occurring, or %NULL to ignore errors. Any of the errors in #GConvertError may occur.
14356  *
14357  * Converts a string which is in the encoding used by GLib for
14358  * filenames into a UTF-8 string. Note that on Windows GLib uses UTF-8
14359  * for filenames; on other platforms, this function indirectly depends on
14360  * the <link linkend="setlocale">current locale</link>.
14361  *
14362  * Returns: The converted string, or %NULL on an error.
14363  */
14364
14365
14366 /**
14367  * g_find_program_in_path:
14368  * @program: a program name in the GLib file name encoding
14369  *
14370  * Locates the first executable named @program in the user's path, in the
14371  * same way that execvp() would locate it. Returns an allocated string
14372  * with the absolute path name, or %NULL if the program is not found in
14373  * the path. If @program is already an absolute path, returns a copy of
14374  * @program if @program exists and is executable, and %NULL otherwise.
14375  *
14376  * On Windows, if @program does not have a file type suffix, tries
14377  * with the suffixes .exe, .cmd, .bat and .com, and the suffixes in
14378  * the <envar>PATHEXT</envar> environment variable.
14379  *
14380  * On Windows, it looks for the file in the same way as CreateProcess()
14381  * would. This means first in the directory where the executing
14382  * program was loaded from, then in the current directory, then in the
14383  * Windows 32-bit system directory, then in the Windows directory, and
14384  * finally in the directories in the <envar>PATH</envar> environment
14385  * variable. If the program is found, the return value contains the
14386  * full name including the type suffix.
14387  *
14388  * Returns: a newly-allocated string with the absolute path, or %NULL
14389  */
14390
14391
14392 /**
14393  * g_fopen:
14394  * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
14395  * @mode: a string describing the mode in which the file should be opened
14396  *
14397  * A wrapper for the stdio fopen() function. The fopen() function
14398  * opens a file and associates a new stream with it.
14399  *
14400  * Because file descriptors are specific to the C library on Windows,
14401  * and a file descriptor is partof the <type>FILE</type> struct, the
14402  * <type>FILE</type> pointer returned by this function makes sense
14403  * only to functions in the same C library. Thus if the GLib-using
14404  * code uses a different C library than GLib does, the
14405  * <type>FILE</type> pointer returned by this function cannot be
14406  * passed to C library functions like fprintf() or fread().
14407  *
14408  * See your C library manual for more details about fopen().
14409  *
14410  * Returns: A <type>FILE</type> pointer if the file was successfully opened, or %NULL if an error occurred
14411  * Since: 2.6
14412  */
14413
14414
14415 /**
14416  * g_format_size:
14417  * @size: a size in bytes
14418  *
14419  * Formats a size (for example the size of a file) into a human readable
14420  * string.  Sizes are rounded to the nearest size prefix (kB, MB, GB)
14421  * and are displayed rounded to the nearest tenth. E.g. the file size
14422  * 3292528 bytes will be converted into the string "3.2 MB".
14423  *
14424  * The prefix units base is 1000 (i.e. 1 kB is 1000 bytes).
14425  *
14426  * This string should be freed with g_free() when not needed any longer.
14427  *
14428  * See g_format_size_full() for more options about how the size might be
14429  * formatted.
14430  *
14431  * Returns: a newly-allocated formatted string containing a human readable file size
14432  * Since: 2.30
14433  */
14434
14435
14436 /**
14437  * g_format_size_for_display:
14438  * @size: a size in bytes
14439  *
14440  * Formats a size (for example the size of a file) into a human
14441  * readable string. Sizes are rounded to the nearest size prefix
14442  * (KB, MB, GB) and are displayed rounded to the nearest tenth.
14443  * E.g. the file size 3292528 bytes will be converted into the
14444  * string "3.1 MB".
14445  *
14446  * The prefix units base is 1024 (i.e. 1 KB is 1024 bytes).
14447  *
14448  * This string should be freed with g_free() when not needed any longer.
14449  *
14450  * Returns: a newly-allocated formatted string containing a human readable file size
14451  * Since: 2.16
14452  * Deprecated: 2.30: This function is broken due to its use of SI suffixes to denote IEC units. Use g_format_size() instead.
14453  */
14454
14455
14456 /**
14457  * g_format_size_full:
14458  * @size: a size in bytes
14459  * @flags: #GFormatSizeFlags to modify the output
14460  *
14461  * Formats a size.
14462  *
14463  * This function is similar to g_format_size() but allows for flags
14464  * that modify the output. See #GFormatSizeFlags.
14465  *
14466  * Returns: a newly-allocated formatted string containing a human readable file size
14467  * Since: 2.30
14468  */
14469
14470
14471 /**
14472  * g_fprintf:
14473  * @file: the stream to write to.
14474  * @format: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
14475  * @...: the arguments to insert in the output.
14476  *
14477  * An implementation of the standard fprintf() function which supports
14478  * positional parameters, as specified in the Single Unix Specification.
14479  *
14480  * Returns: the number of bytes printed.
14481  * Since: 2.2
14482  */
14483
14484
14485 /**
14486  * g_free:
14487  * @mem: the memory to free
14488  *
14489  * Frees the memory pointed to by @mem.
14490  * If @mem is %NULL it simply returns.
14491  */
14492
14493
14494 /**
14495  * g_freopen:
14496  * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
14497  * @mode: a string describing the mode in which the file should be opened
14498  * @stream: (allow-none): an existing stream which will be reused, or %NULL
14499  *
14500  * A wrapper for the POSIX freopen() function. The freopen() function
14501  * opens a file and associates it with an existing stream.
14502  *
14503  * See your C library manual for more details about freopen().
14504  *
14505  * Returns: A <literal>FILE</literal> pointer if the file was successfully opened, or %NULL if an error occurred.
14506  * Since: 2.6
14507  */
14508
14509
14510 /**
14511  * g_get_application_name:
14512  *
14513  * Gets a human-readable name for the application, as set by
14514  * g_set_application_name(). This name should be localized if
14515  * possible, and is intended for display to the user.  Contrast with
14516  * g_get_prgname(), which gets a non-localized name. If
14517  * g_set_application_name() has not been called, returns the result of
14518  * g_get_prgname() (which may be %NULL if g_set_prgname() has also not
14519  * been called).
14520  *
14521  * Returns: human-readable application name. may return %NULL
14522  * Since: 2.2
14523  */
14524
14525
14526 /**
14527  * g_get_charset:
14528  * @charset: return location for character set name
14529  *
14530  * Obtains the character set for the <link linkend="setlocale">current
14531  * locale</link>; you might use this character set as an argument to
14532  * g_convert(), to convert from the current locale's encoding to some
14533  * other encoding. (Frequently g_locale_to_utf8() and g_locale_from_utf8()
14534  * are nice shortcuts, though.)
14535  *
14536  * On Windows the character set returned by this function is the
14537  * so-called system default ANSI code-page. That is the character set
14538  * used by the "narrow" versions of C library and Win32 functions that
14539  * handle file names. It might be different from the character set
14540  * used by the C library's current locale.
14541  *
14542  * The return value is %TRUE if the locale's encoding is UTF-8, in that
14543  * case you can perhaps avoid calling g_convert().
14544  *
14545  * The string returned in @charset is not allocated, and should not be
14546  * freed.
14547  *
14548  * Returns: %TRUE if the returned charset is UTF-8
14549  */
14550
14551
14552 /**
14553  * g_get_codeset:
14554  *
14555  * Gets the character set for the current locale.
14556  *
14557  * Returns: a newly allocated string containing the name of the character set. This string must be freed with g_free().
14558  */
14559
14560
14561 /**
14562  * g_get_current_dir:
14563  *
14564  * Gets the current directory.
14565  *
14566  * The returned string should be freed when no longer needed.
14567  * The encoding of the returned string is system defined.
14568  * On Windows, it is always UTF-8.
14569  *
14570  * Returns: the current directory
14571  */
14572
14573
14574 /**
14575  * g_get_current_time:
14576  * @result: #GTimeVal structure in which to store current time.
14577  *
14578  * Equivalent to the UNIX gettimeofday() function, but portable.
14579  *
14580  * You may find g_get_real_time() to be more convenient.
14581  */
14582
14583
14584 /**
14585  * g_get_environ:
14586  *
14587  * Gets the list of environment variables for the current process.
14588  *
14589  * The list is %NULL terminated and each item in the list is of the
14590  * form 'NAME=VALUE'.
14591  *
14592  * This is equivalent to direct access to the 'environ' global variable,
14593  * except portable.
14594  *
14595  * The return value is freshly allocated and it should be freed with
14596  * g_strfreev() when it is no longer needed.
14597  *
14598  * Returns: (array zero-terminated=1) (transfer full): the list of environment variables
14599  * Since: 2.28
14600  */
14601
14602
14603 /**
14604  * g_get_filename_charsets:
14605  * @charsets: return location for the %NULL-terminated list of encoding names
14606  *
14607  * Determines the preferred character sets used for filenames.
14608  * The first character set from the @charsets is the filename encoding, the
14609  * subsequent character sets are used when trying to generate a displayable
14610  * representation of a filename, see g_filename_display_name().
14611  *
14612  * On Unix, the character sets are determined by consulting the
14613  * environment variables <envar>G_FILENAME_ENCODING</envar> and
14614  * <envar>G_BROKEN_FILENAMES</envar>. On Windows, the character set
14615  * used in the GLib API is always UTF-8 and said environment variables
14616  * have no effect.
14617  *
14618  * <envar>G_FILENAME_ENCODING</envar> may be set to a comma-separated list
14619  * of character set names. The special token "&commat;locale" is taken to
14620  * mean the character set for the <link linkend="setlocale">current
14621  * locale</link>. If <envar>G_FILENAME_ENCODING</envar> is not set, but
14622  * <envar>G_BROKEN_FILENAMES</envar> is, the character set of the current
14623  * locale is taken as the filename encoding. If neither environment variable
14624  * is set, UTF-8 is taken as the filename encoding, but the character
14625  * set of the current locale is also put in the list of encodings.
14626  *
14627  * The returned @charsets belong to GLib and must not be freed.
14628  *
14629  * Note that on Unix, regardless of the locale character set or
14630  * <envar>G_FILENAME_ENCODING</envar> value, the actual file names present
14631  * on a system might be in any random encoding or just gibberish.
14632  *
14633  * Returns: %TRUE if the filename encoding is UTF-8.
14634  * Since: 2.6
14635  */
14636
14637
14638 /**
14639  * g_get_home_dir:
14640  *
14641  * Gets the current user's home directory.
14642  *
14643  * As with most UNIX tools, this function will return the value of the
14644  * <envar>HOME</envar> environment variable if it is set to an existing
14645  * absolute path name, falling back to the <filename>passwd</filename>
14646  * file in the case that it is unset.
14647  *
14648  * If the path given in <envar>HOME</envar> is non-absolute, does not
14649  * exist, or is not a directory, the result is undefined.
14650  *
14651  * <note><para>
14652  *   Before version 2.36 this function would ignore the
14653  *   <envar>HOME</envar> environment variable, taking the value from the
14654  *   <filename>passwd</filename> database instead.  This was changed to
14655  *   increase the compatibility of GLib with other programs (and the XDG
14656  *   basedir specification) and to increase testability of programs
14657  *   based on GLib (by making it easier to run them from test
14658  *   frameworks).
14659  * </para><para>
14660  *   If your program has a strong requirement for either the new or the
14661  *   old behaviour (and if you don't wish to increase your GLib
14662  *   dependency to ensure that the new behaviour is in effect) then you
14663  *   should either directly check the <envar>HOME</envar> environment
14664  *   variable yourself or unset it before calling any functions in GLib.
14665  * </para></note>
14666  *
14667  * Returns: the current user's home directory
14668  */
14669
14670
14671 /**
14672  * g_get_host_name:
14673  *
14674  * Return a name for the machine.
14675  *
14676  * The returned name is not necessarily a fully-qualified domain name,
14677  * or even present in DNS or some other name service at all. It need
14678  * not even be unique on your local network or site, but usually it
14679  * is. Callers should not rely on the return value having any specific
14680  * properties like uniqueness for security purposes. Even if the name
14681  * of the machine is changed while an application is running, the
14682  * return value from this function does not change. The returned
14683  * string is owned by GLib and should not be modified or freed. If no
14684  * name can be determined, a default fixed string "localhost" is
14685  * returned.
14686  *
14687  * Returns: the host name of the machine.
14688  * Since: 2.8
14689  */
14690
14691
14692 /**
14693  * g_get_language_names:
14694  *
14695  * Computes a list of applicable locale names, which can be used to
14696  * e.g. construct locale-dependent filenames or search paths. The returned
14697  * list is sorted from most desirable to least desirable and always contains
14698  * the default locale "C".
14699  *
14700  * For example, if LANGUAGE=de:en_US, then the returned list is
14701  * "de", "en_US", "en", "C".
14702  *
14703  * This function consults the environment variables <envar>LANGUAGE</envar>,
14704  * <envar>LC_ALL</envar>, <envar>LC_MESSAGES</envar> and <envar>LANG</envar>
14705  * to find the list of locales specified by the user.
14706  *
14707  * Returns: (array zero-terminated=1) (transfer none): a %NULL-terminated array of strings owned by GLib that must not be modified or freed.
14708  * Since: 2.6
14709  */
14710
14711
14712 /**
14713  * g_get_locale_variants:
14714  * @locale: a locale identifier
14715  *
14716  * Returns a list of derived variants of @locale, which can be used to
14717  * e.g. construct locale-dependent filenames or search paths. The returned
14718  * list is sorted from most desirable to least desirable.
14719  * This function handles territory, charset and extra locale modifiers.
14720  *
14721  * For example, if @locale is "fr_BE", then the returned list
14722  * is "fr_BE", "fr".
14723  *
14724  * If you need the list of variants for the <emphasis>current locale</emphasis>,
14725  * use g_get_language_names().
14726  *
14727  * Returns: (transfer full) (array zero-terminated=1) (element-type utf8): a newly allocated array of newly allocated strings with the locale variants. Free with g_strfreev().
14728  * Since: 2.28
14729  */
14730
14731
14732 /**
14733  * g_get_monotonic_time:
14734  *
14735  * Queries the system monotonic time, if available.
14736  *
14737  * On POSIX systems with clock_gettime() and <literal>CLOCK_MONOTONIC</literal> this call
14738  * is a very shallow wrapper for that.  Otherwise, we make a best effort
14739  * that probably involves returning the wall clock time (with at least
14740  * microsecond accuracy, subject to the limitations of the OS kernel).
14741  *
14742  * It's important to note that POSIX <literal>CLOCK_MONOTONIC</literal> does
14743  * not count time spent while the machine is suspended.
14744  *
14745  * On Windows, "limitations of the OS kernel" is a rather substantial
14746  * statement.  Depending on the configuration of the system, the wall
14747  * clock time is updated as infrequently as 64 times a second (which
14748  * is approximately every 16ms). Also, on XP (but not on Vista or later)
14749  * the monotonic clock is locally monotonic, but may differ in exact
14750  * value between processes due to timer wrap handling.
14751  *
14752  * Returns: the monotonic time, in microseconds
14753  * Since: 2.28
14754  */
14755
14756
14757 /**
14758  * g_get_num_processors:
14759  *
14760  * Determine the approximate number of threads that the system will
14761  * schedule simultaneously for this process.  This is intended to be
14762  * used as a parameter to g_thread_pool_new() for CPU bound tasks and
14763  * similar cases.
14764  *
14765  * Returns: Number of schedulable threads, always greater than 0
14766  * Since: 2.36
14767  */
14768
14769
14770 /**
14771  * g_get_prgname:
14772  *
14773  * Gets the name of the program. This name should <emphasis>not</emphasis>
14774  * be localized, contrast with g_get_application_name().
14775  * (If you are using GDK or GTK+ the program name is set in gdk_init(),
14776  * which is called by gtk_init(). The program name is found by taking
14777  * the last component of <literal>argv[0]</literal>.)
14778  *
14779  * Returns: the name of the program. The returned string belongs to GLib and must not be modified or freed.
14780  */
14781
14782
14783 /**
14784  * g_get_real_name:
14785  *
14786  * Gets the real name of the user. This usually comes from the user's entry
14787  * in the <filename>passwd</filename> file. The encoding of the returned
14788  * string is system-defined. (On Windows, it is, however, always UTF-8.)
14789  * If the real user name cannot be determined, the string "Unknown" is
14790  * returned.
14791  *
14792  * Returns: the user's real name.
14793  */
14794
14795
14796 /**
14797  * g_get_real_time:
14798  *
14799  * Queries the system wall-clock time.
14800  *
14801  * This call is functionally equivalent to g_get_current_time() except
14802  * that the return value is often more convenient than dealing with a
14803  * #GTimeVal.
14804  *
14805  * You should only use this call if you are actually interested in the real
14806  * wall-clock time.  g_get_monotonic_time() is probably more useful for
14807  * measuring intervals.
14808  *
14809  * Returns: the number of microseconds since January 1, 1970 UTC.
14810  * Since: 2.28
14811  */
14812
14813
14814 /**
14815  * g_get_system_config_dirs:
14816  *
14817  * Returns an ordered list of base directories in which to access
14818  * system-wide configuration information.
14819  *
14820  * On UNIX platforms this is determined using the mechanisms described in
14821  * the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
14822  * XDG Base Directory Specification</ulink>.
14823  * In this case the list of directories retrieved will be XDG_CONFIG_DIRS.
14824  *
14825  * On Windows is the directory that contains application data for all users.
14826  * A typical path is C:\Documents and Settings\All Users\Application Data.
14827  * This folder is used for application data that is not user specific.
14828  * For example, an application can store a spell-check dictionary, a database
14829  * of clip art, or a log file in the CSIDL_COMMON_APPDATA folder.
14830  * This information will not roam and is available to anyone using the computer.
14831  *
14832  * Returns: (array zero-terminated=1) (transfer none): a %NULL-terminated array of strings owned by GLib that must not be modified or freed.
14833  * Since: 2.6
14834  */
14835
14836
14837 /**
14838  * g_get_system_data_dirs:
14839  *
14840  * Returns an ordered list of base directories in which to access
14841  * system-wide application data.
14842  *
14843  * On UNIX platforms this is determined using the mechanisms described in
14844  * the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
14845  * XDG Base Directory Specification</ulink>
14846  * In this case the list of directories retrieved will be XDG_DATA_DIRS.
14847  *
14848  * On Windows the first elements in the list are the Application Data
14849  * and Documents folders for All Users. (These can be determined only
14850  * on Windows 2000 or later and are not present in the list on other
14851  * Windows versions.) See documentation for CSIDL_COMMON_APPDATA and
14852  * CSIDL_COMMON_DOCUMENTS.
14853  *
14854  * Then follows the "share" subfolder in the installation folder for
14855  * the package containing the DLL that calls this function, if it can
14856  * be determined.
14857  *
14858  * Finally the list contains the "share" subfolder in the installation
14859  * folder for GLib, and in the installation folder for the package the
14860  * application's .exe file belongs to.
14861  *
14862  * The installation folders above are determined by looking up the
14863  * folder where the module (DLL or EXE) in question is located. If the
14864  * folder's name is "bin", its parent is used, otherwise the folder
14865  * itself.
14866  *
14867  * Note that on Windows the returned list can vary depending on where
14868  * this function is called.
14869  *
14870  * Returns: (array zero-terminated=1) (transfer none): a %NULL-terminated array of strings owned by GLib that must not be modified or freed.
14871  * Since: 2.6
14872  */
14873
14874
14875 /**
14876  * g_get_tmp_dir:
14877  *
14878  * Gets the directory to use for temporary files.
14879  *
14880  * On UNIX, this is taken from the <envar>TMPDIR</envar> environment
14881  * variable.  If the variable is not set, <literal>P_tmpdir</literal> is
14882  * used, as defined by the system C library.  Failing that, a hard-coded
14883  * default of "/tmp" is returned.
14884  *
14885  * On Windows, the <envar>TEMP</envar> environment variable is used,
14886  * with the root directory of the Windows installation (eg: "C:\") used
14887  * as a default.
14888  *
14889  * The encoding of the returned string is system-defined. On Windows, it
14890  * is always UTF-8. The return value is never %NULL or the empty string.
14891  *
14892  * Returns: the directory to use for temporary files.
14893  */
14894
14895
14896 /**
14897  * g_get_user_cache_dir:
14898  *
14899  * Returns a base directory in which to store non-essential, cached
14900  * data specific to particular user.
14901  *
14902  * On UNIX platforms this is determined using the mechanisms described in
14903  * the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
14904  * XDG Base Directory Specification</ulink>.
14905  * In this case the directory retrieved will be XDG_CACHE_HOME.
14906  *
14907  * On Windows is the directory that serves as a common repository for
14908  * temporary Internet files. A typical path is
14909  * C:\Documents and Settings\username\Local Settings\Temporary Internet Files.
14910  * See documentation for CSIDL_INTERNET_CACHE.
14911  *
14912  * Returns: a string owned by GLib that must not be modified or freed.
14913  * Since: 2.6
14914  */
14915
14916
14917 /**
14918  * g_get_user_config_dir:
14919  *
14920  * Returns a base directory in which to store user-specific application
14921  * configuration information such as user preferences and settings.
14922  *
14923  * On UNIX platforms this is determined using the mechanisms described in
14924  * the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
14925  * XDG Base Directory Specification</ulink>.
14926  * In this case the directory retrieved will be XDG_CONFIG_HOME.
14927  *
14928  * On Windows this is the folder to use for local (as opposed to
14929  * roaming) application data. See documentation for
14930  * CSIDL_LOCAL_APPDATA. Note that on Windows it thus is the same as
14931  * what g_get_user_data_dir() returns.
14932  *
14933  * Returns: a string owned by GLib that must not be modified or freed.
14934  * Since: 2.6
14935  */
14936
14937
14938 /**
14939  * g_get_user_data_dir:
14940  *
14941  * Returns a base directory in which to access application data such
14942  * as icons that is customized for a particular user.
14943  *
14944  * On UNIX platforms this is determined using the mechanisms described in
14945  * the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
14946  * XDG Base Directory Specification</ulink>.
14947  * In this case the directory retrieved will be XDG_DATA_HOME.
14948  *
14949  * On Windows this is the folder to use for local (as opposed to
14950  * roaming) application data. See documentation for
14951  * CSIDL_LOCAL_APPDATA. Note that on Windows it thus is the same as
14952  * what g_get_user_config_dir() returns.
14953  *
14954  * Returns: a string owned by GLib that must not be modified or freed.
14955  * Since: 2.6
14956  */
14957
14958
14959 /**
14960  * g_get_user_name:
14961  *
14962  * Gets the user name of the current user. The encoding of the returned
14963  * string is system-defined. On UNIX, it might be the preferred file name
14964  * encoding, or something else, and there is no guarantee that it is even
14965  * consistent on a machine. On Windows, it is always UTF-8.
14966  *
14967  * Returns: the user name of the current user.
14968  */
14969
14970
14971 /**
14972  * g_get_user_runtime_dir:
14973  *
14974  * Returns a directory that is unique to the current user on the local
14975  * system.
14976  *
14977  * On UNIX platforms this is determined using the mechanisms described in
14978  * the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
14979  * XDG Base Directory Specification</ulink>.  This is the directory
14980  * specified in the <envar>XDG_RUNTIME_DIR</envar> environment variable.
14981  * In the case that this variable is not set, GLib will issue a warning
14982  * message to stderr and return the value of g_get_user_cache_dir().
14983  *
14984  * On Windows this is the folder to use for local (as opposed to
14985  * roaming) application data. See documentation for
14986  * CSIDL_LOCAL_APPDATA.  Note that on Windows it thus is the same as
14987  * what g_get_user_config_dir() returns.
14988  *
14989  * Returns: a string owned by GLib that must not be modified or freed.
14990  * Since: 2.28
14991  */
14992
14993
14994 /**
14995  * g_get_user_special_dir:
14996  * @directory: the logical id of special directory
14997  *
14998  * Returns the full path of a special directory using its logical id.
14999  *
15000  * On Unix this is done using the XDG special user directories.
15001  * For compatibility with existing practise, %G_USER_DIRECTORY_DESKTOP
15002  * falls back to <filename>$HOME/Desktop</filename> when XDG special
15003  * user directories have not been set up.
15004  *
15005  * Depending on the platform, the user might be able to change the path
15006  * of the special directory without requiring the session to restart; GLib
15007  * will not reflect any change once the special directories are loaded.
15008  *
15009  * Returns: the path to the specified special directory, or %NULL if the logical id was not found. The returned string is owned by GLib and should not be modified or freed.
15010  * Since: 2.14
15011  */
15012
15013
15014 /**
15015  * g_getenv:
15016  * @variable: the environment variable to get, in the GLib file name encoding
15017  *
15018  * Returns the value of an environment variable.
15019  *
15020  * The name and value are in the GLib file name encoding. On UNIX,
15021  * this means the actual bytes which might or might not be in some
15022  * consistent character set and encoding. On Windows, it is in UTF-8.
15023  * On Windows, in case the environment variable's value contains
15024  * references to other environment variables, they are expanded.
15025  *
15026  * Returns: the value of the environment variable, or %NULL if the environment variable is not found. The returned string may be overwritten by the next call to g_getenv(), g_setenv() or g_unsetenv().
15027  */
15028
15029
15030 /**
15031  * g_hash_table_add:
15032  * @hash_table: a #GHashTable
15033  * @key: a key to insert
15034  *
15035  * This is a convenience function for using a #GHashTable as a set.  It
15036  * is equivalent to calling g_hash_table_replace() with @key as both the
15037  * key and the value.
15038  *
15039  * When a hash table only ever contains keys that have themselves as the
15040  * corresponding value it is able to be stored more efficiently.  See
15041  * the discussion in the section description.
15042  *
15043  * Since: 2.32
15044  */
15045
15046
15047 /**
15048  * g_hash_table_contains:
15049  * @hash_table: a #GHashTable
15050  * @key: a key to check
15051  *
15052  * Checks if @key is in @hash_table.
15053  *
15054  * Since: 2.32
15055  */
15056
15057
15058 /**
15059  * g_hash_table_destroy:
15060  * @hash_table: a #GHashTable
15061  *
15062  * Destroys all keys and values in the #GHashTable and decrements its
15063  * reference count by 1. If keys and/or values are dynamically allocated,
15064  * you should either free them first or create the #GHashTable with destroy
15065  * notifiers using g_hash_table_new_full(). In the latter case the destroy
15066  * functions you supplied will be called on all keys and values during the
15067  * destruction phase.
15068  */
15069
15070
15071 /**
15072  * g_hash_table_find:
15073  * @hash_table: a #GHashTable
15074  * @predicate: function to test the key/value pairs for a certain property
15075  * @user_data: user data to pass to the function
15076  *
15077  * Calls the given function for key/value pairs in the #GHashTable
15078  * until @predicate returns %TRUE. The function is passed the key
15079  * and value of each pair, and the given @user_data parameter. The
15080  * hash table may not be modified while iterating over it (you can't
15081  * add/remove items).
15082  *
15083  * Note, that hash tables are really only optimized for forward
15084  * lookups, i.e. g_hash_table_lookup(). So code that frequently issues
15085  * g_hash_table_find() or g_hash_table_foreach() (e.g. in the order of
15086  * once per every entry in a hash table) should probably be reworked
15087  * to use additional or different data structures for reverse lookups
15088  * (keep in mind that an O(n) find/foreach operation issued for all n
15089  * values in a hash table ends up needing O(n*n) operations).
15090  *
15091  * Returns: (allow-none): The value of the first key/value pair is returned, for which @predicate evaluates to %TRUE. If no pair with the requested property is found, %NULL is returned.
15092  * Since: 2.4
15093  */
15094
15095
15096 /**
15097  * g_hash_table_foreach:
15098  * @hash_table: a #GHashTable
15099  * @func: the function to call for each key/value pair
15100  * @user_data: user data to pass to the function
15101  *
15102  * Calls the given function for each of the key/value pairs in the
15103  * #GHashTable.  The function is passed the key and value of each
15104  * pair, and the given @user_data parameter.  The hash table may not
15105  * be modified while iterating over it (you can't add/remove
15106  * items). To remove all items matching a predicate, use
15107  * g_hash_table_foreach_remove().
15108  *
15109  * See g_hash_table_find() for performance caveats for linear
15110  * order searches in contrast to g_hash_table_lookup().
15111  */
15112
15113
15114 /**
15115  * g_hash_table_foreach_remove:
15116  * @hash_table: a #GHashTable
15117  * @func: the function to call for each key/value pair
15118  * @user_data: user data to pass to the function
15119  *
15120  * Calls the given function for each key/value pair in the
15121  * #GHashTable. If the function returns %TRUE, then the key/value
15122  * pair is removed from the #GHashTable. If you supplied key or
15123  * value destroy functions when creating the #GHashTable, they are
15124  * used to free the memory allocated for the removed keys and values.
15125  *
15126  * See #GHashTableIter for an alternative way to loop over the
15127  * key/value pairs in the hash table.
15128  *
15129  * Returns: the number of key/value pairs removed
15130  */
15131
15132
15133 /**
15134  * g_hash_table_foreach_steal:
15135  * @hash_table: a #GHashTable
15136  * @func: the function to call for each key/value pair
15137  * @user_data: user data to pass to the function
15138  *
15139  * Calls the given function for each key/value pair in the
15140  * #GHashTable. If the function returns %TRUE, then the key/value
15141  * pair is removed from the #GHashTable, but no key or value
15142  * destroy functions are called.
15143  *
15144  * See #GHashTableIter for an alternative way to loop over the
15145  * key/value pairs in the hash table.
15146  *
15147  * Returns: the number of key/value pairs removed.
15148  */
15149
15150
15151 /**
15152  * g_hash_table_freeze:
15153  * @hash_table: a #GHashTable
15154  *
15155  * This function is deprecated and will be removed in the next major
15156  * release of GLib. It does nothing.
15157  */
15158
15159
15160 /**
15161  * g_hash_table_get_keys:
15162  * @hash_table: a #GHashTable
15163  *
15164  * Retrieves every key inside @hash_table. The returned data is valid
15165  * until changes to the hash release those keys.
15166  *
15167  * Returns: a #GList containing all the keys inside the hash table. The content of the list is owned by the hash table and should not be modified or freed. Use g_list_free() when done using the list.
15168  * Since: 2.14
15169  */
15170
15171
15172 /**
15173  * g_hash_table_get_values:
15174  * @hash_table: a #GHashTable
15175  *
15176  * Retrieves every value inside @hash_table. The returned data
15177  * is valid until @hash_table is modified.
15178  *
15179  * Returns: a #GList containing all the values inside the hash table. The content of the list is owned by the hash table and should not be modified or freed. Use g_list_free() when done using the list.
15180  * Since: 2.14
15181  */
15182
15183
15184 /**
15185  * g_hash_table_insert:
15186  * @hash_table: a #GHashTable
15187  * @key: a key to insert
15188  * @value: the value to associate with the key
15189  *
15190  * Inserts a new key and value into a #GHashTable.
15191  *
15192  * If the key already exists in the #GHashTable its current
15193  * value is replaced with the new value. If you supplied a
15194  * @value_destroy_func when creating the #GHashTable, the old
15195  * value is freed using that function. If you supplied a
15196  * @key_destroy_func when creating the #GHashTable, the passed
15197  * key is freed using that function.
15198  */
15199
15200
15201 /**
15202  * g_hash_table_iter_get_hash_table:
15203  * @iter: an initialized #GHashTableIter
15204  *
15205  * Returns the #GHashTable associated with @iter.
15206  *
15207  * Returns: the #GHashTable associated with @iter.
15208  * Since: 2.16
15209  */
15210
15211
15212 /**
15213  * g_hash_table_iter_init:
15214  * @iter: an uninitialized #GHashTableIter
15215  * @hash_table: a #GHashTable
15216  *
15217  * Initializes a key/value pair iterator and associates it with
15218  * @hash_table. Modifying the hash table after calling this function
15219  * invalidates the returned iterator.
15220  * |[
15221  * GHashTableIter iter;
15222  * gpointer key, value;
15223  *
15224  * g_hash_table_iter_init (&iter, hash_table);
15225  * while (g_hash_table_iter_next (&iter, &key, &value))
15226  *   {
15227  *     /&ast; do something with key and value &ast;/
15228  *   }
15229  * ]|
15230  *
15231  * Since: 2.16
15232  */
15233
15234
15235 /**
15236  * g_hash_table_iter_next:
15237  * @iter: an initialized #GHashTableIter
15238  * @key: (allow-none): a location to store the key, or %NULL
15239  * @value: (allow-none): a location to store the value, or %NULL
15240  *
15241  * Advances @iter and retrieves the key and/or value that are now
15242  * pointed to as a result of this advancement. If %FALSE is returned,
15243  * @key and @value are not set, and the iterator becomes invalid.
15244  *
15245  * Returns: %FALSE if the end of the #GHashTable has been reached.
15246  * Since: 2.16
15247  */
15248
15249
15250 /**
15251  * g_hash_table_iter_remove:
15252  * @iter: an initialized #GHashTableIter
15253  *
15254  * Removes the key/value pair currently pointed to by the iterator
15255  * from its associated #GHashTable. Can only be called after
15256  * g_hash_table_iter_next() returned %TRUE, and cannot be called
15257  * more than once for the same key/value pair.
15258  *
15259  * If the #GHashTable was created using g_hash_table_new_full(),
15260  * the key and value are freed using the supplied destroy functions,
15261  * otherwise you have to make sure that any dynamically allocated
15262  * values are freed yourself.
15263  *
15264  * Since: 2.16
15265  */
15266
15267
15268 /**
15269  * g_hash_table_iter_replace:
15270  * @iter: an initialized #GHashTableIter
15271  * @value: the value to replace with
15272  *
15273  * Replaces the value currently pointed to by the iterator
15274  * from its associated #GHashTable. Can only be called after
15275  * g_hash_table_iter_next() returned %TRUE.
15276  *
15277  * If you supplied a @value_destroy_func when creating the
15278  * #GHashTable, the old value is freed using that function.
15279  *
15280  * Since: 2.30
15281  */
15282
15283
15284 /**
15285  * g_hash_table_iter_steal:
15286  * @iter: an initialized #GHashTableIter
15287  *
15288  * Removes the key/value pair currently pointed to by the
15289  * iterator from its associated #GHashTable, without calling
15290  * the key and value destroy functions. Can only be called
15291  * after g_hash_table_iter_next() returned %TRUE, and cannot
15292  * be called more than once for the same key/value pair.
15293  *
15294  * Since: 2.16
15295  */
15296
15297
15298 /**
15299  * g_hash_table_lookup:
15300  * @hash_table: a #GHashTable
15301  * @key: the key to look up
15302  *
15303  * Looks up a key in a #GHashTable. Note that this function cannot
15304  * distinguish between a key that is not present and one which is present
15305  * and has the value %NULL. If you need this distinction, use
15306  * g_hash_table_lookup_extended().
15307  *
15308  * Returns: (allow-none): the associated value, or %NULL if the key is not found
15309  */
15310
15311
15312 /**
15313  * g_hash_table_lookup_extended:
15314  * @hash_table: a #GHashTable
15315  * @lookup_key: the key to look up
15316  * @orig_key: (allow-none): return location for the original key, or %NULL
15317  * @value: (allow-none): return location for the value associated with the key, or %NULL
15318  *
15319  * Looks up a key in the #GHashTable, returning the original key and the
15320  * associated value and a #gboolean which is %TRUE if the key was found. This
15321  * is useful if you need to free the memory allocated for the original key,
15322  * for example before calling g_hash_table_remove().
15323  *
15324  * You can actually pass %NULL for @lookup_key to test
15325  * whether the %NULL key exists, provided the hash and equal functions
15326  * of @hash_table are %NULL-safe.
15327  *
15328  * Returns: %TRUE if the key was found in the #GHashTable
15329  */
15330
15331
15332 /**
15333  * g_hash_table_new:
15334  * @hash_func: a function to create a hash value from a key
15335  * @key_equal_func: a function to check two keys for equality
15336  *
15337  * Creates a new #GHashTable with a reference count of 1.
15338  *
15339  * Hash values returned by @hash_func are used to determine where keys
15340  * are stored within the #GHashTable data structure. The g_direct_hash(),
15341  * g_int_hash(), g_int64_hash(), g_double_hash() and g_str_hash()
15342  * functions are provided for some common types of keys.
15343  * If @hash_func is %NULL, g_direct_hash() is used.
15344  *
15345  * @key_equal_func is used when looking up keys in the #GHashTable.
15346  * The g_direct_equal(), g_int_equal(), g_int64_equal(), g_double_equal()
15347  * and g_str_equal() functions are provided for the most common types
15348  * of keys. If @key_equal_func is %NULL, keys are compared directly in
15349  * a similar fashion to g_direct_equal(), but without the overhead of
15350  * a function call.
15351  *
15352  * Returns: a new #GHashTable
15353  */
15354
15355
15356 /**
15357  * g_hash_table_new_full:
15358  * @hash_func: a function to create a hash value from a key
15359  * @key_equal_func: a function to check two keys for equality
15360  * @key_destroy_func: (allow-none): a function to free the memory allocated for the key used when removing the entry from the #GHashTable, or %NULL if you don't want to supply such a function.
15361  * @value_destroy_func: (allow-none): a function to free the memory allocated for the value used when removing the entry from the #GHashTable, or %NULL if you don't want to supply such a function.
15362  *
15363  * Creates a new #GHashTable like g_hash_table_new() with a reference
15364  * count of 1 and allows to specify functions to free the memory
15365  * allocated for the key and value that get called when removing the
15366  * entry from the #GHashTable.
15367  *
15368  * Returns: a new #GHashTable
15369  */
15370
15371
15372 /**
15373  * g_hash_table_ref:
15374  * @hash_table: a valid #GHashTable
15375  *
15376  * Atomically increments the reference count of @hash_table by one.
15377  * This function is MT-safe and may be called from any thread.
15378  *
15379  * Returns: the passed in #GHashTable
15380  * Since: 2.10
15381  */
15382
15383
15384 /**
15385  * g_hash_table_remove:
15386  * @hash_table: a #GHashTable
15387  * @key: the key to remove
15388  *
15389  * Removes a key and its associated value from a #GHashTable.
15390  *
15391  * If the #GHashTable was created using g_hash_table_new_full(), the
15392  * key and value are freed using the supplied destroy functions, otherwise
15393  * you have to make sure that any dynamically allocated values are freed
15394  * yourself.
15395  *
15396  * Returns: %TRUE if the key was found and removed from the #GHashTable
15397  */
15398
15399
15400 /**
15401  * g_hash_table_remove_all:
15402  * @hash_table: a #GHashTable
15403  *
15404  * Removes all keys and their associated values from a #GHashTable.
15405  *
15406  * If the #GHashTable was created using g_hash_table_new_full(),
15407  * the keys and values are freed using the supplied destroy functions,
15408  * otherwise you have to make sure that any dynamically allocated
15409  * values are freed yourself.
15410  *
15411  * Since: 2.12
15412  */
15413
15414
15415 /**
15416  * g_hash_table_replace:
15417  * @hash_table: a #GHashTable
15418  * @key: a key to insert
15419  * @value: the value to associate with the key
15420  *
15421  * Inserts a new key and value into a #GHashTable similar to
15422  * g_hash_table_insert(). The difference is that if the key
15423  * already exists in the #GHashTable, it gets replaced by the
15424  * new key. If you supplied a @value_destroy_func when creating
15425  * the #GHashTable, the old value is freed using that function.
15426  * If you supplied a @key_destroy_func when creating the
15427  * #GHashTable, the old key is freed using that function.
15428  */
15429
15430
15431 /**
15432  * g_hash_table_size:
15433  * @hash_table: a #GHashTable
15434  *
15435  * Returns the number of elements contained in the #GHashTable.
15436  *
15437  * Returns: the number of key/value pairs in the #GHashTable.
15438  */
15439
15440
15441 /**
15442  * g_hash_table_steal:
15443  * @hash_table: a #GHashTable
15444  * @key: the key to remove
15445  *
15446  * Removes a key and its associated value from a #GHashTable without
15447  * calling the key and value destroy functions.
15448  *
15449  * Returns: %TRUE if the key was found and removed from the #GHashTable
15450  */
15451
15452
15453 /**
15454  * g_hash_table_steal_all:
15455  * @hash_table: a #GHashTable
15456  *
15457  * Removes all keys and their associated values from a #GHashTable
15458  * without calling the key and value destroy functions.
15459  *
15460  * Since: 2.12
15461  */
15462
15463
15464 /**
15465  * g_hash_table_thaw:
15466  * @hash_table: a #GHashTable
15467  *
15468  * This function is deprecated and will be removed in the next major
15469  * release of GLib. It does nothing.
15470  */
15471
15472
15473 /**
15474  * g_hash_table_unref:
15475  * @hash_table: a valid #GHashTable
15476  *
15477  * Atomically decrements the reference count of @hash_table by one.
15478  * If the reference count drops to 0, all keys and values will be
15479  * destroyed, and all memory allocated by the hash table is released.
15480  * This function is MT-safe and may be called from any thread.
15481  *
15482  * Since: 2.10
15483  */
15484
15485
15486 /**
15487  * g_hmac_copy:
15488  * @hmac: the #GHmac to copy
15489  *
15490  * Copies a #GHmac. If @hmac has been closed, by calling
15491  * g_hmac_get_string() or g_hmac_get_digest(), the copied
15492  * HMAC will be closed as well.
15493  *
15494  * Returns: the copy of the passed #GHmac. Use g_hmac_unref() when finished using it.
15495  * Since: 2.30
15496  */
15497
15498
15499 /**
15500  * g_hmac_get_digest:
15501  * @hmac: a #GHmac
15502  * @buffer: output buffer
15503  * @digest_len: an inout parameter. The caller initializes it to the size of @buffer. After the call it contains the length of the digest
15504  *
15505  * Gets the digest from @checksum as a raw binary array and places it
15506  * into @buffer. The size of the digest depends on the type of checksum.
15507  *
15508  * Once this function has been called, the #GHmac is closed and can
15509  * no longer be updated with g_checksum_update().
15510  *
15511  * Since: 2.30
15512  */
15513
15514
15515 /**
15516  * g_hmac_get_string:
15517  * @hmac: a #GHmac
15518  *
15519  * Gets the HMAC as an hexadecimal string.
15520  *
15521  * Once this function has been called the #GHmac can no longer be
15522  * updated with g_hmac_update().
15523  *
15524  * The hexadecimal characters will be lower case.
15525  *
15526  * Returns: the hexadecimal representation of the HMAC. The returned string is owned by the HMAC and should not be modified or freed.
15527  * Since: 2.30
15528  */
15529
15530
15531 /**
15532  * g_hmac_new:
15533  * @digest_type: the desired type of digest
15534  * @key: (array length=key_len): the key for the HMAC
15535  * @key_len: the length of the keys
15536  *
15537  * Creates a new #GHmac, using the digest algorithm @digest_type.
15538  * If the @digest_type is not known, %NULL is returned.
15539  * A #GHmac can be used to compute the HMAC of a key and an
15540  * arbitrary binary blob, using different hashing algorithms.
15541  *
15542  * A #GHmac works by feeding a binary blob through g_hmac_update()
15543  * until the data is complete; the digest can then be extracted
15544  * using g_hmac_get_string(), which will return the checksum as a
15545  * hexadecimal string; or g_hmac_get_digest(), which will return a
15546  * array of raw bytes. Once either g_hmac_get_string() or
15547  * g_hmac_get_digest() have been called on a #GHmac, the HMAC
15548  * will be closed and it won't be possible to call g_hmac_update()
15549  * on it anymore.
15550  *
15551  * Returns: the newly created #GHmac, or %NULL. Use g_hmac_unref() to free the memory allocated by it.
15552  * Since: 2.30
15553  */
15554
15555
15556 /**
15557  * g_hmac_ref:
15558  * @hmac: a valid #GHmac
15559  *
15560  * Atomically increments the reference count of @hmac by one.
15561  *
15562  * This function is MT-safe and may be called from any thread.
15563  *
15564  * Returns: the passed in #GHmac.
15565  * Since: 2.30
15566  */
15567
15568
15569 /**
15570  * g_hmac_unref:
15571  * @hmac: a #GHmac
15572  *
15573  * Atomically decrements the reference count of @hmac by one.
15574  *
15575  * If the reference count drops to 0, all keys and values will be
15576  * destroyed, and all memory allocated by the hash table is released.
15577  * This function is MT-safe and may be called from any thread.
15578  * Frees the memory allocated for @hmac.
15579  *
15580  * Since: 2.30
15581  */
15582
15583
15584 /**
15585  * g_hmac_update:
15586  * @hmac: a #GHmac
15587  * @data: (array length=length): buffer used to compute the checksum
15588  * @length: size of the buffer, or -1 if it is a nul-terminated string
15589  *
15590  * Feeds @data into an existing #GHmac.
15591  *
15592  * The HMAC must still be open, that is g_hmac_get_string() or
15593  * g_hmac_get_digest() must not have been called on @hmac.
15594  *
15595  * Since: 2.30
15596  */
15597
15598
15599 /**
15600  * g_hook_alloc:
15601  * @hook_list: a #GHookList
15602  *
15603  * Allocates space for a #GHook and initializes it.
15604  *
15605  * Returns: a new #GHook
15606  */
15607
15608
15609 /**
15610  * g_hook_append:
15611  * @hook_list: a #GHookList
15612  * @hook: the #GHook to add to the end of @hook_list
15613  *
15614  * Appends a #GHook onto the end of a #GHookList.
15615  */
15616
15617
15618 /**
15619  * g_hook_compare_ids:
15620  * @new_hook: a #GHook
15621  * @sibling: a #GHook to compare with @new_hook
15622  *
15623  * Compares the ids of two #GHook elements, returning a negative value
15624  * if the second id is greater than the first.
15625  *
15626  * Returns: a value &lt;= 0 if the id of @sibling is >= the id of @new_hook
15627  */
15628
15629
15630 /**
15631  * g_hook_destroy:
15632  * @hook_list: a #GHookList
15633  * @hook_id: a hook ID
15634  *
15635  * Destroys a #GHook, given its ID.
15636  *
15637  * Returns: %TRUE if the #GHook was found in the #GHookList and destroyed
15638  */
15639
15640
15641 /**
15642  * g_hook_destroy_link:
15643  * @hook_list: a #GHookList
15644  * @hook: the #GHook to remove
15645  *
15646  * Removes one #GHook from a #GHookList, marking it
15647  * inactive and calling g_hook_unref() on it.
15648  */
15649
15650
15651 /**
15652  * g_hook_find:
15653  * @hook_list: a #GHookList
15654  * @need_valids: %TRUE if #GHook elements which have been destroyed should be skipped
15655  * @func: the function to call for each #GHook, which should return %TRUE when the #GHook has been found
15656  * @data: the data to pass to @func
15657  *
15658  * Finds a #GHook in a #GHookList using the given function to
15659  * test for a match.
15660  *
15661  * Returns: the found #GHook or %NULL if no matching #GHook is found
15662  */
15663
15664
15665 /**
15666  * g_hook_find_data:
15667  * @hook_list: a #GHookList
15668  * @need_valids: %TRUE if #GHook elements which have been destroyed should be skipped
15669  * @data: the data to find
15670  *
15671  * Finds a #GHook in a #GHookList with the given data.
15672  *
15673  * Returns: the #GHook with the given @data or %NULL if no matching #GHook is found
15674  */
15675
15676
15677 /**
15678  * g_hook_find_func:
15679  * @hook_list: a #GHookList
15680  * @need_valids: %TRUE if #GHook elements which have been destroyed should be skipped
15681  * @func: the function to find
15682  *
15683  * Finds a #GHook in a #GHookList with the given function.
15684  *
15685  * Returns: the #GHook with the given @func or %NULL if no matching #GHook is found
15686  */
15687
15688
15689 /**
15690  * g_hook_find_func_data:
15691  * @hook_list: a #GHookList
15692  * @need_valids: %TRUE if #GHook elements which have been destroyed should be skipped
15693  * @func: the function to find
15694  * @data: the data to find
15695  *
15696  * Finds a #GHook in a #GHookList with the given function and data.
15697  *
15698  * Returns: the #GHook with the given @func and @data or %NULL if no matching #GHook is found
15699  */
15700
15701
15702 /**
15703  * g_hook_first_valid:
15704  * @hook_list: a #GHookList
15705  * @may_be_in_call: %TRUE if hooks which are currently running (e.g. in another thread) are considered valid. If set to %FALSE, these are skipped
15706  *
15707  * Returns the first #GHook in a #GHookList which has not been destroyed.
15708  * The reference count for the #GHook is incremented, so you must call
15709  * g_hook_unref() to restore it when no longer needed. (Or call
15710  * g_hook_next_valid() if you are stepping through the #GHookList.)
15711  *
15712  * Returns: the first valid #GHook, or %NULL if none are valid
15713  */
15714
15715
15716 /**
15717  * g_hook_free:
15718  * @hook_list: a #GHookList
15719  * @hook: the #GHook to free
15720  *
15721  * Calls the #GHookList @finalize_hook function if it exists,
15722  * and frees the memory allocated for the #GHook.
15723  */
15724
15725
15726 /**
15727  * g_hook_get:
15728  * @hook_list: a #GHookList
15729  * @hook_id: a hook id
15730  *
15731  * Returns the #GHook with the given id, or %NULL if it is not found.
15732  *
15733  * Returns: the #GHook with the given id, or %NULL if it is not found
15734  */
15735
15736
15737 /**
15738  * g_hook_insert_before:
15739  * @hook_list: a #GHookList
15740  * @sibling: the #GHook to insert the new #GHook before
15741  * @hook: the #GHook to insert
15742  *
15743  * Inserts a #GHook into a #GHookList, before a given #GHook.
15744  */
15745
15746
15747 /**
15748  * g_hook_insert_sorted:
15749  * @hook_list: a #GHookList
15750  * @hook: the #GHook to insert
15751  * @func: the comparison function used to sort the #GHook elements
15752  *
15753  * Inserts a #GHook into a #GHookList, sorted by the given function.
15754  */
15755
15756
15757 /**
15758  * g_hook_list_clear:
15759  * @hook_list: a #GHookList
15760  *
15761  * Removes all the #GHook elements from a #GHookList.
15762  */
15763
15764
15765 /**
15766  * g_hook_list_init:
15767  * @hook_list: a #GHookList
15768  * @hook_size: the size of each element in the #GHookList, typically <literal>sizeof (GHook)</literal>
15769  *
15770  * Initializes a #GHookList.
15771  * This must be called before the #GHookList is used.
15772  */
15773
15774
15775 /**
15776  * g_hook_list_invoke:
15777  * @hook_list: a #GHookList
15778  * @may_recurse: %TRUE if functions which are already running (e.g. in another thread) can be called. If set to %FALSE, these are skipped
15779  *
15780  * Calls all of the #GHook functions in a #GHookList.
15781  */
15782
15783
15784 /**
15785  * g_hook_list_invoke_check:
15786  * @hook_list: a #GHookList
15787  * @may_recurse: %TRUE if functions which are already running (e.g. in another thread) can be called. If set to %FALSE, these are skipped
15788  *
15789  * Calls all of the #GHook functions in a #GHookList.
15790  * Any function which returns %FALSE is removed from the #GHookList.
15791  */
15792
15793
15794 /**
15795  * g_hook_list_marshal:
15796  * @hook_list: a #GHookList
15797  * @may_recurse: %TRUE if hooks which are currently running (e.g. in another thread) are considered valid. If set to %FALSE, these are skipped
15798  * @marshaller: the function to call for each #GHook
15799  * @marshal_data: data to pass to @marshaller
15800  *
15801  * Calls a function on each valid #GHook.
15802  */
15803
15804
15805 /**
15806  * g_hook_list_marshal_check:
15807  * @hook_list: a #GHookList
15808  * @may_recurse: %TRUE if hooks which are currently running (e.g. in another thread) are considered valid. If set to %FALSE, these are skipped
15809  * @marshaller: the function to call for each #GHook
15810  * @marshal_data: data to pass to @marshaller
15811  *
15812  * Calls a function on each valid #GHook and destroys it if the
15813  * function returns %FALSE.
15814  */
15815
15816
15817 /**
15818  * g_hook_next_valid:
15819  * @hook_list: a #GHookList
15820  * @hook: the current #GHook
15821  * @may_be_in_call: %TRUE if hooks which are currently running (e.g. in another thread) are considered valid. If set to %FALSE, these are skipped
15822  *
15823  * Returns the next #GHook in a #GHookList which has not been destroyed.
15824  * The reference count for the #GHook is incremented, so you must call
15825  * g_hook_unref() to restore it when no longer needed. (Or continue to call
15826  * g_hook_next_valid() until %NULL is returned.)
15827  *
15828  * Returns: the next valid #GHook, or %NULL if none are valid
15829  */
15830
15831
15832 /**
15833  * g_hook_prepend:
15834  * @hook_list: a #GHookList
15835  * @hook: the #GHook to add to the start of @hook_list
15836  *
15837  * Prepends a #GHook on the start of a #GHookList.
15838  */
15839
15840
15841 /**
15842  * g_hook_ref:
15843  * @hook_list: a #GHookList
15844  * @hook: the #GHook to increment the reference count of
15845  *
15846  * Increments the reference count for a #GHook.
15847  *
15848  * Returns: the @hook that was passed in (since 2.6)
15849  */
15850
15851
15852 /**
15853  * g_hook_unref:
15854  * @hook_list: a #GHookList
15855  * @hook: the #GHook to unref
15856  *
15857  * Decrements the reference count of a #GHook.
15858  * If the reference count falls to 0, the #GHook is removed
15859  * from the #GHookList and g_hook_free() is called to free it.
15860  */
15861
15862
15863 /**
15864  * g_hostname_is_ascii_encoded:
15865  * @hostname: a hostname
15866  *
15867  * Tests if @hostname contains segments with an ASCII-compatible
15868  * encoding of an Internationalized Domain Name. If this returns
15869  * %TRUE, you should decode the hostname with g_hostname_to_unicode()
15870  * before displaying it to the user.
15871  *
15872  * Note that a hostname might contain a mix of encoded and unencoded
15873  * segments, and so it is possible for g_hostname_is_non_ascii() and
15874  * g_hostname_is_ascii_encoded() to both return %TRUE for a name.
15875  *
15876  * Returns: %TRUE if @hostname contains any ASCII-encoded segments.
15877  * Since: 2.22
15878  */
15879
15880
15881 /**
15882  * g_hostname_is_ip_address:
15883  * @hostname: a hostname (or IP address in string form)
15884  *
15885  * Tests if @hostname is the string form of an IPv4 or IPv6 address.
15886  * (Eg, "192.168.0.1".)
15887  *
15888  * Returns: %TRUE if @hostname is an IP address
15889  * Since: 2.22
15890  */
15891
15892
15893 /**
15894  * g_hostname_is_non_ascii:
15895  * @hostname: a hostname
15896  *
15897  * Tests if @hostname contains Unicode characters. If this returns
15898  * %TRUE, you need to encode the hostname with g_hostname_to_ascii()
15899  * before using it in non-IDN-aware contexts.
15900  *
15901  * Note that a hostname might contain a mix of encoded and unencoded
15902  * segments, and so it is possible for g_hostname_is_non_ascii() and
15903  * g_hostname_is_ascii_encoded() to both return %TRUE for a name.
15904  *
15905  * Returns: %TRUE if @hostname contains any non-ASCII characters
15906  * Since: 2.22
15907  */
15908
15909
15910 /**
15911  * g_hostname_to_ascii:
15912  * @hostname: a valid UTF-8 or ASCII hostname
15913  *
15914  * Converts @hostname to its canonical ASCII form; an ASCII-only
15915  * string containing no uppercase letters and not ending with a
15916  * trailing dot.
15917  *
15918  * Returns: an ASCII hostname, which must be freed, or %NULL if @hostname is in some way invalid.
15919  * Since: 2.22
15920  */
15921
15922
15923 /**
15924  * g_hostname_to_unicode:
15925  * @hostname: a valid UTF-8 or ASCII hostname
15926  *
15927  * Converts @hostname to its canonical presentation form; a UTF-8
15928  * string in Unicode normalization form C, containing no uppercase
15929  * letters, no forbidden characters, and no ASCII-encoded segments,
15930  * and not ending with a trailing dot.
15931  *
15932  * Of course if @hostname is not an internationalized hostname, then
15933  * the canonical presentation form will be entirely ASCII.
15934  *
15935  * Returns: a UTF-8 hostname, which must be freed, or %NULL if @hostname is in some way invalid.
15936  * Since: 2.22
15937  */
15938
15939
15940 /**
15941  * g_htonl:
15942  * @val: a 32-bit integer value in host byte order
15943  *
15944  * Converts a 32-bit integer value from host to network byte order.
15945  *
15946  * Returns: @val converted to network byte order
15947  */
15948
15949
15950 /**
15951  * g_htons:
15952  * @val: a 16-bit integer value in host byte order
15953  *
15954  * Converts a 16-bit integer value from host to network byte order.
15955  *
15956  * Returns: @val converted to network byte order
15957  */
15958
15959
15960 /**
15961  * g_iconv:
15962  * @converter: conversion descriptor from g_iconv_open()
15963  * @inbuf: bytes to convert
15964  * @inbytes_left: inout parameter, bytes remaining to convert in @inbuf
15965  * @outbuf: converted output bytes
15966  * @outbytes_left: inout parameter, bytes available to fill in @outbuf
15967  *
15968  * Same as the standard UNIX routine iconv(), but
15969  * may be implemented via libiconv on UNIX flavors that lack
15970  * a native implementation.
15971  *
15972  * GLib provides g_convert() and g_locale_to_utf8() which are likely
15973  * more convenient than the raw iconv wrappers.
15974  *
15975  * Returns: count of non-reversible conversions, or -1 on error
15976  */
15977
15978
15979 /**
15980  * g_iconv_close:
15981  * @converter: a conversion descriptor from g_iconv_open()
15982  *
15983  * Same as the standard UNIX routine iconv_close(), but
15984  * may be implemented via libiconv on UNIX flavors that lack
15985  * a native implementation. Should be called to clean up
15986  * the conversion descriptor from g_iconv_open() when
15987  * you are done converting things.
15988  *
15989  * GLib provides g_convert() and g_locale_to_utf8() which are likely
15990  * more convenient than the raw iconv wrappers.
15991  *
15992  * Returns: -1 on error, 0 on success
15993  */
15994
15995
15996 /**
15997  * g_iconv_open:
15998  * @to_codeset: destination codeset
15999  * @from_codeset: source codeset
16000  *
16001  * Same as the standard UNIX routine iconv_open(), but
16002  * may be implemented via libiconv on UNIX flavors that lack
16003  * a native implementation.
16004  *
16005  * GLib provides g_convert() and g_locale_to_utf8() which are likely
16006  * more convenient than the raw iconv wrappers.
16007  *
16008  * Returns: a "conversion descriptor", or (GIConv)-1 if opening the converter failed.
16009  */
16010
16011
16012 /**
16013  * g_idle_add:
16014  * @function: function to call
16015  * @data: data to pass to @function.
16016  *
16017  * Adds a function to be called whenever there are no higher priority
16018  * events pending to the default main loop. The function is given the
16019  * default idle priority, #G_PRIORITY_DEFAULT_IDLE.  If the function
16020  * returns %FALSE it is automatically removed from the list of event
16021  * sources and will not be called again.
16022  *
16023  * This internally creates a main loop source using g_idle_source_new()
16024  * and attaches it to the main loop context using g_source_attach().
16025  * You can do these steps manually if you need greater control.
16026  *
16027  * Returns: the ID (greater than 0) of the event source.
16028  */
16029
16030
16031 /**
16032  * g_idle_add_full:
16033  * @priority: the priority of the idle source. Typically this will be in the range between #G_PRIORITY_DEFAULT_IDLE and #G_PRIORITY_HIGH_IDLE.
16034  * @function: function to call
16035  * @data: data to pass to @function
16036  * @notify: (allow-none): function to call when the idle is removed, or %NULL
16037  *
16038  * Adds a function to be called whenever there are no higher priority
16039  * events pending.  If the function returns %FALSE it is automatically
16040  * removed from the list of event sources and will not be called again.
16041  *
16042  * This internally creates a main loop source using g_idle_source_new()
16043  * and attaches it to the main loop context using g_source_attach().
16044  * You can do these steps manually if you need greater control.
16045  *
16046  * Returns: the ID (greater than 0) of the event source.
16047  * Rename to: g_idle_add
16048  */
16049
16050
16051 /**
16052  * g_idle_remove_by_data:
16053  * @data: the data for the idle source's callback.
16054  *
16055  * Removes the idle function with the given data.
16056  *
16057  * Returns: %TRUE if an idle source was found and removed.
16058  */
16059
16060
16061 /**
16062  * g_idle_source_new:
16063  *
16064  * Creates a new idle source.
16065  *
16066  * The source will not initially be associated with any #GMainContext
16067  * and must be added to one with g_source_attach() before it will be
16068  * executed. Note that the default priority for idle sources is
16069  * %G_PRIORITY_DEFAULT_IDLE, as compared to other sources which
16070  * have a default priority of %G_PRIORITY_DEFAULT.
16071  *
16072  * Returns: the newly-created idle source
16073  */
16074
16075
16076 /**
16077  * g_int64_equal:
16078  * @v1: a pointer to a #gint64 key
16079  * @v2: a pointer to a #gint64 key to compare with @v1
16080  *
16081  * Compares the two #gint64 values being pointed to and returns
16082  * %TRUE if they are equal.
16083  * It can be passed to g_hash_table_new() as the @key_equal_func
16084  * parameter, when using non-%NULL pointers to 64-bit integers as keys in a
16085  * #GHashTable.
16086  *
16087  * Returns: %TRUE if the two keys match.
16088  * Since: 2.22
16089  */
16090
16091
16092 /**
16093  * g_int64_hash:
16094  * @v: a pointer to a #gint64 key
16095  *
16096  * Converts a pointer to a #gint64 to a hash value.
16097  *
16098  * It can be passed to g_hash_table_new() as the @hash_func parameter,
16099  * when using non-%NULL pointers to 64-bit integer values as keys in a
16100  * #GHashTable.
16101  *
16102  * Returns: a hash value corresponding to the key.
16103  * Since: 2.22
16104  */
16105
16106
16107 /**
16108  * g_int_equal:
16109  * @v1: a pointer to a #gint key
16110  * @v2: a pointer to a #gint key to compare with @v1
16111  *
16112  * Compares the two #gint values being pointed to and returns
16113  * %TRUE if they are equal.
16114  * It can be passed to g_hash_table_new() as the @key_equal_func
16115  * parameter, when using non-%NULL pointers to integers as keys in a
16116  * #GHashTable.
16117  *
16118  * Note that this function acts on pointers to #gint, not on #gint directly:
16119  * if your hash table's keys are of the form
16120  * <literal>GINT_TO_POINTER (n)</literal>, use g_direct_equal() instead.
16121  *
16122  * Returns: %TRUE if the two keys match.
16123  */
16124
16125
16126 /**
16127  * g_int_hash:
16128  * @v: a pointer to a #gint key
16129  *
16130  * Converts a pointer to a #gint to a hash value.
16131  * It can be passed to g_hash_table_new() as the @hash_func parameter,
16132  * when using non-%NULL pointers to integer values as keys in a #GHashTable.
16133  *
16134  * Note that this function acts on pointers to #gint, not on #gint directly:
16135  * if your hash table's keys are of the form
16136  * <literal>GINT_TO_POINTER (n)</literal>, use g_direct_hash() instead.
16137  *
16138  * Returns: a hash value corresponding to the key.
16139  */
16140
16141
16142 /**
16143  * g_intern_static_string:
16144  * @string: (allow-none): a static string
16145  *
16146  * Returns a canonical representation for @string. Interned strings
16147  * can be compared for equality by comparing the pointers, instead of
16148  * using strcmp(). g_intern_static_string() does not copy the string,
16149  * therefore @string must not be freed or modified.
16150  *
16151  * Returns: a canonical representation for the string
16152  * Since: 2.10
16153  */
16154
16155
16156 /**
16157  * g_intern_string:
16158  * @string: (allow-none): a string
16159  *
16160  * Returns a canonical representation for @string. Interned strings
16161  * can be compared for equality by comparing the pointers, instead of
16162  * using strcmp().
16163  *
16164  * Returns: a canonical representation for the string
16165  * Since: 2.10
16166  */
16167
16168
16169 /**
16170  * g_io_add_watch:
16171  * @channel: a #GIOChannel
16172  * @condition: the condition to watch for
16173  * @func: the function to call when the condition is satisfied
16174  * @user_data: user data to pass to @func
16175  *
16176  * Adds the #GIOChannel into the default main loop context
16177  * with the default priority.
16178  *
16179  * Returns: the event source id
16180  */
16181
16182
16183 /**
16184  * g_io_add_watch_full:
16185  * @channel: a #GIOChannel
16186  * @priority: the priority of the #GIOChannel source
16187  * @condition: the condition to watch for
16188  * @func: the function to call when the condition is satisfied
16189  * @user_data: user data to pass to @func
16190  * @notify: the function to call when the source is removed
16191  *
16192  * Adds the #GIOChannel into the default main loop context
16193  * with the given priority.
16194  *
16195  * This internally creates a main loop source using g_io_create_watch()
16196  * and attaches it to the main loop context with g_source_attach().
16197  * You can do these steps manually if you need greater control.
16198  *
16199  * Returns: the event source id
16200  * Rename to: g_io_add_watch
16201  */
16202
16203
16204 /**
16205  * g_io_channel_close:
16206  * @channel: A #GIOChannel
16207  *
16208  * Close an IO channel. Any pending data to be written will be
16209  * flushed, ignoring errors. The channel will not be freed until the
16210  * last reference is dropped using g_io_channel_unref().
16211  *
16212  * Deprecated: 2.2: Use g_io_channel_shutdown() instead.
16213  */
16214
16215
16216 /**
16217  * g_io_channel_error_from_errno:
16218  * @en: an <literal>errno</literal> error number, e.g. <literal>EINVAL</literal>
16219  *
16220  * Converts an <literal>errno</literal> error number to a #GIOChannelError.
16221  *
16222  * Returns: a #GIOChannelError error number, e.g. %G_IO_CHANNEL_ERROR_INVAL.
16223  */
16224
16225
16226 /**
16227  * g_io_channel_error_quark:
16228  *
16229  * Returns: the quark used as %G_IO_CHANNEL_ERROR
16230  */
16231
16232
16233 /**
16234  * g_io_channel_flush:
16235  * @channel: a #GIOChannel
16236  * @error: location to store an error of type #GIOChannelError
16237  *
16238  * Flushes the write buffer for the GIOChannel.
16239  *
16240  * Returns: the status of the operation: One of #G_IO_STATUS_NORMAL, #G_IO_STATUS_AGAIN, or #G_IO_STATUS_ERROR.
16241  */
16242
16243
16244 /**
16245  * g_io_channel_get_buffer_condition:
16246  * @channel: A #GIOChannel
16247  *
16248  * This function returns a #GIOCondition depending on whether there
16249  * is data to be read/space to write data in the internal buffers in
16250  * the #GIOChannel. Only the flags %G_IO_IN and %G_IO_OUT may be set.
16251  *
16252  * Returns: A #GIOCondition
16253  */
16254
16255
16256 /**
16257  * g_io_channel_get_buffer_size:
16258  * @channel: a #GIOChannel
16259  *
16260  * Gets the buffer size.
16261  *
16262  * Returns: the size of the buffer.
16263  */
16264
16265
16266 /**
16267  * g_io_channel_get_buffered:
16268  * @channel: a #GIOChannel
16269  *
16270  * Returns whether @channel is buffered.
16271  *
16272  * Returns: %TRUE if the @channel is buffered.
16273  */
16274
16275
16276 /**
16277  * g_io_channel_get_close_on_unref:
16278  * @channel: a #GIOChannel.
16279  *
16280  * Returns whether the file/socket/whatever associated with @channel
16281  * will be closed when @channel receives its final unref and is
16282  * destroyed. The default value of this is %TRUE for channels created
16283  * by g_io_channel_new_file (), and %FALSE for all other channels.
16284  *
16285  * Returns: Whether the channel will be closed on the final unref of the GIOChannel data structure.
16286  */
16287
16288
16289 /**
16290  * g_io_channel_get_encoding:
16291  * @channel: a #GIOChannel
16292  *
16293  * Gets the encoding for the input/output of the channel.
16294  * The internal encoding is always UTF-8. The encoding %NULL
16295  * makes the channel safe for binary data.
16296  *
16297  * Returns: A string containing the encoding, this string is owned by GLib and must not be freed.
16298  */
16299
16300
16301 /**
16302  * g_io_channel_get_flags:
16303  * @channel: a #GIOChannel
16304  *
16305  * Gets the current flags for a #GIOChannel, including read-only
16306  * flags such as %G_IO_FLAG_IS_READABLE.
16307  *
16308  * The values of the flags %G_IO_FLAG_IS_READABLE and %G_IO_FLAG_IS_WRITABLE
16309  * are cached for internal use by the channel when it is created.
16310  * If they should change at some later point (e.g. partial shutdown
16311  * of a socket with the UNIX shutdown() function), the user
16312  * should immediately call g_io_channel_get_flags() to update
16313  * the internal values of these flags.
16314  *
16315  * Returns: the flags which are set on the channel
16316  */
16317
16318
16319 /**
16320  * g_io_channel_get_line_term:
16321  * @channel: a #GIOChannel
16322  * @length: a location to return the length of the line terminator
16323  *
16324  * This returns the string that #GIOChannel uses to determine
16325  * where in the file a line break occurs. A value of %NULL
16326  * indicates autodetection.
16327  *
16328  * Returns: The line termination string. This value is owned by GLib and must not be freed.
16329  */
16330
16331
16332 /**
16333  * g_io_channel_init:
16334  * @channel: a #GIOChannel
16335  *
16336  * Initializes a #GIOChannel struct.
16337  *
16338  * This is called by each of the above functions when creating a
16339  * #GIOChannel, and so is not often needed by the application
16340  * programmer (unless you are creating a new type of #GIOChannel).
16341  */
16342
16343
16344 /**
16345  * g_io_channel_new_file:
16346  * @filename: A string containing the name of a file
16347  * @mode: One of "r", "w", "a", "r+", "w+", "a+". These have the same meaning as in fopen()
16348  * @error: A location to return an error of type %G_FILE_ERROR
16349  *
16350  * Open a file @filename as a #GIOChannel using mode @mode. This
16351  * channel will be closed when the last reference to it is dropped,
16352  * so there is no need to call g_io_channel_close() (though doing
16353  * so will not cause problems, as long as no attempt is made to
16354  * access the channel after it is closed).
16355  *
16356  * Returns: A #GIOChannel on success, %NULL on failure.
16357  */
16358
16359
16360 /**
16361  * g_io_channel_read:
16362  * @channel: a #GIOChannel
16363  * @buf: a buffer to read the data into (which should be at least count bytes long)
16364  * @count: the number of bytes to read from the #GIOChannel
16365  * @bytes_read: returns the number of bytes actually read
16366  *
16367  * Reads data from a #GIOChannel.
16368  *
16369  * Returns: %G_IO_ERROR_NONE if the operation was successful.
16370  * Deprecated: 2.2: Use g_io_channel_read_chars() instead.
16371  */
16372
16373
16374 /**
16375  * g_io_channel_read_chars:
16376  * @channel: a #GIOChannel
16377  * @buf: (out caller-allocates) (array length=count) (element-type guint8): a buffer to read data into
16378  * @count: (in): the size of the buffer. Note that the buffer may not be complelely filled even if there is data in the buffer if the remaining data is not a complete character.
16379  * @bytes_read: (allow-none) (out): The number of bytes read. This may be zero even on success if count < 6 and the channel's encoding is non-%NULL. This indicates that the next UTF-8 character is too wide for the buffer.
16380  * @error: a location to return an error of type #GConvertError or #GIOChannelError.
16381  *
16382  * Replacement for g_io_channel_read() with the new API.
16383  *
16384  * Returns: the status of the operation.
16385  */
16386
16387
16388 /**
16389  * g_io_channel_read_line:
16390  * @channel: a #GIOChannel
16391  * @str_return: (out): The line read from the #GIOChannel, including the line terminator. This data should be freed with g_free() when no longer needed. This is a nul-terminated string. If a @length of zero is returned, this will be %NULL instead.
16392  * @length: (allow-none) (out): location to store length of the read data, or %NULL
16393  * @terminator_pos: (allow-none) (out): location to store position of line terminator, or %NULL
16394  * @error: A location to return an error of type #GConvertError or #GIOChannelError
16395  *
16396  * Reads a line, including the terminating character(s),
16397  * from a #GIOChannel into a newly-allocated string.
16398  * @str_return will contain allocated memory if the return
16399  * is %G_IO_STATUS_NORMAL.
16400  *
16401  * Returns: the status of the operation.
16402  */
16403
16404
16405 /**
16406  * g_io_channel_read_line_string:
16407  * @channel: a #GIOChannel
16408  * @buffer: a #GString into which the line will be written. If @buffer already contains data, the old data will be overwritten.
16409  * @terminator_pos: (allow-none): location to store position of line terminator, or %NULL
16410  * @error: a location to store an error of type #GConvertError or #GIOChannelError
16411  *
16412  * Reads a line from a #GIOChannel, using a #GString as a buffer.
16413  *
16414  * Returns: the status of the operation.
16415  */
16416
16417
16418 /**
16419  * g_io_channel_read_to_end:
16420  * @channel: a #GIOChannel
16421  * @str_return: (out) (array length=length) (element-type guint8): Location to store a pointer to a string holding the remaining data in the #GIOChannel. This data should be freed with g_free() when no longer needed. This data is terminated by an extra nul character, but there may be other nuls in the intervening data.
16422  * @length: (out): location to store length of the data
16423  * @error: location to return an error of type #GConvertError or #GIOChannelError
16424  *
16425  * Reads all the remaining data from the file.
16426  *
16427  * Returns: %G_IO_STATUS_NORMAL on success. This function never returns %G_IO_STATUS_EOF.
16428  */
16429
16430
16431 /**
16432  * g_io_channel_read_unichar:
16433  * @channel: a #GIOChannel
16434  * @thechar: (out): a location to return a character
16435  * @error: a location to return an error of type #GConvertError or #GIOChannelError
16436  *
16437  * Reads a Unicode character from @channel.
16438  * This function cannot be called on a channel with %NULL encoding.
16439  *
16440  * Returns: a #GIOStatus
16441  */
16442
16443
16444 /**
16445  * g_io_channel_ref:
16446  * @channel: a #GIOChannel
16447  *
16448  * Increments the reference count of a #GIOChannel.
16449  *
16450  * Returns: the @channel that was passed in (since 2.6)
16451  */
16452
16453
16454 /**
16455  * g_io_channel_seek:
16456  * @channel: a #GIOChannel
16457  * @offset: an offset, in bytes, which is added to the position specified by @type
16458  * @type: the position in the file, which can be %G_SEEK_CUR (the current position), %G_SEEK_SET (the start of the file), or %G_SEEK_END (the end of the file)
16459  *
16460  * Sets the current position in the #GIOChannel, similar to the standard
16461  * library function fseek().
16462  *
16463  * Returns: %G_IO_ERROR_NONE if the operation was successful.
16464  * Deprecated: 2.2: Use g_io_channel_seek_position() instead.
16465  */
16466
16467
16468 /**
16469  * g_io_channel_seek_position:
16470  * @channel: a #GIOChannel
16471  * @offset: The offset in bytes from the position specified by @type
16472  * @type: a #GSeekType. The type %G_SEEK_CUR is only allowed in those cases where a call to g_io_channel_set_encoding () is allowed. See the documentation for g_io_channel_set_encoding () for details.
16473  * @error: A location to return an error of type #GIOChannelError
16474  *
16475  * Replacement for g_io_channel_seek() with the new API.
16476  *
16477  * Returns: the status of the operation.
16478  */
16479
16480
16481 /**
16482  * g_io_channel_set_buffer_size:
16483  * @channel: a #GIOChannel
16484  * @size: the size of the buffer, or 0 to let GLib pick a good size
16485  *
16486  * Sets the buffer size.
16487  */
16488
16489
16490 /**
16491  * g_io_channel_set_buffered:
16492  * @channel: a #GIOChannel
16493  * @buffered: whether to set the channel buffered or unbuffered
16494  *
16495  * The buffering state can only be set if the channel's encoding
16496  * is %NULL. For any other encoding, the channel must be buffered.
16497  *
16498  * A buffered channel can only be set unbuffered if the channel's
16499  * internal buffers have been flushed. Newly created channels or
16500  * channels which have returned %G_IO_STATUS_EOF
16501  * not require such a flush. For write-only channels, a call to
16502  * g_io_channel_flush () is sufficient. For all other channels,
16503  * the buffers may be flushed by a call to g_io_channel_seek_position ().
16504  * This includes the possibility of seeking with seek type %G_SEEK_CUR
16505  * and an offset of zero. Note that this means that socket-based
16506  * channels cannot be set unbuffered once they have had data
16507  * read from them.
16508  *
16509  * On unbuffered channels, it is safe to mix read and write
16510  * calls from the new and old APIs, if this is necessary for
16511  * maintaining old code.
16512  *
16513  * The default state of the channel is buffered.
16514  */
16515
16516
16517 /**
16518  * g_io_channel_set_close_on_unref:
16519  * @channel: a #GIOChannel
16520  * @do_close: Whether to close the channel on the final unref of the GIOChannel data structure. The default value of this is %TRUE for channels created by g_io_channel_new_file (), and %FALSE for all other channels.
16521  *
16522  * Setting this flag to %TRUE for a channel you have already closed
16523  * can cause problems.
16524  */
16525
16526
16527 /**
16528  * g_io_channel_set_encoding:
16529  * @channel: a #GIOChannel
16530  * @encoding: (allow-none): the encoding type
16531  * @error: location to store an error of type #GConvertError
16532  *
16533  * Sets the encoding for the input/output of the channel.
16534  * The internal encoding is always UTF-8. The default encoding
16535  * for the external file is UTF-8.
16536  *
16537  * The encoding %NULL is safe to use with binary data.
16538  *
16539  * The encoding can only be set if one of the following conditions
16540  * is true:
16541  * <itemizedlist>
16542  * <listitem><para>
16543  *    The channel was just created, and has not been written to or read
16544  *    from yet.
16545  * </para></listitem>
16546  * <listitem><para>
16547  *    The channel is write-only.
16548  * </para></listitem>
16549  * <listitem><para>
16550  *    The channel is a file, and the file pointer was just
16551  *    repositioned by a call to g_io_channel_seek_position().
16552  *    (This flushes all the internal buffers.)
16553  * </para></listitem>
16554  * <listitem><para>
16555  *    The current encoding is %NULL or UTF-8.
16556  * </para></listitem>
16557  * <listitem><para>
16558  *    One of the (new API) read functions has just returned %G_IO_STATUS_EOF
16559  *    (or, in the case of g_io_channel_read_to_end(), %G_IO_STATUS_NORMAL).
16560  * </para></listitem>
16561  * <listitem><para>
16562  *    One of the functions g_io_channel_read_chars() or
16563  *    g_io_channel_read_unichar() has returned %G_IO_STATUS_AGAIN or
16564  *    %G_IO_STATUS_ERROR. This may be useful in the case of
16565  *    %G_CONVERT_ERROR_ILLEGAL_SEQUENCE.
16566  *    Returning one of these statuses from g_io_channel_read_line(),
16567  *    g_io_channel_read_line_string(), or g_io_channel_read_to_end()
16568  *    does <emphasis>not</emphasis> guarantee that the encoding can
16569  *    be changed.
16570  * </para></listitem>
16571  * </itemizedlist>
16572  * Channels which do not meet one of the above conditions cannot call
16573  * g_io_channel_seek_position() with an offset of %G_SEEK_CUR, and, if
16574  * they are "seekable", cannot call g_io_channel_write_chars() after
16575  * calling one of the API "read" functions.
16576  *
16577  * Returns: %G_IO_STATUS_NORMAL if the encoding was successfully set.
16578  */
16579
16580
16581 /**
16582  * g_io_channel_set_flags:
16583  * @channel: a #GIOChannel
16584  * @flags: the flags to set on the IO channel
16585  * @error: A location to return an error of type #GIOChannelError
16586  *
16587  * Sets the (writeable) flags in @channel to (@flags & %G_IO_FLAG_SET_MASK).
16588  *
16589  * Returns: the status of the operation.
16590  */
16591
16592
16593 /**
16594  * g_io_channel_set_line_term:
16595  * @channel: a #GIOChannel
16596  * @line_term: (allow-none): The line termination string. Use %NULL for autodetect.  Autodetection breaks on "\n", "\r\n", "\r", "\0", and the Unicode paragraph separator. Autodetection should not be used for anything other than file-based channels.
16597  * @length: The length of the termination string. If -1 is passed, the string is assumed to be nul-terminated. This option allows termination strings with embedded nuls.
16598  *
16599  * This sets the string that #GIOChannel uses to determine
16600  * where in the file a line break occurs.
16601  */
16602
16603
16604 /**
16605  * g_io_channel_shutdown:
16606  * @channel: a #GIOChannel
16607  * @flush: if %TRUE, flush pending
16608  * @err: location to store a #GIOChannelError
16609  *
16610  * Close an IO channel. Any pending data to be written will be
16611  * flushed if @flush is %TRUE. The channel will not be freed until the
16612  * last reference is dropped using g_io_channel_unref().
16613  *
16614  * Returns: the status of the operation.
16615  */
16616
16617
16618 /**
16619  * g_io_channel_unix_get_fd:
16620  * @channel: a #GIOChannel, created with g_io_channel_unix_new().
16621  *
16622  * Returns the file descriptor of the #GIOChannel.
16623  *
16624  * On Windows this function returns the file descriptor or socket of
16625  * the #GIOChannel.
16626  *
16627  * Returns: the file descriptor of the #GIOChannel.
16628  */
16629
16630
16631 /**
16632  * g_io_channel_unix_new:
16633  * @fd: a file descriptor.
16634  *
16635  * Creates a new #GIOChannel given a file descriptor. On UNIX systems
16636  * this works for plain files, pipes, and sockets.
16637  *
16638  * The returned #GIOChannel has a reference count of 1.
16639  *
16640  * The default encoding for #GIOChannel is UTF-8. If your application
16641  * is reading output from a command using via pipe, you may need to set
16642  * the encoding to the encoding of the current locale (see
16643  * g_get_charset()) with the g_io_channel_set_encoding() function.
16644  *
16645  * If you want to read raw binary data without interpretation, then
16646  * call the g_io_channel_set_encoding() function with %NULL for the
16647  * encoding argument.
16648  *
16649  * This function is available in GLib on Windows, too, but you should
16650  * avoid using it on Windows. The domain of file descriptors and
16651  * sockets overlap. There is no way for GLib to know which one you mean
16652  * in case the argument you pass to this function happens to be both a
16653  * valid file descriptor and socket. If that happens a warning is
16654  * issued, and GLib assumes that it is the file descriptor you mean.
16655  *
16656  * Returns: a new #GIOChannel.
16657  */
16658
16659
16660 /**
16661  * g_io_channel_unref:
16662  * @channel: a #GIOChannel
16663  *
16664  * Decrements the reference count of a #GIOChannel.
16665  */
16666
16667
16668 /**
16669  * g_io_channel_win32_new_fd:
16670  * @fd: a C library file descriptor.
16671  *
16672  * Creates a new #GIOChannel given a file descriptor on Windows. This
16673  * works for file descriptors from the C runtime.
16674  *
16675  * This function works for file descriptors as returned by the open(),
16676  * creat(), pipe() and fileno() calls in the Microsoft C runtime. In
16677  * order to meaningfully use this function your code should use the
16678  * same C runtime as GLib uses, which is msvcrt.dll. Note that in
16679  * current Microsoft compilers it is near impossible to convince it to
16680  * build code that would use msvcrt.dll. The last Microsoft compiler
16681  * version that supported using msvcrt.dll as the C runtime was version
16682  * 6. The GNU compiler and toolchain for Windows, also known as Mingw,
16683  * fully supports msvcrt.dll.
16684  *
16685  * If you have created a #GIOChannel for a file descriptor and started
16686  * watching (polling) it, you shouldn't call read() on the file
16687  * descriptor. This is because adding polling for a file descriptor is
16688  * implemented in GLib on Windows by starting a thread that sits
16689  * blocked in a read() from the file descriptor most of the time. All
16690  * reads from the file descriptor should be done by this internal GLib
16691  * thread. Your code should call only g_io_channel_read().
16692  *
16693  * This function is available only in GLib on Windows.
16694  *
16695  * Returns: a new #GIOChannel.
16696  */
16697
16698
16699 /**
16700  * g_io_channel_win32_new_messages:
16701  * @hwnd: a window handle.
16702  *
16703  * Creates a new #GIOChannel given a window handle on Windows.
16704  *
16705  * This function creates a #GIOChannel that can be used to poll for
16706  * Windows messages for the window in question.
16707  *
16708  * Returns: a new #GIOChannel.
16709  */
16710
16711
16712 /**
16713  * g_io_channel_win32_new_socket:
16714  * @socket: a Winsock socket
16715  *
16716  * Creates a new #GIOChannel given a socket on Windows.
16717  *
16718  * This function works for sockets created by Winsock. It's available
16719  * only in GLib on Windows.
16720  *
16721  * Polling a #GSource created to watch a channel for a socket puts the
16722  * socket in non-blocking mode. This is a side-effect of the
16723  * implementation and unavoidable.
16724  *
16725  * Returns: a new #GIOChannel
16726  */
16727
16728
16729 /**
16730  * g_io_channel_write:
16731  * @channel: a #GIOChannel
16732  * @buf: the buffer containing the data to write
16733  * @count: the number of bytes to write
16734  * @bytes_written: the number of bytes actually written
16735  *
16736  * Writes data to a #GIOChannel.
16737  *
16738  * Returns: %G_IO_ERROR_NONE if the operation was successful.
16739  * Deprecated: 2.2: Use g_io_channel_write_chars() instead.
16740  */
16741
16742
16743 /**
16744  * g_io_channel_write_chars:
16745  * @channel: a #GIOChannel
16746  * @buf: (array) (element-type guint8): a buffer to write data from
16747  * @count: the size of the buffer. If -1, the buffer is taken to be a nul-terminated string.
16748  * @bytes_written: (out): The number of bytes written. This can be nonzero even if the return value is not %G_IO_STATUS_NORMAL. If the return value is %G_IO_STATUS_NORMAL and the channel is blocking, this will always be equal to @count if @count >= 0.
16749  * @error: a location to return an error of type #GConvertError or #GIOChannelError
16750  *
16751  * Replacement for g_io_channel_write() with the new API.
16752  *
16753  * On seekable channels with encodings other than %NULL or UTF-8, generic
16754  * mixing of reading and writing is not allowed. A call to g_io_channel_write_chars ()
16755  * may only be made on a channel from which data has been read in the
16756  * cases described in the documentation for g_io_channel_set_encoding ().
16757  *
16758  * Returns: the status of the operation.
16759  */
16760
16761
16762 /**
16763  * g_io_channel_write_unichar:
16764  * @channel: a #GIOChannel
16765  * @thechar: a character
16766  * @error: location to return an error of type #GConvertError or #GIOChannelError
16767  *
16768  * Writes a Unicode character to @channel.
16769  * This function cannot be called on a channel with %NULL encoding.
16770  *
16771  * Returns: a #GIOStatus
16772  */
16773
16774
16775 /**
16776  * g_io_create_watch:
16777  * @channel: a #GIOChannel to watch
16778  * @condition: conditions to watch for
16779  *
16780  * Creates a #GSource that's dispatched when @condition is met for the
16781  * given @channel. For example, if condition is #G_IO_IN, the source will
16782  * be dispatched when there's data available for reading.
16783  *
16784  * g_io_add_watch() is a simpler interface to this same functionality, for
16785  * the case where you want to add the source to the default main loop context
16786  * at the default priority.
16787  *
16788  * On Windows, polling a #GSource created to watch a channel for a socket
16789  * puts the socket in non-blocking mode. This is a side-effect of the
16790  * implementation and unavoidable.
16791  *
16792  * Returns: a new #GSource
16793  */
16794
16795
16796 /**
16797  * g_key_file_free: (skip)
16798  * @key_file: a #GKeyFile
16799  *
16800  * Clears all keys and groups from @key_file, and decreases the
16801  * reference count by 1. If the reference count reaches zero,
16802  * frees the key file and all its allocated memory.
16803  *
16804  * Since: 2.6
16805  */
16806
16807
16808 /**
16809  * g_key_file_get_boolean:
16810  * @key_file: a #GKeyFile
16811  * @group_name: a group name
16812  * @key: a key
16813  * @error: return location for a #GError
16814  *
16815  * Returns the value associated with @key under @group_name as a
16816  * boolean.
16817  *
16818  * If @key cannot be found then %FALSE is returned and @error is set
16819  * to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the value
16820  * associated with @key cannot be interpreted as a boolean then %FALSE
16821  * is returned and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
16822  *
16823  * Returns: the value associated with the key as a boolean, or %FALSE if the key was not found or could not be parsed.
16824  * Since: 2.6
16825  */
16826
16827
16828 /**
16829  * g_key_file_get_boolean_list:
16830  * @key_file: a #GKeyFile
16831  * @group_name: a group name
16832  * @key: a key
16833  * @length: (out): the number of booleans returned
16834  * @error: return location for a #GError
16835  *
16836  * Returns the values associated with @key under @group_name as
16837  * booleans.
16838  *
16839  * If @key cannot be found then %NULL is returned and @error is set to
16840  * #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the values associated
16841  * with @key cannot be interpreted as booleans then %NULL is returned
16842  * and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
16843  *
16844  * Returns: (array length=length) (element-type gboolean) (transfer container): the values associated with the key as a list of booleans, or %NULL if the key was not found or could not be parsed. The returned list of booleans should be freed with g_free() when no longer needed.
16845  * Since: 2.6
16846  */
16847
16848
16849 /**
16850  * g_key_file_get_comment:
16851  * @key_file: a #GKeyFile
16852  * @group_name: (allow-none): a group name, or %NULL
16853  * @key: a key
16854  * @error: return location for a #GError
16855  *
16856  * Retrieves a comment above @key from @group_name.
16857  * If @key is %NULL then @comment will be read from above
16858  * @group_name. If both @key and @group_name are %NULL, then
16859  * @comment will be read from above the first group in the file.
16860  *
16861  * Returns: a comment that should be freed with g_free()
16862  * Since: 2.6
16863  */
16864
16865
16866 /**
16867  * g_key_file_get_double:
16868  * @key_file: a #GKeyFile
16869  * @group_name: a group name
16870  * @key: a key
16871  * @error: return location for a #GError
16872  *
16873  * Returns the value associated with @key under @group_name as a
16874  * double. If @group_name is %NULL, the start_group is used.
16875  *
16876  * If @key cannot be found then 0.0 is returned and @error is set to
16877  * #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the value associated
16878  * with @key cannot be interpreted as a double then 0.0 is returned
16879  * and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
16880  *
16881  * Returns: the value associated with the key as a double, or 0.0 if the key was not found or could not be parsed.
16882  * Since: 2.12
16883  */
16884
16885
16886 /**
16887  * g_key_file_get_double_list:
16888  * @key_file: a #GKeyFile
16889  * @group_name: a group name
16890  * @key: a key
16891  * @length: (out): the number of doubles returned
16892  * @error: return location for a #GError
16893  *
16894  * Returns the values associated with @key under @group_name as
16895  * doubles.
16896  *
16897  * If @key cannot be found then %NULL is returned and @error is set to
16898  * #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the values associated
16899  * with @key cannot be interpreted as doubles then %NULL is returned
16900  * and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
16901  *
16902  * Returns: (array length=length) (element-type gdouble) (transfer container): the values associated with the key as a list of doubles, or %NULL if the key was not found or could not be parsed. The returned list of doubles should be freed with g_free() when no longer needed.
16903  * Since: 2.12
16904  */
16905
16906
16907 /**
16908  * g_key_file_get_groups:
16909  * @key_file: a #GKeyFile
16910  * @length: (out) (allow-none): return location for the number of returned groups, or %NULL
16911  *
16912  * Returns all groups in the key file loaded with @key_file.
16913  * The array of returned groups will be %NULL-terminated, so
16914  * @length may optionally be %NULL.
16915  *
16916  * Returns: (array zero-terminated=1) (transfer full): a newly-allocated %NULL-terminated array of strings. Use g_strfreev() to free it.
16917  * Since: 2.6
16918  */
16919
16920
16921 /**
16922  * g_key_file_get_int64:
16923  * @key_file: a non-%NULL #GKeyFile
16924  * @group_name: a non-%NULL group name
16925  * @key: a non-%NULL key
16926  * @error: return location for a #GError
16927  *
16928  * Returns the value associated with @key under @group_name as a signed
16929  * 64-bit integer. This is similar to g_key_file_get_integer() but can return
16930  * 64-bit results without truncation.
16931  *
16932  * Returns: the value associated with the key as a signed 64-bit integer, or 0 if the key was not found or could not be parsed.
16933  * Since: 2.26
16934  */
16935
16936
16937 /**
16938  * g_key_file_get_integer:
16939  * @key_file: a #GKeyFile
16940  * @group_name: a group name
16941  * @key: a key
16942  * @error: return location for a #GError
16943  *
16944  * Returns the value associated with @key under @group_name as an
16945  * integer.
16946  *
16947  * If @key cannot be found then 0 is returned and @error is set to
16948  * #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the value associated
16949  * with @key cannot be interpreted as an integer then 0 is returned
16950  * and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
16951  *
16952  * Returns: the value associated with the key as an integer, or 0 if the key was not found or could not be parsed.
16953  * Since: 2.6
16954  */
16955
16956
16957 /**
16958  * g_key_file_get_integer_list:
16959  * @key_file: a #GKeyFile
16960  * @group_name: a group name
16961  * @key: a key
16962  * @length: (out): the number of integers returned
16963  * @error: return location for a #GError
16964  *
16965  * Returns the values associated with @key under @group_name as
16966  * integers.
16967  *
16968  * If @key cannot be found then %NULL is returned and @error is set to
16969  * #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the values associated
16970  * with @key cannot be interpreted as integers then %NULL is returned
16971  * and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
16972  *
16973  * Returns: (array length=length) (element-type gint) (transfer container): the values associated with the key as a list of integers, or %NULL if the key was not found or could not be parsed. The returned list of integers should be freed with g_free() when no longer needed.
16974  * Since: 2.6
16975  */
16976
16977
16978 /**
16979  * g_key_file_get_keys:
16980  * @key_file: a #GKeyFile
16981  * @group_name: a group name
16982  * @length: (out) (allow-none): return location for the number of keys returned, or %NULL
16983  * @error: return location for a #GError, or %NULL
16984  *
16985  * Returns all keys for the group name @group_name.  The array of
16986  * returned keys will be %NULL-terminated, so @length may
16987  * optionally be %NULL. In the event that the @group_name cannot
16988  * be found, %NULL is returned and @error is set to
16989  * #G_KEY_FILE_ERROR_GROUP_NOT_FOUND.
16990  *
16991  * Returns: (array zero-terminated=1) (transfer full): a newly-allocated %NULL-terminated array of strings. Use g_strfreev() to free it.
16992  * Since: 2.6
16993  */
16994
16995
16996 /**
16997  * g_key_file_get_locale_string:
16998  * @key_file: a #GKeyFile
16999  * @group_name: a group name
17000  * @key: a key
17001  * @locale: (allow-none): a locale identifier or %NULL
17002  * @error: return location for a #GError, or %NULL
17003  *
17004  * Returns the value associated with @key under @group_name
17005  * translated in the given @locale if available.  If @locale is
17006  * %NULL then the current locale is assumed.
17007  *
17008  * If @key cannot be found then %NULL is returned and @error is set
17009  * to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. If the value associated
17010  * with @key cannot be interpreted or no suitable translation can
17011  * be found then the untranslated value is returned.
17012  *
17013  * Returns: a newly allocated string or %NULL if the specified key cannot be found.
17014  * Since: 2.6
17015  */
17016
17017
17018 /**
17019  * g_key_file_get_locale_string_list:
17020  * @key_file: a #GKeyFile
17021  * @group_name: a group name
17022  * @key: a key
17023  * @locale: (allow-none): a locale identifier or %NULL
17024  * @length: (out) (allow-none): return location for the number of returned strings or %NULL
17025  * @error: return location for a #GError or %NULL
17026  *
17027  * Returns the values associated with @key under @group_name
17028  * translated in the given @locale if available.  If @locale is
17029  * %NULL then the current locale is assumed.
17030  *
17031  * If @key cannot be found then %NULL is returned and @error is set
17032  * to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. If the values associated
17033  * with @key cannot be interpreted or no suitable translations
17034  * can be found then the untranslated values are returned. The
17035  * returned array is %NULL-terminated, so @length may optionally
17036  * be %NULL.
17037  *
17038  * Returns: (array zero-terminated=1 length=length) (element-type utf8) (transfer full): a newly allocated %NULL-terminated string array or %NULL if the key isn't found. The string array should be freed with g_strfreev().
17039  * Since: 2.6
17040  */
17041
17042
17043 /**
17044  * g_key_file_get_start_group:
17045  * @key_file: a #GKeyFile
17046  *
17047  * Returns the name of the start group of the file.
17048  *
17049  * Returns: The start group of the key file.
17050  * Since: 2.6
17051  */
17052
17053
17054 /**
17055  * g_key_file_get_string:
17056  * @key_file: a #GKeyFile
17057  * @group_name: a group name
17058  * @key: a key
17059  * @error: return location for a #GError, or %NULL
17060  *
17061  * Returns the string value associated with @key under @group_name.
17062  * Unlike g_key_file_get_value(), this function handles escape sequences
17063  * like \s.
17064  *
17065  * In the event the key cannot be found, %NULL is returned and
17066  * @error is set to #G_KEY_FILE_ERROR_KEY_NOT_FOUND.  In the
17067  * event that the @group_name cannot be found, %NULL is returned
17068  * and @error is set to #G_KEY_FILE_ERROR_GROUP_NOT_FOUND.
17069  *
17070  * Returns: a newly allocated string or %NULL if the specified key cannot be found.
17071  * Since: 2.6
17072  */
17073
17074
17075 /**
17076  * g_key_file_get_string_list:
17077  * @key_file: a #GKeyFile
17078  * @group_name: a group name
17079  * @key: a key
17080  * @length: (out) (allow-none): return location for the number of returned strings, or %NULL
17081  * @error: return location for a #GError, or %NULL
17082  *
17083  * Returns the values associated with @key under @group_name.
17084  *
17085  * In the event the key cannot be found, %NULL is returned and
17086  * @error is set to #G_KEY_FILE_ERROR_KEY_NOT_FOUND.  In the
17087  * event that the @group_name cannot be found, %NULL is returned
17088  * and @error is set to #G_KEY_FILE_ERROR_GROUP_NOT_FOUND.
17089  *
17090  * Returns: (array zero-terminated=1 length=length) (element-type utf8) (transfer full): a %NULL-terminated string array or %NULL if the specified key cannot be found. The array should be freed with g_strfreev().
17091  * Since: 2.6
17092  */
17093
17094
17095 /**
17096  * g_key_file_get_uint64:
17097  * @key_file: a non-%NULL #GKeyFile
17098  * @group_name: a non-%NULL group name
17099  * @key: a non-%NULL key
17100  * @error: return location for a #GError
17101  *
17102  * Returns the value associated with @key under @group_name as an unsigned
17103  * 64-bit integer. This is similar to g_key_file_get_integer() but can return
17104  * large positive results without truncation.
17105  *
17106  * Returns: the value associated with the key as an unsigned 64-bit integer, or 0 if the key was not found or could not be parsed.
17107  * Since: 2.26
17108  */
17109
17110
17111 /**
17112  * g_key_file_get_value:
17113  * @key_file: a #GKeyFile
17114  * @group_name: a group name
17115  * @key: a key
17116  * @error: return location for a #GError, or %NULL
17117  *
17118  * Returns the raw value associated with @key under @group_name.
17119  * Use g_key_file_get_string() to retrieve an unescaped UTF-8 string.
17120  *
17121  * In the event the key cannot be found, %NULL is returned and
17122  * @error is set to #G_KEY_FILE_ERROR_KEY_NOT_FOUND.  In the
17123  * event that the @group_name cannot be found, %NULL is returned
17124  * and @error is set to #G_KEY_FILE_ERROR_GROUP_NOT_FOUND.
17125  *
17126  * Returns: a newly allocated string or %NULL if the specified key cannot be found.
17127  * Since: 2.6
17128  */
17129
17130
17131 /**
17132  * g_key_file_has_group:
17133  * @key_file: a #GKeyFile
17134  * @group_name: a group name
17135  *
17136  * Looks whether the key file has the group @group_name.
17137  *
17138  * Returns: %TRUE if @group_name is a part of @key_file, %FALSE otherwise.
17139  * Since: 2.6
17140  */
17141
17142
17143 /**
17144  * g_key_file_has_key: (skip)
17145  * @key_file: a #GKeyFile
17146  * @group_name: a group name
17147  * @key: a key name
17148  * @error: return location for a #GError
17149  *
17150  * Looks whether the key file has the key @key in the group
17151  * @group_name.
17152  *
17153  * <note>This function does not follow the rules for #GError strictly;
17154  * the return value both carries meaning and signals an error.  To use
17155  * this function, you must pass a #GError pointer in @error, and check
17156  * whether it is not %NULL to see if an error occurred.</note>
17157  *
17158  * Language bindings should use g_key_file_get_value() to test whether
17159  * or not a key exists.
17160  *
17161  * Returns: %TRUE if @key is a part of @group_name, %FALSE otherwise.
17162  * Since: 2.6
17163  */
17164
17165
17166 /**
17167  * g_key_file_load_from_data:
17168  * @key_file: an empty #GKeyFile struct
17169  * @data: key file loaded in memory
17170  * @length: the length of @data in bytes (or -1 if data is nul-terminated)
17171  * @flags: flags from #GKeyFileFlags
17172  * @error: return location for a #GError, or %NULL
17173  *
17174  * Loads a key file from memory into an empty #GKeyFile structure.
17175  * If the object cannot be created then %error is set to a #GKeyFileError.
17176  *
17177  * Returns: %TRUE if a key file could be loaded, %FALSE otherwise
17178  * Since: 2.6
17179  */
17180
17181
17182 /**
17183  * g_key_file_load_from_data_dirs:
17184  * @key_file: an empty #GKeyFile struct
17185  * @file: (type filename): a relative path to a filename to open and parse
17186  * @full_path: (out) (type filename) (allow-none): return location for a string containing the full path of the file, or %NULL
17187  * @flags: flags from #GKeyFileFlags
17188  * @error: return location for a #GError, or %NULL
17189  *
17190  * This function looks for a key file named @file in the paths
17191  * returned from g_get_user_data_dir() and g_get_system_data_dirs(),
17192  * loads the file into @key_file and returns the file's full path in
17193  * @full_path.  If the file could not be loaded then an %error is
17194  * set to either a #GFileError or #GKeyFileError.
17195  *
17196  * Returns: %TRUE if a key file could be loaded, %FALSE othewise
17197  * Since: 2.6
17198  */
17199
17200
17201 /**
17202  * g_key_file_load_from_dirs:
17203  * @key_file: an empty #GKeyFile struct
17204  * @file: (type filename): a relative path to a filename to open and parse
17205  * @search_dirs: (array zero-terminated=1) (element-type filename): %NULL-terminated array of directories to search
17206  * @full_path: (out) (type filename) (allow-none): return location for a string containing the full path of the file, or %NULL
17207  * @flags: flags from #GKeyFileFlags
17208  * @error: return location for a #GError, or %NULL
17209  *
17210  * This function looks for a key file named @file in the paths
17211  * specified in @search_dirs, loads the file into @key_file and
17212  * returns the file's full path in @full_path.  If the file could not
17213  * be loaded then an %error is set to either a #GFileError or
17214  * #GKeyFileError.
17215  *
17216  * Returns: %TRUE if a key file could be loaded, %FALSE otherwise
17217  * Since: 2.14
17218  */
17219
17220
17221 /**
17222  * g_key_file_load_from_file:
17223  * @key_file: an empty #GKeyFile struct
17224  * @file: (type filename): the path of a filename to load, in the GLib filename encoding
17225  * @flags: flags from #GKeyFileFlags
17226  * @error: return location for a #GError, or %NULL
17227  *
17228  * Loads a key file into an empty #GKeyFile structure.
17229  * If the file could not be loaded then @error is set to
17230  * either a #GFileError or #GKeyFileError.
17231  *
17232  * Returns: %TRUE if a key file could be loaded, %FALSE otherwise
17233  * Since: 2.6
17234  */
17235
17236
17237 /**
17238  * g_key_file_new:
17239  *
17240  * Creates a new empty #GKeyFile object. Use
17241  * g_key_file_load_from_file(), g_key_file_load_from_data(),
17242  * g_key_file_load_from_dirs() or g_key_file_load_from_data_dirs() to
17243  * read an existing key file.
17244  *
17245  * Returns: (transfer full): an empty #GKeyFile.
17246  * Since: 2.6
17247  */
17248
17249
17250 /**
17251  * g_key_file_ref: (skip)
17252  * @key_file: a #GKeyFile
17253  *
17254  * Increases the reference count of @key_file.
17255  *
17256  * Returns: the same @key_file.
17257  * Since: 2.32
17258  */
17259
17260
17261 /**
17262  * g_key_file_remove_comment:
17263  * @key_file: a #GKeyFile
17264  * @group_name: (allow-none): a group name, or %NULL
17265  * @key: (allow-none): a key
17266  * @error: return location for a #GError
17267  *
17268  * Removes a comment above @key from @group_name.
17269  * If @key is %NULL then @comment will be removed above @group_name.
17270  * If both @key and @group_name are %NULL, then @comment will
17271  * be removed above the first group in the file.
17272  *
17273  * Returns: %TRUE if the comment was removed, %FALSE otherwise
17274  * Since: 2.6
17275  */
17276
17277
17278 /**
17279  * g_key_file_remove_group:
17280  * @key_file: a #GKeyFile
17281  * @group_name: a group name
17282  * @error: return location for a #GError or %NULL
17283  *
17284  * Removes the specified group, @group_name,
17285  * from the key file.
17286  *
17287  * Returns: %TRUE if the group was removed, %FALSE otherwise
17288  * Since: 2.6
17289  */
17290
17291
17292 /**
17293  * g_key_file_remove_key:
17294  * @key_file: a #GKeyFile
17295  * @group_name: a group name
17296  * @key: a key name to remove
17297  * @error: return location for a #GError or %NULL
17298  *
17299  * Removes @key in @group_name from the key file.
17300  *
17301  * Returns: %TRUE if the key was removed, %FALSE otherwise
17302  * Since: 2.6
17303  */
17304
17305
17306 /**
17307  * g_key_file_set_boolean:
17308  * @key_file: a #GKeyFile
17309  * @group_name: a group name
17310  * @key: a key
17311  * @value: %TRUE or %FALSE
17312  *
17313  * Associates a new boolean value with @key under @group_name.
17314  * If @key cannot be found then it is created.
17315  *
17316  * Since: 2.6
17317  */
17318
17319
17320 /**
17321  * g_key_file_set_boolean_list:
17322  * @key_file: a #GKeyFile
17323  * @group_name: a group name
17324  * @key: a key
17325  * @list: (array length=length): an array of boolean values
17326  * @length: length of @list
17327  *
17328  * Associates a list of boolean values with @key under @group_name.
17329  * If @key cannot be found then it is created.
17330  * If @group_name is %NULL, the start_group is used.
17331  *
17332  * Since: 2.6
17333  */
17334
17335
17336 /**
17337  * g_key_file_set_comment:
17338  * @key_file: a #GKeyFile
17339  * @group_name: (allow-none): a group name, or %NULL
17340  * @key: (allow-none): a key
17341  * @comment: a comment
17342  * @error: return location for a #GError
17343  *
17344  * Places a comment above @key from @group_name.
17345  * If @key is %NULL then @comment will be written above @group_name.
17346  * If both @key and @group_name  are %NULL, then @comment will be
17347  * written above the first group in the file.
17348  *
17349  * Returns: %TRUE if the comment was written, %FALSE otherwise
17350  * Since: 2.6
17351  */
17352
17353
17354 /**
17355  * g_key_file_set_double:
17356  * @key_file: a #GKeyFile
17357  * @group_name: a group name
17358  * @key: a key
17359  * @value: an double value
17360  *
17361  * Associates a new double value with @key under @group_name.
17362  * If @key cannot be found then it is created.
17363  *
17364  * Since: 2.12
17365  */
17366
17367
17368 /**
17369  * g_key_file_set_double_list:
17370  * @key_file: a #GKeyFile
17371  * @group_name: a group name
17372  * @key: a key
17373  * @list: (array length=length): an array of double values
17374  * @length: number of double values in @list
17375  *
17376  * Associates a list of double values with @key under
17377  * @group_name.  If @key cannot be found then it is created.
17378  *
17379  * Since: 2.12
17380  */
17381
17382
17383 /**
17384  * g_key_file_set_int64:
17385  * @key_file: a #GKeyFile
17386  * @group_name: a group name
17387  * @key: a key
17388  * @value: an integer value
17389  *
17390  * Associates a new integer value with @key under @group_name.
17391  * If @key cannot be found then it is created.
17392  *
17393  * Since: 2.26
17394  */
17395
17396
17397 /**
17398  * g_key_file_set_integer:
17399  * @key_file: a #GKeyFile
17400  * @group_name: a group name
17401  * @key: a key
17402  * @value: an integer value
17403  *
17404  * Associates a new integer value with @key under @group_name.
17405  * If @key cannot be found then it is created.
17406  *
17407  * Since: 2.6
17408  */
17409
17410
17411 /**
17412  * g_key_file_set_integer_list:
17413  * @key_file: a #GKeyFile
17414  * @group_name: a group name
17415  * @key: a key
17416  * @list: (array length=length): an array of integer values
17417  * @length: number of integer values in @list
17418  *
17419  * Associates a list of integer values with @key under @group_name.
17420  * If @key cannot be found then it is created.
17421  *
17422  * Since: 2.6
17423  */
17424
17425
17426 /**
17427  * g_key_file_set_list_separator:
17428  * @key_file: a #GKeyFile
17429  * @separator: the separator
17430  *
17431  * Sets the character which is used to separate
17432  * values in lists. Typically ';' or ',' are used
17433  * as separators. The default list separator is ';'.
17434  *
17435  * Since: 2.6
17436  */
17437
17438
17439 /**
17440  * g_key_file_set_locale_string:
17441  * @key_file: a #GKeyFile
17442  * @group_name: a group name
17443  * @key: a key
17444  * @locale: a locale identifier
17445  * @string: a string
17446  *
17447  * Associates a string value for @key and @locale under @group_name.
17448  * If the translation for @key cannot be found then it is created.
17449  *
17450  * Since: 2.6
17451  */
17452
17453
17454 /**
17455  * g_key_file_set_locale_string_list:
17456  * @key_file: a #GKeyFile
17457  * @group_name: a group name
17458  * @key: a key
17459  * @locale: a locale identifier
17460  * @list: (array zero-terminated=1 length=length): a %NULL-terminated array of locale string values
17461  * @length: the length of @list
17462  *
17463  * Associates a list of string values for @key and @locale under
17464  * @group_name.  If the translation for @key cannot be found then
17465  * it is created.
17466  *
17467  * Since: 2.6
17468  */
17469
17470
17471 /**
17472  * g_key_file_set_string:
17473  * @key_file: a #GKeyFile
17474  * @group_name: a group name
17475  * @key: a key
17476  * @string: a string
17477  *
17478  * Associates a new string value with @key under @group_name.
17479  * If @key cannot be found then it is created.
17480  * If @group_name cannot be found then it is created.
17481  * Unlike g_key_file_set_value(), this function handles characters
17482  * that need escaping, such as newlines.
17483  *
17484  * Since: 2.6
17485  */
17486
17487
17488 /**
17489  * g_key_file_set_string_list:
17490  * @key_file: a #GKeyFile
17491  * @group_name: a group name
17492  * @key: a key
17493  * @list: (array zero-terminated=1 length=length) (element-type utf8): an array of string values
17494  * @length: number of string values in @list
17495  *
17496  * Associates a list of string values for @key under @group_name.
17497  * If @key cannot be found then it is created.
17498  * If @group_name cannot be found then it is created.
17499  *
17500  * Since: 2.6
17501  */
17502
17503
17504 /**
17505  * g_key_file_set_uint64:
17506  * @key_file: a #GKeyFile
17507  * @group_name: a group name
17508  * @key: a key
17509  * @value: an integer value
17510  *
17511  * Associates a new integer value with @key under @group_name.
17512  * If @key cannot be found then it is created.
17513  *
17514  * Since: 2.26
17515  */
17516
17517
17518 /**
17519  * g_key_file_set_value:
17520  * @key_file: a #GKeyFile
17521  * @group_name: a group name
17522  * @key: a key
17523  * @value: a string
17524  *
17525  * Associates a new value with @key under @group_name.
17526  *
17527  * If @key cannot be found then it is created. If @group_name cannot
17528  * be found then it is created. To set an UTF-8 string which may contain
17529  * characters that need escaping (such as newlines or spaces), use
17530  * g_key_file_set_string().
17531  *
17532  * Since: 2.6
17533  */
17534
17535
17536 /**
17537  * g_key_file_to_data:
17538  * @key_file: a #GKeyFile
17539  * @length: (out) (allow-none): return location for the length of the returned string, or %NULL
17540  * @error: return location for a #GError, or %NULL
17541  *
17542  * This function outputs @key_file as a string.
17543  *
17544  * Note that this function never reports an error,
17545  * so it is safe to pass %NULL as @error.
17546  *
17547  * Returns: a newly allocated string holding the contents of the #GKeyFile
17548  * Since: 2.6
17549  */
17550
17551
17552 /**
17553  * g_key_file_unref:
17554  * @key_file: a #GKeyFile
17555  *
17556  * Decreases the reference count of @key_file by 1. If the reference count
17557  * reaches zero, frees the key file and all its allocated memory.
17558  *
17559  * Since: 2.32
17560  */
17561
17562
17563 /**
17564  * g_list_alloc:
17565  *
17566  * Allocates space for one #GList element. It is called by
17567  * g_list_append(), g_list_prepend(), g_list_insert() and
17568  * g_list_insert_sorted() and so is rarely used on its own.
17569  *
17570  * Returns: a pointer to the newly-allocated #GList element.
17571  */
17572
17573
17574 /**
17575  * g_list_append:
17576  * @list: a pointer to a #GList
17577  * @data: the data for the new element
17578  *
17579  * Adds a new element on to the end of the list.
17580  *
17581  * <note><para>
17582  * The return value is the new start of the list, which
17583  * may have changed, so make sure you store the new value.
17584  * </para></note>
17585  *
17586  * <note><para>
17587  * Note that g_list_append() has to traverse the entire list
17588  * to find the end, which is inefficient when adding multiple
17589  * elements. A common idiom to avoid the inefficiency is to prepend
17590  * the elements and reverse the list when all elements have been added.
17591  * </para></note>
17592  *
17593  * |[
17594  * /&ast; Notice that these are initialized to the empty list. &ast;/
17595  * GList *list = NULL, *number_list = NULL;
17596  *
17597  * /&ast; This is a list of strings. &ast;/
17598  * list = g_list_append (list, "first");
17599  * list = g_list_append (list, "second");
17600  *
17601  * /&ast; This is a list of integers. &ast;/
17602  * number_list = g_list_append (number_list, GINT_TO_POINTER (27));
17603  * number_list = g_list_append (number_list, GINT_TO_POINTER (14));
17604  * ]|
17605  *
17606  * Returns: the new start of the #GList
17607  */
17608
17609
17610 /**
17611  * g_list_concat:
17612  * @list1: a #GList
17613  * @list2: the #GList to add to the end of the first #GList
17614  *
17615  * Adds the second #GList onto the end of the first #GList.
17616  * Note that the elements of the second #GList are not copied.
17617  * They are used directly.
17618  *
17619  * Returns: the start of the new #GList
17620  */
17621
17622
17623 /**
17624  * g_list_copy:
17625  * @list: a #GList
17626  *
17627  * Copies a #GList.
17628  *
17629  * <note><para>
17630  * Note that this is a "shallow" copy. If the list elements
17631  * consist of pointers to data, the pointers are copied but
17632  * the actual data is not. See g_list_copy_deep() if you need
17633  * to copy the data as well.
17634  * </para></note>
17635  *
17636  * Returns: a copy of @list
17637  */
17638
17639
17640 /**
17641  * g_list_copy_deep:
17642  * @list: a #GList
17643  * @func: a copy function used to copy every element in the list
17644  * @user_data: user data passed to the copy function @func, or #NULL
17645  *
17646  * Makes a full (deep) copy of a #GList.
17647  *
17648  * In contrast with g_list_copy(), this function uses @func to make a copy of
17649  * each list element, in addition to copying the list container itself.
17650  *
17651  * @func, as a #GCopyFunc, takes two arguments, the data to be copied and a user
17652  * pointer. It's safe to pass #NULL as user_data, if the copy function takes only
17653  * one argument.
17654  *
17655  * For instance, if @list holds a list of GObjects, you can do:
17656  * |[
17657  * another_list = g_list_copy_deep (list, (GCopyFunc) g_object_ref, NULL);
17658  * ]|
17659  *
17660  * And, to entirely free the new list, you could do:
17661  * |[
17662  * g_list_free_full (another_list, g_object_unref);
17663  * ]|
17664  *
17665  * Returns: a full copy of @list, use #g_list_free_full to free it
17666  * Since: 2.34
17667  */
17668
17669
17670 /**
17671  * g_list_delete_link:
17672  * @list: a #GList
17673  * @link_: node to delete from @list
17674  *
17675  * Removes the node link_ from the list and frees it.
17676  * Compare this to g_list_remove_link() which removes the node
17677  * without freeing it.
17678  *
17679  * Returns: the new head of @list
17680  */
17681
17682
17683 /**
17684  * g_list_find:
17685  * @list: a #GList
17686  * @data: the element data to find
17687  *
17688  * Finds the element in a #GList which
17689  * contains the given data.
17690  *
17691  * Returns: the found #GList element, or %NULL if it is not found
17692  */
17693
17694
17695 /**
17696  * g_list_find_custom:
17697  * @list: a #GList
17698  * @data: user data passed to the function
17699  * @func: the function to call for each element. It should return 0 when the desired element is found
17700  *
17701  * Finds an element in a #GList, using a supplied function to
17702  * find the desired element. It iterates over the list, calling
17703  * the given function which should return 0 when the desired
17704  * element is found. The function takes two #gconstpointer arguments,
17705  * the #GList element's data as the first argument and the
17706  * given user data.
17707  *
17708  * Returns: the found #GList element, or %NULL if it is not found
17709  */
17710
17711
17712 /**
17713  * g_list_first:
17714  * @list: a #GList
17715  *
17716  * Gets the first element in a #GList.
17717  *
17718  * Returns: the first element in the #GList, or %NULL if the #GList has no elements
17719  */
17720
17721
17722 /**
17723  * g_list_foreach:
17724  * @list: a #GList
17725  * @func: the function to call with each element's data
17726  * @user_data: user data to pass to the function
17727  *
17728  * Calls a function for each element of a #GList.
17729  */
17730
17731
17732 /**
17733  * g_list_free:
17734  * @list: a #GList
17735  *
17736  * Frees all of the memory used by a #GList.
17737  * The freed elements are returned to the slice allocator.
17738  *
17739  * <note><para>
17740  * If list elements contain dynamically-allocated memory,
17741  * you should either use g_list_free_full() or free them manually
17742  * first.
17743  * </para></note>
17744  */
17745
17746
17747 /**
17748  * g_list_free1:
17749  *
17750  * Another name for g_list_free_1().
17751  */
17752
17753
17754 /**
17755  * g_list_free_1:
17756  * @list: a #GList element
17757  *
17758  * Frees one #GList element.
17759  * It is usually used after g_list_remove_link().
17760  */
17761
17762
17763 /**
17764  * g_list_free_full:
17765  * @list: a pointer to a #GList
17766  * @free_func: the function to be called to free each element's data
17767  *
17768  * Convenience method, which frees all the memory used by a #GList, and
17769  * calls the specified destroy function on every element's data.
17770  *
17771  * Since: 2.28
17772  */
17773
17774
17775 /**
17776  * g_list_index:
17777  * @list: a #GList
17778  * @data: the data to find
17779  *
17780  * Gets the position of the element containing
17781  * the given data (starting from 0).
17782  *
17783  * Returns: the index of the element containing the data, or -1 if the data is not found
17784  */
17785
17786
17787 /**
17788  * g_list_insert:
17789  * @list: a pointer to a #GList
17790  * @data: the data for the new element
17791  * @position: the position to insert the element. If this is negative, or is larger than the number of elements in the list, the new element is added on to the end of the list.
17792  *
17793  * Inserts a new element into the list at the given position.
17794  *
17795  * Returns: the new start of the #GList
17796  */
17797
17798
17799 /**
17800  * g_list_insert_before:
17801  * @list: a pointer to a #GList
17802  * @sibling: the list element before which the new element is inserted or %NULL to insert at the end of the list
17803  * @data: the data for the new element
17804  *
17805  * Inserts a new element into the list before the given position.
17806  *
17807  * Returns: the new start of the #GList
17808  */
17809
17810
17811 /**
17812  * g_list_insert_sorted:
17813  * @list: a pointer to a #GList
17814  * @data: the data for the new element
17815  * @func: the function to compare elements in the list. It should return a number > 0 if the first parameter comes after the second parameter in the sort order.
17816  *
17817  * Inserts a new element into the list, using the given comparison
17818  * function to determine its position.
17819  *
17820  * Returns: the new start of the #GList
17821  */
17822
17823
17824 /**
17825  * g_list_insert_sorted_with_data:
17826  * @list: a pointer to a #GList
17827  * @data: the data for the new element
17828  * @func: the function to compare elements in the list. It should return a number > 0 if the first parameter comes after the second parameter in the sort order.
17829  * @user_data: user data to pass to comparison function.
17830  *
17831  * Inserts a new element into the list, using the given comparison
17832  * function to determine its position.
17833  *
17834  * Returns: the new start of the #GList
17835  * Since: 2.10
17836  */
17837
17838
17839 /**
17840  * g_list_last:
17841  * @list: a #GList
17842  *
17843  * Gets the last element in a #GList.
17844  *
17845  * Returns: the last element in the #GList, or %NULL if the #GList has no elements
17846  */
17847
17848
17849 /**
17850  * g_list_length:
17851  * @list: a #GList
17852  *
17853  * Gets the number of elements in a #GList.
17854  *
17855  * <note><para>
17856  * This function iterates over the whole list to
17857  * count its elements.
17858  * </para></note>
17859  *
17860  * Returns: the number of elements in the #GList
17861  */
17862
17863
17864 /**
17865  * g_list_next:
17866  * @list: an element in a #GList.
17867  *
17868  * A convenience macro to get the next element in a #GList.
17869  *
17870  * Returns: the next element, or %NULL if there are no more elements.
17871  */
17872
17873
17874 /**
17875  * g_list_nth:
17876  * @list: a #GList
17877  * @n: the position of the element, counting from 0
17878  *
17879  * Gets the element at the given position in a #GList.
17880  *
17881  * Returns: the element, or %NULL if the position is off the end of the #GList
17882  */
17883
17884
17885 /**
17886  * g_list_nth_data:
17887  * @list: a #GList
17888  * @n: the position of the element
17889  *
17890  * Gets the data of the element at the given position.
17891  *
17892  * Returns: the element's data, or %NULL if the position is off the end of the #GList
17893  */
17894
17895
17896 /**
17897  * g_list_nth_prev:
17898  * @list: a #GList
17899  * @n: the position of the element, counting from 0
17900  *
17901  * Gets the element @n places before @list.
17902  *
17903  * Returns: the element, or %NULL if the position is off the end of the #GList
17904  */
17905
17906
17907 /**
17908  * g_list_position:
17909  * @list: a #GList
17910  * @llink: an element in the #GList
17911  *
17912  * Gets the position of the given element
17913  * in the #GList (starting from 0).
17914  *
17915  * Returns: the position of the element in the #GList, or -1 if the element is not found
17916  */
17917
17918
17919 /**
17920  * g_list_prepend:
17921  * @list: a pointer to a #GList
17922  * @data: the data for the new element
17923  *
17924  * Adds a new element on to the start of the list.
17925  *
17926  * <note><para>
17927  * The return value is the new start of the list, which
17928  * may have changed, so make sure you store the new value.
17929  * </para></note>
17930  *
17931  * |[
17932  * /&ast; Notice that it is initialized to the empty list. &ast;/
17933  * GList *list = NULL;
17934  * list = g_list_prepend (list, "last");
17935  * list = g_list_prepend (list, "first");
17936  * ]|
17937  *
17938  * Returns: the new start of the #GList
17939  */
17940
17941
17942 /**
17943  * g_list_previous:
17944  * @list: an element in a #GList.
17945  *
17946  * A convenience macro to get the previous element in a #GList.
17947  *
17948  * Returns: the previous element, or %NULL if there are no previous elements.
17949  */
17950
17951
17952 /**
17953  * g_list_remove:
17954  * @list: a #GList
17955  * @data: the data of the element to remove
17956  *
17957  * Removes an element from a #GList.
17958  * If two elements contain the same data, only the first is removed.
17959  * If none of the elements contain the data, the #GList is unchanged.
17960  *
17961  * Returns: the new start of the #GList
17962  */
17963
17964
17965 /**
17966  * g_list_remove_all:
17967  * @list: a #GList
17968  * @data: data to remove
17969  *
17970  * Removes all list nodes with data equal to @data.
17971  * Returns the new head of the list. Contrast with
17972  * g_list_remove() which removes only the first node
17973  * matching the given data.
17974  *
17975  * Returns: new head of @list
17976  */
17977
17978
17979 /**
17980  * g_list_remove_link:
17981  * @list: a #GList
17982  * @llink: an element in the #GList
17983  *
17984  * Removes an element from a #GList, without freeing the element.
17985  * The removed element's prev and next links are set to %NULL, so
17986  * that it becomes a self-contained list with one element.
17987  *
17988  * Returns: the new start of the #GList, without the element
17989  */
17990
17991
17992 /**
17993  * g_list_reverse:
17994  * @list: a #GList
17995  *
17996  * Reverses a #GList.
17997  * It simply switches the next and prev pointers of each element.
17998  *
17999  * Returns: the start of the reversed #GList
18000  */
18001
18002
18003 /**
18004  * g_list_sort:
18005  * @list: a #GList
18006  * @compare_func: the comparison function used to sort the #GList. This function is passed the data from 2 elements of the #GList and should return 0 if they are equal, a negative value if the first element comes before the second, or a positive value if the first element comes after the second.
18007  *
18008  * Sorts a #GList using the given comparison function. The algorithm
18009  * used is a stable sort.
18010  *
18011  * Returns: the start of the sorted #GList
18012  */
18013
18014
18015 /**
18016  * g_list_sort_with_data:
18017  * @list: a #GList
18018  * @compare_func: comparison function
18019  * @user_data: user data to pass to comparison function
18020  *
18021  * Like g_list_sort(), but the comparison function accepts
18022  * a user data argument.
18023  *
18024  * Returns: the new head of @list
18025  */
18026
18027
18028 /**
18029  * g_listenv:
18030  *
18031  * Gets the names of all variables set in the environment.
18032  *
18033  * Programs that want to be portable to Windows should typically use
18034  * this function and g_getenv() instead of using the environ array
18035  * from the C library directly. On Windows, the strings in the environ
18036  * array are in system codepage encoding, while in most of the typical
18037  * use cases for environment variables in GLib-using programs you want
18038  * the UTF-8 encoding that this function and g_getenv() provide.
18039  *
18040  * Returns: (array zero-terminated=1) (transfer full): a %NULL-terminated list of strings which must be freed with g_strfreev().
18041  * Since: 2.8
18042  */
18043
18044
18045 /**
18046  * g_locale_from_utf8:
18047  * @utf8string: a UTF-8 encoded string
18048  * @len: the length of the string, or -1 if the string is nul-terminated<footnoteref linkend="nul-unsafe"/>.
18049  * @bytes_read: location to store the number of bytes in the input string that were successfully converted, or %NULL. Even if the conversion was successful, this may be less than @len if there were partial characters at the end of the input. If the error #G_CONVERT_ERROR_ILLEGAL_SEQUENCE occurs, the value stored will the byte offset after the last valid input sequence.
18050  * @bytes_written: the number of bytes stored in the output buffer (not including the terminating nul).
18051  * @error: location to store the error occurring, or %NULL to ignore errors. Any of the errors in #GConvertError may occur.
18052  *
18053  * Converts a string from UTF-8 to the encoding used for strings by
18054  * the C runtime (usually the same as that used by the operating
18055  * system) in the <link linkend="setlocale">current locale</link>. On
18056  * Windows this means the system codepage.
18057  *
18058  * Returns: The converted string, or %NULL on an error.
18059  */
18060
18061
18062 /**
18063  * g_locale_to_utf8:
18064  * @opsysstring: a string in the encoding of the current locale. On Windows this means the system codepage.
18065  * @len: the length of the string, or -1 if the string is nul-terminated<footnoteref linkend="nul-unsafe"/>.
18066  * @bytes_read: location to store the number of bytes in the input string that were successfully converted, or %NULL. Even if the conversion was successful, this may be less than @len if there were partial characters at the end of the input. If the error #G_CONVERT_ERROR_ILLEGAL_SEQUENCE occurs, the value stored will the byte offset after the last valid input sequence.
18067  * @bytes_written: the number of bytes stored in the output buffer (not including the terminating nul).
18068  * @error: location to store the error occurring, or %NULL to ignore errors. Any of the errors in #GConvertError may occur.
18069  *
18070  * Converts a string which is in the encoding used for strings by
18071  * the C runtime (usually the same as that used by the operating
18072  * system) in the <link linkend="setlocale">current locale</link> into a
18073  * UTF-8 string.
18074  *
18075  * Returns: The converted string, or %NULL on an error.
18076  */
18077
18078
18079 /**
18080  * g_log:
18081  * @log_domain: the log domain, usually #G_LOG_DOMAIN
18082  * @log_level: the log level, either from #GLogLevelFlags or a user-defined level
18083  * @format: the message format. See the printf() documentation
18084  * @...: the parameters to insert into the format string
18085  *
18086  * Logs an error or debugging message.
18087  *
18088  * If the log level has been set as fatal, the abort()
18089  * function is called to terminate the program.
18090  */
18091
18092
18093 /**
18094  * g_log_default_handler:
18095  * @log_domain: the log domain of the message
18096  * @log_level: the level of the message
18097  * @message: the message
18098  * @unused_data: data passed from g_log() which is unused
18099  *
18100  * The default log handler set up by GLib; g_log_set_default_handler()
18101  * allows to install an alternate default log handler.
18102  * This is used if no log handler has been set for the particular log
18103  * domain and log level combination. It outputs the message to stderr
18104  * or stdout and if the log level is fatal it calls abort().
18105  *
18106  * The behavior of this log handler can be influenced by a number of
18107  * environment variables:
18108  * <variablelist>
18109  *   <varlistentry>
18110  *     <term><envar>G_MESSAGES_PREFIXED</envar></term>
18111  *     <listitem>
18112  *       A :-separated list of log levels for which messages should
18113  *       be prefixed by the program name and PID of the aplication.
18114  *     </listitem>
18115  *   </varlistentry>
18116  *   <varlistentry>
18117  *     <term><envar>G_MESSAGES_DEBUG</envar></term>
18118  *     <listitem>
18119  *       A space-separated list of log domains for which debug and
18120  *       informational messages are printed. By default these
18121  *       messages are not printed.
18122  *     </listitem>
18123  *   </varlistentry>
18124  * </variablelist>
18125  *
18126  * stderr is used for levels %G_LOG_LEVEL_ERROR, %G_LOG_LEVEL_CRITICAL,
18127  * %G_LOG_LEVEL_WARNING and %G_LOG_LEVEL_MESSAGE. stdout is used for
18128  * the rest.
18129  */
18130
18131
18132 /**
18133  * g_log_remove_handler:
18134  * @log_domain: the log domain
18135  * @handler_id: the id of the handler, which was returned in g_log_set_handler()
18136  *
18137  * Removes the log handler.
18138  */
18139
18140
18141 /**
18142  * g_log_set_always_fatal:
18143  * @fatal_mask: the mask containing bits set for each level of error which is to be fatal
18144  *
18145  * Sets the message levels which are always fatal, in any log domain.
18146  * When a message with any of these levels is logged the program terminates.
18147  * You can only set the levels defined by GLib to be fatal.
18148  * %G_LOG_LEVEL_ERROR is always fatal.
18149  *
18150  * You can also make some message levels fatal at runtime by setting
18151  * the <envar>G_DEBUG</envar> environment variable (see
18152  * <ulink url="glib-running.html">Running GLib Applications</ulink>).
18153  *
18154  * Returns: the old fatal mask
18155  */
18156
18157
18158 /**
18159  * g_log_set_default_handler:
18160  * @log_func: the log handler function
18161  * @user_data: data passed to the log handler
18162  *
18163  * Installs a default log handler which is used if no
18164  * log handler has been set for the particular log domain
18165  * and log level combination. By default, GLib uses
18166  * g_log_default_handler() as default log handler.
18167  *
18168  * Returns: the previous default log handler
18169  * Since: 2.6
18170  */
18171
18172
18173 /**
18174  * g_log_set_fatal_mask:
18175  * @log_domain: the log domain
18176  * @fatal_mask: the new fatal mask
18177  *
18178  * Sets the log levels which are fatal in the given domain.
18179  * %G_LOG_LEVEL_ERROR is always fatal.
18180  *
18181  * Returns: the old fatal mask for the log domain
18182  */
18183
18184
18185 /**
18186  * g_log_set_handler:
18187  * @log_domain: (allow-none): the log domain, or %NULL for the default "" application domain
18188  * @log_levels: the log levels to apply the log handler for. To handle fatal and recursive messages as well, combine the log levels with the #G_LOG_FLAG_FATAL and #G_LOG_FLAG_RECURSION bit flags.
18189  * @log_func: the log handler function
18190  * @user_data: data passed to the log handler
18191  *
18192  * Sets the log handler for a domain and a set of log levels.
18193  * To handle fatal and recursive messages the @log_levels parameter
18194  * must be combined with the #G_LOG_FLAG_FATAL and #G_LOG_FLAG_RECURSION
18195  * bit flags.
18196  *
18197  * Note that since the #G_LOG_LEVEL_ERROR log level is always fatal, if
18198  * you want to set a handler for this log level you must combine it with
18199  * #G_LOG_FLAG_FATAL.
18200  *
18201  * <example>
18202  * <title>Adding a log handler for all warning messages in the default
18203  * (application) domain</title>
18204  * <programlisting>
18205  * g_log_set_handler (NULL, G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL
18206  *                    | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
18207  * </programlisting>
18208  * </example>
18209  *
18210  * <example>
18211  * <title>Adding a log handler for all critical messages from GTK+</title>
18212  * <programlisting>
18213  * g_log_set_handler ("Gtk", G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL
18214  *                    | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
18215  * </programlisting>
18216  * </example>
18217  *
18218  * <example>
18219  * <title>Adding a log handler for <emphasis>all</emphasis> messages from
18220  * GLib</title>
18221  * <programlisting>
18222  * g_log_set_handler ("GLib", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
18223  *                    | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
18224  * </programlisting>
18225  * </example>
18226  *
18227  * Returns: the id of the new handler
18228  */
18229
18230
18231 /**
18232  * g_logv:
18233  * @log_domain: the log domain
18234  * @log_level: the log level
18235  * @format: the message format. See the printf() documentation
18236  * @args: the parameters to insert into the format string
18237  *
18238  * Logs an error or debugging message.
18239  *
18240  * If the log level has been set as fatal, the abort()
18241  * function is called to terminate the program.
18242  */
18243
18244
18245 /**
18246  * g_lstat:
18247  * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
18248  * @buf: a pointer to a <structname>stat</structname> struct, which will be filled with the file information
18249  *
18250  * A wrapper for the POSIX lstat() function. The lstat() function is
18251  * like stat() except that in the case of symbolic links, it returns
18252  * information about the symbolic link itself and not the file that it
18253  * refers to. If the system does not support symbolic links g_lstat()
18254  * is identical to g_stat().
18255  *
18256  * See your C library manual for more details about lstat().
18257  *
18258  * Returns: 0 if the information was successfully retrieved, -1 if an error occurred
18259  * Since: 2.6
18260  */
18261
18262
18263 /**
18264  * g_main_context_acquire:
18265  * @context: a #GMainContext
18266  *
18267  * Tries to become the owner of the specified context.
18268  * If some other thread is the owner of the context,
18269  * returns %FALSE immediately. Ownership is properly
18270  * recursive: the owner can require ownership again
18271  * and will release ownership when g_main_context_release()
18272  * is called as many times as g_main_context_acquire().
18273  *
18274  * You must be the owner of a context before you
18275  * can call g_main_context_prepare(), g_main_context_query(),
18276  * g_main_context_check(), g_main_context_dispatch().
18277  *
18278  * Returns: %TRUE if the operation succeeded, and this thread is now the owner of @context.
18279  */
18280
18281
18282 /**
18283  * g_main_context_add_poll:
18284  * @context: (allow-none): a #GMainContext (or %NULL for the default context)
18285  * @fd: a #GPollFD structure holding information about a file descriptor to watch.
18286  * @priority: the priority for this file descriptor which should be the same as the priority used for g_source_attach() to ensure that the file descriptor is polled whenever the results may be needed.
18287  *
18288  * Adds a file descriptor to the set of file descriptors polled for
18289  * this context. This will very seldom be used directly. Instead
18290  * a typical event source will use g_source_add_unix_fd() instead.
18291  */
18292
18293
18294 /**
18295  * g_main_context_check:
18296  * @context: a #GMainContext
18297  * @max_priority: the maximum numerical priority of sources to check
18298  * @fds: (array length=n_fds): array of #GPollFD's that was passed to the last call to g_main_context_query()
18299  * @n_fds: return value of g_main_context_query()
18300  *
18301  * Passes the results of polling back to the main loop.
18302  *
18303  * Returns: %TRUE if some sources are ready to be dispatched.
18304  */
18305
18306
18307 /**
18308  * g_main_context_default:
18309  *
18310  * Returns the global default main context. This is the main context
18311  * used for main loop functions when a main loop is not explicitly
18312  * specified, and corresponds to the "main" main loop. See also
18313  * g_main_context_get_thread_default().
18314  *
18315  * Returns: (transfer none): the global default main context.
18316  */
18317
18318
18319 /**
18320  * g_main_context_dispatch:
18321  * @context: a #GMainContext
18322  *
18323  * Dispatches all pending sources.
18324  */
18325
18326
18327 /**
18328  * g_main_context_find_source_by_funcs_user_data:
18329  * @context: (allow-none): a #GMainContext (if %NULL, the default context will be used).
18330  * @funcs: the @source_funcs passed to g_source_new().
18331  * @user_data: the user data from the callback.
18332  *
18333  * Finds a source with the given source functions and user data.  If
18334  * multiple sources exist with the same source function and user data,
18335  * the first one found will be returned.
18336  *
18337  * Returns: (transfer none): the source, if one was found, otherwise %NULL
18338  */
18339
18340
18341 /**
18342  * g_main_context_find_source_by_id:
18343  * @context: (allow-none): a #GMainContext (if %NULL, the default context will be used)
18344  * @source_id: the source ID, as returned by g_source_get_id().
18345  *
18346  * Finds a #GSource given a pair of context and ID.
18347  *
18348  * Returns: (transfer none): the #GSource if found, otherwise, %NULL
18349  */
18350
18351
18352 /**
18353  * g_main_context_find_source_by_user_data:
18354  * @context: a #GMainContext
18355  * @user_data: the user_data for the callback.
18356  *
18357  * Finds a source with the given user data for the callback.  If
18358  * multiple sources exist with the same user data, the first
18359  * one found will be returned.
18360  *
18361  * Returns: (transfer none): the source, if one was found, otherwise %NULL
18362  */
18363
18364
18365 /**
18366  * g_main_context_get_poll_func:
18367  * @context: a #GMainContext
18368  *
18369  * Gets the poll function set by g_main_context_set_poll_func().
18370  *
18371  * Returns: the poll function
18372  */
18373
18374
18375 /**
18376  * g_main_context_get_thread_default:
18377  *
18378  * Gets the thread-default #GMainContext for this thread. Asynchronous
18379  * operations that want to be able to be run in contexts other than
18380  * the default one should call this method or
18381  * g_main_context_ref_thread_default() to get a #GMainContext to add
18382  * their #GSource<!-- -->s to. (Note that even in single-threaded
18383  * programs applications may sometimes want to temporarily push a
18384  * non-default context, so it is not safe to assume that this will
18385  * always return %NULL if you are running in the default thread.)
18386  *
18387  * If you need to hold a reference on the context, use
18388  * g_main_context_ref_thread_default() instead.
18389  *
18390  * Returns: (transfer none): the thread-default #GMainContext, or %NULL if the thread-default context is the global default context.
18391  * Since: 2.22
18392  */
18393
18394
18395 /**
18396  * g_main_context_invoke:
18397  * @context: (allow-none): a #GMainContext, or %NULL
18398  * @function: function to call
18399  * @data: data to pass to @function
18400  *
18401  * Invokes a function in such a way that @context is owned during the
18402  * invocation of @function.
18403  *
18404  * If @context is %NULL then the global default main context â€” as
18405  * returned by g_main_context_default() â€” is used.
18406  *
18407  * If @context is owned by the current thread, @function is called
18408  * directly.  Otherwise, if @context is the thread-default main context
18409  * of the current thread and g_main_context_acquire() succeeds, then
18410  * @function is called and g_main_context_release() is called
18411  * afterwards.
18412  *
18413  * In any other case, an idle source is created to call @function and
18414  * that source is attached to @context (presumably to be run in another
18415  * thread).  The idle source is attached with #G_PRIORITY_DEFAULT
18416  * priority.  If you want a different priority, use
18417  * g_main_context_invoke_full().
18418  *
18419  * Note that, as with normal idle functions, @function should probably
18420  * return %FALSE.  If it returns %TRUE, it will be continuously run in a
18421  * loop (and may prevent this call from returning).
18422  *
18423  * Since: 2.28
18424  */
18425
18426
18427 /**
18428  * g_main_context_invoke_full:
18429  * @context: (allow-none): a #GMainContext, or %NULL
18430  * @priority: the priority at which to run @function
18431  * @function: function to call
18432  * @data: data to pass to @function
18433  * @notify: (allow-none): a function to call when @data is no longer in use, or %NULL.
18434  *
18435  * Invokes a function in such a way that @context is owned during the
18436  * invocation of @function.
18437  *
18438  * This function is the same as g_main_context_invoke() except that it
18439  * lets you specify the priority incase @function ends up being
18440  * scheduled as an idle and also lets you give a #GDestroyNotify for @data.
18441  *
18442  * @notify should not assume that it is called from any particular
18443  * thread or with any particular context acquired.
18444  *
18445  * Since: 2.28
18446  */
18447
18448
18449 /**
18450  * g_main_context_is_owner:
18451  * @context: a #GMainContext
18452  *
18453  * Determines whether this thread holds the (recursive)
18454  * ownership of this #GMainContext. This is useful to
18455  * know before waiting on another thread that may be
18456  * blocking to get ownership of @context.
18457  *
18458  * Returns: %TRUE if current thread is owner of @context.
18459  * Since: 2.10
18460  */
18461
18462
18463 /**
18464  * g_main_context_iteration:
18465  * @context: (allow-none): a #GMainContext (if %NULL, the default context will be used)
18466  * @may_block: whether the call may block.
18467  *
18468  * Runs a single iteration for the given main loop. This involves
18469  * checking to see if any event sources are ready to be processed,
18470  * then if no events sources are ready and @may_block is %TRUE, waiting
18471  * for a source to become ready, then dispatching the highest priority
18472  * events sources that are ready. Otherwise, if @may_block is %FALSE
18473  * sources are not waited to become ready, only those highest priority
18474  * events sources will be dispatched (if any), that are ready at this
18475  * given moment without further waiting.
18476  *
18477  * Note that even when @may_block is %TRUE, it is still possible for
18478  * g_main_context_iteration() to return %FALSE, since the wait may
18479  * be interrupted for other reasons than an event source becoming ready.
18480  *
18481  * Returns: %TRUE if events were dispatched.
18482  */
18483
18484
18485 /**
18486  * g_main_context_new:
18487  *
18488  * Creates a new #GMainContext structure.
18489  *
18490  * Returns: the new #GMainContext
18491  */
18492
18493
18494 /**
18495  * g_main_context_pending:
18496  * @context: (allow-none): a #GMainContext (if %NULL, the default context will be used)
18497  *
18498  * Checks if any sources have pending events for the given context.
18499  *
18500  * Returns: %TRUE if events are pending.
18501  */
18502
18503
18504 /**
18505  * g_main_context_pop_thread_default:
18506  * @context: (allow-none): a #GMainContext object, or %NULL
18507  *
18508  * Pops @context off the thread-default context stack (verifying that
18509  * it was on the top of the stack).
18510  *
18511  * Since: 2.22
18512  */
18513
18514
18515 /**
18516  * g_main_context_prepare:
18517  * @context: a #GMainContext
18518  * @priority: location to store priority of highest priority source already ready.
18519  *
18520  * Prepares to poll sources within a main loop. The resulting information
18521  * for polling is determined by calling g_main_context_query ().
18522  *
18523  * Returns: %TRUE if some source is ready to be dispatched prior to polling.
18524  */
18525
18526
18527 /**
18528  * g_main_context_push_thread_default:
18529  * @context: (allow-none): a #GMainContext, or %NULL for the global default context
18530  *
18531  * Acquires @context and sets it as the thread-default context for the
18532  * current thread. This will cause certain asynchronous operations
18533  * (such as most <link linkend="gio">gio</link>-based I/O) which are
18534  * started in this thread to run under @context and deliver their
18535  * results to its main loop, rather than running under the global
18536  * default context in the main thread. Note that calling this function
18537  * changes the context returned by
18538  * g_main_context_get_thread_default(), <emphasis>not</emphasis> the
18539  * one returned by g_main_context_default(), so it does not affect the
18540  * context used by functions like g_idle_add().
18541  *
18542  * Normally you would call this function shortly after creating a new
18543  * thread, passing it a #GMainContext which will be run by a
18544  * #GMainLoop in that thread, to set a new default context for all
18545  * async operations in that thread. (In this case, you don't need to
18546  * ever call g_main_context_pop_thread_default().) In some cases
18547  * however, you may want to schedule a single operation in a
18548  * non-default context, or temporarily use a non-default context in
18549  * the main thread. In that case, you can wrap the call to the
18550  * asynchronous operation inside a
18551  * g_main_context_push_thread_default() /
18552  * g_main_context_pop_thread_default() pair, but it is up to you to
18553  * ensure that no other asynchronous operations accidentally get
18554  * started while the non-default context is active.
18555  *
18556  * Beware that libraries that predate this function may not correctly
18557  * handle being used from a thread with a thread-default context. Eg,
18558  * see g_file_supports_thread_contexts().
18559  *
18560  * Since: 2.22
18561  */
18562
18563
18564 /**
18565  * g_main_context_query:
18566  * @context: a #GMainContext
18567  * @max_priority: maximum priority source to check
18568  * @timeout_: (out): location to store timeout to be used in polling
18569  * @fds: (out caller-allocates) (array length=n_fds): location to store #GPollFD records that need to be polled.
18570  * @n_fds: length of @fds.
18571  *
18572  * Determines information necessary to poll this main loop.
18573  *
18574  * Returns: the number of records actually stored in @fds, or, if more than @n_fds records need to be stored, the number of records that need to be stored.
18575  */
18576
18577
18578 /**
18579  * g_main_context_ref:
18580  * @context: a #GMainContext
18581  *
18582  * Increases the reference count on a #GMainContext object by one.
18583  *
18584  * Returns: the @context that was passed in (since 2.6)
18585  */
18586
18587
18588 /**
18589  * g_main_context_ref_thread_default:
18590  *
18591  * Gets the thread-default #GMainContext for this thread, as with
18592  * g_main_context_get_thread_default(), but also adds a reference to
18593  * it with g_main_context_ref(). In addition, unlike
18594  * g_main_context_get_thread_default(), if the thread-default context
18595  * is the global default context, this will return that #GMainContext
18596  * (with a ref added to it) rather than returning %NULL.
18597  *
18598  * Returns: (transfer full): the thread-default #GMainContext. Unref with g_main_context_unref() when you are done with it.
18599  * Since: 2.32
18600  */
18601
18602
18603 /**
18604  * g_main_context_release:
18605  * @context: a #GMainContext
18606  *
18607  * Releases ownership of a context previously acquired by this thread
18608  * with g_main_context_acquire(). If the context was acquired multiple
18609  * times, the ownership will be released only when g_main_context_release()
18610  * is called as many times as it was acquired.
18611  */
18612
18613
18614 /**
18615  * g_main_context_remove_poll:
18616  * @context: a #GMainContext
18617  * @fd: a #GPollFD descriptor previously added with g_main_context_add_poll()
18618  *
18619  * Removes file descriptor from the set of file descriptors to be
18620  * polled for a particular context.
18621  */
18622
18623
18624 /**
18625  * g_main_context_set_poll_func:
18626  * @context: a #GMainContext
18627  * @func: the function to call to poll all file descriptors
18628  *
18629  * Sets the function to use to handle polling of file descriptors. It
18630  * will be used instead of the poll() system call
18631  * (or GLib's replacement function, which is used where
18632  * poll() isn't available).
18633  *
18634  * This function could possibly be used to integrate the GLib event
18635  * loop with an external event loop.
18636  */
18637
18638
18639 /**
18640  * g_main_context_unref:
18641  * @context: a #GMainContext
18642  *
18643  * Decreases the reference count on a #GMainContext object by one. If
18644  * the result is zero, free the context and free all associated memory.
18645  */
18646
18647
18648 /**
18649  * g_main_context_wait:
18650  * @context: a #GMainContext
18651  * @cond: a condition variable
18652  * @mutex: a mutex, currently held
18653  *
18654  * Tries to become the owner of the specified context,
18655  * as with g_main_context_acquire(). But if another thread
18656  * is the owner, atomically drop @mutex and wait on @cond until
18657  * that owner releases ownership or until @cond is signaled, then
18658  * try again (once) to become the owner.
18659  *
18660  * Returns: %TRUE if the operation succeeded, and this thread is now the owner of @context.
18661  */
18662
18663
18664 /**
18665  * g_main_context_wakeup:
18666  * @context: a #GMainContext
18667  *
18668  * If @context is currently blocking in g_main_context_iteration()
18669  * waiting for a source to become ready, cause it to stop blocking
18670  * and return.  Otherwise, cause the next invocation of
18671  * g_main_context_iteration() to return without blocking.
18672  *
18673  * This API is useful for low-level control over #GMainContext; for
18674  * example, integrating it with main loop implementations such as
18675  * #GMainLoop.
18676  *
18677  * Another related use for this function is when implementing a main
18678  * loop with a termination condition, computed from multiple threads:
18679  *
18680  * |[
18681  *   #define NUM_TASKS 10
18682  *   static volatile gint tasks_remaining = NUM_TASKS;
18683  *   ...
18684  *
18685  *   while (g_atomic_int_get (&tasks_remaining) != 0)
18686  *     g_main_context_iteration (NULL, TRUE);
18687  * ]|
18688  *
18689  * Then in a thread:
18690  * |[
18691  *   perform_work();
18692  *
18693  *   if (g_atomic_int_dec_and_test (&tasks_remaining))
18694  *     g_main_context_wakeup (NULL);
18695  * ]|
18696  */
18697
18698
18699 /**
18700  * g_main_current_source:
18701  *
18702  * Returns the currently firing source for this thread.
18703  *
18704  * Returns: (transfer none): The currently firing source or %NULL.
18705  * Since: 2.12
18706  */
18707
18708
18709 /**
18710  * g_main_depth:
18711  *
18712  * Returns the depth of the stack of calls to
18713  * g_main_context_dispatch() on any #GMainContext in the current thread.
18714  *  That is, when called from the toplevel, it gives 0. When
18715  * called from within a callback from g_main_context_iteration()
18716  * (or g_main_loop_run(), etc.) it returns 1. When called from within
18717  * a callback to a recursive call to g_main_context_iteration(),
18718  * it returns 2. And so forth.
18719  *
18720  * This function is useful in a situation like the following:
18721  * Imagine an extremely simple "garbage collected" system.
18722  *
18723  * |[
18724  * static GList *free_list;
18725  *
18726  * gpointer
18727  * allocate_memory (gsize size)
18728  * {
18729  *   gpointer result = g_malloc (size);
18730  *   free_list = g_list_prepend (free_list, result);
18731  *   return result;
18732  * }
18733  *
18734  * void
18735  * free_allocated_memory (void)
18736  * {
18737  *   GList *l;
18738  *   for (l = free_list; l; l = l->next);
18739  *     g_free (l->data);
18740  *   g_list_free (free_list);
18741  *   free_list = NULL;
18742  *  }
18743  *
18744  * [...]
18745  *
18746  * while (TRUE);
18747  *  {
18748  *    g_main_context_iteration (NULL, TRUE);
18749  *    free_allocated_memory();
18750  *   }
18751  * ]|
18752  *
18753  * This works from an application, however, if you want to do the same
18754  * thing from a library, it gets more difficult, since you no longer
18755  * control the main loop. You might think you can simply use an idle
18756  * function to make the call to free_allocated_memory(), but that
18757  * doesn't work, since the idle function could be called from a
18758  * recursive callback. This can be fixed by using g_main_depth()
18759  *
18760  * |[
18761  * gpointer
18762  * allocate_memory (gsize size)
18763  * {
18764  *   FreeListBlock *block = g_new (FreeListBlock, 1);
18765  *   block->mem = g_malloc (size);
18766  *   block->depth = g_main_depth ();
18767  *   free_list = g_list_prepend (free_list, block);
18768  *   return block->mem;
18769  * }
18770  *
18771  * void
18772  * free_allocated_memory (void)
18773  * {
18774  *   GList *l;
18775  *
18776  *   int depth = g_main_depth ();
18777  *   for (l = free_list; l; );
18778  *     {
18779  *       GList *next = l->next;
18780  *       FreeListBlock *block = l->data;
18781  *       if (block->depth > depth)
18782  *         {
18783  *           g_free (block->mem);
18784  *           g_free (block);
18785  *           free_list = g_list_delete_link (free_list, l);
18786  *         }
18787  *
18788  *       l = next;
18789  *     }
18790  *   }
18791  * ]|
18792  *
18793  * There is a temptation to use g_main_depth() to solve
18794  * problems with reentrancy. For instance, while waiting for data
18795  * to be received from the network in response to a menu item,
18796  * the menu item might be selected again. It might seem that
18797  * one could make the menu item's callback return immediately
18798  * and do nothing if g_main_depth() returns a value greater than 1.
18799  * However, this should be avoided since the user then sees selecting
18800  * the menu item do nothing. Furthermore, you'll find yourself adding
18801  * these checks all over your code, since there are doubtless many,
18802  * many things that the user could do. Instead, you can use the
18803  * following techniques:
18804  *
18805  * <orderedlist>
18806  *  <listitem>
18807  *   <para>
18808  *     Use gtk_widget_set_sensitive() or modal dialogs to prevent
18809  *     the user from interacting with elements while the main
18810  *     loop is recursing.
18811  *   </para>
18812  *  </listitem>
18813  *  <listitem>
18814  *   <para>
18815  *     Avoid main loop recursion in situations where you can't handle
18816  *     arbitrary  callbacks. Instead, structure your code so that you
18817  *     simply return to the main loop and then get called again when
18818  *     there is more work to do.
18819  *   </para>
18820  *  </listitem>
18821  * </orderedlist>
18822  *
18823  * Returns: The main loop recursion level in the current thread
18824  */
18825
18826
18827 /**
18828  * g_main_loop_get_context:
18829  * @loop: a #GMainLoop.
18830  *
18831  * Returns the #GMainContext of @loop.
18832  *
18833  * Returns: (transfer none): the #GMainContext of @loop
18834  */
18835
18836
18837 /**
18838  * g_main_loop_is_running:
18839  * @loop: a #GMainLoop.
18840  *
18841  * Checks to see if the main loop is currently being run via g_main_loop_run().
18842  *
18843  * Returns: %TRUE if the mainloop is currently being run.
18844  */
18845
18846
18847 /**
18848  * g_main_loop_new:
18849  * @context: (allow-none): a #GMainContext  (if %NULL, the default context will be used).
18850  * @is_running: set to %TRUE to indicate that the loop is running. This is not very important since calling g_main_loop_run() will set this to %TRUE anyway.
18851  *
18852  * Creates a new #GMainLoop structure.
18853  *
18854  * Returns: a new #GMainLoop.
18855  */
18856
18857
18858 /**
18859  * g_main_loop_quit:
18860  * @loop: a #GMainLoop
18861  *
18862  * Stops a #GMainLoop from running. Any calls to g_main_loop_run()
18863  * for the loop will return.
18864  *
18865  * Note that sources that have already been dispatched when
18866  * g_main_loop_quit() is called will still be executed.
18867  */
18868
18869
18870 /**
18871  * g_main_loop_ref:
18872  * @loop: a #GMainLoop
18873  *
18874  * Increases the reference count on a #GMainLoop object by one.
18875  *
18876  * Returns: @loop
18877  */
18878
18879
18880 /**
18881  * g_main_loop_run:
18882  * @loop: a #GMainLoop
18883  *
18884  * Runs a main loop until g_main_loop_quit() is called on the loop.
18885  * If this is called for the thread of the loop's #GMainContext,
18886  * it will process events from the loop, otherwise it will
18887  * simply wait.
18888  */
18889
18890
18891 /**
18892  * g_main_loop_unref:
18893  * @loop: a #GMainLoop
18894  *
18895  * Decreases the reference count on a #GMainLoop object by one. If
18896  * the result is zero, free the loop and free all associated memory.
18897  */
18898
18899
18900 /**
18901  * g_malloc:
18902  * @n_bytes: the number of bytes to allocate
18903  *
18904  * Allocates @n_bytes bytes of memory.
18905  * If @n_bytes is 0 it returns %NULL.
18906  *
18907  * Returns: a pointer to the allocated memory
18908  */
18909
18910
18911 /**
18912  * g_malloc0:
18913  * @n_bytes: the number of bytes to allocate
18914  *
18915  * Allocates @n_bytes bytes of memory, initialized to 0's.
18916  * If @n_bytes is 0 it returns %NULL.
18917  *
18918  * Returns: a pointer to the allocated memory
18919  */
18920
18921
18922 /**
18923  * g_malloc0_n:
18924  * @n_blocks: the number of blocks to allocate
18925  * @n_block_bytes: the size of each block in bytes
18926  *
18927  * This function is similar to g_malloc0(), allocating (@n_blocks * @n_block_bytes) bytes,
18928  * but care is taken to detect possible overflow during multiplication.
18929  *
18930  * Since: 2.24
18931  * Returns: a pointer to the allocated memory
18932  */
18933
18934
18935 /**
18936  * g_malloc_n:
18937  * @n_blocks: the number of blocks to allocate
18938  * @n_block_bytes: the size of each block in bytes
18939  *
18940  * This function is similar to g_malloc(), allocating (@n_blocks * @n_block_bytes) bytes,
18941  * but care is taken to detect possible overflow during multiplication.
18942  *
18943  * Since: 2.24
18944  * Returns: a pointer to the allocated memory
18945  */
18946
18947
18948 /**
18949  * g_mapped_file_free:
18950  * @file: a #GMappedFile
18951  *
18952  * This call existed before #GMappedFile had refcounting and is currently
18953  * exactly the same as g_mapped_file_unref().
18954  *
18955  * Since: 2.8
18956  * Deprecated: 2.22: Use g_mapped_file_unref() instead.
18957  */
18958
18959
18960 /**
18961  * g_mapped_file_get_bytes:
18962  * @file: a #GMappedFile
18963  *
18964  * Creates a new #GBytes which references the data mapped from @file.
18965  * The mapped contents of the file must not be modified after creating this
18966  * bytes object, because a #GBytes should be immutable.
18967  *
18968  * Returns: (transfer full): A newly allocated #GBytes referencing data from @file
18969  * Since: 2.34
18970  */
18971
18972
18973 /**
18974  * g_mapped_file_get_contents:
18975  * @file: a #GMappedFile
18976  *
18977  * Returns the contents of a #GMappedFile.
18978  *
18979  * Note that the contents may not be zero-terminated,
18980  * even if the #GMappedFile is backed by a text file.
18981  *
18982  * If the file is empty then %NULL is returned.
18983  *
18984  * Returns: the contents of @file, or %NULL.
18985  * Since: 2.8
18986  */
18987
18988
18989 /**
18990  * g_mapped_file_get_length:
18991  * @file: a #GMappedFile
18992  *
18993  * Returns the length of the contents of a #GMappedFile.
18994  *
18995  * Returns: the length of the contents of @file.
18996  * Since: 2.8
18997  */
18998
18999
19000 /**
19001  * g_mapped_file_new:
19002  * @filename: The path of the file to load, in the GLib filename encoding
19003  * @writable: whether the mapping should be writable
19004  * @error: return location for a #GError, or %NULL
19005  *
19006  * Maps a file into memory. On UNIX, this is using the mmap() function.
19007  *
19008  * If @writable is %TRUE, the mapped buffer may be modified, otherwise
19009  * it is an error to modify the mapped buffer. Modifications to the buffer
19010  * are not visible to other processes mapping the same file, and are not
19011  * written back to the file.
19012  *
19013  * Note that modifications of the underlying file might affect the contents
19014  * of the #GMappedFile. Therefore, mapping should only be used if the file
19015  * will not be modified, or if all modifications of the file are done
19016  * atomically (e.g. using g_file_set_contents()).
19017  *
19018  * If @filename is the name of an empty, regular file, the function
19019  * will successfully return an empty #GMappedFile. In other cases of
19020  * size 0 (e.g. device files such as /dev/null), @error will be set
19021  * to the #GFileError value #G_FILE_ERROR_INVAL.
19022  *
19023  * Returns: a newly allocated #GMappedFile which must be unref'd with g_mapped_file_unref(), or %NULL if the mapping failed.
19024  * Since: 2.8
19025  */
19026
19027
19028 /**
19029  * g_mapped_file_new_from_fd:
19030  * @fd: The file descriptor of the file to load
19031  * @writable: whether the mapping should be writable
19032  * @error: return location for a #GError, or %NULL
19033  *
19034  * Maps a file into memory. On UNIX, this is using the mmap() function.
19035  *
19036  * If @writable is %TRUE, the mapped buffer may be modified, otherwise
19037  * it is an error to modify the mapped buffer. Modifications to the buffer
19038  * are not visible to other processes mapping the same file, and are not
19039  * written back to the file.
19040  *
19041  * Note that modifications of the underlying file might affect the contents
19042  * of the #GMappedFile. Therefore, mapping should only be used if the file
19043  * will not be modified, or if all modifications of the file are done
19044  * atomically (e.g. using g_file_set_contents()).
19045  *
19046  * Returns: a newly allocated #GMappedFile which must be unref'd with g_mapped_file_unref(), or %NULL if the mapping failed.
19047  * Since: 2.32
19048  */
19049
19050
19051 /**
19052  * g_mapped_file_ref:
19053  * @file: a #GMappedFile
19054  *
19055  * Increments the reference count of @file by one.  It is safe to call
19056  * this function from any thread.
19057  *
19058  * Returns: the passed in #GMappedFile.
19059  * Since: 2.22
19060  */
19061
19062
19063 /**
19064  * g_mapped_file_unref:
19065  * @file: a #GMappedFile
19066  *
19067  * Decrements the reference count of @file by one.  If the reference count
19068  * drops to 0, unmaps the buffer of @file and frees it.
19069  *
19070  * It is safe to call this function from any thread.
19071  *
19072  * Since 2.22
19073  */
19074
19075
19076 /**
19077  * g_markup_collect_attributes:
19078  * @element_name: the current tag name
19079  * @attribute_names: the attribute names
19080  * @attribute_values: the attribute values
19081  * @error: a pointer to a #GError or %NULL
19082  * @first_type: the #GMarkupCollectType of the first attribute
19083  * @first_attr: the name of the first attribute
19084  * @...: a pointer to the storage location of the first attribute (or %NULL), followed by more types names and pointers, ending with %G_MARKUP_COLLECT_INVALID
19085  *
19086  * Collects the attributes of the element from the data passed to the
19087  * #GMarkupParser start_element function, dealing with common error
19088  * conditions and supporting boolean values.
19089  *
19090  * This utility function is not required to write a parser but can save
19091  * a lot of typing.
19092  *
19093  * The @element_name, @attribute_names, @attribute_values and @error
19094  * parameters passed to the start_element callback should be passed
19095  * unmodified to this function.
19096  *
19097  * Following these arguments is a list of "supported" attributes to collect.
19098  * It is an error to specify multiple attributes with the same name. If any
19099  * attribute not in the list appears in the @attribute_names array then an
19100  * unknown attribute error will result.
19101  *
19102  * The #GMarkupCollectType field allows specifying the type of collection
19103  * to perform and if a given attribute must appear or is optional.
19104  *
19105  * The attribute name is simply the name of the attribute to collect.
19106  *
19107  * The pointer should be of the appropriate type (see the descriptions
19108  * under #GMarkupCollectType) and may be %NULL in case a particular
19109  * attribute is to be allowed but ignored.
19110  *
19111  * This function deals with issuing errors for missing attributes
19112  * (of type %G_MARKUP_ERROR_MISSING_ATTRIBUTE), unknown attributes
19113  * (of type %G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE) and duplicate
19114  * attributes (of type %G_MARKUP_ERROR_INVALID_CONTENT) as well
19115  * as parse errors for boolean-valued attributes (again of type
19116  * %G_MARKUP_ERROR_INVALID_CONTENT). In all of these cases %FALSE
19117  * will be returned and @error will be set as appropriate.
19118  *
19119  * Returns: %TRUE if successful
19120  * Since: 2.16
19121  */
19122
19123
19124 /**
19125  * g_markup_escape_text:
19126  * @text: some valid UTF-8 text
19127  * @length: length of @text in bytes, or -1 if the text is nul-terminated
19128  *
19129  * Escapes text so that the markup parser will parse it verbatim.
19130  * Less than, greater than, ampersand, etc. are replaced with the
19131  * corresponding entities. This function would typically be used
19132  * when writing out a file to be parsed with the markup parser.
19133  *
19134  * Note that this function doesn't protect whitespace and line endings
19135  * from being processed according to the XML rules for normalization
19136  * of line endings and attribute values.
19137  *
19138  * Note also that this function will produce character references in
19139  * the range of &amp;#x1; ... &amp;#x1f; for all control sequences
19140  * except for tabstop, newline and carriage return.  The character
19141  * references in this range are not valid XML 1.0, but they are
19142  * valid XML 1.1 and will be accepted by the GMarkup parser.
19143  *
19144  * Returns: a newly allocated string with the escaped text
19145  */
19146
19147
19148 /**
19149  * g_markup_parse_context_end_parse:
19150  * @context: a #GMarkupParseContext
19151  * @error: return location for a #GError
19152  *
19153  * Signals to the #GMarkupParseContext that all data has been
19154  * fed into the parse context with g_markup_parse_context_parse().
19155  *
19156  * This function reports an error if the document isn't complete,
19157  * for example if elements are still open.
19158  *
19159  * Returns: %TRUE on success, %FALSE if an error was set
19160  */
19161
19162
19163 /**
19164  * g_markup_parse_context_free:
19165  * @context: a #GMarkupParseContext
19166  *
19167  * Frees a #GMarkupParseContext.
19168  *
19169  * This function can't be called from inside one of the
19170  * #GMarkupParser functions or while a subparser is pushed.
19171  */
19172
19173
19174 /**
19175  * g_markup_parse_context_get_element:
19176  * @context: a #GMarkupParseContext
19177  *
19178  * Retrieves the name of the currently open element.
19179  *
19180  * If called from the start_element or end_element handlers this will
19181  * give the element_name as passed to those functions. For the parent
19182  * elements, see g_markup_parse_context_get_element_stack().
19183  *
19184  * Returns: the name of the currently open element, or %NULL
19185  * Since: 2.2
19186  */
19187
19188
19189 /**
19190  * g_markup_parse_context_get_element_stack:
19191  * @context: a #GMarkupParseContext
19192  *
19193  * Retrieves the element stack from the internal state of the parser.
19194  *
19195  * The returned #GSList is a list of strings where the first item is
19196  * the currently open tag (as would be returned by
19197  * g_markup_parse_context_get_element()) and the next item is its
19198  * immediate parent.
19199  *
19200  * This function is intended to be used in the start_element and
19201  * end_element handlers where g_markup_parse_context_get_element()
19202  * would merely return the name of the element that is being
19203  * processed.
19204  *
19205  * Returns: the element stack, which must not be modified
19206  * Since: 2.16
19207  */
19208
19209
19210 /**
19211  * g_markup_parse_context_get_position:
19212  * @context: a #GMarkupParseContext
19213  * @line_number: (allow-none): return location for a line number, or %NULL
19214  * @char_number: (allow-none): return location for a char-on-line number, or %NULL
19215  *
19216  * Retrieves the current line number and the number of the character on
19217  * that line. Intended for use in error messages; there are no strict
19218  * semantics for what constitutes the "current" line number other than
19219  * "the best number we could come up with for error messages."
19220  */
19221
19222
19223 /**
19224  * g_markup_parse_context_get_user_data:
19225  * @context: a #GMarkupParseContext
19226  *
19227  * Returns the user_data associated with @context.
19228  *
19229  * This will either be the user_data that was provided to
19230  * g_markup_parse_context_new() or to the most recent call
19231  * of g_markup_parse_context_push().
19232  *
19233  * Returns: the provided user_data. The returned data belongs to the markup context and will be freed when g_markup_parse_context_free() is called.
19234  * Since: 2.18
19235  */
19236
19237
19238 /**
19239  * g_markup_parse_context_new:
19240  * @parser: a #GMarkupParser
19241  * @flags: one or more #GMarkupParseFlags
19242  * @user_data: user data to pass to #GMarkupParser functions
19243  * @user_data_dnotify: user data destroy notifier called when the parse context is freed
19244  *
19245  * Creates a new parse context. A parse context is used to parse
19246  * marked-up documents. You can feed any number of documents into
19247  * a context, as long as no errors occur; once an error occurs,
19248  * the parse context can't continue to parse text (you have to
19249  * free it and create a new parse context).
19250  *
19251  * Returns: a new #GMarkupParseContext
19252  */
19253
19254
19255 /**
19256  * g_markup_parse_context_parse:
19257  * @context: a #GMarkupParseContext
19258  * @text: chunk of text to parse
19259  * @text_len: length of @text in bytes
19260  * @error: return location for a #GError
19261  *
19262  * Feed some data to the #GMarkupParseContext.
19263  *
19264  * The data need not be valid UTF-8; an error will be signaled if
19265  * it's invalid. The data need not be an entire document; you can
19266  * feed a document into the parser incrementally, via multiple calls
19267  * to this function. Typically, as you receive data from a network
19268  * connection or file, you feed each received chunk of data into this
19269  * function, aborting the process if an error occurs. Once an error
19270  * is reported, no further data may be fed to the #GMarkupParseContext;
19271  * all errors are fatal.
19272  *
19273  * Returns: %FALSE if an error occurred, %TRUE on success
19274  */
19275
19276
19277 /**
19278  * g_markup_parse_context_pop:
19279  * @context: a #GMarkupParseContext
19280  *
19281  * Completes the process of a temporary sub-parser redirection.
19282  *
19283  * This function exists to collect the user_data allocated by a
19284  * matching call to g_markup_parse_context_push(). It must be called
19285  * in the end_element handler corresponding to the start_element
19286  * handler during which g_markup_parse_context_push() was called.
19287  * You must not call this function from the error callback -- the
19288  * @user_data is provided directly to the callback in that case.
19289  *
19290  * This function is not intended to be directly called by users
19291  * interested in invoking subparsers. Instead, it is intended to
19292  * be used by the subparsers themselves to implement a higher-level
19293  * interface.
19294  *
19295  * Returns: the user data passed to g_markup_parse_context_push()
19296  * Since: 2.18
19297  */
19298
19299
19300 /**
19301  * g_markup_parse_context_push:
19302  * @context: a #GMarkupParseContext
19303  * @parser: a #GMarkupParser
19304  * @user_data: user data to pass to #GMarkupParser functions
19305  *
19306  * Temporarily redirects markup data to a sub-parser.
19307  *
19308  * This function may only be called from the start_element handler of
19309  * a #GMarkupParser. It must be matched with a corresponding call to
19310  * g_markup_parse_context_pop() in the matching end_element handler
19311  * (except in the case that the parser aborts due to an error).
19312  *
19313  * All tags, text and other data between the matching tags is
19314  * redirected to the subparser given by @parser. @user_data is used
19315  * as the user_data for that parser. @user_data is also passed to the
19316  * error callback in the event that an error occurs. This includes
19317  * errors that occur in subparsers of the subparser.
19318  *
19319  * The end tag matching the start tag for which this call was made is
19320  * handled by the previous parser (which is given its own user_data)
19321  * which is why g_markup_parse_context_pop() is provided to allow "one
19322  * last access" to the @user_data provided to this function. In the
19323  * case of error, the @user_data provided here is passed directly to
19324  * the error callback of the subparser and g_markup_parse_context_pop()
19325  * should not be called. In either case, if @user_data was allocated
19326  * then it ought to be freed from both of these locations.
19327  *
19328  * This function is not intended to be directly called by users
19329  * interested in invoking subparsers. Instead, it is intended to be
19330  * used by the subparsers themselves to implement a higher-level
19331  * interface.
19332  *
19333  * As an example, see the following implementation of a simple
19334  * parser that counts the number of tags encountered.
19335  *
19336  * |[
19337  * typedef struct
19338  * {
19339  *   gint tag_count;
19340  * } CounterData;
19341  *
19342  * static void
19343  * counter_start_element (GMarkupParseContext  *context,
19344  *                        const gchar          *element_name,
19345  *                        const gchar         **attribute_names,
19346  *                        const gchar         **attribute_values,
19347  *                        gpointer              user_data,
19348  *                        GError              **error)
19349  * {
19350  *   CounterData *data = user_data;
19351  *
19352  *   data->tag_count++;
19353  * }
19354  *
19355  * static void
19356  * counter_error (GMarkupParseContext *context,
19357  *                GError              *error,
19358  *                gpointer             user_data)
19359  * {
19360  *   CounterData *data = user_data;
19361  *
19362  *   g_slice_free (CounterData, data);
19363  * }
19364  *
19365  * static GMarkupParser counter_subparser =
19366  * {
19367  *   counter_start_element,
19368  *   NULL,
19369  *   NULL,
19370  *   NULL,
19371  *   counter_error
19372  * };
19373  * ]|
19374  *
19375  * In order to allow this parser to be easily used as a subparser, the
19376  * following interface is provided:
19377  *
19378  * |[
19379  * void
19380  * start_counting (GMarkupParseContext *context)
19381  * {
19382  *   CounterData *data = g_slice_new (CounterData);
19383  *
19384  *   data->tag_count = 0;
19385  *   g_markup_parse_context_push (context, &counter_subparser, data);
19386  * }
19387  *
19388  * gint
19389  * end_counting (GMarkupParseContext *context)
19390  * {
19391  *   CounterData *data = g_markup_parse_context_pop (context);
19392  *   int result;
19393  *
19394  *   result = data->tag_count;
19395  *   g_slice_free (CounterData, data);
19396  *
19397  *   return result;
19398  * }
19399  * ]|
19400  *
19401  * The subparser would then be used as follows:
19402  *
19403  * |[
19404  * static void start_element (context, element_name, ...)
19405  * {
19406  *   if (strcmp (element_name, "count-these") == 0)
19407  *     start_counting (context);
19408  *
19409  *   /&ast; else, handle other tags... &ast;/
19410  * }
19411  *
19412  * static void end_element (context, element_name, ...)
19413  * {
19414  *   if (strcmp (element_name, "count-these") == 0)
19415  *     g_print ("Counted %d tags\n", end_counting (context));
19416  *
19417  *   /&ast; else, handle other tags... &ast;/
19418  * }
19419  * ]|
19420  *
19421  * Since: 2.18
19422  */
19423
19424
19425 /**
19426  * g_markup_parse_context_ref:
19427  * @context: a #GMarkupParseContext
19428  *
19429  * Increases the reference count of @context.
19430  *
19431  * Returns: the same @context
19432  * Since: 2.36
19433  */
19434
19435
19436 /**
19437  * g_markup_parse_context_unref:
19438  * @context: a #GMarkupParseContext
19439  *
19440  * Decreases the reference count of @context.  When its reference count
19441  * drops to 0, it is freed.
19442  *
19443  * Since: 2.36
19444  */
19445
19446
19447 /**
19448  * g_markup_printf_escaped:
19449  * @format: printf() style format string
19450  * @...: the arguments to insert in the format string
19451  *
19452  * Formats arguments according to @format, escaping
19453  * all string and character arguments in the fashion
19454  * of g_markup_escape_text(). This is useful when you
19455  * want to insert literal strings into XML-style markup
19456  * output, without having to worry that the strings
19457  * might themselves contain markup.
19458  *
19459  * |[
19460  * const char *store = "Fortnum &amp; Mason";
19461  * const char *item = "Tea";
19462  * char *output;
19463  * &nbsp;
19464  * output = g_markup_printf_escaped ("&lt;purchase&gt;"
19465  *                                   "&lt;store&gt;&percnt;s&lt;/store&gt;"
19466  *                                   "&lt;item&gt;&percnt;s&lt;/item&gt;"
19467  *                                   "&lt;/purchase&gt;",
19468  *                                   store, item);
19469  * ]|
19470  *
19471  * Returns: newly allocated result from formatting operation. Free with g_free().
19472  * Since: 2.4
19473  */
19474
19475
19476 /**
19477  * g_markup_vprintf_escaped:
19478  * @format: printf() style format string
19479  * @args: variable argument list, similar to vprintf()
19480  *
19481  * Formats the data in @args according to @format, escaping
19482  * all string and character arguments in the fashion
19483  * of g_markup_escape_text(). See g_markup_printf_escaped().
19484  *
19485  * Returns: newly allocated result from formatting operation. Free with g_free().
19486  * Since: 2.4
19487  */
19488
19489
19490 /**
19491  * g_match_info_expand_references:
19492  * @match_info: (allow-none): a #GMatchInfo or %NULL
19493  * @string_to_expand: the string to expand
19494  * @error: location to store the error occurring, or %NULL to ignore errors
19495  *
19496  * Returns a new string containing the text in @string_to_expand with
19497  * references and escape sequences expanded. References refer to the last
19498  * match done with @string against @regex and have the same syntax used by
19499  * g_regex_replace().
19500  *
19501  * The @string_to_expand must be UTF-8 encoded even if #G_REGEX_RAW was
19502  * passed to g_regex_new().
19503  *
19504  * The backreferences are extracted from the string passed to the match
19505  * function, so you cannot call this function after freeing the string.
19506  *
19507  * @match_info may be %NULL in which case @string_to_expand must not
19508  * contain references. For instance "foo\n" does not refer to an actual
19509  * pattern and '\n' merely will be replaced with \n character,
19510  * while to expand "\0" (whole match) one needs the result of a match.
19511  * Use g_regex_check_replacement() to find out whether @string_to_expand
19512  * contains references.
19513  *
19514  * Returns: (allow-none): the expanded string, or %NULL if an error occurred
19515  * Since: 2.14
19516  */
19517
19518
19519 /**
19520  * g_match_info_fetch:
19521  * @match_info: #GMatchInfo structure
19522  * @match_num: number of the sub expression
19523  *
19524  * Retrieves the text matching the @match_num<!-- -->'th capturing
19525  * parentheses. 0 is the full text of the match, 1 is the first paren
19526  * set, 2 the second, and so on.
19527  *
19528  * If @match_num is a valid sub pattern but it didn't match anything
19529  * (e.g. sub pattern 1, matching "b" against "(a)?b") then an empty
19530  * string is returned.
19531  *
19532  * If the match was obtained using the DFA algorithm, that is using
19533  * g_regex_match_all() or g_regex_match_all_full(), the retrieved
19534  * string is not that of a set of parentheses but that of a matched
19535  * substring. Substrings are matched in reverse order of length, so
19536  * 0 is the longest match.
19537  *
19538  * The string is fetched from the string passed to the match function,
19539  * so you cannot call this function after freeing the string.
19540  *
19541  * Returns: (allow-none): The matched substring, or %NULL if an error occurred. You have to free the string yourself
19542  * Since: 2.14
19543  */
19544
19545
19546 /**
19547  * g_match_info_fetch_all:
19548  * @match_info: a #GMatchInfo structure
19549  *
19550  * Bundles up pointers to each of the matching substrings from a match
19551  * and stores them in an array of gchar pointers. The first element in
19552  * the returned array is the match number 0, i.e. the entire matched
19553  * text.
19554  *
19555  * If a sub pattern didn't match anything (e.g. sub pattern 1, matching
19556  * "b" against "(a)?b") then an empty string is inserted.
19557  *
19558  * If the last match was obtained using the DFA algorithm, that is using
19559  * g_regex_match_all() or g_regex_match_all_full(), the retrieved
19560  * strings are not that matched by sets of parentheses but that of the
19561  * matched substring. Substrings are matched in reverse order of length,
19562  * so the first one is the longest match.
19563  *
19564  * The strings are fetched from the string passed to the match function,
19565  * so you cannot call this function after freeing the string.
19566  *
19567  * Returns: (transfer full): a %NULL-terminated array of gchar * pointers.  It must be freed using g_strfreev(). If the previous match failed %NULL is returned
19568  * Since: 2.14
19569  */
19570
19571
19572 /**
19573  * g_match_info_fetch_named:
19574  * @match_info: #GMatchInfo structure
19575  * @name: name of the subexpression
19576  *
19577  * Retrieves the text matching the capturing parentheses named @name.
19578  *
19579  * If @name is a valid sub pattern name but it didn't match anything
19580  * (e.g. sub pattern "X", matching "b" against "(?P&lt;X&gt;a)?b")
19581  * then an empty string is returned.
19582  *
19583  * The string is fetched from the string passed to the match function,
19584  * so you cannot call this function after freeing the string.
19585  *
19586  * Returns: (allow-none): The matched substring, or %NULL if an error occurred. You have to free the string yourself
19587  * Since: 2.14
19588  */
19589
19590
19591 /**
19592  * g_match_info_fetch_named_pos:
19593  * @match_info: #GMatchInfo structure
19594  * @name: name of the subexpression
19595  * @start_pos: (out) (allow-none): pointer to location where to store the start position, or %NULL
19596  * @end_pos: (out) (allow-none): pointer to location where to store the end position, or %NULL
19597  *
19598  * Retrieves the position in bytes of the capturing parentheses named @name.
19599  *
19600  * If @name is a valid sub pattern name but it didn't match anything
19601  * (e.g. sub pattern "X", matching "b" against "(?P&lt;X&gt;a)?b")
19602  * then @start_pos and @end_pos are set to -1 and %TRUE is returned.
19603  *
19604  * Returns: %TRUE if the position was fetched, %FALSE otherwise. If the position cannot be fetched, @start_pos and @end_pos are left unchanged.
19605  * Since: 2.14
19606  */
19607
19608
19609 /**
19610  * g_match_info_fetch_pos:
19611  * @match_info: #GMatchInfo structure
19612  * @match_num: number of the sub expression
19613  * @start_pos: (out) (allow-none): pointer to location where to store the start position, or %NULL
19614  * @end_pos: (out) (allow-none): pointer to location where to store the end position, or %NULL
19615  *
19616  * Retrieves the position in bytes of the @match_num<!-- -->'th capturing
19617  * parentheses. 0 is the full text of the match, 1 is the first
19618  * paren set, 2 the second, and so on.
19619  *
19620  * If @match_num is a valid sub pattern but it didn't match anything
19621  * (e.g. sub pattern 1, matching "b" against "(a)?b") then @start_pos
19622  * and @end_pos are set to -1 and %TRUE is returned.
19623  *
19624  * If the match was obtained using the DFA algorithm, that is using
19625  * g_regex_match_all() or g_regex_match_all_full(), the retrieved
19626  * position is not that of a set of parentheses but that of a matched
19627  * substring. Substrings are matched in reverse order of length, so
19628  * 0 is the longest match.
19629  *
19630  * Returns: %TRUE if the position was fetched, %FALSE otherwise. If the position cannot be fetched, @start_pos and @end_pos are left unchanged
19631  * Since: 2.14
19632  */
19633
19634
19635 /**
19636  * g_match_info_free:
19637  * @match_info: (allow-none): a #GMatchInfo, or %NULL
19638  *
19639  * If @match_info is not %NULL, calls g_match_info_unref(); otherwise does
19640  * nothing.
19641  *
19642  * Since: 2.14
19643  */
19644
19645
19646 /**
19647  * g_match_info_get_match_count:
19648  * @match_info: a #GMatchInfo structure
19649  *
19650  * Retrieves the number of matched substrings (including substring 0,
19651  * that is the whole matched text), so 1 is returned if the pattern
19652  * has no substrings in it and 0 is returned if the match failed.
19653  *
19654  * If the last match was obtained using the DFA algorithm, that is
19655  * using g_regex_match_all() or g_regex_match_all_full(), the retrieved
19656  * count is not that of the number of capturing parentheses but that of
19657  * the number of matched substrings.
19658  *
19659  * Returns: Number of matched substrings, or -1 if an error occurred
19660  * Since: 2.14
19661  */
19662
19663
19664 /**
19665  * g_match_info_get_regex:
19666  * @match_info: a #GMatchInfo
19667  *
19668  * Returns #GRegex object used in @match_info. It belongs to Glib
19669  * and must not be freed. Use g_regex_ref() if you need to keep it
19670  * after you free @match_info object.
19671  *
19672  * Returns: #GRegex object used in @match_info
19673  * Since: 2.14
19674  */
19675
19676
19677 /**
19678  * g_match_info_get_string:
19679  * @match_info: a #GMatchInfo
19680  *
19681  * Returns the string searched with @match_info. This is the
19682  * string passed to g_regex_match() or g_regex_replace() so
19683  * you may not free it before calling this function.
19684  *
19685  * Returns: the string searched with @match_info
19686  * Since: 2.14
19687  */
19688
19689
19690 /**
19691  * g_match_info_is_partial_match:
19692  * @match_info: a #GMatchInfo structure
19693  *
19694  * Usually if the string passed to g_regex_match*() matches as far as
19695  * it goes, but is too short to match the entire pattern, %FALSE is
19696  * returned. There are circumstances where it might be helpful to
19697  * distinguish this case from other cases in which there is no match.
19698  *
19699  * Consider, for example, an application where a human is required to
19700  * type in data for a field with specific formatting requirements. An
19701  * example might be a date in the form ddmmmyy, defined by the pattern
19702  * "^\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d$".
19703  * If the application sees the user’s keystrokes one by one, and can
19704  * check that what has been typed so far is potentially valid, it is
19705  * able to raise an error as soon as a mistake is made.
19706  *
19707  * GRegex supports the concept of partial matching by means of the
19708  * #G_REGEX_MATCH_PARTIAL_SOFT and #G_REGEX_MATCH_PARTIAL_HARD flags.
19709  * When they are used, the return code for
19710  * g_regex_match() or g_regex_match_full() is, as usual, %TRUE
19711  * for a complete match, %FALSE otherwise. But, when these functions
19712  * return %FALSE, you can check if the match was partial calling
19713  * g_match_info_is_partial_match().
19714  *
19715  * The difference between #G_REGEX_MATCH_PARTIAL_SOFT and
19716  * #G_REGEX_MATCH_PARTIAL_HARD is that when a partial match is encountered
19717  * with #G_REGEX_MATCH_PARTIAL_SOFT, matching continues to search for a
19718  * possible complete match, while with #G_REGEX_MATCH_PARTIAL_HARD matching
19719  * stops at the partial match.
19720  * When both #G_REGEX_MATCH_PARTIAL_SOFT and #G_REGEX_MATCH_PARTIAL_HARD
19721  * are set, the latter takes precedence.
19722  *
19723  * There were formerly some restrictions on the pattern for partial matching.
19724  * The restrictions no longer apply.
19725  *
19726  * See <ulink>man:pcrepartial</ulink> for more information on partial matching.
19727  *
19728  * Returns: %TRUE if the match was partial, %FALSE otherwise
19729  * Since: 2.14
19730  */
19731
19732
19733 /**
19734  * g_match_info_matches:
19735  * @match_info: a #GMatchInfo structure
19736  *
19737  * Returns whether the previous match operation succeeded.
19738  *
19739  * Returns: %TRUE if the previous match operation succeeded, %FALSE otherwise
19740  * Since: 2.14
19741  */
19742
19743
19744 /**
19745  * g_match_info_next:
19746  * @match_info: a #GMatchInfo structure
19747  * @error: location to store the error occurring, or %NULL to ignore errors
19748  *
19749  * Scans for the next match using the same parameters of the previous
19750  * call to g_regex_match_full() or g_regex_match() that returned
19751  * @match_info.
19752  *
19753  * The match is done on the string passed to the match function, so you
19754  * cannot free it before calling this function.
19755  *
19756  * Returns: %TRUE is the string matched, %FALSE otherwise
19757  * Since: 2.14
19758  */
19759
19760
19761 /**
19762  * g_match_info_ref:
19763  * @match_info: a #GMatchInfo
19764  *
19765  * Increases reference count of @match_info by 1.
19766  *
19767  * Returns: @match_info
19768  * Since: 2.30
19769  */
19770
19771
19772 /**
19773  * g_match_info_unref:
19774  * @match_info: a #GMatchInfo
19775  *
19776  * Decreases reference count of @match_info by 1. When reference count drops
19777  * to zero, it frees all the memory associated with the match_info structure.
19778  *
19779  * Since: 2.30
19780  */
19781
19782
19783 /**
19784  * g_mem_gc_friendly:
19785  *
19786  * This variable is %TRUE if the <envar>G_DEBUG</envar> environment variable
19787  * includes the key <literal>gc-friendly</literal>.
19788  */
19789
19790
19791 /**
19792  * g_mem_is_system_malloc:
19793  *
19794  * Checks whether the allocator used by g_malloc() is the system's
19795  * malloc implementation. If it returns %TRUE memory allocated with
19796  * malloc() can be used interchangeable with memory allocated using g_malloc().
19797  * This function is useful for avoiding an extra copy of allocated memory returned
19798  * by a non-GLib-based API.
19799  *
19800  * A different allocator can be set using g_mem_set_vtable().
19801  *
19802  * Returns: if %TRUE, malloc() and g_malloc() can be mixed.
19803  */
19804
19805
19806 /**
19807  * g_mem_profile:
19808  *
19809  * Outputs a summary of memory usage.
19810  *
19811  * It outputs the frequency of allocations of different sizes,
19812  * the total number of bytes which have been allocated,
19813  * the total number of bytes which have been freed,
19814  * and the difference between the previous two values, i.e. the number of bytes
19815  * still in use.
19816  *
19817  * Note that this function will not output anything unless you have
19818  * previously installed the #glib_mem_profiler_table with g_mem_set_vtable().
19819  */
19820
19821
19822 /**
19823  * g_mem_set_vtable:
19824  * @vtable: table of memory allocation routines.
19825  *
19826  * Sets the #GMemVTable to use for memory allocation. You can use this to provide
19827  * custom memory allocation routines. <emphasis>This function must be called
19828  * before using any other GLib functions.</emphasis> The @vtable only needs to
19829  * provide malloc(), realloc(), and free() functions; GLib can provide default
19830  * implementations of the others. The malloc() and realloc() implementations
19831  * should return %NULL on failure, GLib will handle error-checking for you.
19832  * @vtable is copied, so need not persist after this function has been called.
19833  */
19834
19835
19836 /**
19837  * g_memdup:
19838  * @mem: the memory to copy.
19839  * @byte_size: the number of bytes to copy.
19840  *
19841  * Allocates @byte_size bytes of memory, and copies @byte_size bytes into it
19842  * from @mem. If @mem is %NULL it returns %NULL.
19843  *
19844  * Returns: a pointer to the newly-allocated copy of the memory, or %NULL if @mem is %NULL.
19845  */
19846
19847
19848 /**
19849  * g_memmove:
19850  * @dest: the destination address to copy the bytes to.
19851  * @src: the source address to copy the bytes from.
19852  * @len: the number of bytes to copy.
19853  *
19854  * Copies a block of memory @len bytes long, from @src to @dest.
19855  * The source and destination areas may overlap.
19856  *
19857  * In order to use this function, you must include
19858  * <filename>string.h</filename> yourself, because this macro will
19859  * typically simply resolve to memmove() and GLib does not include
19860  * <filename>string.h</filename> for you.
19861  */
19862
19863
19864 /**
19865  * g_message:
19866  * @...: format string, followed by parameters to insert into the format string (as with printf())
19867  *
19868  * A convenience function/macro to log a normal message.
19869  */
19870
19871
19872 /**
19873  * g_mkdir:
19874  * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
19875  * @mode: permissions to use for the newly created directory
19876  *
19877  * A wrapper for the POSIX mkdir() function. The mkdir() function
19878  * attempts to create a directory with the given name and permissions.
19879  * The mode argument is ignored on Windows.
19880  *
19881  * See your C library manual for more details about mkdir().
19882  *
19883  * Returns: 0 if the directory was successfully created, -1 if an error occurred
19884  * Since: 2.6
19885  */
19886
19887
19888 /**
19889  * g_mkdir_with_parents:
19890  * @pathname: a pathname in the GLib file name encoding
19891  * @mode: permissions to use for newly created directories
19892  *
19893  * Create a directory if it doesn't already exist. Create intermediate
19894  * parent directories as needed, too.
19895  *
19896  * Returns: 0 if the directory already exists, or was successfully created. Returns -1 if an error occurred, with errno set.
19897  * Since: 2.8
19898  */
19899
19900
19901 /**
19902  * g_mkdtemp:
19903  * @tmpl: (type filename): template directory name
19904  *
19905  * Creates a temporary directory. See the mkdtemp() documentation
19906  * on most UNIX-like systems.
19907  *
19908  * The parameter is a string that should follow the rules for
19909  * mkdtemp() templates, i.e. contain the string "XXXXXX".
19910  * g_mkdtemp() is slightly more flexible than mkdtemp() in that the
19911  * sequence does not have to occur at the very end of the template
19912  * and you can pass a @mode and additional @flags. The X string will
19913  * be modified to form the name of a directory that didn't exist.
19914  * The string should be in the GLib file name encoding. Most importantly,
19915  * on Windows it should be in UTF-8.
19916  *
19917  * Returns: A pointer to @tmpl, which has been modified to hold the directory name.  In case of errors, %NULL is returned and %errno will be set.
19918  * Since: 2.30
19919  */
19920
19921
19922 /**
19923  * g_mkdtemp_full:
19924  * @tmpl: (type filename): template directory name
19925  * @mode: permissions to create the temporary directory with
19926  *
19927  * Creates a temporary directory. See the mkdtemp() documentation
19928  * on most UNIX-like systems.
19929  *
19930  * The parameter is a string that should follow the rules for
19931  * mkdtemp() templates, i.e. contain the string "XXXXXX".
19932  * g_mkdtemp() is slightly more flexible than mkdtemp() in that the
19933  * sequence does not have to occur at the very end of the template
19934  * and you can pass a @mode. The X string will be modified to form
19935  * the name of a directory that didn't exist. The string should be
19936  * in the GLib file name encoding. Most importantly, on Windows it
19937  * should be in UTF-8.
19938  *
19939  * Returns: A pointer to @tmpl, which has been modified to hold the directory name. In case of errors, %NULL is returned, and %errno will be set.
19940  * Since: 2.30
19941  */
19942
19943
19944 /**
19945  * g_mkstemp:
19946  * @tmpl: (type filename): template filename
19947  *
19948  * Opens a temporary file. See the mkstemp() documentation
19949  * on most UNIX-like systems.
19950  *
19951  * The parameter is a string that should follow the rules for
19952  * mkstemp() templates, i.e. contain the string "XXXXXX".
19953  * g_mkstemp() is slightly more flexible than mkstemp() in that the
19954  * sequence does not have to occur at the very end of the template.
19955  * The X string will be modified to form the name of a file that
19956  * didn't exist. The string should be in the GLib file name encoding.
19957  * Most importantly, on Windows it should be in UTF-8.
19958  *
19959  * Returns: A file handle (as from open()) to the file opened for reading and writing. The file is opened in binary mode on platforms where there is a difference. The file handle should be closed with close(). In case of errors, -1 is returned and %errno will be set.
19960  */
19961
19962
19963 /**
19964  * g_mkstemp_full:
19965  * @tmpl: (type filename): template filename
19966  * @flags: flags to pass to an open() call in addition to O_EXCL and O_CREAT, which are passed automatically
19967  * @mode: permissions to create the temporary file with
19968  *
19969  * Opens a temporary file. See the mkstemp() documentation
19970  * on most UNIX-like systems.
19971  *
19972  * The parameter is a string that should follow the rules for
19973  * mkstemp() templates, i.e. contain the string "XXXXXX".
19974  * g_mkstemp_full() is slightly more flexible than mkstemp()
19975  * in that the sequence does not have to occur at the very end of the
19976  * template and you can pass a @mode and additional @flags. The X
19977  * string will be modified to form the name of a file that didn't exist.
19978  * The string should be in the GLib file name encoding. Most importantly,
19979  * on Windows it should be in UTF-8.
19980  *
19981  * Returns: A file handle (as from open()) to the file opened for reading and writing. The file handle should be closed with close(). In case of errors, -1 is returned and %errno will be set.
19982  * Since: 2.22
19983  */
19984
19985
19986 /**
19987  * g_mutex_clear:
19988  * @mutex: an initialized #GMutex
19989  *
19990  * Frees the resources allocated to a mutex with g_mutex_init().
19991  *
19992  * This function should not be used with a #GMutex that has been
19993  * statically allocated.
19994  *
19995  * Calling g_mutex_clear() on a locked mutex leads to undefined
19996  * behaviour.
19997  *
19998  * Sine: 2.32
19999  */
20000
20001
20002 /**
20003  * g_mutex_init:
20004  * @mutex: an uninitialized #GMutex
20005  *
20006  * Initializes a #GMutex so that it can be used.
20007  *
20008  * This function is useful to initialize a mutex that has been
20009  * allocated on the stack, or as part of a larger structure.
20010  * It is not necessary to initialize a mutex that has been
20011  * statically allocated.
20012  *
20013  * |[
20014  *   typedef struct {
20015  *     GMutex m;
20016  *     ...
20017  *   } Blob;
20018  *
20019  * Blob *b;
20020  *
20021  * b = g_new (Blob, 1);
20022  * g_mutex_init (&b->m);
20023  * ]|
20024  *
20025  * To undo the effect of g_mutex_init() when a mutex is no longer
20026  * needed, use g_mutex_clear().
20027  *
20028  * Calling g_mutex_init() on an already initialized #GMutex leads
20029  * to undefined behaviour.
20030  *
20031  * Since: 2.32
20032  */
20033
20034
20035 /**
20036  * g_mutex_lock:
20037  * @mutex: a #GMutex
20038  *
20039  * Locks @mutex. If @mutex is already locked by another thread, the
20040  * current thread will block until @mutex is unlocked by the other
20041  * thread.
20042  *
20043  * <note>#GMutex is neither guaranteed to be recursive nor to be
20044  * non-recursive.  As such, calling g_mutex_lock() on a #GMutex that has
20045  * already been locked by the same thread results in undefined behaviour
20046  * (including but not limited to deadlocks).</note>
20047  */
20048
20049
20050 /**
20051  * g_mutex_trylock:
20052  * @mutex: a #GMutex
20053  *
20054  * Tries to lock @mutex. If @mutex is already locked by another thread,
20055  * it immediately returns %FALSE. Otherwise it locks @mutex and returns
20056  * %TRUE.
20057  *
20058  * <note>#GMutex is neither guaranteed to be recursive nor to be
20059  * non-recursive.  As such, calling g_mutex_lock() on a #GMutex that has
20060  * already been locked by the same thread results in undefined behaviour
20061  * (including but not limited to deadlocks or arbitrary return values).
20062  * </note>
20063  *
20064  * Returns: %TRUE if @mutex could be locked
20065  */
20066
20067
20068 /**
20069  * g_mutex_unlock:
20070  * @mutex: a #GMutex
20071  *
20072  * Unlocks @mutex. If another thread is blocked in a g_mutex_lock()
20073  * call for @mutex, it will become unblocked and can lock @mutex itself.
20074  *
20075  * Calling g_mutex_unlock() on a mutex that is not locked by the
20076  * current thread leads to undefined behaviour.
20077  */
20078
20079
20080 /**
20081  * g_node_child_index:
20082  * @node: a #GNode
20083  * @data: the data to find
20084  *
20085  * Gets the position of the first child of a #GNode
20086  * which contains the given data.
20087  *
20088  * Returns: the index of the child of @node which contains @data, or -1 if the data is not found
20089  */
20090
20091
20092 /**
20093  * g_node_child_position:
20094  * @node: a #GNode
20095  * @child: a child of @node
20096  *
20097  * Gets the position of a #GNode with respect to its siblings.
20098  * @child must be a child of @node. The first child is numbered 0,
20099  * the second 1, and so on.
20100  *
20101  * Returns: the position of @child with respect to its siblings
20102  */
20103
20104
20105 /**
20106  * g_node_children_foreach:
20107  * @node: a #GNode
20108  * @flags: which types of children are to be visited, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
20109  * @func: the function to call for each visited node
20110  * @data: user data to pass to the function
20111  *
20112  * Calls a function for each of the children of a #GNode.
20113  * Note that it doesn't descend beneath the child nodes.
20114  */
20115
20116
20117 /**
20118  * g_node_copy:
20119  * @node: a #GNode
20120  *
20121  * Recursively copies a #GNode (but does not deep-copy the data inside the
20122  * nodes, see g_node_copy_deep() if you need that).
20123  *
20124  * Returns: a new #GNode containing the same data pointers
20125  */
20126
20127
20128 /**
20129  * g_node_copy_deep:
20130  * @node: a #GNode
20131  * @copy_func: the function which is called to copy the data inside each node, or %NULL to use the original data.
20132  * @data: data to pass to @copy_func
20133  *
20134  * Recursively copies a #GNode and its data.
20135  *
20136  * Returns: a new #GNode containing copies of the data in @node.
20137  * Since: 2.4
20138  */
20139
20140
20141 /**
20142  * g_node_depth:
20143  * @node: a #GNode
20144  *
20145  * Gets the depth of a #GNode.
20146  *
20147  * If @node is %NULL the depth is 0. The root node has a depth of 1.
20148  * For the children of the root node the depth is 2. And so on.
20149  *
20150  * Returns: the depth of the #GNode
20151  */
20152
20153
20154 /**
20155  * g_node_destroy:
20156  * @root: the root of the tree/subtree to destroy
20157  *
20158  * Removes @root and its children from the tree, freeing any memory
20159  * allocated.
20160  */
20161
20162
20163 /**
20164  * g_node_find:
20165  * @root: the root #GNode of the tree to search
20166  * @order: the order in which nodes are visited - %G_IN_ORDER, %G_PRE_ORDER, %G_POST_ORDER, or %G_LEVEL_ORDER
20167  * @flags: which types of children are to be searched, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
20168  * @data: the data to find
20169  *
20170  * Finds a #GNode in a tree.
20171  *
20172  * Returns: the found #GNode, or %NULL if the data is not found
20173  */
20174
20175
20176 /**
20177  * g_node_find_child:
20178  * @node: a #GNode
20179  * @flags: which types of children are to be searched, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
20180  * @data: the data to find
20181  *
20182  * Finds the first child of a #GNode with the given data.
20183  *
20184  * Returns: the found child #GNode, or %NULL if the data is not found
20185  */
20186
20187
20188 /**
20189  * g_node_first_sibling:
20190  * @node: a #GNode
20191  *
20192  * Gets the first sibling of a #GNode.
20193  * This could possibly be the node itself.
20194  *
20195  * Returns: the first sibling of @node
20196  */
20197
20198
20199 /**
20200  * g_node_get_root:
20201  * @node: a #GNode
20202  *
20203  * Gets the root of a tree.
20204  *
20205  * Returns: the root of the tree
20206  */
20207
20208
20209 /**
20210  * g_node_insert:
20211  * @parent: the #GNode to place @node under
20212  * @position: the position to place @node at, with respect to its siblings If position is -1, @node is inserted as the last child of @parent
20213  * @node: the #GNode to insert
20214  *
20215  * Inserts a #GNode beneath the parent at the given position.
20216  *
20217  * Returns: the inserted #GNode
20218  */
20219
20220
20221 /**
20222  * g_node_insert_after:
20223  * @parent: the #GNode to place @node under
20224  * @sibling: the sibling #GNode to place @node after. If sibling is %NULL, the node is inserted as the first child of @parent.
20225  * @node: the #GNode to insert
20226  *
20227  * Inserts a #GNode beneath the parent after the given sibling.
20228  *
20229  * Returns: the inserted #GNode
20230  */
20231
20232
20233 /**
20234  * g_node_insert_before:
20235  * @parent: the #GNode to place @node under
20236  * @sibling: the sibling #GNode to place @node before. If sibling is %NULL, the node is inserted as the last child of @parent.
20237  * @node: the #GNode to insert
20238  *
20239  * Inserts a #GNode beneath the parent before the given sibling.
20240  *
20241  * Returns: the inserted #GNode
20242  */
20243
20244
20245 /**
20246  * g_node_is_ancestor:
20247  * @node: a #GNode
20248  * @descendant: a #GNode
20249  *
20250  * Returns %TRUE if @node is an ancestor of @descendant.
20251  * This is true if node is the parent of @descendant,
20252  * or if node is the grandparent of @descendant etc.
20253  *
20254  * Returns: %TRUE if @node is an ancestor of @descendant
20255  */
20256
20257
20258 /**
20259  * g_node_last_child:
20260  * @node: a #GNode (must not be %NULL)
20261  *
20262  * Gets the last child of a #GNode.
20263  *
20264  * Returns: the last child of @node, or %NULL if @node has no children
20265  */
20266
20267
20268 /**
20269  * g_node_last_sibling:
20270  * @node: a #GNode
20271  *
20272  * Gets the last sibling of a #GNode.
20273  * This could possibly be the node itself.
20274  *
20275  * Returns: the last sibling of @node
20276  */
20277
20278
20279 /**
20280  * g_node_max_height:
20281  * @root: a #GNode
20282  *
20283  * Gets the maximum height of all branches beneath a #GNode.
20284  * This is the maximum distance from the #GNode to all leaf nodes.
20285  *
20286  * If @root is %NULL, 0 is returned. If @root has no children,
20287  * 1 is returned. If @root has children, 2 is returned. And so on.
20288  *
20289  * Returns: the maximum height of the tree beneath @root
20290  */
20291
20292
20293 /**
20294  * g_node_n_children:
20295  * @node: a #GNode
20296  *
20297  * Gets the number of children of a #GNode.
20298  *
20299  * Returns: the number of children of @node
20300  */
20301
20302
20303 /**
20304  * g_node_n_nodes:
20305  * @root: a #GNode
20306  * @flags: which types of children are to be counted, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
20307  *
20308  * Gets the number of nodes in a tree.
20309  *
20310  * Returns: the number of nodes in the tree
20311  */
20312
20313
20314 /**
20315  * g_node_new:
20316  * @data: the data of the new node
20317  *
20318  * Creates a new #GNode containing the given data.
20319  * Used to create the first node in a tree.
20320  *
20321  * Returns: a new #GNode
20322  */
20323
20324
20325 /**
20326  * g_node_nth_child:
20327  * @node: a #GNode
20328  * @n: the index of the desired child
20329  *
20330  * Gets a child of a #GNode, using the given index.
20331  * The first child is at index 0. If the index is
20332  * too big, %NULL is returned.
20333  *
20334  * Returns: the child of @node at index @n
20335  */
20336
20337
20338 /**
20339  * g_node_prepend:
20340  * @parent: the #GNode to place the new #GNode under
20341  * @node: the #GNode to insert
20342  *
20343  * Inserts a #GNode as the first child of the given parent.
20344  *
20345  * Returns: the inserted #GNode
20346  */
20347
20348
20349 /**
20350  * g_node_reverse_children:
20351  * @node: a #GNode.
20352  *
20353  * Reverses the order of the children of a #GNode.
20354  * (It doesn't change the order of the grandchildren.)
20355  */
20356
20357
20358 /**
20359  * g_node_traverse:
20360  * @root: the root #GNode of the tree to traverse
20361  * @order: the order in which nodes are visited - %G_IN_ORDER, %G_PRE_ORDER, %G_POST_ORDER, or %G_LEVEL_ORDER.
20362  * @flags: which types of children are to be visited, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
20363  * @max_depth: the maximum depth of the traversal. Nodes below this depth will not be visited. If max_depth is -1 all nodes in the tree are visited. If depth is 1, only the root is visited. If depth is 2, the root and its children are visited. And so on.
20364  * @func: the function to call for each visited #GNode
20365  * @data: user data to pass to the function
20366  *
20367  * Traverses a tree starting at the given root #GNode.
20368  * It calls the given function for each node visited.
20369  * The traversal can be halted at any point by returning %TRUE from @func.
20370  */
20371
20372
20373 /**
20374  * g_node_unlink:
20375  * @node: the #GNode to unlink, which becomes the root of a new tree
20376  *
20377  * Unlinks a #GNode from a tree, resulting in two separate trees.
20378  */
20379
20380
20381 /**
20382  * g_ntohl:
20383  * @val: a 32-bit integer value in network byte order
20384  *
20385  * Converts a 32-bit integer value from network to host byte order.
20386  *
20387  * Returns: @val converted to host byte order.
20388  */
20389
20390
20391 /**
20392  * g_ntohs:
20393  * @val: a 16-bit integer value in network byte order
20394  *
20395  * Converts a 16-bit integer value from network to host byte order.
20396  *
20397  * Returns: @val converted to host byte order
20398  */
20399
20400
20401 /**
20402  * g_nullify_pointer:
20403  * @nullify_location: the memory address of the pointer.
20404  *
20405  * Set the pointer at the specified location to %NULL.
20406  */
20407
20408
20409 /**
20410  * g_on_error_query:
20411  * @prg_name: the program name, needed by <command>gdb</command> for the [S]tack trace option. If @prg_name is %NULL, g_get_prgname() is called to get the program name (which will work correctly if gdk_init() or gtk_init() has been called)
20412  *
20413  * Prompts the user with
20414  * <computeroutput>[E]xit, [H]alt, show [S]tack trace or [P]roceed</computeroutput>.
20415  * This function is intended to be used for debugging use only.
20416  * The following example shows how it can be used together with
20417  * the g_log() functions.
20418  *
20419  * |[
20420  * &num;include &lt;glib.h&gt;
20421  *
20422  * static void
20423  * log_handler (const gchar   *log_domain,
20424  *              GLogLevelFlags log_level,
20425  *              const gchar   *message,
20426  *              gpointer       user_data)
20427  * {
20428  *   g_log_default_handler (log_domain, log_level, message, user_data);
20429  *
20430  *   g_on_error_query (MY_PROGRAM_NAME);
20431  * }
20432  *
20433  * int
20434  * main (int argc, char *argv[])
20435  * {
20436  *   g_log_set_handler (MY_LOG_DOMAIN,
20437  *                      G_LOG_LEVEL_WARNING |
20438  *                      G_LOG_LEVEL_ERROR |
20439  *                      G_LOG_LEVEL_CRITICAL,
20440  *                      log_handler,
20441  *                      NULL);
20442  *   /&ast; ... &ast;/
20443  * ]|
20444  *
20445  * If [E]xit is selected, the application terminates with a call
20446  * to <literal>_exit(0)</literal>.
20447  *
20448  * If [S]tack trace is selected, g_on_error_stack_trace() is called.
20449  * This invokes <command>gdb</command>, which attaches to the current
20450  * process and shows a stack trace. The prompt is then shown again.
20451  *
20452  * If [P]roceed is selected, the function returns.
20453  *
20454  * This function may cause different actions on non-UNIX platforms.
20455  */
20456
20457
20458 /**
20459  * g_on_error_stack_trace:
20460  * @prg_name: the program name, needed by <command>gdb</command> for the [S]tack trace option.
20461  *
20462  * Invokes <command>gdb</command>, which attaches to the current
20463  * process and shows a stack trace. Called by g_on_error_query()
20464  * when the [S]tack trace option is selected. You can get the current
20465  * process's "program name" with g_get_prgname(), assuming that you
20466  * have called gtk_init() or gdk_init().
20467  *
20468  * This function may cause different actions on non-UNIX platforms.
20469  */
20470
20471
20472 /**
20473  * g_once:
20474  * @once: a #GOnce structure
20475  * @func: the #GThreadFunc function associated to @once. This function is called only once, regardless of the number of times it and its associated #GOnce struct are passed to g_once().
20476  * @arg: data to be passed to @func
20477  *
20478  * The first call to this routine by a process with a given #GOnce
20479  * struct calls @func with the given argument. Thereafter, subsequent
20480  * calls to g_once()  with the same #GOnce struct do not call @func
20481  * again, but return the stored result of the first call. On return
20482  * from g_once(), the status of @once will be %G_ONCE_STATUS_READY.
20483  *
20484  * For example, a mutex or a thread-specific data key must be created
20485  * exactly once. In a threaded environment, calling g_once() ensures
20486  * that the initialization is serialized across multiple threads.
20487  *
20488  * Calling g_once() recursively on the same #GOnce struct in
20489  * @func will lead to a deadlock.
20490  *
20491  * |[
20492  *   gpointer
20493  *   get_debug_flags (void)
20494  *   {
20495  *     static GOnce my_once = G_ONCE_INIT;
20496  *
20497  *     g_once (&my_once, parse_debug_flags, NULL);
20498  *
20499  *     return my_once.retval;
20500  *   }
20501  * ]|
20502  *
20503  * Since: 2.4
20504  */
20505
20506
20507 /**
20508  * g_once_init_enter:
20509  * @location: location of a static initializable variable containing 0
20510  *
20511  * Function to be called when starting a critical initialization
20512  * section. The argument @location must point to a static
20513  * 0-initialized variable that will be set to a value other than 0 at
20514  * the end of the initialization section. In combination with
20515  * g_once_init_leave() and the unique address @value_location, it can
20516  * be ensured that an initialization section will be executed only once
20517  * during a program's life time, and that concurrent threads are
20518  * blocked until initialization completed. To be used in constructs
20519  * like this:
20520  *
20521  * |[
20522  *   static gsize initialization_value = 0;
20523  *
20524  *   if (g_once_init_enter (&amp;initialization_value))
20525  *     {
20526  *       gsize setup_value = 42; /&ast;* initialization code here *&ast;/
20527  *
20528  *       g_once_init_leave (&amp;initialization_value, setup_value);
20529  *     }
20530  *
20531  *   /&ast;* use initialization_value here *&ast;/
20532  * ]|
20533  *
20534  * Returns: %TRUE if the initialization section should be entered, %FALSE and blocks otherwise
20535  * Since: 2.14
20536  */
20537
20538
20539 /**
20540  * g_once_init_leave:
20541  * @location: location of a static initializable variable containing 0
20542  * @result: new non-0 value for *@value_location
20543  *
20544  * Counterpart to g_once_init_enter(). Expects a location of a static
20545  * 0-initialized initialization variable, and an initialization value
20546  * other than 0. Sets the variable to the initialization value, and
20547  * releases concurrent threads blocking in g_once_init_enter() on this
20548  * initialization variable.
20549  *
20550  * Since: 2.14
20551  */
20552
20553
20554 /**
20555  * g_open:
20556  * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
20557  * @flags: as in open()
20558  * @mode: as in open()
20559  *
20560  * A wrapper for the POSIX open() function. The open() function is
20561  * used to convert a pathname into a file descriptor.
20562  *
20563  * On POSIX systems file descriptors are implemented by the operating
20564  * system. On Windows, it's the C library that implements open() and
20565  * file descriptors. The actual Win32 API for opening files is quite
20566  * different, see MSDN documentation for CreateFile(). The Win32 API
20567  * uses file handles, which are more randomish integers, not small
20568  * integers like file descriptors.
20569  *
20570  * Because file descriptors are specific to the C library on Windows,
20571  * the file descriptor returned by this function makes sense only to
20572  * functions in the same C library. Thus if the GLib-using code uses a
20573  * different C library than GLib does, the file descriptor returned by
20574  * this function cannot be passed to C library functions like write()
20575  * or read().
20576  *
20577  * See your C library manual for more details about open().
20578  *
20579  * Returns: a new file descriptor, or -1 if an error occurred. The return value can be used exactly like the return value from open().
20580  * Since: 2.6
20581  */
20582
20583
20584 /**
20585  * g_option_context_add_group:
20586  * @context: a #GOptionContext
20587  * @group: the group to add
20588  *
20589  * Adds a #GOptionGroup to the @context, so that parsing with @context
20590  * will recognize the options in the group. Note that the group will
20591  * be freed together with the context when g_option_context_free() is
20592  * called, so you must not free the group yourself after adding it
20593  * to a context.
20594  *
20595  * Since: 2.6
20596  */
20597
20598
20599 /**
20600  * g_option_context_add_main_entries:
20601  * @context: a #GOptionContext
20602  * @entries: a %NULL-terminated array of #GOptionEntry<!-- -->s
20603  * @translation_domain: (allow-none): a translation domain to use for translating the <option>--help</option> output for the options in @entries with gettext(), or %NULL
20604  *
20605  * A convenience function which creates a main group if it doesn't
20606  * exist, adds the @entries to it and sets the translation domain.
20607  *
20608  * Since: 2.6
20609  */
20610
20611
20612 /**
20613  * g_option_context_free:
20614  * @context: a #GOptionContext
20615  *
20616  * Frees context and all the groups which have been
20617  * added to it.
20618  *
20619  * Please note that parsed arguments need to be freed separately (see
20620  * #GOptionEntry).
20621  *
20622  * Since: 2.6
20623  */
20624
20625
20626 /**
20627  * g_option_context_get_description:
20628  * @context: a #GOptionContext
20629  *
20630  * Returns the description. See g_option_context_set_description().
20631  *
20632  * Returns: the description
20633  * Since: 2.12
20634  */
20635
20636
20637 /**
20638  * g_option_context_get_help:
20639  * @context: a #GOptionContext
20640  * @main_help: if %TRUE, only include the main group
20641  * @group: (allow-none): the #GOptionGroup to create help for, or %NULL
20642  *
20643  * Returns a formatted, translated help text for the given context.
20644  * To obtain the text produced by <option>--help</option>, call
20645  * <literal>g_option_context_get_help (context, TRUE, NULL)</literal>.
20646  * To obtain the text produced by <option>--help-all</option>, call
20647  * <literal>g_option_context_get_help (context, FALSE, NULL)</literal>.
20648  * To obtain the help text for an option group, call
20649  * <literal>g_option_context_get_help (context, FALSE, group)</literal>.
20650  *
20651  * Returns: A newly allocated string containing the help text
20652  * Since: 2.14
20653  */
20654
20655
20656 /**
20657  * g_option_context_get_help_enabled:
20658  * @context: a #GOptionContext
20659  *
20660  * Returns whether automatic <option>--help</option> generation
20661  * is turned on for @context. See g_option_context_set_help_enabled().
20662  *
20663  * Returns: %TRUE if automatic help generation is turned on.
20664  * Since: 2.6
20665  */
20666
20667
20668 /**
20669  * g_option_context_get_ignore_unknown_options:
20670  * @context: a #GOptionContext
20671  *
20672  * Returns whether unknown options are ignored or not. See
20673  * g_option_context_set_ignore_unknown_options().
20674  *
20675  * Returns: %TRUE if unknown options are ignored.
20676  * Since: 2.6
20677  */
20678
20679
20680 /**
20681  * g_option_context_get_main_group:
20682  * @context: a #GOptionContext
20683  *
20684  * Returns a pointer to the main group of @context.
20685  *
20686  * Returns: the main group of @context, or %NULL if @context doesn't have a main group. Note that group belongs to @context and should not be modified or freed.
20687  * Since: 2.6
20688  */
20689
20690
20691 /**
20692  * g_option_context_get_summary:
20693  * @context: a #GOptionContext
20694  *
20695  * Returns the summary. See g_option_context_set_summary().
20696  *
20697  * Returns: the summary
20698  * Since: 2.12
20699  */
20700
20701
20702 /**
20703  * g_option_context_new:
20704  * @parameter_string: (allow-none): a string which is displayed in the first line of <option>--help</option> output, after the usage summary <literal><replaceable>programname</replaceable> [OPTION...]</literal>
20705  *
20706  * Creates a new option context.
20707  *
20708  * The @parameter_string can serve multiple purposes. It can be used
20709  * to add descriptions for "rest" arguments, which are not parsed by
20710  * the #GOptionContext, typically something like "FILES" or
20711  * "FILE1 FILE2...". If you are using #G_OPTION_REMAINING for
20712  * collecting "rest" arguments, GLib handles this automatically by
20713  * using the @arg_description of the corresponding #GOptionEntry in
20714  * the usage summary.
20715  *
20716  * Another usage is to give a short summary of the program
20717  * functionality, like " - frob the strings", which will be displayed
20718  * in the same line as the usage. For a longer description of the
20719  * program functionality that should be displayed as a paragraph
20720  * below the usage line, use g_option_context_set_summary().
20721  *
20722  * Note that the @parameter_string is translated using the
20723  * function set with g_option_context_set_translate_func(), so
20724  * it should normally be passed untranslated.
20725  *
20726  * Returns: a newly created #GOptionContext, which must be freed with g_option_context_free() after use.
20727  * Since: 2.6
20728  */
20729
20730
20731 /**
20732  * g_option_context_parse:
20733  * @context: a #GOptionContext
20734  * @argc: (inout) (allow-none): a pointer to the number of command line arguments
20735  * @argv: (inout) (array length=argc) (allow-none): a pointer to the array of command line arguments
20736  * @error: a return location for errors
20737  *
20738  * Parses the command line arguments, recognizing options
20739  * which have been added to @context. A side-effect of
20740  * calling this function is that g_set_prgname() will be
20741  * called.
20742  *
20743  * If the parsing is successful, any parsed arguments are
20744  * removed from the array and @argc and @argv are updated
20745  * accordingly. A '--' option is stripped from @argv
20746  * unless there are unparsed options before and after it,
20747  * or some of the options after it start with '-'. In case
20748  * of an error, @argc and @argv are left unmodified.
20749  *
20750  * If automatic <option>--help</option> support is enabled
20751  * (see g_option_context_set_help_enabled()), and the
20752  * @argv array contains one of the recognized help options,
20753  * this function will produce help output to stdout and
20754  * call <literal>exit (0)</literal>.
20755  *
20756  * Note that function depends on the
20757  * <link linkend="setlocale">current locale</link> for
20758  * automatic character set conversion of string and filename
20759  * arguments.
20760  *
20761  * Returns: %TRUE if the parsing was successful, %FALSE if an error occurred
20762  * Since: 2.6
20763  */
20764
20765
20766 /**
20767  * g_option_context_set_description:
20768  * @context: a #GOptionContext
20769  * @description: (allow-none): a string to be shown in <option>--help</option> output after the list of options, or %NULL
20770  *
20771  * Adds a string to be displayed in <option>--help</option> output
20772  * after the list of options. This text often includes a bug reporting
20773  * address.
20774  *
20775  * Note that the summary is translated (see
20776  * g_option_context_set_translate_func()).
20777  *
20778  * Since: 2.12
20779  */
20780
20781
20782 /**
20783  * g_option_context_set_help_enabled:
20784  * @context: a #GOptionContext
20785  * @help_enabled: %TRUE to enable <option>--help</option>, %FALSE to disable it
20786  *
20787  * Enables or disables automatic generation of <option>--help</option>
20788  * output. By default, g_option_context_parse() recognizes
20789  * <option>--help</option>, <option>-h</option>,
20790  * <option>-?</option>, <option>--help-all</option>
20791  * and <option>--help-</option><replaceable>groupname</replaceable> and creates
20792  * suitable output to stdout.
20793  *
20794  * Since: 2.6
20795  */
20796
20797
20798 /**
20799  * g_option_context_set_ignore_unknown_options:
20800  * @context: a #GOptionContext
20801  * @ignore_unknown: %TRUE to ignore unknown options, %FALSE to produce an error when unknown options are met
20802  *
20803  * Sets whether to ignore unknown options or not. If an argument is
20804  * ignored, it is left in the @argv array after parsing. By default,
20805  * g_option_context_parse() treats unknown options as error.
20806  *
20807  * This setting does not affect non-option arguments (i.e. arguments
20808  * which don't start with a dash). But note that GOption cannot reliably
20809  * determine whether a non-option belongs to a preceding unknown option.
20810  *
20811  * Since: 2.6
20812  */
20813
20814
20815 /**
20816  * g_option_context_set_main_group:
20817  * @context: a #GOptionContext
20818  * @group: the group to set as main group
20819  *
20820  * Sets a #GOptionGroup as main group of the @context.
20821  * This has the same effect as calling g_option_context_add_group(),
20822  * the only difference is that the options in the main group are
20823  * treated differently when generating <option>--help</option> output.
20824  *
20825  * Since: 2.6
20826  */
20827
20828
20829 /**
20830  * g_option_context_set_summary:
20831  * @context: a #GOptionContext
20832  * @summary: (allow-none): a string to be shown in <option>--help</option> output before the list of options, or %NULL
20833  *
20834  * Adds a string to be displayed in <option>--help</option> output
20835  * before the list of options. This is typically a summary of the
20836  * program functionality.
20837  *
20838  * Note that the summary is translated (see
20839  * g_option_context_set_translate_func() and
20840  * g_option_context_set_translation_domain()).
20841  *
20842  * Since: 2.12
20843  */
20844
20845
20846 /**
20847  * g_option_context_set_translate_func:
20848  * @context: a #GOptionContext
20849  * @func: (allow-none): the #GTranslateFunc, or %NULL
20850  * @data: (allow-none): user data to pass to @func, or %NULL
20851  * @destroy_notify: (allow-none): a function which gets called to free @data, or %NULL
20852  *
20853  * Sets the function which is used to translate the contexts
20854  * user-visible strings, for <option>--help</option> output.
20855  * If @func is %NULL, strings are not translated.
20856  *
20857  * Note that option groups have their own translation functions,
20858  * this function only affects the @parameter_string (see g_option_context_new()),
20859  * the summary (see g_option_context_set_summary()) and the description
20860  * (see g_option_context_set_description()).
20861  *
20862  * If you are using gettext(), you only need to set the translation
20863  * domain, see g_option_context_set_translation_domain().
20864  *
20865  * Since: 2.12
20866  */
20867
20868
20869 /**
20870  * g_option_context_set_translation_domain:
20871  * @context: a #GOptionContext
20872  * @domain: the domain to use
20873  *
20874  * A convenience function to use gettext() for translating
20875  * user-visible strings.
20876  *
20877  * Since: 2.12
20878  */
20879
20880
20881 /**
20882  * g_option_group_add_entries:
20883  * @group: a #GOptionGroup
20884  * @entries: a %NULL-terminated array of #GOptionEntry<!-- -->s
20885  *
20886  * Adds the options specified in @entries to @group.
20887  *
20888  * Since: 2.6
20889  */
20890
20891
20892 /**
20893  * g_option_group_free:
20894  * @group: a #GOptionGroup
20895  *
20896  * Frees a #GOptionGroup. Note that you must <emphasis>not</emphasis>
20897  * free groups which have been added to a #GOptionContext.
20898  *
20899  * Since: 2.6
20900  */
20901
20902
20903 /**
20904  * g_option_group_new:
20905  * @name: the name for the option group, this is used to provide help for the options in this group with <option>--help-</option>@name
20906  * @description: a description for this group to be shown in <option>--help</option>. This string is translated using the translation domain or translation function of the group
20907  * @help_description: a description for the <option>--help-</option>@name option. This string is translated using the translation domain or translation function of the group
20908  * @user_data: (allow-none): user data that will be passed to the pre- and post-parse hooks, the error hook and to callbacks of %G_OPTION_ARG_CALLBACK options, or %NULL
20909  * @destroy: (allow-none): a function that will be called to free @user_data, or %NULL
20910  *
20911  * Creates a new #GOptionGroup.
20912  *
20913  * Returns: a newly created option group. It should be added to a #GOptionContext or freed with g_option_group_free().
20914  * Since: 2.6
20915  */
20916
20917
20918 /**
20919  * g_option_group_set_error_hook:
20920  * @group: a #GOptionGroup
20921  * @error_func: a function to call when an error occurs
20922  *
20923  * Associates a function with @group which will be called
20924  * from g_option_context_parse() when an error occurs.
20925  *
20926  * Note that the user data to be passed to @error_func can be
20927  * specified when constructing the group with g_option_group_new().
20928  *
20929  * Since: 2.6
20930  */
20931
20932
20933 /**
20934  * g_option_group_set_parse_hooks:
20935  * @group: a #GOptionGroup
20936  * @pre_parse_func: (allow-none): a function to call before parsing, or %NULL
20937  * @post_parse_func: (allow-none): a function to call after parsing, or %NULL
20938  *
20939  * Associates two functions with @group which will be called
20940  * from g_option_context_parse() before the first option is parsed
20941  * and after the last option has been parsed, respectively.
20942  *
20943  * Note that the user data to be passed to @pre_parse_func and
20944  * @post_parse_func can be specified when constructing the group
20945  * with g_option_group_new().
20946  *
20947  * Since: 2.6
20948  */
20949
20950
20951 /**
20952  * g_option_group_set_translate_func:
20953  * @group: a #GOptionGroup
20954  * @func: (allow-none): the #GTranslateFunc, or %NULL
20955  * @data: (allow-none): user data to pass to @func, or %NULL
20956  * @destroy_notify: (allow-none): a function which gets called to free @data, or %NULL
20957  *
20958  * Sets the function which is used to translate user-visible
20959  * strings, for <option>--help</option> output. Different
20960  * groups can use different #GTranslateFunc<!-- -->s. If @func
20961  * is %NULL, strings are not translated.
20962  *
20963  * If you are using gettext(), you only need to set the translation
20964  * domain, see g_option_group_set_translation_domain().
20965  *
20966  * Since: 2.6
20967  */
20968
20969
20970 /**
20971  * g_option_group_set_translation_domain:
20972  * @group: a #GOptionGroup
20973  * @domain: the domain to use
20974  *
20975  * A convenience function to use gettext() for translating
20976  * user-visible strings.
20977  *
20978  * Since: 2.6
20979  */
20980
20981
20982 /**
20983  * g_parse_debug_string:
20984  * @string: (allow-none): a list of debug options separated by colons, spaces, or commas, or %NULL.
20985  * @keys: (array length=nkeys): pointer to an array of #GDebugKey which associate strings with bit flags.
20986  * @nkeys: the number of #GDebugKey<!-- -->s in the array.
20987  *
20988  * Parses a string containing debugging options
20989  * into a %guint containing bit flags. This is used
20990  * within GDK and GTK+ to parse the debug options passed on the
20991  * command line or through environment variables.
20992  *
20993  * If @string is equal to <code>"all"</code>, all flags are set. Any flags
20994  * specified along with <code>"all"</code> in @string are inverted; thus,
20995  * <code>"all,foo,bar"</code> or <code>"foo,bar,all"</code> sets all flags
20996  * except those corresponding to <code>"foo"</code> and <code>"bar"</code>.
20997  *
20998  * If @string is equal to <code>"help"</code>, all the available keys in @keys
20999  * are printed out to standard error.
21000  *
21001  * Returns: the combined set of bit flags.
21002  */
21003
21004
21005 /**
21006  * g_path_get_basename:
21007  * @file_name: the name of the file
21008  *
21009  * Gets the last component of the filename.
21010  *
21011  * If @file_name ends with a directory separator it gets the component
21012  * before the last slash. If @file_name consists only of directory
21013  * separators (and on Windows, possibly a drive letter), a single
21014  * separator is returned. If @file_name is empty, it gets ".".
21015  *
21016  * Returns: a newly allocated string containing the last component of the filename
21017  */
21018
21019
21020 /**
21021  * g_path_get_dirname:
21022  * @file_name: the name of the file
21023  *
21024  * Gets the directory components of a file name.
21025  *
21026  * If the file name has no directory components "." is returned.
21027  * The returned string should be freed when no longer needed.
21028  *
21029  * Returns: the directory components of the file
21030  */
21031
21032
21033 /**
21034  * g_path_is_absolute:
21035  * @file_name: a file name
21036  *
21037  * Returns %TRUE if the given @file_name is an absolute file name.
21038  * Note that this is a somewhat vague concept on Windows.
21039  *
21040  * On POSIX systems, an absolute file name is well-defined. It always
21041  * starts from the single root directory. For example "/usr/local".
21042  *
21043  * On Windows, the concepts of current drive and drive-specific
21044  * current directory introduce vagueness. This function interprets as
21045  * an absolute file name one that either begins with a directory
21046  * separator such as "\Users\tml" or begins with the root on a drive,
21047  * for example "C:\Windows". The first case also includes UNC paths
21048  * such as "\\myserver\docs\foo". In all cases, either slashes or
21049  * backslashes are accepted.
21050  *
21051  * Note that a file name relative to the current drive root does not
21052  * truly specify a file uniquely over time and across processes, as
21053  * the current drive is a per-process value and can be changed.
21054  *
21055  * File names relative the current directory on some specific drive,
21056  * such as "D:foo/bar", are not interpreted as absolute by this
21057  * function, but they obviously are not relative to the normal current
21058  * directory as returned by getcwd() or g_get_current_dir()
21059  * either. Such paths should be avoided, or need to be handled using
21060  * Windows-specific code.
21061  *
21062  * Returns: %TRUE if @file_name is absolute
21063  */
21064
21065
21066 /**
21067  * g_path_skip_root:
21068  * @file_name: a file name
21069  *
21070  * Returns a pointer into @file_name after the root component,
21071  * i.e. after the "/" in UNIX or "C:\" under Windows. If @file_name
21072  * is not an absolute path it returns %NULL.
21073  *
21074  * Returns: a pointer into @file_name after the root component
21075  */
21076
21077
21078 /**
21079  * g_pattern_match:
21080  * @pspec: a #GPatternSpec
21081  * @string_length: the length of @string (in bytes, i.e. strlen(), <emphasis>not</emphasis> g_utf8_strlen())
21082  * @string: the UTF-8 encoded string to match
21083  * @string_reversed: (allow-none): the reverse of @string or %NULL
21084  *
21085  * Matches a string against a compiled pattern. Passing the correct
21086  * length of the string given is mandatory. The reversed string can be
21087  * omitted by passing %NULL, this is more efficient if the reversed
21088  * version of the string to be matched is not at hand, as
21089  * g_pattern_match() will only construct it if the compiled pattern
21090  * requires reverse matches.
21091  *
21092  * Note that, if the user code will (possibly) match a string against a
21093  * multitude of patterns containing wildcards, chances are high that
21094  * some patterns will require a reversed string. In this case, it's
21095  * more efficient to provide the reversed string to avoid multiple
21096  * constructions thereof in the various calls to g_pattern_match().
21097  *
21098  * Note also that the reverse of a UTF-8 encoded string can in general
21099  * <emphasis>not</emphasis> be obtained by g_strreverse(). This works
21100  * only if the string doesn't contain any multibyte characters. GLib
21101  * offers the g_utf8_strreverse() function to reverse UTF-8 encoded
21102  * strings.
21103  *
21104  * Returns: %TRUE if @string matches @pspec
21105  */
21106
21107
21108 /**
21109  * g_pattern_match_simple:
21110  * @pattern: the UTF-8 encoded pattern
21111  * @string: the UTF-8 encoded string to match
21112  *
21113  * Matches a string against a pattern given as a string. If this
21114  * function is to be called in a loop, it's more efficient to compile
21115  * the pattern once with g_pattern_spec_new() and call
21116  * g_pattern_match_string() repeatedly.
21117  *
21118  * Returns: %TRUE if @string matches @pspec
21119  */
21120
21121
21122 /**
21123  * g_pattern_match_string:
21124  * @pspec: a #GPatternSpec
21125  * @string: the UTF-8 encoded string to match
21126  *
21127  * Matches a string against a compiled pattern. If the string is to be
21128  * matched against more than one pattern, consider using
21129  * g_pattern_match() instead while supplying the reversed string.
21130  *
21131  * Returns: %TRUE if @string matches @pspec
21132  */
21133
21134
21135 /**
21136  * g_pattern_spec_equal:
21137  * @pspec1: a #GPatternSpec
21138  * @pspec2: another #GPatternSpec
21139  *
21140  * Compares two compiled pattern specs and returns whether they will
21141  * match the same set of strings.
21142  *
21143  * Returns: Whether the compiled patterns are equal
21144  */
21145
21146
21147 /**
21148  * g_pattern_spec_free:
21149  * @pspec: a #GPatternSpec
21150  *
21151  * Frees the memory allocated for the #GPatternSpec.
21152  */
21153
21154
21155 /**
21156  * g_pattern_spec_new:
21157  * @pattern: a zero-terminated UTF-8 encoded string
21158  *
21159  * Compiles a pattern to a #GPatternSpec.
21160  *
21161  * Returns: a newly-allocated #GPatternSpec
21162  */
21163
21164
21165 /**
21166  * g_pointer_bit_lock:
21167  * @address: a pointer to a #gpointer-sized value
21168  * @lock_bit: a bit value between 0 and 31
21169  *
21170  * This is equivalent to g_bit_lock, but working on pointers (or other
21171  * pointer-sized values).
21172  *
21173  * For portability reasons, you may only lock on the bottom 32 bits of
21174  * the pointer.
21175  *
21176  * Since: 2.30
21177  */
21178
21179
21180 /**
21181  * g_pointer_bit_trylock:
21182  * @address: a pointer to a #gpointer-sized value
21183  * @lock_bit: a bit value between 0 and 31
21184  *
21185  * This is equivalent to g_bit_trylock, but working on pointers (or
21186  * other pointer-sized values).
21187  *
21188  * For portability reasons, you may only lock on the bottom 32 bits of
21189  * the pointer.
21190  *
21191  * Returns: %TRUE if the lock was acquired
21192  * Since: 2.30
21193  */
21194
21195
21196 /**
21197  * g_pointer_bit_unlock:
21198  * @address: a pointer to a #gpointer-sized value
21199  * @lock_bit: a bit value between 0 and 31
21200  *
21201  * This is equivalent to g_bit_unlock, but working on pointers (or other
21202  * pointer-sized values).
21203  *
21204  * For portability reasons, you may only lock on the bottom 32 bits of
21205  * the pointer.
21206  *
21207  * Since: 2.30
21208  */
21209
21210
21211 /**
21212  * g_poll:
21213  * @fds: file descriptors to poll
21214  * @nfds: the number of file descriptors in @fds
21215  * @timeout: amount of time to wait, in milliseconds, or -1 to wait forever
21216  *
21217  * Polls @fds, as with the poll() system call, but portably. (On
21218  * systems that don't have poll(), it is emulated using select().)
21219  * This is used internally by #GMainContext, but it can be called
21220  * directly if you need to block until a file descriptor is ready, but
21221  * don't want to run the full main loop.
21222  *
21223  * Each element of @fds is a #GPollFD describing a single file
21224  * descriptor to poll. The %fd field indicates the file descriptor,
21225  * and the %events field indicates the events to poll for. On return,
21226  * the %revents fields will be filled with the events that actually
21227  * occurred.
21228  *
21229  * On POSIX systems, the file descriptors in @fds can be any sort of
21230  * file descriptor, but the situation is much more complicated on
21231  * Windows. If you need to use g_poll() in code that has to run on
21232  * Windows, the easiest solution is to construct all of your
21233  * #GPollFD<!-- -->s with g_io_channel_win32_make_pollfd().
21234  *
21235  * Returns: the number of entries in @fds whose %revents fields were filled in, or 0 if the operation timed out, or -1 on error or if the call was interrupted.
21236  * Since: 2.20
21237  */
21238
21239
21240 /**
21241  * g_prefix_error:
21242  * @err: (allow-none): a return location for a #GError, or %NULL
21243  * @format: printf()-style format string
21244  * @...: arguments to @format
21245  *
21246  * Formats a string according to @format and
21247  * prefix it to an existing error message.  If
21248  * @err is %NULL (ie: no error variable) then do
21249  * nothing.
21250  *
21251  * If *@err is %NULL (ie: an error variable is
21252  * present but there is no error condition) then
21253  * also do nothing.  Whether or not it makes
21254  * sense to take advantage of this feature is up
21255  * to you.
21256  *
21257  * Since: 2.16
21258  */
21259
21260
21261 /**
21262  * g_print:
21263  * @format: the message format. See the printf() documentation
21264  * @...: the parameters to insert into the format string
21265  *
21266  * Outputs a formatted message via the print handler.
21267  * The default print handler simply outputs the message to stdout.
21268  *
21269  * g_print() should not be used from within libraries for debugging
21270  * messages, since it may be redirected by applications to special
21271  * purpose message windows or even files. Instead, libraries should
21272  * use g_log(), or the convenience functions g_message(), g_warning()
21273  * and g_error().
21274  */
21275
21276
21277 /**
21278  * g_printerr:
21279  * @format: the message format. See the printf() documentation
21280  * @...: the parameters to insert into the format string
21281  *
21282  * Outputs a formatted message via the error message handler.
21283  * The default handler simply outputs the message to stderr.
21284  *
21285  * g_printerr() should not be used from within libraries.
21286  * Instead g_log() should be used, or the convenience functions
21287  * g_message(), g_warning() and g_error().
21288  */
21289
21290
21291 /**
21292  * g_printf:
21293  * @format: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
21294  * @...: the arguments to insert in the output.
21295  *
21296  * An implementation of the standard printf() function which supports
21297  * positional parameters, as specified in the Single Unix Specification.
21298  *
21299  * Returns: the number of bytes printed.
21300  * Since: 2.2
21301  */
21302
21303
21304 /**
21305  * g_printf_string_upper_bound:
21306  * @format: the format string. See the printf() documentation
21307  * @args: the parameters to be inserted into the format string
21308  *
21309  * Calculates the maximum space needed to store the output
21310  * of the sprintf() function.
21311  *
21312  * Returns: the maximum space needed to store the formatted string
21313  */
21314
21315
21316 /**
21317  * g_private_get:
21318  * @key: a #GPrivate
21319  *
21320  * Returns the current value of the thread local variable @key.
21321  *
21322  * If the value has not yet been set in this thread, %NULL is returned.
21323  * Values are never copied between threads (when a new thread is
21324  * created, for example).
21325  *
21326  * Returns: the thread-local value
21327  */
21328
21329
21330 /**
21331  * g_private_replace:
21332  * @key: a #GPrivate
21333  * @value: the new value
21334  *
21335  * Sets the thread local variable @key to have the value @value in the
21336  * current thread.
21337  *
21338  * This function differs from g_private_set() in the following way: if
21339  * the previous value was non-%NULL then the #GDestroyNotify handler for
21340  * @key is run on it.
21341  *
21342  * Since: 2.32
21343  */
21344
21345
21346 /**
21347  * g_private_set:
21348  * @key: a #GPrivate
21349  * @value: the new value
21350  *
21351  * Sets the thread local variable @key to have the value @value in the
21352  * current thread.
21353  *
21354  * This function differs from g_private_replace() in the following way:
21355  * the #GDestroyNotify for @key is not called on the old value.
21356  */
21357
21358
21359 /**
21360  * g_propagate_error:
21361  * @dest: error return location
21362  * @src: error to move into the return location
21363  *
21364  * If @dest is %NULL, free @src; otherwise, moves @src into *@dest.
21365  * The error variable @dest points to must be %NULL.
21366  */
21367
21368
21369 /**
21370  * g_propagate_prefixed_error:
21371  * @dest: error return location
21372  * @src: error to move into the return location
21373  * @format: printf()-style format string
21374  * @...: arguments to @format
21375  *
21376  * If @dest is %NULL, free @src; otherwise,
21377  * moves @src into *@dest. *@dest must be %NULL.
21378  * After the move, add a prefix as with
21379  * g_prefix_error().
21380  *
21381  * Since: 2.16
21382  */
21383
21384
21385 /**
21386  * g_ptr_array_add:
21387  * @array: a #GPtrArray.
21388  * @data: the pointer to add.
21389  *
21390  * Adds a pointer to the end of the pointer array. The array will grow
21391  * in size automatically if necessary.
21392  */
21393
21394
21395 /**
21396  * g_ptr_array_foreach:
21397  * @array: a #GPtrArray
21398  * @func: the function to call for each array element
21399  * @user_data: user data to pass to the function
21400  *
21401  * Calls a function for each element of a #GPtrArray.
21402  *
21403  * Since: 2.4
21404  */
21405
21406
21407 /**
21408  * g_ptr_array_free:
21409  * @array: a #GPtrArray.
21410  * @free_seg: if %TRUE the actual pointer array is freed as well.
21411  *
21412  * Frees the memory allocated for the #GPtrArray. If @free_seg is %TRUE
21413  * it frees the memory block holding the elements as well. Pass %FALSE
21414  * if you want to free the #GPtrArray wrapper but preserve the
21415  * underlying array for use elsewhere. If the reference count of @array
21416  * is greater than one, the #GPtrArray wrapper is preserved but the
21417  * size of @array will be set to zero.
21418  *
21419  * <note><para>If array contents point to dynamically-allocated
21420  * memory, they should be freed separately if @free_seg is %TRUE and no
21421  * #GDestroyNotify function has been set for @array.</para></note>
21422  *
21423  * Returns: the pointer array if @free_seg is %FALSE, otherwise %NULL. The pointer array should be freed using g_free().
21424  */
21425
21426
21427 /**
21428  * g_ptr_array_index:
21429  * @array: a #GPtrArray.
21430  * @index_: the index of the pointer to return.
21431  *
21432  * Returns the pointer at the given index of the pointer array.
21433  *
21434  * Returns: the pointer at the given index.
21435  */
21436
21437
21438 /**
21439  * g_ptr_array_new:
21440  *
21441  * Creates a new #GPtrArray with a reference count of 1.
21442  *
21443  * Returns: the new #GPtrArray.
21444  */
21445
21446
21447 /**
21448  * g_ptr_array_new_full:
21449  * @reserved_size: number of pointers preallocated.
21450  * @element_free_func: (allow-none): A function to free elements with destroy @array or %NULL.
21451  *
21452  * Creates a new #GPtrArray with @reserved_size pointers preallocated
21453  * and a reference count of 1. This avoids frequent reallocation, if
21454  * you are going to add many pointers to the array. Note however that
21455  * the size of the array is still 0. It also set @element_free_func
21456  * for freeing each element when the array is destroyed either via
21457  * g_ptr_array_unref(), when g_ptr_array_free() is called with @free_segment
21458  * set to %TRUE or when removing elements.
21459  *
21460  * Returns: A new #GPtrArray.
21461  * Since: 2.30
21462  */
21463
21464
21465 /**
21466  * g_ptr_array_new_with_free_func:
21467  * @element_free_func: (allow-none): A function to free elements with destroy @array or %NULL.
21468  *
21469  * Creates a new #GPtrArray with a reference count of 1 and use @element_free_func
21470  * for freeing each element when the array is destroyed either via
21471  * g_ptr_array_unref(), when g_ptr_array_free() is called with @free_segment
21472  * set to %TRUE or when removing elements.
21473  *
21474  * Returns: A new #GPtrArray.
21475  * Since: 2.22
21476  */
21477
21478
21479 /**
21480  * g_ptr_array_ref:
21481  * @array: a #GPtrArray
21482  *
21483  * Atomically increments the reference count of @array by one.
21484  * This function is thread-safe and may be called from any thread.
21485  *
21486  * Returns: The passed in #GPtrArray
21487  * Since: 2.22
21488  */
21489
21490
21491 /**
21492  * g_ptr_array_remove:
21493  * @array: a #GPtrArray.
21494  * @data: the pointer to remove.
21495  *
21496  * Removes the first occurrence of the given pointer from the pointer
21497  * array. The following elements are moved down one place. If @array
21498  * has a non-%NULL #GDestroyNotify function it is called for the
21499  * removed element.
21500  *
21501  * It returns %TRUE if the pointer was removed, or %FALSE if the
21502  * pointer was not found.
21503  *
21504  * Returns: %TRUE if the pointer is removed. %FALSE if the pointer is not found in the array.
21505  */
21506
21507
21508 /**
21509  * g_ptr_array_remove_fast:
21510  * @array: a #GPtrArray.
21511  * @data: the pointer to remove.
21512  *
21513  * Removes the first occurrence of the given pointer from the pointer
21514  * array. The last element in the array is used to fill in the space,
21515  * so this function does not preserve the order of the array. But it is
21516  * faster than g_ptr_array_remove(). If @array has a non-%NULL
21517  * #GDestroyNotify function it is called for the removed element.
21518  *
21519  * It returns %TRUE if the pointer was removed, or %FALSE if the
21520  * pointer was not found.
21521  *
21522  * Returns: %TRUE if the pointer was found in the array.
21523  */
21524
21525
21526 /**
21527  * g_ptr_array_remove_index:
21528  * @array: a #GPtrArray.
21529  * @index_: the index of the pointer to remove.
21530  *
21531  * Removes the pointer at the given index from the pointer array. The
21532  * following elements are moved down one place. If @array has a
21533  * non-%NULL #GDestroyNotify function it is called for the removed
21534  * element.
21535  *
21536  * Returns: the pointer which was removed.
21537  */
21538
21539
21540 /**
21541  * g_ptr_array_remove_index_fast:
21542  * @array: a #GPtrArray.
21543  * @index_: the index of the pointer to remove.
21544  *
21545  * Removes the pointer at the given index from the pointer array. The
21546  * last element in the array is used to fill in the space, so this
21547  * function does not preserve the order of the array. But it is faster
21548  * than g_ptr_array_remove_index(). If @array has a non-%NULL
21549  * #GDestroyNotify function it is called for the removed element.
21550  *
21551  * Returns: the pointer which was removed.
21552  */
21553
21554
21555 /**
21556  * g_ptr_array_remove_range:
21557  * @array: a @GPtrArray.
21558  * @index_: the index of the first pointer to remove.
21559  * @length: the number of pointers to remove.
21560  *
21561  * Removes the given number of pointers starting at the given index
21562  * from a #GPtrArray.  The following elements are moved to close the
21563  * gap. If @array has a non-%NULL #GDestroyNotify function it is called
21564  * for the removed elements.
21565  *
21566  * Since: 2.4
21567  */
21568
21569
21570 /**
21571  * g_ptr_array_set_free_func:
21572  * @array: A #GPtrArray.
21573  * @element_free_func: (allow-none): A function to free elements with destroy @array or %NULL.
21574  *
21575  * Sets a function for freeing each element when @array is destroyed
21576  * either via g_ptr_array_unref(), when g_ptr_array_free() is called
21577  * with @free_segment set to %TRUE or when removing elements.
21578  *
21579  * Since: 2.22
21580  */
21581
21582
21583 /**
21584  * g_ptr_array_set_size:
21585  * @array: a #GPtrArray.
21586  * @length: the new length of the pointer array.
21587  *
21588  * Sets the size of the array. When making the array larger,
21589  * newly-added elements will be set to %NULL. When making it smaller,
21590  * if @array has a non-%NULL #GDestroyNotify function then it will be
21591  * called for the removed elements.
21592  */
21593
21594
21595 /**
21596  * g_ptr_array_sized_new:
21597  * @reserved_size: number of pointers preallocated.
21598  *
21599  * Creates a new #GPtrArray with @reserved_size pointers preallocated
21600  * and a reference count of 1. This avoids frequent reallocation, if
21601  * you are going to add many pointers to the array. Note however that
21602  * the size of the array is still 0.
21603  *
21604  * Returns: the new #GPtrArray.
21605  */
21606
21607
21608 /**
21609  * g_ptr_array_sort:
21610  * @array: a #GPtrArray.
21611  * @compare_func: comparison function.
21612  *
21613  * Sorts the array, using @compare_func which should be a qsort()-style
21614  * comparison function (returns less than zero for first arg is less
21615  * than second arg, zero for equal, greater than zero if irst arg is
21616  * greater than second arg).
21617  *
21618  * <note><para>The comparison function for g_ptr_array_sort() doesn't
21619  * take the pointers from the array as arguments, it takes pointers to
21620  * the pointers in the array.</para></note>
21621  *
21622  * This is guaranteed to be a stable sort since version 2.32.
21623  */
21624
21625
21626 /**
21627  * g_ptr_array_sort_with_data:
21628  * @array: a #GPtrArray.
21629  * @compare_func: comparison function.
21630  * @user_data: data to pass to @compare_func.
21631  *
21632  * Like g_ptr_array_sort(), but the comparison function has an extra
21633  * user data argument.
21634  *
21635  * <note><para>The comparison function for g_ptr_array_sort_with_data()
21636  * doesn't take the pointers from the array as arguments, it takes
21637  * pointers to the pointers in the array.</para></note>
21638  *
21639  * This is guaranteed to be a stable sort since version 2.32.
21640  */
21641
21642
21643 /**
21644  * g_ptr_array_unref:
21645  * @array: A #GPtrArray.
21646  *
21647  * Atomically decrements the reference count of @array by one. If the
21648  * reference count drops to 0, the effect is the same as calling
21649  * g_ptr_array_free() with @free_segment set to %TRUE. This function
21650  * is MT-safe and may be called from any thread.
21651  *
21652  * Since: 2.22
21653  */
21654
21655
21656 /**
21657  * g_qsort_with_data:
21658  * @pbase: start of array to sort
21659  * @total_elems: elements in the array
21660  * @size: size of each element
21661  * @compare_func: function to compare elements
21662  * @user_data: data to pass to @compare_func
21663  *
21664  * This is just like the standard C qsort() function, but
21665  * the comparison routine accepts a user data argument.
21666  *
21667  * This is guaranteed to be a stable sort since version 2.32.
21668  */
21669
21670
21671 /**
21672  * g_quark_from_static_string:
21673  * @string: (allow-none): a string.
21674  *
21675  * Gets the #GQuark identifying the given (static) string. If the
21676  * string does not currently have an associated #GQuark, a new #GQuark
21677  * is created, linked to the given string.
21678  *
21679  * Note that this function is identical to g_quark_from_string() except
21680  * that if a new #GQuark is created the string itself is used rather
21681  * than a copy. This saves memory, but can only be used if the string
21682  * will <emphasis>always</emphasis> exist. It can be used with
21683  * statically allocated strings in the main program, but not with
21684  * statically allocated memory in dynamically loaded modules, if you
21685  * expect to ever unload the module again (e.g. do not use this
21686  * function in GTK+ theme engines).
21687  *
21688  * Returns: the #GQuark identifying the string, or 0 if @string is %NULL.
21689  */
21690
21691
21692 /**
21693  * g_quark_from_string:
21694  * @string: (allow-none): a string.
21695  *
21696  * Gets the #GQuark identifying the given string. If the string does
21697  * not currently have an associated #GQuark, a new #GQuark is created,
21698  * using a copy of the string.
21699  *
21700  * Returns: the #GQuark identifying the string, or 0 if @string is %NULL.
21701  */
21702
21703
21704 /**
21705  * g_quark_to_string:
21706  * @quark: a #GQuark.
21707  *
21708  * Gets the string associated with the given #GQuark.
21709  *
21710  * Returns: the string associated with the #GQuark
21711  */
21712
21713
21714 /**
21715  * g_quark_try_string:
21716  * @string: (allow-none): a string.
21717  *
21718  * Gets the #GQuark associated with the given string, or 0 if string is
21719  * %NULL or it has no associated #GQuark.
21720  *
21721  * If you want the GQuark to be created if it doesn't already exist,
21722  * use g_quark_from_string() or g_quark_from_static_string().
21723  *
21724  * Returns: the #GQuark associated with the string, or 0 if @string is %NULL or there is no #GQuark associated with it.
21725  */
21726
21727
21728 /**
21729  * g_queue_clear:
21730  * @queue: a #GQueue
21731  *
21732  * Removes all the elements in @queue. If queue elements contain
21733  * dynamically-allocated memory, they should be freed first.
21734  *
21735  * Since: 2.14
21736  */
21737
21738
21739 /**
21740  * g_queue_copy:
21741  * @queue: a #GQueue
21742  *
21743  * Copies a @queue. Note that is a shallow copy. If the elements in the
21744  * queue consist of pointers to data, the pointers are copied, but the
21745  * actual data is not.
21746  *
21747  * Returns: A copy of @queue
21748  * Since: 2.4
21749  */
21750
21751
21752 /**
21753  * g_queue_delete_link:
21754  * @queue: a #GQueue
21755  * @link_: a #GList link that <emphasis>must</emphasis> be part of @queue
21756  *
21757  * Removes @link_ from @queue and frees it.
21758  *
21759  * @link_ must be part of @queue.
21760  *
21761  * Since: 2.4
21762  */
21763
21764
21765 /**
21766  * g_queue_find:
21767  * @queue: a #GQueue
21768  * @data: data to find
21769  *
21770  * Finds the first link in @queue which contains @data.
21771  *
21772  * Returns: The first link in @queue which contains @data.
21773  * Since: 2.4
21774  */
21775
21776
21777 /**
21778  * g_queue_find_custom:
21779  * @queue: a #GQueue
21780  * @data: user data passed to @func
21781  * @func: a #GCompareFunc to call for each element. It should return 0 when the desired element is found
21782  *
21783  * Finds an element in a #GQueue, using a supplied function to find the
21784  * desired element. It iterates over the queue, calling the given function
21785  * which should return 0 when the desired element is found. The function
21786  * takes two gconstpointer arguments, the #GQueue element's data as the
21787  * first argument and the given user data as the second argument.
21788  *
21789  * Returns: The found link, or %NULL if it wasn't found
21790  * Since: 2.4
21791  */
21792
21793
21794 /**
21795  * g_queue_foreach:
21796  * @queue: a #GQueue
21797  * @func: the function to call for each element's data
21798  * @user_data: user data to pass to @func
21799  *
21800  * Calls @func for each element in the queue passing @user_data to the
21801  * function.
21802  *
21803  * Since: 2.4
21804  */
21805
21806
21807 /**
21808  * g_queue_free:
21809  * @queue: a #GQueue.
21810  *
21811  * Frees the memory allocated for the #GQueue. Only call this function if
21812  * @queue was created with g_queue_new(). If queue elements contain
21813  * dynamically-allocated memory, they should be freed first.
21814  *
21815  * <note><para>
21816  * If queue elements contain dynamically-allocated memory,
21817  * you should either use g_queue_free_full() or free them manually
21818  * first.
21819  * </para></note>
21820  */
21821
21822
21823 /**
21824  * g_queue_free_full:
21825  * @queue: a pointer to a #GQueue
21826  * @free_func: the function to be called to free each element's data
21827  *
21828  * Convenience method, which frees all the memory used by a #GQueue, and
21829  * calls the specified destroy function on every element's data.
21830  *
21831  * Since: 2.32
21832  */
21833
21834
21835 /**
21836  * g_queue_get_length:
21837  * @queue: a #GQueue
21838  *
21839  * Returns the number of items in @queue.
21840  *
21841  * Returns: The number of items in @queue.
21842  * Since: 2.4
21843  */
21844
21845
21846 /**
21847  * g_queue_index:
21848  * @queue: a #GQueue
21849  * @data: the data to find.
21850  *
21851  * Returns the position of the first element in @queue which contains @data.
21852  *
21853  * Returns: The position of the first element in @queue which contains @data, or -1 if no element in @queue contains @data.
21854  * Since: 2.4
21855  */
21856
21857
21858 /**
21859  * g_queue_init:
21860  * @queue: an uninitialized #GQueue
21861  *
21862  * A statically-allocated #GQueue must be initialized with this function
21863  * before it can be used. Alternatively you can initialize it with
21864  * #G_QUEUE_INIT. It is not necessary to initialize queues created with
21865  * g_queue_new().
21866  *
21867  * Since: 2.14
21868  */
21869
21870
21871 /**
21872  * g_queue_insert_after:
21873  * @queue: a #GQueue
21874  * @sibling: a #GList link that <emphasis>must</emphasis> be part of @queue
21875  * @data: the data to insert
21876  *
21877  * Inserts @data into @queue after @sibling
21878  *
21879  * @sibling must be part of @queue
21880  *
21881  * Since: 2.4
21882  */
21883
21884
21885 /**
21886  * g_queue_insert_before:
21887  * @queue: a #GQueue
21888  * @sibling: a #GList link that <emphasis>must</emphasis> be part of @queue
21889  * @data: the data to insert
21890  *
21891  * Inserts @data into @queue before @sibling.
21892  *
21893  * @sibling must be part of @queue.
21894  *
21895  * Since: 2.4
21896  */
21897
21898
21899 /**
21900  * g_queue_insert_sorted:
21901  * @queue: a #GQueue
21902  * @data: the data to insert
21903  * @func: the #GCompareDataFunc used to compare elements in the queue. It is called with two elements of the @queue and @user_data. It should return 0 if the elements are equal, a negative value if the first element comes before the second, and a positive value if the second element comes before the first.
21904  * @user_data: user data passed to @func.
21905  *
21906  * Inserts @data into @queue using @func to determine the new position.
21907  *
21908  * Since: 2.4
21909  */
21910
21911
21912 /**
21913  * g_queue_is_empty:
21914  * @queue: a #GQueue.
21915  *
21916  * Returns %TRUE if the queue is empty.
21917  *
21918  * Returns: %TRUE if the queue is empty.
21919  */
21920
21921
21922 /**
21923  * g_queue_link_index:
21924  * @queue: a #GQueue
21925  * @link_: A #GList link
21926  *
21927  * Returns the position of @link_ in @queue.
21928  *
21929  * Returns: The position of @link_, or -1 if the link is not part of @queue
21930  * Since: 2.4
21931  */
21932
21933
21934 /**
21935  * g_queue_new:
21936  *
21937  * Creates a new #GQueue.
21938  *
21939  * Returns: a new #GQueue.
21940  */
21941
21942
21943 /**
21944  * g_queue_peek_head:
21945  * @queue: a #GQueue.
21946  *
21947  * Returns the first element of the queue.
21948  *
21949  * Returns: the data of the first element in the queue, or %NULL if the queue is empty.
21950  */
21951
21952
21953 /**
21954  * g_queue_peek_head_link:
21955  * @queue: a #GQueue
21956  *
21957  * Returns the first link in @queue
21958  *
21959  * Returns: the first link in @queue, or %NULL if @queue is empty
21960  * Since: 2.4
21961  */
21962
21963
21964 /**
21965  * g_queue_peek_nth:
21966  * @queue: a #GQueue
21967  * @n: the position of the element.
21968  *
21969  * Returns the @n'th element of @queue.
21970  *
21971  * Returns: The data for the @n'th element of @queue, or %NULL if @n is off the end of @queue.
21972  * Since: 2.4
21973  */
21974
21975
21976 /**
21977  * g_queue_peek_nth_link:
21978  * @queue: a #GQueue
21979  * @n: the position of the link
21980  *
21981  * Returns the link at the given position
21982  *
21983  * Returns: The link at the @n'th position, or %NULL if @n is off the end of the list
21984  * Since: 2.4
21985  */
21986
21987
21988 /**
21989  * g_queue_peek_tail:
21990  * @queue: a #GQueue.
21991  *
21992  * Returns the last element of the queue.
21993  *
21994  * Returns: the data of the last element in the queue, or %NULL if the queue is empty.
21995  */
21996
21997
21998 /**
21999  * g_queue_peek_tail_link:
22000  * @queue: a #GQueue
22001  *
22002  * Returns the last link @queue.
22003  *
22004  * Returns: the last link in @queue, or %NULL if @queue is empty
22005  * Since: 2.4
22006  */
22007
22008
22009 /**
22010  * g_queue_pop_head:
22011  * @queue: a #GQueue.
22012  *
22013  * Removes the first element of the queue.
22014  *
22015  * Returns: the data of the first element in the queue, or %NULL if the queue is empty.
22016  */
22017
22018
22019 /**
22020  * g_queue_pop_head_link:
22021  * @queue: a #GQueue.
22022  *
22023  * Removes the first element of the queue.
22024  *
22025  * Returns: the #GList element at the head of the queue, or %NULL if the queue is empty.
22026  */
22027
22028
22029 /**
22030  * g_queue_pop_nth:
22031  * @queue: a #GQueue
22032  * @n: the position of the element.
22033  *
22034  * Removes the @n'th element of @queue.
22035  *
22036  * Returns: the element's data, or %NULL if @n is off the end of @queue.
22037  * Since: 2.4
22038  */
22039
22040
22041 /**
22042  * g_queue_pop_nth_link:
22043  * @queue: a #GQueue
22044  * @n: the link's position
22045  *
22046  * Removes and returns the link at the given position.
22047  *
22048  * Returns: The @n'th link, or %NULL if @n is off the end of @queue.
22049  * Since: 2.4
22050  */
22051
22052
22053 /**
22054  * g_queue_pop_tail:
22055  * @queue: a #GQueue.
22056  *
22057  * Removes the last element of the queue.
22058  *
22059  * Returns: the data of the last element in the queue, or %NULL if the queue is empty.
22060  */
22061
22062
22063 /**
22064  * g_queue_pop_tail_link:
22065  * @queue: a #GQueue.
22066  *
22067  * Removes the last element of the queue.
22068  *
22069  * Returns: the #GList element at the tail of the queue, or %NULL if the queue is empty.
22070  */
22071
22072
22073 /**
22074  * g_queue_push_head:
22075  * @queue: a #GQueue.
22076  * @data: the data for the new element.
22077  *
22078  * Adds a new element at the head of the queue.
22079  */
22080
22081
22082 /**
22083  * g_queue_push_head_link:
22084  * @queue: a #GQueue.
22085  * @link_: a single #GList element, <emphasis>not</emphasis> a list with more than one element.
22086  *
22087  * Adds a new element at the head of the queue.
22088  */
22089
22090
22091 /**
22092  * g_queue_push_nth:
22093  * @queue: a #GQueue
22094  * @data: the data for the new element
22095  * @n: the position to insert the new element. If @n is negative or larger than the number of elements in the @queue, the element is added to the end of the queue.
22096  *
22097  * Inserts a new element into @queue at the given position
22098  *
22099  * Since: 2.4
22100  */
22101
22102
22103 /**
22104  * g_queue_push_nth_link:
22105  * @queue: a #GQueue
22106  * @n: the position to insert the link. If this is negative or larger than the number of elements in @queue, the link is added to the end of @queue.
22107  * @link_: the link to add to @queue
22108  *
22109  * Inserts @link into @queue at the given position.
22110  *
22111  * Since: 2.4
22112  */
22113
22114
22115 /**
22116  * g_queue_push_tail:
22117  * @queue: a #GQueue.
22118  * @data: the data for the new element.
22119  *
22120  * Adds a new element at the tail of the queue.
22121  */
22122
22123
22124 /**
22125  * g_queue_push_tail_link:
22126  * @queue: a #GQueue.
22127  * @link_: a single #GList element, <emphasis>not</emphasis> a list with more than one element.
22128  *
22129  * Adds a new element at the tail of the queue.
22130  */
22131
22132
22133 /**
22134  * g_queue_remove:
22135  * @queue: a #GQueue
22136  * @data: data to remove.
22137  *
22138  * Removes the first element in @queue that contains @data.
22139  *
22140  * Returns: %TRUE if @data was found and removed from @queue
22141  * Since: 2.4
22142  */
22143
22144
22145 /**
22146  * g_queue_remove_all:
22147  * @queue: a #GQueue
22148  * @data: data to remove
22149  *
22150  * Remove all elements whose data equals @data from @queue.
22151  *
22152  * Returns: the number of elements removed from @queue
22153  * Since: 2.4
22154  */
22155
22156
22157 /**
22158  * g_queue_reverse:
22159  * @queue: a #GQueue
22160  *
22161  * Reverses the order of the items in @queue.
22162  *
22163  * Since: 2.4
22164  */
22165
22166
22167 /**
22168  * g_queue_sort:
22169  * @queue: a #GQueue
22170  * @compare_func: the #GCompareDataFunc used to sort @queue. This function is passed two elements of the queue and should return 0 if they are equal, a negative value if the first comes before the second, and a positive value if the second comes before the first.
22171  * @user_data: user data passed to @compare_func
22172  *
22173  * Sorts @queue using @compare_func.
22174  *
22175  * Since: 2.4
22176  */
22177
22178
22179 /**
22180  * g_queue_unlink:
22181  * @queue: a #GQueue
22182  * @link_: a #GList link that <emphasis>must</emphasis> be part of @queue
22183  *
22184  * Unlinks @link_ so that it will no longer be part of @queue. The link is
22185  * not freed.
22186  *
22187  * @link_ must be part of @queue,
22188  *
22189  * Since: 2.4
22190  */
22191
22192
22193 /**
22194  * g_rand_boolean:
22195  * @rand_: a #GRand.
22196  *
22197  * Returns a random #gboolean from @rand_. This corresponds to a
22198  * unbiased coin toss.
22199  *
22200  * Returns: a random #gboolean.
22201  */
22202
22203
22204 /**
22205  * g_rand_copy:
22206  * @rand_: a #GRand.
22207  *
22208  * Copies a #GRand into a new one with the same exact state as before.
22209  * This way you can take a snapshot of the random number generator for
22210  * replaying later.
22211  *
22212  * Returns: the new #GRand.
22213  * Since: 2.4
22214  */
22215
22216
22217 /**
22218  * g_rand_double:
22219  * @rand_: a #GRand.
22220  *
22221  * Returns the next random #gdouble from @rand_ equally distributed over
22222  * the range [0..1).
22223  *
22224  * Returns: A random number.
22225  */
22226
22227
22228 /**
22229  * g_rand_double_range:
22230  * @rand_: a #GRand.
22231  * @begin: lower closed bound of the interval.
22232  * @end: upper open bound of the interval.
22233  *
22234  * Returns the next random #gdouble from @rand_ equally distributed over
22235  * the range [@begin..@end).
22236  *
22237  * Returns: A random number.
22238  */
22239
22240
22241 /**
22242  * g_rand_free:
22243  * @rand_: a #GRand.
22244  *
22245  * Frees the memory allocated for the #GRand.
22246  */
22247
22248
22249 /**
22250  * g_rand_int:
22251  * @rand_: a #GRand.
22252  *
22253  * Returns the next random #guint32 from @rand_ equally distributed over
22254  * the range [0..2^32-1].
22255  *
22256  * Returns: A random number.
22257  */
22258
22259
22260 /**
22261  * g_rand_int_range:
22262  * @rand_: a #GRand.
22263  * @begin: lower closed bound of the interval.
22264  * @end: upper open bound of the interval.
22265  *
22266  * Returns the next random #gint32 from @rand_ equally distributed over
22267  * the range [@begin..@end-1].
22268  *
22269  * Returns: A random number.
22270  */
22271
22272
22273 /**
22274  * g_rand_new:
22275  *
22276  * Creates a new random number generator initialized with a seed taken
22277  * either from <filename>/dev/urandom</filename> (if existing) or from
22278  * the current time (as a fallback).
22279  *
22280  * Returns: the new #GRand.
22281  */
22282
22283
22284 /**
22285  * g_rand_new_with_seed:
22286  * @seed: a value to initialize the random number generator.
22287  *
22288  * Creates a new random number generator initialized with @seed.
22289  *
22290  * Returns: the new #GRand.
22291  */
22292
22293
22294 /**
22295  * g_rand_new_with_seed_array:
22296  * @seed: an array of seeds to initialize the random number generator.
22297  * @seed_length: an array of seeds to initialize the random number generator.
22298  *
22299  * Creates a new random number generator initialized with @seed.
22300  *
22301  * Returns: the new #GRand.
22302  * Since: 2.4
22303  */
22304
22305
22306 /**
22307  * g_rand_set_seed:
22308  * @rand_: a #GRand.
22309  * @seed: a value to reinitialize the random number generator.
22310  *
22311  * Sets the seed for the random number generator #GRand to @seed.
22312  */
22313
22314
22315 /**
22316  * g_rand_set_seed_array:
22317  * @rand_: a #GRand.
22318  * @seed: array to initialize with
22319  * @seed_length: length of array
22320  *
22321  * Initializes the random number generator by an array of
22322  * longs.  Array can be of arbitrary size, though only the
22323  * first 624 values are taken.  This function is useful
22324  * if you have many low entropy seeds, or if you require more then
22325  * 32bits of actual entropy for your application.
22326  *
22327  * Since: 2.4
22328  */
22329
22330
22331 /**
22332  * g_random_boolean:
22333  *
22334  * Returns a random #gboolean. This corresponds to a unbiased coin toss.
22335  *
22336  * Returns: a random #gboolean.
22337  */
22338
22339
22340 /**
22341  * g_random_double:
22342  *
22343  * Returns a random #gdouble equally distributed over the range [0..1).
22344  *
22345  * Returns: A random number.
22346  */
22347
22348
22349 /**
22350  * g_random_double_range:
22351  * @begin: lower closed bound of the interval.
22352  * @end: upper open bound of the interval.
22353  *
22354  * Returns a random #gdouble equally distributed over the range [@begin..@end).
22355  *
22356  * Returns: A random number.
22357  */
22358
22359
22360 /**
22361  * g_random_int:
22362  *
22363  * Return a random #guint32 equally distributed over the range
22364  * [0..2^32-1].
22365  *
22366  * Returns: A random number.
22367  */
22368
22369
22370 /**
22371  * g_random_int_range:
22372  * @begin: lower closed bound of the interval.
22373  * @end: upper open bound of the interval.
22374  *
22375  * Returns a random #gint32 equally distributed over the range
22376  * [@begin..@end-1].
22377  *
22378  * Returns: A random number.
22379  */
22380
22381
22382 /**
22383  * g_random_set_seed:
22384  * @seed: a value to reinitialize the global random number generator.
22385  *
22386  * Sets the seed for the global random number generator, which is used
22387  * by the <function>g_random_*</function> functions, to @seed.
22388  */
22389
22390
22391 /**
22392  * g_realloc:
22393  * @mem: the memory to reallocate
22394  * @n_bytes: new size of the memory in bytes
22395  *
22396  * Reallocates the memory pointed to by @mem, so that it now has space for
22397  * @n_bytes bytes of memory. It returns the new address of the memory, which may
22398  * have been moved. @mem may be %NULL, in which case it's considered to
22399  * have zero-length. @n_bytes may be 0, in which case %NULL will be returned
22400  * and @mem will be freed unless it is %NULL.
22401  *
22402  * Returns: the new address of the allocated memory
22403  */
22404
22405
22406 /**
22407  * g_realloc_n:
22408  * @mem: the memory to reallocate
22409  * @n_blocks: the number of blocks to allocate
22410  * @n_block_bytes: the size of each block in bytes
22411  *
22412  * This function is similar to g_realloc(), allocating (@n_blocks * @n_block_bytes) bytes,
22413  * but care is taken to detect possible overflow during multiplication.
22414  *
22415  * Since: 2.24
22416  * Returns: the new address of the allocated memory
22417  */
22418
22419
22420 /**
22421  * g_rec_mutex_clear:
22422  * @rec_mutex: an initialized #GRecMutex
22423  *
22424  * Frees the resources allocated to a recursive mutex with
22425  * g_rec_mutex_init().
22426  *
22427  * This function should not be used with a #GRecMutex that has been
22428  * statically allocated.
22429  *
22430  * Calling g_rec_mutex_clear() on a locked recursive mutex leads
22431  * to undefined behaviour.
22432  *
22433  * Sine: 2.32
22434  */
22435
22436
22437 /**
22438  * g_rec_mutex_init:
22439  * @rec_mutex: an uninitialized #GRecMutex
22440  *
22441  * Initializes a #GRecMutex so that it can be used.
22442  *
22443  * This function is useful to initialize a recursive mutex
22444  * that has been allocated on the stack, or as part of a larger
22445  * structure.
22446  *
22447  * It is not necessary to initialise a recursive mutex that has been
22448  * statically allocated.
22449  *
22450  * |[
22451  *   typedef struct {
22452  *     GRecMutex m;
22453  *     ...
22454  *   } Blob;
22455  *
22456  * Blob *b;
22457  *
22458  * b = g_new (Blob, 1);
22459  * g_rec_mutex_init (&b->m);
22460  * ]|
22461  *
22462  * Calling g_rec_mutex_init() on an already initialized #GRecMutex
22463  * leads to undefined behaviour.
22464  *
22465  * To undo the effect of g_rec_mutex_init() when a recursive mutex
22466  * is no longer needed, use g_rec_mutex_clear().
22467  *
22468  * Since: 2.32
22469  */
22470
22471
22472 /**
22473  * g_rec_mutex_lock:
22474  * @rec_mutex: a #GRecMutex
22475  *
22476  * Locks @rec_mutex. If @rec_mutex is already locked by another
22477  * thread, the current thread will block until @rec_mutex is
22478  * unlocked by the other thread. If @rec_mutex is already locked
22479  * by the current thread, the 'lock count' of @rec_mutex is increased.
22480  * The mutex will only become available again when it is unlocked
22481  * as many times as it has been locked.
22482  *
22483  * Since: 2.32
22484  */
22485
22486
22487 /**
22488  * g_rec_mutex_trylock:
22489  * @rec_mutex: a #GRecMutex
22490  *
22491  * Tries to lock @rec_mutex. If @rec_mutex is already locked
22492  * by another thread, it immediately returns %FALSE. Otherwise
22493  * it locks @rec_mutex and returns %TRUE.
22494  *
22495  * Returns: %TRUE if @rec_mutex could be locked
22496  * Since: 2.32
22497  */
22498
22499
22500 /**
22501  * g_rec_mutex_unlock:
22502  * @rec_mutex: a #GRecMutex
22503  *
22504  * Unlocks @rec_mutex. If another thread is blocked in a
22505  * g_rec_mutex_lock() call for @rec_mutex, it will become unblocked
22506  * and can lock @rec_mutex itself.
22507  *
22508  * Calling g_rec_mutex_unlock() on a recursive mutex that is not
22509  * locked by the current thread leads to undefined behaviour.
22510  *
22511  * Since: 2.32
22512  */
22513
22514
22515 /**
22516  * g_regex_check_replacement:
22517  * @replacement: the replacement string
22518  * @has_references: (out) (allow-none): location to store information about references in @replacement or %NULL
22519  * @error: location to store error
22520  *
22521  * Checks whether @replacement is a valid replacement string
22522  * (see g_regex_replace()), i.e. that all escape sequences in
22523  * it are valid.
22524  *
22525  * If @has_references is not %NULL then @replacement is checked
22526  * for pattern references. For instance, replacement text 'foo\n'
22527  * does not contain references and may be evaluated without information
22528  * about actual match, but '\0\1' (whole match followed by first
22529  * subpattern) requires valid #GMatchInfo object.
22530  *
22531  * Returns: whether @replacement is a valid replacement string
22532  * Since: 2.14
22533  */
22534
22535
22536 /**
22537  * g_regex_escape_nul:
22538  * @string: the string to escape
22539  * @length: the length of @string
22540  *
22541  * Escapes the nul characters in @string to "\x00".  It can be used
22542  * to compile a regex with embedded nul characters.
22543  *
22544  * For completeness, @length can be -1 for a nul-terminated string.
22545  * In this case the output string will be of course equal to @string.
22546  *
22547  * Returns: a newly-allocated escaped string
22548  * Since: 2.30
22549  */
22550
22551
22552 /**
22553  * g_regex_escape_string:
22554  * @string: (array length=length): the string to escape
22555  * @length: the length of @string, or -1 if @string is nul-terminated
22556  *
22557  * Escapes the special characters used for regular expressions
22558  * in @string, for instance "a.b*c" becomes "a\.b\*c". This
22559  * function is useful to dynamically generate regular expressions.
22560  *
22561  * @string can contain nul characters that are replaced with "\0",
22562  * in this case remember to specify the correct length of @string
22563  * in @length.
22564  *
22565  * Returns: a newly-allocated escaped string
22566  * Since: 2.14
22567  */
22568
22569
22570 /**
22571  * g_regex_get_capture_count:
22572  * @regex: a #GRegex
22573  *
22574  * Returns the number of capturing subpatterns in the pattern.
22575  *
22576  * Returns: the number of capturing subpatterns
22577  * Since: 2.14
22578  */
22579
22580
22581 /**
22582  * g_regex_get_compile_flags:
22583  * @regex: a #GRegex
22584  *
22585  * Returns the compile options that @regex was created with.
22586  *
22587  * Returns: flags from #GRegexCompileFlags
22588  * Since: 2.26
22589  */
22590
22591
22592 /**
22593  * g_regex_get_has_cr_or_lf:
22594  * @regex: a #GRegex structure
22595  *
22596  * Checks whether the pattern contains explicit CR or LF references.
22597  *
22598  * Returns: %TRUE if the pattern contains explicit CR or LF references
22599  * Since: 2.34
22600  */
22601
22602
22603 /**
22604  * g_regex_get_match_flags:
22605  * @regex: a #GRegex
22606  *
22607  * Returns the match options that @regex was created with.
22608  *
22609  * Returns: flags from #GRegexMatchFlags
22610  * Since: 2.26
22611  */
22612
22613
22614 /**
22615  * g_regex_get_max_backref:
22616  * @regex: a #GRegex
22617  *
22618  * Returns the number of the highest back reference
22619  * in the pattern, or 0 if the pattern does not contain
22620  * back references.
22621  *
22622  * Returns: the number of the highest back reference
22623  * Since: 2.14
22624  */
22625
22626
22627 /**
22628  * g_regex_get_max_lookbehind:
22629  * @regex: a #GRegex structure
22630  *
22631  * Gets the number of characters in the longest lookbehind assertion in the
22632  * pattern. This information is useful when doing multi-segment matching using
22633  * the partial matching facilities.
22634  *
22635  * Returns: the number of characters in the longest lookbehind assertion.
22636  * Since: 2.38
22637  */
22638
22639
22640 /**
22641  * g_regex_get_pattern:
22642  * @regex: a #GRegex structure
22643  *
22644  * Gets the pattern string associated with @regex, i.e. a copy of
22645  * the string passed to g_regex_new().
22646  *
22647  * Returns: the pattern of @regex
22648  * Since: 2.14
22649  */
22650
22651
22652 /**
22653  * g_regex_get_string_number:
22654  * @regex: #GRegex structure
22655  * @name: name of the subexpression
22656  *
22657  * Retrieves the number of the subexpression named @name.
22658  *
22659  * Returns: The number of the subexpression or -1 if @name does not exists
22660  * Since: 2.14
22661  */
22662
22663
22664 /**
22665  * g_regex_match:
22666  * @regex: a #GRegex structure from g_regex_new()
22667  * @string: the string to scan for matches
22668  * @match_options: match options
22669  * @match_info: (out) (allow-none): pointer to location where to store the #GMatchInfo, or %NULL if you do not need it
22670  *
22671  * Scans for a match in string for the pattern in @regex.
22672  * The @match_options are combined with the match options specified
22673  * when the @regex structure was created, letting you have more
22674  * flexibility in reusing #GRegex structures.
22675  *
22676  * A #GMatchInfo structure, used to get information on the match,
22677  * is stored in @match_info if not %NULL. Note that if @match_info
22678  * is not %NULL then it is created even if the function returns %FALSE,
22679  * i.e. you must free it regardless if regular expression actually matched.
22680  *
22681  * To retrieve all the non-overlapping matches of the pattern in
22682  * string you can use g_match_info_next().
22683  *
22684  * |[
22685  * static void
22686  * print_uppercase_words (const gchar *string)
22687  * {
22688  *   /&ast; Print all uppercase-only words. &ast;/
22689  *   GRegex *regex;
22690  *   GMatchInfo *match_info;
22691  *   &nbsp;
22692  *   regex = g_regex_new ("[A-Z]+", 0, 0, NULL);
22693  *   g_regex_match (regex, string, 0, &amp;match_info);
22694  *   while (g_match_info_matches (match_info))
22695  *     {
22696  *       gchar *word = g_match_info_fetch (match_info, 0);
22697  *       g_print ("Found: %s\n", word);
22698  *       g_free (word);
22699  *       g_match_info_next (match_info, NULL);
22700  *     }
22701  *   g_match_info_free (match_info);
22702  *   g_regex_unref (regex);
22703  * }
22704  * ]|
22705  *
22706  * @string is not copied and is used in #GMatchInfo internally. If
22707  * you use any #GMatchInfo method (except g_match_info_free()) after
22708  * freeing or modifying @string then the behaviour is undefined.
22709  *
22710  * Returns: %TRUE is the string matched, %FALSE otherwise
22711  * Since: 2.14
22712  */
22713
22714
22715 /**
22716  * g_regex_match_all:
22717  * @regex: a #GRegex structure from g_regex_new()
22718  * @string: the string to scan for matches
22719  * @match_options: match options
22720  * @match_info: (out) (allow-none): pointer to location where to store the #GMatchInfo, or %NULL if you do not need it
22721  *
22722  * Using the standard algorithm for regular expression matching only
22723  * the longest match in the string is retrieved. This function uses
22724  * a different algorithm so it can retrieve all the possible matches.
22725  * For more documentation see g_regex_match_all_full().
22726  *
22727  * A #GMatchInfo structure, used to get information on the match, is
22728  * stored in @match_info if not %NULL. Note that if @match_info is
22729  * not %NULL then it is created even if the function returns %FALSE,
22730  * i.e. you must free it regardless if regular expression actually
22731  * matched.
22732  *
22733  * @string is not copied and is used in #GMatchInfo internally. If
22734  * you use any #GMatchInfo method (except g_match_info_free()) after
22735  * freeing or modifying @string then the behaviour is undefined.
22736  *
22737  * Returns: %TRUE is the string matched, %FALSE otherwise
22738  * Since: 2.14
22739  */
22740
22741
22742 /**
22743  * g_regex_match_all_full:
22744  * @regex: a #GRegex structure from g_regex_new()
22745  * @string: (array length=string_len): the string to scan for matches
22746  * @string_len: the length of @string, or -1 if @string is nul-terminated
22747  * @start_position: starting index of the string to match
22748  * @match_options: match options
22749  * @match_info: (out) (allow-none): pointer to location where to store the #GMatchInfo, or %NULL if you do not need it
22750  * @error: location to store the error occurring, or %NULL to ignore errors
22751  *
22752  * Using the standard algorithm for regular expression matching only
22753  * the longest match in the string is retrieved, it is not possible
22754  * to obtain all the available matches. For instance matching
22755  * "&lt;a&gt; &lt;b&gt; &lt;c&gt;" against the pattern "&lt;.*&gt;"
22756  * you get "&lt;a&gt; &lt;b&gt; &lt;c&gt;".
22757  *
22758  * This function uses a different algorithm (called DFA, i.e. deterministic
22759  * finite automaton), so it can retrieve all the possible matches, all
22760  * starting at the same point in the string. For instance matching
22761  * "&lt;a&gt; &lt;b&gt; &lt;c&gt;" against the pattern "&lt;.*&gt;"
22762  * you would obtain three matches: "&lt;a&gt; &lt;b&gt; &lt;c&gt;",
22763  * "&lt;a&gt; &lt;b&gt;" and "&lt;a&gt;".
22764  *
22765  * The number of matched strings is retrieved using
22766  * g_match_info_get_match_count(). To obtain the matched strings and
22767  * their position you can use, respectively, g_match_info_fetch() and
22768  * g_match_info_fetch_pos(). Note that the strings are returned in
22769  * reverse order of length; that is, the longest matching string is
22770  * given first.
22771  *
22772  * Note that the DFA algorithm is slower than the standard one and it
22773  * is not able to capture substrings, so backreferences do not work.
22774  *
22775  * Setting @start_position differs from just passing over a shortened
22776  * string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern
22777  * that begins with any kind of lookbehind assertion, such as "\b".
22778  *
22779  * A #GMatchInfo structure, used to get information on the match, is
22780  * stored in @match_info if not %NULL. Note that if @match_info is
22781  * not %NULL then it is created even if the function returns %FALSE,
22782  * i.e. you must free it regardless if regular expression actually
22783  * matched.
22784  *
22785  * @string is not copied and is used in #GMatchInfo internally. If
22786  * you use any #GMatchInfo method (except g_match_info_free()) after
22787  * freeing or modifying @string then the behaviour is undefined.
22788  *
22789  * Returns: %TRUE is the string matched, %FALSE otherwise
22790  * Since: 2.14
22791  */
22792
22793
22794 /**
22795  * g_regex_match_full:
22796  * @regex: a #GRegex structure from g_regex_new()
22797  * @string: (array length=string_len): the string to scan for matches
22798  * @string_len: the length of @string, or -1 if @string is nul-terminated
22799  * @start_position: starting index of the string to match
22800  * @match_options: match options
22801  * @match_info: (out) (allow-none): pointer to location where to store the #GMatchInfo, or %NULL if you do not need it
22802  * @error: location to store the error occurring, or %NULL to ignore errors
22803  *
22804  * Scans for a match in string for the pattern in @regex.
22805  * The @match_options are combined with the match options specified
22806  * when the @regex structure was created, letting you have more
22807  * flexibility in reusing #GRegex structures.
22808  *
22809  * Setting @start_position differs from just passing over a shortened
22810  * string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern
22811  * that begins with any kind of lookbehind assertion, such as "\b".
22812  *
22813  * A #GMatchInfo structure, used to get information on the match, is
22814  * stored in @match_info if not %NULL. Note that if @match_info is
22815  * not %NULL then it is created even if the function returns %FALSE,
22816  * i.e. you must free it regardless if regular expression actually
22817  * matched.
22818  *
22819  * @string is not copied and is used in #GMatchInfo internally. If
22820  * you use any #GMatchInfo method (except g_match_info_free()) after
22821  * freeing or modifying @string then the behaviour is undefined.
22822  *
22823  * To retrieve all the non-overlapping matches of the pattern in
22824  * string you can use g_match_info_next().
22825  *
22826  * |[
22827  * static void
22828  * print_uppercase_words (const gchar *string)
22829  * {
22830  *   /&ast; Print all uppercase-only words. &ast;/
22831  *   GRegex *regex;
22832  *   GMatchInfo *match_info;
22833  *   GError *error = NULL;
22834  *   &nbsp;
22835  *   regex = g_regex_new ("[A-Z]+", 0, 0, NULL);
22836  *   g_regex_match_full (regex, string, -1, 0, 0, &amp;match_info, &amp;error);
22837  *   while (g_match_info_matches (match_info))
22838  *     {
22839  *       gchar *word = g_match_info_fetch (match_info, 0);
22840  *       g_print ("Found: %s\n", word);
22841  *       g_free (word);
22842  *       g_match_info_next (match_info, &amp;error);
22843  *     }
22844  *   g_match_info_free (match_info);
22845  *   g_regex_unref (regex);
22846  *   if (error != NULL)
22847  *     {
22848  *       g_printerr ("Error while matching: %s\n", error->message);
22849  *       g_error_free (error);
22850  *     }
22851  * }
22852  * ]|
22853  *
22854  * Returns: %TRUE is the string matched, %FALSE otherwise
22855  * Since: 2.14
22856  */
22857
22858
22859 /**
22860  * g_regex_match_simple:
22861  * @pattern: the regular expression
22862  * @string: the string to scan for matches
22863  * @compile_options: compile options for the regular expression, or 0
22864  * @match_options: match options, or 0
22865  *
22866  * Scans for a match in @string for @pattern.
22867  *
22868  * This function is equivalent to g_regex_match() but it does not
22869  * require to compile the pattern with g_regex_new(), avoiding some
22870  * lines of code when you need just to do a match without extracting
22871  * substrings, capture counts, and so on.
22872  *
22873  * If this function is to be called on the same @pattern more than
22874  * once, it's more efficient to compile the pattern once with
22875  * g_regex_new() and then use g_regex_match().
22876  *
22877  * Returns: %TRUE if the string matched, %FALSE otherwise
22878  * Since: 2.14
22879  */
22880
22881
22882 /**
22883  * g_regex_new:
22884  * @pattern: the regular expression
22885  * @compile_options: compile options for the regular expression, or 0
22886  * @match_options: match options for the regular expression, or 0
22887  * @error: return location for a #GError
22888  *
22889  * Compiles the regular expression to an internal form, and does
22890  * the initial setup of the #GRegex structure.
22891  *
22892  * Returns: a #GRegex structure. Call g_regex_unref() when you are done with it
22893  * Since: 2.14
22894  */
22895
22896
22897 /**
22898  * g_regex_ref:
22899  * @regex: a #GRegex
22900  *
22901  * Increases reference count of @regex by 1.
22902  *
22903  * Returns: @regex
22904  * Since: 2.14
22905  */
22906
22907
22908 /**
22909  * g_regex_replace:
22910  * @regex: a #GRegex structure
22911  * @string: (array length=string_len): the string to perform matches against
22912  * @string_len: the length of @string, or -1 if @string is nul-terminated
22913  * @start_position: starting index of the string to match
22914  * @replacement: text to replace each match with
22915  * @match_options: options for the match
22916  * @error: location to store the error occurring, or %NULL to ignore errors
22917  *
22918  * Replaces all occurrences of the pattern in @regex with the
22919  * replacement text. Backreferences of the form '\number' or
22920  * '\g&lt;number&gt;' in the replacement text are interpolated by the
22921  * number-th captured subexpression of the match, '\g&lt;name&gt;' refers
22922  * to the captured subexpression with the given name. '\0' refers to the
22923  * complete match, but '\0' followed by a number is the octal representation
22924  * of a character. To include a literal '\' in the replacement, write '\\'.
22925  * There are also escapes that changes the case of the following text:
22926  *
22927  * <variablelist>
22928  * <varlistentry><term>\l</term>
22929  * <listitem>
22930  * <para>Convert to lower case the next character</para>
22931  * </listitem>
22932  * </varlistentry>
22933  * <varlistentry><term>\u</term>
22934  * <listitem>
22935  * <para>Convert to upper case the next character</para>
22936  * </listitem>
22937  * </varlistentry>
22938  * <varlistentry><term>\L</term>
22939  * <listitem>
22940  * <para>Convert to lower case till \E</para>
22941  * </listitem>
22942  * </varlistentry>
22943  * <varlistentry><term>\U</term>
22944  * <listitem>
22945  * <para>Convert to upper case till \E</para>
22946  * </listitem>
22947  * </varlistentry>
22948  * <varlistentry><term>\E</term>
22949  * <listitem>
22950  * <para>End case modification</para>
22951  * </listitem>
22952  * </varlistentry>
22953  * </variablelist>
22954  *
22955  * If you do not need to use backreferences use g_regex_replace_literal().
22956  *
22957  * The @replacement string must be UTF-8 encoded even if #G_REGEX_RAW was
22958  * passed to g_regex_new(). If you want to use not UTF-8 encoded stings
22959  * you can use g_regex_replace_literal().
22960  *
22961  * Setting @start_position differs from just passing over a shortened
22962  * string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern that
22963  * begins with any kind of lookbehind assertion, such as "\b".
22964  *
22965  * Returns: a newly allocated string containing the replacements
22966  * Since: 2.14
22967  */
22968
22969
22970 /**
22971  * g_regex_replace_eval:
22972  * @regex: a #GRegex structure from g_regex_new()
22973  * @string: (array length=string_len): string to perform matches against
22974  * @string_len: the length of @string, or -1 if @string is nul-terminated
22975  * @start_position: starting index of the string to match
22976  * @match_options: options for the match
22977  * @eval: a function to call for each match
22978  * @user_data: user data to pass to the function
22979  * @error: location to store the error occurring, or %NULL to ignore errors
22980  *
22981  * Replaces occurrences of the pattern in regex with the output of
22982  * @eval for that occurrence.
22983  *
22984  * Setting @start_position differs from just passing over a shortened
22985  * string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern
22986  * that begins with any kind of lookbehind assertion, such as "\b".
22987  *
22988  * The following example uses g_regex_replace_eval() to replace multiple
22989  * strings at once:
22990  * |[
22991  * static gboolean
22992  * eval_cb (const GMatchInfo *info,
22993  *          GString          *res,
22994  *          gpointer          data)
22995  * {
22996  *   gchar *match;
22997  *   gchar *r;
22998  *
22999  *    match = g_match_info_fetch (info, 0);
23000  *    r = g_hash_table_lookup ((GHashTable *)data, match);
23001  *    g_string_append (res, r);
23002  *    g_free (match);
23003  *
23004  *    return FALSE;
23005  * }
23006  *
23007  * /&ast; ... &ast;/
23008  *
23009  * GRegex *reg;
23010  * GHashTable *h;
23011  * gchar *res;
23012  *
23013  * h = g_hash_table_new (g_str_hash, g_str_equal);
23014  *
23015  * g_hash_table_insert (h, "1", "ONE");
23016  * g_hash_table_insert (h, "2", "TWO");
23017  * g_hash_table_insert (h, "3", "THREE");
23018  * g_hash_table_insert (h, "4", "FOUR");
23019  *
23020  * reg = g_regex_new ("1|2|3|4", 0, 0, NULL);
23021  * res = g_regex_replace_eval (reg, text, -1, 0, 0, eval_cb, h, NULL);
23022  * g_hash_table_destroy (h);
23023  *
23024  * /&ast; ... &ast;/
23025  * ]|
23026  *
23027  * Returns: a newly allocated string containing the replacements
23028  * Since: 2.14
23029  */
23030
23031
23032 /**
23033  * g_regex_replace_literal:
23034  * @regex: a #GRegex structure
23035  * @string: (array length=string_len): the string to perform matches against
23036  * @string_len: the length of @string, or -1 if @string is nul-terminated
23037  * @start_position: starting index of the string to match
23038  * @replacement: text to replace each match with
23039  * @match_options: options for the match
23040  * @error: location to store the error occurring, or %NULL to ignore errors
23041  *
23042  * Replaces all occurrences of the pattern in @regex with the
23043  * replacement text. @replacement is replaced literally, to
23044  * include backreferences use g_regex_replace().
23045  *
23046  * Setting @start_position differs from just passing over a
23047  * shortened string and setting #G_REGEX_MATCH_NOTBOL in the
23048  * case of a pattern that begins with any kind of lookbehind
23049  * assertion, such as "\b".
23050  *
23051  * Returns: a newly allocated string containing the replacements
23052  * Since: 2.14
23053  */
23054
23055
23056 /**
23057  * g_regex_split:
23058  * @regex: a #GRegex structure
23059  * @string: the string to split with the pattern
23060  * @match_options: match time option flags
23061  *
23062  * Breaks the string on the pattern, and returns an array of the tokens.
23063  * If the pattern contains capturing parentheses, then the text for each
23064  * of the substrings will also be returned. If the pattern does not match
23065  * anywhere in the string, then the whole string is returned as the first
23066  * token.
23067  *
23068  * As a special case, the result of splitting the empty string "" is an
23069  * empty vector, not a vector containing a single string. The reason for
23070  * this special case is that being able to represent a empty vector is
23071  * typically more useful than consistent handling of empty elements. If
23072  * you do need to represent empty elements, you'll need to check for the
23073  * empty string before calling this function.
23074  *
23075  * A pattern that can match empty strings splits @string into separate
23076  * characters wherever it matches the empty string between characters.
23077  * For example splitting "ab c" using as a separator "\s*", you will get
23078  * "a", "b" and "c".
23079  *
23080  * Returns: (transfer full): a %NULL-terminated gchar ** array. Free it using g_strfreev()
23081  * Since: 2.14
23082  */
23083
23084
23085 /**
23086  * g_regex_split_full:
23087  * @regex: a #GRegex structure
23088  * @string: (array length=string_len): the string to split with the pattern
23089  * @string_len: the length of @string, or -1 if @string is nul-terminated
23090  * @start_position: starting index of the string to match
23091  * @match_options: match time option flags
23092  * @max_tokens: the maximum number of tokens to split @string into. If this is less than 1, the string is split completely
23093  * @error: return location for a #GError
23094  *
23095  * Breaks the string on the pattern, and returns an array of the tokens.
23096  * If the pattern contains capturing parentheses, then the text for each
23097  * of the substrings will also be returned. If the pattern does not match
23098  * anywhere in the string, then the whole string is returned as the first
23099  * token.
23100  *
23101  * As a special case, the result of splitting the empty string "" is an
23102  * empty vector, not a vector containing a single string. The reason for
23103  * this special case is that being able to represent a empty vector is
23104  * typically more useful than consistent handling of empty elements. If
23105  * you do need to represent empty elements, you'll need to check for the
23106  * empty string before calling this function.
23107  *
23108  * A pattern that can match empty strings splits @string into separate
23109  * characters wherever it matches the empty string between characters.
23110  * For example splitting "ab c" using as a separator "\s*", you will get
23111  * "a", "b" and "c".
23112  *
23113  * Setting @start_position differs from just passing over a shortened
23114  * string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern
23115  * that begins with any kind of lookbehind assertion, such as "\b".
23116  *
23117  * Returns: (transfer full): a %NULL-terminated gchar ** array. Free it using g_strfreev()
23118  * Since: 2.14
23119  */
23120
23121
23122 /**
23123  * g_regex_split_simple:
23124  * @pattern: the regular expression
23125  * @string: the string to scan for matches
23126  * @compile_options: compile options for the regular expression, or 0
23127  * @match_options: match options, or 0
23128  *
23129  * Breaks the string on the pattern, and returns an array of
23130  * the tokens. If the pattern contains capturing parentheses,
23131  * then the text for each of the substrings will also be returned.
23132  * If the pattern does not match anywhere in the string, then the
23133  * whole string is returned as the first token.
23134  *
23135  * This function is equivalent to g_regex_split() but it does
23136  * not require to compile the pattern with g_regex_new(), avoiding
23137  * some lines of code when you need just to do a split without
23138  * extracting substrings, capture counts, and so on.
23139  *
23140  * If this function is to be called on the same @pattern more than
23141  * once, it's more efficient to compile the pattern once with
23142  * g_regex_new() and then use g_regex_split().
23143  *
23144  * As a special case, the result of splitting the empty string ""
23145  * is an empty vector, not a vector containing a single string.
23146  * The reason for this special case is that being able to represent
23147  * a empty vector is typically more useful than consistent handling
23148  * of empty elements. If you do need to represent empty elements,
23149  * you'll need to check for the empty string before calling this
23150  * function.
23151  *
23152  * A pattern that can match empty strings splits @string into
23153  * separate characters wherever it matches the empty string between
23154  * characters. For example splitting "ab c" using as a separator
23155  * "\s*", you will get "a", "b" and "c".
23156  *
23157  * Returns: (transfer full): a %NULL-terminated array of strings. Free it using g_strfreev()
23158  * Since: 2.14
23159  */
23160
23161
23162 /**
23163  * g_regex_unref:
23164  * @regex: a #GRegex
23165  *
23166  * Decreases reference count of @regex by 1. When reference count drops
23167  * to zero, it frees all the memory associated with the regex structure.
23168  *
23169  * Since: 2.14
23170  */
23171
23172
23173 /**
23174  * g_reload_user_special_dirs_cache:
23175  *
23176  * Resets the cache used for g_get_user_special_dir(), so
23177  * that the latest on-disk version is used. Call this only
23178  * if you just changed the data on disk yourself.
23179  *
23180  * Due to threadsafety issues this may cause leaking of strings
23181  * that were previously returned from g_get_user_special_dir()
23182  * that can't be freed. We ensure to only leak the data for
23183  * the directories that actually changed value though.
23184  *
23185  * Since: 2.22
23186  */
23187
23188
23189 /**
23190  * g_remove:
23191  * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
23192  *
23193  * A wrapper for the POSIX remove() function. The remove() function
23194  * deletes a name from the filesystem.
23195  *
23196  * See your C library manual for more details about how remove() works
23197  * on your system. On Unix, remove() removes also directories, as it
23198  * calls unlink() for files and rmdir() for directories. On Windows,
23199  * although remove() in the C library only works for files, this
23200  * function tries first remove() and then if that fails rmdir(), and
23201  * thus works for both files and directories. Note however, that on
23202  * Windows, it is in general not possible to remove a file that is
23203  * open to some process, or mapped into memory.
23204  *
23205  * If this function fails on Windows you can't infer too much from the
23206  * errno value. rmdir() is tried regardless of what caused remove() to
23207  * fail. Any errno value set by remove() will be overwritten by that
23208  * set by rmdir().
23209  *
23210  * Returns: 0 if the file was successfully removed, -1 if an error occurred
23211  * Since: 2.6
23212  */
23213
23214
23215 /**
23216  * g_rename:
23217  * @oldfilename: a pathname in the GLib file name encoding (UTF-8 on Windows)
23218  * @newfilename: a pathname in the GLib file name encoding
23219  *
23220  * A wrapper for the POSIX rename() function. The rename() function
23221  * renames a file, moving it between directories if required.
23222  *
23223  * See your C library manual for more details about how rename() works
23224  * on your system. It is not possible in general on Windows to rename
23225  * a file that is open to some process.
23226  *
23227  * Returns: 0 if the renaming succeeded, -1 if an error occurred
23228  * Since: 2.6
23229  */
23230
23231
23232 /**
23233  * g_rmdir:
23234  * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
23235  *
23236  * A wrapper for the POSIX rmdir() function. The rmdir() function
23237  * deletes a directory from the filesystem.
23238  *
23239  * See your C library manual for more details about how rmdir() works
23240  * on your system.
23241  *
23242  * Returns: 0 if the directory was successfully removed, -1 if an error occurred
23243  * Since: 2.6
23244  */
23245
23246
23247 /**
23248  * g_rw_lock_clear:
23249  * @rw_lock: an initialized #GRWLock
23250  *
23251  * Frees the resources allocated to a lock with g_rw_lock_init().
23252  *
23253  * This function should not be used with a #GRWLock that has been
23254  * statically allocated.
23255  *
23256  * Calling g_rw_lock_clear() when any thread holds the lock
23257  * leads to undefined behaviour.
23258  *
23259  * Sine: 2.32
23260  */
23261
23262
23263 /**
23264  * g_rw_lock_init:
23265  * @rw_lock: an uninitialized #GRWLock
23266  *
23267  * Initializes a #GRWLock so that it can be used.
23268  *
23269  * This function is useful to initialize a lock that has been
23270  * allocated on the stack, or as part of a larger structure.  It is not
23271  * necessary to initialise a reader-writer lock that has been statically
23272  * allocated.
23273  *
23274  * |[
23275  *   typedef struct {
23276  *     GRWLock l;
23277  *     ...
23278  *   } Blob;
23279  *
23280  * Blob *b;
23281  *
23282  * b = g_new (Blob, 1);
23283  * g_rw_lock_init (&b->l);
23284  * ]|
23285  *
23286  * To undo the effect of g_rw_lock_init() when a lock is no longer
23287  * needed, use g_rw_lock_clear().
23288  *
23289  * Calling g_rw_lock_init() on an already initialized #GRWLock leads
23290  * to undefined behaviour.
23291  *
23292  * Since: 2.32
23293  */
23294
23295
23296 /**
23297  * g_rw_lock_reader_lock:
23298  * @rw_lock: a #GRWLock
23299  *
23300  * Obtain a read lock on @rw_lock. If another thread currently holds
23301  * the write lock on @rw_lock or blocks waiting for it, the current
23302  * thread will block. Read locks can be taken recursively.
23303  *
23304  * It is implementation-defined how many threads are allowed to
23305  * hold read locks on the same lock simultaneously.
23306  *
23307  * Since: 2.32
23308  */
23309
23310
23311 /**
23312  * g_rw_lock_reader_trylock:
23313  * @rw_lock: a #GRWLock
23314  *
23315  * Tries to obtain a read lock on @rw_lock and returns %TRUE if
23316  * the read lock was successfully obtained. Otherwise it
23317  * returns %FALSE.
23318  *
23319  * Returns: %TRUE if @rw_lock could be locked
23320  * Since: 2.32
23321  */
23322
23323
23324 /**
23325  * g_rw_lock_reader_unlock:
23326  * @rw_lock: a #GRWLock
23327  *
23328  * Release a read lock on @rw_lock.
23329  *
23330  * Calling g_rw_lock_reader_unlock() on a lock that is not held
23331  * by the current thread leads to undefined behaviour.
23332  *
23333  * Since: 2.32
23334  */
23335
23336
23337 /**
23338  * g_rw_lock_writer_lock:
23339  * @rw_lock: a #GRWLock
23340  *
23341  * Obtain a write lock on @rw_lock. If any thread already holds
23342  * a read or write lock on @rw_lock, the current thread will block
23343  * until all other threads have dropped their locks on @rw_lock.
23344  *
23345  * Since: 2.32
23346  */
23347
23348
23349 /**
23350  * g_rw_lock_writer_trylock:
23351  * @rw_lock: a #GRWLock
23352  *
23353  * Tries to obtain a write lock on @rw_lock. If any other thread holds
23354  * a read or write lock on @rw_lock, it immediately returns %FALSE.
23355  * Otherwise it locks @rw_lock and returns %TRUE.
23356  *
23357  * Returns: %TRUE if @rw_lock could be locked
23358  * Since: 2.32
23359  */
23360
23361
23362 /**
23363  * g_rw_lock_writer_unlock:
23364  * @rw_lock: a #GRWLock
23365  *
23366  * Release a write lock on @rw_lock.
23367  *
23368  * Calling g_rw_lock_writer_unlock() on a lock that is not held
23369  * by the current thread leads to undefined behaviour.
23370  *
23371  * Since: 2.32
23372  */
23373
23374
23375 /**
23376  * g_scanner_add_symbol:
23377  * @scanner: a #GScanner
23378  * @symbol: the symbol to add
23379  * @value: the value of the symbol
23380  *
23381  * Adds a symbol to the default scope.
23382  *
23383  * Deprecated: 2.2: Use g_scanner_scope_add_symbol() instead.
23384  */
23385
23386
23387 /**
23388  * g_scanner_cur_line:
23389  * @scanner: a #GScanner
23390  *
23391  * Returns the current line in the input stream (counting
23392  * from 1). This is the line of the last token parsed via
23393  * g_scanner_get_next_token().
23394  *
23395  * Returns: the current line
23396  */
23397
23398
23399 /**
23400  * g_scanner_cur_position:
23401  * @scanner: a #GScanner
23402  *
23403  * Returns the current position in the current line (counting
23404  * from 0). This is the position of the last token parsed via
23405  * g_scanner_get_next_token().
23406  *
23407  * Returns: the current position on the line
23408  */
23409
23410
23411 /**
23412  * g_scanner_cur_token:
23413  * @scanner: a #GScanner
23414  *
23415  * Gets the current token type. This is simply the @token
23416  * field in the #GScanner structure.
23417  *
23418  * Returns: the current token type
23419  */
23420
23421
23422 /**
23423  * g_scanner_cur_value:
23424  * @scanner: a #GScanner
23425  *
23426  * Gets the current token value. This is simply the @value
23427  * field in the #GScanner structure.
23428  *
23429  * Returns: the current token value
23430  */
23431
23432
23433 /**
23434  * g_scanner_destroy:
23435  * @scanner: a #GScanner
23436  *
23437  * Frees all memory used by the #GScanner.
23438  */
23439
23440
23441 /**
23442  * g_scanner_eof:
23443  * @scanner: a #GScanner
23444  *
23445  * Returns %TRUE if the scanner has reached the end of
23446  * the file or text buffer.
23447  *
23448  * Returns: %TRUE if the scanner has reached the end of the file or text buffer
23449  */
23450
23451
23452 /**
23453  * g_scanner_error:
23454  * @scanner: a #GScanner
23455  * @format: the message format. See the printf() documentation
23456  * @...: the parameters to insert into the format string
23457  *
23458  * Outputs an error message, via the #GScanner message handler.
23459  */
23460
23461
23462 /**
23463  * g_scanner_foreach_symbol:
23464  * @scanner: a #GScanner
23465  * @func: the function to call with each symbol
23466  * @data: data to pass to the function
23467  *
23468  * Calls a function for each symbol in the default scope.
23469  *
23470  * Deprecated: 2.2: Use g_scanner_scope_foreach_symbol() instead.
23471  */
23472
23473
23474 /**
23475  * g_scanner_freeze_symbol_table:
23476  * @scanner: a #GScanner
23477  *
23478  * There is no reason to use this macro, since it does nothing.
23479  *
23480  * Deprecated: 2.2: This macro does nothing.
23481  */
23482
23483
23484 /**
23485  * g_scanner_get_next_token:
23486  * @scanner: a #GScanner
23487  *
23488  * Parses the next token just like g_scanner_peek_next_token()
23489  * and also removes it from the input stream. The token data is
23490  * placed in the @token, @value, @line, and @position fields of
23491  * the #GScanner structure.
23492  *
23493  * Returns: the type of the token
23494  */
23495
23496
23497 /**
23498  * g_scanner_input_file:
23499  * @scanner: a #GScanner
23500  * @input_fd: a file descriptor
23501  *
23502  * Prepares to scan a file.
23503  */
23504
23505
23506 /**
23507  * g_scanner_input_text:
23508  * @scanner: a #GScanner
23509  * @text: the text buffer to scan
23510  * @text_len: the length of the text buffer
23511  *
23512  * Prepares to scan a text buffer.
23513  */
23514
23515
23516 /**
23517  * g_scanner_lookup_symbol:
23518  * @scanner: a #GScanner
23519  * @symbol: the symbol to look up
23520  *
23521  * Looks up a symbol in the current scope and return its value.
23522  * If the symbol is not bound in the current scope, %NULL is
23523  * returned.
23524  *
23525  * Returns: the value of @symbol in the current scope, or %NULL if @symbol is not bound in the current scope
23526  */
23527
23528
23529 /**
23530  * g_scanner_new:
23531  * @config_templ: the initial scanner settings
23532  *
23533  * Creates a new #GScanner.
23534  *
23535  * The @config_templ structure specifies the initial settings
23536  * of the scanner, which are copied into the #GScanner
23537  * @config field. If you pass %NULL then the default settings
23538  * are used.
23539  *
23540  * Returns: the new #GScanner
23541  */
23542
23543
23544 /**
23545  * g_scanner_peek_next_token:
23546  * @scanner: a #GScanner
23547  *
23548  * Parses the next token, without removing it from the input stream.
23549  * The token data is placed in the @next_token, @next_value, @next_line,
23550  * and @next_position fields of the #GScanner structure.
23551  *
23552  * Note that, while the token is not removed from the input stream
23553  * (i.e. the next call to g_scanner_get_next_token() will return the
23554  * same token), it will not be reevaluated. This can lead to surprising
23555  * results when changing scope or the scanner configuration after peeking
23556  * the next token. Getting the next token after switching the scope or
23557  * configuration will return whatever was peeked before, regardless of
23558  * any symbols that may have been added or removed in the new scope.
23559  *
23560  * Returns: the type of the token
23561  */
23562
23563
23564 /**
23565  * g_scanner_remove_symbol:
23566  * @scanner: a #GScanner
23567  * @symbol: the symbol to remove
23568  *
23569  * Removes a symbol from the default scope.
23570  *
23571  * Deprecated: 2.2: Use g_scanner_scope_remove_symbol() instead.
23572  */
23573
23574
23575 /**
23576  * g_scanner_scope_add_symbol:
23577  * @scanner: a #GScanner
23578  * @scope_id: the scope id
23579  * @symbol: the symbol to add
23580  * @value: the value of the symbol
23581  *
23582  * Adds a symbol to the given scope.
23583  */
23584
23585
23586 /**
23587  * g_scanner_scope_foreach_symbol:
23588  * @scanner: a #GScanner
23589  * @scope_id: the scope id
23590  * @func: the function to call for each symbol/value pair
23591  * @user_data: user data to pass to the function
23592  *
23593  * Calls the given function for each of the symbol/value pairs
23594  * in the given scope of the #GScanner. The function is passed
23595  * the symbol and value of each pair, and the given @user_data
23596  * parameter.
23597  */
23598
23599
23600 /**
23601  * g_scanner_scope_lookup_symbol:
23602  * @scanner: a #GScanner
23603  * @scope_id: the scope id
23604  * @symbol: the symbol to look up
23605  *
23606  * Looks up a symbol in a scope and return its value. If the
23607  * symbol is not bound in the scope, %NULL is returned.
23608  *
23609  * Returns: the value of @symbol in the given scope, or %NULL if @symbol is not bound in the given scope.
23610  */
23611
23612
23613 /**
23614  * g_scanner_scope_remove_symbol:
23615  * @scanner: a #GScanner
23616  * @scope_id: the scope id
23617  * @symbol: the symbol to remove
23618  *
23619  * Removes a symbol from a scope.
23620  */
23621
23622
23623 /**
23624  * g_scanner_set_scope:
23625  * @scanner: a #GScanner
23626  * @scope_id: the new scope id
23627  *
23628  * Sets the current scope.
23629  *
23630  * Returns: the old scope id
23631  */
23632
23633
23634 /**
23635  * g_scanner_sync_file_offset:
23636  * @scanner: a #GScanner
23637  *
23638  * Rewinds the filedescriptor to the current buffer position
23639  * and blows the file read ahead buffer. This is useful for
23640  * third party uses of the scanners filedescriptor, which hooks
23641  * onto the current scanning position.
23642  */
23643
23644
23645 /**
23646  * g_scanner_thaw_symbol_table:
23647  * @scanner: a #GScanner
23648  *
23649  * There is no reason to use this macro, since it does nothing.
23650  *
23651  * Deprecated: 2.2: This macro does nothing.
23652  */
23653
23654
23655 /**
23656  * g_scanner_unexp_token:
23657  * @scanner: a #GScanner
23658  * @expected_token: the expected token
23659  * @identifier_spec: a string describing how the scanner's user refers to identifiers (%NULL defaults to "identifier"). This is used if @expected_token is %G_TOKEN_IDENTIFIER or %G_TOKEN_IDENTIFIER_NULL.
23660  * @symbol_spec: a string describing how the scanner's user refers to symbols (%NULL defaults to "symbol"). This is used if @expected_token is %G_TOKEN_SYMBOL or any token value greater than %G_TOKEN_LAST.
23661  * @symbol_name: the name of the symbol, if the scanner's current token is a symbol.
23662  * @message: a message string to output at the end of the warning/error, or %NULL.
23663  * @is_error: if %TRUE it is output as an error. If %FALSE it is output as a warning.
23664  *
23665  * Outputs a message through the scanner's msg_handler,
23666  * resulting from an unexpected token in the input stream.
23667  * Note that you should not call g_scanner_peek_next_token()
23668  * followed by g_scanner_unexp_token() without an intermediate
23669  * call to g_scanner_get_next_token(), as g_scanner_unexp_token()
23670  * evaluates the scanner's current token (not the peeked token)
23671  * to construct part of the message.
23672  */
23673
23674
23675 /**
23676  * g_scanner_warn:
23677  * @scanner: a #GScanner
23678  * @format: the message format. See the printf() documentation
23679  * @...: the parameters to insert into the format string
23680  *
23681  * Outputs a warning message, via the #GScanner message handler.
23682  */
23683
23684
23685 /**
23686  * g_sequence_append:
23687  * @seq: a #GSequence
23688  * @data: the data for the new item
23689  *
23690  * Adds a new item to the end of @seq.
23691  *
23692  * Returns: an iterator pointing to the new item
23693  * Since: 2.14
23694  */
23695
23696
23697 /**
23698  * g_sequence_foreach:
23699  * @seq: a #GSequence
23700  * @func: the function to call for each item in @seq
23701  * @user_data: user data passed to @func
23702  *
23703  * Calls @func for each item in the sequence passing @user_data
23704  * to the function.
23705  *
23706  * Since: 2.14
23707  */
23708
23709
23710 /**
23711  * g_sequence_foreach_range:
23712  * @begin: a #GSequenceIter
23713  * @end: a #GSequenceIter
23714  * @func: a #GFunc
23715  * @user_data: user data passed to @func
23716  *
23717  * Calls @func for each item in the range (@begin, @end) passing
23718  * @user_data to the function.
23719  *
23720  * Since: 2.14
23721  */
23722
23723
23724 /**
23725  * g_sequence_free:
23726  * @seq: a #GSequence
23727  *
23728  * Frees the memory allocated for @seq. If @seq has a data destroy
23729  * function associated with it, that function is called on all items in
23730  * @seq.
23731  *
23732  * Since: 2.14
23733  */
23734
23735
23736 /**
23737  * g_sequence_get:
23738  * @iter: a #GSequenceIter
23739  *
23740  * Returns the data that @iter points to.
23741  *
23742  * Returns: the data that @iter points to
23743  * Since: 2.14
23744  */
23745
23746
23747 /**
23748  * g_sequence_get_begin_iter:
23749  * @seq: a #GSequence
23750  *
23751  * Returns the begin iterator for @seq.
23752  *
23753  * Returns: the begin iterator for @seq.
23754  * Since: 2.14
23755  */
23756
23757
23758 /**
23759  * g_sequence_get_end_iter:
23760  * @seq: a #GSequence
23761  *
23762  * Returns the end iterator for @seg
23763  *
23764  * Returns: the end iterator for @seq
23765  * Since: 2.14
23766  */
23767
23768
23769 /**
23770  * g_sequence_get_iter_at_pos:
23771  * @seq: a #GSequence
23772  * @pos: a position in @seq, or -1 for the end.
23773  *
23774  * Returns the iterator at position @pos. If @pos is negative or larger
23775  * than the number of items in @seq, the end iterator is returned.
23776  *
23777  * Returns: The #GSequenceIter at position @pos
23778  * Since: 2.14
23779  */
23780
23781
23782 /**
23783  * g_sequence_get_length:
23784  * @seq: a #GSequence
23785  *
23786  * Returns the length of @seq
23787  *
23788  * Returns: the length of @seq
23789  * Since: 2.14
23790  */
23791
23792
23793 /**
23794  * g_sequence_insert_before:
23795  * @iter: a #GSequenceIter
23796  * @data: the data for the new item
23797  *
23798  * Inserts a new item just before the item pointed to by @iter.
23799  *
23800  * Returns: an iterator pointing to the new item
23801  * Since: 2.14
23802  */
23803
23804
23805 /**
23806  * g_sequence_insert_sorted:
23807  * @seq: a #GSequence
23808  * @data: the data to insert
23809  * @cmp_func: the function used to compare items in the sequence
23810  * @cmp_data: user data passed to @cmp_func.
23811  *
23812  * Inserts @data into @sequence using @func to determine the new
23813  * position. The sequence must already be sorted according to @cmp_func;
23814  * otherwise the new position of @data is undefined.
23815  *
23816  * @cmp_func is called with two items of the @seq and @user_data.
23817  * It should return 0 if the items are equal, a negative value
23818  * if the first item comes before the second, and a positive value
23819  * if the second  item comes before the first.
23820  *
23821  * Returns: a #GSequenceIter pointing to the new item.
23822  * Since: 2.14
23823  */
23824
23825
23826 /**
23827  * g_sequence_insert_sorted_iter:
23828  * @seq: a #GSequence
23829  * @data: data for the new item
23830  * @iter_cmp: the function used to compare iterators in the sequence
23831  * @cmp_data: user data passed to @cmp_func
23832  *
23833  * Like g_sequence_insert_sorted(), but uses
23834  * a #GSequenceIterCompareFunc instead of a #GCompareDataFunc as
23835  * the compare function.
23836  *
23837  * @iter_cmp is called with two iterators pointing into @seq.
23838  * It should return 0 if the iterators are equal, a negative
23839  * value if the first iterator comes before the second, and a
23840  * positive value if the second iterator comes before the first.
23841  *
23842  * It is called with two iterators pointing into @seq. It should
23843  * return 0 if the iterators are equal, a negative value if the
23844  * first iterator comes before the second, and a positive value
23845  * if the second iterator comes before the first.
23846  *
23847  * Returns: a #GSequenceIter pointing to the new item
23848  * Since: 2.14
23849  */
23850
23851
23852 /**
23853  * g_sequence_iter_compare:
23854  * @a: a #GSequenceIter
23855  * @b: a #GSequenceIter
23856  *
23857  * Returns a negative number if @a comes before @b, 0 if they are equal,
23858  * and a positive number if @a comes after @b.
23859  *
23860  * The @a and @b iterators must point into the same sequence.
23861  *
23862  * Returns: A negative number if @a comes before @b, 0 if they are equal, and a positive number if @a comes after @b.
23863  * Since: 2.14
23864  */
23865
23866
23867 /**
23868  * g_sequence_iter_get_position:
23869  * @iter: a #GSequenceIter
23870  *
23871  * Returns the position of @iter
23872  *
23873  * Returns: the position of @iter
23874  * Since: 2.14
23875  */
23876
23877
23878 /**
23879  * g_sequence_iter_get_sequence:
23880  * @iter: a #GSequenceIter
23881  *
23882  * Returns the #GSequence that @iter points into.
23883  *
23884  * Returns: the #GSequence that @iter points into.
23885  * Since: 2.14
23886  */
23887
23888
23889 /**
23890  * g_sequence_iter_is_begin:
23891  * @iter: a #GSequenceIter
23892  *
23893  * Returns whether @iter is the begin iterator
23894  *
23895  * Returns: whether @iter is the begin iterator
23896  * Since: 2.14
23897  */
23898
23899
23900 /**
23901  * g_sequence_iter_is_end:
23902  * @iter: a #GSequenceIter
23903  *
23904  * Returns whether @iter is the end iterator
23905  *
23906  * Returns: Whether @iter is the end iterator.
23907  * Since: 2.14
23908  */
23909
23910
23911 /**
23912  * g_sequence_iter_move:
23913  * @iter: a #GSequenceIter
23914  * @delta: A positive or negative number indicating how many positions away from @iter the returned #GSequenceIter will be.
23915  *
23916  * Returns the #GSequenceIter which is @delta positions away from @iter.
23917  * If @iter is closer than -@delta positions to the beginning of the sequence,
23918  * the begin iterator is returned. If @iter is closer than @delta positions
23919  * to the end of the sequence, the end iterator is returned.
23920  *
23921  * Returns: a #GSequenceIter which is @delta positions away from @iter.
23922  * Since: 2.14
23923  */
23924
23925
23926 /**
23927  * g_sequence_iter_next:
23928  * @iter: a #GSequenceIter
23929  *
23930  * Returns an iterator pointing to the next position after @iter. If
23931  * @iter is the end iterator, the end iterator is returned.
23932  *
23933  * Returns: a #GSequenceIter pointing to the next position after @iter.
23934  * Since: 2.14
23935  */
23936
23937
23938 /**
23939  * g_sequence_iter_prev:
23940  * @iter: a #GSequenceIter
23941  *
23942  * Returns an iterator pointing to the previous position before @iter. If
23943  * @iter is the begin iterator, the begin iterator is returned.
23944  *
23945  * Returns: a #GSequenceIter pointing to the previous position before @iter.
23946  * Since: 2.14
23947  */
23948
23949
23950 /**
23951  * g_sequence_lookup:
23952  * @seq: a #GSequence
23953  * @data: data to lookup
23954  * @cmp_func: the function used to compare items in the sequence
23955  * @cmp_data: user data passed to @cmp_func.
23956  *
23957  * Returns an iterator pointing to the position of the first item found
23958  * equal to @data according to @cmp_func and @cmp_data. If more than one
23959  * item is equal, it is not guaranteed that it is the first which is
23960  * returned. In that case, you can use g_sequence_iter_next() and
23961  * g_sequence_iter_prev() to get others.
23962  *
23963  * @cmp_func is called with two items of the @seq and @user_data.
23964  * It should return 0 if the items are equal, a negative value if
23965  * the first item comes before the second, and a positive value if
23966  * the second item comes before the first.
23967  *
23968  * <note><para>
23969  * This function will fail if the data contained in the sequence is
23970  * unsorted.  Use g_sequence_insert_sorted() or
23971  * g_sequence_insert_sorted_iter() to add data to your sequence or, if
23972  * you want to add a large amount of data, call g_sequence_sort() after
23973  * doing unsorted insertions.
23974  * </para></note>
23975  *
23976  * Returns: an #GSequenceIter pointing to the position of the first item found equal to @data according to @cmp_func and @cmp_data, or %NULL if no such item exists.
23977  * Since: 2.28
23978  */
23979
23980
23981 /**
23982  * g_sequence_lookup_iter:
23983  * @seq: a #GSequence
23984  * @data: data to lookup
23985  * @iter_cmp: the function used to compare iterators in the sequence
23986  * @cmp_data: user data passed to @iter_cmp
23987  *
23988  * Like g_sequence_lookup(), but uses a #GSequenceIterCompareFunc
23989  * instead of a #GCompareDataFunc as the compare function.
23990  *
23991  * @iter_cmp is called with two iterators pointing into @seq.
23992  * It should return 0 if the iterators are equal, a negative value
23993  * if the first iterator comes before the second, and a positive
23994  * value if the second iterator comes before the first.
23995  *
23996  * <note><para>
23997  * This function will fail if the data contained in the sequence is
23998  * unsorted.  Use g_sequence_insert_sorted() or
23999  * g_sequence_insert_sorted_iter() to add data to your sequence or, if
24000  * you want to add a large amount of data, call g_sequence_sort() after
24001  * doing unsorted insertions.
24002  * </para></note>
24003  *
24004  * Returns: an #GSequenceIter pointing to the position of the first item found equal to @data according to @cmp_func and @cmp_data, or %NULL if no such item exists.
24005  * Since: 2.28
24006  */
24007
24008
24009 /**
24010  * g_sequence_move:
24011  * @src: a #GSequenceIter pointing to the item to move
24012  * @dest: a #GSequenceIter pointing to the position to which the item is moved.
24013  *
24014  * Moves the item pointed to by @src to the position indicated by @dest.
24015  * After calling this function @dest will point to the position immediately
24016  * after @src. It is allowed for @src and @dest to point into different
24017  * sequences.
24018  *
24019  * Since: 2.14
24020  */
24021
24022
24023 /**
24024  * g_sequence_move_range:
24025  * @dest: a #GSequenceIter
24026  * @begin: a #GSequenceIter
24027  * @end: a #GSequenceIter
24028  *
24029  * Inserts the (@begin, @end) range at the destination pointed to by ptr.
24030  * The @begin and @end iters must point into the same sequence. It is
24031  * allowed for @dest to point to a different sequence than the one pointed
24032  * into by @begin and @end.
24033  *
24034  * If @dest is NULL, the range indicated by @begin and @end is
24035  * removed from the sequence. If @dest iter points to a place within
24036  * the (@begin, @end) range, the range does not move.
24037  *
24038  * Since: 2.14
24039  */
24040
24041
24042 /**
24043  * g_sequence_new:
24044  * @data_destroy: (allow-none): a #GDestroyNotify function, or %NULL
24045  *
24046  * Creates a new GSequence. The @data_destroy function, if non-%NULL will
24047  * be called on all items when the sequence is destroyed and on items that
24048  * are removed from the sequence.
24049  *
24050  * Returns: a new #GSequence
24051  * Since: 2.14
24052  */
24053
24054
24055 /**
24056  * g_sequence_prepend:
24057  * @seq: a #GSequence
24058  * @data: the data for the new item
24059  *
24060  * Adds a new item to the front of @seq
24061  *
24062  * Returns: an iterator pointing to the new item
24063  * Since: 2.14
24064  */
24065
24066
24067 /**
24068  * g_sequence_range_get_midpoint:
24069  * @begin: a #GSequenceIter
24070  * @end: a #GSequenceIter
24071  *
24072  * Finds an iterator somewhere in the range (@begin, @end). This
24073  * iterator will be close to the middle of the range, but is not
24074  * guaranteed to be <emphasis>exactly</emphasis> in the middle.
24075  *
24076  * The @begin and @end iterators must both point to the same sequence and
24077  * @begin must come before or be equal to @end in the sequence.
24078  *
24079  * Returns: A #GSequenceIter pointing somewhere in the (@begin, @end) range.
24080  * Since: 2.14
24081  */
24082
24083
24084 /**
24085  * g_sequence_remove:
24086  * @iter: a #GSequenceIter
24087  *
24088  * Removes the item pointed to by @iter. It is an error to pass the
24089  * end iterator to this function.
24090  *
24091  * If the sequence has a data destroy function associated with it, this
24092  * function is called on the data for the removed item.
24093  *
24094  * Since: 2.14
24095  */
24096
24097
24098 /**
24099  * g_sequence_remove_range:
24100  * @begin: a #GSequenceIter
24101  * @end: a #GSequenceIter
24102  *
24103  * Removes all items in the (@begin, @end) range.
24104  *
24105  * If the sequence has a data destroy function associated with it, this
24106  * function is called on the data for the removed items.
24107  *
24108  * Since: 2.14
24109  */
24110
24111
24112 /**
24113  * g_sequence_search:
24114  * @seq: a #GSequence
24115  * @data: data for the new item
24116  * @cmp_func: the function used to compare items in the sequence
24117  * @cmp_data: user data passed to @cmp_func.
24118  *
24119  * Returns an iterator pointing to the position where @data would
24120  * be inserted according to @cmp_func and @cmp_data.
24121  *
24122  * @cmp_func is called with two items of the @seq and @user_data.
24123  * It should return 0 if the items are equal, a negative value if
24124  * the first item comes before the second, and a positive value if
24125  * the second item comes before the first.
24126  *
24127  * If you are simply searching for an existing element of the sequence,
24128  * consider using g_sequence_lookup().
24129  *
24130  * <note><para>
24131  * This function will fail if the data contained in the sequence is
24132  * unsorted.  Use g_sequence_insert_sorted() or
24133  * g_sequence_insert_sorted_iter() to add data to your sequence or, if
24134  * you want to add a large amount of data, call g_sequence_sort() after
24135  * doing unsorted insertions.
24136  * </para></note>
24137  *
24138  * Returns: an #GSequenceIter pointing to the position where @data would have been inserted according to @cmp_func and @cmp_data.
24139  * Since: 2.14
24140  */
24141
24142
24143 /**
24144  * g_sequence_search_iter:
24145  * @seq: a #GSequence
24146  * @data: data for the new item
24147  * @iter_cmp: the function used to compare iterators in the sequence
24148  * @cmp_data: user data passed to @iter_cmp
24149  *
24150  * Like g_sequence_search(), but uses a #GSequenceIterCompareFunc
24151  * instead of a #GCompareDataFunc as the compare function.
24152  *
24153  * @iter_cmp is called with two iterators pointing into @seq.
24154  * It should return 0 if the iterators are equal, a negative value
24155  * if the first iterator comes before the second, and a positive
24156  * value if the second iterator comes before the first.
24157  *
24158  * If you are simply searching for an existing element of the sequence,
24159  * consider using g_sequence_lookup_iter().
24160  *
24161  * <note><para>
24162  * This function will fail if the data contained in the sequence is
24163  * unsorted.  Use g_sequence_insert_sorted() or
24164  * g_sequence_insert_sorted_iter() to add data to your sequence or, if
24165  * you want to add a large amount of data, call g_sequence_sort() after
24166  * doing unsorted insertions.
24167  * </para></note>
24168  *
24169  * Returns: a #GSequenceIter pointing to the position in @seq where @data would have been inserted according to @iter_cmp and @cmp_data.
24170  * Since: 2.14
24171  */
24172
24173
24174 /**
24175  * g_sequence_set:
24176  * @iter: a #GSequenceIter
24177  * @data: new data for the item
24178  *
24179  * Changes the data for the item pointed to by @iter to be @data. If
24180  * the sequence has a data destroy function associated with it, that
24181  * function is called on the existing data that @iter pointed to.
24182  *
24183  * Since: 2.14
24184  */
24185
24186
24187 /**
24188  * g_sequence_sort:
24189  * @seq: a #GSequence
24190  * @cmp_func: the function used to sort the sequence
24191  * @cmp_data: user data passed to @cmp_func
24192  *
24193  * Sorts @seq using @cmp_func.
24194  *
24195  * @cmp_func is passed two items of @seq and should
24196  * return 0 if they are equal, a negative value if the
24197  * first comes before the second, and a positive value
24198  * if the second comes before the first.
24199  *
24200  * Since: 2.14
24201  */
24202
24203
24204 /**
24205  * g_sequence_sort_changed:
24206  * @iter: A #GSequenceIter
24207  * @cmp_func: the function used to compare items in the sequence
24208  * @cmp_data: user data passed to @cmp_func.
24209  *
24210  * Moves the data pointed to a new position as indicated by @cmp_func. This
24211  * function should be called for items in a sequence already sorted according
24212  * to @cmp_func whenever some aspect of an item changes so that @cmp_func
24213  * may return different values for that item.
24214  *
24215  * @cmp_func is called with two items of the @seq and @user_data.
24216  * It should return 0 if the items are equal, a negative value if
24217  * the first item comes before the second, and a positive value if
24218  * the second item comes before the first.
24219  *
24220  * Since: 2.14
24221  */
24222
24223
24224 /**
24225  * g_sequence_sort_changed_iter:
24226  * @iter: a #GSequenceIter
24227  * @iter_cmp: the function used to compare iterators in the sequence
24228  * @cmp_data: user data passed to @cmp_func
24229  *
24230  * Like g_sequence_sort_changed(), but uses
24231  * a #GSequenceIterCompareFunc instead of a #GCompareDataFunc as
24232  * the compare function.
24233  *
24234  * @iter_cmp is called with two iterators pointing into @seq. It should
24235  * return 0 if the iterators are equal, a negative value if the first
24236  * iterator comes before the second, and a positive value if the second
24237  * iterator comes before the first.
24238  *
24239  * Since: 2.14
24240  */
24241
24242
24243 /**
24244  * g_sequence_sort_iter:
24245  * @seq: a #GSequence
24246  * @cmp_func: the function used to compare iterators in the sequence
24247  * @cmp_data: user data passed to @cmp_func
24248  *
24249  * Like g_sequence_sort(), but uses a #GSequenceIterCompareFunc instead
24250  * of a GCompareDataFunc as the compare function
24251  *
24252  * @cmp_func is called with two iterators pointing into @seq. It should
24253  * return 0 if the iterators are equal, a negative value if the first
24254  * iterator comes before the second, and a positive value if the second
24255  * iterator comes before the first.
24256  *
24257  * Since: 2.14
24258  */
24259
24260
24261 /**
24262  * g_sequence_swap:
24263  * @a: a #GSequenceIter
24264  * @b: a #GSequenceIter
24265  *
24266  * Swaps the items pointed to by @a and @b. It is allowed for @a and @b
24267  * to point into difference sequences.
24268  *
24269  * Since: 2.14
24270  */
24271
24272
24273 /**
24274  * g_set_application_name:
24275  * @application_name: localized name of the application
24276  *
24277  * Sets a human-readable name for the application. This name should be
24278  * localized if possible, and is intended for display to the user.
24279  * Contrast with g_set_prgname(), which sets a non-localized name.
24280  * g_set_prgname() will be called automatically by gtk_init(),
24281  * but g_set_application_name() will not.
24282  *
24283  * Note that for thread safety reasons, this function can only
24284  * be called once.
24285  *
24286  * The application name will be used in contexts such as error messages,
24287  * or when displaying an application's name in the task list.
24288  *
24289  * Since: 2.2
24290  */
24291
24292
24293 /**
24294  * g_set_error:
24295  * @err: (allow-none): a return location for a #GError, or %NULL
24296  * @domain: error domain
24297  * @code: error code
24298  * @format: printf()-style format
24299  * @...: args for @format
24300  *
24301  * Does nothing if @err is %NULL; if @err is non-%NULL, then *@err
24302  * must be %NULL. A new #GError is created and assigned to *@err.
24303  */
24304
24305
24306 /**
24307  * g_set_error_literal:
24308  * @err: (allow-none): a return location for a #GError, or %NULL
24309  * @domain: error domain
24310  * @code: error code
24311  * @message: error message
24312  *
24313  * Does nothing if @err is %NULL; if @err is non-%NULL, then *@err
24314  * must be %NULL. A new #GError is created and assigned to *@err.
24315  * Unlike g_set_error(), @message is not a printf()-style format string.
24316  * Use this function if @message contains text you don't have control over,
24317  * that could include printf() escape sequences.
24318  *
24319  * Since: 2.18
24320  */
24321
24322
24323 /**
24324  * g_set_prgname:
24325  * @prgname: the name of the program.
24326  *
24327  * Sets the name of the program. This name should <emphasis>not</emphasis>
24328  * be localized, contrast with g_set_application_name(). Note that for
24329  * thread-safety reasons this function can only be called once.
24330  */
24331
24332
24333 /**
24334  * g_set_print_handler:
24335  * @func: the new print handler
24336  *
24337  * Sets the print handler.
24338  *
24339  * Any messages passed to g_print() will be output via
24340  * the new handler. The default handler simply outputs
24341  * the message to stdout. By providing your own handler
24342  * you can redirect the output, to a GTK+ widget or a
24343  * log file for example.
24344  *
24345  * Returns: the old print handler
24346  */
24347
24348
24349 /**
24350  * g_set_printerr_handler:
24351  * @func: the new error message handler
24352  *
24353  * Sets the handler for printing error messages.
24354  *
24355  * Any messages passed to g_printerr() will be output via
24356  * the new handler. The default handler simply outputs the
24357  * message to stderr. By providing your own handler you can
24358  * redirect the output, to a GTK+ widget or a log file for
24359  * example.
24360  *
24361  * Returns: the old error message handler
24362  */
24363
24364
24365 /**
24366  * g_setenv:
24367  * @variable: the environment variable to set, must not contain '='.
24368  * @value: the value for to set the variable to.
24369  * @overwrite: whether to change the variable if it already exists.
24370  *
24371  * Sets an environment variable. Both the variable's name and value
24372  * should be in the GLib file name encoding. On UNIX, this means that
24373  * they can be arbitrary byte strings. On Windows, they should be in
24374  * UTF-8.
24375  *
24376  * Note that on some systems, when variables are overwritten, the memory
24377  * used for the previous variables and its value isn't reclaimed.
24378  *
24379  * <warning><para>
24380  * Environment variable handling in UNIX is not thread-safe, and your
24381  * program may crash if one thread calls g_setenv() while another
24382  * thread is calling getenv(). (And note that many functions, such as
24383  * gettext(), call getenv() internally.) This function is only safe to
24384  * use at the very start of your program, before creating any other
24385  * threads (or creating objects that create worker threads of their
24386  * own).
24387  * </para><para>
24388  * If you need to set up the environment for a child process, you can
24389  * use g_get_environ() to get an environment array, modify that with
24390  * g_environ_setenv() and g_environ_unsetenv(), and then pass that
24391  * array directly to execvpe(), g_spawn_async(), or the like.
24392  * </para></warning>
24393  *
24394  * Returns: %FALSE if the environment variable couldn't be set.
24395  * Since: 2.4
24396  */
24397
24398
24399 /**
24400  * g_shell_parse_argv:
24401  * @command_line: command line to parse
24402  * @argcp: (out): return location for number of args
24403  * @argvp: (out) (array length=argcp zero-terminated=1): return location for array of args
24404  * @error: return location for error
24405  *
24406  * Parses a command line into an argument vector, in much the same way
24407  * the shell would, but without many of the expansions the shell would
24408  * perform (variable expansion, globs, operators, filename expansion,
24409  * etc. are not supported). The results are defined to be the same as
24410  * those you would get from a UNIX98 /bin/sh, as long as the input
24411  * contains none of the unsupported shell expansions. If the input
24412  * does contain such expansions, they are passed through
24413  * literally. Possible errors are those from the #G_SHELL_ERROR
24414  * domain. Free the returned vector with g_strfreev().
24415  *
24416  * Returns: %TRUE on success, %FALSE if error set
24417  */
24418
24419
24420 /**
24421  * g_shell_quote:
24422  * @unquoted_string: a literal string
24423  *
24424  * Quotes a string so that the shell (/bin/sh) will interpret the
24425  * quoted string to mean @unquoted_string. If you pass a filename to
24426  * the shell, for example, you should first quote it with this
24427  * function.  The return value must be freed with g_free(). The
24428  * quoting style used is undefined (single or double quotes may be
24429  * used).
24430  *
24431  * Returns: quoted string
24432  */
24433
24434
24435 /**
24436  * g_shell_unquote:
24437  * @quoted_string: shell-quoted string
24438  * @error: error return location or NULL
24439  *
24440  * Unquotes a string as the shell (/bin/sh) would. Only handles
24441  * quotes; if a string contains file globs, arithmetic operators,
24442  * variables, backticks, redirections, or other special-to-the-shell
24443  * features, the result will be different from the result a real shell
24444  * would produce (the variables, backticks, etc. will be passed
24445  * through literally instead of being expanded). This function is
24446  * guaranteed to succeed if applied to the result of
24447  * g_shell_quote(). If it fails, it returns %NULL and sets the
24448  * error. The @quoted_string need not actually contain quoted or
24449  * escaped text; g_shell_unquote() simply goes through the string and
24450  * unquotes/unescapes anything that the shell would. Both single and
24451  * double quotes are handled, as are escapes including escaped
24452  * newlines. The return value must be freed with g_free(). Possible
24453  * errors are in the #G_SHELL_ERROR domain.
24454  *
24455  * Shell quoting rules are a bit strange. Single quotes preserve the
24456  * literal string exactly. escape sequences are not allowed; not even
24457  * \' - if you want a ' in the quoted text, you have to do something
24458  * like 'foo'\''bar'.  Double quotes allow $, `, ", \, and newline to
24459  * be escaped with backslash. Otherwise double quotes preserve things
24460  * literally.
24461  *
24462  * Returns: an unquoted string
24463  */
24464
24465
24466 /**
24467  * g_slice_alloc:
24468  * @block_size: the number of bytes to allocate
24469  *
24470  * Allocates a block of memory from the slice allocator.
24471  * The block adress handed out can be expected to be aligned
24472  * to at least <literal>1 * sizeof (void*)</literal>,
24473  * though in general slices are 2 * sizeof (void*) bytes aligned,
24474  * if a malloc() fallback implementation is used instead,
24475  * the alignment may be reduced in a libc dependent fashion.
24476  * Note that the underlying slice allocation mechanism can
24477  * be changed with the <link linkend="G_SLICE">G_SLICE=always-malloc</link>
24478  * environment variable.
24479  *
24480  * Returns: a pointer to the allocated memory block
24481  * Since: 2.10
24482  */
24483
24484
24485 /**
24486  * g_slice_alloc0:
24487  * @block_size: the number of bytes to allocate
24488  *
24489  * Allocates a block of memory via g_slice_alloc() and initializes
24490  * the returned memory to 0. Note that the underlying slice allocation
24491  * mechanism can be changed with the
24492  * <link linkend="G_SLICE">G_SLICE=always-malloc</link>
24493  * environment variable.
24494  *
24495  * Returns: a pointer to the allocated block
24496  * Since: 2.10
24497  */
24498
24499
24500 /**
24501  * g_slice_copy:
24502  * @block_size: the number of bytes to allocate
24503  * @mem_block: the memory to copy
24504  *
24505  * Allocates a block of memory from the slice allocator
24506  * and copies @block_size bytes into it from @mem_block.
24507  *
24508  * Returns: a pointer to the allocated memory block
24509  * Since: 2.14
24510  */
24511
24512
24513 /**
24514  * g_slice_dup:
24515  * @type: the type to duplicate, typically a structure name
24516  * @mem: the memory to copy into the allocated block
24517  *
24518  * A convenience macro to duplicate a block of memory using
24519  * the slice allocator.
24520  *
24521  * It calls g_slice_copy() with <literal>sizeof (@type)</literal>
24522  * and casts the returned pointer to a pointer of the given type,
24523  * avoiding a type cast in the source code.
24524  * Note that the underlying slice allocation mechanism can
24525  * be changed with the <link linkend="G_SLICE">G_SLICE=always-malloc</link>
24526  * environment variable.
24527  *
24528  * Returns: a pointer to the allocated block, cast to a pointer to @type
24529  * Since: 2.14
24530  */
24531
24532
24533 /**
24534  * g_slice_free:
24535  * @type: the type of the block to free, typically a structure name
24536  * @mem: a pointer to the block to free
24537  *
24538  * A convenience macro to free a block of memory that has
24539  * been allocated from the slice allocator.
24540  *
24541  * It calls g_slice_free1() using <literal>sizeof (type)</literal>
24542  * as the block size.
24543  * Note that the exact release behaviour can be changed with the
24544  * <link linkend="G_DEBUG">G_DEBUG=gc-friendly</link> environment
24545  * variable, also see <link linkend="G_SLICE">G_SLICE</link> for
24546  * related debugging options.
24547  *
24548  * Since: 2.10
24549  */
24550
24551
24552 /**
24553  * g_slice_free1:
24554  * @block_size: the size of the block
24555  * @mem_block: a pointer to the block to free
24556  *
24557  * Frees a block of memory.
24558  *
24559  * The memory must have been allocated via g_slice_alloc() or
24560  * g_slice_alloc0() and the @block_size has to match the size
24561  * specified upon allocation. Note that the exact release behaviour
24562  * can be changed with the
24563  * <link linkend="G_DEBUG">G_DEBUG=gc-friendly</link> environment
24564  * variable, also see <link linkend="G_SLICE">G_SLICE</link> for
24565  * related debugging options.
24566  *
24567  * Since: 2.10
24568  */
24569
24570
24571 /**
24572  * g_slice_free_chain:
24573  * @type: the type of the @mem_chain blocks
24574  * @mem_chain: a pointer to the first block of the chain
24575  * @next: the field name of the next pointer in @type
24576  *
24577  * Frees a linked list of memory blocks of structure type @type.
24578  * The memory blocks must be equal-sized, allocated via
24579  * g_slice_alloc() or g_slice_alloc0() and linked together by
24580  * a @next pointer (similar to #GSList). The name of the
24581  * @next field in @type is passed as third argument.
24582  * Note that the exact release behaviour can be changed with the
24583  * <link linkend="G_DEBUG">G_DEBUG=gc-friendly</link> environment
24584  * variable, also see <link linkend="G_SLICE">G_SLICE</link> for
24585  * related debugging options.
24586  *
24587  * Since: 2.10
24588  */
24589
24590
24591 /**
24592  * g_slice_free_chain_with_offset:
24593  * @block_size: the size of the blocks
24594  * @mem_chain: a pointer to the first block of the chain
24595  * @next_offset: the offset of the @next field in the blocks
24596  *
24597  * Frees a linked list of memory blocks of structure type @type.
24598  *
24599  * The memory blocks must be equal-sized, allocated via
24600  * g_slice_alloc() or g_slice_alloc0() and linked together by a
24601  * @next pointer (similar to #GSList). The offset of the @next
24602  * field in each block is passed as third argument.
24603  * Note that the exact release behaviour can be changed with the
24604  * <link linkend="G_DEBUG">G_DEBUG=gc-friendly</link> environment
24605  * variable, also see <link linkend="G_SLICE">G_SLICE</link> for
24606  * related debugging options.
24607  *
24608  * Since: 2.10
24609  */
24610
24611
24612 /**
24613  * g_slice_new:
24614  * @type: the type to allocate, typically a structure name
24615  *
24616  * A convenience macro to allocate a block of memory from the
24617  * slice allocator.
24618  *
24619  * It calls g_slice_alloc() with <literal>sizeof (@type)</literal>
24620  * and casts the returned pointer to a pointer of the given type,
24621  * avoiding a type cast in the source code.
24622  * Note that the underlying slice allocation mechanism can
24623  * be changed with the <link linkend="G_SLICE">G_SLICE=always-malloc</link>
24624  * environment variable.
24625  *
24626  * Returns: a pointer to the allocated block, cast to a pointer to @type
24627  * Since: 2.10
24628  */
24629
24630
24631 /**
24632  * g_slice_new0:
24633  * @type: the type to allocate, typically a structure name
24634  *
24635  * A convenience macro to allocate a block of memory from the
24636  * slice allocator and set the memory to 0.
24637  *
24638  * It calls g_slice_alloc0() with <literal>sizeof (@type)</literal>
24639  * and casts the returned pointer to a pointer of the given type,
24640  * avoiding a type cast in the source code.
24641  * Note that the underlying slice allocation mechanism can
24642  * be changed with the <link linkend="G_SLICE">G_SLICE=always-malloc</link>
24643  * environment variable.
24644  *
24645  * Since: 2.10
24646  */
24647
24648
24649 /**
24650  * g_slist_alloc:
24651  *
24652  * Allocates space for one #GSList element. It is called by the
24653  * g_slist_append(), g_slist_prepend(), g_slist_insert() and
24654  * g_slist_insert_sorted() functions and so is rarely used on its own.
24655  *
24656  * Returns: a pointer to the newly-allocated #GSList element.
24657  */
24658
24659
24660 /**
24661  * g_slist_append:
24662  * @list: a #GSList
24663  * @data: the data for the new element
24664  *
24665  * Adds a new element on to the end of the list.
24666  *
24667  * <note><para>
24668  * The return value is the new start of the list, which may
24669  * have changed, so make sure you store the new value.
24670  * </para></note>
24671  *
24672  * <note><para>
24673  * Note that g_slist_append() has to traverse the entire list
24674  * to find the end, which is inefficient when adding multiple
24675  * elements. A common idiom to avoid the inefficiency is to prepend
24676  * the elements and reverse the list when all elements have been added.
24677  * </para></note>
24678  *
24679  * |[
24680  * /&ast; Notice that these are initialized to the empty list. &ast;/
24681  * GSList *list = NULL, *number_list = NULL;
24682  *
24683  * /&ast; This is a list of strings. &ast;/
24684  * list = g_slist_append (list, "first");
24685  * list = g_slist_append (list, "second");
24686  *
24687  * /&ast; This is a list of integers. &ast;/
24688  * number_list = g_slist_append (number_list, GINT_TO_POINTER (27));
24689  * number_list = g_slist_append (number_list, GINT_TO_POINTER (14));
24690  * ]|
24691  *
24692  * Returns: the new start of the #GSList
24693  */
24694
24695
24696 /**
24697  * g_slist_concat:
24698  * @list1: a #GSList
24699  * @list2: the #GSList to add to the end of the first #GSList
24700  *
24701  * Adds the second #GSList onto the end of the first #GSList.
24702  * Note that the elements of the second #GSList are not copied.
24703  * They are used directly.
24704  *
24705  * Returns: the start of the new #GSList
24706  */
24707
24708
24709 /**
24710  * g_slist_copy:
24711  * @list: a #GSList
24712  *
24713  * Copies a #GSList.
24714  *
24715  * <note><para>
24716  * Note that this is a "shallow" copy. If the list elements
24717  * consist of pointers to data, the pointers are copied but
24718  * the actual data isn't. See g_slist_copy_deep() if you need
24719  * to copy the data as well.
24720  * </para></note>
24721  *
24722  * Returns: a copy of @list
24723  */
24724
24725
24726 /**
24727  * g_slist_copy_deep:
24728  * @list: a #GSList
24729  * @func: a copy function used to copy every element in the list
24730  * @user_data: user data passed to the copy function @func, or #NULL
24731  *
24732  * Makes a full (deep) copy of a #GSList.
24733  *
24734  * In contrast with g_slist_copy(), this function uses @func to make a copy of
24735  * each list element, in addition to copying the list container itself.
24736  *
24737  * @func, as a #GCopyFunc, takes two arguments, the data to be copied and a user
24738  * pointer. It's safe to pass #NULL as user_data, if the copy function takes only
24739  * one argument.
24740  *
24741  * For instance, if @list holds a list of GObjects, you can do:
24742  * |[
24743  * another_list = g_slist_copy_deep (list, (GCopyFunc) g_object_ref, NULL);
24744  * ]|
24745  *
24746  * And, to entirely free the new list, you could do:
24747  * |[
24748  * g_slist_free_full (another_list, g_object_unref);
24749  * ]|
24750  *
24751  * Returns: a full copy of @list, use #g_slist_free_full to free it
24752  * Since: 2.34
24753  */
24754
24755
24756 /**
24757  * g_slist_delete_link:
24758  * @list: a #GSList
24759  * @link_: node to delete
24760  *
24761  * Removes the node link_ from the list and frees it.
24762  * Compare this to g_slist_remove_link() which removes the node
24763  * without freeing it.
24764  *
24765  * <note>Removing arbitrary nodes from a singly-linked list
24766  * requires time that is proportional to the length of the list
24767  * (ie. O(n)). If you find yourself using g_slist_delete_link()
24768  * frequently, you should consider a different data structure, such
24769  * as the doubly-linked #GList.</note>
24770  *
24771  * Returns: the new head of @list
24772  */
24773
24774
24775 /**
24776  * g_slist_find:
24777  * @list: a #GSList
24778  * @data: the element data to find
24779  *
24780  * Finds the element in a #GSList which
24781  * contains the given data.
24782  *
24783  * Returns: the found #GSList element, or %NULL if it is not found
24784  */
24785
24786
24787 /**
24788  * g_slist_find_custom:
24789  * @list: a #GSList
24790  * @data: user data passed to the function
24791  * @func: the function to call for each element. It should return 0 when the desired element is found
24792  *
24793  * Finds an element in a #GSList, using a supplied function to
24794  * find the desired element. It iterates over the list, calling
24795  * the given function which should return 0 when the desired
24796  * element is found. The function takes two #gconstpointer arguments,
24797  * the #GSList element's data as the first argument and the
24798  * given user data.
24799  *
24800  * Returns: the found #GSList element, or %NULL if it is not found
24801  */
24802
24803
24804 /**
24805  * g_slist_foreach:
24806  * @list: a #GSList
24807  * @func: the function to call with each element's data
24808  * @user_data: user data to pass to the function
24809  *
24810  * Calls a function for each element of a #GSList.
24811  */
24812
24813
24814 /**
24815  * g_slist_free:
24816  * @list: a #GSList
24817  *
24818  * Frees all of the memory used by a #GSList.
24819  * The freed elements are returned to the slice allocator.
24820  *
24821  * <note><para>
24822  * If list elements contain dynamically-allocated memory,
24823  * you should either use g_slist_free_full() or free them manually
24824  * first.
24825  * </para></note>
24826  */
24827
24828
24829 /**
24830  * g_slist_free1:
24831  *
24832  * A macro which does the same as g_slist_free_1().
24833  *
24834  * Since: 2.10
24835  */
24836
24837
24838 /**
24839  * g_slist_free_1:
24840  * @list: a #GSList element
24841  *
24842  * Frees one #GSList element.
24843  * It is usually used after g_slist_remove_link().
24844  */
24845
24846
24847 /**
24848  * g_slist_free_full:
24849  * @list: a pointer to a #GSList
24850  * @free_func: the function to be called to free each element's data
24851  *
24852  * Convenience method, which frees all the memory used by a #GSList, and
24853  * calls the specified destroy function on every element's data.
24854  *
24855  * Since: 2.28
24856  */
24857
24858
24859 /**
24860  * g_slist_index:
24861  * @list: a #GSList
24862  * @data: the data to find
24863  *
24864  * Gets the position of the element containing
24865  * the given data (starting from 0).
24866  *
24867  * Returns: the index of the element containing the data, or -1 if the data is not found
24868  */
24869
24870
24871 /**
24872  * g_slist_insert:
24873  * @list: a #GSList
24874  * @data: the data for the new element
24875  * @position: the position to insert the element. If this is negative, or is larger than the number of elements in the list, the new element is added on to the end of the list.
24876  *
24877  * Inserts a new element into the list at the given position.
24878  *
24879  * Returns: the new start of the #GSList
24880  */
24881
24882
24883 /**
24884  * g_slist_insert_before:
24885  * @slist: a #GSList
24886  * @sibling: node to insert @data before
24887  * @data: data to put in the newly-inserted node
24888  *
24889  * Inserts a node before @sibling containing @data.
24890  *
24891  * Returns: the new head of the list.
24892  */
24893
24894
24895 /**
24896  * g_slist_insert_sorted:
24897  * @list: a #GSList
24898  * @data: the data for the new element
24899  * @func: the function to compare elements in the list. It should return a number > 0 if the first parameter comes after the second parameter in the sort order.
24900  *
24901  * Inserts a new element into the list, using the given
24902  * comparison function to determine its position.
24903  *
24904  * Returns: the new start of the #GSList
24905  */
24906
24907
24908 /**
24909  * g_slist_insert_sorted_with_data:
24910  * @list: a #GSList
24911  * @data: the data for the new element
24912  * @func: the function to compare elements in the list. It should return a number > 0 if the first parameter comes after the second parameter in the sort order.
24913  * @user_data: data to pass to comparison function
24914  *
24915  * Inserts a new element into the list, using the given
24916  * comparison function to determine its position.
24917  *
24918  * Returns: the new start of the #GSList
24919  * Since: 2.10
24920  */
24921
24922
24923 /**
24924  * g_slist_last:
24925  * @list: a #GSList
24926  *
24927  * Gets the last element in a #GSList.
24928  *
24929  * <note><para>
24930  * This function iterates over the whole list.
24931  * </para></note>
24932  *
24933  * Returns: the last element in the #GSList, or %NULL if the #GSList has no elements
24934  */
24935
24936
24937 /**
24938  * g_slist_length:
24939  * @list: a #GSList
24940  *
24941  * Gets the number of elements in a #GSList.
24942  *
24943  * <note><para>
24944  * This function iterates over the whole list to
24945  * count its elements.
24946  * </para></note>
24947  *
24948  * Returns: the number of elements in the #GSList
24949  */
24950
24951
24952 /**
24953  * g_slist_next:
24954  * @slist: an element in a #GSList.
24955  *
24956  * A convenience macro to get the next element in a #GSList.
24957  *
24958  * Returns: the next element, or %NULL if there are no more elements.
24959  */
24960
24961
24962 /**
24963  * g_slist_nth:
24964  * @list: a #GSList
24965  * @n: the position of the element, counting from 0
24966  *
24967  * Gets the element at the given position in a #GSList.
24968  *
24969  * Returns: the element, or %NULL if the position is off the end of the #GSList
24970  */
24971
24972
24973 /**
24974  * g_slist_nth_data:
24975  * @list: a #GSList
24976  * @n: the position of the element
24977  *
24978  * Gets the data of the element at the given position.
24979  *
24980  * Returns: the element's data, or %NULL if the position is off the end of the #GSList
24981  */
24982
24983
24984 /**
24985  * g_slist_position:
24986  * @list: a #GSList
24987  * @llink: an element in the #GSList
24988  *
24989  * Gets the position of the given element
24990  * in the #GSList (starting from 0).
24991  *
24992  * Returns: the position of the element in the #GSList, or -1 if the element is not found
24993  */
24994
24995
24996 /**
24997  * g_slist_prepend:
24998  * @list: a #GSList
24999  * @data: the data for the new element
25000  *
25001  * Adds a new element on to the start of the list.
25002  *
25003  * <note><para>
25004  * The return value is the new start of the list, which
25005  * may have changed, so make sure you store the new value.
25006  * </para></note>
25007  *
25008  * |[
25009  * /&ast; Notice that it is initialized to the empty list. &ast;/
25010  * GSList *list = NULL;
25011  * list = g_slist_prepend (list, "last");
25012  * list = g_slist_prepend (list, "first");
25013  * ]|
25014  *
25015  * Returns: the new start of the #GSList
25016  */
25017
25018
25019 /**
25020  * g_slist_remove:
25021  * @list: a #GSList
25022  * @data: the data of the element to remove
25023  *
25024  * Removes an element from a #GSList.
25025  * If two elements contain the same data, only the first is removed.
25026  * If none of the elements contain the data, the #GSList is unchanged.
25027  *
25028  * Returns: the new start of the #GSList
25029  */
25030
25031
25032 /**
25033  * g_slist_remove_all:
25034  * @list: a #GSList
25035  * @data: data to remove
25036  *
25037  * Removes all list nodes with data equal to @data.
25038  * Returns the new head of the list. Contrast with
25039  * g_slist_remove() which removes only the first node
25040  * matching the given data.
25041  *
25042  * Returns: new head of @list
25043  */
25044
25045
25046 /**
25047  * g_slist_remove_link:
25048  * @list: a #GSList
25049  * @link_: an element in the #GSList
25050  *
25051  * Removes an element from a #GSList, without
25052  * freeing the element. The removed element's next
25053  * link is set to %NULL, so that it becomes a
25054  * self-contained list with one element.
25055  *
25056  * <note>Removing arbitrary nodes from a singly-linked list
25057  * requires time that is proportional to the length of the list
25058  * (ie. O(n)). If you find yourself using g_slist_remove_link()
25059  * frequently, you should consider a different data structure, such
25060  * as the doubly-linked #GList.</note>
25061  *
25062  * Returns: the new start of the #GSList, without the element
25063  */
25064
25065
25066 /**
25067  * g_slist_reverse:
25068  * @list: a #GSList
25069  *
25070  * Reverses a #GSList.
25071  *
25072  * Returns: the start of the reversed #GSList
25073  */
25074
25075
25076 /**
25077  * g_slist_sort:
25078  * @list: a #GSList
25079  * @compare_func: the comparison function used to sort the #GSList. This function is passed the data from 2 elements of the #GSList and should return 0 if they are equal, a negative value if the first element comes before the second, or a positive value if the first element comes after the second.
25080  *
25081  * Sorts a #GSList using the given comparison function.
25082  *
25083  * Returns: the start of the sorted #GSList
25084  */
25085
25086
25087 /**
25088  * g_slist_sort_with_data:
25089  * @list: a #GSList
25090  * @compare_func: comparison function
25091  * @user_data: data to pass to comparison function
25092  *
25093  * Like g_slist_sort(), but the sort function accepts a user data argument.
25094  *
25095  * Returns: new head of the list
25096  */
25097
25098
25099 /**
25100  * g_snprintf:
25101  * @string: the buffer to hold the output.
25102  * @n: the maximum number of bytes to produce (including the terminating nul character).
25103  * @format: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
25104  * @...: the arguments to insert in the output.
25105  *
25106  * A safer form of the standard sprintf() function. The output is guaranteed
25107  * to not exceed @n characters (including the terminating nul character), so
25108  * it is easy to ensure that a buffer overflow cannot occur.
25109  *
25110  * See also g_strdup_printf().
25111  *
25112  * In versions of GLib prior to 1.2.3, this function may return -1 if the
25113  * output was truncated, and the truncated string may not be nul-terminated.
25114  * In versions prior to 1.3.12, this function returns the length of the output
25115  * string.
25116  *
25117  * The return value of g_snprintf() conforms to the snprintf()
25118  * function as standardized in ISO C99. Note that this is different from
25119  * traditional snprintf(), which returns the length of the output string.
25120  *
25121  * The format string may contain positional parameters, as specified in
25122  * the Single Unix Specification.
25123  *
25124  * Returns: the number of bytes which would be produced if the buffer was large enough.
25125  */
25126
25127
25128 /**
25129  * g_source_add_child_source:
25130  * @source: a #GSource
25131  * @child_source: a second #GSource that @source should "poll"
25132  *
25133  * Adds @child_source to @source as a "polled" source; when @source is
25134  * added to a #GMainContext, @child_source will be automatically added
25135  * with the same priority, when @child_source is triggered, it will
25136  * cause @source to dispatch (in addition to calling its own
25137  * callback), and when @source is destroyed, it will destroy
25138  * @child_source as well. (@source will also still be dispatched if
25139  * its own prepare/check functions indicate that it is ready.)
25140  *
25141  * If you don't need @child_source to do anything on its own when it
25142  * triggers, you can call g_source_set_dummy_callback() on it to set a
25143  * callback that does nothing (except return %TRUE if appropriate).
25144  *
25145  * @source will hold a reference on @child_source while @child_source
25146  * is attached to it.
25147  *
25148  * Since: 2.28
25149  */
25150
25151
25152 /**
25153  * g_source_add_poll:
25154  * @source: a #GSource
25155  * @fd: a #GPollFD structure holding information about a file descriptor to watch.
25156  *
25157  * Adds a file descriptor to the set of file descriptors polled for
25158  * this source. This is usually combined with g_source_new() to add an
25159  * event source. The event source's check function will typically test
25160  * the @revents field in the #GPollFD struct and return %TRUE if events need
25161  * to be processed.
25162  *
25163  * Using this API forces the linear scanning of event sources on each
25164  * main loop iteration.  Newly-written event sources should try to use
25165  * g_source_add_unix_fd() instead of this API.
25166  */
25167
25168
25169 /**
25170  * g_source_add_unix_fd:
25171  * @source: a #GSource
25172  * @fd: the fd to monitor
25173  * @events: an event mask
25174  *
25175  * Monitors @fd for the IO events in @events.
25176  *
25177  * The tag returned by this function can be used to remove or modify the
25178  * monitoring of the fd using g_source_remove_unix_fd() or
25179  * g_source_modify_unix_fd().
25180  *
25181  * It is not necessary to remove the fd before destroying the source; it
25182  * will be cleaned up automatically.
25183  *
25184  * As the name suggests, this function is not available on Windows.
25185  *
25186  * Returns: an opaque tag
25187  * Since: 2.36
25188  */
25189
25190
25191 /**
25192  * g_source_attach:
25193  * @source: a #GSource
25194  * @context: (allow-none): a #GMainContext (if %NULL, the default context will be used)
25195  *
25196  * Adds a #GSource to a @context so that it will be executed within
25197  * that context. Remove it by calling g_source_destroy().
25198  *
25199  * Returns: the ID (greater than 0) for the source within the #GMainContext.
25200  */
25201
25202
25203 /**
25204  * g_source_destroy:
25205  * @source: a #GSource
25206  *
25207  * Removes a source from its #GMainContext, if any, and mark it as
25208  * destroyed.  The source cannot be subsequently added to another
25209  * context.
25210  */
25211
25212
25213 /**
25214  * g_source_get_can_recurse:
25215  * @source: a #GSource
25216  *
25217  * Checks whether a source is allowed to be called recursively.
25218  * see g_source_set_can_recurse().
25219  *
25220  * Returns: whether recursion is allowed.
25221  */
25222
25223
25224 /**
25225  * g_source_get_context:
25226  * @source: a #GSource
25227  *
25228  * Gets the #GMainContext with which the source is associated.
25229  *
25230  * You can call this on a source that has been destroyed, provided
25231  * that the #GMainContext it was attached to still exists (in which
25232  * case it will return that #GMainContext). In particular, you can
25233  * always call this function on the source returned from
25234  * g_main_current_source(). But calling this function on a source
25235  * whose #GMainContext has been destroyed is an error.
25236  *
25237  * Returns: (transfer none) (allow-none): the #GMainContext with which the source is associated, or %NULL if the context has not yet been added to a source.
25238  */
25239
25240
25241 /**
25242  * g_source_get_current_time:
25243  * @source: a #GSource
25244  * @timeval: #GTimeVal structure in which to store current time.
25245  *
25246  * This function ignores @source and is otherwise the same as
25247  * g_get_current_time().
25248  *
25249  * Deprecated: 2.28: use g_source_get_time() instead
25250  */
25251
25252
25253 /**
25254  * g_source_get_id:
25255  * @source: a #GSource
25256  *
25257  * Returns the numeric ID for a particular source. The ID of a source
25258  * is a positive integer which is unique within a particular main loop
25259  * context. The reverse
25260  * mapping from ID to source is done by g_main_context_find_source_by_id().
25261  *
25262  * Returns: the ID (greater than 0) for the source
25263  */
25264
25265
25266 /**
25267  * g_source_get_name:
25268  * @source: a #GSource
25269  *
25270  * Gets a name for the source, used in debugging and profiling.
25271  * The name may be #NULL if it has never been set with
25272  * g_source_set_name().
25273  *
25274  * Returns: the name of the source
25275  * Since: 2.26
25276  */
25277
25278
25279 /**
25280  * g_source_get_priority:
25281  * @source: a #GSource
25282  *
25283  * Gets the priority of a source.
25284  *
25285  * Returns: the priority of the source
25286  */
25287
25288
25289 /**
25290  * g_source_get_ready_time:
25291  * @source: a #GSource
25292  *
25293  * Gets the "ready time" of @source, as set by
25294  * g_source_set_ready_time().
25295  *
25296  * Any time before the current monotonic time (including 0) is an
25297  * indication that the source will fire immediately.
25298  *
25299  * Returns: the monotonic ready time, -1 for "never"
25300  */
25301
25302
25303 /**
25304  * g_source_get_time:
25305  * @source: a #GSource
25306  *
25307  * Gets the time to be used when checking this source. The advantage of
25308  * calling this function over calling g_get_monotonic_time() directly is
25309  * that when checking multiple sources, GLib can cache a single value
25310  * instead of having to repeatedly get the system monotonic time.
25311  *
25312  * The time here is the system monotonic time, if available, or some
25313  * other reasonable alternative otherwise.  See g_get_monotonic_time().
25314  *
25315  * Returns: the monotonic time in microseconds
25316  * Since: 2.28
25317  */
25318
25319
25320 /**
25321  * g_source_is_destroyed:
25322  * @source: a #GSource
25323  *
25324  * Returns whether @source has been destroyed.
25325  *
25326  * This is important when you operate upon your objects
25327  * from within idle handlers, but may have freed the object
25328  * before the dispatch of your idle handler.
25329  *
25330  * |[
25331  * static gboolean
25332  * idle_callback (gpointer data)
25333  * {
25334  *   SomeWidget *self = data;
25335  *
25336  *   GDK_THREADS_ENTER (<!-- -->);
25337  *   /<!-- -->* do stuff with self *<!-- -->/
25338  *   self->idle_id = 0;
25339  *   GDK_THREADS_LEAVE (<!-- -->);
25340  *
25341  *   return G_SOURCE_REMOVE;
25342  * }
25343  *
25344  * static void
25345  * some_widget_do_stuff_later (SomeWidget *self)
25346  * {
25347  *   self->idle_id = g_idle_add (idle_callback, self);
25348  * }
25349  *
25350  * static void
25351  * some_widget_finalize (GObject *object)
25352  * {
25353  *   SomeWidget *self = SOME_WIDGET (object);
25354  *
25355  *   if (self->idle_id)
25356  *     g_source_remove (self->idle_id);
25357  *
25358  *   G_OBJECT_CLASS (parent_class)->finalize (object);
25359  * }
25360  * ]|
25361  *
25362  * This will fail in a multi-threaded application if the
25363  * widget is destroyed before the idle handler fires due
25364  * to the use after free in the callback. A solution, to
25365  * this particular problem, is to check to if the source
25366  * has already been destroy within the callback.
25367  *
25368  * |[
25369  * static gboolean
25370  * idle_callback (gpointer data)
25371  * {
25372  *   SomeWidget *self = data;
25373  *
25374  *   GDK_THREADS_ENTER ();
25375  *   if (!g_source_is_destroyed (g_main_current_source ()))
25376  *     {
25377  *       /<!-- -->* do stuff with self *<!-- -->/
25378  *     }
25379  *   GDK_THREADS_LEAVE ();
25380  *
25381  *   return FALSE;
25382  * }
25383  * ]|
25384  *
25385  * Returns: %TRUE if the source has been destroyed
25386  * Since: 2.12
25387  */
25388
25389
25390 /**
25391  * g_source_modify_unix_fd:
25392  * @source: a #GSource
25393  * @tag: the tag from g_source_add_unix_fd()
25394  * @new_events: the new event mask to watch
25395  *
25396  * Updates the event mask to watch for the fd identified by @tag.
25397  *
25398  * @tag is the tag returned from g_source_add_unix_fd().
25399  *
25400  * If you want to remove a fd, don't set its event mask to zero.
25401  * Instead, call g_source_remove_unix_fd().
25402  *
25403  * As the name suggests, this function is not available on Windows.
25404  *
25405  * Since: 2.36
25406  */
25407
25408
25409 /**
25410  * g_source_new:
25411  * @source_funcs: structure containing functions that implement the sources behavior.
25412  * @struct_size: size of the #GSource structure to create.
25413  *
25414  * Creates a new #GSource structure. The size is specified to
25415  * allow creating structures derived from #GSource that contain
25416  * additional data. The size passed in must be at least
25417  * <literal>sizeof (GSource)</literal>.
25418  *
25419  * The source will not initially be associated with any #GMainContext
25420  * and must be added to one with g_source_attach() before it will be
25421  * executed.
25422  *
25423  * Returns: the newly-created #GSource.
25424  */
25425
25426
25427 /**
25428  * g_source_query_unix_fd:
25429  * @source: a #GSource
25430  * @tag: the tag from g_source_add_unix_fd()
25431  *
25432  * Queries the events reported for the fd corresponding to @tag on
25433  * @source during the last poll.
25434  *
25435  * The return value of this function is only defined when the function
25436  * is called from the check or dispatch functions for @source.
25437  *
25438  * As the name suggests, this function is not available on Windows.
25439  *
25440  * Returns: the conditions reported on the fd
25441  * Since: 2.36
25442  */
25443
25444
25445 /**
25446  * g_source_ref:
25447  * @source: a #GSource
25448  *
25449  * Increases the reference count on a source by one.
25450  *
25451  * Returns: @source
25452  */
25453
25454
25455 /**
25456  * g_source_remove:
25457  * @tag: the ID of the source to remove.
25458  *
25459  * Removes the source with the given id from the default main context.
25460  * The id of
25461  * a #GSource is given by g_source_get_id(), or will be returned by the
25462  * functions g_source_attach(), g_idle_add(), g_idle_add_full(),
25463  * g_timeout_add(), g_timeout_add_full(), g_child_watch_add(),
25464  * g_child_watch_add_full(), g_io_add_watch(), and g_io_add_watch_full().
25465  *
25466  * See also g_source_destroy(). You must use g_source_destroy() for sources
25467  * added to a non-default main context.
25468  *
25469  * Returns: %TRUE if the source was found and removed.
25470  */
25471
25472
25473 /**
25474  * g_source_remove_by_funcs_user_data:
25475  * @funcs: The @source_funcs passed to g_source_new()
25476  * @user_data: the user data for the callback
25477  *
25478  * Removes a source from the default main loop context given the
25479  * source functions and user data. If multiple sources exist with the
25480  * same source functions and user data, only one will be destroyed.
25481  *
25482  * Returns: %TRUE if a source was found and removed.
25483  */
25484
25485
25486 /**
25487  * g_source_remove_by_user_data:
25488  * @user_data: the user_data for the callback.
25489  *
25490  * Removes a source from the default main loop context given the user
25491  * data for the callback. If multiple sources exist with the same user
25492  * data, only one will be destroyed.
25493  *
25494  * Returns: %TRUE if a source was found and removed.
25495  */
25496
25497
25498 /**
25499  * g_source_remove_child_source:
25500  * @source: a #GSource
25501  * @child_source: a #GSource previously passed to g_source_add_child_source().
25502  *
25503  * Detaches @child_source from @source and destroys it.
25504  *
25505  * Since: 2.28
25506  */
25507
25508
25509 /**
25510  * g_source_remove_poll:
25511  * @source: a #GSource
25512  * @fd: a #GPollFD structure previously passed to g_source_add_poll().
25513  *
25514  * Removes a file descriptor from the set of file descriptors polled for
25515  * this source.
25516  */
25517
25518
25519 /**
25520  * g_source_remove_unix_fd:
25521  * @source: a #GSource
25522  * @tag: the tag from g_source_add_unix_fd()
25523  *
25524  * Reverses the effect of a previous call to g_source_add_unix_fd().
25525  *
25526  * You only need to call this if you want to remove an fd from being
25527  * watched while keeping the same source around.  In the normal case you
25528  * will just want to destroy the source.
25529  *
25530  * As the name suggests, this function is not available on Windows.
25531  *
25532  * Since: 2.36
25533  */
25534
25535
25536 /**
25537  * g_source_set_callback:
25538  * @source: the source
25539  * @func: a callback function
25540  * @data: the data to pass to callback function
25541  * @notify: (allow-none): a function to call when @data is no longer in use, or %NULL.
25542  *
25543  * Sets the callback function for a source. The callback for a source is
25544  * called from the source's dispatch function.
25545  *
25546  * The exact type of @func depends on the type of source; ie. you
25547  * should not count on @func being called with @data as its first
25548  * parameter.
25549  *
25550  * Typically, you won't use this function. Instead use functions specific
25551  * to the type of source you are using.
25552  */
25553
25554
25555 /**
25556  * g_source_set_callback_indirect:
25557  * @source: the source
25558  * @callback_data: pointer to callback data "object"
25559  * @callback_funcs: functions for reference counting @callback_data and getting the callback and data
25560  *
25561  * Sets the callback function storing the data as a refcounted callback
25562  * "object". This is used internally. Note that calling
25563  * g_source_set_callback_indirect() assumes
25564  * an initial reference count on @callback_data, and thus
25565  * @callback_funcs->unref will eventually be called once more
25566  * than @callback_funcs->ref.
25567  */
25568
25569
25570 /**
25571  * g_source_set_can_recurse:
25572  * @source: a #GSource
25573  * @can_recurse: whether recursion is allowed for this source
25574  *
25575  * Sets whether a source can be called recursively. If @can_recurse is
25576  * %TRUE, then while the source is being dispatched then this source
25577  * will be processed normally. Otherwise, all processing of this
25578  * source is blocked until the dispatch function returns.
25579  */
25580
25581
25582 /**
25583  * g_source_set_funcs:
25584  * @source: a #GSource
25585  * @funcs: the new #GSourceFuncs
25586  *
25587  * Sets the source functions (can be used to override
25588  * default implementations) of an unattached source.
25589  *
25590  * Since: 2.12
25591  */
25592
25593
25594 /**
25595  * g_source_set_name:
25596  * @source: a #GSource
25597  * @name: debug name for the source
25598  *
25599  * Sets a name for the source, used in debugging and profiling.
25600  * The name defaults to #NULL.
25601  *
25602  * The source name should describe in a human-readable way
25603  * what the source does. For example, "X11 event queue"
25604  * or "GTK+ repaint idle handler" or whatever it is.
25605  *
25606  * It is permitted to call this function multiple times, but is not
25607  * recommended due to the potential performance impact.  For example,
25608  * one could change the name in the "check" function of a #GSourceFuncs
25609  * to include details like the event type in the source name.
25610  *
25611  * Since: 2.26
25612  */
25613
25614
25615 /**
25616  * g_source_set_name_by_id:
25617  * @tag: a #GSource ID
25618  * @name: debug name for the source
25619  *
25620  * Sets the name of a source using its ID.
25621  *
25622  * This is a convenience utility to set source names from the return
25623  * value of g_idle_add(), g_timeout_add(), etc.
25624  *
25625  * Since: 2.26
25626  */
25627
25628
25629 /**
25630  * g_source_set_priority:
25631  * @source: a #GSource
25632  * @priority: the new priority.
25633  *
25634  * Sets the priority of a source. While the main loop is being run, a
25635  * source will be dispatched if it is ready to be dispatched and no
25636  * sources at a higher (numerically smaller) priority are ready to be
25637  * dispatched.
25638  */
25639
25640
25641 /**
25642  * g_source_set_ready_time:
25643  * @source: a #GSource
25644  * @ready_time: the monotonic time at which the source will be ready, 0 for "immediately", -1 for "never"
25645  *
25646  * Sets a #GSource to be dispatched when the given monotonic time is
25647  * reached (or passed).  If the monotonic time is in the past (as it
25648  * always will be if @ready_time is 0) then the source will be
25649  * dispatched immediately.
25650  *
25651  * If @ready_time is -1 then the source is never woken up on the basis
25652  * of the passage of time.
25653  *
25654  * Dispatching the source does not reset the ready time.  You should do
25655  * so yourself, from the source dispatch function.
25656  *
25657  * Note that if you have a pair of sources where the ready time of one
25658  * suggests that it will be delivered first but the priority for the
25659  * other suggests that it would be delivered first, and the ready time
25660  * for both sources is reached during the same main context iteration
25661  * then the order of dispatch is undefined.
25662  *
25663  * Since: 2.36
25664  */
25665
25666
25667 /**
25668  * g_source_unref:
25669  * @source: a #GSource
25670  *
25671  * Decreases the reference count of a source by one. If the
25672  * resulting reference count is zero the source and associated
25673  * memory will be destroyed.
25674  */
25675
25676
25677 /**
25678  * g_spaced_primes_closest:
25679  * @num: a #guint
25680  *
25681  * Gets the smallest prime number from a built-in array of primes which
25682  * is larger than @num. This is used within GLib to calculate the optimum
25683  * size of a #GHashTable.
25684  *
25685  * The built-in array of primes ranges from 11 to 13845163 such that
25686  * each prime is approximately 1.5-2 times the previous prime.
25687  *
25688  * Returns: the smallest prime number from a built-in array of primes which is larger than @num
25689  */
25690
25691
25692 /**
25693  * g_spawn_async:
25694  * @working_directory: (allow-none): child's current working directory, or %NULL to inherit parent's
25695  * @argv: (array zero-terminated=1): child's argument vector
25696  * @envp: (array zero-terminated=1) (allow-none): child's environment, or %NULL to inherit parent's
25697  * @flags: flags from #GSpawnFlags
25698  * @child_setup: (scope async) (allow-none): function to run in the child just before exec()
25699  * @user_data: (closure): user data for @child_setup
25700  * @child_pid: (out) (allow-none): return location for child process reference, or %NULL
25701  * @error: return location for error
25702  *
25703  * See g_spawn_async_with_pipes() for a full description; this function
25704  * simply calls the g_spawn_async_with_pipes() without any pipes.
25705  *
25706  * You should call g_spawn_close_pid() on the returned child process
25707  * reference when you don't need it any more.
25708  *
25709  * <note><para>
25710  * If you are writing a GTK+ application, and the program you
25711  * are spawning is a graphical application, too, then you may
25712  * want to use gdk_spawn_on_screen() instead to ensure that
25713  * the spawned program opens its windows on the right screen.
25714  * </para></note>
25715  *
25716  * <note><para> Note that the returned @child_pid on Windows is a
25717  * handle to the child process and not its identifier. Process handles
25718  * and process identifiers are different concepts on Windows.
25719  * </para></note>
25720  *
25721  * Returns: %TRUE on success, %FALSE if error is set
25722  */
25723
25724
25725 /**
25726  * g_spawn_async_with_pipes:
25727  * @working_directory: (allow-none): child's current working directory, or %NULL to inherit parent's, in the GLib file name encoding
25728  * @argv: (array zero-terminated=1): child's argument vector, in the GLib file name encoding
25729  * @envp: (array zero-terminated=1) (allow-none): child's environment, or %NULL to inherit parent's, in the GLib file name encoding
25730  * @flags: flags from #GSpawnFlags
25731  * @child_setup: (scope async) (allow-none): function to run in the child just before exec()
25732  * @user_data: (closure): user data for @child_setup
25733  * @child_pid: (out) (allow-none): return location for child process ID, or %NULL
25734  * @standard_input: (out) (allow-none): return location for file descriptor to write to child's stdin, or %NULL
25735  * @standard_output: (out) (allow-none): return location for file descriptor to read child's stdout, or %NULL
25736  * @standard_error: (out) (allow-none): return location for file descriptor to read child's stderr, or %NULL
25737  * @error: return location for error
25738  *
25739  * Executes a child program asynchronously (your program will not
25740  * block waiting for the child to exit). The child program is
25741  * specified by the only argument that must be provided, @argv. @argv
25742  * should be a %NULL-terminated array of strings, to be passed as the
25743  * argument vector for the child. The first string in @argv is of
25744  * course the name of the program to execute. By default, the name of
25745  * the program must be a full path. If @flags contains the
25746  * %G_SPAWN_SEARCH_PATH flag, the <envar>PATH</envar> environment variable
25747  * is used to search for the executable. If @flags contains the
25748  * %G_SPAWN_SEARCH_PATH_FROM_ENVP flag, the <envar>PATH</envar> variable from
25749  * @envp is used to search for the executable.
25750  * If both the %G_SPAWN_SEARCH_PATH and %G_SPAWN_SEARCH_PATH_FROM_ENVP
25751  * flags are set, the <envar>PATH</envar> variable from @envp takes precedence
25752  * over the environment variable.
25753  *
25754  * If the program name is not a full path and %G_SPAWN_SEARCH_PATH flag is not
25755  * used, then the program will be run from the current directory (or
25756  * @working_directory, if specified); this might be unexpected or even
25757  * dangerous in some cases when the current directory is world-writable.
25758  *
25759  * On Windows, note that all the string or string vector arguments to
25760  * this function and the other g_spawn*() functions are in UTF-8, the
25761  * GLib file name encoding. Unicode characters that are not part of
25762  * the system codepage passed in these arguments will be correctly
25763  * available in the spawned program only if it uses wide character API
25764  * to retrieve its command line. For C programs built with Microsoft's
25765  * tools it is enough to make the program have a wmain() instead of
25766  * main(). wmain() has a wide character argument vector as parameter.
25767  *
25768  * At least currently, mingw doesn't support wmain(), so if you use
25769  * mingw to develop the spawned program, it will have to call the
25770  * undocumented function __wgetmainargs() to get the wide character
25771  * argument vector and environment. See gspawn-win32-helper.c in the
25772  * GLib sources or init.c in the mingw runtime sources for a prototype
25773  * for that function. Alternatively, you can retrieve the Win32 system
25774  * level wide character command line passed to the spawned program
25775  * using the GetCommandLineW() function.
25776  *
25777  * On Windows the low-level child process creation API
25778  * <function>CreateProcess()</function> doesn't use argument vectors,
25779  * but a command line. The C runtime library's
25780  * <function>spawn*()</function> family of functions (which
25781  * g_spawn_async_with_pipes() eventually calls) paste the argument
25782  * vector elements together into a command line, and the C runtime startup code
25783  * does a corresponding reconstruction of an argument vector from the
25784  * command line, to be passed to main(). Complications arise when you have
25785  * argument vector elements that contain spaces of double quotes. The
25786  * <function>spawn*()</function> functions don't do any quoting or
25787  * escaping, but on the other hand the startup code does do unquoting
25788  * and unescaping in order to enable receiving arguments with embedded
25789  * spaces or double quotes. To work around this asymmetry,
25790  * g_spawn_async_with_pipes() will do quoting and escaping on argument
25791  * vector elements that need it before calling the C runtime
25792  * spawn() function.
25793  *
25794  * The returned @child_pid on Windows is a handle to the child
25795  * process, not its identifier. Process handles and process
25796  * identifiers are different concepts on Windows.
25797  *
25798  * @envp is a %NULL-terminated array of strings, where each string
25799  * has the form <literal>KEY=VALUE</literal>. This will become
25800  * the child's environment. If @envp is %NULL, the child inherits its
25801  * parent's environment.
25802  *
25803  * @flags should be the bitwise OR of any flags you want to affect the
25804  * function's behaviour. The %G_SPAWN_DO_NOT_REAP_CHILD means that the
25805  * child will not automatically be reaped; you must use a child watch to
25806  * be notified about the death of the child process. Eventually you must
25807  * call g_spawn_close_pid() on the @child_pid, in order to free
25808  * resources which may be associated with the child process. (On Unix,
25809  * using a child watch is equivalent to calling waitpid() or handling
25810  * the <literal>SIGCHLD</literal> signal manually. On Windows, calling g_spawn_close_pid()
25811  * is equivalent to calling CloseHandle() on the process handle returned
25812  * in @child_pid).  See g_child_watch_add().
25813  *
25814  * %G_SPAWN_LEAVE_DESCRIPTORS_OPEN means that the parent's open file
25815  * descriptors will be inherited by the child; otherwise all
25816  * descriptors except stdin/stdout/stderr will be closed before
25817  * calling exec() in the child. %G_SPAWN_SEARCH_PATH
25818  * means that <literal>argv[0]</literal> need not be an absolute path, it
25819  * will be looked for in the <envar>PATH</envar> environment variable.
25820  * %G_SPAWN_SEARCH_PATH_FROM_ENVP means need not be an absolute path, it
25821  * will be looked for in the <envar>PATH</envar> variable from @envp. If
25822  * both %G_SPAWN_SEARCH_PATH and %G_SPAWN_SEARCH_PATH_FROM_ENVP are used,
25823  * the value from @envp takes precedence over the environment.
25824  * %G_SPAWN_STDOUT_TO_DEV_NULL means that the child's standard output will
25825  * be discarded, instead of going to the same location as the parent's
25826  * standard output. If you use this flag, @standard_output must be %NULL.
25827  * %G_SPAWN_STDERR_TO_DEV_NULL means that the child's standard error
25828  * will be discarded, instead of going to the same location as the parent's
25829  * standard error. If you use this flag, @standard_error must be %NULL.
25830  * %G_SPAWN_CHILD_INHERITS_STDIN means that the child will inherit the parent's
25831  * standard input (by default, the child's standard input is attached to
25832  * /dev/null). If you use this flag, @standard_input must be %NULL.
25833  * %G_SPAWN_FILE_AND_ARGV_ZERO means that the first element of @argv is
25834  * the file to execute, while the remaining elements are the
25835  * actual argument vector to pass to the file. Normally
25836  * g_spawn_async_with_pipes() uses @argv[0] as the file to execute, and
25837  * passes all of @argv to the child.
25838  *
25839  * @child_setup and @user_data are a function and user data. On POSIX
25840  * platforms, the function is called in the child after GLib has
25841  * performed all the setup it plans to perform (including creating
25842  * pipes, closing file descriptors, etc.) but before calling
25843  * exec(). That is, @child_setup is called just
25844  * before calling exec() in the child. Obviously
25845  * actions taken in this function will only affect the child, not the
25846  * parent.
25847  *
25848  * On Windows, there is no separate fork() and exec()
25849  * functionality. Child processes are created and run with a single
25850  * API call, CreateProcess(). There is no sensible thing @child_setup
25851  * could be used for on Windows so it is ignored and not called.
25852  *
25853  * If non-%NULL, @child_pid will on Unix be filled with the child's
25854  * process ID. You can use the process ID to send signals to the
25855  * child, or to use g_child_watch_add() (or waitpid()) if you specified the
25856  * %G_SPAWN_DO_NOT_REAP_CHILD flag. On Windows, @child_pid will be
25857  * filled with a handle to the child process only if you specified the
25858  * %G_SPAWN_DO_NOT_REAP_CHILD flag. You can then access the child
25859  * process using the Win32 API, for example wait for its termination
25860  * with the <function>WaitFor*()</function> functions, or examine its
25861  * exit code with GetExitCodeProcess(). You should close the handle
25862  * with CloseHandle() or g_spawn_close_pid() when you no longer need it.
25863  *
25864  * If non-%NULL, the @standard_input, @standard_output, @standard_error
25865  * locations will be filled with file descriptors for writing to the child's
25866  * standard input or reading from its standard output or standard error.
25867  * The caller of g_spawn_async_with_pipes() must close these file descriptors
25868  * when they are no longer in use. If these parameters are %NULL, the corresponding
25869  * pipe won't be created.
25870  *
25871  * If @standard_input is NULL, the child's standard input is attached to
25872  * /dev/null unless %G_SPAWN_CHILD_INHERITS_STDIN is set.
25873  *
25874  * If @standard_error is NULL, the child's standard error goes to the same
25875  * location as the parent's standard error unless %G_SPAWN_STDERR_TO_DEV_NULL
25876  * is set.
25877  *
25878  * If @standard_output is NULL, the child's standard output goes to the same
25879  * location as the parent's standard output unless %G_SPAWN_STDOUT_TO_DEV_NULL
25880  * is set.
25881  *
25882  * @error can be %NULL to ignore errors, or non-%NULL to report errors.
25883  * If an error is set, the function returns %FALSE. Errors
25884  * are reported even if they occur in the child (for example if the
25885  * executable in <literal>argv[0]</literal> is not found). Typically
25886  * the <literal>message</literal> field of returned errors should be displayed
25887  * to users. Possible errors are those from the #G_SPAWN_ERROR domain.
25888  *
25889  * If an error occurs, @child_pid, @standard_input, @standard_output,
25890  * and @standard_error will not be filled with valid values.
25891  *
25892  * If @child_pid is not %NULL and an error does not occur then the returned
25893  * process reference must be closed using g_spawn_close_pid().
25894  *
25895  * <note><para>
25896  * If you are writing a GTK+ application, and the program you
25897  * are spawning is a graphical application, too, then you may
25898  * want to use gdk_spawn_on_screen_with_pipes() instead to ensure that
25899  * the spawned program opens its windows on the right screen.
25900  * </para></note>
25901  *
25902  * Returns: %TRUE on success, %FALSE if an error was set
25903  */
25904
25905
25906 /**
25907  * g_spawn_check_exit_status:
25908  * @exit_status: An exit code as returned from g_spawn_sync()
25909  * @error: a #GError
25910  *
25911  * Set @error if @exit_status indicates the child exited abnormally
25912  * (e.g. with a nonzero exit code, or via a fatal signal).
25913  *
25914  * The g_spawn_sync() and g_child_watch_add() family of APIs return an
25915  * exit status for subprocesses encoded in a platform-specific way.
25916  * On Unix, this is guaranteed to be in the same format
25917  * <literal>waitpid(2)</literal> returns, and on Windows it is
25918  * guaranteed to be the result of
25919  * <literal>GetExitCodeProcess()</literal>.  Prior to the introduction
25920  * of this function in GLib 2.34, interpreting @exit_status required
25921  * use of platform-specific APIs, which is problematic for software
25922  * using GLib as a cross-platform layer.
25923  *
25924  * Additionally, many programs simply want to determine whether or not
25925  * the child exited successfully, and either propagate a #GError or
25926  * print a message to standard error.  In that common case, this
25927  * function can be used.  Note that the error message in @error will
25928  * contain human-readable information about the exit status.
25929  *
25930  * The <literal>domain</literal> and <literal>code</literal> of @error
25931  * have special semantics in the case where the process has an "exit
25932  * code", as opposed to being killed by a signal.  On Unix, this
25933  * happens if <literal>WIFEXITED</literal> would be true of
25934  * @exit_status.  On Windows, it is always the case.
25935  *
25936  * The special semantics are that the actual exit code will be the
25937  * code set in @error, and the domain will be %G_SPAWN_EXIT_ERROR.
25938  * This allows you to differentiate between different exit codes.
25939  *
25940  * If the process was terminated by some means other than an exit
25941  * status, the domain will be %G_SPAWN_ERROR, and the code will be
25942  * %G_SPAWN_ERROR_FAILED.
25943  *
25944  * This function just offers convenience; you can of course also check
25945  * the available platform via a macro such as %G_OS_UNIX, and use
25946  * <literal>WIFEXITED()</literal> and <literal>WEXITSTATUS()</literal>
25947  * on @exit_status directly.  Do not attempt to scan or parse the
25948  * error message string; it may be translated and/or change in future
25949  * versions of GLib.
25950  *
25951  * Returns: %TRUE if child exited successfully, %FALSE otherwise (and @error will be set)
25952  * Since: 2.34
25953  */
25954
25955
25956 /**
25957  * g_spawn_close_pid:
25958  * @pid: The process reference to close
25959  *
25960  * On some platforms, notably Windows, the #GPid type represents a resource
25961  * which must be closed to prevent resource leaking. g_spawn_close_pid()
25962  * is provided for this purpose. It should be used on all platforms, even
25963  * though it doesn't do anything under UNIX.
25964  */
25965
25966
25967 /**
25968  * g_spawn_command_line_async:
25969  * @command_line: a command line
25970  * @error: return location for errors
25971  *
25972  * A simple version of g_spawn_async() that parses a command line with
25973  * g_shell_parse_argv() and passes it to g_spawn_async(). Runs a
25974  * command line in the background. Unlike g_spawn_async(), the
25975  * %G_SPAWN_SEARCH_PATH flag is enabled, other flags are not. Note
25976  * that %G_SPAWN_SEARCH_PATH can have security implications, so
25977  * consider using g_spawn_async() directly if appropriate. Possible
25978  * errors are those from g_shell_parse_argv() and g_spawn_async().
25979  *
25980  * The same concerns on Windows apply as for g_spawn_command_line_sync().
25981  *
25982  * Returns: %TRUE on success, %FALSE if error is set.
25983  */
25984
25985
25986 /**
25987  * g_spawn_command_line_sync:
25988  * @command_line: a command line
25989  * @standard_output: (out) (array zero-terminated=1) (element-type guint8) (allow-none): return location for child output
25990  * @standard_error: (out) (array zero-terminated=1) (element-type guint8) (allow-none): return location for child errors
25991  * @exit_status: (out) (allow-none): return location for child exit status, as returned by waitpid()
25992  * @error: return location for errors
25993  *
25994  * A simple version of g_spawn_sync() with little-used parameters
25995  * removed, taking a command line instead of an argument vector.  See
25996  * g_spawn_sync() for full details. @command_line will be parsed by
25997  * g_shell_parse_argv(). Unlike g_spawn_sync(), the %G_SPAWN_SEARCH_PATH flag
25998  * is enabled. Note that %G_SPAWN_SEARCH_PATH can have security
25999  * implications, so consider using g_spawn_sync() directly if
26000  * appropriate. Possible errors are those from g_spawn_sync() and those
26001  * from g_shell_parse_argv().
26002  *
26003  * If @exit_status is non-%NULL, the platform-specific exit status of
26004  * the child is stored there; see the documentation of
26005  * g_spawn_check_exit_status() for how to use and interpret this.
26006  *
26007  * On Windows, please note the implications of g_shell_parse_argv()
26008  * parsing @command_line. Parsing is done according to Unix shell rules, not
26009  * Windows command interpreter rules.
26010  * Space is a separator, and backslashes are
26011  * special. Thus you cannot simply pass a @command_line containing
26012  * canonical Windows paths, like "c:\\program files\\app\\app.exe", as
26013  * the backslashes will be eaten, and the space will act as a
26014  * separator. You need to enclose such paths with single quotes, like
26015  * "'c:\\program files\\app\\app.exe' 'e:\\folder\\argument.txt'".
26016  *
26017  * Returns: %TRUE on success, %FALSE if an error was set
26018  */
26019
26020
26021 /**
26022  * g_spawn_sync:
26023  * @working_directory: (allow-none): child's current working directory, or %NULL to inherit parent's
26024  * @argv: (array zero-terminated=1): child's argument vector
26025  * @envp: (array zero-terminated=1) (allow-none): child's environment, or %NULL to inherit parent's
26026  * @flags: flags from #GSpawnFlags
26027  * @child_setup: (scope async) (allow-none): function to run in the child just before exec()
26028  * @user_data: (closure): user data for @child_setup
26029  * @standard_output: (out) (array zero-terminated=1) (element-type guint8) (allow-none): return location for child output, or %NULL
26030  * @standard_error: (out) (array zero-terminated=1) (element-type guint8) (allow-none): return location for child error messages, or %NULL
26031  * @exit_status: (out) (allow-none): return location for child exit status, as returned by waitpid(), or %NULL
26032  * @error: return location for error, or %NULL
26033  *
26034  * Executes a child synchronously (waits for the child to exit before returning).
26035  * All output from the child is stored in @standard_output and @standard_error,
26036  * if those parameters are non-%NULL. Note that you must set the
26037  * %G_SPAWN_STDOUT_TO_DEV_NULL and %G_SPAWN_STDERR_TO_DEV_NULL flags when
26038  * passing %NULL for @standard_output and @standard_error.
26039  *
26040  * If @exit_status is non-%NULL, the platform-specific exit status of
26041  * the child is stored there; see the documentation of
26042  * g_spawn_check_exit_status() for how to use and interpret this.
26043  * Note that it is invalid to pass %G_SPAWN_DO_NOT_REAP_CHILD in
26044  * @flags.
26045  *
26046  * If an error occurs, no data is returned in @standard_output,
26047  * @standard_error, or @exit_status.
26048  *
26049  * This function calls g_spawn_async_with_pipes() internally; see that
26050  * function for full details on the other parameters and details on
26051  * how these functions work on Windows.
26052  *
26053  * Returns: %TRUE on success, %FALSE if an error was set.
26054  */
26055
26056
26057 /**
26058  * g_sprintf:
26059  * @string: A pointer to a memory buffer to contain the resulting string. It is up to the caller to ensure that the allocated buffer is large enough to hold the formatted result
26060  * @format: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
26061  * @...: the arguments to insert in the output.
26062  *
26063  * An implementation of the standard sprintf() function which supports
26064  * positional parameters, as specified in the Single Unix Specification.
26065  *
26066  * Note that it is usually better to use g_snprintf(), to avoid the
26067  * risk of buffer overflow.
26068  *
26069  * See also g_strdup_printf().
26070  *
26071  * Returns: the number of bytes printed.
26072  * Since: 2.2
26073  */
26074
26075
26076 /**
26077  * g_stat:
26078  * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
26079  * @buf: a pointer to a <structname>stat</structname> struct, which will be filled with the file information
26080  *
26081  * A wrapper for the POSIX stat() function. The stat() function
26082  * returns information about a file. On Windows the stat() function in
26083  * the C library checks only the FAT-style READONLY attribute and does
26084  * not look at the ACL at all. Thus on Windows the protection bits in
26085  * the st_mode field are a fabrication of little use.
26086  *
26087  * On Windows the Microsoft C libraries have several variants of the
26088  * <structname>stat</structname> struct and stat() function with names
26089  * like "_stat", "_stat32", "_stat32i64" and "_stat64i32". The one
26090  * used here is for 32-bit code the one with 32-bit size and time
26091  * fields, specifically called "_stat32".
26092  *
26093  * In Microsoft's compiler, by default "struct stat" means one with
26094  * 64-bit time fields while in MinGW "struct stat" is the legacy one
26095  * with 32-bit fields. To hopefully clear up this messs, the gstdio.h
26096  * header defines a type GStatBuf which is the appropriate struct type
26097  * depending on the platform and/or compiler being used. On POSIX it
26098  * is just "struct stat", but note that even on POSIX platforms,
26099  * "stat" might be a macro.
26100  *
26101  * See your C library manual for more details about stat().
26102  *
26103  * Returns: 0 if the information was successfully retrieved, -1 if an error occurred
26104  * Since: 2.6
26105  */
26106
26107
26108 /**
26109  * g_stpcpy:
26110  * @dest: destination buffer.
26111  * @src: source string.
26112  *
26113  * Copies a nul-terminated string into the dest buffer, include the
26114  * trailing nul, and return a pointer to the trailing nul byte.
26115  * This is useful for concatenating multiple strings together
26116  * without having to repeatedly scan for the end.
26117  *
26118  * Returns: a pointer to trailing nul byte.
26119  */
26120
26121
26122 /**
26123  * g_str_equal:
26124  * @v1: a key
26125  * @v2: a key to compare with @v1
26126  *
26127  * Compares two strings for byte-by-byte equality and returns %TRUE
26128  * if they are equal. It can be passed to g_hash_table_new() as the
26129  * @key_equal_func parameter, when using non-%NULL strings as keys in a
26130  * #GHashTable.
26131  *
26132  * Note that this function is primarily meant as a hash table comparison
26133  * function. For a general-purpose, %NULL-safe string comparison function,
26134  * see g_strcmp0().
26135  *
26136  * Returns: %TRUE if the two keys match
26137  */
26138
26139
26140 /**
26141  * g_str_has_prefix:
26142  * @str: a nul-terminated string
26143  * @prefix: the nul-terminated prefix to look for
26144  *
26145  * Looks whether the string @str begins with @prefix.
26146  *
26147  * Returns: %TRUE if @str begins with @prefix, %FALSE otherwise.
26148  * Since: 2.2
26149  */
26150
26151
26152 /**
26153  * g_str_has_suffix:
26154  * @str: a nul-terminated string
26155  * @suffix: the nul-terminated suffix to look for
26156  *
26157  * Looks whether the string @str ends with @suffix.
26158  *
26159  * Returns: %TRUE if @str end with @suffix, %FALSE otherwise.
26160  * Since: 2.2
26161  */
26162
26163
26164 /**
26165  * g_str_hash:
26166  * @v: a string key
26167  *
26168  * Converts a string to a hash value.
26169  *
26170  * This function implements the widely used "djb" hash apparently posted
26171  * by Daniel Bernstein to comp.lang.c some time ago.  The 32 bit
26172  * unsigned hash value starts at 5381 and for each byte 'c' in the
26173  * string, is updated: <literal>hash = hash * 33 + c</literal>.  This
26174  * function uses the signed value of each byte.
26175  *
26176  * It can be passed to g_hash_table_new() as the @hash_func parameter,
26177  * when using non-%NULL strings as keys in a #GHashTable.
26178  *
26179  * Returns: a hash value corresponding to the key
26180  */
26181
26182
26183 /**
26184  * g_strcanon:
26185  * @string: a nul-terminated array of bytes
26186  * @valid_chars: bytes permitted in @string
26187  * @substitutor: replacement character for disallowed bytes
26188  *
26189  * For each character in @string, if the character is not in
26190  * @valid_chars, replaces the character with @substitutor.
26191  * Modifies @string in place, and return @string itself, not
26192  * a copy. The return value is to allow nesting such as
26193  * |[
26194  *   g_ascii_strup (g_strcanon (str, "abc", '?'))
26195  * ]|
26196  *
26197  * Returns: @string
26198  */
26199
26200
26201 /**
26202  * g_strcasecmp:
26203  * @s1: a string.
26204  * @s2: a string to compare with @s1.
26205  *
26206  * A case-insensitive string comparison, corresponding to the standard
26207  * strcasecmp() function on platforms which support it.
26208  *
26209  * Returns: 0 if the strings match, a negative value if @s1 &lt; @s2, or a positive value if @s1 &gt; @s2.
26210  * Deprecated: 2.2: See g_strncasecmp() for a discussion of why this function is deprecated and how to replace it.
26211  */
26212
26213
26214 /**
26215  * g_strchomp:
26216  * @string: a string to remove the trailing whitespace from
26217  *
26218  * Removes trailing whitespace from a string.
26219  *
26220  * This function doesn't allocate or reallocate any memory;
26221  * it modifies @string in place. The pointer to @string is
26222  * returned to allow the nesting of functions.
26223  *
26224  * Also see g_strchug() and g_strstrip().
26225  *
26226  * Returns: @string.
26227  */
26228
26229
26230 /**
26231  * g_strchug:
26232  * @string: a string to remove the leading whitespace from
26233  *
26234  * Removes leading whitespace from a string, by moving the rest
26235  * of the characters forward.
26236  *
26237  * This function doesn't allocate or reallocate any memory;
26238  * it modifies @string in place. The pointer to @string is
26239  * returned to allow the nesting of functions.
26240  *
26241  * Also see g_strchomp() and g_strstrip().
26242  *
26243  * Returns: @string
26244  */
26245
26246
26247 /**
26248  * g_strcmp0:
26249  * @str1: (allow-none): a C string or %NULL
26250  * @str2: (allow-none): another C string or %NULL
26251  *
26252  * Compares @str1 and @str2 like strcmp(). Handles %NULL
26253  * gracefully by sorting it before non-%NULL strings.
26254  * Comparing two %NULL pointers returns 0.
26255  *
26256  * Returns: an integer less than, equal to, or greater than zero, if @str1 is <, == or > than @str2.
26257  * Since: 2.16
26258  */
26259
26260
26261 /**
26262  * g_strcompress:
26263  * @source: a string to compress
26264  *
26265  * Replaces all escaped characters with their one byte equivalent.
26266  *
26267  * This function does the reverse conversion of g_strescape().
26268  *
26269  * Returns: a newly-allocated copy of @source with all escaped character compressed
26270  */
26271
26272
26273 /**
26274  * g_strconcat:
26275  * @string1: the first string to add, which must not be %NULL
26276  * @...: a %NULL-terminated list of strings to append to the string
26277  *
26278  * Concatenates all of the given strings into one long string.
26279  * The returned string should be freed with g_free() when no longer needed.
26280  *
26281  * Note that this function is usually not the right function to use to
26282  * assemble a translated message from pieces, since proper translation
26283  * often requires the pieces to be reordered.
26284  *
26285  * <warning><para>The variable argument list <emphasis>must</emphasis> end
26286  * with %NULL. If you forget the %NULL, g_strconcat() will start appending
26287  * random memory junk to your string.</para></warning>
26288  *
26289  * Returns: a newly-allocated string containing all the string arguments
26290  */
26291
26292
26293 /**
26294  * g_strdelimit:
26295  * @string: the string to convert
26296  * @delimiters: (allow-none): a string containing the current delimiters, or %NULL to use the standard delimiters defined in #G_STR_DELIMITERS
26297  * @new_delimiter: the new delimiter character
26298  *
26299  * Converts any delimiter characters in @string to @new_delimiter.
26300  * Any characters in @string which are found in @delimiters are
26301  * changed to the @new_delimiter character. Modifies @string in place,
26302  * and returns @string itself, not a copy. The return value is to
26303  * allow nesting such as
26304  * |[
26305  *   g_ascii_strup (g_strdelimit (str, "abc", '?'))
26306  * ]|
26307  *
26308  * Returns: @string
26309  */
26310
26311
26312 /**
26313  * g_strdown:
26314  * @string: the string to convert.
26315  *
26316  * Converts a string to lower case.
26317  *
26318  * Returns: the string
26319  * Deprecated: 2.2: This function is totally broken for the reasons discussed in the g_strncasecmp() docs - use g_ascii_strdown() or g_utf8_strdown() instead.
26320  */
26321
26322
26323 /**
26324  * g_strdup:
26325  * @str: the string to duplicate
26326  *
26327  * Duplicates a string. If @str is %NULL it returns %NULL.
26328  * The returned string should be freed with g_free()
26329  * when no longer needed.
26330  *
26331  * Returns: a newly-allocated copy of @str
26332  */
26333
26334
26335 /**
26336  * g_strdup_printf:
26337  * @format: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>
26338  * @...: the parameters to insert into the format string
26339  *
26340  * Similar to the standard C sprintf() function but safer, since it
26341  * calculates the maximum space required and allocates memory to hold
26342  * the result. The returned string should be freed with g_free() when no
26343  * longer needed.
26344  *
26345  * Returns: a newly-allocated string holding the result
26346  */
26347
26348
26349 /**
26350  * g_strdup_vprintf:
26351  * @format: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>
26352  * @args: the list of parameters to insert into the format string
26353  *
26354  * Similar to the standard C vsprintf() function but safer, since it
26355  * calculates the maximum space required and allocates memory to hold
26356  * the result. The returned string should be freed with g_free() when
26357  * no longer needed.
26358  *
26359  * See also g_vasprintf(), which offers the same functionality, but
26360  * additionally returns the length of the allocated string.
26361  *
26362  * Returns: a newly-allocated string holding the result
26363  */
26364
26365
26366 /**
26367  * g_strdupv:
26368  * @str_array: a %NULL-terminated array of strings
26369  *
26370  * Copies %NULL-terminated array of strings. The copy is a deep copy;
26371  * the new array should be freed by first freeing each string, then
26372  * the array itself. g_strfreev() does this for you. If called
26373  * on a %NULL value, g_strdupv() simply returns %NULL.
26374  *
26375  * Returns: a new %NULL-terminated array of strings.
26376  */
26377
26378
26379 /**
26380  * g_strerror:
26381  * @errnum: the system error number. See the standard C %errno documentation
26382  *
26383  * Returns a string corresponding to the given error code, e.g.
26384  * "no such process". You should use this function in preference to
26385  * strerror(), because it returns a string in UTF-8 encoding, and since
26386  * not all platforms support the strerror() function.
26387  *
26388  * Returns: a UTF-8 string describing the error code. If the error code is unknown, it returns "unknown error (&lt;code&gt;)".
26389  */
26390
26391
26392 /**
26393  * g_strescape:
26394  * @source: a string to escape
26395  * @exceptions: a string of characters not to escape in @source
26396  *
26397  * Escapes the special characters '\b', '\f', '\n', '\r', '\t', '\v', '\'
26398  * and '&quot;' in the string @source by inserting a '\' before
26399  * them. Additionally all characters in the range 0x01-0x1F (everything
26400  * below SPACE) and in the range 0x7F-0xFF (all non-ASCII chars) are
26401  * replaced with a '\' followed by their octal representation.
26402  * Characters supplied in @exceptions are not escaped.
26403  *
26404  * g_strcompress() does the reverse conversion.
26405  *
26406  * Returns: a newly-allocated copy of @source with certain characters escaped. See above.
26407  */
26408
26409
26410 /**
26411  * g_strfreev:
26412  * @str_array: a %NULL-terminated array of strings to free
26413  *
26414  * Frees a %NULL-terminated array of strings, and the array itself.
26415  * If called on a %NULL value, g_strfreev() simply returns.
26416  */
26417
26418
26419 /**
26420  * g_string_append:
26421  * @string: a #GString
26422  * @val: the string to append onto the end of @string
26423  *
26424  * Adds a string onto the end of a #GString, expanding
26425  * it if necessary.
26426  *
26427  * Returns: @string
26428  */
26429
26430
26431 /**
26432  * g_string_append_c:
26433  * @string: a #GString
26434  * @c: the byte to append onto the end of @string
26435  *
26436  * Adds a byte onto the end of a #GString, expanding
26437  * it if necessary.
26438  *
26439  * Returns: @string
26440  */
26441
26442
26443 /**
26444  * g_string_append_len:
26445  * @string: a #GString
26446  * @val: bytes to append
26447  * @len: number of bytes of @val to use
26448  *
26449  * Appends @len bytes of @val to @string. Because @len is
26450  * provided, @val may contain embedded nuls and need not
26451  * be nul-terminated.
26452  *
26453  * Since this function does not stop at nul bytes, it is
26454  * the caller's responsibility to ensure that @val has at
26455  * least @len addressable bytes.
26456  *
26457  * Returns: @string
26458  */
26459
26460
26461 /**
26462  * g_string_append_printf:
26463  * @string: a #GString
26464  * @format: the string format. See the printf() documentation
26465  * @...: the parameters to insert into the format string
26466  *
26467  * Appends a formatted string onto the end of a #GString.
26468  * This function is similar to g_string_printf() except
26469  * that the text is appended to the #GString.
26470  */
26471
26472
26473 /**
26474  * g_string_append_unichar:
26475  * @string: a #GString
26476  * @wc: a Unicode character
26477  *
26478  * Converts a Unicode character into UTF-8, and appends it
26479  * to the string.
26480  *
26481  * Returns: @string
26482  */
26483
26484
26485 /**
26486  * g_string_append_uri_escaped:
26487  * @string: a #GString
26488  * @unescaped: a string
26489  * @reserved_chars_allowed: a string of reserved characters allowed to be used, or %NULL
26490  * @allow_utf8: set %TRUE if the escaped string may include UTF8 characters
26491  *
26492  * Appends @unescaped to @string, escaped any characters that
26493  * are reserved in URIs using URI-style escape sequences.
26494  *
26495  * Returns: @string
26496  * Since: 2.16
26497  */
26498
26499
26500 /**
26501  * g_string_append_vprintf:
26502  * @string: a #GString
26503  * @format: the string format. See the printf() documentation
26504  * @args: the list of arguments to insert in the output
26505  *
26506  * Appends a formatted string onto the end of a #GString.
26507  * This function is similar to g_string_append_printf()
26508  * except that the arguments to the format string are passed
26509  * as a va_list.
26510  *
26511  * Since: 2.14
26512  */
26513
26514
26515 /**
26516  * g_string_ascii_down:
26517  * @string: a GString
26518  *
26519  * Converts all uppercase ASCII letters to lowercase ASCII letters.
26520  *
26521  * Returns: passed-in @string pointer, with all the uppercase characters converted to lowercase in place, with semantics that exactly match g_ascii_tolower().
26522  */
26523
26524
26525 /**
26526  * g_string_ascii_up:
26527  * @string: a GString
26528  *
26529  * Converts all lowercase ASCII letters to uppercase ASCII letters.
26530  *
26531  * Returns: passed-in @string pointer, with all the lowercase characters converted to uppercase in place, with semantics that exactly match g_ascii_toupper().
26532  */
26533
26534
26535 /**
26536  * g_string_assign:
26537  * @string: the destination #GString. Its current contents are destroyed.
26538  * @rval: the string to copy into @string
26539  *
26540  * Copies the bytes from a string into a #GString,
26541  * destroying any previous contents. It is rather like
26542  * the standard strcpy() function, except that you do not
26543  * have to worry about having enough space to copy the string.
26544  *
26545  * Returns: @string
26546  */
26547
26548
26549 /**
26550  * g_string_chunk_clear:
26551  * @chunk: a #GStringChunk
26552  *
26553  * Frees all strings contained within the #GStringChunk.
26554  * After calling g_string_chunk_clear() it is not safe to
26555  * access any of the strings which were contained within it.
26556  *
26557  * Since: 2.14
26558  */
26559
26560
26561 /**
26562  * g_string_chunk_free:
26563  * @chunk: a #GStringChunk
26564  *
26565  * Frees all memory allocated by the #GStringChunk.
26566  * After calling g_string_chunk_free() it is not safe to
26567  * access any of the strings which were contained within it.
26568  */
26569
26570
26571 /**
26572  * g_string_chunk_insert:
26573  * @chunk: a #GStringChunk
26574  * @string: the string to add
26575  *
26576  * Adds a copy of @string to the #GStringChunk.
26577  * It returns a pointer to the new copy of the string
26578  * in the #GStringChunk. The characters in the string
26579  * can be changed, if necessary, though you should not
26580  * change anything after the end of the string.
26581  *
26582  * Unlike g_string_chunk_insert_const(), this function
26583  * does not check for duplicates. Also strings added
26584  * with g_string_chunk_insert() will not be searched
26585  * by g_string_chunk_insert_const() when looking for
26586  * duplicates.
26587  *
26588  * Returns: a pointer to the copy of @string within the #GStringChunk
26589  */
26590
26591
26592 /**
26593  * g_string_chunk_insert_const:
26594  * @chunk: a #GStringChunk
26595  * @string: the string to add
26596  *
26597  * Adds a copy of @string to the #GStringChunk, unless the same
26598  * string has already been added to the #GStringChunk with
26599  * g_string_chunk_insert_const().
26600  *
26601  * This function is useful if you need to copy a large number
26602  * of strings but do not want to waste space storing duplicates.
26603  * But you must remember that there may be several pointers to
26604  * the same string, and so any changes made to the strings
26605  * should be done very carefully.
26606  *
26607  * Note that g_string_chunk_insert_const() will not return a
26608  * pointer to a string added with g_string_chunk_insert(), even
26609  * if they do match.
26610  *
26611  * Returns: a pointer to the new or existing copy of @string within the #GStringChunk
26612  */
26613
26614
26615 /**
26616  * g_string_chunk_insert_len:
26617  * @chunk: a #GStringChunk
26618  * @string: bytes to insert
26619  * @len: number of bytes of @string to insert, or -1 to insert a nul-terminated string
26620  *
26621  * Adds a copy of the first @len bytes of @string to the #GStringChunk.
26622  * The copy is nul-terminated.
26623  *
26624  * Since this function does not stop at nul bytes, it is the caller's
26625  * responsibility to ensure that @string has at least @len addressable
26626  * bytes.
26627  *
26628  * The characters in the returned string can be changed, if necessary,
26629  * though you should not change anything after the end of the string.
26630  *
26631  * Returns: a pointer to the copy of @string within the #GStringChunk
26632  * Since: 2.4
26633  */
26634
26635
26636 /**
26637  * g_string_chunk_new:
26638  * @size: the default size of the blocks of memory which are allocated to store the strings. If a particular string is larger than this default size, a larger block of memory will be allocated for it.
26639  *
26640  * Creates a new #GStringChunk.
26641  *
26642  * Returns: a new #GStringChunk
26643  */
26644
26645
26646 /**
26647  * g_string_down:
26648  * @string: a #GString
26649  *
26650  * Converts a #GString to lowercase.
26651  *
26652  * Returns: the #GString
26653  * Deprecated: 2.2: This function uses the locale-specific tolower() function, which is almost never the right thing. Use g_string_ascii_down() or g_utf8_strdown() instead.
26654  */
26655
26656
26657 /**
26658  * g_string_equal:
26659  * @v: a #GString
26660  * @v2: another #GString
26661  *
26662  * Compares two strings for equality, returning %TRUE if they are equal.
26663  * For use with #GHashTable.
26664  *
26665  * Returns: %TRUE if the strings are the same length and contain the same bytes
26666  */
26667
26668
26669 /**
26670  * g_string_erase:
26671  * @string: a #GString
26672  * @pos: the position of the content to remove
26673  * @len: the number of bytes to remove, or -1 to remove all following bytes
26674  *
26675  * Removes @len bytes from a #GString, starting at position @pos.
26676  * The rest of the #GString is shifted down to fill the gap.
26677  *
26678  * Returns: @string
26679  */
26680
26681
26682 /**
26683  * g_string_free:
26684  * @string: a #GString
26685  * @free_segment: if %TRUE, the actual character data is freed as well
26686  *
26687  * Frees the memory allocated for the #GString.
26688  * If @free_segment is %TRUE it also frees the character data.  If
26689  * it's %FALSE, the caller gains ownership of the buffer and must
26690  * free it after use with g_free().
26691  *
26692  * Returns: the character data of @string (i.e. %NULL if @free_segment is %TRUE)
26693  */
26694
26695
26696 /**
26697  * g_string_free_to_bytes:
26698  * @string: (transfer full): a #GString
26699  *
26700  * Transfers ownership of the contents of @string to a newly allocated
26701  * #GBytes.  The #GString structure itself is deallocated, and it is
26702  * therefore invalid to use @string after invoking this function.
26703  *
26704  * Note that while #GString ensures that its buffer always has a
26705  * trailing nul character (not reflected in its "len"), the returned
26706  * #GBytes does not include this extra nul; i.e. it has length exactly
26707  * equal to the "len" member.
26708  *
26709  * Returns: A newly allocated #GBytes containing contents of @string; @string itself is freed
26710  * Since: 2.34
26711  */
26712
26713
26714 /**
26715  * g_string_hash:
26716  * @str: a string to hash
26717  *
26718  * Creates a hash code for @str; for use with #GHashTable.
26719  *
26720  * Returns: hash code for @str
26721  */
26722
26723
26724 /**
26725  * g_string_insert:
26726  * @string: a #GString
26727  * @pos: the position to insert the copy of the string
26728  * @val: the string to insert
26729  *
26730  * Inserts a copy of a string into a #GString,
26731  * expanding it if necessary.
26732  *
26733  * Returns: @string
26734  */
26735
26736
26737 /**
26738  * g_string_insert_c:
26739  * @string: a #GString
26740  * @pos: the position to insert the byte
26741  * @c: the byte to insert
26742  *
26743  * Inserts a byte into a #GString, expanding it if necessary.
26744  *
26745  * Returns: @string
26746  */
26747
26748
26749 /**
26750  * g_string_insert_len:
26751  * @string: a #GString
26752  * @pos: position in @string where insertion should happen, or -1 for at the end
26753  * @val: bytes to insert
26754  * @len: number of bytes of @val to insert
26755  *
26756  * Inserts @len bytes of @val into @string at @pos.
26757  * Because @len is provided, @val may contain embedded
26758  * nuls and need not be nul-terminated. If @pos is -1,
26759  * bytes are inserted at the end of the string.
26760  *
26761  * Since this function does not stop at nul bytes, it is
26762  * the caller's responsibility to ensure that @val has at
26763  * least @len addressable bytes.
26764  *
26765  * Returns: @string
26766  */
26767
26768
26769 /**
26770  * g_string_insert_unichar:
26771  * @string: a #GString
26772  * @pos: the position at which to insert character, or -1 to append at the end of the string
26773  * @wc: a Unicode character
26774  *
26775  * Converts a Unicode character into UTF-8, and insert it
26776  * into the string at the given position.
26777  *
26778  * Returns: @string
26779  */
26780
26781
26782 /**
26783  * g_string_new:
26784  * @init: the initial text to copy into the string
26785  *
26786  * Creates a new #GString, initialized with the given string.
26787  *
26788  * Returns: the new #GString
26789  */
26790
26791
26792 /**
26793  * g_string_new_len:
26794  * @init: initial contents of the string
26795  * @len: length of @init to use
26796  *
26797  * Creates a new #GString with @len bytes of the @init buffer.
26798  * Because a length is provided, @init need not be nul-terminated,
26799  * and can contain embedded nul bytes.
26800  *
26801  * Since this function does not stop at nul bytes, it is the caller's
26802  * responsibility to ensure that @init has at least @len addressable
26803  * bytes.
26804  *
26805  * Returns: a new #GString
26806  */
26807
26808
26809 /**
26810  * g_string_overwrite:
26811  * @string: a #GString
26812  * @pos: the position at which to start overwriting
26813  * @val: the string that will overwrite the @string starting at @pos
26814  *
26815  * Overwrites part of a string, lengthening it if necessary.
26816  *
26817  * Returns: @string
26818  * Since: 2.14
26819  */
26820
26821
26822 /**
26823  * g_string_overwrite_len:
26824  * @string: a #GString
26825  * @pos: the position at which to start overwriting
26826  * @val: the string that will overwrite the @string starting at @pos
26827  * @len: the number of bytes to write from @val
26828  *
26829  * Overwrites part of a string, lengthening it if necessary.
26830  * This function will work with embedded nuls.
26831  *
26832  * Returns: @string
26833  * Since: 2.14
26834  */
26835
26836
26837 /**
26838  * g_string_prepend:
26839  * @string: a #GString
26840  * @val: the string to prepend on the start of @string
26841  *
26842  * Adds a string on to the start of a #GString,
26843  * expanding it if necessary.
26844  *
26845  * Returns: @string
26846  */
26847
26848
26849 /**
26850  * g_string_prepend_c:
26851  * @string: a #GString
26852  * @c: the byte to prepend on the start of the #GString
26853  *
26854  * Adds a byte onto the start of a #GString,
26855  * expanding it if necessary.
26856  *
26857  * Returns: @string
26858  */
26859
26860
26861 /**
26862  * g_string_prepend_len:
26863  * @string: a #GString
26864  * @val: bytes to prepend
26865  * @len: number of bytes in @val to prepend
26866  *
26867  * Prepends @len bytes of @val to @string.
26868  * Because @len is provided, @val may contain
26869  * embedded nuls and need not be nul-terminated.
26870  *
26871  * Since this function does not stop at nul bytes,
26872  * it is the caller's responsibility to ensure that
26873  * @val has at least @len addressable bytes.
26874  *
26875  * Returns: @string
26876  */
26877
26878
26879 /**
26880  * g_string_prepend_unichar:
26881  * @string: a #GString
26882  * @wc: a Unicode character
26883  *
26884  * Converts a Unicode character into UTF-8, and prepends it
26885  * to the string.
26886  *
26887  * Returns: @string
26888  */
26889
26890
26891 /**
26892  * g_string_printf:
26893  * @string: a #GString
26894  * @format: the string format. See the printf() documentation
26895  * @...: the parameters to insert into the format string
26896  *
26897  * Writes a formatted string into a #GString.
26898  * This is similar to the standard sprintf() function,
26899  * except that the #GString buffer automatically expands
26900  * to contain the results. The previous contents of the
26901  * #GString are destroyed.
26902  */
26903
26904
26905 /**
26906  * g_string_set_size:
26907  * @string: a #GString
26908  * @len: the new length
26909  *
26910  * Sets the length of a #GString. If the length is less than
26911  * the current length, the string will be truncated. If the
26912  * length is greater than the current length, the contents
26913  * of the newly added area are undefined. (However, as
26914  * always, string->str[string->len] will be a nul byte.)
26915  *
26916  * Returns: @string
26917  */
26918
26919
26920 /**
26921  * g_string_sized_new:
26922  * @dfl_size: the default size of the space allocated to hold the string
26923  *
26924  * Creates a new #GString, with enough space for @dfl_size
26925  * bytes. This is useful if you are going to add a lot of
26926  * text to the string and don't want it to be reallocated
26927  * too often.
26928  *
26929  * Returns: the new #GString
26930  */
26931
26932
26933 /**
26934  * g_string_sprintf:
26935  * @string: a #GString
26936  * @format: the string format. See the sprintf() documentation
26937  * @...: the parameters to insert into the format string
26938  *
26939  * Writes a formatted string into a #GString.
26940  * This is similar to the standard sprintf() function,
26941  * except that the #GString buffer automatically expands
26942  * to contain the results. The previous contents of the
26943  * #GString are destroyed.
26944  *
26945  * Deprecated: This function has been renamed to g_string_printf().
26946  */
26947
26948
26949 /**
26950  * g_string_sprintfa:
26951  * @string: a #GString
26952  * @format: the string format. See the sprintf() documentation
26953  * @...: the parameters to insert into the format string
26954  *
26955  * Appends a formatted string onto the end of a #GString.
26956  * This function is similar to g_string_sprintf() except that
26957  * the text is appended to the #GString.
26958  *
26959  * Deprecated: This function has been renamed to g_string_append_printf()
26960  */
26961
26962
26963 /**
26964  * g_string_truncate:
26965  * @string: a #GString
26966  * @len: the new size of @string
26967  *
26968  * Cuts off the end of the GString, leaving the first @len bytes.
26969  *
26970  * Returns: @string
26971  */
26972
26973
26974 /**
26975  * g_string_up:
26976  * @string: a #GString
26977  *
26978  * Converts a #GString to uppercase.
26979  *
26980  * Returns: @string
26981  * Deprecated: 2.2: This function uses the locale-specific toupper() function, which is almost never the right thing. Use g_string_ascii_up() or g_utf8_strup() instead.
26982  */
26983
26984
26985 /**
26986  * g_string_vprintf:
26987  * @string: a #GString
26988  * @format: the string format. See the printf() documentation
26989  * @args: the parameters to insert into the format string
26990  *
26991  * Writes a formatted string into a #GString.
26992  * This function is similar to g_string_printf() except that
26993  * the arguments to the format string are passed as a va_list.
26994  *
26995  * Since: 2.14
26996  */
26997
26998
26999 /**
27000  * g_strip_context:
27001  * @msgid: a string
27002  * @msgval: another string
27003  *
27004  * An auxiliary function for gettext() support (see Q_()).
27005  *
27006  * Returns: @msgval, unless @msgval is identical to @msgid and contains a '|' character, in which case a pointer to the substring of msgid after the first '|' character is returned.
27007  * Since: 2.4
27008  */
27009
27010
27011 /**
27012  * g_strjoin:
27013  * @separator: (allow-none): a string to insert between each of the strings, or %NULL
27014  * @...: a %NULL-terminated list of strings to join
27015  *
27016  * Joins a number of strings together to form one long string, with the
27017  * optional @separator inserted between each of them. The returned string
27018  * should be freed with g_free().
27019  *
27020  * Returns: a newly-allocated string containing all of the strings joined together, with @separator between them
27021  */
27022
27023
27024 /**
27025  * g_strjoinv:
27026  * @separator: (allow-none): a string to insert between each of the strings, or %NULL
27027  * @str_array: a %NULL-terminated array of strings to join
27028  *
27029  * Joins a number of strings together to form one long string, with the
27030  * optional @separator inserted between each of them. The returned string
27031  * should be freed with g_free().
27032  *
27033  * Returns: a newly-allocated string containing all of the strings joined together, with @separator between them
27034  */
27035
27036
27037 /**
27038  * g_strlcat:
27039  * @dest: destination buffer, already containing one nul-terminated string
27040  * @src: source buffer
27041  * @dest_size: length of @dest buffer in bytes (not length of existing string inside @dest)
27042  *
27043  * Portability wrapper that calls strlcat() on systems which have it,
27044  * and emulates it otherwise. Appends nul-terminated @src string to @dest,
27045  * guaranteeing nul-termination for @dest. The total size of @dest won't
27046  * exceed @dest_size.
27047  *
27048  * At most dest_size - 1 characters will be copied.
27049  * Unlike strncat, dest_size is the full size of dest, not the space left over.
27050  * This function does NOT allocate memory.
27051  * This always NUL terminates (unless siz == 0 or there were no NUL characters
27052  * in the dest_size characters of dest to start with).
27053  *
27054  * <note><para>Caveat: this is supposedly a more secure alternative to
27055  * strcat() or strncat(), but for real security g_strconcat() is harder
27056  * to mess up.</para></note>
27057  *
27058  * Returns: size of attempted result, which is MIN (dest_size, strlen (original dest)) + strlen (src), so if retval >= dest_size, truncation occurred.
27059  */
27060
27061
27062 /**
27063  * g_strlcpy:
27064  * @dest: destination buffer
27065  * @src: source buffer
27066  * @dest_size: length of @dest in bytes
27067  *
27068  * Portability wrapper that calls strlcpy() on systems which have it,
27069  * and emulates strlcpy() otherwise. Copies @src to @dest; @dest is
27070  * guaranteed to be nul-terminated; @src must be nul-terminated;
27071  * @dest_size is the buffer size, not the number of chars to copy.
27072  *
27073  * At most dest_size - 1 characters will be copied. Always nul-terminates
27074  * (unless dest_size == 0). This function does <emphasis>not</emphasis>
27075  * allocate memory. Unlike strncpy(), this function doesn't pad dest (so
27076  * it's often faster). It returns the size of the attempted result,
27077  * strlen (src), so if @retval >= @dest_size, truncation occurred.
27078  *
27079  * <note><para>Caveat: strlcpy() is supposedly more secure than
27080  * strcpy() or strncpy(), but if you really want to avoid screwups,
27081  * g_strdup() is an even better idea.</para></note>
27082  *
27083  * Returns: length of @src
27084  */
27085
27086
27087 /**
27088  * g_strncasecmp:
27089  * @s1: a string.
27090  * @s2: a string to compare with @s1.
27091  * @n: the maximum number of characters to compare.
27092  *
27093  * A case-insensitive string comparison, corresponding to the standard
27094  * strncasecmp() function on platforms which support it.
27095  * It is similar to g_strcasecmp() except it only compares the first @n
27096  * characters of the strings.
27097  *
27098  * Returns: 0 if the strings match, a negative value if @s1 &lt; @s2, or a positive value if @s1 &gt; @s2.
27099  * Deprecated: 2.2: The problem with g_strncasecmp() is that it does the comparison by calling toupper()/tolower(). These functions are locale-specific and operate on single bytes. However, it is impossible to handle things correctly from an I18N standpoint by operating on bytes, since characters may be multibyte. Thus g_strncasecmp() is broken if your string is guaranteed to be ASCII, since it's locale-sensitive, and it's broken if your string is localized, since it doesn't work on many encodings at all, including UTF-8, EUC-JP, etc.  There are therefore two replacement techniques: g_ascii_strncasecmp(), which only works on ASCII and is not locale-sensitive, and g_utf8_casefold() followed by strcmp() on the resulting strings, which is good for case-insensitive sorting of UTF-8.
27100  */
27101
27102
27103 /**
27104  * g_strndup:
27105  * @str: the string to duplicate
27106  * @n: the maximum number of bytes to copy from @str
27107  *
27108  * Duplicates the first @n bytes of a string, returning a newly-allocated
27109  * buffer @n + 1 bytes long which will always be nul-terminated.
27110  * If @str is less than @n bytes long the buffer is padded with nuls.
27111  * If @str is %NULL it returns %NULL.
27112  * The returned value should be freed when no longer needed.
27113  *
27114  * <note><para>
27115  * To copy a number of characters from a UTF-8 encoded string, use
27116  * g_utf8_strncpy() instead.
27117  * </para></note>
27118  *
27119  * Returns: a newly-allocated buffer containing the first @n bytes of @str, nul-terminated
27120  */
27121
27122
27123 /**
27124  * g_strnfill:
27125  * @length: the length of the new string
27126  * @fill_char: the byte to fill the string with
27127  *
27128  * Creates a new string @length bytes long filled with @fill_char.
27129  * The returned string should be freed when no longer needed.
27130  *
27131  * Returns: a newly-allocated string filled the @fill_char
27132  */
27133
27134
27135 /**
27136  * g_strreverse:
27137  * @string: the string to reverse
27138  *
27139  * Reverses all of the bytes in a string. For example,
27140  * <literal>g_strreverse ("abcdef")</literal> will result
27141  * in "fedcba".
27142  *
27143  * Note that g_strreverse() doesn't work on UTF-8 strings
27144  * containing multibyte characters. For that purpose, use
27145  * g_utf8_strreverse().
27146  *
27147  * Returns: the same pointer passed in as @string
27148  */
27149
27150
27151 /**
27152  * g_strrstr:
27153  * @haystack: a nul-terminated string
27154  * @needle: the nul-terminated string to search for
27155  *
27156  * Searches the string @haystack for the last occurrence
27157  * of the string @needle.
27158  *
27159  * Returns: a pointer to the found occurrence, or %NULL if not found.
27160  */
27161
27162
27163 /**
27164  * g_strrstr_len:
27165  * @haystack: a nul-terminated string
27166  * @haystack_len: the maximum length of @haystack
27167  * @needle: the nul-terminated string to search for
27168  *
27169  * Searches the string @haystack for the last occurrence
27170  * of the string @needle, limiting the length of the search
27171  * to @haystack_len.
27172  *
27173  * Returns: a pointer to the found occurrence, or %NULL if not found.
27174  */
27175
27176
27177 /**
27178  * g_strsignal:
27179  * @signum: the signal number. See the <literal>signal</literal> documentation
27180  *
27181  * Returns a string describing the given signal, e.g. "Segmentation fault".
27182  * You should use this function in preference to strsignal(), because it
27183  * returns a string in UTF-8 encoding, and since not all platforms support
27184  * the strsignal() function.
27185  *
27186  * Returns: a UTF-8 string describing the signal. If the signal is unknown, it returns "unknown signal (&lt;signum&gt;)".
27187  */
27188
27189
27190 /**
27191  * g_strsplit:
27192  * @string: a string to split
27193  * @delimiter: a string which specifies the places at which to split the string. The delimiter is not included in any of the resulting strings, unless @max_tokens is reached.
27194  * @max_tokens: the maximum number of pieces to split @string into. If this is less than 1, the string is split completely.
27195  *
27196  * Splits a string into a maximum of @max_tokens pieces, using the given
27197  * @delimiter. If @max_tokens is reached, the remainder of @string is
27198  * appended to the last token.
27199  *
27200  * As a special case, the result of splitting the empty string "" is an empty
27201  * vector, not a vector containing a single string. The reason for this
27202  * special case is that being able to represent a empty vector is typically
27203  * more useful than consistent handling of empty elements. If you do need
27204  * to represent empty elements, you'll need to check for the empty string
27205  * before calling g_strsplit().
27206  *
27207  * Returns: a newly-allocated %NULL-terminated array of strings. Use g_strfreev() to free it.
27208  */
27209
27210
27211 /**
27212  * g_strsplit_set:
27213  * @string: The string to be tokenized
27214  * @delimiters: A nul-terminated string containing bytes that are used to split the string.
27215  * @max_tokens: The maximum number of tokens to split @string into. If this is less than 1, the string is split completely
27216  *
27217  * Splits @string into a number of tokens not containing any of the characters
27218  * in @delimiter. A token is the (possibly empty) longest string that does not
27219  * contain any of the characters in @delimiters. If @max_tokens is reached, the
27220  * remainder is appended to the last token.
27221  *
27222  * For example the result of g_strsplit_set ("abc:def/ghi", ":/", -1) is a
27223  * %NULL-terminated vector containing the three strings "abc", "def",
27224  * and "ghi".
27225  *
27226  * The result if g_strsplit_set (":def/ghi:", ":/", -1) is a %NULL-terminated
27227  * vector containing the four strings "", "def", "ghi", and "".
27228  *
27229  * As a special case, the result of splitting the empty string "" is an empty
27230  * vector, not a vector containing a single string. The reason for this
27231  * special case is that being able to represent a empty vector is typically
27232  * more useful than consistent handling of empty elements. If you do need
27233  * to represent empty elements, you'll need to check for the empty string
27234  * before calling g_strsplit_set().
27235  *
27236  * Note that this function works on bytes not characters, so it can't be used
27237  * to delimit UTF-8 strings for anything but ASCII characters.
27238  *
27239  * Returns: a newly-allocated %NULL-terminated array of strings. Use g_strfreev() to free it.
27240  * Since: 2.4
27241  */
27242
27243
27244 /**
27245  * g_strstr_len:
27246  * @haystack: a string
27247  * @haystack_len: the maximum length of @haystack. Note that -1 is a valid length, if @haystack is nul-terminated, meaning it will search through the whole string.
27248  * @needle: the string to search for
27249  *
27250  * Searches the string @haystack for the first occurrence
27251  * of the string @needle, limiting the length of the search
27252  * to @haystack_len.
27253  *
27254  * Returns: a pointer to the found occurrence, or %NULL if not found.
27255  */
27256
27257
27258 /**
27259  * g_strstrip:
27260  * @string: a string to remove the leading and trailing whitespace from
27261  *
27262  * Removes leading and trailing whitespace from a string.
27263  * See g_strchomp() and g_strchug().
27264  *
27265  * Returns: @string
27266  */
27267
27268
27269 /**
27270  * g_strtod:
27271  * @nptr: the string to convert to a numeric value.
27272  * @endptr: if non-%NULL, it returns the character after the last character used in the conversion.
27273  *
27274  * Converts a string to a #gdouble value.
27275  * It calls the standard strtod() function to handle the conversion, but
27276  * if the string is not completely converted it attempts the conversion
27277  * again with g_ascii_strtod(), and returns the best match.
27278  *
27279  * This function should seldom be used. The normal situation when reading
27280  * numbers not for human consumption is to use g_ascii_strtod(). Only when
27281  * you know that you must expect both locale formatted and C formatted numbers
27282  * should you use this. Make sure that you don't pass strings such as comma
27283  * separated lists of values, since the commas may be interpreted as a decimal
27284  * point in some locales, causing unexpected results.
27285  *
27286  * Returns: the #gdouble value.
27287  */
27288
27289
27290 /**
27291  * g_strup:
27292  * @string: the string to convert.
27293  *
27294  * Converts a string to upper case.
27295  *
27296  * Returns: the string
27297  * Deprecated: 2.2: This function is totally broken for the reasons discussed in the g_strncasecmp() docs - use g_ascii_strup() or g_utf8_strup() instead.
27298  */
27299
27300
27301 /**
27302  * g_strv_length:
27303  * @str_array: a %NULL-terminated array of strings
27304  *
27305  * Returns the length of the given %NULL-terminated
27306  * string array @str_array.
27307  *
27308  * Returns: length of @str_array.
27309  * Since: 2.6
27310  */
27311
27312
27313 /**
27314  * g_test_add:
27315  * @testpath: The test path for a new test case.
27316  * @Fixture: The type of a fixture data structure.
27317  * @tdata: Data argument for the test functions.
27318  * @fsetup: The function to set up the fixture data.
27319  * @ftest: The actual test function.
27320  * @fteardown: The function to tear down the fixture data.
27321  *
27322  * Hook up a new test case at @testpath, similar to g_test_add_func().
27323  * A fixture data structure with setup and teardown function may be provided
27324  * though, similar to g_test_create_case().
27325  * g_test_add() is implemented as a macro, so that the fsetup(), ftest() and
27326  * fteardown() callbacks can expect a @Fixture pointer as first argument in
27327  * a type safe manner.
27328  *
27329  * Since: 2.16
27330  */
27331
27332
27333 /**
27334  * g_test_add_data_func:
27335  * @testpath: /-separated test case path name for the test.
27336  * @test_data: Test data argument for the test function.
27337  * @test_func: The test function to invoke for this test.
27338  *
27339  * Create a new test case, similar to g_test_create_case(). However
27340  * the test is assumed to use no fixture, and test suites are automatically
27341  * created on the fly and added to the root fixture, based on the
27342  * slash-separated portions of @testpath. The @test_data argument
27343  * will be passed as first argument to @test_func.
27344  *
27345  * If @testpath includes the component "subprocess" anywhere in it,
27346  * the test will be skipped by default, and only run if explicitly
27347  * required via the <option>-p</option> command-line option or
27348  * g_test_trap_subprocess().
27349  *
27350  * Since: 2.16
27351  */
27352
27353
27354 /**
27355  * g_test_add_data_func_full:
27356  * @testpath: /-separated test case path name for the test.
27357  * @test_data: Test data argument for the test function.
27358  * @test_func: The test function to invoke for this test.
27359  * @data_free_func: #GDestroyNotify for @test_data.
27360  *
27361  * Create a new test case, as with g_test_add_data_func(), but freeing
27362  * @test_data after the test run is complete.
27363  *
27364  * Since: 2.34
27365  */
27366
27367
27368 /**
27369  * g_test_add_func:
27370  * @testpath: /-separated test case path name for the test.
27371  * @test_func: The test function to invoke for this test.
27372  *
27373  * Create a new test case, similar to g_test_create_case(). However
27374  * the test is assumed to use no fixture, and test suites are automatically
27375  * created on the fly and added to the root fixture, based on the
27376  * slash-separated portions of @testpath.
27377  *
27378  * If @testpath includes the component "subprocess" anywhere in it,
27379  * the test will be skipped by default, and only run if explicitly
27380  * required via the <option>-p</option> command-line option or
27381  * g_test_trap_subprocess().
27382  *
27383  * Since: 2.16
27384  */
27385
27386
27387 /**
27388  * g_test_assert_expected_messages:
27389  *
27390  * Asserts that all messages previously indicated via
27391  * g_test_expect_message() have been seen and suppressed.
27392  *
27393  * Since: 2.34
27394  */
27395
27396
27397 /**
27398  * g_test_bug:
27399  * @bug_uri_snippet: Bug specific bug tracker URI portion.
27400  *
27401  * This function adds a message to test reports that
27402  * associates a bug URI with a test case.
27403  * Bug URIs are constructed from a base URI set with g_test_bug_base()
27404  * and @bug_uri_snippet.
27405  *
27406  * Since: 2.16
27407  */
27408
27409
27410 /**
27411  * g_test_bug_base:
27412  * @uri_pattern: the base pattern for bug URIs
27413  *
27414  * Specify the base URI for bug reports.
27415  *
27416  * The base URI is used to construct bug report messages for
27417  * g_test_message() when g_test_bug() is called.
27418  * Calling this function outside of a test case sets the
27419  * default base URI for all test cases. Calling it from within
27420  * a test case changes the base URI for the scope of the test
27421  * case only.
27422  * Bug URIs are constructed by appending a bug specific URI
27423  * portion to @uri_pattern, or by replacing the special string
27424  * '\%s' within @uri_pattern if that is present.
27425  *
27426  * Since: 2.16
27427  */
27428
27429
27430 /**
27431  * g_test_build_filename:
27432  * @file_type: the type of file (built vs. distributed)
27433  * @first_path: the first segment of the pathname
27434  * @...: %NULL-terminated additional path segments
27435  *
27436  * Creates the pathname to a data file that is required for a test.
27437  *
27438  * This function is conceptually similar to g_build_filename() except
27439  * that the first argument has been replaced with a #GTestFileType
27440  * argument.
27441  *
27442  * The data file should either have been distributed with the module
27443  * containing the test (%G_TEST_DIST) or built as part of the build
27444  * system of that module (%G_TEST_BUILT).
27445  *
27446  * In order for this function to work in srcdir != builddir situations,
27447  * the G_TEST_SRCDIR and G_TEST_BUILDDIR environment variables need to
27448  * have been defined.  As of 2.38, this is done by the Makefile.decl
27449  * included in GLib.  Please ensure that your copy is up to date before
27450  * using this function.
27451  *
27452  * In case neither variable is set, this function will fall back to
27453  * using the dirname portion of argv[0], possibly removing ".libs".
27454  * This allows for casual running of tests directly from the commandline
27455  * in the srcdir == builddir case and should also support running of
27456  * installed tests, assuming the data files have been installed in the
27457  * same relative path as the test binary.
27458  *
27459  * Returns: the path of the file, to be freed using g_free()
27460  * Since: 2.38
27461  */
27462
27463
27464 /**
27465  * g_test_create_case:
27466  * @test_name: the name for the test case
27467  * @data_size: the size of the fixture data structure
27468  * @test_data: test data argument for the test functions
27469  * @data_setup: the function to set up the fixture data
27470  * @data_test: the actual test function
27471  * @data_teardown: the function to teardown the fixture data
27472  *
27473  * Create a new #GTestCase, named @test_name, this API is fairly
27474  * low level, calling g_test_add() or g_test_add_func() is preferable.
27475  * When this test is executed, a fixture structure of size @data_size
27476  * will be allocated and filled with 0s. Then @data_setup is called
27477  * to initialize the fixture. After fixture setup, the actual test
27478  * function @data_test is called. Once the test run completed, the
27479  * fixture structure is torn down  by calling @data_teardown and
27480  * after that the memory is released.
27481  *
27482  * Splitting up a test run into fixture setup, test function and
27483  * fixture teardown is most usful if the same fixture is used for
27484  * multiple tests. In this cases, g_test_create_case() will be
27485  * called with the same fixture, but varying @test_name and
27486  * @data_test arguments.
27487  *
27488  * Returns: a newly allocated #GTestCase.
27489  * Since: 2.16
27490  */
27491
27492
27493 /**
27494  * g_test_create_suite:
27495  * @suite_name: a name for the suite
27496  *
27497  * Create a new test suite with the name @suite_name.
27498  *
27499  * Returns: A newly allocated #GTestSuite instance.
27500  * Since: 2.16
27501  */
27502
27503
27504 /**
27505  * g_test_expect_message:
27506  * @log_domain: (allow-none): the log domain of the message
27507  * @log_level: the log level of the message
27508  * @pattern: a glob-style <link linkend="glib-Glob-style-pattern-matching">pattern</link>
27509  *
27510  * Indicates that a message with the given @log_domain and @log_level,
27511  * with text matching @pattern, is expected to be logged. When this
27512  * message is logged, it will not be printed, and the test case will
27513  * not abort.
27514  *
27515  * Use g_test_assert_expected_messages() to assert that all
27516  * previously-expected messages have been seen and suppressed.
27517  *
27518  * You can call this multiple times in a row, if multiple messages are
27519  * expected as a result of a single call. (The messages must appear in
27520  * the same order as the calls to g_test_expect_message().)
27521  *
27522  * For example:
27523  *
27524  * |[
27525  *   /&ast; g_main_context_push_thread_default() should fail if the
27526  *    &ast; context is already owned by another thread.
27527  *    &ast;/
27528  *   g_test_expect_message (G_LOG_DOMAIN,
27529  *                          G_LOG_LEVEL_CRITICAL,
27530  *                          "assertion*acquired_context*failed");
27531  *   g_main_context_push_thread_default (bad_context);
27532  *   g_test_assert_expected_messages ();
27533  * ]|
27534  *
27535  * Note that you cannot use this to test g_error() messages, since
27536  * g_error() intentionally never returns even if the program doesn't
27537  * abort; use g_test_trap_subprocess() in this case.
27538  *
27539  * Since: 2.34
27540  */
27541
27542
27543 /**
27544  * g_test_fail:
27545  *
27546  * Indicates that a test failed. This function can be called
27547  * multiple times from the same test. You can use this function
27548  * if your test failed in a recoverable way.
27549  *
27550  * Do not use this function if the failure of a test could cause
27551  * other tests to malfunction.
27552  *
27553  * Calling this function will not stop the test from running, you
27554  * need to return from the test function yourself. So you can
27555  * produce additional diagnostic messages or even continue running
27556  * the test.
27557  *
27558  * If not called from inside a test, this function does nothing.
27559  *
27560  * Since: 2.30
27561  */
27562
27563
27564 /**
27565  * g_test_failed:
27566  *
27567  * Returns whether a test has already failed. This will
27568  * be the case when g_test_fail(), g_test_incomplete()
27569  * or g_test_skip() have been called, but also if an
27570  * assertion has failed.
27571  *
27572  * This can be useful to return early from a test if
27573  * continuing after a failed assertion might be harmful.
27574  *
27575  * The return value of this function is only meaningful
27576  * if it is called from inside a test function.
27577  *
27578  * Returns: %TRUE if the test has failed
27579  * Since: 2.38
27580  */
27581
27582
27583 /**
27584  * g_test_get_dir:
27585  * @file_type: the type of file (built vs. distributed)
27586  *
27587  * Gets the pathname of the directory containing test files of the type
27588  * specified by @file_type.
27589  *
27590  * This is approximately the same as calling g_test_build_filename("."),
27591  * but you don't need to free the return value.
27592  *
27593  * Returns: the path of the directory, owned by GLib
27594  * Since: 2.38
27595  */
27596
27597
27598 /**
27599  * g_test_get_filename:
27600  * @file_type: the type of file (built vs. distributed)
27601  * @first_path: the first segment of the pathname
27602  * @...: %NULL-terminated additional path segments
27603  *
27604  * Gets the pathname to a data file that is required for a test.
27605  *
27606  * This is the same as g_test_build_filename() with two differences.
27607  * The first difference is that must only use this function from within
27608  * a testcase function.  The second difference is that you need not free
27609  * the return value -- it will be automatically freed when the testcase
27610  * finishes running.
27611  *
27612  * It is safe to use this function from a thread inside of a testcase
27613  * but you must ensure that all such uses occur before the main testcase
27614  * function returns (ie: it is best to ensure that all threads have been
27615  * joined).
27616  *
27617  * Returns: the path, automatically freed at the end of the testcase
27618  * Since: 2.38
27619  */
27620
27621
27622 /**
27623  * g_test_get_root:
27624  *
27625  * Get the toplevel test suite for the test path API.
27626  *
27627  * Returns: the toplevel #GTestSuite
27628  * Since: 2.16
27629  */
27630
27631
27632 /**
27633  * g_test_incomplete:
27634  * @msg: (allow-none): explanation
27635  *
27636  * Indicates that a test failed because of some incomplete
27637  * functionality. This function can be called multiple times
27638  * from the same test.
27639  *
27640  * Calling this function will not stop the test from running, you
27641  * need to return from the test function yourself. So you can
27642  * produce additional diagnostic messages or even continue running
27643  * the test.
27644  *
27645  * If not called from inside a test, this function does nothing.
27646  *
27647  * Since: 2.38
27648  */
27649
27650
27651 /**
27652  * g_test_init:
27653  * @argc: Address of the @argc parameter of the main() function. Changed if any arguments were handled.
27654  * @argv: Address of the @argv parameter of main(). Any parameters understood by g_test_init() stripped before return.
27655  * @...: Reserved for future extension. Currently, you must pass %NULL.
27656  *
27657  * Initialize the GLib testing framework, e.g. by seeding the
27658  * test random number generator, the name for g_get_prgname()
27659  * and parsing test related command line args.
27660  * So far, the following arguments are understood:
27661  * <variablelist>
27662  *   <varlistentry>
27663  *     <term><option>-l</option></term>
27664  *     <listitem><para>
27665  *       List test cases available in a test executable.
27666  *     </para></listitem>
27667  *   </varlistentry>
27668  *   <varlistentry>
27669  *     <term><option>--seed=<replaceable>RANDOMSEED</replaceable></option></term>
27670  *     <listitem><para>
27671  *       Provide a random seed to reproduce test runs using random numbers.
27672  *     </para></listitem>
27673  *     </varlistentry>
27674  *     <varlistentry>
27675  *       <term><option>--verbose</option></term>
27676  *       <listitem><para>Run tests verbosely.</para></listitem>
27677  *     </varlistentry>
27678  *     <varlistentry>
27679  *       <term><option>-q</option>, <option>--quiet</option></term>
27680  *       <listitem><para>Run tests quietly.</para></listitem>
27681  *     </varlistentry>
27682  *     <varlistentry>
27683  *       <term><option>-p <replaceable>TESTPATH</replaceable></option></term>
27684  *       <listitem><para>
27685  *         Execute all tests matching <replaceable>TESTPATH</replaceable>.
27686  *         This can also be used to force a test to run that would otherwise
27687  *         be skipped (ie, a test whose name contains "/subprocess").
27688  *       </para></listitem>
27689  *     </varlistentry>
27690  *     <varlistentry>
27691  *       <term><option>-m {perf|slow|thorough|quick|undefined|no-undefined}</option></term>
27692  *       <listitem><para>
27693  *         Execute tests according to these test modes:
27694  *         <variablelist>
27695  *           <varlistentry>
27696  *             <term>perf</term>
27697  *             <listitem><para>
27698  *               Performance tests, may take long and report results.
27699  *             </para></listitem>
27700  *           </varlistentry>
27701  *           <varlistentry>
27702  *             <term>slow, thorough</term>
27703  *             <listitem><para>
27704  *               Slow and thorough tests, may take quite long and
27705  *               maximize coverage.
27706  *             </para></listitem>
27707  *           </varlistentry>
27708  *           <varlistentry>
27709  *             <term>quick</term>
27710  *             <listitem><para>
27711  *               Quick tests, should run really quickly and give good coverage.
27712  *             </para></listitem>
27713  *           </varlistentry>
27714  *           <varlistentry>
27715  *             <term>undefined</term>
27716  *             <listitem><para>
27717  *               Tests for undefined behaviour, may provoke programming errors
27718  *               under g_test_trap_subprocess() or g_test_expect_messages() to check
27719  *               that appropriate assertions or warnings are given
27720  *             </para></listitem>
27721  *           </varlistentry>
27722  *           <varlistentry>
27723  *             <term>no-undefined</term>
27724  *             <listitem><para>
27725  *               Avoid tests for undefined behaviour
27726  *             </para></listitem>
27727  *           </varlistentry>
27728  *         </variablelist>
27729  *       </para></listitem>
27730  *     </varlistentry>
27731  *     <varlistentry>
27732  *       <term><option>--debug-log</option></term>
27733  *       <listitem><para>Debug test logging output.</para></listitem>
27734  *     </varlistentry>
27735  *  </variablelist>
27736  *
27737  * Since: 2.16
27738  */
27739
27740
27741 /**
27742  * g_test_initialized:
27743  *
27744  * Returns %TRUE if g_test_init() has been called.
27745  *
27746  * Returns: %TRUE if g_test_init() has been called.
27747  * Since: 2.36
27748  */
27749
27750
27751 /**
27752  * g_test_log_buffer_free:
27753  *
27754  * Internal function for gtester to free test log messages, no ABI guarantees provided.
27755  */
27756
27757
27758 /**
27759  * g_test_log_buffer_new:
27760  *
27761  * Internal function for gtester to decode test log messages, no ABI guarantees provided.
27762  */
27763
27764
27765 /**
27766  * g_test_log_buffer_pop:
27767  *
27768  * Internal function for gtester to retrieve test log messages, no ABI guarantees provided.
27769  */
27770
27771
27772 /**
27773  * g_test_log_buffer_push:
27774  *
27775  * Internal function for gtester to decode test log messages, no ABI guarantees provided.
27776  */
27777
27778
27779 /**
27780  * g_test_log_msg_free:
27781  *
27782  * Internal function for gtester to free test log messages, no ABI guarantees provided.
27783  */
27784
27785
27786 /**
27787  * g_test_log_set_fatal_handler:
27788  * @log_func: the log handler function.
27789  * @user_data: data passed to the log handler.
27790  *
27791  * Installs a non-error fatal log handler which can be
27792  * used to decide whether log messages which are counted
27793  * as fatal abort the program.
27794  *
27795  * The use case here is that you are running a test case
27796  * that depends on particular libraries or circumstances
27797  * and cannot prevent certain known critical or warning
27798  * messages. So you install a handler that compares the
27799  * domain and message to precisely not abort in such a case.
27800  *
27801  * Note that the handler is reset at the beginning of
27802  * any test case, so you have to set it inside each test
27803  * function which needs the special behavior.
27804  *
27805  * This handler has no effect on g_error messages.
27806  *
27807  * Since: 2.22
27808  */
27809
27810
27811 /**
27812  * g_test_maximized_result:
27813  * @maximized_quantity: the reported value
27814  * @format: the format string of the report message
27815  * @...: arguments to pass to the printf() function
27816  *
27817  * Report the result of a performance or measurement test.
27818  * The test should generally strive to maximize the reported
27819  * quantities (larger values are better than smaller ones),
27820  * this and @maximized_quantity can determine sorting
27821  * order for test result reports.
27822  *
27823  * Since: 2.16
27824  */
27825
27826
27827 /**
27828  * g_test_message:
27829  * @format: the format string
27830  * @...: printf-like arguments to @format
27831  *
27832  * Add a message to the test report.
27833  *
27834  * Since: 2.16
27835  */
27836
27837
27838 /**
27839  * g_test_minimized_result:
27840  * @minimized_quantity: the reported value
27841  * @format: the format string of the report message
27842  * @...: arguments to pass to the printf() function
27843  *
27844  * Report the result of a performance or measurement test.
27845  * The test should generally strive to minimize the reported
27846  * quantities (smaller values are better than larger ones),
27847  * this and @minimized_quantity can determine sorting
27848  * order for test result reports.
27849  *
27850  * Since: 2.16
27851  */
27852
27853
27854 /**
27855  * g_test_perf:
27856  *
27857  * Returns %TRUE if tests are run in performance mode.
27858  *
27859  * Returns: %TRUE if in performance mode
27860  */
27861
27862
27863 /**
27864  * g_test_queue_destroy:
27865  * @destroy_func: Destroy callback for teardown phase.
27866  * @destroy_data: Destroy callback data.
27867  *
27868  * This function enqueus a callback @destroy_func to be executed
27869  * during the next test case teardown phase. This is most useful
27870  * to auto destruct allocted test resources at the end of a test run.
27871  * Resources are released in reverse queue order, that means enqueueing
27872  * callback A before callback B will cause B() to be called before
27873  * A() during teardown.
27874  *
27875  * Since: 2.16
27876  */
27877
27878
27879 /**
27880  * g_test_queue_free:
27881  * @gfree_pointer: the pointer to be stored.
27882  *
27883  * Enqueue a pointer to be released with g_free() during the next
27884  * teardown phase. This is equivalent to calling g_test_queue_destroy()
27885  * with a destroy callback of g_free().
27886  *
27887  * Since: 2.16
27888  */
27889
27890
27891 /**
27892  * g_test_queue_unref:
27893  * @gobject: the object to unref
27894  *
27895  * Enqueue an object to be released with g_object_unref() during
27896  * the next teardown phase. This is equivalent to calling
27897  * g_test_queue_destroy() with a destroy callback of g_object_unref().
27898  *
27899  * Since: 2.16
27900  */
27901
27902
27903 /**
27904  * g_test_quick:
27905  *
27906  * Returns %TRUE if tests are run in quick mode.
27907  * Exactly one of g_test_quick() and g_test_slow() is active in any run;
27908  * there is no "medium speed".
27909  *
27910  * Returns: %TRUE if in quick mode
27911  */
27912
27913
27914 /**
27915  * g_test_quiet:
27916  *
27917  * Returns %TRUE if tests are run in quiet mode.
27918  * The default is neither g_test_verbose() nor g_test_quiet().
27919  *
27920  * Returns: %TRUE if in quiet mode
27921  */
27922
27923
27924 /**
27925  * g_test_rand_bit:
27926  *
27927  * Get a reproducible random bit (0 or 1), see g_test_rand_int()
27928  * for details on test case random numbers.
27929  *
27930  * Since: 2.16
27931  */
27932
27933
27934 /**
27935  * g_test_rand_double:
27936  *
27937  * Get a reproducible random floating point number,
27938  * see g_test_rand_int() for details on test case random numbers.
27939  *
27940  * Returns: a random number from the seeded random number generator.
27941  * Since: 2.16
27942  */
27943
27944
27945 /**
27946  * g_test_rand_double_range:
27947  * @range_start: the minimum value returned by this function
27948  * @range_end: the minimum value not returned by this function
27949  *
27950  * Get a reproducible random floating pointer number out of a specified range,
27951  * see g_test_rand_int() for details on test case random numbers.
27952  *
27953  * Returns: a number with @range_start <= number < @range_end.
27954  * Since: 2.16
27955  */
27956
27957
27958 /**
27959  * g_test_rand_int:
27960  *
27961  * Get a reproducible random integer number.
27962  *
27963  * The random numbers generated by the g_test_rand_*() family of functions
27964  * change with every new test program start, unless the --seed option is
27965  * given when starting test programs.
27966  *
27967  * For individual test cases however, the random number generator is
27968  * reseeded, to avoid dependencies between tests and to make --seed
27969  * effective for all test cases.
27970  *
27971  * Returns: a random number from the seeded random number generator.
27972  * Since: 2.16
27973  */
27974
27975
27976 /**
27977  * g_test_rand_int_range:
27978  * @begin: the minimum value returned by this function
27979  * @end: the smallest value not to be returned by this function
27980  *
27981  * Get a reproducible random integer number out of a specified range,
27982  * see g_test_rand_int() for details on test case random numbers.
27983  *
27984  * Returns: a number with @begin <= number < @end.
27985  * Since: 2.16
27986  */
27987
27988
27989 /**
27990  * g_test_run:
27991  *
27992  * Runs all tests under the toplevel suite which can be retrieved
27993  * with g_test_get_root(). Similar to g_test_run_suite(), the test
27994  * cases to be run are filtered according to
27995  * test path arguments (-p <replaceable>testpath</replaceable>) as
27996  * parsed by g_test_init().
27997  * g_test_run_suite() or g_test_run() may only be called once
27998  * in a program.
27999  *
28000  * Returns: 0 on success
28001  * Since: 2.16
28002  */
28003
28004
28005 /**
28006  * g_test_run_suite:
28007  * @suite: a #GTestSuite
28008  *
28009  * Execute the tests within @suite and all nested #GTestSuites.
28010  * The test suites to be executed are filtered according to
28011  * test path arguments (-p <replaceable>testpath</replaceable>)
28012  * as parsed by g_test_init().
28013  * g_test_run_suite() or g_test_run() may only be called once
28014  * in a program.
28015  *
28016  * Returns: 0 on success
28017  * Since: 2.16
28018  */
28019
28020
28021 /**
28022  * g_test_set_nonfatal_assertions:
28023  *
28024  * Changes the behaviour of g_assert_cmpstr(), g_assert_cmpint(),
28025  * g_assert_cmpuint(), g_assert_cmphex(), g_assert_cmpfloat(),
28026  * g_assert_true(), g_assert_false(), g_assert_null(), g_assert_no_error(),
28027  * g_assert_error(), g_test_assert_expected_messages() and the various
28028  * g_test_trap_assert_*() macros to not abort to program, but instead
28029  * call g_test_fail() and continue.
28030  *
28031  * Note that the g_assert_not_reached() and g_assert() are not
28032  * affected by this.
28033  *
28034  * This function can only be called after g_test_init().
28035  *
28036  * Since: 2.38
28037  */
28038
28039
28040 /**
28041  * g_test_skip:
28042  * @msg: (allow-none): explanation
28043  *
28044  * Indicates that a test was skipped.
28045  *
28046  * Calling this function will not stop the test from running, you
28047  * need to return from the test function yourself. So you can
28048  * produce additional diagnostic messages or even continue running
28049  * the test.
28050  *
28051  * If not called from inside a test, this function does nothing.
28052  *
28053  * Since: 2.38
28054  */
28055
28056
28057 /**
28058  * g_test_slow:
28059  *
28060  * Returns %TRUE if tests are run in slow mode.
28061  * Exactly one of g_test_quick() and g_test_slow() is active in any run;
28062  * there is no "medium speed".
28063  *
28064  * Returns: the opposite of g_test_quick()
28065  */
28066
28067
28068 /**
28069  * g_test_subprocess:
28070  *
28071  * Returns %TRUE (after g_test_init() has been called) if the test
28072  * program is running under g_test_trap_subprocess().
28073  *
28074  * Returns: %TRUE if the test program is running under g_test_trap_subprocess().
28075  * Since: 2.38
28076  */
28077
28078
28079 /**
28080  * g_test_suite_add:
28081  * @suite: a #GTestSuite
28082  * @test_case: a #GTestCase
28083  *
28084  * Adds @test_case to @suite.
28085  *
28086  * Since: 2.16
28087  */
28088
28089
28090 /**
28091  * g_test_suite_add_suite:
28092  * @suite: a #GTestSuite
28093  * @nestedsuite: another #GTestSuite
28094  *
28095  * Adds @nestedsuite to @suite.
28096  *
28097  * Since: 2.16
28098  */
28099
28100
28101 /**
28102  * g_test_thorough:
28103  *
28104  * Returns %TRUE if tests are run in thorough mode, equivalent to
28105  * g_test_slow().
28106  *
28107  * Returns: the same thing as g_test_slow()
28108  */
28109
28110
28111 /**
28112  * g_test_timer_elapsed:
28113  *
28114  * Get the time since the last start of the timer with g_test_timer_start().
28115  *
28116  * Returns: the time since the last start of the timer, as a double
28117  * Since: 2.16
28118  */
28119
28120
28121 /**
28122  * g_test_timer_last:
28123  *
28124  * Report the last result of g_test_timer_elapsed().
28125  *
28126  * Returns: the last result of g_test_timer_elapsed(), as a double
28127  * Since: 2.16
28128  */
28129
28130
28131 /**
28132  * g_test_timer_start:
28133  *
28134  * Start a timing test. Call g_test_timer_elapsed() when the task is supposed
28135  * to be done. Call this function again to restart the timer.
28136  *
28137  * Since: 2.16
28138  */
28139
28140
28141 /**
28142  * g_test_trap_assert_failed:
28143  *
28144  * Assert that the last test subprocess failed.
28145  * See g_test_trap_subprocess().
28146  *
28147  * This is sometimes used to test situations that are formally considered to
28148  * be undefined behaviour, like inputs that fail a g_return_if_fail()
28149  * check. In these situations you should skip the entire test, including the
28150  * call to g_test_trap_subprocess(), unless g_test_undefined() returns %TRUE
28151  * to indicate that undefined behaviour may be tested.
28152  *
28153  * Since: 2.16
28154  */
28155
28156
28157 /**
28158  * g_test_trap_assert_passed:
28159  *
28160  * Assert that the last test subprocess passed.
28161  * See g_test_trap_subprocess().
28162  *
28163  * Since: 2.16
28164  */
28165
28166
28167 /**
28168  * g_test_trap_assert_stderr:
28169  * @serrpattern: a glob-style <link linkend="glib-Glob-style-pattern-matching">pattern</link>
28170  *
28171  * Assert that the stderr output of the last test subprocess
28172  * matches @serrpattern. See  g_test_trap_subprocess().
28173  *
28174  * This is sometimes used to test situations that are formally
28175  * considered to be undefined behaviour, like code that hits a
28176  * g_assert() or g_error(). In these situations you should skip the
28177  * entire test, including the call to g_test_trap_subprocess(), unless
28178  * g_test_undefined() returns %TRUE to indicate that undefined
28179  * behaviour may be tested.
28180  *
28181  * Since: 2.16
28182  */
28183
28184
28185 /**
28186  * g_test_trap_assert_stderr_unmatched:
28187  * @serrpattern: a glob-style <link linkend="glib-Glob-style-pattern-matching">pattern</link>
28188  *
28189  * Assert that the stderr output of the last test subprocess
28190  * does not match @serrpattern. See g_test_trap_subprocess().
28191  *
28192  * Since: 2.16
28193  */
28194
28195
28196 /**
28197  * g_test_trap_assert_stdout:
28198  * @soutpattern: a glob-style <link linkend="glib-Glob-style-pattern-matching">pattern</link>
28199  *
28200  * Assert that the stdout output of the last test subprocess matches
28201  * @soutpattern. See g_test_trap_subprocess().
28202  *
28203  * Since: 2.16
28204  */
28205
28206
28207 /**
28208  * g_test_trap_assert_stdout_unmatched:
28209  * @soutpattern: a glob-style <link linkend="glib-Glob-style-pattern-matching">pattern</link>
28210  *
28211  * Assert that the stdout output of the last test subprocess
28212  * does not match @soutpattern. See g_test_trap_subprocess().
28213  *
28214  * Since: 2.16
28215  */
28216
28217
28218 /**
28219  * g_test_trap_fork:
28220  * @usec_timeout: Timeout for the forked test in micro seconds.
28221  * @test_trap_flags: Flags to modify forking behaviour.
28222  *
28223  * Fork the current test program to execute a test case that might
28224  * not return or that might abort.
28225  *
28226  * If @usec_timeout is non-0, the forked test case is aborted and
28227  * considered failing if its run time exceeds it.
28228  *
28229  * The forking behavior can be configured with the #GTestTrapFlags flags.
28230  *
28231  * In the following example, the test code forks, the forked child
28232  * process produces some sample output and exits successfully.
28233  * The forking parent process then asserts successful child program
28234  * termination and validates child program outputs.
28235  *
28236  * |[
28237  *   static void
28238  *   test_fork_patterns (void)
28239  *   {
28240  *     if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR))
28241  *       {
28242  *         g_print ("some stdout text: somagic17\n");
28243  *         g_printerr ("some stderr text: semagic43\n");
28244  *         exit (0); /&ast; successful test run &ast;/
28245  *       }
28246  *     g_test_trap_assert_passed ();
28247  *     g_test_trap_assert_stdout ("*somagic17*");
28248  *     g_test_trap_assert_stderr ("*semagic43*");
28249  *   }
28250  * ]|
28251  *
28252  * Returns: %TRUE for the forked child and %FALSE for the executing parent process.
28253  * Since: 2.16
28254  * Deprecated: This function is implemented only on Unix platforms, and is not always reliable due to problems inherent in fork-without-exec. Use g_test_trap_subprocess() instead.
28255  */
28256
28257
28258 /**
28259  * g_test_trap_has_passed:
28260  *
28261  * Check the result of the last g_test_trap_subprocess() call.
28262  *
28263  * Returns: %TRUE if the last test subprocess terminated successfully.
28264  * Since: 2.16
28265  */
28266
28267
28268 /**
28269  * g_test_trap_reached_timeout:
28270  *
28271  * Check the result of the last g_test_trap_subprocess() call.
28272  *
28273  * Returns: %TRUE if the last test subprocess got killed due to a timeout.
28274  * Since: 2.16
28275  */
28276
28277
28278 /**
28279  * g_test_trap_subprocess:
28280  * @test_path: Test to run in a subprocess
28281  * @usec_timeout: Timeout for the subprocess test in micro seconds.
28282  * @test_flags: Flags to modify subprocess behaviour.
28283  *
28284  * Respawns the test program to run only @test_path in a subprocess.
28285  * This can be used for a test case that might not return, or that
28286  * might abort. @test_path will normally be the name of the parent
28287  * test, followed by "<literal>/subprocess/</literal>" and then a name
28288  * for the specific subtest (or just ending with
28289  * "<literal>/subprocess</literal>" if the test only has one child
28290  * test); tests with names of this form will automatically be skipped
28291  * in the parent process.
28292  *
28293  * If @usec_timeout is non-0, the test subprocess is aborted and
28294  * considered failing if its run time exceeds it.
28295  *
28296  * The subprocess behavior can be configured with the
28297  * #GTestSubprocessFlags flags.
28298  *
28299  * You can use methods such as g_test_trap_assert_passed(),
28300  * g_test_trap_assert_failed(), and g_test_trap_assert_stderr() to
28301  * check the results of the subprocess. (But note that
28302  * g_test_trap_assert_stdout() and g_test_trap_assert_stderr()
28303  * cannot be used if @test_flags specifies that the child should
28304  * inherit the parent stdout/stderr.)
28305  *
28306  * If your <literal>main ()</literal> needs to behave differently in
28307  * the subprocess, you can call g_test_subprocess() (after calling
28308  * g_test_init()) to see whether you are in a subprocess.
28309  *
28310  * The following example tests that calling
28311  * <literal>my_object_new(1000000)</literal> will abort with an error
28312  * message.
28313  *
28314  * |[
28315  *   static void
28316  *   test_create_large_object_subprocess (void)
28317  *   {
28318  *     my_object_new (1000000);
28319  *   }
28320  *
28321  *   static void
28322  *   test_create_large_object (void)
28323  *   {
28324  *     g_test_trap_subprocess ("/myobject/create_large_object/subprocess", 0, 0);
28325  *     g_test_trap_assert_failed ();
28326  *     g_test_trap_assert_stderr ("*ERROR*too large*");
28327  *   }
28328  *
28329  *   int
28330  *   main (int argc, char **argv)
28331  *   {
28332  *     g_test_init (&argc, &argv, NULL);
28333  *
28334  *     g_test_add_func ("/myobject/create_large_object",
28335  *                      test_create_large_object);
28336  *     /&ast; Because of the '/subprocess' in the name, this test will
28337  *      &ast; not be run by the g_test_run () call below.
28338  *      &ast;/
28339  *     g_test_add_func ("/myobject/create_large_object/subprocess",
28340  *                      test_create_large_object_subprocess);
28341  *
28342  *     return g_test_run ();
28343  *   }
28344  * ]|
28345  *
28346  * Since: 2.38
28347  */
28348
28349
28350 /**
28351  * g_test_undefined:
28352  *
28353  * Returns %TRUE if tests may provoke assertions and other formally-undefined
28354  * behaviour, to verify that appropriate warnings are given. It might, in some
28355  * cases, be useful to turn this off if running tests under valgrind.
28356  *
28357  * Returns: %TRUE if tests may provoke programming errors
28358  */
28359
28360
28361 /**
28362  * g_test_verbose:
28363  *
28364  * Returns %TRUE if tests are run in verbose mode.
28365  * The default is neither g_test_verbose() nor g_test_quiet().
28366  *
28367  * Returns: %TRUE if in verbose mode
28368  */
28369
28370
28371 /**
28372  * g_thread_exit:
28373  * @retval: the return value of this thread
28374  *
28375  * Terminates the current thread.
28376  *
28377  * If another thread is waiting for us using g_thread_join() then the
28378  * waiting thread will be woken up and get @retval as the return value
28379  * of g_thread_join().
28380  *
28381  * Calling <literal>g_thread_exit (retval)</literal> is equivalent to
28382  * returning @retval from the function @func, as given to g_thread_new().
28383  *
28384  * <note><para>
28385  *   You must only call g_thread_exit() from a thread that you created
28386  *   yourself with g_thread_new() or related APIs.  You must not call
28387  *   this function from a thread created with another threading library
28388  *   or or from within a #GThreadPool.
28389  * </para></note>
28390  */
28391
28392
28393 /**
28394  * g_thread_join:
28395  * @thread: a #GThread
28396  *
28397  * Waits until @thread finishes, i.e. the function @func, as
28398  * given to g_thread_new(), returns or g_thread_exit() is called.
28399  * If @thread has already terminated, then g_thread_join()
28400  * returns immediately.
28401  *
28402  * Any thread can wait for any other thread by calling g_thread_join(),
28403  * not just its 'creator'. Calling g_thread_join() from multiple threads
28404  * for the same @thread leads to undefined behaviour.
28405  *
28406  * The value returned by @func or given to g_thread_exit() is
28407  * returned by this function.
28408  *
28409  * g_thread_join() consumes the reference to the passed-in @thread.
28410  * This will usually cause the #GThread struct and associated resources
28411  * to be freed. Use g_thread_ref() to obtain an extra reference if you
28412  * want to keep the GThread alive beyond the g_thread_join() call.
28413  *
28414  * Returns: the return value of the thread
28415  */
28416
28417
28418 /**
28419  * g_thread_new:
28420  * @name: (allow-none): an (optional) name for the new thread
28421  * @func: a function to execute in the new thread
28422  * @data: an argument to supply to the new thread
28423  *
28424  * This function creates a new thread. The new thread starts by invoking
28425  * @func with the argument data. The thread will run until @func returns
28426  * or until g_thread_exit() is called from the new thread. The return value
28427  * of @func becomes the return value of the thread, which can be obtained
28428  * with g_thread_join().
28429  *
28430  * The @name can be useful for discriminating threads in a debugger.
28431  * It is not used for other purposes and does not have to be unique.
28432  * Some systems restrict the length of @name to 16 bytes.
28433  *
28434  * If the thread can not be created the program aborts. See
28435  * g_thread_try_new() if you want to attempt to deal with failures.
28436  *
28437  * To free the struct returned by this function, use g_thread_unref().
28438  * Note that g_thread_join() implicitly unrefs the #GThread as well.
28439  *
28440  * Returns: the new #GThread
28441  * Since: 2.32
28442  */
28443
28444
28445 /**
28446  * g_thread_pool_free:
28447  * @pool: a #GThreadPool
28448  * @immediate: should @pool shut down immediately?
28449  * @wait_: should the function wait for all tasks to be finished?
28450  *
28451  * Frees all resources allocated for @pool.
28452  *
28453  * If @immediate is %TRUE, no new task is processed for @pool.
28454  * Otherwise @pool is not freed before the last task is processed.
28455  * Note however, that no thread of this pool is interrupted while
28456  * processing a task. Instead at least all still running threads
28457  * can finish their tasks before the @pool is freed.
28458  *
28459  * If @wait_ is %TRUE, the functions does not return before all
28460  * tasks to be processed (dependent on @immediate, whether all
28461  * or only the currently running) are ready.
28462  * Otherwise the function returns immediately.
28463  *
28464  * After calling this function @pool must not be used anymore.
28465  */
28466
28467
28468 /**
28469  * g_thread_pool_get_max_idle_time:
28470  *
28471  * This function will return the maximum @interval that a
28472  * thread will wait in the thread pool for new tasks before
28473  * being stopped.
28474  *
28475  * If this function returns 0, threads waiting in the thread
28476  * pool for new work are not stopped.
28477  *
28478  * Returns: the maximum @interval (milliseconds) to wait for new tasks in the thread pool before stopping the thread
28479  * Since: 2.10
28480  */
28481
28482
28483 /**
28484  * g_thread_pool_get_max_threads:
28485  * @pool: a #GThreadPool
28486  *
28487  * Returns the maximal number of threads for @pool.
28488  *
28489  * Returns: the maximal number of threads
28490  */
28491
28492
28493 /**
28494  * g_thread_pool_get_max_unused_threads:
28495  *
28496  * Returns the maximal allowed number of unused threads.
28497  *
28498  * Returns: the maximal number of unused threads
28499  */
28500
28501
28502 /**
28503  * g_thread_pool_get_num_threads:
28504  * @pool: a #GThreadPool
28505  *
28506  * Returns the number of threads currently running in @pool.
28507  *
28508  * Returns: the number of threads currently running
28509  */
28510
28511
28512 /**
28513  * g_thread_pool_get_num_unused_threads:
28514  *
28515  * Returns the number of currently unused threads.
28516  *
28517  * Returns: the number of currently unused threads
28518  */
28519
28520
28521 /**
28522  * g_thread_pool_new:
28523  * @func: a function to execute in the threads of the new thread pool
28524  * @user_data: user data that is handed over to @func every time it is called
28525  * @max_threads: the maximal number of threads to execute concurrently in  the new thread pool, -1 means no limit
28526  * @exclusive: should this thread pool be exclusive?
28527  * @error: return location for error, or %NULL
28528  *
28529  * This function creates a new thread pool.
28530  *
28531  * Whenever you call g_thread_pool_push(), either a new thread is
28532  * created or an unused one is reused. At most @max_threads threads
28533  * are running concurrently for this thread pool. @max_threads = -1
28534  * allows unlimited threads to be created for this thread pool. The
28535  * newly created or reused thread now executes the function @func
28536  * with the two arguments. The first one is the parameter to
28537  * g_thread_pool_push() and the second one is @user_data.
28538  *
28539  * The parameter @exclusive determines whether the thread pool owns
28540  * all threads exclusive or shares them with other thread pools.
28541  * If @exclusive is %TRUE, @max_threads threads are started
28542  * immediately and they will run exclusively for this thread pool
28543  * until it is destroyed by g_thread_pool_free(). If @exclusive is
28544  * %FALSE, threads are created when needed and shared between all
28545  * non-exclusive thread pools. This implies that @max_threads may
28546  * not be -1 for exclusive thread pools.
28547  *
28548  * @error can be %NULL to ignore errors, or non-%NULL to report
28549  * errors. An error can only occur when @exclusive is set to %TRUE
28550  * and not all @max_threads threads could be created.
28551  *
28552  * Returns: the new #GThreadPool
28553  */
28554
28555
28556 /**
28557  * g_thread_pool_push:
28558  * @pool: a #GThreadPool
28559  * @data: a new task for @pool
28560  * @error: return location for error, or %NULL
28561  *
28562  * Inserts @data into the list of tasks to be executed by @pool.
28563  *
28564  * When the number of currently running threads is lower than the
28565  * maximal allowed number of threads, a new thread is started (or
28566  * reused) with the properties given to g_thread_pool_new().
28567  * Otherwise, @data stays in the queue until a thread in this pool
28568  * finishes its previous task and processes @data.
28569  *
28570  * @error can be %NULL to ignore errors, or non-%NULL to report
28571  * errors. An error can only occur when a new thread couldn't be
28572  * created. In that case @data is simply appended to the queue of
28573  * work to do.
28574  *
28575  * Before version 2.32, this function did not return a success status.
28576  *
28577  * Returns: %TRUE on success, %FALSE if an error occurred
28578  */
28579
28580
28581 /**
28582  * g_thread_pool_set_max_idle_time:
28583  * @interval: the maximum @interval (in milliseconds) a thread can be idle
28584  *
28585  * This function will set the maximum @interval that a thread
28586  * waiting in the pool for new tasks can be idle for before
28587  * being stopped. This function is similar to calling
28588  * g_thread_pool_stop_unused_threads() on a regular timeout,
28589  * except this is done on a per thread basis.
28590  *
28591  * By setting @interval to 0, idle threads will not be stopped.
28592  *
28593  * The default value is 15000 (15 seconds).
28594  *
28595  * Since: 2.10
28596  */
28597
28598
28599 /**
28600  * g_thread_pool_set_max_threads:
28601  * @pool: a #GThreadPool
28602  * @max_threads: a new maximal number of threads for @pool, or -1 for unlimited
28603  * @error: return location for error, or %NULL
28604  *
28605  * Sets the maximal allowed number of threads for @pool.
28606  * A value of -1 means that the maximal number of threads
28607  * is unlimited. If @pool is an exclusive thread pool, setting
28608  * the maximal number of threads to -1 is not allowed.
28609  *
28610  * Setting @max_threads to 0 means stopping all work for @pool.
28611  * It is effectively frozen until @max_threads is set to a non-zero
28612  * value again.
28613  *
28614  * A thread is never terminated while calling @func, as supplied by
28615  * g_thread_pool_new(). Instead the maximal number of threads only
28616  * has effect for the allocation of new threads in g_thread_pool_push().
28617  * A new thread is allocated, whenever the number of currently
28618  * running threads in @pool is smaller than the maximal number.
28619  *
28620  * @error can be %NULL to ignore errors, or non-%NULL to report
28621  * errors. An error can only occur when a new thread couldn't be
28622  * created.
28623  *
28624  * Before version 2.32, this function did not return a success status.
28625  *
28626  * Returns: %TRUE on success, %FALSE if an error occurred
28627  */
28628
28629
28630 /**
28631  * g_thread_pool_set_max_unused_threads:
28632  * @max_threads: maximal number of unused threads
28633  *
28634  * Sets the maximal number of unused threads to @max_threads.
28635  * If @max_threads is -1, no limit is imposed on the number
28636  * of unused threads.
28637  *
28638  * The default value is 2.
28639  */
28640
28641
28642 /**
28643  * g_thread_pool_set_sort_function:
28644  * @pool: a #GThreadPool
28645  * @func: the #GCompareDataFunc used to sort the list of tasks. This function is passed two tasks. It should return 0 if the order in which they are handled does not matter, a negative value if the first task should be processed before the second or a positive value if the second task should be processed first.
28646  * @user_data: user data passed to @func
28647  *
28648  * Sets the function used to sort the list of tasks. This allows the
28649  * tasks to be processed by a priority determined by @func, and not
28650  * just in the order in which they were added to the pool.
28651  *
28652  * Note, if the maximum number of threads is more than 1, the order
28653  * that threads are executed cannot be guaranteed 100%. Threads are
28654  * scheduled by the operating system and are executed at random. It
28655  * cannot be assumed that threads are executed in the order they are
28656  * created.
28657  *
28658  * Since: 2.10
28659  */
28660
28661
28662 /**
28663  * g_thread_pool_stop_unused_threads:
28664  *
28665  * Stops all currently unused threads. This does not change the
28666  * maximal number of unused threads. This function can be used to
28667  * regularly stop all unused threads e.g. from g_timeout_add().
28668  */
28669
28670
28671 /**
28672  * g_thread_pool_unprocessed:
28673  * @pool: a #GThreadPool
28674  *
28675  * Returns the number of tasks still unprocessed in @pool.
28676  *
28677  * Returns: the number of unprocessed tasks
28678  */
28679
28680
28681 /**
28682  * g_thread_ref:
28683  * @thread: a #GThread
28684  *
28685  * Increase the reference count on @thread.
28686  *
28687  * Returns: a new reference to @thread
28688  * Since: 2.32
28689  */
28690
28691
28692 /**
28693  * g_thread_self:
28694  *
28695  * This functions returns the #GThread corresponding to the
28696  * current thread. Note that this function does not increase
28697  * the reference count of the returned struct.
28698  *
28699  * This function will return a #GThread even for threads that
28700  * were not created by GLib (i.e. those created by other threading
28701  * APIs). This may be useful for thread identification purposes
28702  * (i.e. comparisons) but you must not use GLib functions (such
28703  * as g_thread_join()) on these threads.
28704  *
28705  * Returns: the #GThread representing the current thread
28706  */
28707
28708
28709 /**
28710  * g_thread_supported:
28711  *
28712  * This macro returns %TRUE if the thread system is initialized,
28713  * and %FALSE if it is not.
28714  *
28715  * For language bindings, g_thread_get_initialized() provides
28716  * the same functionality as a function.
28717  *
28718  * Returns: %TRUE, if the thread system is initialized
28719  */
28720
28721
28722 /**
28723  * g_thread_try_new:
28724  * @name: (allow-none): an (optional) name for the new thread
28725  * @func: a function to execute in the new thread
28726  * @data: an argument to supply to the new thread
28727  * @error: return location for error, or %NULL
28728  *
28729  * This function is the same as g_thread_new() except that
28730  * it allows for the possibility of failure.
28731  *
28732  * If a thread can not be created (due to resource limits),
28733  * @error is set and %NULL is returned.
28734  *
28735  * Returns: the new #GThread, or %NULL if an error occurred
28736  * Since: 2.32
28737  */
28738
28739
28740 /**
28741  * g_thread_unref:
28742  * @thread: a #GThread
28743  *
28744  * Decrease the reference count on @thread, possibly freeing all
28745  * resources associated with it.
28746  *
28747  * Note that each thread holds a reference to its #GThread while
28748  * it is running, so it is safe to drop your own reference to it
28749  * if you don't need it anymore.
28750  *
28751  * Since: 2.32
28752  */
28753
28754
28755 /**
28756  * g_thread_yield:
28757  *
28758  * Causes the calling thread to voluntarily relinquish the CPU, so
28759  * that other threads can run.
28760  *
28761  * This function is often used as a method to make busy wait less evil.
28762  */
28763
28764
28765 /**
28766  * g_time_val_add:
28767  * @time_: a #GTimeVal
28768  * @microseconds: number of microseconds to add to @time
28769  *
28770  * Adds the given number of microseconds to @time_. @microseconds can
28771  * also be negative to decrease the value of @time_.
28772  */
28773
28774
28775 /**
28776  * g_time_val_from_iso8601:
28777  * @iso_date: an ISO 8601 encoded date string
28778  * @time_: (out): a #GTimeVal
28779  *
28780  * Converts a string containing an ISO 8601 encoded date and time
28781  * to a #GTimeVal and puts it into @time_.
28782  *
28783  * @iso_date must include year, month, day, hours, minutes, and
28784  * seconds. It can optionally include fractions of a second and a time
28785  * zone indicator. (In the absence of any time zone indication, the
28786  * timestamp is assumed to be in local time.)
28787  *
28788  * Returns: %TRUE if the conversion was successful.
28789  * Since: 2.12
28790  */
28791
28792
28793 /**
28794  * g_time_val_to_iso8601:
28795  * @time_: a #GTimeVal
28796  *
28797  * Converts @time_ into an RFC 3339 encoded string, relative to the
28798  * Coordinated Universal Time (UTC). This is one of the many formats
28799  * allowed by ISO 8601.
28800  *
28801  * ISO 8601 allows a large number of date/time formats, with or without
28802  * punctuation and optional elements. The format returned by this function
28803  * is a complete date and time, with optional punctuation included, the
28804  * UTC time zone represented as "Z", and the @tv_usec part included if
28805  * and only if it is nonzero, i.e. either
28806  * "YYYY-MM-DDTHH:MM:SSZ" or "YYYY-MM-DDTHH:MM:SS.fffffZ".
28807  *
28808  * This corresponds to the Internet date/time format defined by
28809  * <ulink url="https://www.ietf.org/rfc/rfc3339.txt">RFC 3339</ulink>, and
28810  * to either of the two most-precise formats defined by
28811  * <ulink url="http://www.w3.org/TR/NOTE-datetime-19980827">the W3C Note
28812  * "Date and Time Formats"</ulink>. Both of these documents are profiles of
28813  * ISO 8601.
28814  *
28815  * Use g_date_time_format() or g_strdup_printf() if a different
28816  * variation of ISO 8601 format is required.
28817  *
28818  * Returns: a newly allocated string containing an ISO 8601 date
28819  * Since: 2.12
28820  */
28821
28822
28823 /**
28824  * g_time_zone_adjust_time:
28825  * @tz: a #GTimeZone
28826  * @type: the #GTimeType of @time_
28827  * @time_: a pointer to a number of seconds since January 1, 1970
28828  *
28829  * Finds an interval within @tz that corresponds to the given @time_,
28830  * possibly adjusting @time_ if required to fit into an interval.
28831  * The meaning of @time_ depends on @type.
28832  *
28833  * This function is similar to g_time_zone_find_interval(), with the
28834  * difference that it always succeeds (by making the adjustments
28835  * described below).
28836  *
28837  * In any of the cases where g_time_zone_find_interval() succeeds then
28838  * this function returns the same value, without modifying @time_.
28839  *
28840  * This function may, however, modify @time_ in order to deal with
28841  * non-existent times.  If the non-existent local @time_ of 02:30 were
28842  * requested on March 14th 2010 in Toronto then this function would
28843  * adjust @time_ to be 03:00 and return the interval containing the
28844  * adjusted time.
28845  *
28846  * Returns: the interval containing @time_, never -1
28847  * Since: 2.26
28848  */
28849
28850
28851 /**
28852  * g_time_zone_find_interval:
28853  * @tz: a #GTimeZone
28854  * @type: the #GTimeType of @time_
28855  * @time_: a number of seconds since January 1, 1970
28856  *
28857  * Finds an the interval within @tz that corresponds to the given @time_.
28858  * The meaning of @time_ depends on @type.
28859  *
28860  * If @type is %G_TIME_TYPE_UNIVERSAL then this function will always
28861  * succeed (since universal time is monotonic and continuous).
28862  *
28863  * Otherwise @time_ is treated is local time.  The distinction between
28864  * %G_TIME_TYPE_STANDARD and %G_TIME_TYPE_DAYLIGHT is ignored except in
28865  * the case that the given @time_ is ambiguous.  In Toronto, for example,
28866  * 01:30 on November 7th 2010 occurred twice (once inside of daylight
28867  * savings time and the next, an hour later, outside of daylight savings
28868  * time).  In this case, the different value of @type would result in a
28869  * different interval being returned.
28870  *
28871  * It is still possible for this function to fail.  In Toronto, for
28872  * example, 02:00 on March 14th 2010 does not exist (due to the leap
28873  * forward to begin daylight savings time).  -1 is returned in that
28874  * case.
28875  *
28876  * Returns: the interval containing @time_, or -1 in case of failure
28877  * Since: 2.26
28878  */
28879
28880
28881 /**
28882  * g_time_zone_get_abbreviation:
28883  * @tz: a #GTimeZone
28884  * @interval: an interval within the timezone
28885  *
28886  * Determines the time zone abbreviation to be used during a particular
28887  * @interval of time in the time zone @tz.
28888  *
28889  * For example, in Toronto this is currently "EST" during the winter
28890  * months and "EDT" during the summer months when daylight savings time
28891  * is in effect.
28892  *
28893  * Returns: the time zone abbreviation, which belongs to @tz
28894  * Since: 2.26
28895  */
28896
28897
28898 /**
28899  * g_time_zone_get_offset:
28900  * @tz: a #GTimeZone
28901  * @interval: an interval within the timezone
28902  *
28903  * Determines the offset to UTC in effect during a particular @interval
28904  * of time in the time zone @tz.
28905  *
28906  * The offset is the number of seconds that you add to UTC time to
28907  * arrive at local time for @tz (ie: negative numbers for time zones
28908  * west of GMT, positive numbers for east).
28909  *
28910  * Returns: the number of seconds that should be added to UTC to get the local time in @tz
28911  * Since: 2.26
28912  */
28913
28914
28915 /**
28916  * g_time_zone_is_dst:
28917  * @tz: a #GTimeZone
28918  * @interval: an interval within the timezone
28919  *
28920  * Determines if daylight savings time is in effect during a particular
28921  * @interval of time in the time zone @tz.
28922  *
28923  * Returns: %TRUE if daylight savings time is in effect
28924  * Since: 2.26
28925  */
28926
28927
28928 /**
28929  * g_time_zone_new:
28930  * @identifier: (allow-none): a timezone identifier
28931  *
28932  * Creates a #GTimeZone corresponding to @identifier.
28933  *
28934  * @identifier can either be an RFC3339/ISO 8601 time offset or
28935  * something that would pass as a valid value for the
28936  * <varname>TZ</varname> environment variable (including %NULL).
28937  *
28938  * In Windows, @identifier can also be the unlocalized name of a time
28939  * zone for standard time, for example "Pacific Standard Time".
28940  *
28941  * Valid RFC3339 time offsets are <literal>"Z"</literal> (for UTC) or
28942  * <literal>"±hh:mm"</literal>.  ISO 8601 additionally specifies
28943  * <literal>"±hhmm"</literal> and <literal>"±hh"</literal>.  Offsets are
28944  * time values to be added to Coordinated Universal Time (UTC) to get
28945  * the local time.
28946  *
28947  * In Unix, the <varname>TZ</varname> environment variable typically
28948  * corresponds to the name of a file in the zoneinfo database, or
28949  * string in "std offset [dst [offset],start[/time],end[/time]]"
28950  * (POSIX) format.  There  are  no spaces in the specification.  The
28951  * name of standard and daylight savings time zone must be three or more
28952  * alphabetic characters.  Offsets are time values to be added to local
28953  * time to get Coordinated Universal Time (UTC) and should be
28954  * <literal>"[±]hh[[:]mm[:ss]]"</literal>.  Dates are either
28955  * <literal>"Jn"</literal> (Julian day with n between 1 and 365, leap
28956  * years not counted), <literal>"n"</literal> (zero-based Julian day
28957  * with n between 0 and 365) or <literal>"Mm.w.d"</literal> (day d
28958  * (0 <= d <= 6) of week w (1 <= w <= 5) of month m (1 <= m <= 12), day
28959  * 0 is a Sunday).  Times are in local wall clock time, the default is
28960  * 02:00:00.
28961  *
28962  * In Windows, the "tzn[+|–]hh[:mm[:ss]][dzn]" format is used, but also
28963  * accepts POSIX format.  The Windows format uses US rules for all time
28964  * zones; daylight savings time is 60 minutes behind the standard time
28965  * with date and time of change taken from Pacific Standard Time.
28966  * Offsets are time values to be added to the local time to get
28967  * Coordinated Universal Time (UTC).
28968  *
28969  * g_time_zone_new_local() calls this function with the value of the
28970  * <varname>TZ</varname> environment variable.  This function itself is
28971  * independent of the value of <varname>TZ</varname>, but if @identifier
28972  * is %NULL then <filename>/etc/localtime</filename> will be consulted
28973  * to discover the correct time zone on Unix and the registry will be
28974  * consulted or GetTimeZoneInformation() will be used to get the local
28975  * time zone on Windows.
28976  *
28977  * If intervals are not available, only time zone rules from
28978  * <varname>TZ</varname> environment variable or other means, then they
28979  * will be computed from year 1900 to 2037.  If the maximum year for the
28980  * rules is available and it is greater than 2037, then it will followed
28981  * instead.
28982  *
28983  * See <ulink
28984  * url='http://tools.ietf.org/html/rfc3339#section-5.6'>RFC3339
28985  * Â§5.6</ulink> for a precise definition of valid RFC3339 time offsets
28986  * (the <varname>time-offset</varname> expansion) and ISO 8601 for the
28987  * full list of valid time offsets.  See <ulink
28988  * url='http://www.gnu.org/s/libc/manual/html_node/TZ-Variable.html'>The
28989  * GNU C Library manual</ulink> for an explanation of the possible
28990  * values of the <varname>TZ</varname> environment variable.  See <ulink
28991  * url='http://msdn.microsoft.com/en-us/library/ms912391%28v=winembedded.11%29.aspx'>
28992  * Microsoft Time Zone Index Values</ulink> for the list of time zones
28993  * on Windows.
28994  *
28995  * You should release the return value by calling g_time_zone_unref()
28996  * when you are done with it.
28997  *
28998  * Returns: the requested timezone
28999  * Since: 2.26
29000  */
29001
29002
29003 /**
29004  * g_time_zone_new_local:
29005  *
29006  * Creates a #GTimeZone corresponding to local time.  The local time
29007  * zone may change between invocations to this function; for example,
29008  * if the system administrator changes it.
29009  *
29010  * This is equivalent to calling g_time_zone_new() with the value of the
29011  * <varname>TZ</varname> environment variable (including the possibility
29012  * of %NULL).
29013  *
29014  * You should release the return value by calling g_time_zone_unref()
29015  * when you are done with it.
29016  *
29017  * Returns: the local timezone
29018  * Since: 2.26
29019  */
29020
29021
29022 /**
29023  * g_time_zone_new_utc:
29024  *
29025  * Creates a #GTimeZone corresponding to UTC.
29026  *
29027  * This is equivalent to calling g_time_zone_new() with a value like
29028  * "Z", "UTC", "+00", etc.
29029  *
29030  * You should release the return value by calling g_time_zone_unref()
29031  * when you are done with it.
29032  *
29033  * Returns: the universal timezone
29034  * Since: 2.26
29035  */
29036
29037
29038 /**
29039  * g_time_zone_ref:
29040  * @tz: a #GTimeZone
29041  *
29042  * Increases the reference count on @tz.
29043  *
29044  * Returns: a new reference to @tz.
29045  * Since: 2.26
29046  */
29047
29048
29049 /**
29050  * g_time_zone_unref:
29051  * @tz: a #GTimeZone
29052  *
29053  * Decreases the reference count on @tz.
29054  *
29055  * Since: 2.26
29056  */
29057
29058
29059 /**
29060  * g_timeout_add:
29061  * @interval: the time between calls to the function, in milliseconds (1/1000ths of a second)
29062  * @function: function to call
29063  * @data: data to pass to @function
29064  *
29065  * Sets a function to be called at regular intervals, with the default
29066  * priority, #G_PRIORITY_DEFAULT.  The function is called repeatedly
29067  * until it returns %FALSE, at which point the timeout is automatically
29068  * destroyed and the function will not be called again.  The first call
29069  * to the function will be at the end of the first @interval.
29070  *
29071  * Note that timeout functions may be delayed, due to the processing of other
29072  * event sources. Thus they should not be relied on for precise timing.
29073  * After each call to the timeout function, the time of the next
29074  * timeout is recalculated based on the current time and the given interval
29075  * (it does not try to 'catch up' time lost in delays).
29076  *
29077  * If you want to have a timer in the "seconds" range and do not care
29078  * about the exact time of the first call of the timer, use the
29079  * g_timeout_add_seconds() function; this function allows for more
29080  * optimizations and more efficient system power usage.
29081  *
29082  * This internally creates a main loop source using g_timeout_source_new()
29083  * and attaches it to the main loop context using g_source_attach(). You can
29084  * do these steps manually if you need greater control.
29085  *
29086  * The interval given is in terms of monotonic time, not wall clock
29087  * time.  See g_get_monotonic_time().
29088  *
29089  * Returns: the ID (greater than 0) of the event source.
29090  */
29091
29092
29093 /**
29094  * g_timeout_add_full:
29095  * @priority: the priority of the timeout source. Typically this will be in the range between #G_PRIORITY_DEFAULT and #G_PRIORITY_HIGH.
29096  * @interval: the time between calls to the function, in milliseconds (1/1000ths of a second)
29097  * @function: function to call
29098  * @data: data to pass to @function
29099  * @notify: (allow-none): function to call when the timeout is removed, or %NULL
29100  *
29101  * Sets a function to be called at regular intervals, with the given
29102  * priority.  The function is called repeatedly until it returns
29103  * %FALSE, at which point the timeout is automatically destroyed and
29104  * the function will not be called again.  The @notify function is
29105  * called when the timeout is destroyed.  The first call to the
29106  * function will be at the end of the first @interval.
29107  *
29108  * Note that timeout functions may be delayed, due to the processing of other
29109  * event sources. Thus they should not be relied on for precise timing.
29110  * After each call to the timeout function, the time of the next
29111  * timeout is recalculated based on the current time and the given interval
29112  * (it does not try to 'catch up' time lost in delays).
29113  *
29114  * This internally creates a main loop source using g_timeout_source_new()
29115  * and attaches it to the main loop context using g_source_attach(). You can
29116  * do these steps manually if you need greater control.
29117  *
29118  * The interval given in terms of monotonic time, not wall clock time.
29119  * See g_get_monotonic_time().
29120  *
29121  * Returns: the ID (greater than 0) of the event source.
29122  * Rename to: g_timeout_add
29123  */
29124
29125
29126 /**
29127  * g_timeout_add_seconds:
29128  * @interval: the time between calls to the function, in seconds
29129  * @function: function to call
29130  * @data: data to pass to @function
29131  *
29132  * Sets a function to be called at regular intervals with the default
29133  * priority, #G_PRIORITY_DEFAULT. The function is called repeatedly until
29134  * it returns %FALSE, at which point the timeout is automatically destroyed
29135  * and the function will not be called again.
29136  *
29137  * This internally creates a main loop source using
29138  * g_timeout_source_new_seconds() and attaches it to the main loop context
29139  * using g_source_attach(). You can do these steps manually if you need
29140  * greater control. Also see g_timeout_add_seconds_full().
29141  *
29142  * Note that the first call of the timer may not be precise for timeouts
29143  * of one second. If you need finer precision and have such a timeout,
29144  * you may want to use g_timeout_add() instead.
29145  *
29146  * The interval given is in terms of monotonic time, not wall clock
29147  * time.  See g_get_monotonic_time().
29148  *
29149  * Returns: the ID (greater than 0) of the event source.
29150  * Since: 2.14
29151  */
29152
29153
29154 /**
29155  * g_timeout_add_seconds_full:
29156  * @priority: the priority of the timeout source. Typically this will be in the range between #G_PRIORITY_DEFAULT and #G_PRIORITY_HIGH.
29157  * @interval: the time between calls to the function, in seconds
29158  * @function: function to call
29159  * @data: data to pass to @function
29160  * @notify: (allow-none): function to call when the timeout is removed, or %NULL
29161  *
29162  * Sets a function to be called at regular intervals, with @priority.
29163  * The function is called repeatedly until it returns %FALSE, at which
29164  * point the timeout is automatically destroyed and the function will
29165  * not be called again.
29166  *
29167  * Unlike g_timeout_add(), this function operates at whole second granularity.
29168  * The initial starting point of the timer is determined by the implementation
29169  * and the implementation is expected to group multiple timers together so that
29170  * they fire all at the same time.
29171  * To allow this grouping, the @interval to the first timer is rounded
29172  * and can deviate up to one second from the specified interval.
29173  * Subsequent timer iterations will generally run at the specified interval.
29174  *
29175  * Note that timeout functions may be delayed, due to the processing of other
29176  * event sources. Thus they should not be relied on for precise timing.
29177  * After each call to the timeout function, the time of the next
29178  * timeout is recalculated based on the current time and the given @interval
29179  *
29180  * If you want timing more precise than whole seconds, use g_timeout_add()
29181  * instead.
29182  *
29183  * The grouping of timers to fire at the same time results in a more power
29184  * and CPU efficient behavior so if your timer is in multiples of seconds
29185  * and you don't require the first timer exactly one second from now, the
29186  * use of g_timeout_add_seconds() is preferred over g_timeout_add().
29187  *
29188  * This internally creates a main loop source using
29189  * g_timeout_source_new_seconds() and attaches it to the main loop context
29190  * using g_source_attach(). You can do these steps manually if you need
29191  * greater control.
29192  *
29193  * The interval given is in terms of monotonic time, not wall clock
29194  * time.  See g_get_monotonic_time().
29195  *
29196  * Returns: the ID (greater than 0) of the event source.
29197  * Rename to: g_timeout_add_seconds
29198  * Since: 2.14
29199  */
29200
29201
29202 /**
29203  * g_timeout_source_new:
29204  * @interval: the timeout interval in milliseconds.
29205  *
29206  * Creates a new timeout source.
29207  *
29208  * The source will not initially be associated with any #GMainContext
29209  * and must be added to one with g_source_attach() before it will be
29210  * executed.
29211  *
29212  * The interval given is in terms of monotonic time, not wall clock
29213  * time.  See g_get_monotonic_time().
29214  *
29215  * Returns: the newly-created timeout source
29216  */
29217
29218
29219 /**
29220  * g_timeout_source_new_seconds:
29221  * @interval: the timeout interval in seconds
29222  *
29223  * Creates a new timeout source.
29224  *
29225  * The source will not initially be associated with any #GMainContext
29226  * and must be added to one with g_source_attach() before it will be
29227  * executed.
29228  *
29229  * The scheduling granularity/accuracy of this timeout source will be
29230  * in seconds.
29231  *
29232  * The interval given in terms of monotonic time, not wall clock time.
29233  * See g_get_monotonic_time().
29234  *
29235  * Returns: the newly-created timeout source
29236  * Since: 2.14
29237  */
29238
29239
29240 /**
29241  * g_timer_continue:
29242  * @timer: a #GTimer.
29243  *
29244  * Resumes a timer that has previously been stopped with
29245  * g_timer_stop(). g_timer_stop() must be called before using this
29246  * function.
29247  *
29248  * Since: 2.4
29249  */
29250
29251
29252 /**
29253  * g_timer_destroy:
29254  * @timer: a #GTimer to destroy.
29255  *
29256  * Destroys a timer, freeing associated resources.
29257  */
29258
29259
29260 /**
29261  * g_timer_elapsed:
29262  * @timer: a #GTimer.
29263  * @microseconds: return location for the fractional part of seconds elapsed, in microseconds (that is, the total number of microseconds elapsed, modulo 1000000), or %NULL
29264  *
29265  * If @timer has been started but not stopped, obtains the time since
29266  * the timer was started. If @timer has been stopped, obtains the
29267  * elapsed time between the time it was started and the time it was
29268  * stopped. The return value is the number of seconds elapsed,
29269  * including any fractional part. The @microseconds out parameter is
29270  * essentially useless.
29271  *
29272  * Returns: seconds elapsed as a floating point value, including any fractional part.
29273  */
29274
29275
29276 /**
29277  * g_timer_new:
29278  *
29279  * Creates a new timer, and starts timing (i.e. g_timer_start() is
29280  * implicitly called for you).
29281  *
29282  * Returns: a new #GTimer.
29283  */
29284
29285
29286 /**
29287  * g_timer_reset:
29288  * @timer: a #GTimer.
29289  *
29290  * This function is useless; it's fine to call g_timer_start() on an
29291  * already-started timer to reset the start time, so g_timer_reset()
29292  * serves no purpose.
29293  */
29294
29295
29296 /**
29297  * g_timer_start:
29298  * @timer: a #GTimer.
29299  *
29300  * Marks a start time, so that future calls to g_timer_elapsed() will
29301  * report the time since g_timer_start() was called. g_timer_new()
29302  * automatically marks the start time, so no need to call
29303  * g_timer_start() immediately after creating the timer.
29304  */
29305
29306
29307 /**
29308  * g_timer_stop:
29309  * @timer: a #GTimer.
29310  *
29311  * Marks an end time, so calls to g_timer_elapsed() will return the
29312  * difference between this end time and the start time.
29313  */
29314
29315
29316 /**
29317  * g_trash_stack_height:
29318  * @stack_p: a #GTrashStack
29319  *
29320  * Returns the height of a #GTrashStack.
29321  *
29322  * Note that execution of this function is of O(N) complexity
29323  * where N denotes the number of items on the stack.
29324  *
29325  * Returns: the height of the stack
29326  */
29327
29328
29329 /**
29330  * g_trash_stack_peek:
29331  * @stack_p: a #GTrashStack
29332  *
29333  * Returns the element at the top of a #GTrashStack
29334  * which may be %NULL.
29335  *
29336  * Returns: the element at the top of the stack
29337  */
29338
29339
29340 /**
29341  * g_trash_stack_pop:
29342  * @stack_p: a #GTrashStack
29343  *
29344  * Pops a piece of memory off a #GTrashStack.
29345  *
29346  * Returns: the element at the top of the stack
29347  */
29348
29349
29350 /**
29351  * g_trash_stack_push:
29352  * @stack_p: a #GTrashStack
29353  * @data_p: the piece of memory to push on the stack
29354  *
29355  * Pushes a piece of memory onto a #GTrashStack.
29356  */
29357
29358
29359 /**
29360  * g_tree_destroy:
29361  * @tree: a #GTree.
29362  *
29363  * Removes all keys and values from the #GTree and decreases its
29364  * reference count by one. If keys and/or values are dynamically
29365  * allocated, you should either free them first or create the #GTree
29366  * using g_tree_new_full().  In the latter case the destroy functions
29367  * you supplied will be called on all keys and values before destroying
29368  * the #GTree.
29369  */
29370
29371
29372 /**
29373  * g_tree_foreach:
29374  * @tree: a #GTree.
29375  * @func: the function to call for each node visited. If this function returns %TRUE, the traversal is stopped.
29376  * @user_data: user data to pass to the function.
29377  *
29378  * Calls the given function for each of the key/value pairs in the #GTree.
29379  * The function is passed the key and value of each pair, and the given
29380  * @data parameter. The tree is traversed in sorted order.
29381  *
29382  * The tree may not be modified while iterating over it (you can't
29383  * add/remove items). To remove all items matching a predicate, you need
29384  * to add each item to a list in your #GTraverseFunc as you walk over
29385  * the tree, then walk the list and remove each item.
29386  */
29387
29388
29389 /**
29390  * g_tree_height:
29391  * @tree: a #GTree.
29392  *
29393  * Gets the height of a #GTree.
29394  *
29395  * If the #GTree contains no nodes, the height is 0.
29396  * If the #GTree contains only one root node the height is 1.
29397  * If the root node has children the height is 2, etc.
29398  *
29399  * Returns: the height of the #GTree.
29400  */
29401
29402
29403 /**
29404  * g_tree_insert:
29405  * @tree: a #GTree.
29406  * @key: the key to insert.
29407  * @value: the value corresponding to the key.
29408  *
29409  * Inserts a key/value pair into a #GTree. If the given key already exists
29410  * in the #GTree its corresponding value is set to the new value. If you
29411  * supplied a value_destroy_func when creating the #GTree, the old value is
29412  * freed using that function. If you supplied a @key_destroy_func when
29413  * creating the #GTree, the passed key is freed using that function.
29414  *
29415  * The tree is automatically 'balanced' as new key/value pairs are added,
29416  * so that the distance from the root to every leaf is as small as possible.
29417  */
29418
29419
29420 /**
29421  * g_tree_lookup:
29422  * @tree: a #GTree.
29423  * @key: the key to look up.
29424  *
29425  * Gets the value corresponding to the given key. Since a #GTree is
29426  * automatically balanced as key/value pairs are added, key lookup is very
29427  * fast.
29428  *
29429  * Returns: the value corresponding to the key, or %NULL if the key was not found.
29430  */
29431
29432
29433 /**
29434  * g_tree_lookup_extended:
29435  * @tree: a #GTree.
29436  * @lookup_key: the key to look up.
29437  * @orig_key: returns the original key.
29438  * @value: returns the value associated with the key.
29439  *
29440  * Looks up a key in the #GTree, returning the original key and the
29441  * associated value and a #gboolean which is %TRUE if the key was found. This
29442  * is useful if you need to free the memory allocated for the original key,
29443  * for example before calling g_tree_remove().
29444  *
29445  * Returns: %TRUE if the key was found in the #GTree.
29446  */
29447
29448
29449 /**
29450  * g_tree_new:
29451  * @key_compare_func: the function used to order the nodes in the #GTree. It should return values similar to the standard strcmp() function - 0 if the two arguments are equal, a negative value if the first argument comes before the second, or a positive value if the first argument comes after the second.
29452  *
29453  * Creates a new #GTree.
29454  *
29455  * Returns: a new #GTree.
29456  */
29457
29458
29459 /**
29460  * g_tree_new_full:
29461  * @key_compare_func: qsort()-style comparison function.
29462  * @key_compare_data: data to pass to comparison function.
29463  * @key_destroy_func: a function to free the memory allocated for the key used when removing the entry from the #GTree or %NULL if you don't want to supply such a function.
29464  * @value_destroy_func: a function to free the memory allocated for the value used when removing the entry from the #GTree or %NULL if you don't want to supply such a function.
29465  *
29466  * Creates a new #GTree like g_tree_new() and allows to specify functions
29467  * to free the memory allocated for the key and value that get called when
29468  * removing the entry from the #GTree.
29469  *
29470  * Returns: a new #GTree.
29471  */
29472
29473
29474 /**
29475  * g_tree_new_with_data:
29476  * @key_compare_func: qsort()-style comparison function.
29477  * @key_compare_data: data to pass to comparison function.
29478  *
29479  * Creates a new #GTree with a comparison function that accepts user data.
29480  * See g_tree_new() for more details.
29481  *
29482  * Returns: a new #GTree.
29483  */
29484
29485
29486 /**
29487  * g_tree_nnodes:
29488  * @tree: a #GTree.
29489  *
29490  * Gets the number of nodes in a #GTree.
29491  *
29492  * Returns: the number of nodes in the #GTree.
29493  */
29494
29495
29496 /**
29497  * g_tree_ref:
29498  * @tree: a #GTree.
29499  *
29500  * Increments the reference count of @tree by one.  It is safe to call
29501  * this function from any thread.
29502  *
29503  * Returns: the passed in #GTree.
29504  * Since: 2.22
29505  */
29506
29507
29508 /**
29509  * g_tree_remove:
29510  * @tree: a #GTree.
29511  * @key: the key to remove.
29512  *
29513  * Removes a key/value pair from a #GTree.
29514  *
29515  * If the #GTree was created using g_tree_new_full(), the key and value
29516  * are freed using the supplied destroy functions, otherwise you have to
29517  * make sure that any dynamically allocated values are freed yourself.
29518  * If the key does not exist in the #GTree, the function does nothing.
29519  *
29520  * Returns: %TRUE if the key was found (prior to 2.8, this function returned nothing)
29521  */
29522
29523
29524 /**
29525  * g_tree_replace:
29526  * @tree: a #GTree.
29527  * @key: the key to insert.
29528  * @value: the value corresponding to the key.
29529  *
29530  * Inserts a new key and value into a #GTree similar to g_tree_insert().
29531  * The difference is that if the key already exists in the #GTree, it gets
29532  * replaced by the new key. If you supplied a @value_destroy_func when
29533  * creating the #GTree, the old value is freed using that function. If you
29534  * supplied a @key_destroy_func when creating the #GTree, the old key is
29535  * freed using that function.
29536  *
29537  * The tree is automatically 'balanced' as new key/value pairs are added,
29538  * so that the distance from the root to every leaf is as small as possible.
29539  */
29540
29541
29542 /**
29543  * g_tree_search:
29544  * @tree: a #GTree
29545  * @search_func: a function used to search the #GTree
29546  * @user_data: the data passed as the second argument to @search_func
29547  *
29548  * Searches a #GTree using @search_func.
29549  *
29550  * The @search_func is called with a pointer to the key of a key/value
29551  * pair in the tree, and the passed in @user_data. If @search_func returns
29552  * 0 for a key/value pair, then the corresponding value is returned as
29553  * the result of g_tree_search(). If @search_func returns -1, searching
29554  * will proceed among the key/value pairs that have a smaller key; if
29555  * @search_func returns 1, searching will proceed among the key/value
29556  * pairs that have a larger key.
29557  *
29558  * Returns: the value corresponding to the found key, or %NULL if the key was not found.
29559  */
29560
29561
29562 /**
29563  * g_tree_steal:
29564  * @tree: a #GTree.
29565  * @key: the key to remove.
29566  *
29567  * Removes a key and its associated value from a #GTree without calling
29568  * the key and value destroy functions.
29569  *
29570  * If the key does not exist in the #GTree, the function does nothing.
29571  *
29572  * Returns: %TRUE if the key was found (prior to 2.8, this function returned nothing)
29573  */
29574
29575
29576 /**
29577  * g_tree_traverse:
29578  * @tree: a #GTree.
29579  * @traverse_func: the function to call for each node visited. If this function returns %TRUE, the traversal is stopped.
29580  * @traverse_type: the order in which nodes are visited, one of %G_IN_ORDER, %G_PRE_ORDER and %G_POST_ORDER.
29581  * @user_data: user data to pass to the function.
29582  *
29583  * Calls the given function for each node in the #GTree.
29584  *
29585  * Deprecated: 2.2: The order of a balanced tree is somewhat arbitrary. If you just want to visit all nodes in sorted order, use g_tree_foreach() instead. If you really need to visit nodes in a different order, consider using an <link linkend="glib-N-ary-Trees">N-ary Tree</link>.
29586  */
29587
29588
29589 /**
29590  * g_tree_unref:
29591  * @tree: a #GTree.
29592  *
29593  * Decrements the reference count of @tree by one.  If the reference count
29594  * drops to 0, all keys and values will be destroyed (if destroy
29595  * functions were specified) and all memory allocated by @tree will be
29596  * released.
29597  *
29598  * It is safe to call this function from any thread.
29599  *
29600  * Since: 2.22
29601  */
29602
29603
29604 /**
29605  * g_try_malloc:
29606  * @n_bytes: number of bytes to allocate.
29607  *
29608  * Attempts to allocate @n_bytes, and returns %NULL on failure.
29609  * Contrast with g_malloc(), which aborts the program on failure.
29610  *
29611  * Returns: the allocated memory, or %NULL.
29612  */
29613
29614
29615 /**
29616  * g_try_malloc0:
29617  * @n_bytes: number of bytes to allocate
29618  *
29619  * Attempts to allocate @n_bytes, initialized to 0's, and returns %NULL on
29620  * failure. Contrast with g_malloc0(), which aborts the program on failure.
29621  *
29622  * Since: 2.8
29623  * Returns: the allocated memory, or %NULL
29624  */
29625
29626
29627 /**
29628  * g_try_malloc0_n:
29629  * @n_blocks: the number of blocks to allocate
29630  * @n_block_bytes: the size of each block in bytes
29631  *
29632  * This function is similar to g_try_malloc0(), allocating (@n_blocks * @n_block_bytes) bytes,
29633  * but care is taken to detect possible overflow during multiplication.
29634  *
29635  * Since: 2.24
29636  * Returns: the allocated memory, or %NULL
29637  */
29638
29639
29640 /**
29641  * g_try_malloc_n:
29642  * @n_blocks: the number of blocks to allocate
29643  * @n_block_bytes: the size of each block in bytes
29644  *
29645  * This function is similar to g_try_malloc(), allocating (@n_blocks * @n_block_bytes) bytes,
29646  * but care is taken to detect possible overflow during multiplication.
29647  *
29648  * Since: 2.24
29649  * Returns: the allocated memory, or %NULL.
29650  */
29651
29652
29653 /**
29654  * g_try_realloc:
29655  * @mem: (allow-none): previously-allocated memory, or %NULL.
29656  * @n_bytes: number of bytes to allocate.
29657  *
29658  * Attempts to realloc @mem to a new size, @n_bytes, and returns %NULL
29659  * on failure. Contrast with g_realloc(), which aborts the program
29660  * on failure. If @mem is %NULL, behaves the same as g_try_malloc().
29661  *
29662  * Returns: the allocated memory, or %NULL.
29663  */
29664
29665
29666 /**
29667  * g_try_realloc_n:
29668  * @mem: (allow-none): previously-allocated memory, or %NULL.
29669  * @n_blocks: the number of blocks to allocate
29670  * @n_block_bytes: the size of each block in bytes
29671  *
29672  * This function is similar to g_try_realloc(), allocating (@n_blocks * @n_block_bytes) bytes,
29673  * but care is taken to detect possible overflow during multiplication.
29674  *
29675  * Since: 2.24
29676  * Returns: the allocated memory, or %NULL.
29677  */
29678
29679
29680 /**
29681  * g_ucs4_to_utf16:
29682  * @str: a UCS-4 encoded string
29683  * @len: the maximum length (number of characters) of @str to use. If @len < 0, then the string is nul-terminated.
29684  * @items_read: (allow-none): location to store number of bytes read, or %NULL. If an error occurs then the index of the invalid input is stored here.
29685  * @items_written: (allow-none): location to store number of <type>gunichar2</type> written, or %NULL. The value stored here does not include the trailing 0.
29686  * @error: location to store the error occurring, or %NULL to ignore errors. Any of the errors in #GConvertError other than %G_CONVERT_ERROR_NO_CONVERSION may occur.
29687  *
29688  * Convert a string from UCS-4 to UTF-16. A 0 character will be
29689  * added to the result after the converted text.
29690  *
29691  * Returns: a pointer to a newly allocated UTF-16 string. This value must be freed with g_free(). If an error occurs, %NULL will be returned and @error set.
29692  */
29693
29694
29695 /**
29696  * g_ucs4_to_utf8:
29697  * @str: a UCS-4 encoded string
29698  * @len: the maximum length (number of characters) of @str to use. If @len < 0, then the string is nul-terminated.
29699  * @items_read: (allow-none): location to store number of characters read, or %NULL.
29700  * @items_written: (allow-none): location to store number of bytes written or %NULL. The value here stored does not include the trailing 0 byte.
29701  * @error: location to store the error occurring, or %NULL to ignore errors. Any of the errors in #GConvertError other than %G_CONVERT_ERROR_NO_CONVERSION may occur.
29702  *
29703  * Convert a string from a 32-bit fixed width representation as UCS-4.
29704  * to UTF-8. The result will be terminated with a 0 byte.
29705  *
29706  * Returns: a pointer to a newly allocated UTF-8 string. This value must be freed with g_free(). If an error occurs, %NULL will be returned and @error set. In that case, @items_read will be set to the position of the first invalid input character.
29707  */
29708
29709
29710 /**
29711  * g_unichar_break_type:
29712  * @c: a Unicode character
29713  *
29714  * Determines the break type of @c. @c should be a Unicode character
29715  * (to derive a character from UTF-8 encoded text, use
29716  * g_utf8_get_char()). The break type is used to find word and line
29717  * breaks ("text boundaries"), Pango implements the Unicode boundary
29718  * resolution algorithms and normally you would use a function such
29719  * as pango_break() instead of caring about break types yourself.
29720  *
29721  * Returns: the break type of @c
29722  */
29723
29724
29725 /**
29726  * g_unichar_combining_class:
29727  * @uc: a Unicode character
29728  *
29729  * Determines the canonical combining class of a Unicode character.
29730  *
29731  * Returns: the combining class of the character
29732  * Since: 2.14
29733  */
29734
29735
29736 /**
29737  * g_unichar_compose:
29738  * @a: a Unicode character
29739  * @b: a Unicode character
29740  * @ch: return location for the composed character
29741  *
29742  * Performs a single composition step of the
29743  * Unicode canonical composition algorithm.
29744  *
29745  * This function includes algorithmic Hangul Jamo composition,
29746  * but it is not exactly the inverse of g_unichar_decompose().
29747  * No composition can have either of @a or @b equal to zero.
29748  * To be precise, this function composes if and only if
29749  * there exists a Primary Composite P which is canonically
29750  * equivalent to the sequence <@a,@b>.  See the Unicode
29751  * Standard for the definition of Primary Composite.
29752  *
29753  * If @a and @b do not compose a new character, @ch is set to zero.
29754  *
29755  * See <ulink url="http://unicode.org/reports/tr15/">UAX#15</ulink>
29756  * for details.
29757  *
29758  * Returns: %TRUE if the characters could be composed
29759  * Since: 2.30
29760  */
29761
29762
29763 /**
29764  * g_unichar_decompose:
29765  * @ch: a Unicode character
29766  * @a: return location for the first component of @ch
29767  * @b: return location for the second component of @ch
29768  *
29769  * Performs a single decomposition step of the
29770  * Unicode canonical decomposition algorithm.
29771  *
29772  * This function does not include compatibility
29773  * decompositions. It does, however, include algorithmic
29774  * Hangul Jamo decomposition, as well as 'singleton'
29775  * decompositions which replace a character by a single
29776  * other character. In the case of singletons *@b will
29777  * be set to zero.
29778  *
29779  * If @ch is not decomposable, *@a is set to @ch and *@b
29780  * is set to zero.
29781  *
29782  * Note that the way Unicode decomposition pairs are
29783  * defined, it is guaranteed that @b would not decompose
29784  * further, but @a may itself decompose.  To get the full
29785  * canonical decomposition for @ch, one would need to
29786  * recursively call this function on @a.  Or use
29787  * g_unichar_fully_decompose().
29788  *
29789  * See <ulink url="http://unicode.org/reports/tr15/">UAX#15</ulink>
29790  * for details.
29791  *
29792  * Returns: %TRUE if the character could be decomposed
29793  * Since: 2.30
29794  */
29795
29796
29797 /**
29798  * g_unichar_digit_value:
29799  * @c: a Unicode character
29800  *
29801  * Determines the numeric value of a character as a decimal
29802  * digit.
29803  *
29804  * Returns: If @c is a decimal digit (according to g_unichar_isdigit()), its numeric value. Otherwise, -1.
29805  */
29806
29807
29808 /**
29809  * g_unichar_fully_decompose:
29810  * @ch: a Unicode character.
29811  * @compat: whether perform canonical or compatibility decomposition
29812  * @result: (allow-none): location to store decomposed result, or %NULL
29813  * @result_len: length of @result
29814  *
29815  * Computes the canonical or compatibility decomposition of a
29816  * Unicode character.  For compatibility decomposition,
29817  * pass %TRUE for @compat; for canonical decomposition
29818  * pass %FALSE for @compat.
29819  *
29820  * The decomposed sequence is placed in @result.  Only up to
29821  * @result_len characters are written into @result.  The length
29822  * of the full decomposition (irrespective of @result_len) is
29823  * returned by the function.  For canonical decomposition,
29824  * currently all decompositions are of length at most 4, but
29825  * this may change in the future (very unlikely though).
29826  * At any rate, Unicode does guarantee that a buffer of length
29827  * 18 is always enough for both compatibility and canonical
29828  * decompositions, so that is the size recommended. This is provided
29829  * as %G_UNICHAR_MAX_DECOMPOSITION_LENGTH.
29830  *
29831  * See <ulink url="http://unicode.org/reports/tr15/">UAX#15</ulink>
29832  * for details.
29833  *
29834  * Returns: the length of the full decomposition.
29835  * Since: 2.30
29836  */
29837
29838
29839 /**
29840  * g_unichar_get_mirror_char:
29841  * @ch: a Unicode character
29842  * @mirrored_ch: location to store the mirrored character
29843  *
29844  * In Unicode, some characters are <firstterm>mirrored</firstterm>. This
29845  * means that their images are mirrored horizontally in text that is laid
29846  * out from right to left. For instance, "(" would become its mirror image,
29847  * ")", in right-to-left text.
29848  *
29849  * If @ch has the Unicode mirrored property and there is another unicode
29850  * character that typically has a glyph that is the mirror image of @ch's
29851  * glyph and @mirrored_ch is set, it puts that character in the address
29852  * pointed to by @mirrored_ch.  Otherwise the original character is put.
29853  *
29854  * Returns: %TRUE if @ch has a mirrored character, %FALSE otherwise
29855  * Since: 2.4
29856  */
29857
29858
29859 /**
29860  * g_unichar_get_script:
29861  * @ch: a Unicode character
29862  *
29863  * Looks up the #GUnicodeScript for a particular character (as defined
29864  * by Unicode Standard Annex \#24). No check is made for @ch being a
29865  * valid Unicode character; if you pass in invalid character, the
29866  * result is undefined.
29867  *
29868  * This function is equivalent to pango_script_for_unichar() and the
29869  * two are interchangeable.
29870  *
29871  * Returns: the #GUnicodeScript for the character.
29872  * Since: 2.14
29873  */
29874
29875
29876 /**
29877  * g_unichar_isalnum:
29878  * @c: a Unicode character
29879  *
29880  * Determines whether a character is alphanumeric.
29881  * Given some UTF-8 text, obtain a character value
29882  * with g_utf8_get_char().
29883  *
29884  * Returns: %TRUE if @c is an alphanumeric character
29885  */
29886
29887
29888 /**
29889  * g_unichar_isalpha:
29890  * @c: a Unicode character
29891  *
29892  * Determines whether a character is alphabetic (i.e. a letter).
29893  * Given some UTF-8 text, obtain a character value with
29894  * g_utf8_get_char().
29895  *
29896  * Returns: %TRUE if @c is an alphabetic character
29897  */
29898
29899
29900 /**
29901  * g_unichar_iscntrl:
29902  * @c: a Unicode character
29903  *
29904  * Determines whether a character is a control character.
29905  * Given some UTF-8 text, obtain a character value with
29906  * g_utf8_get_char().
29907  *
29908  * Returns: %TRUE if @c is a control character
29909  */
29910
29911
29912 /**
29913  * g_unichar_isdefined:
29914  * @c: a Unicode character
29915  *
29916  * Determines if a given character is assigned in the Unicode
29917  * standard.
29918  *
29919  * Returns: %TRUE if the character has an assigned value
29920  */
29921
29922
29923 /**
29924  * g_unichar_isdigit:
29925  * @c: a Unicode character
29926  *
29927  * Determines whether a character is numeric (i.e. a digit).  This
29928  * covers ASCII 0-9 and also digits in other languages/scripts.  Given
29929  * some UTF-8 text, obtain a character value with g_utf8_get_char().
29930  *
29931  * Returns: %TRUE if @c is a digit
29932  */
29933
29934
29935 /**
29936  * g_unichar_isgraph:
29937  * @c: a Unicode character
29938  *
29939  * Determines whether a character is printable and not a space
29940  * (returns %FALSE for control characters, format characters, and
29941  * spaces). g_unichar_isprint() is similar, but returns %TRUE for
29942  * spaces. Given some UTF-8 text, obtain a character value with
29943  * g_utf8_get_char().
29944  *
29945  * Returns: %TRUE if @c is printable unless it's a space
29946  */
29947
29948
29949 /**
29950  * g_unichar_islower:
29951  * @c: a Unicode character
29952  *
29953  * Determines whether a character is a lowercase letter.
29954  * Given some UTF-8 text, obtain a character value with
29955  * g_utf8_get_char().
29956  *
29957  * Returns: %TRUE if @c is a lowercase letter
29958  */
29959
29960
29961 /**
29962  * g_unichar_ismark:
29963  * @c: a Unicode character
29964  *
29965  * Determines whether a character is a mark (non-spacing mark,
29966  * combining mark, or enclosing mark in Unicode speak).
29967  * Given some UTF-8 text, obtain a character value
29968  * with g_utf8_get_char().
29969  *
29970  * Note: in most cases where isalpha characters are allowed,
29971  * ismark characters should be allowed to as they are essential
29972  * for writing most European languages as well as many non-Latin
29973  * scripts.
29974  *
29975  * Returns: %TRUE if @c is a mark character
29976  * Since: 2.14
29977  */
29978
29979
29980 /**
29981  * g_unichar_isprint:
29982  * @c: a Unicode character
29983  *
29984  * Determines whether a character is printable.
29985  * Unlike g_unichar_isgraph(), returns %TRUE for spaces.
29986  * Given some UTF-8 text, obtain a character value with
29987  * g_utf8_get_char().
29988  *
29989  * Returns: %TRUE if @c is printable
29990  */
29991
29992
29993 /**
29994  * g_unichar_ispunct:
29995  * @c: a Unicode character
29996  *
29997  * Determines whether a character is punctuation or a symbol.
29998  * Given some UTF-8 text, obtain a character value with
29999  * g_utf8_get_char().
30000  *
30001  * Returns: %TRUE if @c is a punctuation or symbol character
30002  */
30003
30004
30005 /**
30006  * g_unichar_isspace:
30007  * @c: a Unicode character
30008  *
30009  * Determines whether a character is a space, tab, or line separator
30010  * (newline, carriage return, etc.).  Given some UTF-8 text, obtain a
30011  * character value with g_utf8_get_char().
30012  *
30013  * (Note: don't use this to do word breaking; you have to use
30014  * Pango or equivalent to get word breaking right, the algorithm
30015  * is fairly complex.)
30016  *
30017  * Returns: %TRUE if @c is a space character
30018  */
30019
30020
30021 /**
30022  * g_unichar_istitle:
30023  * @c: a Unicode character
30024  *
30025  * Determines if a character is titlecase. Some characters in
30026  * Unicode which are composites, such as the DZ digraph
30027  * have three case variants instead of just two. The titlecase
30028  * form is used at the beginning of a word where only the
30029  * first letter is capitalized. The titlecase form of the DZ
30030  * digraph is U+01F2 LATIN CAPITAL LETTTER D WITH SMALL LETTER Z.
30031  *
30032  * Returns: %TRUE if the character is titlecase
30033  */
30034
30035
30036 /**
30037  * g_unichar_isupper:
30038  * @c: a Unicode character
30039  *
30040  * Determines if a character is uppercase.
30041  *
30042  * Returns: %TRUE if @c is an uppercase character
30043  */
30044
30045
30046 /**
30047  * g_unichar_iswide:
30048  * @c: a Unicode character
30049  *
30050  * Determines if a character is typically rendered in a double-width
30051  * cell.
30052  *
30053  * Returns: %TRUE if the character is wide
30054  */
30055
30056
30057 /**
30058  * g_unichar_iswide_cjk:
30059  * @c: a Unicode character
30060  *
30061  * Determines if a character is typically rendered in a double-width
30062  * cell under legacy East Asian locales.  If a character is wide according to
30063  * g_unichar_iswide(), then it is also reported wide with this function, but
30064  * the converse is not necessarily true.  See the
30065  * <ulink url="http://www.unicode.org/reports/tr11/">Unicode Standard
30066  * Annex #11</ulink> for details.
30067  *
30068  * If a character passes the g_unichar_iswide() test then it will also pass
30069  * this test, but not the other way around.  Note that some characters may
30070  * pas both this test and g_unichar_iszerowidth().
30071  *
30072  * Returns: %TRUE if the character is wide in legacy East Asian locales
30073  * Since: 2.12
30074  */
30075
30076
30077 /**
30078  * g_unichar_isxdigit:
30079  * @c: a Unicode character.
30080  *
30081  * Determines if a character is a hexidecimal digit.
30082  *
30083  * Returns: %TRUE if the character is a hexadecimal digit
30084  */
30085
30086
30087 /**
30088  * g_unichar_iszerowidth:
30089  * @c: a Unicode character
30090  *
30091  * Determines if a given character typically takes zero width when rendered.
30092  * The return value is %TRUE for all non-spacing and enclosing marks
30093  * (e.g., combining accents), format characters, zero-width
30094  * space, but not U+00AD SOFT HYPHEN.
30095  *
30096  * A typical use of this function is with one of g_unichar_iswide() or
30097  * g_unichar_iswide_cjk() to determine the number of cells a string occupies
30098  * when displayed on a grid display (terminals).  However, note that not all
30099  * terminals support zero-width rendering of zero-width marks.
30100  *
30101  * Returns: %TRUE if the character has zero width
30102  * Since: 2.14
30103  */
30104
30105
30106 /**
30107  * g_unichar_to_utf8:
30108  * @c: a Unicode character code
30109  * @outbuf: output buffer, must have at least 6 bytes of space. If %NULL, the length will be computed and returned and nothing will be written to @outbuf.
30110  *
30111  * Converts a single character to UTF-8.
30112  *
30113  * Returns: number of bytes written
30114  */
30115
30116
30117 /**
30118  * g_unichar_tolower:
30119  * @c: a Unicode character.
30120  *
30121  * Converts a character to lower case.
30122  *
30123  * Returns: the result of converting @c to lower case. If @c is not an upperlower or titlecase character, or has no lowercase equivalent @c is returned unchanged.
30124  */
30125
30126
30127 /**
30128  * g_unichar_totitle:
30129  * @c: a Unicode character
30130  *
30131  * Converts a character to the titlecase.
30132  *
30133  * Returns: the result of converting @c to titlecase. If @c is not an uppercase or lowercase character, @c is returned unchanged.
30134  */
30135
30136
30137 /**
30138  * g_unichar_toupper:
30139  * @c: a Unicode character
30140  *
30141  * Converts a character to uppercase.
30142  *
30143  * Returns: the result of converting @c to uppercase. If @c is not an lowercase or titlecase character, or has no upper case equivalent @c is returned unchanged.
30144  */
30145
30146
30147 /**
30148  * g_unichar_type:
30149  * @c: a Unicode character
30150  *
30151  * Classifies a Unicode character by type.
30152  *
30153  * Returns: the type of the character.
30154  */
30155
30156
30157 /**
30158  * g_unichar_validate:
30159  * @ch: a Unicode character
30160  *
30161  * Checks whether @ch is a valid Unicode character. Some possible
30162  * integer values of @ch will not be valid. 0 is considered a valid
30163  * character, though it's normally a string terminator.
30164  *
30165  * Returns: %TRUE if @ch is a valid Unicode character
30166  */
30167
30168
30169 /**
30170  * g_unichar_xdigit_value:
30171  * @c: a Unicode character
30172  *
30173  * Determines the numeric value of a character as a hexidecimal
30174  * digit.
30175  *
30176  * Returns: If @c is a hex digit (according to g_unichar_isxdigit()), its numeric value. Otherwise, -1.
30177  */
30178
30179
30180 /**
30181  * g_unicode_canonical_decomposition:
30182  * @ch: a Unicode character.
30183  * @result_len: location to store the length of the return value.
30184  *
30185  * Computes the canonical decomposition of a Unicode character.
30186  *
30187  * Returns: a newly allocated string of Unicode characters. @result_len is set to the resulting length of the string.
30188  * Deprecated: 2.30: Use the more flexible g_unichar_fully_decompose() instead.
30189  */
30190
30191
30192 /**
30193  * g_unicode_canonical_ordering:
30194  * @string: a UCS-4 encoded string.
30195  * @len: the maximum length of @string to use.
30196  *
30197  * Computes the canonical ordering of a string in-place.
30198  * This rearranges decomposed characters in the string
30199  * according to their combining classes.  See the Unicode
30200  * manual for more information.
30201  */
30202
30203
30204 /**
30205  * g_unicode_script_from_iso15924:
30206  * @iso15924: a Unicode script
30207  *
30208  * Looks up the Unicode script for @iso15924.  ISO 15924 assigns four-letter
30209  * codes to scripts.  For example, the code for Arabic is 'Arab'.
30210  * This function accepts four letter codes encoded as a @guint32 in a
30211  * big-endian fashion.  That is, the code expected for Arabic is
30212  * 0x41726162 (0x41 is ASCII code for 'A', 0x72 is ASCII code for 'r', etc).
30213  *
30214  * See <ulink url="http://unicode.org/iso15924/codelists.html">Codes for the
30215  * representation of names of scripts</ulink> for details.
30216  *
30217  * Returns: the Unicode script for @iso15924, or of %G_UNICODE_SCRIPT_INVALID_CODE if @iso15924 is zero and %G_UNICODE_SCRIPT_UNKNOWN if @iso15924 is unknown.
30218  * Since: 2.30
30219  */
30220
30221
30222 /**
30223  * g_unicode_script_to_iso15924:
30224  * @script: a Unicode script
30225  *
30226  * Looks up the ISO 15924 code for @script.  ISO 15924 assigns four-letter
30227  * codes to scripts.  For example, the code for Arabic is 'Arab'.  The
30228  * four letter codes are encoded as a @guint32 by this function in a
30229  * big-endian fashion.  That is, the code returned for Arabic is
30230  * 0x41726162 (0x41 is ASCII code for 'A', 0x72 is ASCII code for 'r', etc).
30231  *
30232  * See <ulink url="http://unicode.org/iso15924/codelists.html">Codes for the
30233  * representation of names of scripts</ulink> for details.
30234  *
30235  * Returns: the ISO 15924 code for @script, encoded as an integer, of zero if @script is %G_UNICODE_SCRIPT_INVALID_CODE or ISO 15924 code 'Zzzz' (script code for UNKNOWN) if @script is not understood.
30236  * Since: 2.30
30237  */
30238
30239
30240 /**
30241  * g_unix_fd_add:
30242  * @fd: a file descriptor
30243  * @condition: IO conditions to watch for on @fd
30244  * @function: a #GPollFDFunc
30245  * @user_data: data to pass to @function
30246  *
30247  * Sets a function to be called when the IO condition, as specified by
30248  * @condition becomes true for @fd.
30249  *
30250  * @function will be called when the specified IO condition becomes
30251  * %TRUE.  The function is expected to clear whatever event caused the
30252  * IO condition to become true and return %TRUE in order to be notified
30253  * when it happens again.  If @function returns %FALSE then the watch
30254  * will be cancelled.
30255  *
30256  * The return value of this function can be passed to g_source_remove()
30257  * to cancel the watch at any time that it exists.
30258  *
30259  * The source will never close the fd -- you must do it yourself.
30260  *
30261  * Returns: the ID (greater than 0) of the event source
30262  * Since: 2.36
30263  */
30264
30265
30266 /**
30267  * g_unix_fd_add_full:
30268  * @priority: the priority of the source
30269  * @fd: a file descriptor
30270  * @condition: IO conditions to watch for on @fd
30271  * @function: a #GUnixFDSourceFunc
30272  * @user_data: data to pass to @function
30273  * @notify: function to call when the idle is removed, or %NULL
30274  *
30275  * Sets a function to be called when the IO condition, as specified by
30276  * @condition becomes true for @fd.
30277  *
30278  * This is the same as g_unix_fd_add(), except that it allows you to
30279  * specify a non-default priority and a provide a #GDestroyNotify for
30280  * @user_data.
30281  *
30282  * Returns: the ID (greater than 0) of the event source
30283  * Since: 2.36
30284  */
30285
30286
30287 /**
30288  * g_unix_fd_source_new:
30289  * @fd: a file descriptor
30290  * @condition: IO conditions to watch for on @fd
30291  *
30292  * Creates a #GSource to watch for a particular IO condition on a file
30293  * descriptor.
30294  *
30295  * The source will never close the fd -- you must do it yourself.
30296  *
30297  * Returns: the newly created #GSource
30298  * Since: 2.36
30299  */
30300
30301
30302 /**
30303  * g_unix_open_pipe:
30304  * @fds: Array of two integers
30305  * @flags: Bitfield of file descriptor flags, see "man 2 fcntl"
30306  * @error: a #GError
30307  *
30308  * Similar to the UNIX pipe() call, but on modern systems like Linux
30309  * uses the pipe2() system call, which atomically creates a pipe with
30310  * the configured flags.  The only supported flag currently is
30311  * <literal>FD_CLOEXEC</literal>.  If for example you want to configure
30312  * <literal>O_NONBLOCK</literal>, that must still be done separately with
30313  * fcntl().
30314  *
30315  * <note>This function does *not* take <literal>O_CLOEXEC</literal>, it takes
30316  * <literal>FD_CLOEXEC</literal> as if for fcntl(); these are
30317  * different on Linux/glibc.</note>
30318  *
30319  * Returns: %TRUE on success, %FALSE if not (and errno will be set).
30320  * Since: 2.30
30321  */
30322
30323
30324 /**
30325  * g_unix_set_fd_nonblocking:
30326  * @fd: A file descriptor
30327  * @nonblock: If %TRUE, set the descriptor to be non-blocking
30328  * @error: a #GError
30329  *
30330  * Control the non-blocking state of the given file descriptor,
30331  * according to @nonblock.  On most systems this uses <literal>O_NONBLOCK</literal>, but
30332  * on some older ones may use <literal>O_NDELAY</literal>.
30333  *
30334  * Returns: %TRUE if successful
30335  * Since: 2.30
30336  */
30337
30338
30339 /**
30340  * g_unix_signal_add:
30341  * @signum: Signal number
30342  * @handler: Callback
30343  * @user_data: Data for @handler
30344  *
30345  * A convenience function for g_unix_signal_source_new(), which
30346  * attaches to the default #GMainContext.  You can remove the watch
30347  * using g_source_remove().
30348  *
30349  * Returns: An ID (greater than 0) for the event source
30350  * Since: 2.30
30351  */
30352
30353
30354 /**
30355  * g_unix_signal_add_full:
30356  * @priority: the priority of the signal source. Typically this will be in the range between #G_PRIORITY_DEFAULT and #G_PRIORITY_HIGH.
30357  * @signum: Signal number
30358  * @handler: Callback
30359  * @user_data: Data for @handler
30360  * @notify: #GDestroyNotify for @handler
30361  *
30362  * A convenience function for g_unix_signal_source_new(), which
30363  * attaches to the default #GMainContext.  You can remove the watch
30364  * using g_source_remove().
30365  *
30366  * Returns: An ID (greater than 0) for the event source
30367  * Rename to: g_unix_signal_add
30368  * Since: 2.30
30369  */
30370
30371
30372 /**
30373  * g_unix_signal_source_new:
30374  * @signum: A signal number
30375  *
30376  * Create a #GSource that will be dispatched upon delivery of the UNIX
30377  * signal @signum.  In GLib versions before 2.36, only
30378  * <literal>SIGHUP</literal>, <literal>SIGINT</literal>,
30379  * <literal>SIGTERM</literal> can be monitored.  In GLib 2.36,
30380  * <literal>SIGUSR1</literal> and <literal>SIGUSR2</literal> were
30381  * added.
30382  *
30383  * Note that unlike the UNIX default, all sources which have created a
30384  * watch will be dispatched, regardless of which underlying thread
30385  * invoked g_unix_signal_source_new().
30386  *
30387  * For example, an effective use of this function is to handle <literal>SIGTERM</literal>
30388  * cleanly; flushing any outstanding files, and then calling
30389  * g_main_loop_quit ().  It is not safe to do any of this a regular
30390  * UNIX signal handler; your handler may be invoked while malloc() or
30391  * another library function is running, causing reentrancy if you
30392  * attempt to use it from the handler.  None of the GLib/GObject API
30393  * is safe against this kind of reentrancy.
30394  *
30395  * The interaction of this source when combined with native UNIX
30396  * functions like sigprocmask() is not defined.
30397  *
30398  * The source will not initially be associated with any #GMainContext
30399  * and must be added to one with g_source_attach() before it will be
30400  * executed.
30401  *
30402  * Returns: A newly created #GSource
30403  * Since: 2.30
30404  */
30405
30406
30407 /**
30408  * g_unlink:
30409  * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
30410  *
30411  * A wrapper for the POSIX unlink() function. The unlink() function
30412  * deletes a name from the filesystem. If this was the last link to the
30413  * file and no processes have it opened, the diskspace occupied by the
30414  * file is freed.
30415  *
30416  * See your C library manual for more details about unlink(). Note
30417  * that on Windows, it is in general not possible to delete files that
30418  * are open to some process, or mapped into memory.
30419  *
30420  * Returns: 0 if the name was successfully deleted, -1 if an error occurred
30421  * Since: 2.6
30422  */
30423
30424
30425 /**
30426  * g_unsetenv:
30427  * @variable: the environment variable to remove, must not contain '='
30428  *
30429  * Removes an environment variable from the environment.
30430  *
30431  * Note that on some systems, when variables are overwritten, the
30432  * memory used for the previous variables and its value isn't reclaimed.
30433  *
30434  * <warning><para>
30435  * Environment variable handling in UNIX is not thread-safe, and your
30436  * program may crash if one thread calls g_unsetenv() while another
30437  * thread is calling getenv(). (And note that many functions, such as
30438  * gettext(), call getenv() internally.) This function is only safe
30439  * to use at the very start of your program, before creating any other
30440  * threads (or creating objects that create worker threads of their
30441  * own).
30442  * </para><para>
30443  * If you need to set up the environment for a child process, you can
30444  * use g_get_environ() to get an environment array, modify that with
30445  * g_environ_setenv() and g_environ_unsetenv(), and then pass that
30446  * array directly to execvpe(), g_spawn_async(), or the like.
30447  * </para></warning>
30448  *
30449  * Since: 2.4
30450  */
30451
30452
30453 /**
30454  * g_uri_escape_string:
30455  * @unescaped: the unescaped input string.
30456  * @reserved_chars_allowed: (allow-none): a string of reserved characters that are allowed to be used, or %NULL.
30457  * @allow_utf8: %TRUE if the result can include UTF-8 characters.
30458  *
30459  * Escapes a string for use in a URI.
30460  *
30461  * Normally all characters that are not "unreserved" (i.e. ASCII alphanumerical
30462  * characters plus dash, dot, underscore and tilde) are escaped.
30463  * But if you specify characters in @reserved_chars_allowed they are not
30464  * escaped. This is useful for the "reserved" characters in the URI
30465  * specification, since those are allowed unescaped in some portions of
30466  * a URI.
30467  *
30468  * Returns: an escaped version of @unescaped. The returned string should be freed when no longer needed.
30469  * Since: 2.16
30470  */
30471
30472
30473 /**
30474  * g_uri_list_extract_uris:
30475  * @uri_list: an URI list
30476  *
30477  * Splits an URI list conforming to the text/uri-list
30478  * mime type defined in RFC 2483 into individual URIs,
30479  * discarding any comments. The URIs are not validated.
30480  *
30481  * Returns: (transfer full): a newly allocated %NULL-terminated list of strings holding the individual URIs. The array should be freed with g_strfreev().
30482  * Since: 2.6
30483  */
30484
30485
30486 /**
30487  * g_uri_parse_scheme:
30488  * @uri: a valid URI.
30489  *
30490  * Gets the scheme portion of a URI string. RFC 3986 decodes the scheme as:
30491  * <programlisting>
30492  * URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
30493  * </programlisting>
30494  * Common schemes include "file", "http", "svn+ssh", etc.
30495  *
30496  * Returns: The "Scheme" component of the URI, or %NULL on error. The returned string should be freed when no longer needed.
30497  * Since: 2.16
30498  */
30499
30500
30501 /**
30502  * g_uri_unescape_segment:
30503  * @escaped_string: (allow-none): A string, may be %NULL
30504  * @escaped_string_end: (allow-none): Pointer to end of @escaped_string, may be %NULL
30505  * @illegal_characters: (allow-none): An optional string of illegal characters not to be allowed, may be %NULL
30506  *
30507  * Unescapes a segment of an escaped string.
30508  *
30509  * If any of the characters in @illegal_characters or the character zero appears
30510  * as an escaped character in @escaped_string then that is an error and %NULL
30511  * will be returned. This is useful it you want to avoid for instance having a
30512  * slash being expanded in an escaped path element, which might confuse pathname
30513  * handling.
30514  *
30515  * Returns: an unescaped version of @escaped_string or %NULL on error. The returned string should be freed when no longer needed.  As a special case if %NULL is given for @escaped_string, this function will return %NULL.
30516  * Since: 2.16
30517  */
30518
30519
30520 /**
30521  * g_uri_unescape_string:
30522  * @escaped_string: an escaped string to be unescaped.
30523  * @illegal_characters: (allow-none): a string of illegal characters not to be allowed, or %NULL.
30524  *
30525  * Unescapes a whole escaped string.
30526  *
30527  * If any of the characters in @illegal_characters or the character zero appears
30528  * as an escaped character in @escaped_string then that is an error and %NULL
30529  * will be returned. This is useful it you want to avoid for instance having a
30530  * slash being expanded in an escaped path element, which might confuse pathname
30531  * handling.
30532  *
30533  * Returns: an unescaped version of @escaped_string. The returned string should be freed when no longer needed.
30534  * Since: 2.16
30535  */
30536
30537
30538 /**
30539  * g_usleep:
30540  * @microseconds: number of microseconds to pause
30541  *
30542  * Pauses the current thread for the given number of microseconds.
30543  *
30544  * There are 1 million microseconds per second (represented by the
30545  * #G_USEC_PER_SEC macro). g_usleep() may have limited precision,
30546  * depending on hardware and operating system; don't rely on the exact
30547  * length of the sleep.
30548  */
30549
30550
30551 /**
30552  * g_utf16_to_ucs4:
30553  * @str: a UTF-16 encoded string
30554  * @len: the maximum length (number of <type>gunichar2</type>) of @str to use. If @len < 0, then the string is nul-terminated.
30555  * @items_read: (allow-none): location to store number of words read, or %NULL. If %NULL, then %G_CONVERT_ERROR_PARTIAL_INPUT will be returned in case @str contains a trailing partial character. If an error occurs then the index of the invalid input is stored here.
30556  * @items_written: (allow-none): location to store number of characters written, or %NULL. The value stored here does not include the trailing 0 character.
30557  * @error: location to store the error occurring, or %NULL to ignore errors. Any of the errors in #GConvertError other than %G_CONVERT_ERROR_NO_CONVERSION may occur.
30558  *
30559  * Convert a string from UTF-16 to UCS-4. The result will be
30560  * nul-terminated.
30561  *
30562  * Returns: a pointer to a newly allocated UCS-4 string. This value must be freed with g_free(). If an error occurs, %NULL will be returned and @error set.
30563  */
30564
30565
30566 /**
30567  * g_utf16_to_utf8:
30568  * @str: a UTF-16 encoded string
30569  * @len: the maximum length (number of <type>gunichar2</type>) of @str to use. If @len < 0, then the string is nul-terminated.
30570  * @items_read: (allow-none): location to store number of words read, or %NULL. If %NULL, then %G_CONVERT_ERROR_PARTIAL_INPUT will be returned in case @str contains a trailing partial character. If an error occurs then the index of the invalid input is stored here.
30571  * @items_written: (allow-none): location to store number of bytes written, or %NULL. The value stored here does not include the trailing 0 byte.
30572  * @error: location to store the error occurring, or %NULL to ignore errors. Any of the errors in #GConvertError other than %G_CONVERT_ERROR_NO_CONVERSION may occur.
30573  *
30574  * Convert a string from UTF-16 to UTF-8. The result will be
30575  * terminated with a 0 byte.
30576  *
30577  * Note that the input is expected to be already in native endianness,
30578  * an initial byte-order-mark character is not handled specially.
30579  * g_convert() can be used to convert a byte buffer of UTF-16 data of
30580  * ambiguous endianess.
30581  *
30582  * Further note that this function does not validate the result
30583  * string; it may e.g. include embedded NUL characters. The only
30584  * validation done by this function is to ensure that the input can
30585  * be correctly interpreted as UTF-16, i.e. it doesn't contain
30586  * things unpaired surrogates.
30587  *
30588  * Returns: a pointer to a newly allocated UTF-8 string. This value must be freed with g_free(). If an error occurs, %NULL will be returned and @error set.
30589  */
30590
30591
30592 /**
30593  * g_utf8_casefold:
30594  * @str: a UTF-8 encoded string
30595  * @len: length of @str, in bytes, or -1 if @str is nul-terminated.
30596  *
30597  * Converts a string into a form that is independent of case. The
30598  * result will not correspond to any particular case, but can be
30599  * compared for equality or ordered with the results of calling
30600  * g_utf8_casefold() on other strings.
30601  *
30602  * Note that calling g_utf8_casefold() followed by g_utf8_collate() is
30603  * only an approximation to the correct linguistic case insensitive
30604  * ordering, though it is a fairly good one. Getting this exactly
30605  * right would require a more sophisticated collation function that
30606  * takes case sensitivity into account. GLib does not currently
30607  * provide such a function.
30608  *
30609  * Returns: a newly allocated string, that is a case independent form of @str.
30610  */
30611
30612
30613 /**
30614  * g_utf8_collate:
30615  * @str1: a UTF-8 encoded string
30616  * @str2: a UTF-8 encoded string
30617  *
30618  * Compares two strings for ordering using the linguistically
30619  * correct rules for the <link linkend="setlocale">current locale</link>.
30620  * When sorting a large number of strings, it will be significantly
30621  * faster to obtain collation keys with g_utf8_collate_key() and
30622  * compare the keys with strcmp() when sorting instead of sorting
30623  * the original strings.
30624  *
30625  * Returns: &lt; 0 if @str1 compares before @str2, 0 if they compare equal, &gt; 0 if @str1 compares after @str2.
30626  */
30627
30628
30629 /**
30630  * g_utf8_collate_key:
30631  * @str: a UTF-8 encoded string.
30632  * @len: length of @str, in bytes, or -1 if @str is nul-terminated.
30633  *
30634  * Converts a string into a collation key that can be compared
30635  * with other collation keys produced by the same function using
30636  * strcmp().
30637  *
30638  * The results of comparing the collation keys of two strings
30639  * with strcmp() will always be the same as comparing the two
30640  * original keys with g_utf8_collate().
30641  *
30642  * Note that this function depends on the
30643  * <link linkend="setlocale">current locale</link>.
30644  *
30645  * Returns: a newly allocated string. This string should be freed with g_free() when you are done with it.
30646  */
30647
30648
30649 /**
30650  * g_utf8_collate_key_for_filename:
30651  * @str: a UTF-8 encoded string.
30652  * @len: length of @str, in bytes, or -1 if @str is nul-terminated.
30653  *
30654  * Converts a string into a collation key that can be compared
30655  * with other collation keys produced by the same function using strcmp().
30656  *
30657  * In order to sort filenames correctly, this function treats the dot '.'
30658  * as a special case. Most dictionary orderings seem to consider it
30659  * insignificant, thus producing the ordering "event.c" "eventgenerator.c"
30660  * "event.h" instead of "event.c" "event.h" "eventgenerator.c". Also, we
30661  * would like to treat numbers intelligently so that "file1" "file10" "file5"
30662  * is sorted as "file1" "file5" "file10".
30663  *
30664  * Note that this function depends on the
30665  * <link linkend="setlocale">current locale</link>.
30666  *
30667  * Returns: a newly allocated string. This string should be freed with g_free() when you are done with it.
30668  * Since: 2.8
30669  */
30670
30671
30672 /**
30673  * g_utf8_find_next_char:
30674  * @p: a pointer to a position within a UTF-8 encoded string
30675  * @end: a pointer to the byte following the end of the string, or %NULL to indicate that the string is nul-terminated.
30676  *
30677  * Finds the start of the next UTF-8 character in the string after @p.
30678  *
30679  * @p does not have to be at the beginning of a UTF-8 character. No check
30680  * is made to see if the character found is actually valid other than
30681  * it starts with an appropriate byte.
30682  *
30683  * Returns: a pointer to the found character or %NULL
30684  */
30685
30686
30687 /**
30688  * g_utf8_find_prev_char:
30689  * @str: pointer to the beginning of a UTF-8 encoded string
30690  * @p: pointer to some position within @str
30691  *
30692  * Given a position @p with a UTF-8 encoded string @str, find the start
30693  * of the previous UTF-8 character starting before @p. Returns %NULL if no
30694  * UTF-8 characters are present in @str before @p.
30695  *
30696  * @p does not have to be at the beginning of a UTF-8 character. No check
30697  * is made to see if the character found is actually valid other than
30698  * it starts with an appropriate byte.
30699  *
30700  * Returns: a pointer to the found character or %NULL.
30701  */
30702
30703
30704 /**
30705  * g_utf8_get_char:
30706  * @p: a pointer to Unicode character encoded as UTF-8
30707  *
30708  * Converts a sequence of bytes encoded as UTF-8 to a Unicode character.
30709  * If @p does not point to a valid UTF-8 encoded character, results are
30710  * undefined. If you are not sure that the bytes are complete
30711  * valid Unicode characters, you should use g_utf8_get_char_validated()
30712  * instead.
30713  *
30714  * Returns: the resulting character
30715  */
30716
30717
30718 /**
30719  * g_utf8_get_char_validated:
30720  * @p: a pointer to Unicode character encoded as UTF-8
30721  * @max_len: the maximum number of bytes to read, or -1, for no maximum or if @p is nul-terminated
30722  *
30723  * Convert a sequence of bytes encoded as UTF-8 to a Unicode character.
30724  * This function checks for incomplete characters, for invalid characters
30725  * such as characters that are out of the range of Unicode, and for
30726  * overlong encodings of valid characters.
30727  *
30728  * Returns: the resulting character. If @p points to a partial sequence at the end of a string that could begin a valid character (or if @max_len is zero), returns (gunichar)-2; otherwise, if @p does not point to a valid UTF-8 encoded Unicode character, returns (gunichar)-1.
30729  */
30730
30731
30732 /**
30733  * g_utf8_normalize:
30734  * @str: a UTF-8 encoded string.
30735  * @len: length of @str, in bytes, or -1 if @str is nul-terminated.
30736  * @mode: the type of normalization to perform.
30737  *
30738  * Converts a string into canonical form, standardizing
30739  * such issues as whether a character with an accent
30740  * is represented as a base character and combining
30741  * accent or as a single precomposed character. The
30742  * string has to be valid UTF-8, otherwise %NULL is
30743  * returned. You should generally call g_utf8_normalize()
30744  * before comparing two Unicode strings.
30745  *
30746  * The normalization mode %G_NORMALIZE_DEFAULT only
30747  * standardizes differences that do not affect the
30748  * text content, such as the above-mentioned accent
30749  * representation. %G_NORMALIZE_ALL also standardizes
30750  * the "compatibility" characters in Unicode, such
30751  * as SUPERSCRIPT THREE to the standard forms
30752  * (in this case DIGIT THREE). Formatting information
30753  * may be lost but for most text operations such
30754  * characters should be considered the same.
30755  *
30756  * %G_NORMALIZE_DEFAULT_COMPOSE and %G_NORMALIZE_ALL_COMPOSE
30757  * are like %G_NORMALIZE_DEFAULT and %G_NORMALIZE_ALL,
30758  * but returned a result with composed forms rather
30759  * than a maximally decomposed form. This is often
30760  * useful if you intend to convert the string to
30761  * a legacy encoding or pass it to a system with
30762  * less capable Unicode handling.
30763  *
30764  * Returns: a newly allocated string, that is the normalized form of @str, or %NULL if @str is not valid UTF-8.
30765  */
30766
30767
30768 /**
30769  * g_utf8_offset_to_pointer:
30770  * @str: a UTF-8 encoded string
30771  * @offset: a character offset within @str
30772  *
30773  * Converts from an integer character offset to a pointer to a position
30774  * within the string.
30775  *
30776  * Since 2.10, this function allows to pass a negative @offset to
30777  * step backwards. It is usually worth stepping backwards from the end
30778  * instead of forwards if @offset is in the last fourth of the string,
30779  * since moving forward is about 3 times faster than moving backward.
30780  *
30781  * <note><para>
30782  * This function doesn't abort when reaching the end of @str. Therefore
30783  * you should be sure that @offset is within string boundaries before
30784  * calling that function. Call g_utf8_strlen() when unsure.
30785  *
30786  * This limitation exists as this function is called frequently during
30787  * text rendering and therefore has to be as fast as possible.
30788  * </para></note>
30789  *
30790  * Returns: the resulting pointer
30791  */
30792
30793
30794 /**
30795  * g_utf8_pointer_to_offset:
30796  * @str: a UTF-8 encoded string
30797  * @pos: a pointer to a position within @str
30798  *
30799  * Converts from a pointer to position within a string to a integer
30800  * character offset.
30801  *
30802  * Since 2.10, this function allows @pos to be before @str, and returns
30803  * a negative offset in this case.
30804  *
30805  * Returns: the resulting character offset
30806  */
30807
30808
30809 /**
30810  * g_utf8_prev_char:
30811  * @p: a pointer to a position within a UTF-8 encoded string
30812  *
30813  * Finds the previous UTF-8 character in the string before @p.
30814  *
30815  * @p does not have to be at the beginning of a UTF-8 character. No check
30816  * is made to see if the character found is actually valid other than
30817  * it starts with an appropriate byte. If @p might be the first
30818  * character of the string, you must use g_utf8_find_prev_char() instead.
30819  *
30820  * Returns: a pointer to the found character.
30821  */
30822
30823
30824 /**
30825  * g_utf8_strchr:
30826  * @p: a nul-terminated UTF-8 encoded string
30827  * @len: the maximum length of @p
30828  * @c: a Unicode character
30829  *
30830  * Finds the leftmost occurrence of the given Unicode character
30831  * in a UTF-8 encoded string, while limiting the search to @len bytes.
30832  * If @len is -1, allow unbounded search.
30833  *
30834  * Returns: %NULL if the string does not contain the character, otherwise, a pointer to the start of the leftmost occurrence of the character in the string.
30835  */
30836
30837
30838 /**
30839  * g_utf8_strdown:
30840  * @str: a UTF-8 encoded string
30841  * @len: length of @str, in bytes, or -1 if @str is nul-terminated.
30842  *
30843  * Converts all Unicode characters in the string that have a case
30844  * to lowercase. The exact manner that this is done depends
30845  * on the current locale, and may result in the number of
30846  * characters in the string changing.
30847  *
30848  * Returns: a newly allocated string, with all characters converted to lowercase.
30849  */
30850
30851
30852 /**
30853  * g_utf8_strlen:
30854  * @p: pointer to the start of a UTF-8 encoded string
30855  * @max: the maximum number of bytes to examine. If @max is less than 0, then the string is assumed to be nul-terminated. If @max is 0, @p will not be examined and may be %NULL. If @max is greater than 0, up to @max bytes are examined
30856  *
30857  * Computes the length of the string in characters, not including
30858  * the terminating nul character. If the @max'th byte falls in the
30859  * middle of a character, the last (partial) character is not counted.
30860  *
30861  * Returns: the length of the string in characters
30862  */
30863
30864
30865 /**
30866  * g_utf8_strncpy:
30867  * @dest: buffer to fill with characters from @src
30868  * @src: UTF-8 encoded string
30869  * @n: character count
30870  *
30871  * Like the standard C strncpy() function, but
30872  * copies a given number of characters instead of a given number of
30873  * bytes. The @src string must be valid UTF-8 encoded text.
30874  * (Use g_utf8_validate() on all text before trying to use UTF-8
30875  * utility functions with it.)
30876  *
30877  * Returns: @dest
30878  */
30879
30880
30881 /**
30882  * g_utf8_strrchr:
30883  * @p: a nul-terminated UTF-8 encoded string
30884  * @len: the maximum length of @p
30885  * @c: a Unicode character
30886  *
30887  * Find the rightmost occurrence of the given Unicode character
30888  * in a UTF-8 encoded string, while limiting the search to @len bytes.
30889  * If @len is -1, allow unbounded search.
30890  *
30891  * Returns: %NULL if the string does not contain the character, otherwise, a pointer to the start of the rightmost occurrence of the character in the string.
30892  */
30893
30894
30895 /**
30896  * g_utf8_strreverse:
30897  * @str: a UTF-8 encoded string
30898  * @len: the maximum length of @str to use, in bytes. If @len < 0, then the string is nul-terminated.
30899  *
30900  * Reverses a UTF-8 string. @str must be valid UTF-8 encoded text.
30901  * (Use g_utf8_validate() on all text before trying to use UTF-8
30902  * utility functions with it.)
30903  *
30904  * This function is intended for programmatic uses of reversed strings.
30905  * It pays no attention to decomposed characters, combining marks, byte
30906  * order marks, directional indicators (LRM, LRO, etc) and similar
30907  * characters which might need special handling when reversing a string
30908  * for display purposes.
30909  *
30910  * Note that unlike g_strreverse(), this function returns
30911  * newly-allocated memory, which should be freed with g_free() when
30912  * no longer needed.
30913  *
30914  * Returns: a newly-allocated string which is the reverse of @str.
30915  * Since: 2.2
30916  */
30917
30918
30919 /**
30920  * g_utf8_strup:
30921  * @str: a UTF-8 encoded string
30922  * @len: length of @str, in bytes, or -1 if @str is nul-terminated.
30923  *
30924  * Converts all Unicode characters in the string that have a case
30925  * to uppercase. The exact manner that this is done depends
30926  * on the current locale, and may result in the number of
30927  * characters in the string increasing. (For instance, the
30928  * German ess-zet will be changed to SS.)
30929  *
30930  * Returns: a newly allocated string, with all characters converted to uppercase.
30931  */
30932
30933
30934 /**
30935  * g_utf8_substring:
30936  * @str: a UTF-8 encoded string
30937  * @start_pos: a character offset within @str
30938  * @end_pos: another character offset within @str
30939  *
30940  * Copies a substring out of a UTF-8 encoded string.
30941  * The substring will contain @end_pos - @start_pos
30942  * characters.
30943  *
30944  * Returns: a newly allocated copy of the requested substring. Free with g_free() when no longer needed.
30945  * Since: 2.30
30946  */
30947
30948
30949 /**
30950  * g_utf8_to_ucs4:
30951  * @str: a UTF-8 encoded string
30952  * @len: the maximum length of @str to use, in bytes. If @len < 0, then the string is nul-terminated.
30953  * @items_read: (allow-none): location to store number of bytes read, or %NULL. If %NULL, then %G_CONVERT_ERROR_PARTIAL_INPUT will be returned in case @str contains a trailing partial character. If an error occurs then the index of the invalid input is stored here.
30954  * @items_written: (allow-none): location to store number of characters written or %NULL. The value here stored does not include the trailing 0 character.
30955  * @error: location to store the error occurring, or %NULL to ignore errors. Any of the errors in #GConvertError other than %G_CONVERT_ERROR_NO_CONVERSION may occur.
30956  *
30957  * Convert a string from UTF-8 to a 32-bit fixed width
30958  * representation as UCS-4. A trailing 0 character will be added to the
30959  * string after the converted text.
30960  *
30961  * Returns: a pointer to a newly allocated UCS-4 string. This value must be freed with g_free(). If an error occurs, %NULL will be returned and @error set.
30962  */
30963
30964
30965 /**
30966  * g_utf8_to_ucs4_fast:
30967  * @str: a UTF-8 encoded string
30968  * @len: the maximum length of @str to use, in bytes. If @len < 0, then the string is nul-terminated.
30969  * @items_written: (allow-none): location to store the number of characters in the result, or %NULL.
30970  *
30971  * Convert a string from UTF-8 to a 32-bit fixed width
30972  * representation as UCS-4, assuming valid UTF-8 input.
30973  * This function is roughly twice as fast as g_utf8_to_ucs4()
30974  * but does no error checking on the input. A trailing 0 character
30975  * will be added to the string after the converted text.
30976  *
30977  * Returns: a pointer to a newly allocated UCS-4 string. This value must be freed with g_free().
30978  */
30979
30980
30981 /**
30982  * g_utf8_to_utf16:
30983  * @str: a UTF-8 encoded string
30984  * @len: the maximum length (number of bytes) of @str to use. If @len < 0, then the string is nul-terminated.
30985  * @items_read: (allow-none): location to store number of bytes read, or %NULL. If %NULL, then %G_CONVERT_ERROR_PARTIAL_INPUT will be returned in case @str contains a trailing partial character. If an error occurs then the index of the invalid input is stored here.
30986  * @items_written: (allow-none): location to store number of <type>gunichar2</type> written, or %NULL. The value stored here does not include the trailing 0.
30987  * @error: location to store the error occurring, or %NULL to ignore errors. Any of the errors in #GConvertError other than %G_CONVERT_ERROR_NO_CONVERSION may occur.
30988  *
30989  * Convert a string from UTF-8 to UTF-16. A 0 character will be
30990  * added to the result after the converted text.
30991  *
30992  * Returns: a pointer to a newly allocated UTF-16 string. This value must be freed with g_free(). If an error occurs, %NULL will be returned and @error set.
30993  */
30994
30995
30996 /**
30997  * g_utf8_validate:
30998  * @str: (array length=max_len) (element-type guint8): a pointer to character data
30999  * @max_len: max bytes to validate, or -1 to go until NUL
31000  * @end: (allow-none) (out) (transfer none): return location for end of valid data
31001  *
31002  * Validates UTF-8 encoded text. @str is the text to validate;
31003  * if @str is nul-terminated, then @max_len can be -1, otherwise
31004  * @max_len should be the number of bytes to validate.
31005  * If @end is non-%NULL, then the end of the valid range
31006  * will be stored there (i.e. the start of the first invalid
31007  * character if some bytes were invalid, or the end of the text
31008  * being validated otherwise).
31009  *
31010  * Note that g_utf8_validate() returns %FALSE if @max_len is
31011  * positive and any of the @max_len bytes are NUL.
31012  *
31013  * Returns %TRUE if all of @str was valid. Many GLib and GTK+
31014  * routines <emphasis>require</emphasis> valid UTF-8 as input;
31015  * so data read from a file or the network should be checked
31016  * with g_utf8_validate() before doing anything else with it.
31017  *
31018  * Returns: %TRUE if the text was valid UTF-8
31019  */
31020
31021
31022 /**
31023  * g_utime:
31024  * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
31025  * @utb: a pointer to a struct utimbuf.
31026  *
31027  * A wrapper for the POSIX utime() function. The utime() function
31028  * sets the access and modification timestamps of a file.
31029  *
31030  * See your C library manual for more details about how utime() works
31031  * on your system.
31032  *
31033  * Returns: 0 if the operation was successful, -1 if an error occurred
31034  * Since: 2.18
31035  */
31036
31037
31038 /**
31039  * g_variant_builder_add: (skp)
31040  * @builder: a #GVariantBuilder
31041  * @format_string: a #GVariant varargs format string
31042  * @...: arguments, as per @format_string
31043  *
31044  * Adds to a #GVariantBuilder.
31045  *
31046  * This call is a convenience wrapper that is exactly equivalent to
31047  * calling g_variant_new() followed by g_variant_builder_add_value().
31048  *
31049  * This function might be used as follows:
31050  *
31051  * <programlisting>
31052  * GVariant *
31053  * make_pointless_dictionary (void)
31054  * {
31055  *   GVariantBuilder *builder;
31056  *   int i;
31057  *
31058  *   builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
31059  *   for (i = 0; i < 16; i++)
31060  *     {
31061  *       gchar buf[3];
31062  *
31063  *       sprintf (buf, "%d", i);
31064  *       g_variant_builder_add (builder, "{is}", i, buf);
31065  *     }
31066  *
31067  *   return g_variant_builder_end (builder);
31068  * }
31069  * </programlisting>
31070  *
31071  * Since: 2.24
31072  */
31073
31074
31075 /**
31076  * g_variant_builder_add_parsed:
31077  * @builder: a #GVariantBuilder
31078  * @format: a text format #GVariant
31079  * @...: arguments as per @format
31080  *
31081  * Adds to a #GVariantBuilder.
31082  *
31083  * This call is a convenience wrapper that is exactly equivalent to
31084  * calling g_variant_new_parsed() followed by
31085  * g_variant_builder_add_value().
31086  *
31087  * This function might be used as follows:
31088  *
31089  * <programlisting>
31090  * GVariant *
31091  * make_pointless_dictionary (void)
31092  * {
31093  *   GVariantBuilder *builder;
31094  *   int i;
31095  *
31096  *   builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
31097  *   g_variant_builder_add_parsed (builder, "{'width', <%i>}", 600);
31098  *   g_variant_builder_add_parsed (builder, "{'title', <%s>}", "foo");
31099  *   g_variant_builder_add_parsed (builder, "{'transparency', <0.5>}");
31100  *   return g_variant_builder_end (builder);
31101  * }
31102  * </programlisting>
31103  *
31104  * Since: 2.26
31105  */
31106
31107
31108 /**
31109  * g_variant_builder_add_value:
31110  * @builder: a #GVariantBuilder
31111  * @value: a #GVariant
31112  *
31113  * Adds @value to @builder.
31114  *
31115  * It is an error to call this function in any way that would create an
31116  * inconsistent value to be constructed.  Some examples of this are
31117  * putting different types of items into an array, putting the wrong
31118  * types or number of items in a tuple, putting more than one value into
31119  * a variant, etc.
31120  *
31121  * If @value is a floating reference (see g_variant_ref_sink()),
31122  * the @builder instance takes ownership of @value.
31123  *
31124  * Since: 2.24
31125  */
31126
31127
31128 /**
31129  * g_variant_builder_clear: (skip)
31130  * @builder: a #GVariantBuilder
31131  *
31132  * Releases all memory associated with a #GVariantBuilder without
31133  * freeing the #GVariantBuilder structure itself.
31134  *
31135  * It typically only makes sense to do this on a stack-allocated
31136  * #GVariantBuilder if you want to abort building the value part-way
31137  * through.  This function need not be called if you call
31138  * g_variant_builder_end() and it also doesn't need to be called on
31139  * builders allocated with g_variant_builder_new (see
31140  * g_variant_builder_unref() for that).
31141  *
31142  * This function leaves the #GVariantBuilder structure set to all-zeros.
31143  * It is valid to call this function on either an initialised
31144  * #GVariantBuilder or one that is set to all-zeros but it is not valid
31145  * to call this function on uninitialised memory.
31146  *
31147  * Since: 2.24
31148  */
31149
31150
31151 /**
31152  * g_variant_builder_close:
31153  * @builder: a #GVariantBuilder
31154  *
31155  * Closes the subcontainer inside the given @builder that was opened by
31156  * the most recent call to g_variant_builder_open().
31157  *
31158  * It is an error to call this function in any way that would create an
31159  * inconsistent value to be constructed (ie: too few values added to the
31160  * subcontainer).
31161  *
31162  * Since: 2.24
31163  */
31164
31165
31166 /**
31167  * g_variant_builder_end:
31168  * @builder: a #GVariantBuilder
31169  *
31170  * Ends the builder process and returns the constructed value.
31171  *
31172  * It is not permissible to use @builder in any way after this call
31173  * except for reference counting operations (in the case of a
31174  * heap-allocated #GVariantBuilder) or by reinitialising it with
31175  * g_variant_builder_init() (in the case of stack-allocated).
31176  *
31177  * It is an error to call this function in any way that would create an
31178  * inconsistent value to be constructed (ie: insufficient number of
31179  * items added to a container with a specific number of children
31180  * required).  It is also an error to call this function if the builder
31181  * was created with an indefinite array or maybe type and no children
31182  * have been added; in this case it is impossible to infer the type of
31183  * the empty array.
31184  *
31185  * Returns: (transfer none): a new, floating, #GVariant
31186  * Since: 2.24
31187  */
31188
31189
31190 /**
31191  * g_variant_builder_init: (skip)
31192  * @builder: a #GVariantBuilder
31193  * @type: a container type
31194  *
31195  * Initialises a #GVariantBuilder structure.
31196  *
31197  * @type must be non-%NULL.  It specifies the type of container to
31198  * construct.  It can be an indefinite type such as
31199  * %G_VARIANT_TYPE_ARRAY or a definite type such as "as" or "(ii)".
31200  * Maybe, array, tuple, dictionary entry and variant-typed values may be
31201  * constructed.
31202  *
31203  * After the builder is initialised, values are added using
31204  * g_variant_builder_add_value() or g_variant_builder_add().
31205  *
31206  * After all the child values are added, g_variant_builder_end() frees
31207  * the memory associated with the builder and returns the #GVariant that
31208  * was created.
31209  *
31210  * This function completely ignores the previous contents of @builder.
31211  * On one hand this means that it is valid to pass in completely
31212  * uninitialised memory.  On the other hand, this means that if you are
31213  * initialising over top of an existing #GVariantBuilder you need to
31214  * first call g_variant_builder_clear() in order to avoid leaking
31215  * memory.
31216  *
31217  * You must not call g_variant_builder_ref() or
31218  * g_variant_builder_unref() on a #GVariantBuilder that was initialised
31219  * with this function.  If you ever pass a reference to a
31220  * #GVariantBuilder outside of the control of your own code then you
31221  * should assume that the person receiving that reference may try to use
31222  * reference counting; you should use g_variant_builder_new() instead of
31223  * this function.
31224  *
31225  * Since: 2.24
31226  */
31227
31228
31229 /**
31230  * g_variant_builder_new:
31231  * @type: a container type
31232  *
31233  * Allocates and initialises a new #GVariantBuilder.
31234  *
31235  * You should call g_variant_builder_unref() on the return value when it
31236  * is no longer needed.  The memory will not be automatically freed by
31237  * any other call.
31238  *
31239  * In most cases it is easier to place a #GVariantBuilder directly on
31240  * the stack of the calling function and initialise it with
31241  * g_variant_builder_init().
31242  *
31243  * Returns: (transfer full): a #GVariantBuilder
31244  * Since: 2.24
31245  */
31246
31247
31248 /**
31249  * g_variant_builder_open:
31250  * @builder: a #GVariantBuilder
31251  * @type: a #GVariantType
31252  *
31253  * Opens a subcontainer inside the given @builder.  When done adding
31254  * items to the subcontainer, g_variant_builder_close() must be called.
31255  *
31256  * It is an error to call this function in any way that would cause an
31257  * inconsistent value to be constructed (ie: adding too many values or
31258  * a value of an incorrect type).
31259  *
31260  * Since: 2.24
31261  */
31262
31263
31264 /**
31265  * g_variant_builder_ref:
31266  * @builder: a #GVariantBuilder allocated by g_variant_builder_new()
31267  *
31268  * Increases the reference count on @builder.
31269  *
31270  * Don't call this on stack-allocated #GVariantBuilder instances or bad
31271  * things will happen.
31272  *
31273  * Returns: (transfer full): a new reference to @builder
31274  * Since: 2.24
31275  */
31276
31277
31278 /**
31279  * g_variant_builder_unref:
31280  * @builder: (transfer full): a #GVariantBuilder allocated by g_variant_builder_new()
31281  *
31282  * Decreases the reference count on @builder.
31283  *
31284  * In the event that there are no more references, releases all memory
31285  * associated with the #GVariantBuilder.
31286  *
31287  * Don't call this on stack-allocated #GVariantBuilder instances or bad
31288  * things will happen.
31289  *
31290  * Since: 2.24
31291  */
31292
31293
31294 /**
31295  * g_variant_byteswap:
31296  * @value: a #GVariant
31297  *
31298  * Performs a byteswapping operation on the contents of @value.  The
31299  * result is that all multi-byte numeric data contained in @value is
31300  * byteswapped.  That includes 16, 32, and 64bit signed and unsigned
31301  * integers as well as file handles and double precision floating point
31302  * values.
31303  *
31304  * This function is an identity mapping on any value that does not
31305  * contain multi-byte numeric data.  That include strings, booleans,
31306  * bytes and containers containing only these things (recursively).
31307  *
31308  * The returned value is always in normal form and is marked as trusted.
31309  *
31310  * Returns: (transfer full): the byteswapped form of @value
31311  * Since: 2.24
31312  */
31313
31314
31315 /**
31316  * g_variant_check_format_string:
31317  * @value: a #GVariant
31318  * @format_string: a valid #GVariant format string
31319  * @copy_only: %TRUE to ensure the format string makes deep copies
31320  *
31321  * Checks if calling g_variant_get() with @format_string on @value would
31322  * be valid from a type-compatibility standpoint.  @format_string is
31323  * assumed to be a valid format string (from a syntactic standpoint).
31324  *
31325  * If @copy_only is %TRUE then this function additionally checks that it
31326  * would be safe to call g_variant_unref() on @value immediately after
31327  * the call to g_variant_get() without invalidating the result.  This is
31328  * only possible if deep copies are made (ie: there are no pointers to
31329  * the data inside of the soon-to-be-freed #GVariant instance).  If this
31330  * check fails then a g_critical() is printed and %FALSE is returned.
31331  *
31332  * This function is meant to be used by functions that wish to provide
31333  * varargs accessors to #GVariant values of uncertain values (eg:
31334  * g_variant_lookup() or g_menu_model_get_item_attribute()).
31335  *
31336  * Returns: %TRUE if @format_string is safe to use
31337  * Since: 2.34
31338  */
31339
31340
31341 /**
31342  * g_variant_classify:
31343  * @value: a #GVariant
31344  *
31345  * Classifies @value according to its top-level type.
31346  *
31347  * Returns: the #GVariantClass of @value
31348  * Since: 2.24
31349  */
31350
31351
31352 /**
31353  * g_variant_compare:
31354  * @one: (type GVariant): a basic-typed #GVariant instance
31355  * @two: (type GVariant): a #GVariant instance of the same type
31356  *
31357  * Compares @one and @two.
31358  *
31359  * The types of @one and @two are #gconstpointer only to allow use of
31360  * this function with #GTree, #GPtrArray, etc.  They must each be a
31361  * #GVariant.
31362  *
31363  * Comparison is only defined for basic types (ie: booleans, numbers,
31364  * strings).  For booleans, %FALSE is less than %TRUE.  Numbers are
31365  * ordered in the usual way.  Strings are in ASCII lexographical order.
31366  *
31367  * It is a programmer error to attempt to compare container values or
31368  * two values that have types that are not exactly equal.  For example,
31369  * you cannot compare a 32-bit signed integer with a 32-bit unsigned
31370  * integer.  Also note that this function is not particularly
31371  * well-behaved when it comes to comparison of doubles; in particular,
31372  * the handling of incomparable values (ie: NaN) is undefined.
31373  *
31374  * If you only require an equality comparison, g_variant_equal() is more
31375  * general.
31376  *
31377  * Returns: negative value if a &lt; b; zero if a = b; positive value if a &gt; b.
31378  * Since: 2.26
31379  */
31380
31381
31382 /**
31383  * g_variant_dup_bytestring:
31384  * @value: an array-of-bytes #GVariant instance
31385  * @length: (out) (allow-none) (default NULL): a pointer to a #gsize, to store the length (not including the nul terminator)
31386  *
31387  * Similar to g_variant_get_bytestring() except that instead of
31388  * returning a constant string, the string is duplicated.
31389  *
31390  * The return value must be freed using g_free().
31391  *
31392  * Returns: (transfer full) (array zero-terminated=1 length=length) (element-type guint8): a newly allocated string
31393  * Since: 2.26
31394  */
31395
31396
31397 /**
31398  * g_variant_dup_bytestring_array:
31399  * @value: an array of array of bytes #GVariant ('aay')
31400  * @length: (out) (allow-none): the length of the result, or %NULL
31401  *
31402  * Gets the contents of an array of array of bytes #GVariant.  This call
31403  * makes a deep copy; the return result should be released with
31404  * g_strfreev().
31405  *
31406  * If @length is non-%NULL then the number of elements in the result is
31407  * stored there.  In any case, the resulting array will be
31408  * %NULL-terminated.
31409  *
31410  * For an empty array, @length will be set to 0 and a pointer to a
31411  * %NULL pointer will be returned.
31412  *
31413  * Returns: (array length=length) (transfer full): an array of strings
31414  * Since: 2.26
31415  */
31416
31417
31418 /**
31419  * g_variant_dup_objv:
31420  * @value: an array of object paths #GVariant
31421  * @length: (out) (allow-none): the length of the result, or %NULL
31422  *
31423  * Gets the contents of an array of object paths #GVariant.  This call
31424  * makes a deep copy; the return result should be released with
31425  * g_strfreev().
31426  *
31427  * If @length is non-%NULL then the number of elements in the result
31428  * is stored there.  In any case, the resulting array will be
31429  * %NULL-terminated.
31430  *
31431  * For an empty array, @length will be set to 0 and a pointer to a
31432  * %NULL pointer will be returned.
31433  *
31434  * Returns: (array length=length zero-terminated=1) (transfer full): an array of strings
31435  * Since: 2.30
31436  */
31437
31438
31439 /**
31440  * g_variant_dup_string:
31441  * @value: a string #GVariant instance
31442  * @length: (out): a pointer to a #gsize, to store the length
31443  *
31444  * Similar to g_variant_get_string() except that instead of returning
31445  * a constant string, the string is duplicated.
31446  *
31447  * The string will always be utf8 encoded.
31448  *
31449  * The return value must be freed using g_free().
31450  *
31451  * Returns: (transfer full): a newly allocated string, utf8 encoded
31452  * Since: 2.24
31453  */
31454
31455
31456 /**
31457  * g_variant_dup_strv:
31458  * @value: an array of strings #GVariant
31459  * @length: (out) (allow-none): the length of the result, or %NULL
31460  *
31461  * Gets the contents of an array of strings #GVariant.  This call
31462  * makes a deep copy; the return result should be released with
31463  * g_strfreev().
31464  *
31465  * If @length is non-%NULL then the number of elements in the result
31466  * is stored there.  In any case, the resulting array will be
31467  * %NULL-terminated.
31468  *
31469  * For an empty array, @length will be set to 0 and a pointer to a
31470  * %NULL pointer will be returned.
31471  *
31472  * Returns: (array length=length zero-terminated=1) (transfer full): an array of strings
31473  * Since: 2.24
31474  */
31475
31476
31477 /**
31478  * g_variant_equal:
31479  * @one: (type GVariant): a #GVariant instance
31480  * @two: (type GVariant): a #GVariant instance
31481  *
31482  * Checks if @one and @two have the same type and value.
31483  *
31484  * The types of @one and @two are #gconstpointer only to allow use of
31485  * this function with #GHashTable.  They must each be a #GVariant.
31486  *
31487  * Returns: %TRUE if @one and @two are equal
31488  * Since: 2.24
31489  */
31490
31491
31492 /**
31493  * g_variant_get: (skip)
31494  * @value: a #GVariant instance
31495  * @format_string: a #GVariant format string
31496  * @...: arguments, as per @format_string
31497  *
31498  * Deconstructs a #GVariant instance.
31499  *
31500  * Think of this function as an analogue to scanf().
31501  *
31502  * The arguments that are expected by this function are entirely
31503  * determined by @format_string.  @format_string also restricts the
31504  * permissible types of @value.  It is an error to give a value with
31505  * an incompatible type.  See the section on <link
31506  * linkend='gvariant-format-strings'>GVariant Format Strings</link>.
31507  * Please note that the syntax of the format string is very likely to be
31508  * extended in the future.
31509  *
31510  * @format_string determines the C types that are used for unpacking
31511  * the values and also determines if the values are copied or borrowed,
31512  * see the section on
31513  * <link linkend='gvariant-format-strings-pointers'>GVariant Format Strings</link>.
31514  *
31515  * Since: 2.24
31516  */
31517
31518
31519 /**
31520  * g_variant_get_boolean:
31521  * @value: a boolean #GVariant instance
31522  *
31523  * Returns the boolean value of @value.
31524  *
31525  * It is an error to call this function with a @value of any type
31526  * other than %G_VARIANT_TYPE_BOOLEAN.
31527  *
31528  * Returns: %TRUE or %FALSE
31529  * Since: 2.24
31530  */
31531
31532
31533 /**
31534  * g_variant_get_byte:
31535  * @value: a byte #GVariant instance
31536  *
31537  * Returns the byte value of @value.
31538  *
31539  * It is an error to call this function with a @value of any type
31540  * other than %G_VARIANT_TYPE_BYTE.
31541  *
31542  * Returns: a #guchar
31543  * Since: 2.24
31544  */
31545
31546
31547 /**
31548  * g_variant_get_bytestring:
31549  * @value: an array-of-bytes #GVariant instance
31550  *
31551  * Returns the string value of a #GVariant instance with an
31552  * array-of-bytes type.  The string has no particular encoding.
31553  *
31554  * If the array does not end with a nul terminator character, the empty
31555  * string is returned.  For this reason, you can always trust that a
31556  * non-%NULL nul-terminated string will be returned by this function.
31557  *
31558  * If the array contains a nul terminator character somewhere other than
31559  * the last byte then the returned string is the string, up to the first
31560  * such nul character.
31561  *
31562  * It is an error to call this function with a @value that is not an
31563  * array of bytes.
31564  *
31565  * The return value remains valid as long as @value exists.
31566  *
31567  * Returns: (transfer none) (array zero-terminated=1) (element-type guint8): the constant string
31568  * Since: 2.26
31569  */
31570
31571
31572 /**
31573  * g_variant_get_bytestring_array:
31574  * @value: an array of array of bytes #GVariant ('aay')
31575  * @length: (out) (allow-none): the length of the result, or %NULL
31576  *
31577  * Gets the contents of an array of array of bytes #GVariant.  This call
31578  * makes a shallow copy; the return result should be released with
31579  * g_free(), but the individual strings must not be modified.
31580  *
31581  * If @length is non-%NULL then the number of elements in the result is
31582  * stored there.  In any case, the resulting array will be
31583  * %NULL-terminated.
31584  *
31585  * For an empty array, @length will be set to 0 and a pointer to a
31586  * %NULL pointer will be returned.
31587  *
31588  * Returns: (array length=length) (transfer container): an array of constant strings
31589  * Since: 2.26
31590  */
31591
31592
31593 /**
31594  * g_variant_get_child: (skip)
31595  * @value: a container #GVariant
31596  * @index_: the index of the child to deconstruct
31597  * @format_string: a #GVariant format string
31598  * @...: arguments, as per @format_string
31599  *
31600  * Reads a child item out of a container #GVariant instance and
31601  * deconstructs it according to @format_string.  This call is
31602  * essentially a combination of g_variant_get_child_value() and
31603  * g_variant_get().
31604  *
31605  * @format_string determines the C types that are used for unpacking
31606  * the values and also determines if the values are copied or borrowed,
31607  * see the section on
31608  * <link linkend='gvariant-format-strings-pointers'>GVariant Format Strings</link>.
31609  *
31610  * Since: 2.24
31611  */
31612
31613
31614 /**
31615  * g_variant_get_child_value:
31616  * @value: a container #GVariant
31617  * @index_: the index of the child to fetch
31618  *
31619  * Reads a child item out of a container #GVariant instance.  This
31620  * includes variants, maybes, arrays, tuples and dictionary
31621  * entries.  It is an error to call this function on any other type of
31622  * #GVariant.
31623  *
31624  * It is an error if @index_ is greater than the number of child items
31625  * in the container.  See g_variant_n_children().
31626  *
31627  * The returned value is never floating.  You should free it with
31628  * g_variant_unref() when you're done with it.
31629  *
31630  * This function is O(1).
31631  *
31632  * Returns: (transfer full): the child at the specified index
31633  * Since: 2.24
31634  */
31635
31636
31637 /**
31638  * g_variant_get_data:
31639  * @value: a #GVariant instance
31640  *
31641  * Returns a pointer to the serialised form of a #GVariant instance.
31642  * The returned data may not be in fully-normalised form if read from an
31643  * untrusted source.  The returned data must not be freed; it remains
31644  * valid for as long as @value exists.
31645  *
31646  * If @value is a fixed-sized value that was deserialised from a
31647  * corrupted serialised container then %NULL may be returned.  In this
31648  * case, the proper thing to do is typically to use the appropriate
31649  * number of nul bytes in place of @value.  If @value is not fixed-sized
31650  * then %NULL is never returned.
31651  *
31652  * In the case that @value is already in serialised form, this function
31653  * is O(1).  If the value is not already in serialised form,
31654  * serialisation occurs implicitly and is approximately O(n) in the size
31655  * of the result.
31656  *
31657  * To deserialise the data returned by this function, in addition to the
31658  * serialised data, you must know the type of the #GVariant, and (if the
31659  * machine might be different) the endianness of the machine that stored
31660  * it. As a result, file formats or network messages that incorporate
31661  * serialised #GVariant<!---->s must include this information either
31662  * implicitly (for instance "the file always contains a
31663  * %G_VARIANT_TYPE_VARIANT and it is always in little-endian order") or
31664  * explicitly (by storing the type and/or endianness in addition to the
31665  * serialised data).
31666  *
31667  * Returns: (transfer none): the serialised form of @value, or %NULL
31668  * Since: 2.24
31669  */
31670
31671
31672 /**
31673  * g_variant_get_data_as_bytes:
31674  * @value: a #GVariant
31675  *
31676  * Returns a pointer to the serialised form of a #GVariant instance.
31677  * The semantics of this function are exactly the same as
31678  * g_variant_get_data(), except that the returned #GBytes holds
31679  * a reference to the variant data.
31680  *
31681  * Returns: (transfer full): A new #GBytes representing the variant data
31682  * Since: 2.36
31683  */
31684
31685
31686 /**
31687  * g_variant_get_double:
31688  * @value: a double #GVariant instance
31689  *
31690  * Returns the double precision floating point value of @value.
31691  *
31692  * It is an error to call this function with a @value of any type
31693  * other than %G_VARIANT_TYPE_DOUBLE.
31694  *
31695  * Returns: a #gdouble
31696  * Since: 2.24
31697  */
31698
31699
31700 /**
31701  * g_variant_get_fixed_array:
31702  * @value: a #GVariant array with fixed-sized elements
31703  * @n_elements: (out): a pointer to the location to store the number of items
31704  * @element_size: the size of each element
31705  *
31706  * Provides access to the serialised data for an array of fixed-sized
31707  * items.
31708  *
31709  * @value must be an array with fixed-sized elements.  Numeric types are
31710  * fixed-size, as are tuples containing only other fixed-sized types.
31711  *
31712  * @element_size must be the size of a single element in the array,
31713  * as given by the section on
31714  * <link linkend='gvariant-serialised-data-memory'>Serialised Data
31715  * Memory</link>.
31716  *
31717  * In particular, arrays of these fixed-sized types can be interpreted
31718  * as an array of the given C type, with @element_size set to
31719  * <code>sizeof</code> the appropriate type:
31720  *
31721  * <informaltable>
31722  * <tgroup cols='2'>
31723  * <thead><row><entry>element type</entry> <entry>C type</entry></row></thead>
31724  * <tbody>
31725  * <row><entry>%G_VARIANT_TYPE_INT16 (etc.)</entry>
31726  *   <entry>#gint16 (etc.)</entry></row>
31727  * <row><entry>%G_VARIANT_TYPE_BOOLEAN</entry>
31728  *   <entry>#guchar (not #gboolean!)</entry></row>
31729  * <row><entry>%G_VARIANT_TYPE_BYTE</entry> <entry>#guchar</entry></row>
31730  * <row><entry>%G_VARIANT_TYPE_HANDLE</entry> <entry>#guint32</entry></row>
31731  * <row><entry>%G_VARIANT_TYPE_DOUBLE</entry> <entry>#gdouble</entry></row>
31732  * </tbody>
31733  * </tgroup>
31734  * </informaltable>
31735  *
31736  * For example, if calling this function for an array of 32 bit integers,
31737  * you might say <code>sizeof (gint32)</code>.  This value isn't used
31738  * except for the purpose of a double-check that the form of the
31739  * serialised data matches the caller's expectation.
31740  *
31741  * @n_elements, which must be non-%NULL is set equal to the number of
31742  * items in the array.
31743  *
31744  * Returns: (array length=n_elements) (transfer none): a pointer to the fixed array
31745  * Since: 2.24
31746  */
31747
31748
31749 /**
31750  * g_variant_get_handle:
31751  * @value: a handle #GVariant instance
31752  *
31753  * Returns the 32-bit signed integer value of @value.
31754  *
31755  * It is an error to call this function with a @value of any type other
31756  * than %G_VARIANT_TYPE_HANDLE.
31757  *
31758  * By convention, handles are indexes into an array of file descriptors
31759  * that are sent alongside a D-Bus message.  If you're not interacting
31760  * with D-Bus, you probably don't need them.
31761  *
31762  * Returns: a #gint32
31763  * Since: 2.24
31764  */
31765
31766
31767 /**
31768  * g_variant_get_int16:
31769  * @value: a int16 #GVariant instance
31770  *
31771  * Returns the 16-bit signed integer value of @value.
31772  *
31773  * It is an error to call this function with a @value of any type
31774  * other than %G_VARIANT_TYPE_INT16.
31775  *
31776  * Returns: a #gint16
31777  * Since: 2.24
31778  */
31779
31780
31781 /**
31782  * g_variant_get_int32:
31783  * @value: a int32 #GVariant instance
31784  *
31785  * Returns the 32-bit signed integer value of @value.
31786  *
31787  * It is an error to call this function with a @value of any type
31788  * other than %G_VARIANT_TYPE_INT32.
31789  *
31790  * Returns: a #gint32
31791  * Since: 2.24
31792  */
31793
31794
31795 /**
31796  * g_variant_get_int64:
31797  * @value: a int64 #GVariant instance
31798  *
31799  * Returns the 64-bit signed integer value of @value.
31800  *
31801  * It is an error to call this function with a @value of any type
31802  * other than %G_VARIANT_TYPE_INT64.
31803  *
31804  * Returns: a #gint64
31805  * Since: 2.24
31806  */
31807
31808
31809 /**
31810  * g_variant_get_maybe:
31811  * @value: a maybe-typed value
31812  *
31813  * Given a maybe-typed #GVariant instance, extract its value.  If the
31814  * value is Nothing, then this function returns %NULL.
31815  *
31816  * Returns: (allow-none) (transfer full): the contents of @value, or %NULL
31817  * Since: 2.24
31818  */
31819
31820
31821 /**
31822  * g_variant_get_normal_form:
31823  * @value: a #GVariant
31824  *
31825  * Gets a #GVariant instance that has the same value as @value and is
31826  * trusted to be in normal form.
31827  *
31828  * If @value is already trusted to be in normal form then a new
31829  * reference to @value is returned.
31830  *
31831  * If @value is not already trusted, then it is scanned to check if it
31832  * is in normal form.  If it is found to be in normal form then it is
31833  * marked as trusted and a new reference to it is returned.
31834  *
31835  * If @value is found not to be in normal form then a new trusted
31836  * #GVariant is created with the same value as @value.
31837  *
31838  * It makes sense to call this function if you've received #GVariant
31839  * data from untrusted sources and you want to ensure your serialised
31840  * output is definitely in normal form.
31841  *
31842  * Returns: (transfer full): a trusted #GVariant
31843  * Since: 2.24
31844  */
31845
31846
31847 /**
31848  * g_variant_get_objv:
31849  * @value: an array of object paths #GVariant
31850  * @length: (out) (allow-none): the length of the result, or %NULL
31851  *
31852  * Gets the contents of an array of object paths #GVariant.  This call
31853  * makes a shallow copy; the return result should be released with
31854  * g_free(), but the individual strings must not be modified.
31855  *
31856  * If @length is non-%NULL then the number of elements in the result
31857  * is stored there.  In any case, the resulting array will be
31858  * %NULL-terminated.
31859  *
31860  * For an empty array, @length will be set to 0 and a pointer to a
31861  * %NULL pointer will be returned.
31862  *
31863  * Returns: (array length=length zero-terminated=1) (transfer container): an array of constant strings
31864  * Since: 2.30
31865  */
31866
31867
31868 /**
31869  * g_variant_get_size:
31870  * @value: a #GVariant instance
31871  *
31872  * Determines the number of bytes that would be required to store @value
31873  * with g_variant_store().
31874  *
31875  * If @value has a fixed-sized type then this function always returned
31876  * that fixed size.
31877  *
31878  * In the case that @value is already in serialised form or the size has
31879  * already been calculated (ie: this function has been called before)
31880  * then this function is O(1).  Otherwise, the size is calculated, an
31881  * operation which is approximately O(n) in the number of values
31882  * involved.
31883  *
31884  * Returns: the serialised size of @value
31885  * Since: 2.24
31886  */
31887
31888
31889 /**
31890  * g_variant_get_string:
31891  * @value: a string #GVariant instance
31892  * @length: (allow-none) (default 0) (out): a pointer to a #gsize, to store the length
31893  *
31894  * Returns the string value of a #GVariant instance with a string
31895  * type.  This includes the types %G_VARIANT_TYPE_STRING,
31896  * %G_VARIANT_TYPE_OBJECT_PATH and %G_VARIANT_TYPE_SIGNATURE.
31897  *
31898  * The string will always be utf8 encoded.
31899  *
31900  * If @length is non-%NULL then the length of the string (in bytes) is
31901  * returned there.  For trusted values, this information is already
31902  * known.  For untrusted values, a strlen() will be performed.
31903  *
31904  * It is an error to call this function with a @value of any type
31905  * other than those three.
31906  *
31907  * The return value remains valid as long as @value exists.
31908  *
31909  * Returns: (transfer none): the constant string, utf8 encoded
31910  * Since: 2.24
31911  */
31912
31913
31914 /**
31915  * g_variant_get_strv:
31916  * @value: an array of strings #GVariant
31917  * @length: (out) (allow-none): the length of the result, or %NULL
31918  *
31919  * Gets the contents of an array of strings #GVariant.  This call
31920  * makes a shallow copy; the return result should be released with
31921  * g_free(), but the individual strings must not be modified.
31922  *
31923  * If @length is non-%NULL then the number of elements in the result
31924  * is stored there.  In any case, the resulting array will be
31925  * %NULL-terminated.
31926  *
31927  * For an empty array, @length will be set to 0 and a pointer to a
31928  * %NULL pointer will be returned.
31929  *
31930  * Returns: (array length=length zero-terminated=1) (transfer container): an array of constant strings
31931  * Since: 2.24
31932  */
31933
31934
31935 /**
31936  * g_variant_get_type:
31937  * @value: a #GVariant
31938  *
31939  * Determines the type of @value.
31940  *
31941  * The return value is valid for the lifetime of @value and must not
31942  * be freed.
31943  *
31944  * Returns: a #GVariantType
31945  * Since: 2.24
31946  */
31947
31948
31949 /**
31950  * g_variant_get_type_string:
31951  * @value: a #GVariant
31952  *
31953  * Returns the type string of @value.  Unlike the result of calling
31954  * g_variant_type_peek_string(), this string is nul-terminated.  This
31955  * string belongs to #GVariant and must not be freed.
31956  *
31957  * Returns: the type string for the type of @value
31958  * Since: 2.24
31959  */
31960
31961
31962 /**
31963  * g_variant_get_uint16:
31964  * @value: a uint16 #GVariant instance
31965  *
31966  * Returns the 16-bit unsigned integer value of @value.
31967  *
31968  * It is an error to call this function with a @value of any type
31969  * other than %G_VARIANT_TYPE_UINT16.
31970  *
31971  * Returns: a #guint16
31972  * Since: 2.24
31973  */
31974
31975
31976 /**
31977  * g_variant_get_uint32:
31978  * @value: a uint32 #GVariant instance
31979  *
31980  * Returns the 32-bit unsigned integer value of @value.
31981  *
31982  * It is an error to call this function with a @value of any type
31983  * other than %G_VARIANT_TYPE_UINT32.
31984  *
31985  * Returns: a #guint32
31986  * Since: 2.24
31987  */
31988
31989
31990 /**
31991  * g_variant_get_uint64:
31992  * @value: a uint64 #GVariant instance
31993  *
31994  * Returns the 64-bit unsigned integer value of @value.
31995  *
31996  * It is an error to call this function with a @value of any type
31997  * other than %G_VARIANT_TYPE_UINT64.
31998  *
31999  * Returns: a #guint64
32000  * Since: 2.24
32001  */
32002
32003
32004 /**
32005  * g_variant_get_va: (skip)
32006  * @value: a #GVariant
32007  * @format_string: a string that is prefixed with a format string
32008  * @endptr: (allow-none) (default NULL): location to store the end pointer, or %NULL
32009  * @app: a pointer to a #va_list
32010  *
32011  * This function is intended to be used by libraries based on #GVariant
32012  * that want to provide g_variant_get()-like functionality to their
32013  * users.
32014  *
32015  * The API is more general than g_variant_get() to allow a wider range
32016  * of possible uses.
32017  *
32018  * @format_string must still point to a valid format string, but it only
32019  * need to be nul-terminated if @endptr is %NULL.  If @endptr is
32020  * non-%NULL then it is updated to point to the first character past the
32021  * end of the format string.
32022  *
32023  * @app is a pointer to a #va_list.  The arguments, according to
32024  * @format_string, are collected from this #va_list and the list is left
32025  * pointing to the argument following the last.
32026  *
32027  * These two generalisations allow mixing of multiple calls to
32028  * g_variant_new_va() and g_variant_get_va() within a single actual
32029  * varargs call by the user.
32030  *
32031  * @format_string determines the C types that are used for unpacking
32032  * the values and also determines if the values are copied or borrowed,
32033  * see the section on
32034  * <link linkend='gvariant-format-strings-pointers'>GVariant Format Strings</link>.
32035  *
32036  * Since: 2.24
32037  */
32038
32039
32040 /**
32041  * g_variant_get_variant:
32042  * @value: a variant #GVariant instance
32043  *
32044  * Unboxes @value.  The result is the #GVariant instance that was
32045  * contained in @value.
32046  *
32047  * Returns: (transfer full): the item contained in the variant
32048  * Since: 2.24
32049  */
32050
32051
32052 /**
32053  * g_variant_hash:
32054  * @value: (type GVariant): a basic #GVariant value as a #gconstpointer
32055  *
32056  * Generates a hash value for a #GVariant instance.
32057  *
32058  * The output of this function is guaranteed to be the same for a given
32059  * value only per-process.  It may change between different processor
32060  * architectures or even different versions of GLib.  Do not use this
32061  * function as a basis for building protocols or file formats.
32062  *
32063  * The type of @value is #gconstpointer only to allow use of this
32064  * function with #GHashTable.  @value must be a #GVariant.
32065  *
32066  * Returns: a hash value corresponding to @value
32067  * Since: 2.24
32068  */
32069
32070
32071 /**
32072  * g_variant_is_container:
32073  * @value: a #GVariant instance
32074  *
32075  * Checks if @value is a container.
32076  *
32077  * Returns: %TRUE if @value is a container
32078  * Since: 2.24
32079  */
32080
32081
32082 /**
32083  * g_variant_is_floating:
32084  * @value: a #GVariant
32085  *
32086  * Checks whether @value has a floating reference count.
32087  *
32088  * This function should only ever be used to assert that a given variant
32089  * is or is not floating, or for debug purposes. To acquire a reference
32090  * to a variant that might be floating, always use g_variant_ref_sink()
32091  * or g_variant_take_ref().
32092  *
32093  * See g_variant_ref_sink() for more information about floating reference
32094  * counts.
32095  *
32096  * Returns: whether @value is floating
32097  * Since: 2.26
32098  */
32099
32100
32101 /**
32102  * g_variant_is_normal_form:
32103  * @value: a #GVariant instance
32104  *
32105  * Checks if @value is in normal form.
32106  *
32107  * The main reason to do this is to detect if a given chunk of
32108  * serialised data is in normal form: load the data into a #GVariant
32109  * using g_variant_new_from_data() and then use this function to
32110  * check.
32111  *
32112  * If @value is found to be in normal form then it will be marked as
32113  * being trusted.  If the value was already marked as being trusted then
32114  * this function will immediately return %TRUE.
32115  *
32116  * Returns: %TRUE if @value is in normal form
32117  * Since: 2.24
32118  */
32119
32120
32121 /**
32122  * g_variant_is_object_path:
32123  * @string: a normal C nul-terminated string
32124  *
32125  * Determines if a given string is a valid D-Bus object path.  You
32126  * should ensure that a string is a valid D-Bus object path before
32127  * passing it to g_variant_new_object_path().
32128  *
32129  * A valid object path starts with '/' followed by zero or more
32130  * sequences of characters separated by '/' characters.  Each sequence
32131  * must contain only the characters "[A-Z][a-z][0-9]_".  No sequence
32132  * (including the one following the final '/' character) may be empty.
32133  *
32134  * Returns: %TRUE if @string is a D-Bus object path
32135  * Since: 2.24
32136  */
32137
32138
32139 /**
32140  * g_variant_is_of_type:
32141  * @value: a #GVariant instance
32142  * @type: a #GVariantType
32143  *
32144  * Checks if a value has a type matching the provided type.
32145  *
32146  * Returns: %TRUE if the type of @value matches @type
32147  * Since: 2.24
32148  */
32149
32150
32151 /**
32152  * g_variant_is_signature:
32153  * @string: a normal C nul-terminated string
32154  *
32155  * Determines if a given string is a valid D-Bus type signature.  You
32156  * should ensure that a string is a valid D-Bus type signature before
32157  * passing it to g_variant_new_signature().
32158  *
32159  * D-Bus type signatures consist of zero or more definite #GVariantType
32160  * strings in sequence.
32161  *
32162  * Returns: %TRUE if @string is a D-Bus type signature
32163  * Since: 2.24
32164  */
32165
32166
32167 /**
32168  * g_variant_iter_copy:
32169  * @iter: a #GVariantIter
32170  *
32171  * Creates a new heap-allocated #GVariantIter to iterate over the
32172  * container that was being iterated over by @iter.  Iteration begins on
32173  * the new iterator from the current position of the old iterator but
32174  * the two copies are independent past that point.
32175  *
32176  * Use g_variant_iter_free() to free the return value when you no longer
32177  * need it.
32178  *
32179  * A reference is taken to the container that @iter is iterating over
32180  * and will be releated only when g_variant_iter_free() is called.
32181  *
32182  * Returns: (transfer full): a new heap-allocated #GVariantIter
32183  * Since: 2.24
32184  */
32185
32186
32187 /**
32188  * g_variant_iter_free:
32189  * @iter: (transfer full): a heap-allocated #GVariantIter
32190  *
32191  * Frees a heap-allocated #GVariantIter.  Only call this function on
32192  * iterators that were returned by g_variant_iter_new() or
32193  * g_variant_iter_copy().
32194  *
32195  * Since: 2.24
32196  */
32197
32198
32199 /**
32200  * g_variant_iter_init: (skip)
32201  * @iter: a pointer to a #GVariantIter
32202  * @value: a container #GVariant
32203  *
32204  * Initialises (without allocating) a #GVariantIter.  @iter may be
32205  * completely uninitialised prior to this call; its old value is
32206  * ignored.
32207  *
32208  * The iterator remains valid for as long as @value exists, and need not
32209  * be freed in any way.
32210  *
32211  * Returns: the number of items in @value
32212  * Since: 2.24
32213  */
32214
32215
32216 /**
32217  * g_variant_iter_loop: (skip)
32218  * @iter: a #GVariantIter
32219  * @format_string: a GVariant format string
32220  * @...: the arguments to unpack the value into
32221  *
32222  * Gets the next item in the container and unpacks it into the variable
32223  * argument list according to @format_string, returning %TRUE.
32224  *
32225  * If no more items remain then %FALSE is returned.
32226  *
32227  * On the first call to this function, the pointers appearing on the
32228  * variable argument list are assumed to point at uninitialised memory.
32229  * On the second and later calls, it is assumed that the same pointers
32230  * will be given and that they will point to the memory as set by the
32231  * previous call to this function.  This allows the previous values to
32232  * be freed, as appropriate.
32233  *
32234  * This function is intended to be used with a while loop as
32235  * demonstrated in the following example.  This function can only be
32236  * used when iterating over an array.  It is only valid to call this
32237  * function with a string constant for the format string and the same
32238  * string constant must be used each time.  Mixing calls to this
32239  * function and g_variant_iter_next() or g_variant_iter_next_value() on
32240  * the same iterator causes undefined behavior.
32241  *
32242  * If you break out of a such a while loop using g_variant_iter_loop() then
32243  * you must free or unreference all the unpacked values as you would with
32244  * g_variant_get(). Failure to do so will cause a memory leak.
32245  *
32246  * See the section on <link linkend='gvariant-format-strings'>GVariant
32247  * Format Strings</link>.
32248  *
32249  * <example>
32250  *  <title>Memory management with g_variant_iter_loop()</title>
32251  *  <programlisting>
32252  *   /<!-- -->* Iterates a dictionary of type 'a{sv}' *<!-- -->/
32253  *   void
32254  *   iterate_dictionary (GVariant *dictionary)
32255  *   {
32256  *     GVariantIter iter;
32257  *     GVariant *value;
32258  *     gchar *key;
32259  *
32260  *     g_variant_iter_init (&iter, dictionary);
32261  *     while (g_variant_iter_loop (&iter, "{sv}", &key, &value))
32262  *       {
32263  *         g_print ("Item '%s' has type '%s'\n", key,
32264  *                  g_variant_get_type_string (value));
32265  *
32266  *         /<!-- -->* no need to free 'key' and 'value' here *<!-- -->/
32267  *         /<!-- -->* unless breaking out of this loop *<!-- -->/
32268  *       }
32269  *   }
32270  *  </programlisting>
32271  * </example>
32272  *
32273  * For most cases you should use g_variant_iter_next().
32274  *
32275  * This function is really only useful when unpacking into #GVariant or
32276  * #GVariantIter in order to allow you to skip the call to
32277  * g_variant_unref() or g_variant_iter_free().
32278  *
32279  * For example, if you are only looping over simple integer and string
32280  * types, g_variant_iter_next() is definitely preferred.  For string
32281  * types, use the '&' prefix to avoid allocating any memory at all (and
32282  * thereby avoiding the need to free anything as well).
32283  *
32284  * @format_string determines the C types that are used for unpacking
32285  * the values and also determines if the values are copied or borrowed,
32286  * see the section on
32287  * <link linkend='gvariant-format-strings-pointers'>GVariant Format Strings</link>.
32288  *
32289  * Returns: %TRUE if a value was unpacked, or %FALSE if there was no value
32290  * Since: 2.24
32291  */
32292
32293
32294 /**
32295  * g_variant_iter_n_children:
32296  * @iter: a #GVariantIter
32297  *
32298  * Queries the number of child items in the container that we are
32299  * iterating over.  This is the total number of items -- not the number
32300  * of items remaining.
32301  *
32302  * This function might be useful for preallocation of arrays.
32303  *
32304  * Returns: the number of children in the container
32305  * Since: 2.24
32306  */
32307
32308
32309 /**
32310  * g_variant_iter_new:
32311  * @value: a container #GVariant
32312  *
32313  * Creates a heap-allocated #GVariantIter for iterating over the items
32314  * in @value.
32315  *
32316  * Use g_variant_iter_free() to free the return value when you no longer
32317  * need it.
32318  *
32319  * A reference is taken to @value and will be released only when
32320  * g_variant_iter_free() is called.
32321  *
32322  * Returns: (transfer full): a new heap-allocated #GVariantIter
32323  * Since: 2.24
32324  */
32325
32326
32327 /**
32328  * g_variant_iter_next: (skip)
32329  * @iter: a #GVariantIter
32330  * @format_string: a GVariant format string
32331  * @...: the arguments to unpack the value into
32332  *
32333  * Gets the next item in the container and unpacks it into the variable
32334  * argument list according to @format_string, returning %TRUE.
32335  *
32336  * If no more items remain then %FALSE is returned.
32337  *
32338  * All of the pointers given on the variable arguments list of this
32339  * function are assumed to point at uninitialised memory.  It is the
32340  * responsibility of the caller to free all of the values returned by
32341  * the unpacking process.
32342  *
32343  * See the section on <link linkend='gvariant-format-strings'>GVariant
32344  * Format Strings</link>.
32345  *
32346  * <example>
32347  *  <title>Memory management with g_variant_iter_next()</title>
32348  *  <programlisting>
32349  *   /<!-- -->* Iterates a dictionary of type 'a{sv}' *<!-- -->/
32350  *   void
32351  *   iterate_dictionary (GVariant *dictionary)
32352  *   {
32353  *     GVariantIter iter;
32354  *     GVariant *value;
32355  *     gchar *key;
32356  *
32357  *     g_variant_iter_init (&iter, dictionary);
32358  *     while (g_variant_iter_next (&iter, "{sv}", &key, &value))
32359  *       {
32360  *         g_print ("Item '%s' has type '%s'\n", key,
32361  *                  g_variant_get_type_string (value));
32362  *
32363  *         /<!-- -->* must free data for ourselves *<!-- -->/
32364  *         g_variant_unref (value);
32365  *         g_free (key);
32366  *       }
32367  *   }
32368  *  </programlisting>
32369  * </example>
32370  *
32371  * For a solution that is likely to be more convenient to C programmers
32372  * when dealing with loops, see g_variant_iter_loop().
32373  *
32374  * @format_string determines the C types that are used for unpacking
32375  * the values and also determines if the values are copied or borrowed,
32376  * see the section on
32377  * <link linkend='gvariant-format-strings-pointers'>GVariant Format Strings</link>.
32378  *
32379  * Returns: %TRUE if a value was unpacked, or %FALSE if there as no value
32380  * Since: 2.24
32381  */
32382
32383
32384 /**
32385  * g_variant_iter_next_value:
32386  * @iter: a #GVariantIter
32387  *
32388  * Gets the next item in the container.  If no more items remain then
32389  * %NULL is returned.
32390  *
32391  * Use g_variant_unref() to drop your reference on the return value when
32392  * you no longer need it.
32393  *
32394  * <example>
32395  *  <title>Iterating with g_variant_iter_next_value()</title>
32396  *  <programlisting>
32397  *   /<!-- -->* recursively iterate a container *<!-- -->/
32398  *   void
32399  *   iterate_container_recursive (GVariant *container)
32400  *   {
32401  *     GVariantIter iter;
32402  *     GVariant *child;
32403  *
32404  *     g_variant_iter_init (&iter, container);
32405  *     while ((child = g_variant_iter_next_value (&iter)))
32406  *       {
32407  *         g_print ("type '%s'\n", g_variant_get_type_string (child));
32408  *
32409  *         if (g_variant_is_container (child))
32410  *           iterate_container_recursive (child);
32411  *
32412  *         g_variant_unref (child);
32413  *       }
32414  *   }
32415  * </programlisting>
32416  * </example>
32417  *
32418  * Returns: (allow-none) (transfer full): a #GVariant, or %NULL
32419  * Since: 2.24
32420  */
32421
32422
32423 /**
32424  * g_variant_lookup: (skip)
32425  * @dictionary: a dictionary #GVariant
32426  * @key: the key to lookup in the dictionary
32427  * @format_string: a GVariant format string
32428  * @...: the arguments to unpack the value into
32429  *
32430  * Looks up a value in a dictionary #GVariant.
32431  *
32432  * This function is a wrapper around g_variant_lookup_value() and
32433  * g_variant_get().  In the case that %NULL would have been returned,
32434  * this function returns %FALSE.  Otherwise, it unpacks the returned
32435  * value and returns %TRUE.
32436  *
32437  * @format_string determines the C types that are used for unpacking
32438  * the values and also determines if the values are copied or borrowed,
32439  * see the section on
32440  * <link linkend='gvariant-format-strings-pointers'>GVariant Format Strings</link>.
32441  *
32442  * Returns: %TRUE if a value was unpacked
32443  * Since: 2.28
32444  */
32445
32446
32447 /**
32448  * g_variant_lookup_value:
32449  * @dictionary: a dictionary #GVariant
32450  * @key: the key to lookup in the dictionary
32451  * @expected_type: (allow-none): a #GVariantType, or %NULL
32452  *
32453  * Looks up a value in a dictionary #GVariant.
32454  *
32455  * This function works with dictionaries of the type
32456  * <literal>a{s*}</literal> (and equally well with type
32457  * <literal>a{o*}</literal>, but we only further discuss the string case
32458  * for sake of clarity).
32459  *
32460  * In the event that @dictionary has the type <literal>a{sv}</literal>,
32461  * the @expected_type string specifies what type of value is expected to
32462  * be inside of the variant.  If the value inside the variant has a
32463  * different type then %NULL is returned.  In the event that @dictionary
32464  * has a value type other than <literal>v</literal> then @expected_type
32465  * must directly match the key type and it is used to unpack the value
32466  * directly or an error occurs.
32467  *
32468  * In either case, if @key is not found in @dictionary, %NULL is
32469  * returned.
32470  *
32471  * If the key is found and the value has the correct type, it is
32472  * returned.  If @expected_type was specified then any non-%NULL return
32473  * value will have this type.
32474  *
32475  * Returns: (transfer full): the value of the dictionary key, or %NULL
32476  * Since: 2.28
32477  */
32478
32479
32480 /**
32481  * g_variant_n_children:
32482  * @value: a container #GVariant
32483  *
32484  * Determines the number of children in a container #GVariant instance.
32485  * This includes variants, maybes, arrays, tuples and dictionary
32486  * entries.  It is an error to call this function on any other type of
32487  * #GVariant.
32488  *
32489  * For variants, the return value is always 1.  For values with maybe
32490  * types, it is always zero or one.  For arrays, it is the length of the
32491  * array.  For tuples it is the number of tuple items (which depends
32492  * only on the type).  For dictionary entries, it is always 2
32493  *
32494  * This function is O(1).
32495  *
32496  * Returns: the number of children in the container
32497  * Since: 2.24
32498  */
32499
32500
32501 /**
32502  * g_variant_new: (skip)
32503  * @format_string: a #GVariant format string
32504  * @...: arguments, as per @format_string
32505  *
32506  * Creates a new #GVariant instance.
32507  *
32508  * Think of this function as an analogue to g_strdup_printf().
32509  *
32510  * The type of the created instance and the arguments that are
32511  * expected by this function are determined by @format_string.  See the
32512  * section on <link linkend='gvariant-format-strings'>GVariant Format
32513  * Strings</link>.  Please note that the syntax of the format string is
32514  * very likely to be extended in the future.
32515  *
32516  * The first character of the format string must not be '*' '?' '@' or
32517  * 'r'; in essence, a new #GVariant must always be constructed by this
32518  * function (and not merely passed through it unmodified).
32519  *
32520  * Returns: a new floating #GVariant instance
32521  * Since: 2.24
32522  */
32523
32524
32525 /**
32526  * g_variant_new_array:
32527  * @child_type: (allow-none): the element type of the new array
32528  * @children: (allow-none) (array length=n_children): an array of #GVariant pointers, the children
32529  * @n_children: the length of @children
32530  *
32531  * Creates a new #GVariant array from @children.
32532  *
32533  * @child_type must be non-%NULL if @n_children is zero.  Otherwise, the
32534  * child type is determined by inspecting the first element of the
32535  * @children array.  If @child_type is non-%NULL then it must be a
32536  * definite type.
32537  *
32538  * The items of the array are taken from the @children array.  No entry
32539  * in the @children array may be %NULL.
32540  *
32541  * All items in the array must have the same type, which must be the
32542  * same as @child_type, if given.
32543  *
32544  * If the @children are floating references (see g_variant_ref_sink()), the
32545  * new instance takes ownership of them as if via g_variant_ref_sink().
32546  *
32547  * Returns: (transfer none): a floating reference to a new #GVariant array
32548  * Since: 2.24
32549  */
32550
32551
32552 /**
32553  * g_variant_new_boolean:
32554  * @value: a #gboolean value
32555  *
32556  * Creates a new boolean #GVariant instance -- either %TRUE or %FALSE.
32557  *
32558  * Returns: (transfer none): a floating reference to a new boolean #GVariant instance
32559  * Since: 2.24
32560  */
32561
32562
32563 /**
32564  * g_variant_new_byte:
32565  * @value: a #guint8 value
32566  *
32567  * Creates a new byte #GVariant instance.
32568  *
32569  * Returns: (transfer none): a floating reference to a new byte #GVariant instance
32570  * Since: 2.24
32571  */
32572
32573
32574 /**
32575  * g_variant_new_bytestring:
32576  * @string: (array zero-terminated=1) (element-type guint8): a normal nul-terminated string in no particular encoding
32577  *
32578  * Creates an array-of-bytes #GVariant with the contents of @string.
32579  * This function is just like g_variant_new_string() except that the
32580  * string need not be valid utf8.
32581  *
32582  * The nul terminator character at the end of the string is stored in
32583  * the array.
32584  *
32585  * Returns: (transfer none): a floating reference to a new bytestring #GVariant instance
32586  * Since: 2.26
32587  */
32588
32589
32590 /**
32591  * g_variant_new_bytestring_array:
32592  * @strv: (array length=length): an array of strings
32593  * @length: the length of @strv, or -1
32594  *
32595  * Constructs an array of bytestring #GVariant from the given array of
32596  * strings.
32597  *
32598  * If @length is -1 then @strv is %NULL-terminated.
32599  *
32600  * Returns: (transfer none): a new floating #GVariant instance
32601  * Since: 2.26
32602  */
32603
32604
32605 /**
32606  * g_variant_new_dict_entry: (constructor)
32607  * @key: a basic #GVariant, the key
32608  * @value: a #GVariant, the value
32609  *
32610  * Creates a new dictionary entry #GVariant. @key and @value must be
32611  * non-%NULL. @key must be a value of a basic type (ie: not a container).
32612  *
32613  * If the @key or @value are floating references (see g_variant_ref_sink()),
32614  * the new instance takes ownership of them as if via g_variant_ref_sink().
32615  *
32616  * Returns: (transfer none): a floating reference to a new dictionary entry #GVariant
32617  * Since: 2.24
32618  */
32619
32620
32621 /**
32622  * g_variant_new_double:
32623  * @value: a #gdouble floating point value
32624  *
32625  * Creates a new double #GVariant instance.
32626  *
32627  * Returns: (transfer none): a floating reference to a new double #GVariant instance
32628  * Since: 2.24
32629  */
32630
32631
32632 /**
32633  * g_variant_new_fixed_array:
32634  * @element_type: the #GVariantType of each element
32635  * @elements: a pointer to the fixed array of contiguous elements
32636  * @n_elements: the number of elements
32637  * @element_size: the size of each element
32638  *
32639  * Provides access to the serialised data for an array of fixed-sized
32640  * items.
32641  *
32642  * @value must be an array with fixed-sized elements.  Numeric types are
32643  * fixed-size as are tuples containing only other fixed-sized types.
32644  *
32645  * @element_size must be the size of a single element in the array.  For
32646  * example, if calling this function for an array of 32 bit integers,
32647  * you might say <code>sizeof (gint32)</code>.  This value isn't used
32648  * except for the purpose of a double-check that the form of the
32649  * serialised data matches the caller's expectation.
32650  *
32651  * @n_elements, which must be non-%NULL is set equal to the number of
32652  * items in the array.
32653  *
32654  * Returns: (transfer none): a floating reference to a new array #GVariant instance
32655  * Since: 2.32
32656  */
32657
32658
32659 /**
32660  * g_variant_new_from_bytes:
32661  * @type: a #GVariantType
32662  * @bytes: a #GBytes
32663  * @trusted: if the contents of @bytes are trusted
32664  *
32665  * Constructs a new serialised-mode #GVariant instance.  This is the
32666  * inner interface for creation of new serialised values that gets
32667  * called from various functions in gvariant.c.
32668  *
32669  * A reference is taken on @bytes.
32670  *
32671  * Returns: (transfer none): a new #GVariant with a floating reference
32672  * Since: 2.36
32673  */
32674
32675
32676 /**
32677  * g_variant_new_from_data:
32678  * @type: a definite #GVariantType
32679  * @data: (array length=size) (element-type guint8): the serialised data
32680  * @size: the size of @data
32681  * @trusted: %TRUE if @data is definitely in normal form
32682  * @notify: (scope async): function to call when @data is no longer needed
32683  * @user_data: data for @notify
32684  *
32685  * Creates a new #GVariant instance from serialised data.
32686  *
32687  * @type is the type of #GVariant instance that will be constructed.
32688  * The interpretation of @data depends on knowing the type.
32689  *
32690  * @data is not modified by this function and must remain valid with an
32691  * unchanging value until such a time as @notify is called with
32692  * @user_data.  If the contents of @data change before that time then
32693  * the result is undefined.
32694  *
32695  * If @data is trusted to be serialised data in normal form then
32696  * @trusted should be %TRUE.  This applies to serialised data created
32697  * within this process or read from a trusted location on the disk (such
32698  * as a file installed in /usr/lib alongside your application).  You
32699  * should set trusted to %FALSE if @data is read from the network, a
32700  * file in the user's home directory, etc.
32701  *
32702  * If @data was not stored in this machine's native endianness, any multi-byte
32703  * numeric values in the returned variant will also be in non-native
32704  * endianness. g_variant_byteswap() can be used to recover the original values.
32705  *
32706  * @notify will be called with @user_data when @data is no longer
32707  * needed.  The exact time of this call is unspecified and might even be
32708  * before this function returns.
32709  *
32710  * Returns: (transfer none): a new floating #GVariant of type @type
32711  * Since: 2.24
32712  */
32713
32714
32715 /**
32716  * g_variant_new_handle:
32717  * @value: a #gint32 value
32718  *
32719  * Creates a new handle #GVariant instance.
32720  *
32721  * By convention, handles are indexes into an array of file descriptors
32722  * that are sent alongside a D-Bus message.  If you're not interacting
32723  * with D-Bus, you probably don't need them.
32724  *
32725  * Returns: (transfer none): a floating reference to a new handle #GVariant instance
32726  * Since: 2.24
32727  */
32728
32729
32730 /**
32731  * g_variant_new_int16:
32732  * @value: a #gint16 value
32733  *
32734  * Creates a new int16 #GVariant instance.
32735  *
32736  * Returns: (transfer none): a floating reference to a new int16 #GVariant instance
32737  * Since: 2.24
32738  */
32739
32740
32741 /**
32742  * g_variant_new_int32:
32743  * @value: a #gint32 value
32744  *
32745  * Creates a new int32 #GVariant instance.
32746  *
32747  * Returns: (transfer none): a floating reference to a new int32 #GVariant instance
32748  * Since: 2.24
32749  */
32750
32751
32752 /**
32753  * g_variant_new_int64:
32754  * @value: a #gint64 value
32755  *
32756  * Creates a new int64 #GVariant instance.
32757  *
32758  * Returns: (transfer none): a floating reference to a new int64 #GVariant instance
32759  * Since: 2.24
32760  */
32761
32762
32763 /**
32764  * g_variant_new_maybe:
32765  * @child_type: (allow-none): the #GVariantType of the child, or %NULL
32766  * @child: (allow-none): the child value, or %NULL
32767  *
32768  * Depending on if @child is %NULL, either wraps @child inside of a
32769  * maybe container or creates a Nothing instance for the given @type.
32770  *
32771  * At least one of @child_type and @child must be non-%NULL.
32772  * If @child_type is non-%NULL then it must be a definite type.
32773  * If they are both non-%NULL then @child_type must be the type
32774  * of @child.
32775  *
32776  * If @child is a floating reference (see g_variant_ref_sink()), the new
32777  * instance takes ownership of @child.
32778  *
32779  * Returns: (transfer none): a floating reference to a new #GVariant maybe instance
32780  * Since: 2.24
32781  */
32782
32783
32784 /**
32785  * g_variant_new_object_path:
32786  * @object_path: a normal C nul-terminated string
32787  *
32788  * Creates a D-Bus object path #GVariant with the contents of @string.
32789  * @string must be a valid D-Bus object path.  Use
32790  * g_variant_is_object_path() if you're not sure.
32791  *
32792  * Returns: (transfer none): a floating reference to a new object path #GVariant instance
32793  * Since: 2.24
32794  */
32795
32796
32797 /**
32798  * g_variant_new_objv:
32799  * @strv: (array length=length) (element-type utf8): an array of strings
32800  * @length: the length of @strv, or -1
32801  *
32802  * Constructs an array of object paths #GVariant from the given array of
32803  * strings.
32804  *
32805  * Each string must be a valid #GVariant object path; see
32806  * g_variant_is_object_path().
32807  *
32808  * If @length is -1 then @strv is %NULL-terminated.
32809  *
32810  * Returns: (transfer none): a new floating #GVariant instance
32811  * Since: 2.30
32812  */
32813
32814
32815 /**
32816  * g_variant_new_parsed:
32817  * @format: a text format #GVariant
32818  * @...: arguments as per @format
32819  *
32820  * Parses @format and returns the result.
32821  *
32822  * @format must be a text format #GVariant with one extension: at any
32823  * point that a value may appear in the text, a '%' character followed
32824  * by a GVariant format string (as per g_variant_new()) may appear.  In
32825  * that case, the same arguments are collected from the argument list as
32826  * g_variant_new() would have collected.
32827  *
32828  * Consider this simple example:
32829  *
32830  * <informalexample><programlisting>
32831  *  g_variant_new_parsed ("[('one', 1), ('two', %i), (%s, 3)]", 2, "three");
32832  * </programlisting></informalexample>
32833  *
32834  * In the example, the variable argument parameters are collected and
32835  * filled in as if they were part of the original string to produce the
32836  * result of <code>[('one', 1), ('two', 2), ('three', 3)]</code>.
32837  *
32838  * This function is intended only to be used with @format as a string
32839  * literal.  Any parse error is fatal to the calling process.  If you
32840  * want to parse data from untrusted sources, use g_variant_parse().
32841  *
32842  * You may not use this function to return, unmodified, a single
32843  * #GVariant pointer from the argument list.  ie: @format may not solely
32844  * be anything along the lines of "%*", "%?", "\%r", or anything starting
32845  * with "%@".
32846  *
32847  * Returns: a new floating #GVariant instance
32848  */
32849
32850
32851 /**
32852  * g_variant_new_parsed_va:
32853  * @format: a text format #GVariant
32854  * @app: a pointer to a #va_list
32855  *
32856  * Parses @format and returns the result.
32857  *
32858  * This is the version of g_variant_new_parsed() intended to be used
32859  * from libraries.
32860  *
32861  * The return value will be floating if it was a newly created GVariant
32862  * instance.  In the case that @format simply specified the collection
32863  * of a #GVariant pointer (eg: @format was "%*") then the collected
32864  * #GVariant pointer will be returned unmodified, without adding any
32865  * additional references.
32866  *
32867  * In order to behave correctly in all cases it is necessary for the
32868  * calling function to g_variant_ref_sink() the return result before
32869  * returning control to the user that originally provided the pointer.
32870  * At this point, the caller will have their own full reference to the
32871  * result.  This can also be done by adding the result to a container,
32872  * or by passing it to another g_variant_new() call.
32873  *
32874  * Returns: a new, usually floating, #GVariant
32875  */
32876
32877
32878 /**
32879  * g_variant_new_printf: (skip)
32880  * @format_string: a printf-style format string
32881  * @...: arguments for @format_string
32882  *
32883  * Creates a string-type GVariant using printf formatting.
32884  *
32885  * This is similar to calling g_strdup_printf() and then
32886  * g_variant_new_string() but it saves a temporary variable and an
32887  * unnecessary copy.
32888  *
32889  * Returns: (transfer none): a floating reference to a new string #GVariant instance
32890  * Since: 2.38
32891  */
32892
32893
32894 /**
32895  * g_variant_new_signature:
32896  * @signature: a normal C nul-terminated string
32897  *
32898  * Creates a D-Bus type signature #GVariant with the contents of
32899  * @string.  @string must be a valid D-Bus type signature.  Use
32900  * g_variant_is_signature() if you're not sure.
32901  *
32902  * Returns: (transfer none): a floating reference to a new signature #GVariant instance
32903  * Since: 2.24
32904  */
32905
32906
32907 /**
32908  * g_variant_new_string:
32909  * @string: a normal utf8 nul-terminated string
32910  *
32911  * Creates a string #GVariant with the contents of @string.
32912  *
32913  * @string must be valid utf8.
32914  *
32915  * Returns: (transfer none): a floating reference to a new string #GVariant instance
32916  * Since: 2.24
32917  */
32918
32919
32920 /**
32921  * g_variant_new_strv:
32922  * @strv: (array length=length) (element-type utf8): an array of strings
32923  * @length: the length of @strv, or -1
32924  *
32925  * Constructs an array of strings #GVariant from the given array of
32926  * strings.
32927  *
32928  * If @length is -1 then @strv is %NULL-terminated.
32929  *
32930  * Returns: (transfer none): a new floating #GVariant instance
32931  * Since: 2.24
32932  */
32933
32934
32935 /**
32936  * g_variant_new_take_string: (skip)
32937  * @string: a normal utf8 nul-terminated string
32938  *
32939  * Creates a string #GVariant with the contents of @string.
32940  *
32941  * @string must be valid utf8.
32942  *
32943  * This function consumes @string.  g_free() will be called on @string
32944  * when it is no longer required.
32945  *
32946  * You must not modify or access @string in any other way after passing
32947  * it to this function.  It is even possible that @string is immediately
32948  * freed.
32949  *
32950  * Returns: (transfer none): a floating reference to a new string #GVariant instance
32951  * Since: 2.38
32952  */
32953
32954
32955 /**
32956  * g_variant_new_tuple:
32957  * @children: (array length=n_children): the items to make the tuple out of
32958  * @n_children: the length of @children
32959  *
32960  * Creates a new tuple #GVariant out of the items in @children.  The
32961  * type is determined from the types of @children.  No entry in the
32962  * @children array may be %NULL.
32963  *
32964  * If @n_children is 0 then the unit tuple is constructed.
32965  *
32966  * If the @children are floating references (see g_variant_ref_sink()), the
32967  * new instance takes ownership of them as if via g_variant_ref_sink().
32968  *
32969  * Returns: (transfer none): a floating reference to a new #GVariant tuple
32970  * Since: 2.24
32971  */
32972
32973
32974 /**
32975  * g_variant_new_uint16:
32976  * @value: a #guint16 value
32977  *
32978  * Creates a new uint16 #GVariant instance.
32979  *
32980  * Returns: (transfer none): a floating reference to a new uint16 #GVariant instance
32981  * Since: 2.24
32982  */
32983
32984
32985 /**
32986  * g_variant_new_uint32:
32987  * @value: a #guint32 value
32988  *
32989  * Creates a new uint32 #GVariant instance.
32990  *
32991  * Returns: (transfer none): a floating reference to a new uint32 #GVariant instance
32992  * Since: 2.24
32993  */
32994
32995
32996 /**
32997  * g_variant_new_uint64:
32998  * @value: a #guint64 value
32999  *
33000  * Creates a new uint64 #GVariant instance.
33001  *
33002  * Returns: (transfer none): a floating reference to a new uint64 #GVariant instance
33003  * Since: 2.24
33004  */
33005
33006
33007 /**
33008  * g_variant_new_va: (skip)
33009  * @format_string: a string that is prefixed with a format string
33010  * @endptr: (allow-none) (default NULL): location to store the end pointer, or %NULL
33011  * @app: a pointer to a #va_list
33012  *
33013  * This function is intended to be used by libraries based on
33014  * #GVariant that want to provide g_variant_new()-like functionality
33015  * to their users.
33016  *
33017  * The API is more general than g_variant_new() to allow a wider range
33018  * of possible uses.
33019  *
33020  * @format_string must still point to a valid format string, but it only
33021  * needs to be nul-terminated if @endptr is %NULL.  If @endptr is
33022  * non-%NULL then it is updated to point to the first character past the
33023  * end of the format string.
33024  *
33025  * @app is a pointer to a #va_list.  The arguments, according to
33026  * @format_string, are collected from this #va_list and the list is left
33027  * pointing to the argument following the last.
33028  *
33029  * These two generalisations allow mixing of multiple calls to
33030  * g_variant_new_va() and g_variant_get_va() within a single actual
33031  * varargs call by the user.
33032  *
33033  * The return value will be floating if it was a newly created GVariant
33034  * instance (for example, if the format string was "(ii)").  In the case
33035  * that the format_string was '*', '?', 'r', or a format starting with
33036  * '@' then the collected #GVariant pointer will be returned unmodified,
33037  * without adding any additional references.
33038  *
33039  * In order to behave correctly in all cases it is necessary for the
33040  * calling function to g_variant_ref_sink() the return result before
33041  * returning control to the user that originally provided the pointer.
33042  * At this point, the caller will have their own full reference to the
33043  * result.  This can also be done by adding the result to a container,
33044  * or by passing it to another g_variant_new() call.
33045  *
33046  * Returns: a new, usually floating, #GVariant
33047  * Since: 2.24
33048  */
33049
33050
33051 /**
33052  * g_variant_new_variant: (constructor)
33053  * @value: a #GVariant instance
33054  *
33055  * Boxes @value.  The result is a #GVariant instance representing a
33056  * variant containing the original value.
33057  *
33058  * If @child is a floating reference (see g_variant_ref_sink()), the new
33059  * instance takes ownership of @child.
33060  *
33061  * Returns: (transfer none): a floating reference to a new variant #GVariant instance
33062  * Since: 2.24
33063  */
33064
33065
33066 /**
33067  * g_variant_parse:
33068  * @type: (allow-none): a #GVariantType, or %NULL
33069  * @text: a string containing a GVariant in text form
33070  * @limit: (allow-none): a pointer to the end of @text, or %NULL
33071  * @endptr: (allow-none): a location to store the end pointer, or %NULL
33072  * @error: (allow-none): a pointer to a %NULL #GError pointer, or %NULL
33073  *
33074  * Parses a #GVariant from a text representation.
33075  *
33076  * A single #GVariant is parsed from the content of @text.
33077  *
33078  * The format is described <link linkend='gvariant-text'>here</link>.
33079  *
33080  * The memory at @limit will never be accessed and the parser behaves as
33081  * if the character at @limit is the nul terminator.  This has the
33082  * effect of bounding @text.
33083  *
33084  * If @endptr is non-%NULL then @text is permitted to contain data
33085  * following the value that this function parses and @endptr will be
33086  * updated to point to the first character past the end of the text
33087  * parsed by this function.  If @endptr is %NULL and there is extra data
33088  * then an error is returned.
33089  *
33090  * If @type is non-%NULL then the value will be parsed to have that
33091  * type.  This may result in additional parse errors (in the case that
33092  * the parsed value doesn't fit the type) but may also result in fewer
33093  * errors (in the case that the type would have been ambiguous, such as
33094  * with empty arrays).
33095  *
33096  * In the event that the parsing is successful, the resulting #GVariant
33097  * is returned.
33098  *
33099  * In case of any error, %NULL will be returned.  If @error is non-%NULL
33100  * then it will be set to reflect the error that occurred.
33101  *
33102  * Officially, the language understood by the parser is "any string
33103  * produced by g_variant_print()".
33104  *
33105  * Returns: a reference to a #GVariant, or %NULL
33106  */
33107
33108
33109 /**
33110  * g_variant_print:
33111  * @value: a #GVariant
33112  * @type_annotate: %TRUE if type information should be included in the output
33113  *
33114  * Pretty-prints @value in the format understood by g_variant_parse().
33115  *
33116  * The format is described <link linkend='gvariant-text'>here</link>.
33117  *
33118  * If @type_annotate is %TRUE, then type information is included in
33119  * the output.
33120  *
33121  * Returns: (transfer full): a newly-allocated string holding the result.
33122  * Since: 2.24
33123  */
33124
33125
33126 /**
33127  * g_variant_print_string: (skip)
33128  * @value: a #GVariant
33129  * @string: (allow-none) (default NULL): a #GString, or %NULL
33130  * @type_annotate: %TRUE if type information should be included in the output
33131  *
33132  * Behaves as g_variant_print(), but operates on a #GString.
33133  *
33134  * If @string is non-%NULL then it is appended to and returned.  Else,
33135  * a new empty #GString is allocated and it is returned.
33136  *
33137  * Returns: a #GString containing the string
33138  * Since: 2.24
33139  */
33140
33141
33142 /**
33143  * g_variant_ref:
33144  * @value: a #GVariant
33145  *
33146  * Increases the reference count of @value.
33147  *
33148  * Returns: the same @value
33149  * Since: 2.24
33150  */
33151
33152
33153 /**
33154  * g_variant_ref_sink:
33155  * @value: a #GVariant
33156  *
33157  * #GVariant uses a floating reference count system.  All functions with
33158  * names starting with <literal>g_variant_new_</literal> return floating
33159  * references.
33160  *
33161  * Calling g_variant_ref_sink() on a #GVariant with a floating reference
33162  * will convert the floating reference into a full reference.  Calling
33163  * g_variant_ref_sink() on a non-floating #GVariant results in an
33164  * additional normal reference being added.
33165  *
33166  * In other words, if the @value is floating, then this call "assumes
33167  * ownership" of the floating reference, converting it to a normal
33168  * reference.  If the @value is not floating, then this call adds a
33169  * new normal reference increasing the reference count by one.
33170  *
33171  * All calls that result in a #GVariant instance being inserted into a
33172  * container will call g_variant_ref_sink() on the instance.  This means
33173  * that if the value was just created (and has only its floating
33174  * reference) then the container will assume sole ownership of the value
33175  * at that point and the caller will not need to unreference it.  This
33176  * makes certain common styles of programming much easier while still
33177  * maintaining normal refcounting semantics in situations where values
33178  * are not floating.
33179  *
33180  * Returns: the same @value
33181  * Since: 2.24
33182  */
33183
33184
33185 /**
33186  * g_variant_store:
33187  * @value: the #GVariant to store
33188  * @data: the location to store the serialised data at
33189  *
33190  * Stores the serialised form of @value at @data.  @data should be
33191  * large enough.  See g_variant_get_size().
33192  *
33193  * The stored data is in machine native byte order but may not be in
33194  * fully-normalised form if read from an untrusted source.  See
33195  * g_variant_get_normal_form() for a solution.
33196  *
33197  * As with g_variant_get_data(), to be able to deserialise the
33198  * serialised variant successfully, its type and (if the destination
33199  * machine might be different) its endianness must also be available.
33200  *
33201  * This function is approximately O(n) in the size of @data.
33202  *
33203  * Since: 2.24
33204  */
33205
33206
33207 /**
33208  * g_variant_take_ref:
33209  * @value: a #GVariant
33210  *
33211  * If @value is floating, sink it.  Otherwise, do nothing.
33212  *
33213  * Typically you want to use g_variant_ref_sink() in order to
33214  * automatically do the correct thing with respect to floating or
33215  * non-floating references, but there is one specific scenario where
33216  * this function is helpful.
33217  *
33218  * The situation where this function is helpful is when creating an API
33219  * that allows the user to provide a callback function that returns a
33220  * #GVariant.  We certainly want to allow the user the flexibility to
33221  * return a non-floating reference from this callback (for the case
33222  * where the value that is being returned already exists).
33223  *
33224  * At the same time, the style of the #GVariant API makes it likely that
33225  * for newly-created #GVariant instances, the user can be saved some
33226  * typing if they are allowed to return a #GVariant with a floating
33227  * reference.
33228  *
33229  * Using this function on the return value of the user's callback allows
33230  * the user to do whichever is more convenient for them.  The caller
33231  * will alway receives exactly one full reference to the value: either
33232  * the one that was returned in the first place, or a floating reference
33233  * that has been converted to a full reference.
33234  *
33235  * This function has an odd interaction when combined with
33236  * g_variant_ref_sink() running at the same time in another thread on
33237  * the same #GVariant instance.  If g_variant_ref_sink() runs first then
33238  * the result will be that the floating reference is converted to a hard
33239  * reference.  If g_variant_take_ref() runs first then the result will
33240  * be that the floating reference is converted to a hard reference and
33241  * an additional reference on top of that one is added.  It is best to
33242  * avoid this situation.
33243  *
33244  * Returns: the same @value
33245  */
33246
33247
33248 /**
33249  * g_variant_type_copy:
33250  * @type: a #GVariantType
33251  *
33252  * Makes a copy of a #GVariantType.  It is appropriate to call
33253  * g_variant_type_free() on the return value.  @type may not be %NULL.
33254  *
33255  * Returns: (transfer full): a new #GVariantType  Since 2.24
33256  */
33257
33258
33259 /**
33260  * g_variant_type_dup_string:
33261  * @type: a #GVariantType
33262  *
33263  * Returns a newly-allocated copy of the type string corresponding to
33264  * @type.  The returned string is nul-terminated.  It is appropriate to
33265  * call g_free() on the return value.
33266  *
33267  * Returns: (transfer full): the corresponding type string  Since 2.24
33268  */
33269
33270
33271 /**
33272  * g_variant_type_element:
33273  * @type: an array or maybe #GVariantType
33274  *
33275  * Determines the element type of an array or maybe type.
33276  *
33277  * This function may only be used with array or maybe types.
33278  *
33279  * Returns: (transfer none): the element type of @type  Since 2.24
33280  */
33281
33282
33283 /**
33284  * g_variant_type_equal:
33285  * @type1: (type GVariantType): a #GVariantType
33286  * @type2: (type GVariantType): a #GVariantType
33287  *
33288  * Compares @type1 and @type2 for equality.
33289  *
33290  * Only returns %TRUE if the types are exactly equal.  Even if one type
33291  * is an indefinite type and the other is a subtype of it, %FALSE will
33292  * be returned if they are not exactly equal.  If you want to check for
33293  * subtypes, use g_variant_type_is_subtype_of().
33294  *
33295  * The argument types of @type1 and @type2 are only #gconstpointer to
33296  * allow use with #GHashTable without function pointer casting.  For
33297  * both arguments, a valid #GVariantType must be provided.
33298  *
33299  * Returns: %TRUE if @type1 and @type2 are exactly equal  Since 2.24
33300  */
33301
33302
33303 /**
33304  * g_variant_type_first:
33305  * @type: a tuple or dictionary entry #GVariantType
33306  *
33307  * Determines the first item type of a tuple or dictionary entry
33308  * type.
33309  *
33310  * This function may only be used with tuple or dictionary entry types,
33311  * but must not be used with the generic tuple type
33312  * %G_VARIANT_TYPE_TUPLE.
33313  *
33314  * In the case of a dictionary entry type, this returns the type of
33315  * the key.
33316  *
33317  * %NULL is returned in case of @type being %G_VARIANT_TYPE_UNIT.
33318  *
33319  * This call, together with g_variant_type_next() provides an iterator
33320  * interface over tuple and dictionary entry types.
33321  *
33322  * Returns: (transfer none): the first item type of @type, or %NULL  Since 2.24
33323  */
33324
33325
33326 /**
33327  * g_variant_type_free:
33328  * @type: (allow-none): a #GVariantType, or %NULL
33329  *
33330  * Frees a #GVariantType that was allocated with
33331  * g_variant_type_copy(), g_variant_type_new() or one of the container
33332  * type constructor functions.
33333  *
33334  * In the case that @type is %NULL, this function does nothing.
33335  *
33336  * Since 2.24
33337  */
33338
33339
33340 /**
33341  * g_variant_type_get_string_length:
33342  * @type: a #GVariantType
33343  *
33344  * Returns the length of the type string corresponding to the given
33345  * @type.  This function must be used to determine the valid extent of
33346  * the memory region returned by g_variant_type_peek_string().
33347  *
33348  * Returns: the length of the corresponding type string  Since 2.24
33349  */
33350
33351
33352 /**
33353  * g_variant_type_hash:
33354  * @type: (type GVariantType): a #GVariantType
33355  *
33356  * Hashes @type.
33357  *
33358  * The argument type of @type is only #gconstpointer to allow use with
33359  * #GHashTable without function pointer casting.  A valid
33360  * #GVariantType must be provided.
33361  *
33362  * Returns: the hash value  Since 2.24
33363  */
33364
33365
33366 /**
33367  * g_variant_type_is_array:
33368  * @type: a #GVariantType
33369  *
33370  * Determines if the given @type is an array type.  This is true if the
33371  * type string for @type starts with an 'a'.
33372  *
33373  * This function returns %TRUE for any indefinite type for which every
33374  * definite subtype is an array type -- %G_VARIANT_TYPE_ARRAY, for
33375  * example.
33376  *
33377  * Returns: %TRUE if @type is an array type  Since 2.24
33378  */
33379
33380
33381 /**
33382  * g_variant_type_is_basic:
33383  * @type: a #GVariantType
33384  *
33385  * Determines if the given @type is a basic type.
33386  *
33387  * Basic types are booleans, bytes, integers, doubles, strings, object
33388  * paths and signatures.
33389  *
33390  * Only a basic type may be used as the key of a dictionary entry.
33391  *
33392  * This function returns %FALSE for all indefinite types except
33393  * %G_VARIANT_TYPE_BASIC.
33394  *
33395  * Returns: %TRUE if @type is a basic type  Since 2.24
33396  */
33397
33398
33399 /**
33400  * g_variant_type_is_container:
33401  * @type: a #GVariantType
33402  *
33403  * Determines if the given @type is a container type.
33404  *
33405  * Container types are any array, maybe, tuple, or dictionary
33406  * entry types plus the variant type.
33407  *
33408  * This function returns %TRUE for any indefinite type for which every
33409  * definite subtype is a container -- %G_VARIANT_TYPE_ARRAY, for
33410  * example.
33411  *
33412  * Returns: %TRUE if @type is a container type  Since 2.24
33413  */
33414
33415
33416 /**
33417  * g_variant_type_is_definite:
33418  * @type: a #GVariantType
33419  *
33420  * Determines if the given @type is definite (ie: not indefinite).
33421  *
33422  * A type is definite if its type string does not contain any indefinite
33423  * type characters ('*', '?', or 'r').
33424  *
33425  * A #GVariant instance may not have an indefinite type, so calling
33426  * this function on the result of g_variant_get_type() will always
33427  * result in %TRUE being returned.  Calling this function on an
33428  * indefinite type like %G_VARIANT_TYPE_ARRAY, however, will result in
33429  * %FALSE being returned.
33430  *
33431  * Returns: %TRUE if @type is definite  Since 2.24
33432  */
33433
33434
33435 /**
33436  * g_variant_type_is_dict_entry:
33437  * @type: a #GVariantType
33438  *
33439  * Determines if the given @type is a dictionary entry type.  This is
33440  * true if the type string for @type starts with a '{'.
33441  *
33442  * This function returns %TRUE for any indefinite type for which every
33443  * definite subtype is a dictionary entry type --
33444  * %G_VARIANT_TYPE_DICT_ENTRY, for example.
33445  *
33446  * Returns: %TRUE if @type is a dictionary entry type  Since 2.24
33447  */
33448
33449
33450 /**
33451  * g_variant_type_is_maybe:
33452  * @type: a #GVariantType
33453  *
33454  * Determines if the given @type is a maybe type.  This is true if the
33455  * type string for @type starts with an 'm'.
33456  *
33457  * This function returns %TRUE for any indefinite type for which every
33458  * definite subtype is a maybe type -- %G_VARIANT_TYPE_MAYBE, for
33459  * example.
33460  *
33461  * Returns: %TRUE if @type is a maybe type  Since 2.24
33462  */
33463
33464
33465 /**
33466  * g_variant_type_is_subtype_of:
33467  * @type: a #GVariantType
33468  * @supertype: a #GVariantType
33469  *
33470  * Checks if @type is a subtype of @supertype.
33471  *
33472  * This function returns %TRUE if @type is a subtype of @supertype.  All
33473  * types are considered to be subtypes of themselves.  Aside from that,
33474  * only indefinite types can have subtypes.
33475  *
33476  * Returns: %TRUE if @type is a subtype of @supertype  Since 2.24
33477  */
33478
33479
33480 /**
33481  * g_variant_type_is_tuple:
33482  * @type: a #GVariantType
33483  *
33484  * Determines if the given @type is a tuple type.  This is true if the
33485  * type string for @type starts with a '(' or if @type is
33486  * %G_VARIANT_TYPE_TUPLE.
33487  *
33488  * This function returns %TRUE for any indefinite type for which every
33489  * definite subtype is a tuple type -- %G_VARIANT_TYPE_TUPLE, for
33490  * example.
33491  *
33492  * Returns: %TRUE if @type is a tuple type  Since 2.24
33493  */
33494
33495
33496 /**
33497  * g_variant_type_is_variant:
33498  * @type: a #GVariantType
33499  *
33500  * Determines if the given @type is the variant type.
33501  *
33502  * Returns: %TRUE if @type is the variant type  Since 2.24
33503  */
33504
33505
33506 /**
33507  * g_variant_type_key:
33508  * @type: a dictionary entry #GVariantType
33509  *
33510  * Determines the key type of a dictionary entry type.
33511  *
33512  * This function may only be used with a dictionary entry type.  Other
33513  * than the additional restriction, this call is equivalent to
33514  * g_variant_type_first().
33515  *
33516  * Returns: (transfer none): the key type of the dictionary entry  Since 2.24
33517  */
33518
33519
33520 /**
33521  * g_variant_type_n_items:
33522  * @type: a tuple or dictionary entry #GVariantType
33523  *
33524  * Determines the number of items contained in a tuple or
33525  * dictionary entry type.
33526  *
33527  * This function may only be used with tuple or dictionary entry types,
33528  * but must not be used with the generic tuple type
33529  * %G_VARIANT_TYPE_TUPLE.
33530  *
33531  * In the case of a dictionary entry type, this function will always
33532  * return 2.
33533  *
33534  * Returns: the number of items in @type  Since 2.24
33535  */
33536
33537
33538 /**
33539  * g_variant_type_new:
33540  * @type_string: a valid GVariant type string
33541  *
33542  * Creates a new #GVariantType corresponding to the type string given
33543  * by @type_string.  It is appropriate to call g_variant_type_free() on
33544  * the return value.
33545  *
33546  * It is a programmer error to call this function with an invalid type
33547  * string.  Use g_variant_type_string_is_valid() if you are unsure.
33548  *
33549  * Returns: (transfer full): a new #GVariantType
33550  * Since: 2.24
33551  */
33552
33553
33554 /**
33555  * g_variant_type_new_array: (constructor)
33556  * @element: a #GVariantType
33557  *
33558  * Constructs the type corresponding to an array of elements of the
33559  * type @type.
33560  *
33561  * It is appropriate to call g_variant_type_free() on the return value.
33562  *
33563  * Returns: (transfer full): a new array #GVariantType  Since 2.24
33564  */
33565
33566
33567 /**
33568  * g_variant_type_new_dict_entry: (constructor)
33569  * @key: a basic #GVariantType
33570  * @value: a #GVariantType
33571  *
33572  * Constructs the type corresponding to a dictionary entry with a key
33573  * of type @key and a value of type @value.
33574  *
33575  * It is appropriate to call g_variant_type_free() on the return value.
33576  *
33577  * Returns: (transfer full): a new dictionary entry #GVariantType  Since 2.24
33578  */
33579
33580
33581 /**
33582  * g_variant_type_new_maybe: (constructor)
33583  * @element: a #GVariantType
33584  *
33585  * Constructs the type corresponding to a maybe instance containing
33586  * type @type or Nothing.
33587  *
33588  * It is appropriate to call g_variant_type_free() on the return value.
33589  *
33590  * Returns: (transfer full): a new maybe #GVariantType  Since 2.24
33591  */
33592
33593
33594 /**
33595  * g_variant_type_new_tuple:
33596  * @items: (array length=length): an array of #GVariantTypes, one for each item
33597  * @length: the length of @items, or -1
33598  *
33599  * Constructs a new tuple type, from @items.
33600  *
33601  * @length is the number of items in @items, or -1 to indicate that
33602  * @items is %NULL-terminated.
33603  *
33604  * It is appropriate to call g_variant_type_free() on the return value.
33605  *
33606  * Returns: (transfer full): a new tuple #GVariantType  Since 2.24
33607  */
33608
33609
33610 /**
33611  * g_variant_type_next:
33612  * @type: a #GVariantType from a previous call
33613  *
33614  * Determines the next item type of a tuple or dictionary entry
33615  * type.
33616  *
33617  * @type must be the result of a previous call to
33618  * g_variant_type_first() or g_variant_type_next().
33619  *
33620  * If called on the key type of a dictionary entry then this call
33621  * returns the value type.  If called on the value type of a dictionary
33622  * entry then this call returns %NULL.
33623  *
33624  * For tuples, %NULL is returned when @type is the last item in a tuple.
33625  *
33626  * Returns: (transfer none): the next #GVariantType after @type, or %NULL  Since 2.24
33627  */
33628
33629
33630 /**
33631  * g_variant_type_peek_string: (skip)
33632  * @type: a #GVariantType
33633  *
33634  * Returns the type string corresponding to the given @type.  The
33635  * result is not nul-terminated; in order to determine its length you
33636  * must call g_variant_type_get_string_length().
33637  *
33638  * To get a nul-terminated string, see g_variant_type_dup_string().
33639  *
33640  * Returns: the corresponding type string (not nul-terminated)  Since 2.24
33641  */
33642
33643
33644 /**
33645  * g_variant_type_string_is_valid:
33646  * @type_string: a pointer to any string
33647  *
33648  * Checks if @type_string is a valid GVariant type string.  This call is
33649  * equivalent to calling g_variant_type_string_scan() and confirming
33650  * that the following character is a nul terminator.
33651  *
33652  * Returns: %TRUE if @type_string is exactly one valid type string  Since 2.24
33653  */
33654
33655
33656 /**
33657  * g_variant_type_string_scan:
33658  * @string: a pointer to any string
33659  * @limit: (allow-none): the end of @string, or %NULL
33660  * @endptr: (out) (allow-none): location to store the end pointer, or %NULL
33661  *
33662  * Scan for a single complete and valid GVariant type string in @string.
33663  * The memory pointed to by @limit (or bytes beyond it) is never
33664  * accessed.
33665  *
33666  * If a valid type string is found, @endptr is updated to point to the
33667  * first character past the end of the string that was found and %TRUE
33668  * is returned.
33669  *
33670  * If there is no valid type string starting at @string, or if the type
33671  * string does not end before @limit then %FALSE is returned.
33672  *
33673  * For the simple case of checking if a string is a valid type string,
33674  * see g_variant_type_string_is_valid().
33675  *
33676  * Returns: %TRUE if a valid type string was found
33677  * Since: 2.24
33678  */
33679
33680
33681 /**
33682  * g_variant_type_value:
33683  * @type: a dictionary entry #GVariantType
33684  *
33685  * Determines the value type of a dictionary entry type.
33686  *
33687  * This function may only be used with a dictionary entry type.
33688  *
33689  * Returns: (transfer none): the value type of the dictionary entry  Since 2.24
33690  */
33691
33692
33693 /**
33694  * g_variant_unref:
33695  * @value: a #GVariant
33696  *
33697  * Decreases the reference count of @value.  When its reference count
33698  * drops to 0, the memory used by the variant is freed.
33699  *
33700  * Since: 2.24
33701  */
33702
33703
33704 /**
33705  * g_vasprintf:
33706  * @string: the return location for the newly-allocated string.
33707  * @format: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
33708  * @args: the list of arguments to insert in the output.
33709  *
33710  * An implementation of the GNU vasprintf() function which supports
33711  * positional parameters, as specified in the Single Unix Specification.
33712  * This function is similar to g_vsprintf(), except that it allocates a
33713  * string to hold the output, instead of putting the output in a buffer
33714  * you allocate in advance.
33715  *
33716  * Returns: the number of bytes printed.
33717  * Since: 2.4
33718  */
33719
33720
33721 /**
33722  * g_vfprintf:
33723  * @file: the stream to write to.
33724  * @format: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
33725  * @args: the list of arguments to insert in the output.
33726  *
33727  * An implementation of the standard fprintf() function which supports
33728  * positional parameters, as specified in the Single Unix Specification.
33729  *
33730  * Returns: the number of bytes printed.
33731  * Since: 2.2
33732  */
33733
33734
33735 /**
33736  * g_vprintf:
33737  * @format: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
33738  * @args: the list of arguments to insert in the output.
33739  *
33740  * An implementation of the standard vprintf() function which supports
33741  * positional parameters, as specified in the Single Unix Specification.
33742  *
33743  * Returns: the number of bytes printed.
33744  * Since: 2.2
33745  */
33746
33747
33748 /**
33749  * g_vsnprintf:
33750  * @string: the buffer to hold the output.
33751  * @n: the maximum number of bytes to produce (including the terminating nul character).
33752  * @format: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
33753  * @args: the list of arguments to insert in the output.
33754  *
33755  * A safer form of the standard vsprintf() function. The output is guaranteed
33756  * to not exceed @n characters (including the terminating nul character), so
33757  * it is easy to ensure that a buffer overflow cannot occur.
33758  *
33759  * See also g_strdup_vprintf().
33760  *
33761  * In versions of GLib prior to 1.2.3, this function may return -1 if the
33762  * output was truncated, and the truncated string may not be nul-terminated.
33763  * In versions prior to 1.3.12, this function returns the length of the output
33764  * string.
33765  *
33766  * The return value of g_vsnprintf() conforms to the vsnprintf() function
33767  * as standardized in ISO C99. Note that this is different from traditional
33768  * vsnprintf(), which returns the length of the output string.
33769  *
33770  * The format string may contain positional parameters, as specified in
33771  * the Single Unix Specification.
33772  *
33773  * Returns: the number of bytes which would be produced if the buffer was large enough.
33774  */
33775
33776
33777 /**
33778  * g_vsprintf:
33779  * @string: the buffer to hold the output.
33780  * @format: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
33781  * @args: the list of arguments to insert in the output.
33782  *
33783  * An implementation of the standard vsprintf() function which supports
33784  * positional parameters, as specified in the Single Unix Specification.
33785  *
33786  * Returns: the number of bytes printed.
33787  * Since: 2.2
33788  */
33789
33790
33791 /**
33792  * g_wakeup_acknowledge:
33793  * @wakeup: a #GWakeup
33794  *
33795  * Acknowledges receipt of a wakeup signal on @wakeup.
33796  *
33797  * You must call this after @wakeup polls as ready.  If not, it will
33798  * continue to poll as ready until you do so.
33799  *
33800  * If you call this function and @wakeup is not signaled, nothing
33801  * happens.
33802  *
33803  * Since: 2.30
33804  */
33805
33806
33807 /**
33808  * g_wakeup_free:
33809  * @wakeup: a #GWakeup
33810  *
33811  * Frees @wakeup.
33812  *
33813  * You must not currently be polling on the #GPollFD returned by
33814  * g_wakeup_get_pollfd(), or the result is undefined.
33815  */
33816
33817
33818 /**
33819  * g_wakeup_get_pollfd:
33820  * @wakeup: a #GWakeup
33821  * @poll_fd: a #GPollFD
33822  *
33823  * Prepares a @poll_fd such that polling on it will succeed when
33824  * g_wakeup_signal() has been called on @wakeup.
33825  *
33826  * @poll_fd is valid until @wakeup is freed.
33827  *
33828  * Since: 2.30
33829  */
33830
33831
33832 /**
33833  * g_wakeup_new:
33834  *
33835  * Creates a new #GWakeup.
33836  *
33837  * You should use g_wakeup_free() to free it when you are done.
33838  *
33839  * Returns: a new #GWakeup
33840  * Since: 2.30
33841  */
33842
33843
33844 /**
33845  * g_wakeup_signal:
33846  * @wakeup: a #GWakeup
33847  *
33848  * Signals @wakeup.
33849  *
33850  * Any future (or present) polling on the #GPollFD returned by
33851  * g_wakeup_get_pollfd() will immediately succeed until such a time as
33852  * g_wakeup_acknowledge() is called.
33853  *
33854  * This function is safe to call from a UNIX signal handler.
33855  *
33856  * Since: 2.30
33857  */
33858
33859
33860 /**
33861  * g_warning:
33862  * @...: format string, followed by parameters to insert into the format string (as with printf())
33863  *
33864  * A convenience function/macro to log a warning message.
33865  *
33866  * You can make warnings fatal at runtime by setting the
33867  * <envar>G_DEBUG</envar> environment variable (see
33868  * <ulink url="glib-running.html">Running GLib Applications</ulink>).
33869  */
33870
33871
33872 /**
33873  * g_win32_error_message:
33874  * @error: error code.
33875  *
33876  * Translate a Win32 error code (as returned by GetLastError()) into
33877  * the corresponding message. The message is either language neutral,
33878  * or in the thread's language, or the user's language, the system's
33879  * language, or US English (see docs for FormatMessage()). The
33880  * returned string is in UTF-8. It should be deallocated with
33881  * g_free().
33882  *
33883  * Returns: newly-allocated error message
33884  */
33885
33886
33887 /**
33888  * g_win32_get_package_installation_directory:
33889  * @package: (allow-none): You should pass %NULL for this.
33890  * @dll_name: (allow-none): The name of a DLL that a package provides in UTF-8, or %NULL.
33891  *
33892  * Try to determine the installation directory for a software package.
33893  *
33894  * This function is deprecated. Use
33895  * g_win32_get_package_installation_directory_of_module() instead.
33896  *
33897  * The use of @package is deprecated. You should always pass %NULL. A
33898  * warning is printed if non-NULL is passed as @package.
33899  *
33900  * The original intended use of @package was for a short identifier of
33901  * the package, typically the same identifier as used for
33902  * <literal>GETTEXT_PACKAGE</literal> in software configured using GNU
33903  * autotools. The function first looks in the Windows Registry for the
33904  * value <literal>&num;InstallationDirectory</literal> in the key
33905  * <literal>&num;HKLM\Software\@package</literal>, and if that value
33906  * exists and is a string, returns that.
33907  *
33908  * It is strongly recommended that packagers of GLib-using libraries
33909  * for Windows do not store installation paths in the Registry to be
33910  * used by this function as that interfers with having several
33911  * parallel installations of the library. Enabling multiple
33912  * installations of different versions of some GLib-using library, or
33913  * GLib itself, is desirable for various reasons.
33914  *
33915  * For this reason it is recommeded to always pass %NULL as
33916  * @package to this function, to avoid the temptation to use the
33917  * Registry. In version 2.20 of GLib the @package parameter
33918  * will be ignored and this function won't look in the Registry at all.
33919  *
33920  * If @package is %NULL, or the above value isn't found in the
33921  * Registry, but @dll_name is non-%NULL, it should name a DLL loaded
33922  * into the current process. Typically that would be the name of the
33923  * DLL calling this function, looking for its installation
33924  * directory. The function then asks Windows what directory that DLL
33925  * was loaded from. If that directory's last component is "bin" or
33926  * "lib", the parent directory is returned, otherwise the directory
33927  * itself. If that DLL isn't loaded, the function proceeds as if
33928  * @dll_name was %NULL.
33929  *
33930  * If both @package and @dll_name are %NULL, the directory from where
33931  * the main executable of the process was loaded is used instead in
33932  * the same way as above.
33933  *
33934  * Returns: a string containing the installation directory for @package. The string is in the GLib file name encoding, i.e. UTF-8. The return value should be freed with g_free() when not needed any longer. If the function fails %NULL is returned.
33935  * Deprecated: 2.18: Pass the HMODULE of a DLL or EXE to g_win32_get_package_installation_directory_of_module() instead.
33936  */
33937
33938
33939 /**
33940  * g_win32_get_package_installation_directory_of_module:
33941  * @hmodule: (allow-none): The Win32 handle for a DLL loaded into the current process, or %NULL
33942  *
33943  * This function tries to determine the installation directory of a
33944  * software package based on the location of a DLL of the software
33945  * package.
33946  *
33947  * @hmodule should be the handle of a loaded DLL or %NULL. The
33948  * function looks up the directory that DLL was loaded from. If
33949  * @hmodule is NULL, the directory the main executable of the current
33950  * process is looked up. If that directory's last component is "bin"
33951  * or "lib", its parent directory is returned, otherwise the directory
33952  * itself.
33953  *
33954  * It thus makes sense to pass only the handle to a "public" DLL of a
33955  * software package to this function, as such DLLs typically are known
33956  * to be installed in a "bin" or occasionally "lib" subfolder of the
33957  * installation folder. DLLs that are of the dynamically loaded module
33958  * or plugin variety are often located in more private locations
33959  * deeper down in the tree, from which it is impossible for GLib to
33960  * deduce the root of the package installation.
33961  *
33962  * The typical use case for this function is to have a DllMain() that
33963  * saves the handle for the DLL. Then when code in the DLL needs to
33964  * construct names of files in the installation tree it calls this
33965  * function passing the DLL handle.
33966  *
33967  * Returns: a string containing the guessed installation directory for the software package @hmodule is from. The string is in the GLib file name encoding, i.e. UTF-8. The return value should be freed with g_free() when not needed any longer. If the function fails %NULL is returned.
33968  * Since: 2.16
33969  */
33970
33971
33972 /**
33973  * g_win32_get_package_installation_subdirectory:
33974  * @package: (allow-none): You should pass %NULL for this.
33975  * @dll_name: (allow-none): The name of a DLL that a package provides, in UTF-8, or %NULL.
33976  * @subdir: A subdirectory of the package installation directory, also in UTF-8
33977  *
33978  * This function is deprecated. Use
33979  * g_win32_get_package_installation_directory_of_module() and
33980  * g_build_filename() instead.
33981  *
33982  * Returns a newly-allocated string containing the path of the
33983  * subdirectory @subdir in the return value from calling
33984  * g_win32_get_package_installation_directory() with the @package and
33985  * @dll_name parameters. See the documentation for
33986  * g_win32_get_package_installation_directory() for more details. In
33987  * particular, note that it is deprecated to pass anything except NULL
33988  * as @package.
33989  *
33990  * Returns: a string containing the complete path to @subdir inside the installation directory of @package. The returned string is in the GLib file name encoding, i.e. UTF-8. The return value should be freed with g_free() when no longer needed. If something goes wrong, %NULL is returned.
33991  * Deprecated: 2.18: Pass the HMODULE of a DLL or EXE to g_win32_get_package_installation_directory_of_module() instead, and then construct a subdirectory pathname with g_build_filename().
33992  */
33993
33994
33995 /**
33996  * g_win32_get_windows_version:
33997  *
33998  * Returns version information for the Windows operating system the
33999  * code is running on. See MSDN documentation for the GetVersion()
34000  * function. To summarize, the most significant bit is one on Win9x,
34001  * and zero on NT-based systems. Since version 2.14, GLib works only
34002  * on NT-based systems, so checking whether your are running on Win9x
34003  * in your own software is moot. The least significant byte is 4 on
34004  * Windows NT 4, and 5 on Windows XP. Software that needs really
34005  * detailed version and feature information should use Win32 API like
34006  * GetVersionEx() and VerifyVersionInfo().
34007  *
34008  * Returns: The version information.
34009  * Since: 2.6
34010  */
34011
34012
34013 /**
34014  * g_win32_getlocale:
34015  *
34016  * The setlocale() function in the Microsoft C library uses locale
34017  * names of the form "English_United States.1252" etc. We want the
34018  * UNIXish standard form "en_US", "zh_TW" etc. This function gets the
34019  * current thread locale from Windows - without any encoding info -
34020  * and returns it as a string of the above form for use in forming
34021  * file names etc. The returned string should be deallocated with
34022  * g_free().
34023  *
34024  * Returns: newly-allocated locale name.
34025  */
34026
34027
34028 /**
34029  * g_win32_locale_filename_from_utf8:
34030  * @utf8filename: a UTF-8 encoded filename.
34031  *
34032  * Converts a filename from UTF-8 to the system codepage.
34033  *
34034  * On NT-based Windows, on NTFS file systems, file names are in
34035  * Unicode. It is quite possible that Unicode file names contain
34036  * characters not representable in the system codepage. (For instance,
34037  * Greek or Cyrillic characters on Western European or US Windows
34038  * installations, or various less common CJK characters on CJK Windows
34039  * installations.)
34040  *
34041  * In such a case, and if the filename refers to an existing file, and
34042  * the file system stores alternate short (8.3) names for directory
34043  * entries, the short form of the filename is returned. Note that the
34044  * "short" name might in fact be longer than the Unicode name if the
34045  * Unicode name has very short pathname components containing
34046  * non-ASCII characters. If no system codepage name for the file is
34047  * possible, %NULL is returned.
34048  *
34049  * The return value is dynamically allocated and should be freed with
34050  * g_free() when no longer needed.
34051  *
34052  * Returns: The converted filename, or %NULL on conversion failure and lack of short names.
34053  * Since: 2.8
34054  */
34055
34056
34057 /**
34058  * gboolean:
34059  *
34060  * A standard boolean type.
34061  * Variables of this type should only contain the value
34062  * %TRUE or %FALSE.
34063  */
34064
34065
34066 /**
34067  * gchar:
34068  *
34069  * Corresponds to the standard C <type>char</type> type.
34070  */
34071
34072
34073 /**
34074  * gconstpointer:
34075  *
34076  * An untyped pointer to constant data.
34077  * The data pointed to should not be changed.
34078  *
34079  * This is typically used in function prototypes to indicate
34080  * that the data pointed to will not be altered by the function.
34081  */
34082
34083
34084 /**
34085  * gdouble:
34086  *
34087  * Corresponds to the standard C <type>double</type> type.
34088  * Values of this type can range from -#G_MAXDOUBLE to #G_MAXDOUBLE.
34089  */
34090
34091
34092 /**
34093  * gfloat:
34094  *
34095  * Corresponds to the standard C <type>float</type> type.
34096  * Values of this type can range from -#G_MAXFLOAT to #G_MAXFLOAT.
34097  */
34098
34099
34100 /**
34101  * gint:
34102  *
34103  * Corresponds to the standard C <type>int</type> type.
34104  * Values of this type can range from #G_MININT to #G_MAXINT.
34105  */
34106
34107
34108 /**
34109  * gint16:
34110  *
34111  * A signed integer guaranteed to be 16 bits on all platforms.
34112  * Values of this type can range from #G_MININT16 (= -32,768) to
34113  * #G_MAXINT16 (= 32,767).
34114  *
34115  * To print or scan values of this type, use
34116  * %G_GINT16_MODIFIER and/or %G_GINT16_FORMAT.
34117  */
34118
34119
34120 /**
34121  * gint32:
34122  *
34123  * A signed integer guaranteed to be 32 bits on all platforms.
34124  * Values of this type can range from #G_MININT32 (= -2,147,483,648)
34125  * to #G_MAXINT32 (= 2,147,483,647).
34126  *
34127  * To print or scan values of this type, use
34128  * %G_GINT32_MODIFIER and/or %G_GINT32_FORMAT.
34129  */
34130
34131
34132 /**
34133  * gint64:
34134  *
34135  * A signed integer guaranteed to be 64 bits on all platforms.
34136  * Values of this type can range from #G_MININT64
34137  * (= -9,223,372,036,854,775,808) to #G_MAXINT64
34138  * (= 9,223,372,036,854,775,807).
34139  *
34140  * To print or scan values of this type, use
34141  * %G_GINT64_MODIFIER and/or %G_GINT64_FORMAT.
34142  */
34143
34144
34145 /**
34146  * gint8:
34147  *
34148  * A signed integer guaranteed to be 8 bits on all platforms.
34149  * Values of this type can range from #G_MININT8 (= -128) to
34150  * #G_MAXINT8 (= 127).
34151  */
34152
34153
34154 /**
34155  * gintptr:
34156  *
34157  * Corresponds to the C99 type <type>intptr_t</type>,
34158  * a signed integer type that can hold any pointer.
34159  *
34160  * To print or scan values of this type, use
34161  * %G_GINTPTR_MODIFIER and/or %G_GINTPTR_FORMAT.
34162  *
34163  * Since: 2.18
34164  */
34165
34166
34167 /**
34168  * glib__private__:
34169  * @arg: Do not use this argument
34170  *
34171  * Do not call this function; it is used to share private
34172  * API between glib, gobject, and gio.
34173  */
34174
34175
34176 /**
34177  * glib_check_version:
34178  * @required_major: the required major version.
34179  * @required_minor: the required minor version.
34180  * @required_micro: the required micro version.
34181  *
34182  * Checks that the GLib library in use is compatible with the
34183  * given version. Generally you would pass in the constants
34184  * #GLIB_MAJOR_VERSION, #GLIB_MINOR_VERSION, #GLIB_MICRO_VERSION
34185  * as the three arguments to this function; that produces
34186  * a check that the library in use is compatible with
34187  * the version of GLib the application or module was compiled
34188  * against.
34189  *
34190  * Compatibility is defined by two things: first the version
34191  * of the running library is newer than the version
34192  * @required_major.required_minor.@required_micro. Second
34193  * the running library must be binary compatible with the
34194  * version @required_major.required_minor.@required_micro
34195  * (same major version.)
34196  *
34197  * Returns: %NULL if the GLib library is compatible with the given version, or a string describing the version mismatch. The returned string is owned by GLib and must not be modified or freed.
34198  * Since: 2.6
34199  */
34200
34201
34202 /**
34203  * glib_gettext:
34204  * @str: The string to be translated
34205  *
34206  * Returns the translated string from the glib translations.
34207  * This is an internal function and should only be used by
34208  * the internals of glib (such as libgio).
34209  *
34210  * Returns: the transation of @str to the current locale
34211  */
34212
34213
34214 /**
34215  * glib_mem_profiler_table:
34216  *
34217  * A #GMemVTable containing profiling variants of the memory
34218  * allocation functions. Use them together with g_mem_profile()
34219  * in order to get information about the memory allocation pattern
34220  * of your program.
34221  */
34222
34223
34224 /**
34225  * glib_pgettext:
34226  * @msgctxtid: a combined message context and message id, separated by a \004 character
34227  * @msgidoffset: the offset of the message id in @msgctxid
34228  *
34229  * This function is a variant of glib_gettext() which supports
34230  * a disambiguating message context. See g_dpgettext() for full
34231  * details.
34232  *
34233  * This is an internal function and should only be used by
34234  * the internals of glib (such as libgio).
34235  *
34236  * Returns: the translation of @str to the current locale
34237  */
34238
34239
34240 /**
34241  * glong:
34242  *
34243  * Corresponds to the standard C <type>long</type> type.
34244  * Values of this type can range from #G_MINLONG to #G_MAXLONG.
34245  */
34246
34247
34248 /**
34249  * goffset:
34250  *
34251  * A signed integer type that is used for file offsets,
34252  * corresponding to the C99 type <type>off64_t</type>.
34253  * Values of this type can range from #G_MINOFFSET to
34254  * #G_MAXOFFSET.
34255  *
34256  * To print or scan values of this type, use
34257  * %G_GOFFSET_MODIFIER and/or %G_GOFFSET_FORMAT.
34258  *
34259  * Since: 2.14
34260  */
34261
34262
34263 /**
34264  * gpointer:
34265  *
34266  * An untyped pointer.
34267  * #gpointer looks better and is easier to use
34268  * than <type>void*</type>.
34269  */
34270
34271
34272 /**
34273  * gshort:
34274  *
34275  * Corresponds to the standard C <type>short</type> type.
34276  * Values of this type can range from #G_MINSHORT to #G_MAXSHORT.
34277  */
34278
34279
34280 /**
34281  * gsize:
34282  *
34283  * An unsigned integer type of the result of the sizeof operator,
34284  * corresponding to the <type>size_t</type> type defined in C99.
34285  * This type is wide enough to hold the numeric value of a pointer,
34286  * so it is usually 32bit wide on a 32bit platform and 64bit wide
34287  * on a 64bit platform. Values of this type can range from 0 to
34288  * #G_MAXSIZE.
34289  *
34290  * To print or scan values of this type, use
34291  * %G_GSIZE_MODIFIER and/or %G_GSIZE_FORMAT.
34292  */
34293
34294
34295 /**
34296  * gssize:
34297  *
34298  * A signed variant of #gsize, corresponding to the
34299  * <type>ssize_t</type> defined on most platforms.
34300  * Values of this type can range from #G_MINSSIZE
34301  * to #G_MAXSSIZE.
34302  *
34303  * To print or scan values of this type, use
34304  * %G_GSIZE_MODIFIER and/or %G_GSSIZE_FORMAT.
34305  */
34306
34307
34308 /**
34309  * guchar:
34310  *
34311  * Corresponds to the standard C <type>unsigned char</type> type.
34312  */
34313
34314
34315 /**
34316  * guint:
34317  *
34318  * Corresponds to the standard C <type>unsigned int</type> type.
34319  * Values of this type can range from 0 to #G_MAXUINT.
34320  */
34321
34322
34323 /**
34324  * guint16:
34325  *
34326  * An unsigned integer guaranteed to be 16 bits on all platforms.
34327  * Values of this type can range from 0 to #G_MAXUINT16 (= 65,535).
34328  *
34329  * To print or scan values of this type, use
34330  * %G_GINT16_MODIFIER and/or %G_GUINT16_FORMAT.
34331  */
34332
34333
34334 /**
34335  * guint32:
34336  *
34337  * An unsigned integer guaranteed to be 32 bits on all platforms.
34338  * Values of this type can range from 0 to #G_MAXUINT32 (= 4,294,967,295).
34339  *
34340  * To print or scan values of this type, use
34341  * %G_GINT32_MODIFIER and/or %G_GUINT32_FORMAT.
34342  */
34343
34344
34345 /**
34346  * guint64:
34347  *
34348  * An unsigned integer guaranteed to be 64 bits on all platforms.
34349  * Values of this type can range from 0 to #G_MAXUINT64
34350  * (= 18,446,744,073,709,551,615).
34351  *
34352  * To print or scan values of this type, use
34353  * %G_GINT64_MODIFIER and/or %G_GUINT64_FORMAT.
34354  */
34355
34356
34357 /**
34358  * guint8:
34359  *
34360  * An unsigned integer guaranteed to be 8 bits on all platforms.
34361  * Values of this type can range from 0 to #G_MAXUINT8 (= 255).
34362  */
34363
34364
34365 /**
34366  * guintptr:
34367  *
34368  * Corresponds to the C99 type <type>uintptr_t</type>,
34369  * an unsigned integer type that can hold any pointer.
34370  *
34371  * To print or scan values of this type, use
34372  * %G_GINTPTR_MODIFIER and/or %G_GUINTPTR_FORMAT.
34373  *
34374  * Since: 2.18
34375  */
34376
34377
34378 /**
34379  * gulong:
34380  *
34381  * Corresponds to the standard C <type>unsigned long</type> type.
34382  * Values of this type can range from 0 to #G_MAXULONG.
34383  */
34384
34385
34386 /**
34387  * gushort:
34388  *
34389  * Corresponds to the standard C <type>unsigned short</type> type.
34390  * Values of this type can range from 0 to #G_MAXUSHORT.
34391  */
34392
34393
34394
34395 /************************************************************/
34396 /* THIS FILE IS GENERATED DO NOT EDIT */
34397 /************************************************************/