You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

os2compat.c 2.8KB

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