1 /* OS/2 compatibility functions.
2 Copyright (C) 2001-2002, 2015 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published by
6 the Free Software Foundation; either version 2.1 of the License, or
7 (at your option) any later version.
9 This program 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
12 GNU Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
24 #include <sys/param.h>
26 /* A version of getenv() that works from DLLs */
27 extern unsigned long DosScanEnv (const unsigned char *pszName, unsigned char **ppszValue);
30 _nl_getenv (const char *name)
33 if (DosScanEnv (name, &value))
39 /* A fixed size buffer. */
40 char libintl_nl_default_dirname[MAXPATHLEN+1];
42 char *_nlos2_libdir = NULL;
43 char *_nlos2_localealiaspath = NULL;
44 char *_nlos2_localedir = NULL;
46 static __attribute__((constructor)) void
49 char *root = getenv ("UNIXROOT");
50 char *gnulocaledir = getenv ("GNULOCALEDIR");
52 _nlos2_libdir = gnulocaledir;
57 size_t sl = strlen (root);
58 _nlos2_libdir = (char *) malloc (sl + strlen (LIBDIR) + 1);
59 memcpy (_nlos2_libdir, root, sl);
60 memcpy (_nlos2_libdir + sl, LIBDIR, strlen (LIBDIR) + 1);
63 _nlos2_libdir = LIBDIR;
66 _nlos2_localealiaspath = gnulocaledir;
67 if (!_nlos2_localealiaspath)
71 size_t sl = strlen (root);
72 _nlos2_localealiaspath = (char *) malloc (sl + strlen (LOCALE_ALIAS_PATH) + 1);
73 memcpy (_nlos2_localealiaspath, root, sl);
74 memcpy (_nlos2_localealiaspath + sl, LOCALE_ALIAS_PATH, strlen (LOCALE_ALIAS_PATH) + 1);
77 _nlos2_localealiaspath = LOCALE_ALIAS_PATH;
80 _nlos2_localedir = gnulocaledir;
81 if (!_nlos2_localedir)
85 size_t sl = strlen (root);
86 _nlos2_localedir = (char *) malloc (sl + strlen (LOCALEDIR) + 1);
87 memcpy (_nlos2_localedir, root, sl);
88 memcpy (_nlos2_localedir + sl, LOCALEDIR, strlen (LOCALEDIR) + 1);
91 _nlos2_localedir = LOCALEDIR;
94 if (strlen (_nlos2_localedir) <= MAXPATHLEN)
95 strcpy (libintl_nl_default_dirname, _nlos2_localedir);