intl-compat.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /* intl-compat.c - Stub functions to call gettext functions from GNU gettext
  2. Library.
  3. Copyright (C) 1995, 2000, 2001 Software Foundation, Inc.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  15. #ifdef HAVE_CONFIG_H
  16. # include <config.h>
  17. #endif
  18. #include "libgnuintl.h"
  19. #include "gettextP.h"
  20. /* @@ end of prolog @@ */
  21. /* This file redirects the gettext functions (without prefix or suffix) to
  22. those defined in the included GNU gettext library (with "__" suffix).
  23. It is compiled into libintl when the included GNU gettext library is
  24. configured --with-included-gettext.
  25. This redirection works also in the case that the system C library or
  26. the system libintl library contain gettext/textdomain/... functions.
  27. If it didn't, we would need to add preprocessor level redirections to
  28. libgnuintl.h of the following form:
  29. # define gettext gettext__
  30. # define dgettext dgettext__
  31. # define dcgettext dcgettext__
  32. # define ngettext ngettext__
  33. # define dngettext dngettext__
  34. # define dcngettext dcngettext__
  35. # define textdomain textdomain__
  36. # define bindtextdomain bindtextdomain__
  37. # define bind_textdomain_codeset bind_textdomain_codeset__
  38. How does this redirection work? There are two cases.
  39. A. When libintl.a is linked into an executable, it works because
  40. functions defined in the executable always override functions in
  41. the shared libraries.
  42. B. When libintl.so is used, it works because
  43. 1. those systems defining gettext/textdomain/... in the C library
  44. (namely, Solaris 2.4 and newer, and GNU libc 2.0 and newer) are
  45. ELF systems and define these symbols as weak, thus explicitly
  46. letting other shared libraries override it.
  47. 2. those systems defining gettext/textdomain/... in a standalone
  48. libintl.so library (namely, Solaris 2.3 and newer) have this
  49. shared library in /usr/lib, and the linker will search /usr/lib
  50. *after* the directory where the GNU gettext library is installed.
  51. A third case, namely when libintl.a is linked into a shared library
  52. whose name is not libintl.so, is not supported. In this case, on
  53. Solaris, when -lintl precedes the linker option for the shared library
  54. containing GNU gettext, the system's gettext would indeed override
  55. the GNU gettext. Anyone doing this kind of stuff must be clever enough
  56. to 1. compile libintl.a with -fPIC, 2. remove -lintl from his linker
  57. command line. */
  58. #undef gettext
  59. #undef dgettext
  60. #undef dcgettext
  61. #undef ngettext
  62. #undef dngettext
  63. #undef dcngettext
  64. #undef textdomain
  65. #undef bindtextdomain
  66. #undef bind_textdomain_codeset
  67. char *
  68. gettext (msgid)
  69. const char *msgid;
  70. {
  71. return gettext__ (msgid);
  72. }
  73. char *
  74. dgettext (domainname, msgid)
  75. const char *domainname;
  76. const char *msgid;
  77. {
  78. return dgettext__ (domainname, msgid);
  79. }
  80. char *
  81. dcgettext (domainname, msgid, category)
  82. const char *domainname;
  83. const char *msgid;
  84. int category;
  85. {
  86. return dcgettext__ (domainname, msgid, category);
  87. }
  88. char *
  89. ngettext (msgid1, msgid2, n)
  90. const char *msgid1;
  91. const char *msgid2;
  92. unsigned long int n;
  93. {
  94. return ngettext__ (msgid1, msgid2, n);
  95. }
  96. char *
  97. dngettext (domainname, msgid1, msgid2, n)
  98. const char *domainname;
  99. const char *msgid1;
  100. const char *msgid2;
  101. unsigned long int n;
  102. {
  103. return dngettext__ (domainname, msgid1, msgid2, n);
  104. }
  105. char *
  106. dcngettext (domainname, msgid1, msgid2, n, category)
  107. const char *domainname;
  108. const char *msgid1;
  109. const char *msgid2;
  110. unsigned long int n;
  111. int category;
  112. {
  113. return dcngettext__ (domainname, msgid1, msgid2, n, category);
  114. }
  115. char *
  116. textdomain (domainname)
  117. const char *domainname;
  118. {
  119. return textdomain__ (domainname);
  120. }
  121. char *
  122. bindtextdomain (domainname, dirname)
  123. const char *domainname;
  124. const char *dirname;
  125. {
  126. return bindtextdomain__ (domainname, dirname);
  127. }
  128. char *
  129. bind_textdomain_codeset (domainname, codeset)
  130. const char *domainname;
  131. const char *codeset;
  132. {
  133. return bind_textdomain_codeset__ (domainname, codeset);
  134. }