1 <!-- ##### SECTION Title ##### -->
2 Miscellaneous Utility Functions
4 <!-- ##### SECTION Short_Description ##### -->
5 a selection of portable utility functions
7 <!-- ##### SECTION Long_Description ##### -->
9 These are portable utility functions.
12 <!-- ##### SECTION See_Also ##### -->
17 <!-- ##### SECTION Stability_Level ##### -->
20 <!-- ##### FUNCTION g_get_application_name ##### -->
28 <!-- ##### FUNCTION g_set_application_name ##### -->
36 <!-- ##### FUNCTION g_get_prgname ##### -->
44 <!-- ##### FUNCTION g_set_prgname ##### -->
52 <!-- ##### FUNCTION g_getenv ##### -->
61 <!-- ##### FUNCTION g_setenv ##### -->
72 <!-- ##### FUNCTION g_unsetenv ##### -->
80 <!-- ##### FUNCTION g_listenv ##### -->
88 <!-- ##### FUNCTION g_get_user_name ##### -->
96 <!-- ##### FUNCTION g_get_real_name ##### -->
104 <!-- ##### FUNCTION g_get_user_cache_dir ##### -->
112 <!-- ##### FUNCTION g_get_user_data_dir ##### -->
120 <!-- ##### FUNCTION g_get_user_config_dir ##### -->
128 <!-- ##### ENUM GUserDirectory ##### -->
133 @G_USER_DIRECTORY_DESKTOP:
134 @G_USER_DIRECTORY_DOCUMENTS:
135 @G_USER_DIRECTORY_DOWNLOAD:
136 @G_USER_DIRECTORY_MUSIC:
137 @G_USER_DIRECTORY_PICTURES:
138 @G_USER_DIRECTORY_PUBLIC_SHARE:
139 @G_USER_DIRECTORY_TEMPLATES:
140 @G_USER_DIRECTORY_VIDEOS:
141 @G_USER_N_DIRECTORIES:
143 <!-- ##### FUNCTION g_get_user_special_dir ##### -->
152 <!-- ##### FUNCTION g_get_system_data_dirs ##### -->
160 <!-- ##### FUNCTION g_get_system_config_dirs ##### -->
168 <!-- ##### FUNCTION g_reload_user_special_dirs_cache ##### -->
175 <!-- ##### FUNCTION g_get_host_name ##### -->
183 <!-- ##### FUNCTION g_get_home_dir ##### -->
191 <!-- ##### FUNCTION g_get_tmp_dir ##### -->
199 <!-- ##### FUNCTION g_get_current_dir ##### -->
207 <!-- ##### FUNCTION g_basename ##### -->
214 <!-- ##### MACRO g_dirname ##### -->
216 This function is deprecated and will be removed in the next major
217 release of GLib. Use g_path_get_dirname() instead.
221 Gets the directory components of a file name.
222 If the file name has no directory components "." is returned.
223 The returned string should be freed when no longer needed.
226 @Returns: the directory components of the file.
229 <!-- ##### FUNCTION g_path_is_absolute ##### -->
238 <!-- ##### FUNCTION g_path_skip_root ##### -->
247 <!-- ##### FUNCTION g_path_get_basename ##### -->
256 <!-- ##### FUNCTION g_path_get_dirname ##### -->
265 <!-- ##### FUNCTION g_build_filename ##### -->
275 <!-- ##### FUNCTION g_build_filenamev ##### -->
284 <!-- ##### FUNCTION g_build_path ##### -->
295 <!-- ##### FUNCTION g_build_pathv ##### -->
305 <!-- ##### FUNCTION g_format_size_for_display ##### -->
314 <!-- ##### FUNCTION g_find_program_in_path ##### -->
323 <!-- ##### FUNCTION g_bit_nth_lsf ##### -->
325 Find the position of the first bit set in @mask, searching from (but not
326 including) @nth_bit upwards. Bits are numbered from 0 (least significant)
327 to sizeof(#gulong) * 8 - 1 (31 or 63, usually). To start searching from the
328 0th bit, set @nth_bit to -1.
331 @mask: a #gulong containing flags.
332 @nth_bit: the index of the bit to start the search from.
333 @Returns: the index of the first bit set which is higher than @nth_bit.
336 <!-- ##### FUNCTION g_bit_nth_msf ##### -->
338 Find the position of the first bit set in @mask, searching from (but not
339 including) @nth_bit downwards. Bits are numbered from 0 (least significant)
340 to sizeof(#gulong) * 8 - 1 (31 or 63, usually). To start searching from the
341 last bit, set @nth_bit to -1 or GLIB_SIZEOF_LONG * 8.
344 @mask: a #gulong containing flags.
345 @nth_bit: the index of the bit to start the search from.
346 @Returns: the index of the first bit set which is lower than @nth_bit.
349 <!-- ##### FUNCTION g_bit_storage ##### -->
351 Gets the number of bits used to hold @number,
352 e.g. if @number is 4, 3 bits are needed.
356 @Returns: the number of bits used to hold @number.
359 <!-- ##### FUNCTION g_spaced_primes_closest ##### -->
361 Gets the smallest prime number from a built-in array of primes which
362 is larger than @num. This is used within GLib to calculate the optimum
363 size of a #GHashTable.
366 The built-in array of primes ranges from 11 to 13845163 such that
367 each prime is approximately 1.5-2 times the previous prime.
371 @Returns: the smallest prime number from a built-in array of primes which is
375 <!-- ##### FUNCTION g_atexit ##### -->
383 <!-- ##### FUNCTION g_parse_debug_string ##### -->
394 <!-- ##### STRUCT GDebugKey ##### -->
396 Associates a string with a bit flag.
397 Used in g_parse_debug_string().
403 <!-- ##### USER_FUNCTION GVoidFunc ##### -->
405 Declares a type of function which takes no arguments and has no return value.
406 It is used to specify the type function passed to g_atexit().
411 <!-- ##### USER_FUNCTION GFreeFunc ##### -->
413 Declares a type of function which takes an arbitrary data pointer argument
414 and has no return value. It is not currently used in GLib or GTK+.
417 @data: a data pointer.
420 <!-- ##### FUNCTION g_qsort_with_data ##### -->
432 <!-- ##### FUNCTION g_nullify_pointer ##### -->