1<!-- ##### SECTION Title ##### --> 2Miscellaneous Utility Functions 3 4<!-- ##### SECTION Short_Description ##### --> 5a selection of portable utility functions 6 7<!-- ##### SECTION Long_Description ##### --> 8<para> 9These are portable utility functions. 10</para> 11 12<!-- ##### SECTION See_Also ##### --> 13<para> 14 15</para> 16 17<!-- ##### SECTION Stability_Level ##### --> 18 19 20<!-- ##### FUNCTION g_get_application_name ##### --> 21<para> 22 23</para> 24 25@Returns: 26 27 28<!-- ##### FUNCTION g_set_application_name ##### --> 29<para> 30 31</para> 32 33@application_name: 34 35 36<!-- ##### FUNCTION g_get_prgname ##### --> 37<para> 38 39</para> 40 41@Returns: 42 43 44<!-- ##### FUNCTION g_set_prgname ##### --> 45<para> 46 47</para> 48 49@prgname: 50 51 52<!-- ##### FUNCTION g_getenv ##### --> 53<para> 54 55</para> 56 57@variable: 58@Returns: 59 60 61<!-- ##### FUNCTION g_setenv ##### --> 62<para> 63 64</para> 65 66@variable: 67@value: 68@overwrite: 69@Returns: 70 71 72<!-- ##### FUNCTION g_unsetenv ##### --> 73<para> 74 75</para> 76 77@variable: 78 79 80<!-- ##### FUNCTION g_listenv ##### --> 81<para> 82 83</para> 84 85@Returns: 86 87 88<!-- ##### FUNCTION g_get_user_name ##### --> 89<para> 90 91</para> 92 93@Returns: 94 95 96<!-- ##### FUNCTION g_get_real_name ##### --> 97<para> 98 99</para> 100 101@Returns: 102 103 104<!-- ##### FUNCTION g_get_user_cache_dir ##### --> 105<para> 106 107</para> 108 109@Returns: 110 111 112<!-- ##### FUNCTION g_get_user_data_dir ##### --> 113<para> 114 115</para> 116 117@Returns: 118 119 120<!-- ##### FUNCTION g_get_user_config_dir ##### --> 121<para> 122 123</para> 124 125@Returns: 126 127 128<!-- ##### ENUM GUserDirectory ##### --> 129<para> 130 131</para> 132 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: 142 143<!-- ##### FUNCTION g_get_user_special_dir ##### --> 144<para> 145 146</para> 147 148@directory: 149@Returns: 150 151 152<!-- ##### FUNCTION g_get_system_data_dirs ##### --> 153<para> 154 155</para> 156 157@Returns: 158 159 160<!-- ##### FUNCTION g_get_system_config_dirs ##### --> 161<para> 162 163</para> 164 165@Returns: 166 167 168<!-- ##### FUNCTION g_get_host_name ##### --> 169<para> 170 171</para> 172 173@Returns: 174 175 176<!-- ##### FUNCTION g_get_home_dir ##### --> 177<para> 178 179</para> 180 181@Returns: 182 183 184<!-- ##### FUNCTION g_get_tmp_dir ##### --> 185<para> 186 187</para> 188 189@Returns: 190 191 192<!-- ##### FUNCTION g_get_current_dir ##### --> 193<para> 194 195</para> 196 197@Returns: 198 199 200<!-- ##### FUNCTION g_basename ##### --> 201 202 203@file_name: 204@Returns: 205 206 207<!-- ##### MACRO g_dirname ##### --> 208<para> 209This function is deprecated and will be removed in the next major 210release of GLib. Use g_path_get_dirname() instead. 211</para> 212 213<para> 214Gets the directory components of a file name. 215If the file name has no directory components "." is returned. 216The returned string should be freed when no longer needed. 217</para> 218 219@Returns: the directory components of the file. 220 221 222<!-- ##### FUNCTION g_path_is_absolute ##### --> 223<para> 224 225</para> 226 227@file_name: 228@Returns: 229 230 231<!-- ##### FUNCTION g_path_skip_root ##### --> 232<para> 233 234</para> 235 236@file_name: 237@Returns: 238 239 240<!-- ##### FUNCTION g_path_get_basename ##### --> 241<para> 242 243</para> 244 245@file_name: 246@Returns: 247 248 249<!-- ##### FUNCTION g_path_get_dirname ##### --> 250<para> 251 252</para> 253 254@file_name: 255@Returns: 256 257 258<!-- ##### FUNCTION g_build_filename ##### --> 259<para> 260 261</para> 262 263@first_element: 264@Varargs: 265@Returns: 266 267 268<!-- ##### FUNCTION g_build_filenamev ##### --> 269<para> 270 271</para> 272 273@args: 274@Returns: 275 276 277<!-- ##### FUNCTION g_build_path ##### --> 278<para> 279 280</para> 281 282@separator: 283@first_element: 284@Varargs: 285@Returns: 286 287 288<!-- ##### FUNCTION g_build_pathv ##### --> 289<para> 290 291</para> 292 293@separator: 294@args: 295@Returns: 296 297 298<!-- ##### FUNCTION g_format_size_for_display ##### --> 299<para> 300 301</para> 302 303@size: 304@Returns: 305 306 307<!-- ##### FUNCTION g_find_program_in_path ##### --> 308<para> 309 310</para> 311 312@program: 313@Returns: 314 315 316<!-- ##### FUNCTION g_bit_nth_lsf ##### --> 317<para> 318Find the position of the first bit set in @mask, searching from (but not 319including) @nth_bit upwards. Bits are numbered from 0 (least significant) 320to sizeof(#gulong) * 8 - 1 (31 or 63, usually). To start searching from the 3210th bit, set @nth_bit to -1. 322</para> 323 324@mask: a #gulong containing flags. 325@nth_bit: the index of the bit to start the search from. 326@Returns: the index of the first bit set which is higher than @nth_bit. 327 328 329<!-- ##### FUNCTION g_bit_nth_msf ##### --> 330<para> 331Find the position of the first bit set in @mask, searching from (but not 332including) @nth_bit downwards. Bits are numbered from 0 (least significant) 333to sizeof(#gulong) * 8 - 1 (31 or 63, usually). To start searching from the 334last bit, set @nth_bit to -1 or GLIB_SIZEOF_LONG * 8. 335</para> 336 337@mask: a #gulong containing flags. 338@nth_bit: the index of the bit to start the search from. 339@Returns: the index of the first bit set which is lower than @nth_bit. 340 341 342<!-- ##### FUNCTION g_bit_storage ##### --> 343<para> 344Gets the number of bits used to hold @number, 345e.g. if @number is 4, 3 bits are needed. 346</para> 347 348@number: a guint. 349@Returns: the number of bits used to hold @number. 350 351 352<!-- ##### FUNCTION g_spaced_primes_closest ##### --> 353<para> 354Gets the smallest prime number from a built-in array of primes which 355is larger than @num. This is used within GLib to calculate the optimum 356size of a #GHashTable. 357</para> 358<para> 359The built-in array of primes ranges from 11 to 13845163 such that 360each prime is approximately 1.5-2 times the previous prime. 361</para> 362 363@num: a #guint. 364@Returns: the smallest prime number from a built-in array of primes which is 365larger than @num. 366 367 368<!-- ##### FUNCTION g_atexit ##### --> 369<para> 370 371</para> 372 373@func: 374 375 376<!-- ##### FUNCTION g_parse_debug_string ##### --> 377<para> 378 379</para> 380 381@string: 382@keys: 383@nkeys: 384@Returns: 385 386 387<!-- ##### STRUCT GDebugKey ##### --> 388<para> 389Associates a string with a bit flag. 390Used in g_parse_debug_string(). 391</para> 392 393@key: the string 394@value: the flag 395 396<!-- ##### USER_FUNCTION GVoidFunc ##### --> 397<para> 398Declares a type of function which takes no arguments and has no return value. 399It is used to specify the type function passed to g_atexit(). 400</para> 401 402 403 404<!-- ##### USER_FUNCTION GFreeFunc ##### --> 405<para> 406Declares a type of function which takes an arbitrary data pointer argument 407and has no return value. It is not currently used in GLib or GTK+. 408</para> 409 410@data: a data pointer. 411 412 413<!-- ##### FUNCTION g_qsort_with_data ##### --> 414<para> 415 416</para> 417 418@pbase: 419@total_elems: 420@size: 421@compare_func: 422@user_data: 423 424 425<!-- ##### FUNCTION g_nullify_pointer ##### --> 426<para> 427 428</para> 429 430@nullify_location: 431 432 433