intl.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /* Copyright (C) 2003 Manuel Novoa III
  2. *
  3. * This library is free software; you can redistribute it and/or
  4. * modify it under the terms of the GNU Library General Public
  5. * License as published by the Free Software Foundation; either
  6. * version 2 of the License, or (at your option) any later version.
  7. *
  8. * This library 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 GNU
  11. * Library General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU Library General Public
  14. * License along with this library; if not, write to the Free
  15. * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. */
  17. /*
  18. * Supply some weaks for gettext and friends. Used by strerror*().
  19. */
  20. #include <stdlib.h>
  21. #include <string.h>
  22. #include <errno.h>
  23. #undef __OPTIMIZE__
  24. #include <libintl.h>
  25. /**********************************************************************/
  26. #ifdef L_gettext
  27. char *weak_function gettext(const char *msgid)
  28. {
  29. return (char *) msgid;
  30. }
  31. #endif
  32. /**********************************************************************/
  33. #ifdef L_dgettext
  34. char *__uClibc_dgettext(const char *domainname,
  35. const char *msgid)
  36. {
  37. return (char *) msgid;
  38. }
  39. weak_alias (__uClibc_dgettext, __dgettext)
  40. weak_alias (__uClibc_dgettext, dgettext)
  41. #endif
  42. /**********************************************************************/
  43. #ifdef L_dcgettext
  44. char * __uClibc_dcgettext(const char *domainname,
  45. const char *msgid, int category)
  46. {
  47. return (char *) msgid;
  48. }
  49. weak_alias (__uClibc_dcgettext, __dcgettext)
  50. weak_alias (__uClibc_dcgettext, dcgettext)
  51. #endif
  52. /**********************************************************************/
  53. #ifdef L_ngettext
  54. char *weak_function ngettext(const char *msgid1, const char *msgid2,
  55. unsigned long int n)
  56. {
  57. return (char *) ((n == 1) ? msgid1 : msgid2);
  58. }
  59. #endif
  60. /**********************************************************************/
  61. #ifdef L_dngettext
  62. char *weak_function dngettext(const char *domainname, const char *msgid1,
  63. const char *msgid2, unsigned long int n)
  64. {
  65. return (char *) ((n == 1) ? msgid1 : msgid2);
  66. }
  67. #endif
  68. /**********************************************************************/
  69. #ifdef L_dcngettext
  70. char *weak_function dcngettext(const char *domainname, const char *msgid1,
  71. const char *msgid2, unsigned long int n,
  72. int category)
  73. {
  74. return (char *) ((n == 1) ? msgid1 : msgid2);
  75. }
  76. #endif
  77. /**********************************************************************/
  78. #ifdef L_textdomain
  79. char *weak_function textdomain(const char *domainname)
  80. {
  81. static const char default_str[] = "messages";
  82. if (domainname && *domainname && strcmp(domainname, default_str)) {
  83. __set_errno(EINVAL);
  84. return NULL;
  85. }
  86. return (char *) default_str;
  87. }
  88. #endif
  89. /**********************************************************************/
  90. #ifdef L_bindtextdomain
  91. char *weak_function bindtextdomain(const char *domainname, const char *dirname)
  92. {
  93. static const char dir[] = "/";
  94. if (!domainname || !*domainname
  95. || (dirname
  96. #if 1
  97. && ((dirname[0] != '/') || dirname[1])
  98. #else
  99. && strcmp(dirname, dir)
  100. #endif
  101. )
  102. ) {
  103. __set_errno(EINVAL);
  104. return NULL;
  105. }
  106. return (char *) dir;
  107. }
  108. #endif
  109. /**********************************************************************/
  110. #ifdef L_bind_textdomain_codeset
  111. /* Specify the character encoding in which the messages from the
  112. DOMAINNAME message catalog will be returned. */
  113. char *weak_function bind_textdomain_codeset(const char *domainname,
  114. const char *codeset)
  115. {
  116. if (!domainname || !*domainname || codeset) {
  117. __set_errno(EINVAL);
  118. }
  119. return NULL;
  120. }
  121. #endif
  122. /**********************************************************************/