| 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 | | } |
| 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 | | |