Blame intl/os2compat.c

Packit Service a721b1
/* OS/2 compatibility functions.
Packit Service a721b1
   Copyright (C) 2001-2002 Free Software Foundation, Inc.
Packit Service a721b1
Packit Service a721b1
   This program is free software; you can redistribute it and/or modify it
Packit Service a721b1
   under the terms of the GNU Library General Public License as published
Packit Service a721b1
   by the Free Software Foundation; either version 2, or (at your option)
Packit Service a721b1
   any later version.
Packit Service a721b1
Packit Service a721b1
   This program is distributed in the hope that it will be useful,
Packit Service a721b1
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service a721b1
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service a721b1
   Library General Public License for more details.
Packit Service a721b1
Packit Service a721b1
   You should have received a copy of the GNU Library General Public
Packit Service a721b1
   License along with this program; if not, write to the Free Software
Packit Service a721b1
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
Packit Service a721b1
   USA.  */
Packit Service a721b1
Packit Service a721b1
#define OS2_AWARE
Packit Service a721b1
#ifdef HAVE_CONFIG_H
Packit Service a721b1
#include <config.h>
Packit Service a721b1
#endif
Packit Service a721b1
Packit Service a721b1
#include <stdlib.h>
Packit Service a721b1
#include <string.h>
Packit Service a721b1
#include <sys/param.h>
Packit Service a721b1
Packit Service a721b1
/* A version of getenv() that works from DLLs */
Packit Service a721b1
extern unsigned long DosScanEnv (const unsigned char *pszName, unsigned char **ppszValue);
Packit Service a721b1
Packit Service a721b1
char *
Packit Service a721b1
_nl_getenv (const char *name)
Packit Service a721b1
{
Packit Service a721b1
  unsigned char *value;
Packit Service a721b1
  if (DosScanEnv (name, &value))
Packit Service a721b1
    return NULL;
Packit Service a721b1
  else
Packit Service a721b1
    return value;
Packit Service a721b1
}
Packit Service a721b1
Packit Service a721b1
/* A fixed size buffer.  */
Packit Service a721b1
char libintl_nl_default_dirname[MAXPATHLEN+1];
Packit Service a721b1
Packit Service a721b1
char *_nlos2_libdir = NULL;
Packit Service a721b1
char *_nlos2_localealiaspath = NULL;
Packit Service a721b1
char *_nlos2_localedir = NULL;
Packit Service a721b1
Packit Service a721b1
static __attribute__((constructor)) void
Packit Service a721b1
nlos2_initialize ()
Packit Service a721b1
{
Packit Service a721b1
  char *root = getenv ("UNIXROOT");
Packit Service a721b1
  char *gnulocaledir = getenv ("GNULOCALEDIR");
Packit Service a721b1
Packit Service a721b1
  _nlos2_libdir = gnulocaledir;
Packit Service a721b1
  if (!_nlos2_libdir)
Packit Service a721b1
    {
Packit Service a721b1
      if (root)
Packit Service a721b1
        {
Packit Service a721b1
          size_t sl = strlen (root);
Packit Service a721b1
          _nlos2_libdir = (char *) malloc (sl + strlen (LIBDIR) + 1);
Packit Service a721b1
          memcpy (_nlos2_libdir, root, sl);
Packit Service a721b1
          memcpy (_nlos2_libdir + sl, LIBDIR, strlen (LIBDIR) + 1);
Packit Service a721b1
        }
Packit Service a721b1
      else
Packit Service a721b1
        _nlos2_libdir = LIBDIR;
Packit Service a721b1
    }
Packit Service a721b1
Packit Service a721b1
  _nlos2_localealiaspath = gnulocaledir;
Packit Service a721b1
  if (!_nlos2_localealiaspath)
Packit Service a721b1
    {
Packit Service a721b1
      if (root)
Packit Service a721b1
        {
Packit Service a721b1
          size_t sl = strlen (root);
Packit Service a721b1
          _nlos2_localealiaspath = (char *) malloc (sl + strlen (LOCALE_ALIAS_PATH) + 1);
Packit Service a721b1
          memcpy (_nlos2_localealiaspath, root, sl);
Packit Service a721b1
          memcpy (_nlos2_localealiaspath + sl, LOCALE_ALIAS_PATH, strlen (LOCALE_ALIAS_PATH) + 1);
Packit Service a721b1
        }
Packit Service a721b1
     else
Packit Service a721b1
        _nlos2_localealiaspath = LOCALE_ALIAS_PATH;
Packit Service a721b1
    }
Packit Service a721b1
Packit Service a721b1
  _nlos2_localedir = gnulocaledir;
Packit Service a721b1
  if (!_nlos2_localedir)
Packit Service a721b1
    {
Packit Service a721b1
      if (root)
Packit Service a721b1
        {
Packit Service a721b1
          size_t sl = strlen (root);
Packit Service a721b1
          _nlos2_localedir = (char *) malloc (sl + strlen (LOCALEDIR) + 1);
Packit Service a721b1
          memcpy (_nlos2_localedir, root, sl);
Packit Service a721b1
          memcpy (_nlos2_localedir + sl, LOCALEDIR, strlen (LOCALEDIR) + 1);
Packit Service a721b1
        }
Packit Service a721b1
      else
Packit Service a721b1
        _nlos2_localedir = LOCALEDIR;
Packit Service a721b1
    }
Packit Service a721b1
Packit Service a721b1
  if (strlen (_nlos2_localedir) <= MAXPATHLEN)
Packit Service a721b1
    strcpy (libintl_nl_default_dirname, _nlos2_localedir);
Packit Service a721b1
}