OSDN Git Service

Update license
[uclinux-h8/uClibc.git] / libintl / intl.c
1 /* Copyright (C) 2003     Manuel Novoa III
2  * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
3  *
4  * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
5  */
6
7 /*
8  *  Stub version of libintl.
9  *
10  *  Aug 30, 2003
11  *  Add some hidden names to support locale-enabled libstd++.
12  */
13
14 #include <stdlib.h>
15 #include <string.h>
16 #include <errno.h>
17
18 #undef __OPTIMIZE__
19 #include <libintl.h>
20
21 /**********************************************************************/
22 #ifdef L_gettext
23
24 char *gettext(const char *msgid)
25 {
26         return (char *) msgid;
27 }
28
29 #endif
30 /**********************************************************************/
31 #ifdef L_dgettext
32
33 char *__dgettext(const char *domainname,
34                                  const char *msgid)
35 {
36         return (char *) msgid;
37 }
38
39 strong_alias(__dgettext, dgettext)
40
41 #endif
42 /**********************************************************************/
43 #ifdef L_dcgettext
44
45 char *__dcgettext(const char *domainname,
46                                   const char *msgid, int category)
47 {
48         return (char *) msgid;
49 }
50
51 strong_alias(__dcgettext, dcgettext)
52
53 #endif
54 /**********************************************************************/
55 #ifdef L_ngettext
56
57 char *ngettext(const char *msgid1, const char *msgid2,
58                            unsigned long int n)
59 {
60         return (char *) ((n == 1) ? msgid1 : msgid2);
61 }
62
63 #endif
64 /**********************************************************************/
65 #ifdef L_dngettext
66
67 char *dngettext(const char *domainname, const char *msgid1,
68                                 const char *msgid2, unsigned long int n)
69 {
70         return (char *) ((n == 1) ? msgid1 : msgid2);
71 }
72
73 #endif
74 /**********************************************************************/
75 #ifdef L_dcngettext
76
77 char *dcngettext(const char *domainname, const char *msgid1,
78                                  const char *msgid2, unsigned long int n,
79                                  int category)
80 {
81         return (char *) ((n == 1) ? msgid1 : msgid2);
82 }
83
84 #endif
85 /**********************************************************************/
86 #ifdef L_textdomain
87
88 char *__textdomain(const char *domainname)
89 {
90         static const char default_str[] = "messages";
91
92         if (domainname && *domainname && strcmp(domainname, default_str)) {
93                 __set_errno(EINVAL);
94                 return NULL;
95         }
96         return (char *) default_str;
97 }
98
99 strong_alias(__textdomain, textdomain)
100
101 #endif
102 /**********************************************************************/
103 #ifdef L_bindtextdomain
104
105 char *__bindtextdomain(const char *domainname, const char *dirname)
106 {
107         static const char dir[] = "/";
108
109         if (!domainname || !*domainname
110                 || (dirname
111 #if 1
112                         && ((dirname[0] != '/') || dirname[1])
113 #else
114                         && strcmp(dirname, dir)
115 #endif
116                         )
117                 ) {
118                 __set_errno(EINVAL);
119                 return NULL;
120         }
121
122         return (char *) dir;
123 }
124
125 strong_alias(__bindtextdomain, bindtextdomain)
126
127 #endif
128 /**********************************************************************/
129 #ifdef L_bind_textdomain_codeset
130
131 /* Specify the character encoding in which the messages from the
132    DOMAINNAME message catalog will be returned.  */
133 char *bind_textdomain_codeset(const char *domainname,
134                                                                                         const char *codeset)
135 {
136         if (!domainname || !*domainname || codeset) {
137                 __set_errno(EINVAL);
138         }
139         return NULL;
140 }
141
142 #endif
143 /**********************************************************************/
144 #ifdef L__nl_expand_alias
145
146 /* glibc-ism */
147
148 const char *_nl_expand_alias(const char * name)
149 {
150         return NULL;             /* uClibc does not support locale aliases. */
151 }
152
153 #endif
154 /**********************************************************************/
155 #ifdef L__nl_msg_cat_cntr
156
157 /* glibc-ism */
158
159 int _nl_msg_cat_cntr = 0;
160
161 #endif
162 /**********************************************************************/