1 /* Redirections from public function names to GNU libintl functions.
2 Copyright (C) 1995, 2000-2003, 2005, 2023 Free Software Foundation, Inc.
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published by
6 the Free Software Foundation; either version 2.1 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17 #ifdef HAVE_CONFIG_H
18 # include <config.h>
19 #endif
20
21 #include "gettextP.h"
22
23 /* @@ end of prolog @@ */
24
25
26 /* This file redirects the gettext functions (without prefix) to those
27 defined in the included GNU libintl library (with "libintl_" prefix).
28 It is compiled into libintl for three purposes:
29 * Packages that bind libintl into other programming languages
30 (Python, Perl, PHP, OCaml, Free Pascal Compiler, mailfromd's mail
31 filtering language, and many others) bind to the symbols without
32 prefix and at the linker level, i.e. without '#include <libintl.h>'.
33 Only few packages bind to the symbols with "libintl_" prefix.
34 * On glibc systems, we want that existing and future features of
35 GNU gettext (such as the logging to $GETTEXT_LOG_UNTRANSLATED)
36 become available when the program is linked against -lintl or
37 when libintl.so is used LD_PRELOADable library.
38 * In order to make the AM_GNU_GETTEXT test of gettext <= 0.11.2 work
39 with the libintl library >= 0.11.3 which has the redirections
40 primarily in the <libintl.h> include file.
41 */
42
43 #undef gettext
44 #undef dgettext
45 #undef dcgettext
46 #undef ngettext
47 #undef dngettext
48 #undef dcngettext
49 #undef textdomain
50 #undef bindtextdomain
51 #undef bind_textdomain_codeset
52
53
54 /* When building a DLL, we must export some functions. Note that because
55 the functions are only defined for binary backward compatibility, we
56 don't need to use __declspec(dllimport) in any case. */
57 #if HAVE_VISIBILITY && BUILDING_DLL
58 # define DLL_EXPORTED __attribute__((__visibility__("default")))
59 #elif defined _MSC_VER && BUILDING_DLL
60 /* When building with MSVC, exporting a symbol means that the object file
61 contains a "linker directive" of the form /EXPORT:symbol. This can be
62 inspected through the "objdump -s --section=.drectve FILE" or
63 "dumpbin /directives FILE" commands.
64 The symbols from this file should be exported if and only if the object
65 file gets included in a DLL. Libtool, on Windows platforms, defines
66 the C macro DLL_EXPORT (together with PIC) when compiling for a DLL
67 and does not define it when compiling an object file meant to be linked
68 statically into some executable. */
69 # if defined DLL_EXPORT
70 # define DLL_EXPORTED __declspec(dllexport)
71 # else
72 # define DLL_EXPORTED
73 # endif
74 #else
75 # define DLL_EXPORTED
76 #endif
77
78
79 DLL_EXPORTED
80 char *
81 gettext (const char *msgid)
82 {
83 return libintl_gettext (msgid);
84 }
85
86
87 DLL_EXPORTED
88 char *
89 dgettext (const char *domainname, const char *msgid)
90 {
91 return libintl_dgettext (domainname, msgid);
92 }
93
94
95 DLL_EXPORTED
96 char *
97 dcgettext (const char *domainname, const char *msgid, int category)
98 {
99 return libintl_dcgettext (domainname, msgid, category);
100 }
101
102
103 DLL_EXPORTED
104 char *
105 ngettext (const char *msgid1, const char *msgid2, unsigned long int n)
106 {
107 return libintl_ngettext (msgid1, msgid2, n);
108 }
109
110
111 DLL_EXPORTED
112 char *
113 dngettext (const char *domainname,
114 const char *msgid1, const char *msgid2, unsigned long int n)
115 {
116 return libintl_dngettext (domainname, msgid1, msgid2, n);
117 }
118
119
120 DLL_EXPORTED
121 char *
122 dcngettext (const char *domainname,
123 const char *msgid1, const char *msgid2, unsigned long int n,
124 int category)
125 {
126 return libintl_dcngettext (domainname, msgid1, msgid2, n, category);
127 }
128
129
130 DLL_EXPORTED
131 char *
132 textdomain (const char *domainname)
133 {
134 return libintl_textdomain (domainname);
135 }
136
137
138 DLL_EXPORTED
139 char *
140 bindtextdomain (const char *domainname, const char *dirname)
141 {
142 return libintl_bindtextdomain (domainname, dirname);
143 }
144
145
146 DLL_EXPORTED
147 char *
148 bind_textdomain_codeset (const char *domainname, const char *codeset)
149 {
150 return libintl_bind_textdomain_codeset (domainname, codeset);
151 }