1 /* GLIB - Library of useful routines for C programming
2 * Copyright (C) 1995-1998 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 * Modified by the GLib Team and others 1997-2000. See the AUTHORS
22 * file for a list of people on the GLib Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GLib at ftp://ftp.gtk.org/pub/gtk/.
28 * MT safe for the unix part, FIXME: make the win32 part MT safe as well.
44 #include <sys/types.h>
45 #ifdef HAVE_SYS_PARAM_H
46 #include <sys/param.h>
49 /* implement gutils's inline functions
51 #define G_IMPLEMENT_INLINES 1
54 #include "gprintfint.h"
57 #define G_PATH_LENGTH MAXPATHLEN
58 #elif defined (PATH_MAX)
59 #define G_PATH_LENGTH PATH_MAX
60 #elif defined (_PC_PATH_MAX)
61 #define G_PATH_LENGTH sysconf(_PC_PATH_MAX)
63 #define G_PATH_LENGTH 2048
66 #ifdef G_PLATFORM_WIN32
67 # define STRICT /* Strict typing, please */
70 # include <lmcons.h> /* For UNLEN */
72 #endif /* G_PLATFORM_WIN32 */
82 #ifdef HAVE_BIND_TEXTDOMAIN_CODESET
86 const guint glib_major_version = GLIB_MAJOR_VERSION;
87 const guint glib_minor_version = GLIB_MINOR_VERSION;
88 const guint glib_micro_version = GLIB_MICRO_VERSION;
89 const guint glib_interface_age = GLIB_INTERFACE_AGE;
90 const guint glib_binary_age = GLIB_BINARY_AGE;
92 #if !defined (HAVE_MEMMOVE) && !defined (HAVE_WORKING_BCOPY)
94 g_memmove (gpointer dest, gconstpointer src, gulong len)
96 gchar* destptr = dest;
97 const gchar* srcptr = src;
98 if (src + len < dest || dest + len < src)
100 bcopy (src, dest, len);
103 else if (dest <= src)
106 *(destptr++) = *(srcptr++);
113 *(--destptr) = *(--srcptr);
116 #endif /* !HAVE_MEMMOVE && !HAVE_WORKING_BCOPY */
119 g_atexit (GVoidFunc func)
122 const gchar *error = NULL;
124 /* keep this in sync with glib.h */
126 #ifdef G_NATIVE_ATEXIT
127 result = ATEXIT (func);
129 error = g_strerror (errno);
130 #elif defined (HAVE_ATEXIT)
131 # ifdef NeXT /* @#%@! NeXTStep */
132 result = !atexit ((void (*)(void)) func);
134 error = g_strerror (errno);
136 result = atexit ((void (*)(void)) func);
138 error = g_strerror (errno);
140 #elif defined (HAVE_ON_EXIT)
141 result = on_exit ((void (*)(int, void *)) func, NULL);
143 error = g_strerror (errno);
146 error = "no implementation";
147 #endif /* G_NATIVE_ATEXIT */
150 g_error ("Could not register atexit() function: %s", error);
153 /* Based on execvp() from GNU Libc.
154 * Some of this code is cut-and-pasted into gspawn.c
158 my_strchrnul (const gchar *str, gchar c)
160 gchar *p = (gchar*)str;
161 while (*p && (*p != c))
169 gchar *inner_find_program_in_path (const gchar *program);
172 g_find_program_in_path (const gchar *program)
174 const gchar *last_dot = strrchr (program, '.');
176 if (last_dot == NULL || strchr (last_dot, '\\') != NULL)
178 const gint program_length = strlen (program);
179 const gchar *pathext = getenv ("PATHEXT");
181 gchar *decorated_program;
185 pathext = ".com;.exe;.bat";
191 p = my_strchrnul (pathext, ';');
193 decorated_program = g_malloc (program_length + (p-pathext) + 1);
194 memcpy (decorated_program, program, program_length);
195 memcpy (decorated_program+program_length, pathext, p-pathext);
196 decorated_program [program_length + (p-pathext)] = '\0';
198 retval = inner_find_program_in_path (decorated_program);
199 g_free (decorated_program);
203 } while (*p++ != '\0');
207 return inner_find_program_in_path (program);
210 #define g_find_program_in_path inner_find_program_in_path
214 * g_find_program_in_path:
215 * @program: a program name
217 * Locates the first executable named @program in the user's path, in the
218 * same way that execvp() would locate it. Returns an allocated string
219 * with the absolute path name, or NULL if the program is not found in
220 * the path. If @program is already an absolute path, returns a copy of
221 * @program if @program exists and is executable, and NULL otherwise.
223 * On Windows, if @program does not have a file type suffix, tries to
224 * append the suffixes in the PATHEXT environment variable (if that
225 * doesn't exists, the suffixes .com, .exe, and .bat) in turn, and
226 * then look for the resulting file name in the same way as
227 * CreateProcess() would. This means first in the directory where the
228 * program was loaded from, then in the current directory, then in the
229 * Windows 32-bit system directory, then in the Windows directory, and
230 * finally in the directories in the PATH environment variable. If
231 * the program is found, the return value contains the full name
232 * including the type suffix.
234 * Return value: absolute path, or NULL
237 g_find_program_in_path (const gchar *program)
239 const gchar *path, *p;
240 gchar *name, *freeme;
247 g_return_val_if_fail (program != NULL, NULL);
249 /* If it is an absolute path, or a relative path including subdirectories,
250 * don't look in PATH.
252 if (g_path_is_absolute (program)
253 || strchr (program, G_DIR_SEPARATOR) != NULL)
255 if (g_file_test (program, G_FILE_TEST_IS_EXECUTABLE))
256 return g_strdup (program);
261 path = g_getenv ("PATH");
265 /* There is no `PATH' in the environment. The default
266 * search path in GNU libc is the current directory followed by
267 * the path `confstr' returns for `_CS_PATH'.
270 /* In GLib we put . last, for security, and don't use the
271 * unportable confstr(); UNIX98 does not actually specify
272 * what to search if PATH is unset. POSIX may, dunno.
275 path = "/bin:/usr/bin:.";
280 gchar moddir[MAXPATHLEN], sysdir[MAXPATHLEN], windir[MAXPATHLEN];
282 GetModuleFileName (NULL, moddir, sizeof (moddir));
283 tmp = g_path_get_dirname (moddir);
284 GetSystemDirectory (sysdir, sizeof (sysdir));
285 GetWindowsDirectory (windir, sizeof (windir));
286 path_tmp = g_strconcat (tmp, ";.;", sysdir, ";", windir,
287 (path != NULL ? ";" : NULL),
288 (path != NULL ? path : NULL),
295 len = strlen (program) + 1;
296 pathlen = strlen (path);
297 freeme = name = g_malloc (pathlen + len + 1);
299 /* Copy the file name at the top, including '\0' */
300 memcpy (name + pathlen + 1, program, len);
301 name = name + pathlen;
302 /* And add the slash before the filename */
303 *name = G_DIR_SEPARATOR;
311 p = my_strchrnul (path, G_SEARCHPATH_SEPARATOR);
314 /* Two adjacent colons, or a colon at the beginning or the end
315 * of `PATH' means to search the current directory.
319 startp = memcpy (name - (p - path), path, p - path);
321 if (g_file_test (startp, G_FILE_TEST_IS_EXECUTABLE))
324 ret = g_strdup (startp);
332 while (*p++ != '\0');
343 g_parse_debug_string (const gchar *string,
344 const GDebugKey *keys,
350 g_return_val_if_fail (string != NULL, 0);
352 if (!g_ascii_strcasecmp (string, "all"))
354 for (i=0; i<nkeys; i++)
355 result |= keys[i].value;
359 const gchar *p = string;
361 gboolean done = FALSE;
372 for (i=0; i<nkeys; i++)
373 if (g_ascii_strncasecmp(keys[i].key, p, q - p) == 0 &&
374 keys[i].key[q - p] == '\0')
375 result |= keys[i].value;
386 * @file_name: the name of the file.
388 * Gets the name of the file without any leading directory components.
389 * It returns a pointer into the given file name string.
391 * Return value: the name of the file without any leading directory components.
393 * Deprecated: Use g_path_get_basename() instead.
395 G_CONST_RETURN gchar*
396 g_basename (const gchar *file_name)
398 register gchar *base;
400 g_return_val_if_fail (file_name != NULL, NULL);
402 base = strrchr (file_name, G_DIR_SEPARATOR);
407 if (g_ascii_isalpha (file_name[0]) && file_name[1] == ':')
408 return (gchar*) file_name + 2;
409 #endif /* G_OS_WIN32 */
411 return (gchar*) file_name;
415 g_path_get_basename (const gchar *file_name)
417 register gssize base;
418 register gssize last_nonslash;
422 g_return_val_if_fail (file_name != NULL, NULL);
424 if (file_name[0] == '\0')
426 return g_strdup (".");
428 last_nonslash = strlen (file_name) - 1;
430 while (last_nonslash >= 0 && file_name [last_nonslash] == G_DIR_SEPARATOR)
433 if (last_nonslash == -1)
434 /* string only containing slashes */
435 return g_strdup (G_DIR_SEPARATOR_S);
438 if (last_nonslash == 1 && g_ascii_isalpha (file_name[0]) && file_name[1] == ':')
439 /* string only containing slashes and a drive */
440 return g_strdup (G_DIR_SEPARATOR_S);
441 #endif /* G_OS_WIN32 */
443 base = last_nonslash;
445 while (base >=0 && file_name [base] != G_DIR_SEPARATOR)
449 if (base == -1 && g_ascii_isalpha (file_name[0]) && file_name[1] == ':')
451 #endif /* G_OS_WIN32 */
453 len = last_nonslash - base;
454 retval = g_malloc (len + 1);
455 memcpy (retval, file_name + base + 1, len);
461 g_path_is_absolute (const gchar *file_name)
463 g_return_val_if_fail (file_name != NULL, FALSE);
465 if (file_name[0] == G_DIR_SEPARATOR
467 || file_name[0] == '/'
473 /* Recognize drive letter on native Windows */
474 if (g_ascii_isalpha (file_name[0]) && file_name[1] == ':' && (file_name[2] == G_DIR_SEPARATOR || file_name[2] == '/'))
476 #endif /* G_OS_WIN32 */
481 G_CONST_RETURN gchar*
482 g_path_skip_root (const gchar *file_name)
484 g_return_val_if_fail (file_name != NULL, NULL);
486 #ifdef G_PLATFORM_WIN32
487 /* Skip \\server\share (Win32) or //server/share (Cygwin) */
488 if (file_name[0] == G_DIR_SEPARATOR &&
489 file_name[1] == G_DIR_SEPARATOR &&
494 if ((p = strchr (file_name + 2, G_DIR_SEPARATOR)) > file_name + 2 &&
499 while (file_name[0] && file_name[0] != G_DIR_SEPARATOR)
502 /* Possibly skip a backslash after the share name */
503 if (file_name[0] == G_DIR_SEPARATOR)
506 return (gchar *)file_name;
511 /* Skip initial slashes */
512 if (file_name[0] == G_DIR_SEPARATOR)
514 while (file_name[0] == G_DIR_SEPARATOR)
516 return (gchar *)file_name;
521 if (g_ascii_isalpha (file_name[0]) && file_name[1] == ':' && file_name[2] == G_DIR_SEPARATOR)
522 return (gchar *)file_name + 3;
529 g_path_get_dirname (const gchar *file_name)
531 register gchar *base;
534 g_return_val_if_fail (file_name != NULL, NULL);
536 base = strrchr (file_name, G_DIR_SEPARATOR);
538 return g_strdup (".");
539 while (base > file_name && *base == G_DIR_SEPARATOR)
541 len = (guint) 1 + base - file_name;
543 base = g_new (gchar, len + 1);
544 g_memmove (base, file_name, len);
551 g_get_current_dir (void)
553 gchar *buffer = NULL;
555 static gulong max_len = 0;
558 max_len = (G_PATH_LENGTH == -1) ? 2048 : G_PATH_LENGTH;
560 /* We don't use getcwd(3) on SUNOS, because, it does a popen("pwd")
561 * and, if that wasn't bad enough, hangs in doing so.
563 #if (defined (sun) && !defined (__SVR4)) || !defined(HAVE_GETCWD)
564 buffer = g_new (gchar, max_len + 1);
566 dir = getwd (buffer);
567 #else /* !sun || !HAVE_GETCWD */
568 while (max_len < G_MAXULONG / 2)
570 buffer = g_new (gchar, max_len + 1);
572 dir = getcwd (buffer, max_len);
574 if (dir || errno != ERANGE)
580 #endif /* !sun || !HAVE_GETCWD */
582 if (!dir || !*buffer)
584 /* hm, should we g_error() out here?
585 * this can happen if e.g. "./" has mode \0000
587 buffer[0] = G_DIR_SEPARATOR;
591 dir = g_strdup (buffer);
597 G_CONST_RETURN gchar*
598 g_getenv (const gchar *variable)
601 g_return_val_if_fail (variable != NULL, NULL);
603 return getenv (variable);
605 G_LOCK_DEFINE_STATIC (getenv);
611 static GArray *environs = NULL;
616 g_return_val_if_fail (variable != NULL, NULL);
621 environs = g_array_new (FALSE, FALSE, sizeof (struct env_struct));
623 /* First we try to find the envinronment variable inside the already
627 for (i = 0; i < environs->len; i++)
629 env = &g_array_index (environs, struct env_struct, i);
630 if (strcmp (env->key, variable) == 0)
632 g_assert (env->value);
638 /* If not found, we ask the system */
640 system_env = getenv (variable);
647 /* On Windows NT, it is relatively typical that environment variables
648 * contain references to other environment variables. Handle that by
649 * calling ExpandEnvironmentStrings.
652 g_array_set_size (environs, environs->len + 1);
654 env = &g_array_index (environs, struct env_struct, environs->len - 1);
656 /* First check how much space we need */
657 length = ExpandEnvironmentStrings (system_env, dummy, 2);
659 /* Then allocate that much, and actualy do the expansion and insert
660 * the new found pair into our buffer
663 env->value = g_malloc (length);
664 env->key = g_strdup (variable);
666 ExpandEnvironmentStrings (system_env, env->value, length);
674 G_LOCK_DEFINE_STATIC (g_utils_global);
676 static gchar *g_tmp_dir = NULL;
677 static gchar *g_user_name = NULL;
678 static gchar *g_real_name = NULL;
679 static gchar *g_home_dir = NULL;
681 /* HOLDS: g_utils_global_lock */
683 g_get_any_init (void)
687 g_tmp_dir = g_strdup (g_getenv ("TMPDIR"));
689 g_tmp_dir = g_strdup (g_getenv ("TMP"));
691 g_tmp_dir = g_strdup (g_getenv ("TEMP"));
697 g_tmp_dir = g_strdup (P_tmpdir);
698 k = strlen (g_tmp_dir);
699 if (k > 1 && g_tmp_dir[k - 1] == G_DIR_SEPARATOR)
700 g_tmp_dir[k - 1] = '\0';
707 g_tmp_dir = g_strdup ("/tmp");
708 #else /* G_OS_WIN32 */
709 g_tmp_dir = g_strdup ("C:\\");
710 #endif /* G_OS_WIN32 */
714 /* We check $HOME first for Win32, though it is a last resort for Unix
715 * where we prefer the results of getpwuid().
717 g_home_dir = g_strdup (g_getenv ("HOME"));
719 /* In case HOME is Unix-style (it happens), convert it to
725 while ((p = strchr (g_home_dir, '/')) != NULL)
731 /* USERPROFILE is probably the closest equivalent to $HOME? */
732 if (getenv ("USERPROFILE") != NULL)
733 g_home_dir = g_strdup (g_getenv ("USERPROFILE"));
738 /* At least at some time, HOMEDRIVE and HOMEPATH were used
739 * to point to the home directory, I think. But on Windows
740 * 2000 HOMEDRIVE seems to be equal to SYSTEMDRIVE, and
741 * HOMEPATH is its root "\"?
743 if (getenv ("HOMEDRIVE") != NULL && getenv ("HOMEPATH") != NULL)
745 gchar *homedrive, *homepath;
747 homedrive = g_strdup (g_getenv ("HOMEDRIVE"));
748 homepath = g_strdup (g_getenv ("HOMEPATH"));
750 g_home_dir = g_strconcat (homedrive, homepath, NULL);
755 #endif /* G_OS_WIN32 */
759 struct passwd *pw = NULL;
760 gpointer buffer = NULL;
763 # if defined (HAVE_POSIX_GETPWUID_R) || defined (HAVE_NONPOSIX_GETPWUID_R)
765 # ifdef _SC_GETPW_R_SIZE_MAX
766 /* This reurns the maximum length */
767 glong bufsize = sysconf (_SC_GETPW_R_SIZE_MAX);
771 # else /* _SC_GETPW_R_SIZE_MAX */
773 # endif /* _SC_GETPW_R_SIZE_MAX */
778 buffer = g_malloc (bufsize);
781 # ifdef HAVE_POSIX_GETPWUID_R
782 error = getpwuid_r (getuid (), &pwd, buffer, bufsize, &pw);
783 error = error < 0 ? errno : error;
784 # else /* HAVE_NONPOSIX_GETPWUID_R */
785 /* HPUX 11 falls into the HAVE_POSIX_GETPWUID_R case */
786 # if defined(_AIX) || defined(__hpux)
787 error = getpwuid_r (getuid (), &pwd, buffer, bufsize);
788 pw = error == 0 ? &pwd : NULL;
790 pw = getpwuid_r (getuid (), &pwd, buffer, bufsize);
791 error = pw ? 0 : errno;
793 # endif /* HAVE_NONPOSIX_GETPWUID_R */
797 /* we bail out prematurely if the user id can't be found
798 * (should be pretty rare case actually), or if the buffer
799 * should be sufficiently big and lookups are still not
802 if (error == 0 || error == ENOENT)
804 g_warning ("getpwuid_r(): failed due to unknown user id (%lu)",
808 if (bufsize > 32 * 1024)
810 g_warning ("getpwuid_r(): failed due to: %s.",
819 # endif /* HAVE_POSIX_GETPWUID_R || HAVE_NONPOSIX_GETPWUID_R */
824 pw = getpwuid (getuid ());
829 g_user_name = g_strdup (pw->pw_name);
830 g_real_name = g_strdup (pw->pw_gecos);
832 g_home_dir = g_strdup (pw->pw_dir);
837 #else /* !HAVE_PWD_H */
842 gchar buffer[UNLEN+1];
844 if (GetUserName ((LPTSTR) buffer, (LPDWORD) &len))
846 g_user_name = g_strdup (buffer);
847 g_real_name = g_strdup (buffer);
850 # endif /* G_OS_WIN32 */
852 #endif /* !HAVE_PWD_H */
855 g_home_dir = g_strdup (g_getenv ("HOME"));
858 /* change '\\' in %HOME% to '/' */
859 g_strdelimit (g_home_dir, "\\",'/');
862 g_user_name = g_strdup ("somebody");
864 g_real_name = g_strdup ("Unknown");
869 for (p = g_real_name; *p; p++)
873 p = g_strdup (g_real_name);
874 g_free (g_real_name);
882 G_CONST_RETURN gchar*
883 g_get_user_name (void)
885 G_LOCK (g_utils_global);
888 G_UNLOCK (g_utils_global);
893 G_CONST_RETURN gchar*
894 g_get_real_name (void)
896 G_LOCK (g_utils_global);
899 G_UNLOCK (g_utils_global);
904 /* Return the home directory of the user. If there is a HOME
905 * environment variable, its value is returned, otherwise use some
906 * system-dependent way of finding it out. If no home directory can be
907 * deduced, return NULL.
910 G_CONST_RETURN gchar*
911 g_get_home_dir (void)
913 G_LOCK (g_utils_global);
916 G_UNLOCK (g_utils_global);
921 /* Return a directory to be used to store temporary files. This is the
922 * value of the TMPDIR, TMP or TEMP environment variables (they are
923 * checked in that order). If none of those exist, use P_tmpdir from
924 * stdio.h. If that isn't defined, return "/tmp" on POSIXly systems,
925 * and C:\ on Windows.
928 G_CONST_RETURN gchar*
931 G_LOCK (g_utils_global);
934 G_UNLOCK (g_utils_global);
939 G_LOCK_DEFINE (g_prgname);
940 static gchar *g_prgname = NULL;
949 G_UNLOCK (g_prgname);
955 g_set_prgname (const gchar *prgname)
959 g_prgname = g_strdup (prgname);
960 G_UNLOCK (g_prgname);
963 G_LOCK_DEFINE (g_application_name);
964 static gchar *g_application_name = NULL;
967 * g_get_application_name:
969 * Gets a human-readable name for the application, as set by
970 * g_set_application_name(). This name should be localized if
971 * possible, and is intended for display to the user. Contrast with
972 * g_get_prgname(), which gets a non-localized name. If
973 * g_set_application_name() has not been called, returns the result of
974 * g_get_prgname() (which may be %NULL if g_set_prgname() has also not
977 * Return value: human-readable application name. may return %NULL
981 G_CONST_RETURN gchar*
982 g_get_application_name (void)
986 G_LOCK (g_application_name);
987 retval = g_application_name;
988 G_UNLOCK (g_application_name);
991 return g_get_prgname ();
997 * g_set_application_name:
998 * @application_name: localized name of the application
1000 * Sets a human-readable name for the application. This name should be
1001 * localized if possible, and is intended for display to the user.
1002 * Contrast with g_set_prgname(), which sets a non-localized name.
1003 * g_set_prgname() will be called automatically by gtk_init(),
1004 * but g_set_application_name() will not.
1006 * Note that for thread safety reasons, this function can only
1009 * The application name will be used in contexts such as error messages,
1010 * or when displaying an application's name in the task list.
1014 g_set_application_name (const gchar *application_name)
1016 gboolean already_set = FALSE;
1018 G_LOCK (g_application_name);
1019 if (g_application_name)
1022 g_application_name = g_strdup (application_name);
1023 G_UNLOCK (g_application_name);
1026 g_warning ("g_set_application() name called multiple times");
1030 g_direct_hash (gconstpointer v)
1032 return GPOINTER_TO_UINT (v);
1036 g_direct_equal (gconstpointer v1,
1043 g_int_equal (gconstpointer v1,
1046 return *((const gint*) v1) == *((const gint*) v2);
1050 g_int_hash (gconstpointer v)
1052 return *(const gint*) v;
1056 * g_nullify_pointer:
1057 * @nullify_location: the memory address of the pointer.
1059 * Set the pointer at the specified location to %NULL.
1062 g_nullify_pointer (gpointer *nullify_location)
1064 g_return_if_fail (nullify_location != NULL);
1066 *nullify_location = NULL;
1072 * Get the codeset for the current locale.
1074 * Return value: a newly allocated string containing the name
1075 * of the codeset. This string must be freed with g_free().
1078 g_get_codeset (void)
1081 char *result = nl_langinfo (CODESET);
1082 return g_strdup (result);
1084 #ifdef G_PLATFORM_WIN32
1085 return g_strdup_printf ("CP%d", GetACP ());
1087 /* FIXME: Do something more intelligent based on setlocale (LC_CTYPE, NULL)
1089 return g_strdup ("ISO-8859-1");
1096 #include <libintl.h>
1098 #ifdef G_PLATFORM_WIN32
1100 G_WIN32_DLLMAIN_FOR_DLL_NAME (static, dll_name)
1102 static const gchar *
1103 _glib_get_locale_dir (void)
1105 static const gchar *cache = NULL;
1107 cache = g_win32_get_package_installation_subdirectory
1108 (GETTEXT_PACKAGE, dll_name, "lib\\locale");
1113 #undef GLIB_LOCALE_DIR
1114 #define GLIB_LOCALE_DIR _glib_get_locale_dir ()
1116 #endif /* G_PLATFORM_WIN32 */
1118 G_CONST_RETURN gchar *
1119 _glib_gettext (const gchar *str)
1121 static gboolean _glib_gettext_initialized = FALSE;
1123 if (!_glib_gettext_initialized)
1125 bindtextdomain(GETTEXT_PACKAGE, GLIB_LOCALE_DIR);
1126 # ifdef HAVE_BIND_TEXTDOMAIN_CODESET
1127 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
1129 _glib_gettext_initialized = TRUE;
1132 return dgettext (GETTEXT_PACKAGE, str);
1135 #endif /* ENABLE_NLS */