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