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 <!-- ##### SECTION Image ##### -->
23 <!-- ##### FUNCTION g_get_application_name ##### -->
32 <!-- ##### FUNCTION g_set_application_name ##### -->
40 <!-- ##### FUNCTION g_get_prgname ##### -->
49 <!-- ##### FUNCTION g_set_prgname ##### -->
57 <!-- ##### FUNCTION g_getenv ##### -->
66 <!-- ##### FUNCTION g_setenv ##### -->
77 <!-- ##### FUNCTION g_unsetenv ##### -->
85 <!-- ##### FUNCTION g_listenv ##### -->
94 <!-- ##### FUNCTION g_get_user_name ##### -->
103 <!-- ##### FUNCTION g_get_real_name ##### -->
112 <!-- ##### FUNCTION g_get_user_cache_dir ##### -->
121 <!-- ##### FUNCTION g_get_user_data_dir ##### -->
130 <!-- ##### FUNCTION g_get_user_config_dir ##### -->
139 <!-- ##### ENUM GUserDirectory ##### -->
144 @G_USER_DIRECTORY_DESKTOP:
145 @G_USER_DIRECTORY_DOCUMENTS:
146 @G_USER_DIRECTORY_DOWNLOAD:
147 @G_USER_DIRECTORY_MUSIC:
148 @G_USER_DIRECTORY_PICTURES:
149 @G_USER_DIRECTORY_PUBLIC_SHARE:
150 @G_USER_DIRECTORY_TEMPLATES:
151 @G_USER_DIRECTORY_VIDEOS:
152 @G_USER_N_DIRECTORIES:
154 <!-- ##### FUNCTION g_get_user_special_dir ##### -->
163 <!-- ##### FUNCTION g_get_system_data_dirs ##### -->
172 <!-- ##### FUNCTION g_get_system_config_dirs ##### -->
181 <!-- ##### FUNCTION g_reload_user_special_dirs_cache ##### -->
189 <!-- ##### FUNCTION g_get_host_name ##### -->
198 <!-- ##### FUNCTION g_get_home_dir ##### -->
207 <!-- ##### FUNCTION g_get_tmp_dir ##### -->
216 <!-- ##### FUNCTION g_get_current_dir ##### -->
225 <!-- ##### FUNCTION g_basename ##### -->
232 <!-- ##### MACRO g_dirname ##### -->
234 This function is deprecated and will be removed in the next major
235 release of GLib. Use g_path_get_dirname() instead.
239 Gets the directory components of a file name.
240 If the file name has no directory components "." is returned.
241 The returned string should be freed when no longer needed.
244 @Returns: the directory components of the file.
247 <!-- ##### FUNCTION g_path_is_absolute ##### -->
256 <!-- ##### FUNCTION g_path_skip_root ##### -->
265 <!-- ##### FUNCTION g_path_get_basename ##### -->
274 <!-- ##### FUNCTION g_path_get_dirname ##### -->
283 <!-- ##### FUNCTION g_build_filename ##### -->
293 <!-- ##### FUNCTION g_build_filenamev ##### -->
302 <!-- ##### FUNCTION g_build_path ##### -->
313 <!-- ##### FUNCTION g_build_pathv ##### -->
323 <!-- ##### FUNCTION g_format_size_for_display ##### -->
332 <!-- ##### FUNCTION g_find_program_in_path ##### -->
341 <!-- ##### FUNCTION g_bit_nth_lsf ##### -->
343 Find the position of the first bit set in @mask, searching from (but not
344 including) @nth_bit upwards. Bits are numbered from 0 (least significant)
345 to sizeof(#gulong) * 8 - 1 (31 or 63, usually). To start searching from the
346 0th bit, set @nth_bit to -1.
349 @mask: a #gulong containing flags.
350 @nth_bit: the index of the bit to start the search from.
351 @Returns: the index of the first bit set which is higher than @nth_bit.
354 <!-- ##### FUNCTION g_bit_nth_msf ##### -->
356 Find the position of the first bit set in @mask, searching from (but not
357 including) @nth_bit downwards. Bits are numbered from 0 (least significant)
358 to sizeof(#gulong) * 8 - 1 (31 or 63, usually). To start searching from the
359 last bit, set @nth_bit to -1 or GLIB_SIZEOF_LONG * 8.
362 @mask: a #gulong containing flags.
363 @nth_bit: the index of the bit to start the search from.
364 @Returns: the index of the first bit set which is lower than @nth_bit.
367 <!-- ##### FUNCTION g_bit_storage ##### -->
369 Gets the number of bits used to hold @number,
370 e.g. if @number is 4, 3 bits are needed.
374 @Returns: the number of bits used to hold @number.
377 <!-- ##### FUNCTION g_spaced_primes_closest ##### -->
379 Gets the smallest prime number from a built-in array of primes which
380 is larger than @num. This is used within GLib to calculate the optimum
381 size of a #GHashTable.
384 The built-in array of primes ranges from 11 to 13845163 such that
385 each prime is approximately 1.5-2 times the previous prime.
389 @Returns: the smallest prime number from a built-in array of primes which is
393 <!-- ##### FUNCTION g_atexit ##### -->
401 <!-- ##### FUNCTION g_parse_debug_string ##### -->
412 <!-- ##### STRUCT GDebugKey ##### -->
414 Associates a string with a bit flag.
415 Used in g_parse_debug_string().
421 <!-- ##### USER_FUNCTION GVoidFunc ##### -->
423 Declares a type of function which takes no arguments and has no return value.
424 It is used to specify the type function passed to g_atexit().
430 <!-- ##### USER_FUNCTION GFreeFunc ##### -->
432 Declares a type of function which takes an arbitrary data pointer argument
433 and has no return value. It is not currently used in GLib or GTK+.
436 @data: a data pointer.
439 <!-- ##### FUNCTION g_qsort_with_data ##### -->
451 <!-- ##### FUNCTION g_nullify_pointer ##### -->