Remove building with NOCRYPTO option
[minix3.git] / lib / libintl / sysdep.c
blob48b9d814e08c587bb400c718153f6628971be8d2
1 /* $NetBSD: sysdep.c,v 1.2 2005/04/27 09:50:26 yamt Exp $ */
3 /*-
4 * Copyright (c)2004 Citrus Project,
5 * All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
29 #include <sys/cdefs.h>
30 #if defined(LIBC_SCCS) && !defined(lint)
31 __RCSID("$NetBSD: sysdep.c,v 1.2 2005/04/27 09:50:26 yamt Exp $");
32 #endif /* LIBC_SCCS and not lint */
34 #include <sys/param.h>
35 #include <sys/types.h>
37 #include <inttypes.h>
38 #include <stdlib.h>
39 #include <string.h>
41 #include "libintl_local.h"
43 struct sysdep_pair
45 const char *tag;
46 const char *string;
47 size_t len;
50 #define T_(tag) { #tag, tag, sizeof (tag)-1 }
51 #define numof(a) (sizeof (a) / sizeof ((a)[0]))
53 const struct sysdep_pair sysdep_pair_table[] = {
54 /* this table must be sorted in the dictionary order. */
55 T_(PRIX16),
56 T_(PRIX32),
57 T_(PRIX64),
58 T_(PRIX8),
59 T_(PRIXFAST16),
60 T_(PRIXFAST32),
61 T_(PRIXFAST64),
62 T_(PRIXFAST8),
63 T_(PRIXLEAST16),
64 T_(PRIXLEAST32),
65 T_(PRIXLEAST64),
66 T_(PRIXLEAST8),
67 T_(PRIXMAX),
68 T_(PRIXPTR),
69 T_(PRId16),
70 T_(PRId32),
71 T_(PRId64),
72 T_(PRId8),
73 T_(PRIdFAST16),
74 T_(PRIdFAST32),
75 T_(PRIdFAST64),
76 T_(PRIdFAST8),
77 T_(PRIdLEAST16),
78 T_(PRIdLEAST32),
79 T_(PRIdLEAST64),
80 T_(PRIdLEAST8),
81 T_(PRIdMAX),
82 T_(PRIdPTR),
83 T_(PRIi16),
84 T_(PRIi32),
85 T_(PRIi64),
86 T_(PRIi8),
87 T_(PRIiFAST16),
88 T_(PRIiFAST32),
89 T_(PRIiFAST64),
90 T_(PRIiFAST8),
91 T_(PRIiLEAST16),
92 T_(PRIiLEAST32),
93 T_(PRIiLEAST64),
94 T_(PRIiLEAST8),
95 T_(PRIiMAX),
96 T_(PRIiPTR),
97 T_(PRIo16),
98 T_(PRIo32),
99 T_(PRIo64),
100 T_(PRIo8),
101 T_(PRIoFAST16),
102 T_(PRIoFAST32),
103 T_(PRIoFAST64),
104 T_(PRIoFAST8),
105 T_(PRIoLEAST16),
106 T_(PRIoLEAST32),
107 T_(PRIoLEAST64),
108 T_(PRIoLEAST8),
109 T_(PRIoMAX),
110 T_(PRIoPTR),
111 T_(PRIu16),
112 T_(PRIu32),
113 T_(PRIu64),
114 T_(PRIu8),
115 T_(PRIuFAST16),
116 T_(PRIuFAST32),
117 T_(PRIuFAST64),
118 T_(PRIuFAST8),
119 T_(PRIuLEAST16),
120 T_(PRIuLEAST32),
121 T_(PRIuLEAST64),
122 T_(PRIuLEAST8),
123 T_(PRIuMAX),
124 T_(PRIuPTR),
125 T_(PRIx16),
126 T_(PRIx32),
127 T_(PRIx64),
128 T_(PRIx8),
129 T_(PRIxFAST16),
130 T_(PRIxFAST32),
131 T_(PRIxFAST64),
132 T_(PRIxFAST8),
133 T_(PRIxLEAST16),
134 T_(PRIxLEAST32),
135 T_(PRIxLEAST64),
136 T_(PRIxLEAST8),
137 T_(PRIxMAX),
138 T_(PRIxPTR),
139 T_(SCNd16),
140 T_(SCNd32),
141 T_(SCNd64),
142 T_(SCNd8),
143 T_(SCNdFAST16),
144 T_(SCNdFAST32),
145 T_(SCNdFAST64),
146 T_(SCNdFAST8),
147 T_(SCNdLEAST16),
148 T_(SCNdLEAST32),
149 T_(SCNdLEAST64),
150 T_(SCNdLEAST8),
151 T_(SCNdMAX),
152 T_(SCNdPTR),
153 T_(SCNi16),
154 T_(SCNi32),
155 T_(SCNi64),
156 T_(SCNi8),
157 T_(SCNiFAST16),
158 T_(SCNiFAST32),
159 T_(SCNiFAST64),
160 T_(SCNiFAST8),
161 T_(SCNiLEAST16),
162 T_(SCNiLEAST32),
163 T_(SCNiLEAST64),
164 T_(SCNiLEAST8),
165 T_(SCNiMAX),
166 T_(SCNiPTR),
167 T_(SCNo16),
168 T_(SCNo32),
169 T_(SCNo64),
170 T_(SCNo8),
171 T_(SCNoFAST16),
172 T_(SCNoFAST32),
173 T_(SCNoFAST64),
174 T_(SCNoFAST8),
175 T_(SCNoLEAST16),
176 T_(SCNoLEAST32),
177 T_(SCNoLEAST64),
178 T_(SCNoLEAST8),
179 T_(SCNoMAX),
180 T_(SCNoPTR),
181 T_(SCNu16),
182 T_(SCNu32),
183 T_(SCNu64),
184 T_(SCNu8),
185 T_(SCNuFAST16),
186 T_(SCNuFAST32),
187 T_(SCNuFAST64),
188 T_(SCNuFAST8),
189 T_(SCNuLEAST16),
190 T_(SCNuLEAST32),
191 T_(SCNuLEAST64),
192 T_(SCNuLEAST8),
193 T_(SCNuMAX),
194 T_(SCNuPTR),
195 T_(SCNx16),
196 T_(SCNx32),
197 T_(SCNx64),
198 T_(SCNx8),
199 T_(SCNxFAST16),
200 T_(SCNxFAST32),
201 T_(SCNxFAST64),
202 T_(SCNxFAST8),
203 T_(SCNxLEAST16),
204 T_(SCNxLEAST32),
205 T_(SCNxLEAST64),
206 T_(SCNxLEAST8),
207 T_(SCNxMAX),
208 T_(SCNxPTR)
211 static int
212 cmp_sysdep_tag(const void *tag, const void *elem)
214 const struct sysdep_pair *pair = elem;
216 return strcmp(tag, pair->tag);
219 const char *
220 __intl_sysdep_get_string_by_tag(const char *tag, size_t *rlen)
222 const struct sysdep_pair *found;
224 found = bsearch(tag, sysdep_pair_table, numof(sysdep_pair_table),
225 sizeof(sysdep_pair_table[0]), &cmp_sysdep_tag);
227 if (found) {
228 if (rlen)
229 *rlen = found->len;
230 return found->string;
233 if (rlen)
234 *rlen = 0;
235 return "";