Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

os2compat.c

00001 /* OS/2 compatibility functions.
00002    Copyright (C) 2001-2002 Free Software Foundation, Inc.
00003 
00004    This program is free software; you can redistribute it and/or modify it
00005    under the terms of the GNU Library General Public License as published
00006    by the Free Software Foundation; either version 2, or (at your option)
00007    any later version.
00008 
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public
00015    License along with this program; if not, write to the Free Software
00016    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
00017    USA.  */
00018 
00019 #define OS2_AWARE
00020 #ifdef HAVE_CONFIG_H
00021 #include <config.h>
00022 #endif
00023 
00024 #include <stdlib.h>
00025 #include <string.h>
00026 
00027 /* A version of getenv() that works from DLLs */
00028 extern unsigned long DosScanEnv (const unsigned char *pszName, unsigned char **ppszValue);
00029 
00030 char *
00031 _nl_getenv (const char *name)
00032 {
00033   unsigned char *value;
00034   if (DosScanEnv (name, &value))
00035     return NULL;
00036   else
00037     return value;
00038 }
00039 
00040 /* A fixed size buffer.  */
00041 #define LOCALEDIR_MAX 260
00042 char _nl_default_dirname__[LOCALEDIR_MAX+1];
00043 
00044 char *_os2_libdir = NULL;
00045 char *_os2_localealiaspath = NULL;
00046 char *_os2_localedir = NULL;
00047 
00048 static __attribute__((constructor)) void
00049 os2_initialize ()
00050 {
00051   char *root = getenv ("UNIXROOT");
00052   char *gnulocaledir = getenv ("GNULOCALEDIR");
00053 
00054   _os2_libdir = gnulocaledir;
00055   if (!_os2_libdir)
00056     {
00057       if (root)
00058         {
00059           size_t sl = strlen (root);
00060           _os2_libdir = (char *) malloc (sl + strlen (LIBDIR) + 1);
00061           memcpy (_os2_libdir, root, sl);
00062           memcpy (_os2_libdir + sl, LIBDIR, strlen (LIBDIR) + 1);
00063         }
00064       else
00065         _os2_libdir = LIBDIR;
00066     }
00067 
00068   _os2_localealiaspath = gnulocaledir;
00069   if (!_os2_localealiaspath)
00070     {
00071       if (root)
00072         {
00073           size_t sl = strlen (root);
00074           _os2_localealiaspath = (char *) malloc (sl + strlen (LOCALE_ALIAS_PATH) + 1);
00075           memcpy (_os2_localealiaspath, root, sl);
00076           memcpy (_os2_localealiaspath + sl, LOCALE_ALIAS_PATH, strlen (LOCALE_ALIAS_PATH) + 1);
00077         }
00078      else
00079         _os2_localealiaspath = LOCALE_ALIAS_PATH;
00080     }
00081 
00082   _os2_localedir = gnulocaledir;
00083   if (!_os2_localedir)
00084     {
00085       if (root)
00086         {
00087           size_t sl = strlen (root);
00088           _os2_localedir = (char *) malloc (sl + strlen (LOCALEDIR) + 1);
00089           memcpy (_os2_localedir, root, sl);
00090           memcpy (_os2_localedir + sl, LOCALEDIR, strlen (LOCALEDIR) + 1);
00091         }
00092       else
00093         _os2_localedir = LOCALEDIR;
00094     }
00095 
00096   {
00097     extern const char _nl_default_dirname__[];
00098     if (strlen (_os2_localedir) <= LOCALEDIR_MAX)
00099       strcpy (_nl_default_dirname__, _os2_localedir);
00100   }
00101 }

Generated on Sun Feb 16 23:39:49 2003 for FreeLCD by doxygen1.2.18