00001 /* intl-compat.c - Stub functions to call gettext functions from GNU gettext 00002 Library. 00003 Copyright (C) 1995, 2000, 2001 Software Foundation, Inc. 00004 00005 This program is free software; you can redistribute it and/or modify it 00006 under the terms of the GNU Library General Public License as published 00007 by the Free Software Foundation; either version 2, or (at your option) 00008 any later version. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public 00016 License along with this program; if not, write to the Free Software 00017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 00018 USA. */ 00019 00020 #ifdef HAVE_CONFIG_H 00021 # include <config.h> 00022 #endif 00023 00024 #include "libgnuintl.h" 00025 #include "gettextP.h" 00026 00027 /* @@ end of prolog @@ */ 00028 00029 /* This file redirects the gettext functions (without prefix or suffix) to 00030 those defined in the included GNU gettext library (with "__" suffix). 00031 It is compiled into libintl when the included GNU gettext library is 00032 configured --with-included-gettext. 00033 00034 This redirection works also in the case that the system C library or 00035 the system libintl library contain gettext/textdomain/... functions. 00036 If it didn't, we would need to add preprocessor level redirections to 00037 libgnuintl.h of the following form: 00038 00039 # define gettext gettext__ 00040 # define dgettext dgettext__ 00041 # define dcgettext dcgettext__ 00042 # define ngettext ngettext__ 00043 # define dngettext dngettext__ 00044 # define dcngettext dcngettext__ 00045 # define textdomain textdomain__ 00046 # define bindtextdomain bindtextdomain__ 00047 # define bind_textdomain_codeset bind_textdomain_codeset__ 00048 00049 How does this redirection work? There are two cases. 00050 A. When libintl.a is linked into an executable, it works because 00051 functions defined in the executable always override functions in 00052 the shared libraries. 00053 B. When libintl.so is used, it works because 00054 1. those systems defining gettext/textdomain/... in the C library 00055 (namely, Solaris 2.4 and newer, and GNU libc 2.0 and newer) are 00056 ELF systems and define these symbols as weak, thus explicitly 00057 letting other shared libraries override it. 00058 2. those systems defining gettext/textdomain/... in a standalone 00059 libintl.so library (namely, Solaris 2.3 and newer) have this 00060 shared library in /usr/lib, and the linker will search /usr/lib 00061 *after* the directory where the GNU gettext library is installed. 00062 00063 A third case, namely when libintl.a is linked into a shared library 00064 whose name is not libintl.so, is not supported. In this case, on 00065 Solaris, when -lintl precedes the linker option for the shared library 00066 containing GNU gettext, the system's gettext would indeed override 00067 the GNU gettext. Anyone doing this kind of stuff must be clever enough 00068 to 1. compile libintl.a with -fPIC, 2. remove -lintl from his linker 00069 command line. */ 00070 00071 00072 #undef gettext 00073 #undef dgettext 00074 #undef dcgettext 00075 #undef ngettext 00076 #undef dngettext 00077 #undef dcngettext 00078 #undef textdomain 00079 #undef bindtextdomain 00080 #undef bind_textdomain_codeset 00081 00082 00083 char * 00084 gettext (msgid) 00085 const char *msgid; 00086 { 00087 return gettext__ (msgid); 00088 } 00089 00090 00091 char * 00092 dgettext (domainname, msgid) 00093 const char *domainname; 00094 const char *msgid; 00095 { 00096 return dgettext__ (domainname, msgid); 00097 } 00098 00099 00100 char * 00101 dcgettext (domainname, msgid, category) 00102 const char *domainname; 00103 const char *msgid; 00104 int category; 00105 { 00106 return dcgettext__ (domainname, msgid, category); 00107 } 00108 00109 00110 char * 00111 ngettext (msgid1, msgid2, n) 00112 const char *msgid1; 00113 const char *msgid2; 00114 unsigned long int n; 00115 { 00116 return ngettext__ (msgid1, msgid2, n); 00117 } 00118 00119 00120 char * 00121 dngettext (domainname, msgid1, msgid2, n) 00122 const char *domainname; 00123 const char *msgid1; 00124 const char *msgid2; 00125 unsigned long int n; 00126 { 00127 return dngettext__ (domainname, msgid1, msgid2, n); 00128 } 00129 00130 00131 char * 00132 dcngettext (domainname, msgid1, msgid2, n, category) 00133 const char *domainname; 00134 const char *msgid1; 00135 const char *msgid2; 00136 unsigned long int n; 00137 int category; 00138 { 00139 return dcngettext__ (domainname, msgid1, msgid2, n, category); 00140 } 00141 00142 00143 char * 00144 textdomain (domainname) 00145 const char *domainname; 00146 { 00147 return textdomain__ (domainname); 00148 } 00149 00150 00151 char * 00152 bindtextdomain (domainname, dirname) 00153 const char *domainname; 00154 const char *dirname; 00155 { 00156 return bindtextdomain__ (domainname, dirname); 00157 } 00158 00159 00160 char * 00161 bind_textdomain_codeset (domainname, codeset) 00162 const char *domainname; 00163 const char *codeset; 00164 { 00165 return bind_textdomain_codeset__ (domainname, codeset); 00166 }