| 1 | /* Message catalogs for internationalization. |
|---|
| 2 | Copyright (C) 1995-1997, 2000-2007 Free Software Foundation, Inc. |
|---|
| 3 | |
|---|
| 4 | This program is free software; you can redistribute it and/or modify it |
|---|
| 5 | under the terms of the GNU Library General Public License as published |
|---|
| 6 | by the Free Software Foundation; either version 2, or (at your option) |
|---|
| 7 | 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 GNU |
|---|
| 12 | Library General Public License for more details. |
|---|
| 13 | |
|---|
| 14 | You should have received a copy of the GNU Library General Public |
|---|
| 15 | License along with this program; if not, write to the Free Software |
|---|
| 16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, |
|---|
| 17 | USA. */ |
|---|
| 18 | |
|---|
| 19 | #ifndef _LIBINTL_H |
|---|
| 20 | #define _LIBINTL_H 1 |
|---|
| 21 | |
|---|
| 22 | #include <locale.h> |
|---|
| 23 | |
|---|
| 24 | /* The LC_MESSAGES locale category is the category used by the functions |
|---|
| 25 | gettext() and dgettext(). It is specified in POSIX, but not in ANSI C. |
|---|
| 26 | On systems that don't define it, use an arbitrary value instead. |
|---|
| 27 | On Solaris, <locale.h> defines __LOCALE_H (or _LOCALE_H in Solaris 2.5) |
|---|
| 28 | then includes <libintl.h> (i.e. this file!) and then only defines |
|---|
| 29 | LC_MESSAGES. To avoid a redefinition warning, don't define LC_MESSAGES |
|---|
| 30 | in this case. */ |
|---|
| 31 | #if !defined LC_MESSAGES && !(defined __LOCALE_H || (defined _LOCALE_H && defined __sun)) |
|---|
| 32 | # define LC_MESSAGES 1729 |
|---|
| 33 | #endif |
|---|
| 34 | |
|---|
| 35 | /* We define an additional symbol to signal that we use the GNU |
|---|
| 36 | implementation of gettext. */ |
|---|
| 37 | #define __USE_GNU_GETTEXT 1 |
|---|
| 38 | |
|---|
| 39 | /* Provide information about the supported file formats. Returns the |
|---|
| 40 | maximum minor revision number supported for a given major revision. */ |
|---|
| 41 | #define __GNU_GETTEXT_SUPPORTED_REVISION(major) \ |
|---|
| 42 | ((major) == 0 || (major) == 1 ? 1 : -1) |
|---|
| 43 | |
|---|
| 44 | /* Resolve a platform specific conflict on DJGPP. GNU gettext takes |
|---|
| 45 | precedence over _conio_gettext. */ |
|---|
| 46 | #ifdef __DJGPP__ |
|---|
| 47 | # undef gettext |
|---|
| 48 | #endif |
|---|
| 49 | |
|---|
| 50 | #ifdef __cplusplus |
|---|
| 51 | extern "C" { |
|---|
| 52 | #endif |
|---|
| 53 | |
|---|
| 54 | |
|---|
| 55 | /* Version number: (major<<16) + (minor<<8) + subminor */ |
|---|
| 56 | #define LIBINTL_VERSION 0x001100 |
|---|
| 57 | extern int libintl_version; |
|---|
| 58 | |
|---|
| 59 | |
|---|
| 60 | /* We redirect the functions to those prefixed with "libintl_". This is |
|---|
| 61 | necessary, because some systems define gettext/textdomain/... in the C |
|---|
| 62 | library (namely, Solaris 2.4 and newer, and GNU libc 2.0 and newer). |
|---|
| 63 | If we used the unprefixed names, there would be cases where the |
|---|
| 64 | definition in the C library would override the one in the libintl.so |
|---|
| 65 | shared library. Recall that on ELF systems, the symbols are looked |
|---|
| 66 | up in the following order: |
|---|
| 67 | 1. in the executable, |
|---|
| 68 | 2. in the shared libraries specified on the link command line, in order, |
|---|
| 69 | 3. in the dependencies of the shared libraries specified on the link |
|---|
| 70 | command line, |
|---|
| 71 | 4. in the dlopen()ed shared libraries, in the order in which they were |
|---|
| 72 | dlopen()ed. |
|---|
| 73 | The definition in the C library would override the one in libintl.so if |
|---|
| 74 | either |
|---|
| 75 | * -lc is given on the link command line and -lintl isn't, or |
|---|
| 76 | * -lc is given on the link command line before -lintl, or |
|---|
| 77 | * libintl.so is a dependency of a dlopen()ed shared library but not |
|---|
| 78 | linked to the executable at link time. |
|---|
| 79 | Since Solaris gettext() behaves differently than GNU gettext(), this |
|---|
| 80 | would be unacceptable. |
|---|
| 81 | |
|---|
| 82 | The redirection happens by default through macros in C, so that &gettext |
|---|
| 83 | is independent of the compilation unit, but through inline functions in |
|---|
| 84 | C++, in order not to interfere with the name mangling of class fields or |
|---|
| 85 | class methods called 'gettext'. */ |
|---|
| 86 | |
|---|
| 87 | /* The user can define _INTL_REDIRECT_INLINE or _INTL_REDIRECT_MACROS. |
|---|
| 88 | If he doesn't, we choose the method. A third possible method is |
|---|
| 89 | _INTL_REDIRECT_ASM, supported only by GCC. */ |
|---|
| 90 | #if !(defined _INTL_REDIRECT_INLINE || defined _INTL_REDIRECT_MACROS) |
|---|
| 91 | # if __GNUC__ >= 2 && !(__APPLE_CC__ > 1) && !defined __MINGW32__ && !(__GNUC__ == 2 && defined _AIX) && (defined __STDC__ || defined __cplusplus) |
|---|
| 92 | # define _INTL_REDIRECT_ASM |
|---|
| 93 | # else |
|---|
| 94 | # ifdef __cplusplus |
|---|
| 95 | # define _INTL_REDIRECT_INLINE |
|---|
| 96 | # else |
|---|
| 97 | # define _INTL_REDIRECT_MACROS |
|---|
| 98 | # endif |
|---|
| 99 | # endif |
|---|
| 100 | #endif |
|---|
| 101 | /* Auxiliary macros. */ |
|---|
| 102 | #ifdef _INTL_REDIRECT_ASM |
|---|
| 103 | # define _INTL_ASM(cname) __asm__ (_INTL_ASMNAME (__USER_LABEL_PREFIX__, #cname)) |
|---|
| 104 | # define _INTL_ASMNAME(prefix,cnamestring) _INTL_STRINGIFY (prefix) cnamestring |
|---|
| 105 | # define _INTL_STRINGIFY(prefix) #prefix |
|---|
| 106 | #else |
|---|
| 107 | # define _INTL_ASM(cname) |
|---|
| 108 | #endif |
|---|
| 109 | |
|---|
| 110 | /* _INTL_MAY_RETURN_STRING_ARG(n) declares that the given function may return |
|---|
| 111 | its n-th argument literally. This enables GCC to warn for example about |
|---|
| 112 | printf (gettext ("foo %y")). */ |
|---|
| 113 | #if __GNUC__ >= 3 && !(__APPLE_CC__ > 1 && defined __cplusplus) |
|---|
| 114 | # define _INTL_MAY_RETURN_STRING_ARG(n) __attribute__ ((__format_arg__ (n))) |
|---|
| 115 | #else |
|---|
| 116 | # define _INTL_MAY_RETURN_STRING_ARG(n) |
|---|
| 117 | #endif |
|---|
| 118 | |
|---|
| 119 | /* Look up MSGID in the current default message catalog for the current |
|---|
| 120 | LC_MESSAGES locale. If not found, returns MSGID itself (the default |
|---|
| 121 | text). */ |
|---|
| 122 | #ifdef _INTL_REDIRECT_INLINE |
|---|
| 123 | extern char *libintl_gettext (const char *__msgid) |
|---|
| 124 | _INTL_MAY_RETURN_STRING_ARG (1); |
|---|
| 125 | static inline char *gettext (const char *__msgid) |
|---|
| 126 | { |
|---|
| 127 | return libintl_gettext (__msgid); |
|---|
| 128 | } |
|---|
| 129 | #else |
|---|
| 130 | #ifdef _INTL_REDIRECT_MACROS |
|---|
| 131 | # define gettext libintl_gettext |
|---|
| 132 | #endif |
|---|
| 133 | extern char *gettext (const char *__msgid) |
|---|
| 134 | _INTL_ASM (libintl_gettext) |
|---|
| 135 | _INTL_MAY_RETURN_STRING_ARG (1); |
|---|
| 136 | #endif |
|---|
| 137 | |
|---|
| 138 | /* Look up MSGID in the DOMAINNAME message catalog for the current |
|---|
| 139 | LC_MESSAGES locale. */ |
|---|
| 140 | #ifdef _INTL_REDIRECT_INLINE |
|---|
| 141 | extern char *libintl_dgettext (const char *__domainname, const char *__msgid) |
|---|
| 142 | _INTL_MAY_RETURN_STRING_ARG (2); |
|---|
| 143 | static inline char *dgettext (const char *__domainname, const char *__msgid) |
|---|
| 144 | { |
|---|
| 145 | return libintl_dgettext (__domainname, __msgid); |
|---|
| 146 | } |
|---|
| 147 | #else |
|---|
| 148 | #ifdef _INTL_REDIRECT_MACROS |
|---|
| 149 | # define dgettext libintl_dgettext |
|---|
| 150 | #endif |
|---|
| 151 | extern char *dgettext (const char *__domainname, const char *__msgid) |
|---|
| 152 | _INTL_ASM (libintl_dgettext) |
|---|
| 153 | _INTL_MAY_RETURN_STRING_ARG (2); |
|---|
| 154 | #endif |
|---|
| 155 | |
|---|
| 156 | /* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY |
|---|
| 157 | locale. */ |
|---|
| 158 | #ifdef _INTL_REDIRECT_INLINE |
|---|
| 159 | extern char *libintl_dcgettext (const char *__domainname, const char *__msgid, |
|---|
| 160 | int __category) |
|---|
| 161 | _INTL_MAY_RETURN_STRING_ARG (2); |
|---|
| 162 | static inline char *dcgettext (const char *__domainname, const char *__msgid, |
|---|
| 163 | int __category) |
|---|
| 164 | { |
|---|
| 165 | return libintl_dcgettext (__domainname, __msgid, __category); |
|---|
| 166 | } |
|---|
| 167 | #else |
|---|
| 168 | #ifdef _INTL_REDIRECT_MACROS |
|---|
| 169 | # define dcgettext libintl_dcgettext |
|---|
| 170 | #endif |
|---|
| 171 | extern char *dcgettext (const char *__domainname, const char *__msgid, |
|---|
| 172 | int __category) |
|---|
| 173 | _INTL_ASM (libintl_dcgettext) |
|---|
| 174 | _INTL_MAY_RETURN_STRING_ARG (2); |
|---|
| 175 | #endif |
|---|
| 176 | |
|---|
| 177 | |
|---|
| 178 | /* Similar to `gettext' but select the plural form corresponding to the |
|---|
| 179 | number N. */ |
|---|
| 180 | #ifdef _INTL_REDIRECT_INLINE |
|---|
| 181 | extern char *libintl_ngettext (const char *__msgid1, const char *__msgid2, |
|---|
| 182 | unsigned long int __n) |
|---|
| 183 | _INTL_MAY_RETURN_STRING_ARG (1) _INTL_MAY_RETURN_STRING_ARG (2); |
|---|
| 184 | static inline char *ngettext (const char *__msgid1, const char *__msgid2, |
|---|
| 185 | unsigned long int __n) |
|---|
| 186 | { |
|---|
| 187 | return libintl_ngettext (__msgid1, __msgid2, __n); |
|---|
| 188 | } |
|---|
| 189 | #else |
|---|
| 190 | #ifdef _INTL_REDIRECT_MACROS |
|---|
| 191 | # define ngettext libintl_ngettext |
|---|
| 192 | #endif |
|---|
| 193 | extern char *ngettext (const char *__msgid1, const char *__msgid2, |
|---|
| 194 | unsigned long int __n) |
|---|
| 195 | _INTL_ASM (libintl_ngettext) |
|---|
| 196 | _INTL_MAY_RETURN_STRING_ARG (1) _INTL_MAY_RETURN_STRING_ARG (2); |
|---|
| 197 | #endif |
|---|
| 198 | |
|---|
| 199 | /* Similar to `dgettext' but select the plural form corresponding to the |
|---|
| 200 | number N. */ |
|---|
| 201 | #ifdef _INTL_REDIRECT_INLINE |
|---|
| 202 | extern char *libintl_dngettext (const char *__domainname, const char *__msgid1, |
|---|
| 203 | const char *__msgid2, unsigned long int __n) |
|---|
| 204 | _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3); |
|---|
| 205 | static inline char *dngettext (const char *__domainname, const char *__msgid1, |
|---|
| 206 | const char *__msgid2, unsigned long int __n) |
|---|
| 207 | { |
|---|
| 208 | return libintl_dngettext (__domainname, __msgid1, __msgid2, __n); |
|---|
| 209 | } |
|---|
| 210 | #else |
|---|
| 211 | #ifdef _INTL_REDIRECT_MACROS |
|---|
| 212 | # define dngettext libintl_dngettext |
|---|
| 213 | #endif |
|---|
| 214 | extern char *dngettext (const char *__domainname, |
|---|
| 215 | const char *__msgid1, const char *__msgid2, |
|---|
| 216 | unsigned long int __n) |
|---|
| 217 | _INTL_ASM (libintl_dngettext) |
|---|
| 218 | _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3); |
|---|
| 219 | #endif |
|---|
| 220 | |
|---|
| 221 | /* Similar to `dcgettext' but select the plural form corresponding to the |
|---|
| 222 | number N. */ |
|---|
| 223 | #ifdef _INTL_REDIRECT_INLINE |
|---|
| 224 | extern char *libintl_dcngettext (const char *__domainname, |
|---|
| 225 | const char *__msgid1, const char *__msgid2, |
|---|
| 226 | unsigned long int __n, int __category) |
|---|
| 227 | _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3); |
|---|
| 228 | static inline char *dcngettext (const char *__domainname, |
|---|
| 229 | const char *__msgid1, const char *__msgid2, |
|---|
| 230 | unsigned long int __n, int __category) |
|---|
| 231 | { |
|---|
| 232 | return libintl_dcngettext (__domainname, __msgid1, __msgid2, __n, __category); |
|---|
| 233 | } |
|---|
| 234 | #else |
|---|
| 235 | #ifdef _INTL_REDIRECT_MACROS |
|---|
| 236 | # define dcngettext libintl_dcngettext |
|---|
| 237 | #endif |
|---|
| 238 | extern char *dcngettext (const char *__domainname, |
|---|
| 239 | const char *__msgid1, const char *__msgid2, |
|---|
| 240 | unsigned long int __n, int __category) |
|---|
| 241 | _INTL_ASM (libintl_dcngettext) |
|---|
| 242 | _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3); |
|---|
| 243 | #endif |
|---|
| 244 | |
|---|
| 245 | |
|---|
| 246 | |
|---|
| 247 | /* Set the current default message catalog to DOMAINNAME. |
|---|
| 248 | If DOMAINNAME is null, return the current default. |
|---|
| 249 | If DOMAINNAME is "", reset to the default of "messages". */ |
|---|
| 250 | #ifdef _INTL_REDIRECT_INLINE |
|---|
| 251 | extern char *libintl_textdomain (const char *__domainname); |
|---|
| 252 | static inline char *textdomain (const char *__domainname) |
|---|
| 253 | { |
|---|
| 254 | return libintl_textdomain (__domainname); |
|---|
| 255 | } |
|---|
| 256 | #else |
|---|
| 257 | #ifdef _INTL_REDIRECT_MACROS |
|---|
| 258 | # define textdomain libintl_textdomain |
|---|
| 259 | #endif |
|---|
| 260 | extern char *textdomain (const char *__domainname) |
|---|
| 261 | _INTL_ASM (libintl_textdomain); |
|---|
| 262 | #endif |
|---|
| 263 | |
|---|
| 264 | /* Specify that the DOMAINNAME message catalog will be found |
|---|
| 265 | in DIRNAME rather than in the system locale data base. */ |
|---|
| 266 | #ifdef _INTL_REDIRECT_INLINE |
|---|
| 267 | extern char *libintl_bindtextdomain (const char *__domainname, |
|---|
| 268 | const char *__dirname); |
|---|
| 269 | static inline char *bindtextdomain (const char *__domainname, |
|---|
| 270 | const char *__dirname) |
|---|
| 271 | { |
|---|
| 272 | return libintl_bindtextdomain (__domainname, __dirname); |
|---|
| 273 | } |
|---|
| 274 | #else |
|---|
| 275 | #ifdef _INTL_REDIRECT_MACROS |
|---|
| 276 | # define bindtextdomain libintl_bindtextdomain |
|---|
| 277 | #endif |
|---|
| 278 | extern char *bindtextdomain (const char *__domainname, const char *__dirname) |
|---|
| 279 | _INTL_ASM (libintl_bindtextdomain); |
|---|
| 280 | #endif |
|---|
| 281 | |
|---|
| 282 | /* Specify the character encoding in which the messages from the |
|---|
| 283 | DOMAINNAME message catalog will be returned. */ |
|---|
| 284 | #ifdef _INTL_REDIRECT_INLINE |
|---|
| 285 | extern char *libintl_bind_textdomain_codeset (const char *__domainname, |
|---|
| 286 | const char *__codeset); |
|---|
| 287 | static inline char *bind_textdomain_codeset (const char *__domainname, |
|---|
| 288 | const char *__codeset) |
|---|
| 289 | { |
|---|
| 290 | return libintl_bind_textdomain_codeset (__domainname, __codeset); |
|---|
| 291 | } |
|---|
| 292 | #else |
|---|
| 293 | #ifdef _INTL_REDIRECT_MACROS |
|---|
| 294 | # define bind_textdomain_codeset libintl_bind_textdomain_codeset |
|---|
| 295 | #endif |
|---|
| 296 | extern char *bind_textdomain_codeset (const char *__domainname, |
|---|
| 297 | const char *__codeset) |
|---|
| 298 | _INTL_ASM (libintl_bind_textdomain_codeset); |
|---|
| 299 | #endif |
|---|
| 300 | |
|---|
| 301 | |
|---|
| 302 | |
|---|
| 303 | /* Support for format strings with positions in *printf(), following the |
|---|
| 304 | POSIX/XSI specification. |
|---|
| 305 | Note: These replacements for the *printf() functions are visible only |
|---|
| 306 | in source files that #include <libintl.h> or #include "gettext.h". |
|---|
| 307 | Packages that use *printf() in source files that don't refer to _() |
|---|
| 308 | or gettext() but for which the format string could be the return value |
|---|
| 309 | of _() or gettext() need to add this #include. Oh well. */ |
|---|
| 310 | |
|---|
| 311 | #if !0 |
|---|
| 312 | |
|---|
| 313 | #include <stdio.h> |
|---|
| 314 | #include <stddef.h> |
|---|
| 315 | |
|---|
| 316 | /* Get va_list. */ |
|---|
| 317 | #if __STDC__ || defined __cplusplus || defined _MSC_VER |
|---|
| 318 | # include <stdarg.h> |
|---|
| 319 | #else |
|---|
| 320 | # include <varargs.h> |
|---|
| 321 | #endif |
|---|
| 322 | |
|---|
| 323 | #undef fprintf |
|---|
| 324 | #define fprintf libintl_fprintf |
|---|
| 325 | extern int fprintf (FILE *, const char *, ...); |
|---|
| 326 | #undef vfprintf |
|---|
| 327 | #define vfprintf libintl_vfprintf |
|---|
| 328 | extern int vfprintf (FILE *, const char *, va_list); |
|---|
| 329 | |
|---|
| 330 | #undef printf |
|---|
| 331 | #if defined __NetBSD__ || defined __BEOS__ || defined __CYGWIN__ || defined __MINGW32__ |
|---|
| 332 | /* Don't break __attribute__((format(printf,M,N))). |
|---|
| 333 | This redefinition is only possible because the libc in NetBSD, Cygwin, |
|---|
| 334 | mingw does not have a function __printf__. */ |
|---|
| 335 | # define libintl_printf __printf__ |
|---|
| 336 | #endif |
|---|
| 337 | #define printf libintl_printf |
|---|
| 338 | extern int printf (const char *, ...); |
|---|
| 339 | #undef vprintf |
|---|
| 340 | #define vprintf libintl_vprintf |
|---|
| 341 | extern int vprintf (const char *, va_list); |
|---|
| 342 | |
|---|
| 343 | #undef sprintf |
|---|
| 344 | #define sprintf libintl_sprintf |
|---|
| 345 | extern int sprintf (char *, const char *, ...); |
|---|
| 346 | #undef vsprintf |
|---|
| 347 | #define vsprintf libintl_vsprintf |
|---|
| 348 | extern int vsprintf (char *, const char *, va_list); |
|---|
| 349 | |
|---|
| 350 | #if 1 |
|---|
| 351 | |
|---|
| 352 | #undef snprintf |
|---|
| 353 | #define snprintf libintl_snprintf |
|---|
| 354 | extern int snprintf (char *, size_t, const char *, ...); |
|---|
| 355 | #undef vsnprintf |
|---|
| 356 | #define vsnprintf libintl_vsnprintf |
|---|
| 357 | extern int vsnprintf (char *, size_t, const char *, va_list); |
|---|
| 358 | |
|---|
| 359 | #endif |
|---|
| 360 | |
|---|
| 361 | #if 0 |
|---|
| 362 | |
|---|
| 363 | #undef asprintf |
|---|
| 364 | #define asprintf libintl_asprintf |
|---|
| 365 | extern int asprintf (char **, const char *, ...); |
|---|
| 366 | #undef vasprintf |
|---|
| 367 | #define vasprintf libintl_vasprintf |
|---|
| 368 | extern int vasprintf (char **, const char *, va_list); |
|---|
| 369 | |
|---|
| 370 | #endif |
|---|
| 371 | |
|---|
| 372 | #if 0 |
|---|
| 373 | |
|---|
| 374 | #undef fwprintf |
|---|
| 375 | #define fwprintf libintl_fwprintf |
|---|
| 376 | extern int fwprintf (FILE *, const wchar_t *, ...); |
|---|
| 377 | #undef vfwprintf |
|---|
| 378 | #define vfwprintf libintl_vfwprintf |
|---|
| 379 | extern int vfwprintf (FILE *, const wchar_t *, va_list); |
|---|
| 380 | |
|---|
| 381 | #undef wprintf |
|---|
| 382 | #define wprintf libintl_wprintf |
|---|
| 383 | extern int wprintf (const wchar_t *, ...); |
|---|
| 384 | #undef vwprintf |
|---|
| 385 | #define vwprintf libintl_vwprintf |
|---|
| 386 | extern int vwprintf (const wchar_t *, va_list); |
|---|
| 387 | |
|---|
| 388 | #undef swprintf |
|---|
| 389 | #define swprintf libintl_swprintf |
|---|
| 390 | extern int swprintf (wchar_t *, size_t, const wchar_t *, ...); |
|---|
| 391 | #undef vswprintf |
|---|
| 392 | #define vswprintf libintl_vswprintf |
|---|
| 393 | extern int vswprintf (wchar_t *, size_t, const wchar_t *, va_list); |
|---|
| 394 | |
|---|
| 395 | #endif |
|---|
| 396 | |
|---|
| 397 | #endif |
|---|
| 398 | |
|---|
| 399 | |
|---|
| 400 | /* Support for relocatable packages. */ |
|---|
| 401 | |
|---|
| 402 | /* Sets the original and the current installation prefix of the package. |
|---|
| 403 | Relocation simply replaces a pathname starting with the original prefix |
|---|
| 404 | by the corresponding pathname with the current prefix instead. Both |
|---|
| 405 | prefixes should be directory names without trailing slash (i.e. use "" |
|---|
| 406 | instead of "/"). */ |
|---|
| 407 | #define libintl_set_relocation_prefix libintl_set_relocation_prefix |
|---|
| 408 | extern void |
|---|
| 409 | libintl_set_relocation_prefix (const char *orig_prefix, |
|---|
| 410 | const char *curr_prefix); |
|---|
| 411 | |
|---|
| 412 | /* wchar_t support */ |
|---|
| 413 | #ifdef _INTL_REDIRECT_INLINE |
|---|
| 414 | #define WCHAR_LIBINTL_STATIC_INLINE static inline |
|---|
| 415 | #elif defined(_MSC_VER) |
|---|
| 416 | #define WCHAR_LIBINTL_STATIC_INLINE static _inline |
|---|
| 417 | #else |
|---|
| 418 | #define WCHAR_LIBINTL_STATIC_INLINE static |
|---|
| 419 | #endif |
|---|
| 420 | |
|---|
| 421 | #define wgettext(msgid) wgettext_(msgid, L##msgid) |
|---|
| 422 | #define dwgettext(domainname, msgid) dwgettext_(domainname, msgid, L##msgid) |
|---|
| 423 | #define dcwgettext(domainname, msgid, category) dwgettext_(domainname, msgid, category, L##msgid) |
|---|
| 424 | #define nwgettext(msgid1, msgid2, n) nwgettext_(msgid1, msgid2, n, L##msgid1, L##msgid2) |
|---|
| 425 | #define dnwgettext(domainname, msgid1, msgid2, n) dnwgettext_(domainname, msgid1, msgid2, n, L##msgid1, L##msgid2) |
|---|
| 426 | #define dcnwgettext(domainname, msgid1, msgid2, n, category) dnwgettext_(domainname, msgid1, msgid2, n, L##msgid1, L##msgid2) |
|---|
| 427 | |
|---|
| 428 | WCHAR_LIBINTL_STATIC_INLINE |
|---|
| 429 | const wchar_t *wgettext_ (const char *msgid, const wchar_t *wmsgid) |
|---|
| 430 | { |
|---|
| 431 | const char *translated = gettext (msgid); |
|---|
| 432 | return translated != msgid ? (const wchar_t *)translated : wmsgid; |
|---|
| 433 | } |
|---|
| 434 | |
|---|
| 435 | WCHAR_LIBINTL_STATIC_INLINE |
|---|
| 436 | const wchar_t *dwgettext_ (const char *domainname, const char *msgid, const wchar_t *wmsgid) |
|---|
| 437 | { |
|---|
| 438 | const char *translated = dgettext (domainname, msgid); |
|---|
| 439 | return translated != msgid ? (const wchar_t *)translated : wmsgid; |
|---|
| 440 | } |
|---|
| 441 | |
|---|
| 442 | WCHAR_LIBINTL_STATIC_INLINE |
|---|
| 443 | const wchar_t *dcwgettext_ (const char *domainname, const char *msgid, int category, const wchar_t *wmsgid) |
|---|
| 444 | { |
|---|
| 445 | const char *translated = dcgettext (domainname, msgid, category); |
|---|
| 446 | return translated != msgid ? (const wchar_t *)translated : wmsgid; |
|---|
| 447 | } |
|---|
| 448 | |
|---|
| 449 | WCHAR_LIBINTL_STATIC_INLINE |
|---|
| 450 | const wchar_t *nwgettext_ (const char *msgid1, const char *msgid2, unsigned long n, const wchar_t *wmsgid1, const wchar_t *wmsgid2) |
|---|
| 451 | { |
|---|
| 452 | const char *translated = ngettext (msgid1, msgid2, n); |
|---|
| 453 | return translated == msgid1 ? wmsgid1 : (translated == msgid2 ? wmsgid2 : (const wchar_t *)translated); |
|---|
| 454 | } |
|---|
| 455 | |
|---|
| 456 | WCHAR_LIBINTL_STATIC_INLINE |
|---|
| 457 | const wchar_t *dnwgettext_ (const char *domainname, const char *msgid1, const char *msgid2, unsigned long n, const wchar_t *wmsgid1, const wchar_t *wmsgid2) |
|---|
| 458 | { |
|---|
| 459 | const char *translated = dngettext (domainname, msgid1, msgid2, n); |
|---|
| 460 | return translated == msgid1 ? wmsgid1 : (translated == msgid2 ? wmsgid2 : (const wchar_t *)translated); |
|---|
| 461 | } |
|---|
| 462 | |
|---|
| 463 | WCHAR_LIBINTL_STATIC_INLINE |
|---|
| 464 | const wchar_t *dcnwgettext_ (const char *domainname, const char *msgid1, const char *msgid2, unsigned long n, const wchar_t *wmsgid1, const wchar_t *wmsgid2, int category) |
|---|
| 465 | { |
|---|
| 466 | const char *translated = dcngettext (domainname, msgid1, msgid2, n, category); |
|---|
| 467 | return translated == msgid1 ? wmsgid1 : (translated == msgid2 ? wmsgid2 : (const wchar_t *)translated); |
|---|
| 468 | } |
|---|
| 469 | |
|---|
| 470 | #ifdef __cplusplus |
|---|
| 471 | } |
|---|
| 472 | #endif |
|---|
| 473 | |
|---|
| 474 | /* MS Windows Wide character support. */ |
|---|
| 475 | #if (defined(WIN32) || defined(_WIN32) || defined(_WIN64) || defined(_WIN32_WCE)) \ |
|---|
| 476 | && !defined(__CYGWIN__) && (defined(UNICODE) || defined(_UNICODE)) |
|---|
| 477 | |
|---|
| 478 | #include <windows.h> |
|---|
| 479 | |
|---|
| 480 | #ifdef __cplusplus |
|---|
| 481 | extern "C" |
|---|
| 482 | { |
|---|
| 483 | #endif |
|---|
| 484 | |
|---|
| 485 | #undef bindtextdomain |
|---|
| 486 | #define bindtextdomain windows_bindtextdomain |
|---|
| 487 | #define wbindtextdomain windows_wbindtextdomain |
|---|
| 488 | |
|---|
| 489 | /* http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx */ |
|---|
| 490 | #define WCHAR_LIBINTL_MAX_PATH 33000 |
|---|
| 491 | |
|---|
| 492 | WCHAR_LIBINTL_STATIC_INLINE |
|---|
| 493 | const wchar_t *windows_wbindtextdomain (const char *domainname, const wchar_t *dirname16) |
|---|
| 494 | { |
|---|
| 495 | char *dirname8 = NULL; |
|---|
| 496 | unsigned int num_elements = 0; |
|---|
| 497 | |
|---|
| 498 | |
|---|
| 499 | if (wcslen (dirname16) >= WCHAR_LIBINTL_MAX_PATH) |
|---|
| 500 | { |
|---|
| 501 | return NULL; |
|---|
| 502 | } |
|---|
| 503 | |
|---|
| 504 | num_elements = WideCharToMultiByte (CP_UTF8, 0, dirname16, -1, NULL, 0, 0, 0); |
|---|
| 505 | if (num_elements == 0) |
|---|
| 506 | { |
|---|
| 507 | return NULL; |
|---|
| 508 | } |
|---|
| 509 | |
|---|
| 510 | dirname8 = (char *)malloc (num_elements); |
|---|
| 511 | if (!dirname8) |
|---|
| 512 | { |
|---|
| 513 | return NULL; |
|---|
| 514 | } |
|---|
| 515 | |
|---|
| 516 | if (0 == WideCharToMultiByte (CP_UTF8, 0, dirname16, -1, dirname8, num_elements, 0, 0)) |
|---|
| 517 | { |
|---|
| 518 | free (dirname8); |
|---|
| 519 | return NULL; |
|---|
| 520 | } |
|---|
| 521 | |
|---|
| 522 | if (libintl_bindtextdomain (domainname, dirname8) == NULL) |
|---|
| 523 | { |
|---|
| 524 | free (dirname8); |
|---|
| 525 | return NULL; |
|---|
| 526 | } |
|---|
| 527 | |
|---|
| 528 | free (dirname8); |
|---|
| 529 | |
|---|
| 530 | return dirname16; |
|---|
| 531 | } |
|---|
| 532 | |
|---|
| 533 | WCHAR_LIBINTL_STATIC_INLINE |
|---|
| 534 | const char *windows_bindtextdomain(const char *domainname, const char *dirname) |
|---|
| 535 | { |
|---|
| 536 | wchar_t *dirname16 = NULL; |
|---|
| 537 | unsigned int num_elements = 0; |
|---|
| 538 | UINT acp = 0; |
|---|
| 539 | |
|---|
| 540 | acp = GetACP (); |
|---|
| 541 | |
|---|
| 542 | num_elements = MultiByteToWideChar (acp, 0, dirname, -1, NULL, 0); |
|---|
| 543 | if (num_elements == 0) |
|---|
| 544 | { |
|---|
| 545 | return NULL; |
|---|
| 546 | } |
|---|
| 547 | |
|---|
| 548 | if (num_elements >= WCHAR_LIBINTL_MAX_PATH) |
|---|
| 549 | { |
|---|
| 550 | return NULL; |
|---|
| 551 | } |
|---|
| 552 | |
|---|
| 553 | dirname16 = (wchar_t *)malloc (num_elements * sizeof(wchar_t)); |
|---|
| 554 | |
|---|
| 555 | if (0 == MultiByteToWideChar (acp, 0, dirname, -1, |
|---|
| 556 | dirname16, num_elements)) |
|---|
| 557 | { |
|---|
| 558 | free (dirname16); |
|---|
| 559 | return NULL; |
|---|
| 560 | } |
|---|
| 561 | |
|---|
| 562 | if (windows_wbindtextdomain (domainname, dirname16) == NULL) |
|---|
| 563 | { |
|---|
| 564 | free (dirname16); |
|---|
| 565 | return NULL; |
|---|
| 566 | } |
|---|
| 567 | |
|---|
| 568 | free (dirname16); |
|---|
| 569 | |
|---|
| 570 | return dirname; |
|---|
| 571 | } |
|---|
| 572 | |
|---|
| 573 | #ifdef __cplusplus |
|---|
| 574 | } |
|---|
| 575 | #endif |
|---|
| 576 | |
|---|
| 577 | #endif /* (defined(WIN32) || defined(_WIN32) || defined(_WIN64) || defined(_WIN32_WCE)) \ |
|---|
| 578 | && !defined(__CYGWIN__) && (defined(UNICODE) || defined(_UNICODE)) */ |
|---|
| 579 | |
|---|
| 580 | #undef WCHAR_LIBINTL_MAX_PATH |
|---|
| 581 | #undef WCHAR_LIBINTL_STATIC_INLINE |
|---|
| 582 | |
|---|
| 583 | #endif /* libintl.h */ |
|---|
| 584 | |
|---|
| 585 | |
|---|