1 /* 2 * Distributed under the Boost Software License, Version 1.0. 3 * (See accompanying file LICENSE_1_0.txt or copy at 4 * http://www.boost.org/LICENSE_1_0.txt) 5 */ 6 module glib.gutils; 7 8 import glib.gtypes; 9 10 import core.stdc.stdarg; 11 12 13 enum GUserDirectory { 14 G_USER_DIRECTORY_DESKTOP, 15 G_USER_DIRECTORY_DOCUMENTS, 16 G_USER_DIRECTORY_DOWNLOAD, 17 G_USER_DIRECTORY_MUSIC, 18 G_USER_DIRECTORY_PICTURES, 19 G_USER_DIRECTORY_PUBLIC_SHARE, 20 G_USER_DIRECTORY_TEMPLATES, 21 G_USER_DIRECTORY_VIDEOS, 22 23 G_USER_N_DIRECTORIES 24 } 25 26 27 28 struct GDebugKey 29 { 30 const(gchar) *key; 31 guint value; 32 } 33 34 35 enum GFormatSizeFlags 36 { 37 G_FORMAT_SIZE_DEFAULT = 0, 38 G_FORMAT_SIZE_LONG_FORMAT = 1 << 0, 39 G_FORMAT_SIZE_IEC_UNITS = 1 << 1 40 } 41 42 43 extern (C) { 44 45 46 const(gchar) * g_get_user_name (); 47 48 const(gchar) * g_get_real_name (); 49 50 const(gchar) * g_get_home_dir (); 51 52 const(gchar) * g_get_tmp_dir (); 53 54 const(gchar) * g_get_host_name (); 55 56 const(gchar) * g_get_prgname (); 57 58 void g_set_prgname (const(gchar) *prgname); 59 60 const(gchar) * g_get_application_name (); 61 62 void g_set_application_name (const(gchar) *application_name); 63 64 65 void g_reload_user_special_dirs_cache (); 66 67 const(gchar) * g_get_user_data_dir (); 68 69 const(gchar) * g_get_user_config_dir (); 70 71 const(gchar) * g_get_user_cache_dir (); 72 73 const(gchar*)* g_get_system_data_dirs (); 74 75 const(gchar*) * g_get_system_config_dirs (); 76 77 const(gchar) * g_get_user_runtime_dir (); 78 79 const(gchar) * g_get_user_special_dir (GUserDirectory directory); 80 81 guint g_parse_debug_string (const(gchar) *str, 82 const(GDebugKey) *keys, 83 guint nkeys); 84 85 86 gint g_snprintf (gchar *str, 87 gulong n, 88 const(gchar) *format, 89 ...); 90 91 gint g_vsnprintf (gchar *str, 92 gulong n, 93 const(gchar) *format, 94 va_list args); 95 96 97 void g_nullify_pointer (gpointer *nullify_location); 98 99 gchar *g_format_size_full (guint64 size, 100 GFormatSizeFlags flags); 101 102 gchar *g_format_size (guint64 size); 103 104 deprecated("use g_format_size") 105 gchar *g_format_size_for_display (goffset size); 106 107 108 void g_abort (); 109 110 gchar* g_find_program_in_path (const(gchar) *program); 111 112 } 113 114 115 /* Bit tests 116 */ 117 // G_INLINE_FUNC gint g_bit_nth_lsf (gulong mask, 118 // gint nth_bit) G_GNUC_CONST; 119 // G_INLINE_FUNC gint g_bit_nth_msf (gulong mask, 120 // gint nth_bit) G_GNUC_CONST; 121 // G_INLINE_FUNC guint g_bit_storage (gulong number) G_GNUC_CONST; 122 // 123 // /* inline function implementations 124 // */ 125 // #if defined (G_CAN_INLINE) || defined (__G_UTILS_C__) 126 // G_INLINE_FUNC gint 127 // g_bit_nth_lsf (gulong mask, 128 // gint nth_bit) 129 // { 130 // if (G_UNLIKELY (nth_bit < -1)) 131 // nth_bit = -1; 132 // while (nth_bit < ((GLIB_SIZEOF_LONG * 8) - 1)) 133 // { 134 // nth_bit++; 135 // if (mask & (1UL << nth_bit)) 136 // return nth_bit; 137 // } 138 // return -1; 139 // } 140 // G_INLINE_FUNC gint 141 // g_bit_nth_msf (gulong mask, 142 // gint nth_bit) 143 // { 144 // if (nth_bit < 0 || G_UNLIKELY (nth_bit > GLIB_SIZEOF_LONG * 8)) 145 // nth_bit = GLIB_SIZEOF_LONG * 8; 146 // while (nth_bit > 0) 147 // { 148 // nth_bit--; 149 // if (mask & (1UL << nth_bit)) 150 // return nth_bit; 151 // } 152 // return -1; 153 // } 154 // G_INLINE_FUNC guint 155 // g_bit_storage (gulong number) 156 // { 157 // #if defined(__GNUC__) && (__GNUC__ >= 4) && defined(__OPTIMIZE__) 158 // return G_LIKELY (number) ? 159 // ((GLIB_SIZEOF_LONG * 8U - 1) ^ (guint) __builtin_clzl(number)) + 1 : 1; 160 // #else 161 // guint n_bits = 0; 162 // 163 // do 164 // { 165 // n_bits++; 166 // number >>= 1; 167 // } 168 // while (number); 169 // return n_bits; 170 // #endif 171 // } 172 // #endif /* G_CAN_INLINE || __G_UTILS_C__ */ 173