1*946379e7Schristos /* OS/2 compatibility functions.
2*946379e7Schristos Copyright (C) 2001-2002 Free Software Foundation, Inc.
3*946379e7Schristos
4*946379e7Schristos This program is free software; you can redistribute it and/or modify it
5*946379e7Schristos under the terms of the GNU Library General Public License as published
6*946379e7Schristos by the Free Software Foundation; either version 2, or (at your option)
7*946379e7Schristos any later version.
8*946379e7Schristos
9*946379e7Schristos This program is distributed in the hope that it will be useful,
10*946379e7Schristos but WITHOUT ANY WARRANTY; without even the implied warranty of
11*946379e7Schristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12*946379e7Schristos Library General Public License for more details.
13*946379e7Schristos
14*946379e7Schristos You should have received a copy of the GNU Library General Public
15*946379e7Schristos License along with this program; if not, write to the Free Software
16*946379e7Schristos Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17*946379e7Schristos USA. */
18*946379e7Schristos
19*946379e7Schristos #define OS2_AWARE
20*946379e7Schristos #ifdef HAVE_CONFIG_H
21*946379e7Schristos #include <config.h>
22*946379e7Schristos #endif
23*946379e7Schristos
24*946379e7Schristos #include <stdlib.h>
25*946379e7Schristos #include <string.h>
26*946379e7Schristos #include <sys/param.h>
27*946379e7Schristos
28*946379e7Schristos /* A version of getenv() that works from DLLs */
29*946379e7Schristos extern unsigned long DosScanEnv (const unsigned char *pszName, unsigned char **ppszValue);
30*946379e7Schristos
31*946379e7Schristos char *
_nl_getenv(const char * name)32*946379e7Schristos _nl_getenv (const char *name)
33*946379e7Schristos {
34*946379e7Schristos unsigned char *value;
35*946379e7Schristos if (DosScanEnv (name, &value))
36*946379e7Schristos return NULL;
37*946379e7Schristos else
38*946379e7Schristos return value;
39*946379e7Schristos }
40*946379e7Schristos
41*946379e7Schristos /* A fixed size buffer. */
42*946379e7Schristos char libintl_nl_default_dirname[MAXPATHLEN+1];
43*946379e7Schristos
44*946379e7Schristos char *_nlos2_libdir = NULL;
45*946379e7Schristos char *_nlos2_localealiaspath = NULL;
46*946379e7Schristos char *_nlos2_localedir = NULL;
47*946379e7Schristos
48*946379e7Schristos static __attribute__((constructor)) void
nlos2_initialize()49*946379e7Schristos nlos2_initialize ()
50*946379e7Schristos {
51*946379e7Schristos char *root = getenv ("UNIXROOT");
52*946379e7Schristos char *gnulocaledir = getenv ("GNULOCALEDIR");
53*946379e7Schristos
54*946379e7Schristos _nlos2_libdir = gnulocaledir;
55*946379e7Schristos if (!_nlos2_libdir)
56*946379e7Schristos {
57*946379e7Schristos if (root)
58*946379e7Schristos {
59*946379e7Schristos size_t sl = strlen (root);
60*946379e7Schristos _nlos2_libdir = (char *) malloc (sl + strlen (LIBDIR) + 1);
61*946379e7Schristos memcpy (_nlos2_libdir, root, sl);
62*946379e7Schristos memcpy (_nlos2_libdir + sl, LIBDIR, strlen (LIBDIR) + 1);
63*946379e7Schristos }
64*946379e7Schristos else
65*946379e7Schristos _nlos2_libdir = LIBDIR;
66*946379e7Schristos }
67*946379e7Schristos
68*946379e7Schristos _nlos2_localealiaspath = gnulocaledir;
69*946379e7Schristos if (!_nlos2_localealiaspath)
70*946379e7Schristos {
71*946379e7Schristos if (root)
72*946379e7Schristos {
73*946379e7Schristos size_t sl = strlen (root);
74*946379e7Schristos _nlos2_localealiaspath = (char *) malloc (sl + strlen (LOCALE_ALIAS_PATH) + 1);
75*946379e7Schristos memcpy (_nlos2_localealiaspath, root, sl);
76*946379e7Schristos memcpy (_nlos2_localealiaspath + sl, LOCALE_ALIAS_PATH, strlen (LOCALE_ALIAS_PATH) + 1);
77*946379e7Schristos }
78*946379e7Schristos else
79*946379e7Schristos _nlos2_localealiaspath = LOCALE_ALIAS_PATH;
80*946379e7Schristos }
81*946379e7Schristos
82*946379e7Schristos _nlos2_localedir = gnulocaledir;
83*946379e7Schristos if (!_nlos2_localedir)
84*946379e7Schristos {
85*946379e7Schristos if (root)
86*946379e7Schristos {
87*946379e7Schristos size_t sl = strlen (root);
88*946379e7Schristos _nlos2_localedir = (char *) malloc (sl + strlen (LOCALEDIR) + 1);
89*946379e7Schristos memcpy (_nlos2_localedir, root, sl);
90*946379e7Schristos memcpy (_nlos2_localedir + sl, LOCALEDIR, strlen (LOCALEDIR) + 1);
91*946379e7Schristos }
92*946379e7Schristos else
93*946379e7Schristos _nlos2_localedir = LOCALEDIR;
94*946379e7Schristos }
95*946379e7Schristos
96*946379e7Schristos if (strlen (_nlos2_localedir) <= MAXPATHLEN)
97*946379e7Schristos strcpy (libintl_nl_default_dirname, _nlos2_localedir);
98*946379e7Schristos }
99