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