Print this page
7127 remove -Wno-missing-braces from Makefile.uts
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/kiconv/kiconv_emea/kiconv_emea.c
+++ new/usr/src/uts/common/kiconv/kiconv_emea/kiconv_emea.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
↓ open down ↓ |
15 lines elided |
↑ open up ↑ |
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 */
25 25
26 -#pragma ident "%Z%%M% %I% %E% SMI"
27 -
28 26 /*
29 27 * Kernel iconv code conversion module (kiconv_emea) for Europe, Middle East,
30 28 * and South East Asia (PSARC/2007/173).
31 29 */
32 30
33 31 #include <sys/types.h>
34 32 #include <sys/param.h>
35 33 #include <sys/sysmacros.h>
36 34 #include <sys/systm.h>
37 35 #include <sys/debug.h>
38 36 #include <sys/kmem.h>
39 37 #include <sys/cmn_err.h>
40 38 #include <sys/ddi.h>
41 39 #include <sys/sunddi.h>
42 40 #include <sys/ksynch.h>
43 41 #include <sys/modctl.h>
44 42 #include <sys/byteorder.h>
45 43 #include <sys/errno.h>
46 44 #include <sys/kiconv.h>
47 45 #include <sys/kiconv_emea1.h>
48 46 #include <sys/kiconv_emea2.h>
49 47
50 48
51 49 /*
52 50 * The following macros indicate ids to the correct code conversion mapping
53 51 * data tables to use. The actual tables are coming from <sys/kiconv_emea1.h>
54 52 * and <sys/kiconv_emea2.h>. If you update the header files, then, you might
55 53 * also need to update the table ids at below.
56 54 *
57 55 * The table for KICONV_TBLID_720 is a special case and should come from
58 56 * a separate header file than others at <sys/kiconv_emea1.h> hence it has
59 57 * an id that is rather unusual distinguishing itself from others. (And,
60 58 * the ids much be of uint8_t.)
61 59 */
62 60 #define KICONV_TBLID_720 (0xFFU)
63 61 #define KICONV_TBLID_RANGE1_START KICONV_TBLID_720
64 62 #define KICONV_TBLID_RANGE1_END KICONV_TBLID_720
65 63
66 64 #define KICONV_TBLID_737 (0)
67 65 #define KICONV_TBLID_852 (1)
68 66 #define KICONV_TBLID_857 (2)
69 67 #define KICONV_TBLID_862 (3)
70 68 #define KICONV_TBLID_866 (4)
71 69 #define KICONV_TBLID_1250 (5)
72 70 #define KICONV_TBLID_1251 (6)
73 71 #define KICONV_TBLID_1253 (7)
74 72 #define KICONV_TBLID_1254 (8)
75 73 #define KICONV_TBLID_1255 (9)
76 74 #define KICONV_TBLID_1256 (10)
77 75 #define KICONV_TBLID_1257 (11)
78 76 #define KICONV_TBLID_8859_2 (12)
79 77 #define KICONV_TBLID_8859_3 (13)
80 78 #define KICONV_TBLID_8859_4 (14)
81 79 #define KICONV_TBLID_8859_5 (15)
82 80 #define KICONV_TBLID_8859_6 (16)
83 81 #define KICONV_TBLID_8859_7 (17)
84 82 #define KICONV_TBLID_8859_8 (18)
85 83 #define KICONV_TBLID_8859_9 (19)
86 84 #define KICONV_TBLID_8859_10 (20)
87 85 #define KICONV_TBLID_8859_11 (21)
88 86 #define KICONV_TBLID_8859_13 (22)
89 87 #define KICONV_TBLID_KOI8_R (23)
90 88
91 89 #define KICONV_MAX_MAPPING_TBLID KICONV_TBLID_KOI8_R
92 90
93 91 /*
94 92 * The following tables are coming from u8_textprep.c. We use them to
95 93 * check on validity of UTF-8 characters and their bytes.
96 94 */
97 95 extern const int8_t u8_number_of_bytes[];
98 96 extern const uint8_t u8_valid_min_2nd_byte[];
99 97 extern const uint8_t u8_valid_max_2nd_byte[];
100 98
101 99
102 100 /*
103 101 * The following 25 open_to_xxxx() functions are kiconv_open functions for
104 102 * the conversions from UTF-8 to xxxx single byte codesets.
105 103 */
106 104 static void *
107 105 open_to_720()
108 106 {
109 107 kiconv_state_t s;
110 108
111 109 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
112 110 s->id = KICONV_TBLID_720;
113 111 s->bom_processed = 0;
114 112
115 113 return ((void *)s);
116 114 }
117 115
118 116 static void *
119 117 open_to_737()
120 118 {
121 119 kiconv_state_t s;
122 120
123 121 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
124 122 s->id = KICONV_TBLID_737;
125 123 s->bom_processed = 0;
126 124
127 125 return ((void *)s);
128 126 }
129 127
130 128 static void *
131 129 open_to_852()
132 130 {
133 131 kiconv_state_t s;
134 132
135 133 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
136 134 s->id = KICONV_TBLID_852;
137 135 s->bom_processed = 0;
138 136
139 137 return ((void *)s);
140 138 }
141 139
142 140 static void *
143 141 open_to_857()
144 142 {
145 143 kiconv_state_t s;
146 144
147 145 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
148 146 s->id = KICONV_TBLID_857;
149 147 s->bom_processed = 0;
150 148
151 149 return ((void *)s);
152 150 }
153 151
154 152 static void *
155 153 open_to_862()
156 154 {
157 155 kiconv_state_t s;
158 156
159 157 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
160 158 s->id = KICONV_TBLID_862;
161 159 s->bom_processed = 0;
162 160
163 161 return ((void *)s);
164 162 }
165 163
166 164 static void *
167 165 open_to_866()
168 166 {
169 167 kiconv_state_t s;
170 168
171 169 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
172 170 s->id = KICONV_TBLID_866;
173 171 s->bom_processed = 0;
174 172
175 173 return ((void *)s);
176 174 }
177 175
178 176 static void *
179 177 open_to_1250()
180 178 {
181 179 kiconv_state_t s;
182 180
183 181 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
184 182 s->id = KICONV_TBLID_1250;
185 183 s->bom_processed = 0;
186 184
187 185 return ((void *)s);
188 186 }
189 187
190 188 static void *
191 189 open_to_1251()
192 190 {
193 191 kiconv_state_t s;
194 192
195 193 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
196 194 s->id = KICONV_TBLID_1251;
197 195 s->bom_processed = 0;
198 196
199 197 return ((void *)s);
200 198 }
201 199
202 200 static void *
203 201 open_to_1253()
204 202 {
205 203 kiconv_state_t s;
206 204
207 205 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
208 206 s->id = KICONV_TBLID_1253;
209 207 s->bom_processed = 0;
210 208
211 209 return ((void *)s);
212 210 }
213 211
214 212 static void *
215 213 open_to_1254()
216 214 {
217 215 kiconv_state_t s;
218 216
219 217 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
220 218 s->id = KICONV_TBLID_1254;
221 219 s->bom_processed = 0;
222 220
223 221 return ((void *)s);
224 222 }
225 223
226 224 static void *
227 225 open_to_1255()
228 226 {
229 227 kiconv_state_t s;
230 228
231 229 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
232 230 s->id = KICONV_TBLID_1255;
233 231 s->bom_processed = 0;
234 232
235 233 return ((void *)s);
236 234 }
237 235
238 236 static void *
239 237 open_to_1256()
240 238 {
241 239 kiconv_state_t s;
242 240
243 241 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
244 242 s->id = KICONV_TBLID_1256;
245 243 s->bom_processed = 0;
246 244
247 245 return ((void *)s);
248 246 }
249 247
250 248 static void *
251 249 open_to_1257()
252 250 {
253 251 kiconv_state_t s;
254 252
255 253 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
256 254 s->id = KICONV_TBLID_1257;
257 255 s->bom_processed = 0;
258 256
259 257 return ((void *)s);
260 258 }
261 259
262 260 static void *
263 261 open_to_88592()
264 262 {
265 263 kiconv_state_t s;
266 264
267 265 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
268 266 s->id = KICONV_TBLID_8859_2;
269 267 s->bom_processed = 0;
270 268
271 269 return ((void *)s);
272 270 }
273 271
274 272 static void *
275 273 open_to_88593()
276 274 {
277 275 kiconv_state_t s;
278 276
279 277 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
280 278 s->id = KICONV_TBLID_8859_3;
281 279 s->bom_processed = 0;
282 280
283 281 return ((void *)s);
284 282 }
285 283
286 284 static void *
287 285 open_to_88594()
288 286 {
289 287 kiconv_state_t s;
290 288
291 289 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
292 290 s->id = KICONV_TBLID_8859_4;
293 291 s->bom_processed = 0;
294 292
295 293 return ((void *)s);
296 294 }
297 295
298 296 static void *
299 297 open_to_88595()
300 298 {
301 299 kiconv_state_t s;
302 300
303 301 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
304 302 s->id = KICONV_TBLID_8859_5;
305 303 s->bom_processed = 0;
306 304
307 305 return ((void *)s);
308 306 }
309 307
310 308 static void *
311 309 open_to_88596()
312 310 {
313 311 kiconv_state_t s;
314 312
315 313 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
316 314 s->id = KICONV_TBLID_8859_6;
317 315 s->bom_processed = 0;
318 316
319 317 return ((void *)s);
320 318 }
321 319
322 320 static void *
323 321 open_to_88597()
324 322 {
325 323 kiconv_state_t s;
326 324
327 325 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
328 326 s->id = KICONV_TBLID_8859_7;
329 327 s->bom_processed = 0;
330 328
331 329 return ((void *)s);
332 330 }
333 331
334 332 static void *
335 333 open_to_88598()
336 334 {
337 335 kiconv_state_t s;
338 336
339 337 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
340 338 s->id = KICONV_TBLID_8859_8;
341 339 s->bom_processed = 0;
342 340
343 341 return ((void *)s);
344 342 }
345 343
346 344 static void *
347 345 open_to_88599()
348 346 {
349 347 kiconv_state_t s;
350 348
351 349 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
352 350 s->id = KICONV_TBLID_8859_9;
353 351 s->bom_processed = 0;
354 352
355 353 return ((void *)s);
356 354 }
357 355
358 356 static void *
359 357 open_to_885910()
360 358 {
361 359 kiconv_state_t s;
362 360
363 361 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
364 362 s->id = KICONV_TBLID_8859_10;
365 363 s->bom_processed = 0;
366 364
367 365 return ((void *)s);
368 366 }
369 367
370 368 static void *
371 369 open_to_885911()
372 370 {
373 371 kiconv_state_t s;
374 372
375 373 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
376 374 s->id = KICONV_TBLID_8859_11;
377 375 s->bom_processed = 0;
378 376
379 377 return ((void *)s);
380 378 }
381 379
382 380 static void *
383 381 open_to_885913()
384 382 {
385 383 kiconv_state_t s;
386 384
387 385 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
388 386 s->id = KICONV_TBLID_8859_13;
389 387 s->bom_processed = 0;
390 388
391 389 return ((void *)s);
392 390 }
393 391
394 392 static void *
395 393 open_to_koi8r()
396 394 {
397 395 kiconv_state_t s;
398 396
399 397 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
400 398 s->id = KICONV_TBLID_KOI8_R;
401 399 s->bom_processed = 0;
402 400
403 401 return ((void *)s);
404 402 }
405 403
406 404 /*
407 405 * The following 25 open_fr_xxxx() functions are kiconv_open functions for
408 406 * the conversions from xxxx single byte codeset to UTF-8.
409 407 */
410 408 static void *
411 409 open_fr_720()
412 410 {
413 411 return ((void *)KICONV_TBLID_720);
414 412 }
415 413
416 414 static void *
417 415 open_fr_737()
418 416 {
419 417 return ((void *)KICONV_TBLID_737);
420 418 }
421 419
422 420 static void *
423 421 open_fr_852()
424 422 {
425 423 return ((void *)KICONV_TBLID_852);
426 424 }
427 425
428 426 static void *
429 427 open_fr_857()
430 428 {
431 429 return ((void *)KICONV_TBLID_857);
432 430 }
433 431
434 432 static void *
435 433 open_fr_862()
436 434 {
437 435 return ((void *)KICONV_TBLID_862);
438 436 }
439 437
440 438 static void *
441 439 open_fr_866()
442 440 {
443 441 return ((void *)KICONV_TBLID_866);
444 442 }
445 443
446 444 static void *
447 445 open_fr_1250()
448 446 {
449 447 return ((void *)KICONV_TBLID_1250);
450 448 }
451 449
452 450 static void *
453 451 open_fr_1251()
454 452 {
455 453 return ((void *)KICONV_TBLID_1251);
456 454 }
457 455
458 456 static void *
459 457 open_fr_1253()
460 458 {
461 459 return ((void *)KICONV_TBLID_1253);
462 460 }
463 461
464 462 static void *
465 463 open_fr_1254()
466 464 {
467 465 return ((void *)KICONV_TBLID_1254);
468 466 }
469 467
470 468 static void *
471 469 open_fr_1255()
472 470 {
473 471 return ((void *)KICONV_TBLID_1255);
474 472 }
475 473
476 474 static void *
477 475 open_fr_1256()
478 476 {
479 477 return ((void *)KICONV_TBLID_1256);
480 478 }
481 479
482 480 static void *
483 481 open_fr_1257()
484 482 {
485 483 return ((void *)KICONV_TBLID_1257);
486 484 }
487 485
488 486 static void *
489 487 open_fr_88592()
490 488 {
491 489 return ((void *)KICONV_TBLID_8859_2);
492 490 }
493 491
494 492 static void *
495 493 open_fr_88593()
496 494 {
497 495 return ((void *)KICONV_TBLID_8859_3);
498 496 }
499 497
500 498 static void *
501 499 open_fr_88594()
502 500 {
503 501 return ((void *)KICONV_TBLID_8859_4);
504 502 }
505 503
506 504 static void *
507 505 open_fr_88595()
508 506 {
509 507 return ((void *)KICONV_TBLID_8859_5);
510 508 }
511 509
512 510 static void *
513 511 open_fr_88596()
514 512 {
515 513 return ((void *)KICONV_TBLID_8859_6);
516 514 }
517 515
518 516 static void *
519 517 open_fr_88597()
520 518 {
521 519 return ((void *)KICONV_TBLID_8859_7);
522 520 }
523 521
524 522 static void *
525 523 open_fr_88598()
526 524 {
527 525 return ((void *)KICONV_TBLID_8859_8);
528 526 }
529 527
530 528 static void *
531 529 open_fr_88599()
532 530 {
533 531 return ((void *)KICONV_TBLID_8859_9);
534 532 }
535 533
536 534 static void *
537 535 open_fr_885910()
538 536 {
539 537 return ((void *)KICONV_TBLID_8859_10);
540 538 }
541 539
542 540 static void *
543 541 open_fr_885911()
544 542 {
545 543 return ((void *)KICONV_TBLID_8859_11);
546 544 }
547 545
548 546 static void *
549 547 open_fr_885913()
550 548 {
551 549 return ((void *)KICONV_TBLID_8859_13);
552 550 }
553 551
554 552 static void *
555 553 open_fr_koi8r()
556 554 {
557 555 return ((void *)KICONV_TBLID_KOI8_R);
558 556 }
559 557
560 558 /*
561 559 * The following is the common kiconv_close function for the conversions from
562 560 * UTF-8 to single byte codesets.
563 561 */
564 562 static int
565 563 close_to_sb(void *s)
566 564 {
567 565 if (! s || s == (void *)-1)
568 566 return (EBADF);
569 567
570 568 kmem_free(s, sizeof (kiconv_state_data_t));
571 569
572 570 return (0);
573 571 }
574 572
575 573 /*
576 574 * The following is the common kiconv_close function for the conversions from
577 575 * single byte codesets to UTF-8.
578 576 */
579 577 static int
580 578 close_fr_sb(void *s)
581 579 {
582 580 if ((ulong_t)s > KICONV_MAX_MAPPING_TBLID &&
583 581 ((ulong_t)s < KICONV_TBLID_RANGE1_START ||
584 582 (ulong_t)s > KICONV_TBLID_RANGE1_END))
585 583 return (EBADF);
586 584
587 585 return (0);
588 586 }
589 587
590 588 /*
591 589 * The following is the common kiconv function for the conversions from
592 590 * UTF-8 to single byte codesets. (This may look a lot similar to
593 591 * kiconvstr_to_sb() but they do have different features to cover and
594 592 * it's not really worth to try to merge them into a single function since
595 593 * you'll have to add performance penalty for both per each character
596 594 * conversion as you will have to figure out if this is kiconv_to_sb() or
597 595 * kiconvstr_to_sb().)
598 596 */
599 597 static size_t
600 598 kiconv_to_sb(void *kcd, char **inbuf, size_t *inbytesleft, char **outbuf,
601 599 size_t *outbytesleft, int *errno)
602 600 {
603 601 kiconv_to_sb_tbl_comp_t *tbl;
604 602 size_t id;
605 603 size_t ret_val;
606 604 uchar_t *ib;
607 605 uchar_t *oldib;
608 606 uchar_t *ob;
609 607 uchar_t *ibtail;
610 608 uchar_t *obtail;
611 609 uint32_t u8;
612 610 size_t i;
613 611 size_t l;
614 612 size_t h;
615 613 size_t init_h;
616 614 int8_t sz;
617 615 boolean_t second;
618 616
619 617 /* Check on the kiconv code conversion descriptor. */
620 618 if (! kcd || kcd == (void *)-1) {
621 619 *errno = EBADF;
622 620 return ((size_t)-1);
623 621 }
624 622
625 623 /* Get the table id and check on it. */
626 624 id = ((kiconv_state_t)kcd)->id;
627 625 if (id > KICONV_MAX_MAPPING_TBLID &&
628 626 (id < KICONV_TBLID_RANGE1_START || id > KICONV_TBLID_RANGE1_END)) {
629 627 *errno = EBADF;
630 628 return ((size_t)-1);
631 629 }
632 630
633 631 /* If this is a state reset request, process and return. */
634 632 if (! inbuf || ! (*inbuf)) {
635 633 ((kiconv_state_t)kcd)->bom_processed = 0;
636 634 return ((size_t)0);
637 635 }
638 636
639 637 ret_val = 0;
640 638 ib = (uchar_t *)*inbuf;
641 639 ob = (uchar_t *)*outbuf;
642 640 ibtail = ib + *inbytesleft;
643 641 obtail = ob + *outbytesleft;
644 642
645 643 /*
646 644 * Get the table we want to use and also calculate the "init_h"
647 645 * which is the initial high index for the binary search that we will
648 646 * use. While the table sizes are all the same at the moment, to be
649 647 * ready for future cases where tables could be in different sizes,
650 648 * we separately calculate the init_h at here.
651 649 */
652 650 if (id == KICONV_TBLID_720) {
653 651 tbl = (kiconv_to_sb_tbl_comp_t *)u8_to_cp720_tbl;
654 652 init_h = sizeof (u8_to_cp720_tbl);
655 653 } else {
656 654 tbl = (kiconv_to_sb_tbl_comp_t *)to_sb_tbl[id];
657 655 init_h = sizeof (to_sb_tbl[id]);
658 656 }
659 657 init_h = init_h / sizeof (kiconv_to_sb_tbl_comp_t) - 1;
660 658
661 659 /*
662 660 * If we haven't checked on the UTF-8 signature BOM character in
663 661 * the beginning of the conversion data stream, we check it and if
664 662 * find one, we skip it since we have no use for it.
665 663 */
666 664 if (((kiconv_state_t)kcd)->bom_processed == 0 && (ibtail - ib) >= 3 &&
667 665 *ib == 0xef && *(ib + 1) == 0xbb && *(ib + 2) == 0xbf)
668 666 ib += 3;
669 667 ((kiconv_state_t)kcd)->bom_processed = 1;
670 668
671 669 while (ib < ibtail) {
672 670 sz = u8_number_of_bytes[*ib];
673 671 if (sz <= 0) {
674 672 *errno = EILSEQ;
675 673 ret_val = (size_t)-1;
676 674 break;
677 675 }
678 676
679 677 /*
680 678 * If there is no room to write at the output buffer,
681 679 * we issue E2BIG and let the caller knows about it.
682 680 */
683 681 if (ob >= obtail) {
684 682 *errno = E2BIG;
685 683 ret_val = (size_t)-1;
686 684 break;
687 685 }
688 686
689 687 /*
690 688 * If it is a 7-bit ASCII character, we don't need to
691 689 * process further and we just copy the character over.
692 690 *
693 691 * If not, we collect the character bytes up to four bytes,
694 692 * validate the bytes, and binary search for the corresponding
695 693 * single byte codeset character byte. If we find it from
696 694 * the mapping table, we put that into the output buffer;
697 695 * otherwise, we put a replacement character instead as
698 696 * a non-identical conversion.
699 697 */
700 698 if (sz == 1) {
701 699 *ob++ = *ib++;
702 700 continue;
703 701 }
704 702
705 703 /*
706 704 * Issue EINVAL if the last character at the input buffer
707 705 * is an incomplete character missing a byte or more.
708 706 */
709 707 if ((ibtail - ib) < sz) {
710 708 *errno = EINVAL;
711 709 ret_val = (size_t)-1;
712 710 break;
713 711 }
714 712
715 713 /*
716 714 * We collect UTF-8 character bytes and at the same time,
717 715 * check on if the bytes are valid bytes or not. This follows
718 716 * the latest UTF-8 byte representation.
719 717 */
720 718 oldib = ib;
721 719 u8 = *ib++;
722 720 second = B_TRUE;
723 721 for (i = 1; i < sz; i++) {
724 722 if (second) {
725 723 if (*ib < u8_valid_min_2nd_byte[u8] ||
726 724 *ib > u8_valid_max_2nd_byte[u8]) {
727 725 *errno = EILSEQ;
728 726 ret_val = (size_t)-1;
729 727 ib = oldib;
730 728 goto TO_SB_ILLEGAL_CHAR_ERR;
731 729 }
732 730 second = B_FALSE;
733 731 } else if (*ib < 0x80 || *ib > 0xbf) {
734 732 *errno = EILSEQ;
735 733 ret_val = (size_t)-1;
736 734 ib = oldib;
737 735 goto TO_SB_ILLEGAL_CHAR_ERR;
738 736 }
739 737 u8 = (u8 << 8) | ((uint32_t)*ib);
740 738 ib++;
741 739 }
742 740
743 741 i = l = 0;
744 742 h = init_h;
745 743 while (l <= h) {
746 744 i = (l + h) / 2;
747 745 if (tbl[i].u8 == u8)
748 746 break;
749 747 else if (tbl[i].u8 < u8)
750 748 l = i + 1;
751 749 else
752 750 h = i - 1;
753 751 }
754 752
755 753 if (tbl[i].u8 == u8) {
756 754 *ob++ = tbl[i].sb;
757 755 } else {
758 756 /*
759 757 * What this means is that we encountered
760 758 * a non-identical conversion. In other words,
761 759 * input buffer contains a valid character in
762 760 * the fromcode but the tocode doesn't have
763 761 * any character that can be mapped to.
764 762 *
765 763 * In this case, we insert an ASCII replacement
766 764 * character instead at the output buffer and
767 765 * count such non-identical conversions by
768 766 * increasing the ret_val.
769 767 *
770 768 * If the return value of the function is bigger
771 769 * than zero, that means we had such non-identical
772 770 * conversion(s).
773 771 */
774 772 *ob++ = KICONV_ASCII_REPLACEMENT_CHAR;
775 773 ret_val++;
776 774 }
777 775 }
778 776
779 777 TO_SB_ILLEGAL_CHAR_ERR:
780 778 *inbuf = (char *)ib;
781 779 *inbytesleft = ibtail - ib;
782 780 *outbuf = (char *)ob;
783 781 *outbytesleft = obtail - ob;
784 782
785 783 return (ret_val);
786 784 }
787 785
788 786 /*
789 787 * The following is the common kiconv function for the conversions from
790 788 * single byte codesets to UTf-8.
791 789 */
792 790 static size_t
793 791 kiconv_fr_sb(void *kcd, char **inbuf, size_t *inbytesleft, char **outbuf,
794 792 size_t *outbytesleft, int *errno)
795 793 {
796 794 kiconv_to_utf8_tbl_comp_t *tbl;
797 795 size_t ret_val;
798 796 uchar_t *ib;
799 797 uchar_t *ob;
800 798 uchar_t *ibtail;
801 799 uchar_t *obtail;
802 800 size_t i;
803 801 size_t k;
804 802 int8_t sz;
805 803
806 804 /* Validate the kiconv code conversion descriptor. */
807 805 if ((ulong_t)kcd > KICONV_MAX_MAPPING_TBLID &&
808 806 ((ulong_t)kcd < KICONV_TBLID_RANGE1_START ||
809 807 (ulong_t)kcd > KICONV_TBLID_RANGE1_END)) {
810 808 *errno = EBADF;
811 809 return ((size_t)-1);
812 810 }
813 811
814 812 /*
815 813 * If this is a state reset request, there is nothing to do and so
816 814 * we just return.
817 815 */
818 816 if (! inbuf || ! (*inbuf))
819 817 return ((size_t)0);
820 818
821 819 ret_val = 0;
822 820 ib = (uchar_t *)*inbuf;
823 821 ob = (uchar_t *)*outbuf;
824 822 ibtail = ib + *inbytesleft;
825 823 obtail = ob + *outbytesleft;
826 824
827 825 tbl = ((ulong_t)kcd == KICONV_TBLID_720) ?
828 826 (kiconv_to_utf8_tbl_comp_t *)cp720_to_u8_tbl :
829 827 (kiconv_to_utf8_tbl_comp_t *)to_u8_tbl[(ulong_t)kcd];
830 828
831 829 while (ib < ibtail) {
832 830 /*
833 831 * If this is a 7-bit ASCII character, we just copy over and
834 832 * that's all we need to do for this character.
835 833 */
836 834 if (*ib < 0x80) {
837 835 if (ob >= obtail) {
838 836 *errno = E2BIG;
839 837 ret_val = (size_t)-1;
840 838 break;
841 839 }
842 840
843 841 *ob++ = *ib++;
844 842 continue;
845 843 }
846 844
847 845 /*
848 846 * Otherwise, we get the corresponding UTF-8 character bytes
849 847 * from the mapping table and copy them over.
850 848 *
851 849 * We don't need to worry about if the UTF-8 character bytes
852 850 * at the mapping tables are valid or not since they are good.
853 851 */
854 852 k = *ib - 0x80;
855 853 sz = u8_number_of_bytes[tbl[k].u8[0]];
856 854
857 855 /*
858 856 * If (sz <= 0), that means the character in the input buffer
859 857 * is an illegal character possibly unassigned or non-character
860 858 * at the fromcode single byte codeset.
861 859 */
862 860 if (sz <= 0) {
863 861 *errno = EILSEQ;
864 862 ret_val = (size_t)-1;
865 863 break;
866 864 }
867 865
868 866 if ((obtail - ob) < sz) {
869 867 *errno = E2BIG;
870 868 ret_val = (size_t)-1;
871 869 break;
872 870 }
873 871
874 872 for (i = 0; i < sz; i++)
875 873 *ob++ = tbl[k].u8[i];
876 874
877 875 ib++;
878 876 }
879 877
880 878 *inbuf = (char *)ib;
881 879 *inbytesleft = ibtail - ib;
882 880 *outbuf = (char *)ob;
883 881 *outbytesleft = obtail - ob;
884 882
885 883 return (ret_val);
886 884 }
887 885
888 886 /*
889 887 * The following is the common kiconvstr function for the conversions from
890 888 * UTF-8 to single byte codeset.
891 889 */
892 890 static size_t
893 891 kiconvstr_to_sb(size_t id, uchar_t *ib, size_t *inlen, uchar_t *ob,
894 892 size_t *outlen, int flag, int *errno)
895 893 {
896 894 kiconv_to_sb_tbl_comp_t *tbl;
897 895 size_t ret_val;
898 896 uchar_t *oldib;
899 897 uchar_t *ibtail;
900 898 uchar_t *obtail;
901 899 uint32_t u8;
902 900 size_t i;
903 901 size_t l;
904 902 size_t h;
905 903 size_t init_h;
906 904 int8_t sz;
907 905 boolean_t second;
908 906 boolean_t do_not_ignore_null;
909 907
910 908 /* Let's double check on the table id. */
911 909 if (id > KICONV_MAX_MAPPING_TBLID &&
912 910 (id < KICONV_TBLID_RANGE1_START || id > KICONV_TBLID_RANGE1_END)) {
913 911 *errno = EBADF;
914 912 return ((size_t)-1);
915 913 }
916 914
917 915 ret_val = 0;
918 916 ibtail = ib + *inlen;
919 917 obtail = ob + *outlen;
920 918 do_not_ignore_null = ((flag & KICONV_IGNORE_NULL) == 0);
921 919
922 920 if (id == KICONV_TBLID_720) {
923 921 tbl = (kiconv_to_sb_tbl_comp_t *)u8_to_cp720_tbl;
924 922 init_h = sizeof (u8_to_cp720_tbl);
925 923 } else {
926 924 tbl = (kiconv_to_sb_tbl_comp_t *)to_sb_tbl[id];
927 925 init_h = sizeof (to_sb_tbl[id]);
928 926 }
929 927 init_h = init_h / sizeof (kiconv_to_sb_tbl_comp_t) - 1;
930 928
931 929 /* Skip any UTF-8 signature BOM character in the beginning. */
932 930 if ((ibtail - ib) >= 3 && *ib == 0xef && *(ib + 1) == 0xbb &&
933 931 *(ib + 2) == 0xbf)
934 932 ib += 3;
935 933
936 934 /*
937 935 * Basically this is pretty much the same as kiconv_to_sb() except
938 936 * that we are now accepting two flag values and doing the processing
939 937 * accordingly.
940 938 */
941 939 while (ib < ibtail) {
942 940 sz = u8_number_of_bytes[*ib];
943 941 if (sz <= 0) {
944 942 if (flag & KICONV_REPLACE_INVALID) {
945 943 if (ob >= obtail) {
946 944 *errno = E2BIG;
947 945 ret_val = (size_t)-1;
948 946 break;
949 947 }
950 948
951 949 ib++;
952 950 goto STR_TO_SB_REPLACE_INVALID;
953 951 }
954 952
955 953 *errno = EILSEQ;
956 954 ret_val = (size_t)-1;
957 955 break;
958 956 }
959 957
960 958 if (*ib == '\0' && do_not_ignore_null)
961 959 break;
962 960
963 961 if (ob >= obtail) {
964 962 *errno = E2BIG;
965 963 ret_val = (size_t)-1;
966 964 break;
967 965 }
968 966
969 967 if (sz == 1) {
970 968 *ob++ = *ib++;
971 969 continue;
972 970 }
973 971
974 972 if ((ibtail - ib) < sz) {
975 973 if (flag & KICONV_REPLACE_INVALID) {
976 974 ib = ibtail;
977 975 goto STR_TO_SB_REPLACE_INVALID;
978 976 }
979 977
980 978 *errno = EINVAL;
981 979 ret_val = (size_t)-1;
982 980 break;
983 981 }
984 982
985 983 oldib = ib;
986 984 u8 = *ib++;
987 985 second = B_TRUE;
988 986 for (i = 1; i < sz; i++) {
989 987 if (second) {
990 988 if (*ib < u8_valid_min_2nd_byte[u8] ||
991 989 *ib > u8_valid_max_2nd_byte[u8]) {
992 990 if (flag & KICONV_REPLACE_INVALID) {
993 991 ib = oldib + sz;
994 992 goto STR_TO_SB_REPLACE_INVALID;
995 993 }
996 994
997 995 *errno = EILSEQ;
998 996 ret_val = (size_t)-1;
999 997 ib = oldib;
1000 998 goto STR_TO_SB_ILLEGAL_CHAR_ERR;
1001 999 }
1002 1000 second = B_FALSE;
1003 1001 } else if (*ib < 0x80 || *ib > 0xbf) {
1004 1002 if (flag & KICONV_REPLACE_INVALID) {
1005 1003 ib = oldib + sz;
1006 1004 goto STR_TO_SB_REPLACE_INVALID;
1007 1005 }
1008 1006
1009 1007 *errno = EILSEQ;
1010 1008 ret_val = (size_t)-1;
1011 1009 ib = oldib;
1012 1010 goto STR_TO_SB_ILLEGAL_CHAR_ERR;
1013 1011 }
1014 1012 u8 = (u8 << 8) | ((uint32_t)*ib);
1015 1013 ib++;
1016 1014 }
1017 1015
1018 1016 i = l = 0;
1019 1017 h = init_h;
1020 1018 while (l <= h) {
1021 1019 i = (l + h) / 2;
1022 1020 if (tbl[i].u8 == u8)
1023 1021 break;
1024 1022 else if (tbl[i].u8 < u8)
1025 1023 l = i + 1;
1026 1024 else
1027 1025 h = i - 1;
1028 1026 }
1029 1027
1030 1028 if (tbl[i].u8 == u8) {
1031 1029 *ob++ = tbl[i].sb;
1032 1030 } else {
1033 1031 STR_TO_SB_REPLACE_INVALID:
1034 1032 *ob++ = KICONV_ASCII_REPLACEMENT_CHAR;
1035 1033 ret_val++;
1036 1034 }
1037 1035 }
1038 1036
1039 1037 STR_TO_SB_ILLEGAL_CHAR_ERR:
1040 1038 *inlen = ibtail - ib;
1041 1039 *outlen = obtail - ob;
1042 1040
1043 1041 return (ret_val);
1044 1042 }
1045 1043
1046 1044 /*
1047 1045 * The following 25 functions are the real entry points that will be
1048 1046 * given to the kiconv framework at the genunix.
1049 1047 */
1050 1048 static size_t
1051 1049 kiconvstr_to_720(char *inarray, size_t *inlen, char *outarray,
1052 1050 size_t *outlen, int flag, int *errno)
1053 1051 {
1054 1052 return (kiconvstr_to_sb(KICONV_TBLID_720, (uchar_t *)inarray,
1055 1053 inlen, (uchar_t *)outarray, outlen, flag, errno));
1056 1054 }
1057 1055
1058 1056 static size_t
1059 1057 kiconvstr_to_737(char *inarray, size_t *inlen, char *outarray,
1060 1058 size_t *outlen, int flag, int *errno)
1061 1059 {
1062 1060 return (kiconvstr_to_sb(KICONV_TBLID_737, (uchar_t *)inarray,
1063 1061 inlen, (uchar_t *)outarray, outlen, flag, errno));
1064 1062 }
1065 1063
1066 1064 static size_t
1067 1065 kiconvstr_to_852(char *inarray, size_t *inlen, char *outarray,
1068 1066 size_t *outlen, int flag, int *errno)
1069 1067 {
1070 1068 return (kiconvstr_to_sb(KICONV_TBLID_852, (uchar_t *)inarray,
1071 1069 inlen, (uchar_t *)outarray, outlen, flag, errno));
1072 1070 }
1073 1071
1074 1072 static size_t
1075 1073 kiconvstr_to_857(char *inarray, size_t *inlen, char *outarray,
1076 1074 size_t *outlen, int flag, int *errno)
1077 1075 {
1078 1076 return (kiconvstr_to_sb(KICONV_TBLID_857, (uchar_t *)inarray,
1079 1077 inlen, (uchar_t *)outarray, outlen, flag, errno));
1080 1078 }
1081 1079
1082 1080 static size_t
1083 1081 kiconvstr_to_862(char *inarray, size_t *inlen, char *outarray,
1084 1082 size_t *outlen, int flag, int *errno)
1085 1083 {
1086 1084 return (kiconvstr_to_sb(KICONV_TBLID_862, (uchar_t *)inarray,
1087 1085 inlen, (uchar_t *)outarray, outlen, flag, errno));
1088 1086 }
1089 1087
1090 1088 static size_t
1091 1089 kiconvstr_to_866(char *inarray, size_t *inlen, char *outarray,
1092 1090 size_t *outlen, int flag, int *errno)
1093 1091 {
1094 1092 return (kiconvstr_to_sb(KICONV_TBLID_866, (uchar_t *)inarray,
1095 1093 inlen, (uchar_t *)outarray, outlen, flag, errno));
1096 1094 }
1097 1095
1098 1096 static size_t
1099 1097 kiconvstr_to_1250(char *inarray, size_t *inlen, char *outarray,
1100 1098 size_t *outlen, int flag, int *errno)
1101 1099 {
1102 1100 return (kiconvstr_to_sb(KICONV_TBLID_1250, (uchar_t *)inarray,
1103 1101 inlen, (uchar_t *)outarray, outlen, flag, errno));
1104 1102 }
1105 1103
1106 1104 static size_t
1107 1105 kiconvstr_to_1251(char *inarray, size_t *inlen, char *outarray,
1108 1106 size_t *outlen, int flag, int *errno)
1109 1107 {
1110 1108 return (kiconvstr_to_sb(KICONV_TBLID_1251, (uchar_t *)inarray,
1111 1109 inlen, (uchar_t *)outarray, outlen, flag, errno));
1112 1110 }
1113 1111
1114 1112 static size_t
1115 1113 kiconvstr_to_1253(char *inarray, size_t *inlen, char *outarray,
1116 1114 size_t *outlen, int flag, int *errno)
1117 1115 {
1118 1116 return (kiconvstr_to_sb(KICONV_TBLID_1253, (uchar_t *)inarray,
1119 1117 inlen, (uchar_t *)outarray, outlen, flag, errno));
1120 1118 }
1121 1119
1122 1120 static size_t
1123 1121 kiconvstr_to_1254(char *inarray, size_t *inlen, char *outarray,
1124 1122 size_t *outlen, int flag, int *errno)
1125 1123 {
1126 1124 return (kiconvstr_to_sb(KICONV_TBLID_1254, (uchar_t *)inarray,
1127 1125 inlen, (uchar_t *)outarray, outlen, flag, errno));
1128 1126 }
1129 1127
1130 1128 static size_t
1131 1129 kiconvstr_to_1255(char *inarray, size_t *inlen, char *outarray,
1132 1130 size_t *outlen, int flag, int *errno)
1133 1131 {
1134 1132 return (kiconvstr_to_sb(KICONV_TBLID_1255, (uchar_t *)inarray,
1135 1133 inlen, (uchar_t *)outarray, outlen, flag, errno));
1136 1134 }
1137 1135
1138 1136 static size_t
1139 1137 kiconvstr_to_1256(char *inarray, size_t *inlen, char *outarray,
1140 1138 size_t *outlen, int flag, int *errno)
1141 1139 {
1142 1140 return (kiconvstr_to_sb(KICONV_TBLID_1256, (uchar_t *)inarray,
1143 1141 inlen, (uchar_t *)outarray, outlen, flag, errno));
1144 1142 }
1145 1143
1146 1144 static size_t
1147 1145 kiconvstr_to_1257(char *inarray, size_t *inlen, char *outarray,
1148 1146 size_t *outlen, int flag, int *errno)
1149 1147 {
1150 1148 return (kiconvstr_to_sb(KICONV_TBLID_1257, (uchar_t *)inarray,
1151 1149 inlen, (uchar_t *)outarray, outlen, flag, errno));
1152 1150 }
1153 1151
1154 1152 static size_t
1155 1153 kiconvstr_to_88592(char *inarray, size_t *inlen, char *outarray,
1156 1154 size_t *outlen, int flag, int *errno)
1157 1155 {
1158 1156 return (kiconvstr_to_sb(KICONV_TBLID_8859_2, (uchar_t *)inarray,
1159 1157 inlen, (uchar_t *)outarray, outlen, flag, errno));
1160 1158 }
1161 1159
1162 1160 static size_t
1163 1161 kiconvstr_to_88593(char *inarray, size_t *inlen, char *outarray,
1164 1162 size_t *outlen, int flag, int *errno)
1165 1163 {
1166 1164 return (kiconvstr_to_sb(KICONV_TBLID_8859_3, (uchar_t *)inarray,
1167 1165 inlen, (uchar_t *)outarray, outlen, flag, errno));
1168 1166 }
1169 1167
1170 1168 static size_t
1171 1169 kiconvstr_to_88594(char *inarray, size_t *inlen, char *outarray,
1172 1170 size_t *outlen, int flag, int *errno)
1173 1171 {
1174 1172 return (kiconvstr_to_sb(KICONV_TBLID_8859_4, (uchar_t *)inarray,
1175 1173 inlen, (uchar_t *)outarray, outlen, flag, errno));
1176 1174 }
1177 1175
1178 1176 static size_t
1179 1177 kiconvstr_to_88595(char *inarray, size_t *inlen, char *outarray,
1180 1178 size_t *outlen, int flag, int *errno)
1181 1179 {
1182 1180 return (kiconvstr_to_sb(KICONV_TBLID_8859_5, (uchar_t *)inarray,
1183 1181 inlen, (uchar_t *)outarray, outlen, flag, errno));
1184 1182 }
1185 1183
1186 1184 static size_t
1187 1185 kiconvstr_to_88596(char *inarray, size_t *inlen, char *outarray,
1188 1186 size_t *outlen, int flag, int *errno)
1189 1187 {
1190 1188 return (kiconvstr_to_sb(KICONV_TBLID_8859_6, (uchar_t *)inarray,
1191 1189 inlen, (uchar_t *)outarray, outlen, flag, errno));
1192 1190 }
1193 1191
1194 1192 static size_t
1195 1193 kiconvstr_to_88597(char *inarray, size_t *inlen, char *outarray,
1196 1194 size_t *outlen, int flag, int *errno)
1197 1195 {
1198 1196 return (kiconvstr_to_sb(KICONV_TBLID_8859_7, (uchar_t *)inarray,
1199 1197 inlen, (uchar_t *)outarray, outlen, flag, errno));
1200 1198 }
1201 1199
1202 1200 static size_t
1203 1201 kiconvstr_to_88598(char *inarray, size_t *inlen, char *outarray,
1204 1202 size_t *outlen, int flag, int *errno)
1205 1203 {
1206 1204 return (kiconvstr_to_sb(KICONV_TBLID_8859_8, (uchar_t *)inarray,
1207 1205 inlen, (uchar_t *)outarray, outlen, flag, errno));
1208 1206 }
1209 1207
1210 1208 static size_t
1211 1209 kiconvstr_to_88599(char *inarray, size_t *inlen, char *outarray,
1212 1210 size_t *outlen, int flag, int *errno)
1213 1211 {
1214 1212 return (kiconvstr_to_sb(KICONV_TBLID_8859_9, (uchar_t *)inarray,
1215 1213 inlen, (uchar_t *)outarray, outlen, flag, errno));
1216 1214 }
1217 1215
1218 1216 static size_t
1219 1217 kiconvstr_to_885910(char *inarray, size_t *inlen, char *outarray,
1220 1218 size_t *outlen, int flag, int *errno)
1221 1219 {
1222 1220 return (kiconvstr_to_sb(KICONV_TBLID_8859_10, (uchar_t *)inarray,
1223 1221 inlen, (uchar_t *)outarray, outlen, flag, errno));
1224 1222 }
1225 1223
1226 1224 static size_t
1227 1225 kiconvstr_to_885911(char *inarray, size_t *inlen, char *outarray,
1228 1226 size_t *outlen, int flag, int *errno)
1229 1227 {
1230 1228 return (kiconvstr_to_sb(KICONV_TBLID_8859_11, (uchar_t *)inarray,
1231 1229 inlen, (uchar_t *)outarray, outlen, flag, errno));
1232 1230 }
1233 1231
1234 1232 static size_t
1235 1233 kiconvstr_to_885913(char *inarray, size_t *inlen, char *outarray,
1236 1234 size_t *outlen, int flag, int *errno)
1237 1235 {
1238 1236 return (kiconvstr_to_sb(KICONV_TBLID_8859_13, (uchar_t *)inarray,
1239 1237 inlen, (uchar_t *)outarray, outlen, flag, errno));
1240 1238 }
1241 1239
1242 1240 static size_t
1243 1241 kiconvstr_to_koi8r(char *inarray, size_t *inlen, char *outarray,
1244 1242 size_t *outlen, int flag, int *errno)
1245 1243 {
1246 1244 return (kiconvstr_to_sb(KICONV_TBLID_KOI8_R, (uchar_t *)inarray,
1247 1245 inlen, (uchar_t *)outarray, outlen, flag, errno));
1248 1246 }
1249 1247
1250 1248 /*
1251 1249 * The following is the common kiconvstr function for the conversions from
1252 1250 * single byte codeset to UTF-8.
1253 1251 */
1254 1252 static size_t
1255 1253 kiconvstr_fr_sb(size_t id, uchar_t *ib, size_t *inlen, uchar_t *ob,
1256 1254 size_t *outlen, int flag, int *errno)
1257 1255 {
1258 1256 kiconv_to_utf8_tbl_comp_t *tbl;
1259 1257 size_t ret_val;
1260 1258 uchar_t *ibtail;
1261 1259 uchar_t *obtail;
1262 1260 size_t i;
1263 1261 size_t k;
1264 1262 int8_t sz;
1265 1263 boolean_t do_not_ignore_null;
1266 1264
1267 1265 if (id > KICONV_MAX_MAPPING_TBLID &&
1268 1266 (id < KICONV_TBLID_RANGE1_START || id > KICONV_TBLID_RANGE1_END)) {
1269 1267 *errno = EBADF;
1270 1268 return ((size_t)-1);
1271 1269 }
1272 1270
1273 1271 ret_val = 0;
1274 1272 ibtail = ib + *inlen;
1275 1273 obtail = ob + *outlen;
1276 1274 do_not_ignore_null = ((flag & KICONV_IGNORE_NULL) == 0);
1277 1275
1278 1276 tbl = (id == KICONV_TBLID_720) ?
1279 1277 (kiconv_to_utf8_tbl_comp_t *)cp720_to_u8_tbl :
1280 1278 (kiconv_to_utf8_tbl_comp_t *)to_u8_tbl[id];
1281 1279
1282 1280 while (ib < ibtail) {
1283 1281 if (*ib == '\0' && do_not_ignore_null)
1284 1282 break;
1285 1283
1286 1284 if (*ib < 0x80) {
1287 1285 if (ob >= obtail) {
1288 1286 *errno = E2BIG;
1289 1287 ret_val = (size_t)-1;
1290 1288 break;
1291 1289 }
1292 1290 *ob++ = *ib++;
1293 1291 continue;
1294 1292 }
1295 1293
1296 1294 k = *ib - 0x80;
1297 1295 sz = u8_number_of_bytes[tbl[k].u8[0]];
1298 1296
1299 1297 if (sz <= 0) {
1300 1298 if (flag & KICONV_REPLACE_INVALID) {
1301 1299 if ((obtail - ob) < 3) {
1302 1300 *errno = E2BIG;
1303 1301 ret_val = (size_t)-1;
1304 1302 break;
1305 1303 }
1306 1304
1307 1305 /* Save KICONV_UTF8_REPLACEMENT_CHAR. */
1308 1306 *ob++ = 0xef;
1309 1307 *ob++ = 0xbf;
1310 1308 *ob++ = 0xbd;
1311 1309 ret_val++;
1312 1310 ib++;
1313 1311
1314 1312 continue;
1315 1313 }
1316 1314
1317 1315 *errno = EILSEQ;
1318 1316 ret_val = (size_t)-1;
1319 1317 break;
1320 1318 }
1321 1319
1322 1320 if ((obtail - ob) < sz) {
1323 1321 *errno = E2BIG;
1324 1322 ret_val = (size_t)-1;
1325 1323 break;
1326 1324 }
1327 1325
1328 1326 for (i = 0; i < sz; i++)
1329 1327 *ob++ = tbl[k].u8[i];
1330 1328
1331 1329 ib++;
1332 1330 }
1333 1331
1334 1332 *inlen = ibtail - ib;
1335 1333 *outlen = obtail - ob;
1336 1334
1337 1335 return (ret_val);
1338 1336 }
1339 1337
1340 1338 /*
1341 1339 * The following 25 functions are the real entry points that will be
1342 1340 * given to kiconv framework at the genunix.
1343 1341 */
1344 1342 static size_t
1345 1343 kiconvstr_fr_720(char *inarray, size_t *inlen, char *outarray,
1346 1344 size_t *outlen, int flag, int *errno)
1347 1345 {
1348 1346 return (kiconvstr_fr_sb(KICONV_TBLID_720, (uchar_t *)inarray,
1349 1347 inlen, (uchar_t *)outarray, outlen, flag, errno));
1350 1348 }
1351 1349
1352 1350 static size_t
1353 1351 kiconvstr_fr_737(char *inarray, size_t *inlen, char *outarray,
1354 1352 size_t *outlen, int flag, int *errno)
1355 1353 {
1356 1354 return (kiconvstr_fr_sb(KICONV_TBLID_737, (uchar_t *)inarray,
1357 1355 inlen, (uchar_t *)outarray, outlen, flag, errno));
1358 1356 }
1359 1357
1360 1358 static size_t
1361 1359 kiconvstr_fr_852(char *inarray, size_t *inlen, char *outarray,
1362 1360 size_t *outlen, int flag, int *errno)
1363 1361 {
1364 1362 return (kiconvstr_fr_sb(KICONV_TBLID_852, (uchar_t *)inarray,
1365 1363 inlen, (uchar_t *)outarray, outlen, flag, errno));
1366 1364 }
1367 1365
1368 1366 static size_t
1369 1367 kiconvstr_fr_857(char *inarray, size_t *inlen, char *outarray,
1370 1368 size_t *outlen, int flag, int *errno)
1371 1369 {
1372 1370 return (kiconvstr_fr_sb(KICONV_TBLID_857, (uchar_t *)inarray,
1373 1371 inlen, (uchar_t *)outarray, outlen, flag, errno));
1374 1372 }
1375 1373
1376 1374 static size_t
1377 1375 kiconvstr_fr_862(char *inarray, size_t *inlen, char *outarray,
1378 1376 size_t *outlen, int flag, int *errno)
1379 1377 {
1380 1378 return (kiconvstr_fr_sb(KICONV_TBLID_862, (uchar_t *)inarray,
1381 1379 inlen, (uchar_t *)outarray, outlen, flag, errno));
1382 1380 }
1383 1381
1384 1382 static size_t
1385 1383 kiconvstr_fr_866(char *inarray, size_t *inlen, char *outarray,
1386 1384 size_t *outlen, int flag, int *errno)
1387 1385 {
1388 1386 return (kiconvstr_fr_sb(KICONV_TBLID_866, (uchar_t *)inarray,
1389 1387 inlen, (uchar_t *)outarray, outlen, flag, errno));
1390 1388 }
1391 1389
1392 1390 static size_t
1393 1391 kiconvstr_fr_1250(char *inarray, size_t *inlen, char *outarray,
1394 1392 size_t *outlen, int flag, int *errno)
1395 1393 {
1396 1394 return (kiconvstr_fr_sb(KICONV_TBLID_1250, (uchar_t *)inarray,
1397 1395 inlen, (uchar_t *)outarray, outlen, flag, errno));
1398 1396 }
1399 1397
1400 1398 static size_t
1401 1399 kiconvstr_fr_1251(char *inarray, size_t *inlen, char *outarray,
1402 1400 size_t *outlen, int flag, int *errno)
1403 1401 {
1404 1402 return (kiconvstr_fr_sb(KICONV_TBLID_1251, (uchar_t *)inarray,
1405 1403 inlen, (uchar_t *)outarray, outlen, flag, errno));
1406 1404 }
1407 1405
1408 1406 static size_t
1409 1407 kiconvstr_fr_1253(char *inarray, size_t *inlen, char *outarray,
1410 1408 size_t *outlen, int flag, int *errno)
1411 1409 {
1412 1410 return (kiconvstr_fr_sb(KICONV_TBLID_1253, (uchar_t *)inarray,
1413 1411 inlen, (uchar_t *)outarray, outlen, flag, errno));
1414 1412 }
1415 1413
1416 1414 static size_t
1417 1415 kiconvstr_fr_1254(char *inarray, size_t *inlen, char *outarray,
1418 1416 size_t *outlen, int flag, int *errno)
1419 1417 {
1420 1418 return (kiconvstr_fr_sb(KICONV_TBLID_1254, (uchar_t *)inarray,
1421 1419 inlen, (uchar_t *)outarray, outlen, flag, errno));
1422 1420 }
1423 1421
1424 1422 static size_t
1425 1423 kiconvstr_fr_1255(char *inarray, size_t *inlen, char *outarray,
1426 1424 size_t *outlen, int flag, int *errno)
1427 1425 {
1428 1426 return (kiconvstr_fr_sb(KICONV_TBLID_1255, (uchar_t *)inarray,
1429 1427 inlen, (uchar_t *)outarray, outlen, flag, errno));
1430 1428 }
1431 1429
1432 1430 static size_t
1433 1431 kiconvstr_fr_1256(char *inarray, size_t *inlen, char *outarray,
1434 1432 size_t *outlen, int flag, int *errno)
1435 1433 {
1436 1434 return (kiconvstr_fr_sb(KICONV_TBLID_1256, (uchar_t *)inarray,
1437 1435 inlen, (uchar_t *)outarray, outlen, flag, errno));
1438 1436 }
1439 1437
1440 1438 static size_t
1441 1439 kiconvstr_fr_1257(char *inarray, size_t *inlen, char *outarray,
1442 1440 size_t *outlen, int flag, int *errno)
1443 1441 {
1444 1442 return (kiconvstr_fr_sb(KICONV_TBLID_1257, (uchar_t *)inarray,
1445 1443 inlen, (uchar_t *)outarray, outlen, flag, errno));
1446 1444 }
1447 1445
1448 1446 static size_t
1449 1447 kiconvstr_fr_88592(char *inarray, size_t *inlen, char *outarray,
1450 1448 size_t *outlen, int flag, int *errno)
1451 1449 {
1452 1450 return (kiconvstr_fr_sb(KICONV_TBLID_8859_2, (uchar_t *)inarray,
1453 1451 inlen, (uchar_t *)outarray, outlen, flag, errno));
1454 1452 }
1455 1453
1456 1454 static size_t
1457 1455 kiconvstr_fr_88593(char *inarray, size_t *inlen, char *outarray,
1458 1456 size_t *outlen, int flag, int *errno)
1459 1457 {
1460 1458 return (kiconvstr_fr_sb(KICONV_TBLID_8859_3, (uchar_t *)inarray,
1461 1459 inlen, (uchar_t *)outarray, outlen, flag, errno));
1462 1460 }
1463 1461
1464 1462 static size_t
1465 1463 kiconvstr_fr_88594(char *inarray, size_t *inlen, char *outarray,
1466 1464 size_t *outlen, int flag, int *errno)
1467 1465 {
1468 1466 return (kiconvstr_fr_sb(KICONV_TBLID_8859_4, (uchar_t *)inarray,
1469 1467 inlen, (uchar_t *)outarray, outlen, flag, errno));
1470 1468 }
1471 1469
1472 1470 static size_t
1473 1471 kiconvstr_fr_88595(char *inarray, size_t *inlen, char *outarray,
1474 1472 size_t *outlen, int flag, int *errno)
1475 1473 {
1476 1474 return (kiconvstr_fr_sb(KICONV_TBLID_8859_5, (uchar_t *)inarray,
1477 1475 inlen, (uchar_t *)outarray, outlen, flag, errno));
1478 1476 }
1479 1477
1480 1478 static size_t
1481 1479 kiconvstr_fr_88596(char *inarray, size_t *inlen, char *outarray,
1482 1480 size_t *outlen, int flag, int *errno)
1483 1481 {
1484 1482 return (kiconvstr_fr_sb(KICONV_TBLID_8859_6, (uchar_t *)inarray,
1485 1483 inlen, (uchar_t *)outarray, outlen, flag, errno));
1486 1484 }
1487 1485
1488 1486 static size_t
1489 1487 kiconvstr_fr_88597(char *inarray, size_t *inlen, char *outarray,
1490 1488 size_t *outlen, int flag, int *errno)
1491 1489 {
1492 1490 return (kiconvstr_fr_sb(KICONV_TBLID_8859_7, (uchar_t *)inarray,
1493 1491 inlen, (uchar_t *)outarray, outlen, flag, errno));
1494 1492 }
1495 1493
1496 1494 static size_t
1497 1495 kiconvstr_fr_88598(char *inarray, size_t *inlen, char *outarray,
1498 1496 size_t *outlen, int flag, int *errno)
1499 1497 {
1500 1498 return (kiconvstr_fr_sb(KICONV_TBLID_8859_8, (uchar_t *)inarray,
1501 1499 inlen, (uchar_t *)outarray, outlen, flag, errno));
1502 1500 }
1503 1501
1504 1502 static size_t
1505 1503 kiconvstr_fr_88599(char *inarray, size_t *inlen, char *outarray,
1506 1504 size_t *outlen, int flag, int *errno)
1507 1505 {
1508 1506 return (kiconvstr_fr_sb(KICONV_TBLID_8859_9, (uchar_t *)inarray,
1509 1507 inlen, (uchar_t *)outarray, outlen, flag, errno));
1510 1508 }
1511 1509
1512 1510 static size_t
1513 1511 kiconvstr_fr_885910(char *inarray, size_t *inlen, char *outarray,
1514 1512 size_t *outlen, int flag, int *errno)
1515 1513 {
1516 1514 return (kiconvstr_fr_sb(KICONV_TBLID_8859_10, (uchar_t *)inarray,
1517 1515 inlen, (uchar_t *)outarray, outlen, flag, errno));
1518 1516 }
1519 1517
1520 1518 static size_t
1521 1519 kiconvstr_fr_885911(char *inarray, size_t *inlen, char *outarray,
1522 1520 size_t *outlen, int flag, int *errno)
1523 1521 {
1524 1522 return (kiconvstr_fr_sb(KICONV_TBLID_8859_11, (uchar_t *)inarray,
1525 1523 inlen, (uchar_t *)outarray, outlen, flag, errno));
1526 1524 }
1527 1525
1528 1526 static size_t
1529 1527 kiconvstr_fr_885913(char *inarray, size_t *inlen, char *outarray,
1530 1528 size_t *outlen, int flag, int *errno)
1531 1529 {
1532 1530 return (kiconvstr_fr_sb(KICONV_TBLID_8859_13, (uchar_t *)inarray,
1533 1531 inlen, (uchar_t *)outarray, outlen, flag, errno));
1534 1532 }
1535 1533
1536 1534 static size_t
1537 1535 kiconvstr_fr_koi8r(char *inarray, size_t *inlen, char *outarray,
1538 1536 size_t *outlen, int flag, int *errno)
1539 1537 {
1540 1538 return (kiconvstr_fr_sb(KICONV_TBLID_KOI8_R, (uchar_t *)inarray,
1541 1539 inlen, (uchar_t *)outarray, outlen, flag, errno));
1542 1540 }
1543 1541
1544 1542
1545 1543 /*
1546 1544 * The following are the supported code conversions that will be passed to
1547 1545 * and registered from this module. The tocode and fromcode names are
1548 1546 * normalized.
1549 1547 */
1550 1548 #define KICONV_MAX_EMEA_OPS 50
1551 1549
1552 1550 static kiconv_ops_t kiconv_emea_ops[KICONV_MAX_EMEA_OPS] = {
1553 1551 {
1554 1552 "utf8", "cp1250",
1555 1553 open_fr_1250, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_1250
1556 1554 },
1557 1555 {
1558 1556 "cp1250", "utf8",
1559 1557 open_to_1250, kiconv_to_sb, close_to_sb, kiconvstr_to_1250
1560 1558 },
1561 1559 {
1562 1560 "utf8", "iso88592",
1563 1561 open_fr_88592, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_88592
1564 1562 },
1565 1563 {
1566 1564 "iso88592", "utf8",
1567 1565 open_to_88592, kiconv_to_sb, close_to_sb, kiconvstr_to_88592
1568 1566 },
1569 1567 {
1570 1568 "utf8", "cp852",
1571 1569 open_fr_852, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_852
1572 1570 },
1573 1571 {
1574 1572 "cp852", "utf8",
1575 1573 open_to_852, kiconv_to_sb, close_to_sb, kiconvstr_to_852
1576 1574 },
1577 1575 {
1578 1576 "utf8", "cp1251",
1579 1577 open_fr_1251, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_1251
1580 1578 },
1581 1579 {
1582 1580 "cp1251", "utf8",
1583 1581 open_to_1251, kiconv_to_sb, close_to_sb, kiconvstr_to_1251
1584 1582 },
1585 1583 {
1586 1584 "utf8", "iso88595",
1587 1585 open_fr_88595, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_88595
1588 1586 },
1589 1587 {
1590 1588 "iso88595", "utf8",
1591 1589 open_to_88595, kiconv_to_sb, close_to_sb, kiconvstr_to_88595
1592 1590 },
1593 1591 {
1594 1592 "utf8", "koi8r",
1595 1593 open_fr_koi8r, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_koi8r
1596 1594 },
1597 1595 {
1598 1596 "koi8r", "utf8",
1599 1597 open_to_koi8r, kiconv_to_sb, close_to_sb, kiconvstr_to_koi8r
1600 1598 },
1601 1599 {
1602 1600 "utf8", "cp866",
1603 1601 open_fr_866, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_866
1604 1602 },
1605 1603 {
1606 1604 "cp866", "utf8",
1607 1605 open_to_866, kiconv_to_sb, close_to_sb, kiconvstr_to_866
1608 1606 },
1609 1607 {
1610 1608 "utf8", "cp1253",
1611 1609 open_fr_1253, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_1253
1612 1610 },
1613 1611 {
1614 1612 "cp1253", "utf8",
1615 1613 open_to_1253, kiconv_to_sb, close_to_sb, kiconvstr_to_1253
1616 1614 },
1617 1615 {
1618 1616 "utf8", "iso88597",
1619 1617 open_fr_88597, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_88597
1620 1618 },
1621 1619 {
1622 1620 "iso88597", "utf8",
1623 1621 open_to_88597, kiconv_to_sb, close_to_sb, kiconvstr_to_88597
1624 1622 },
1625 1623 {
1626 1624 "utf8", "cp737",
1627 1625 open_fr_737, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_737
1628 1626 },
1629 1627 {
1630 1628 "cp737", "utf8",
1631 1629 open_to_737, kiconv_to_sb, close_to_sb, kiconvstr_to_737
1632 1630 },
1633 1631 {
1634 1632 "utf8", "cp1254",
1635 1633 open_fr_1254, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_1254
1636 1634 },
1637 1635 {
1638 1636 "cp1254", "utf8",
1639 1637 open_to_1254, kiconv_to_sb, close_to_sb, kiconvstr_to_1254
1640 1638 },
1641 1639 {
1642 1640 "utf8", "iso88599",
1643 1641 open_fr_88599, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_88599
1644 1642 },
1645 1643 {
1646 1644 "iso88599", "utf8",
1647 1645 open_to_88599, kiconv_to_sb, close_to_sb, kiconvstr_to_88599
1648 1646 },
1649 1647 {
1650 1648 "utf8", "cp857",
1651 1649 open_fr_857, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_857
1652 1650 },
1653 1651 {
1654 1652 "cp857", "utf8",
1655 1653 open_to_857, kiconv_to_sb, close_to_sb, kiconvstr_to_857
1656 1654 },
1657 1655 {
1658 1656 "utf8", "cp1256",
1659 1657 open_fr_1256, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_1256
1660 1658 },
1661 1659 {
1662 1660 "cp1256", "utf8",
1663 1661 open_to_1256, kiconv_to_sb, close_to_sb, kiconvstr_to_1256
1664 1662 },
1665 1663 {
1666 1664 "utf8", "iso88596",
1667 1665 open_fr_88596, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_88596
1668 1666 },
1669 1667 {
1670 1668 "iso88596", "utf8",
1671 1669 open_to_88596, kiconv_to_sb, close_to_sb, kiconvstr_to_88596
1672 1670 },
1673 1671 {
1674 1672 "utf8", "cp720",
1675 1673 open_fr_720, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_720
1676 1674 },
1677 1675 {
1678 1676 "cp720", "utf8",
1679 1677 open_to_720, kiconv_to_sb, close_to_sb, kiconvstr_to_720
1680 1678 },
1681 1679 {
1682 1680 "utf8", "cp1255",
1683 1681 open_fr_1255, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_1255
1684 1682 },
1685 1683 {
1686 1684 "cp1255", "utf8",
1687 1685 open_to_1255, kiconv_to_sb, close_to_sb, kiconvstr_to_1255
1688 1686 },
1689 1687 {
1690 1688 "utf8", "iso88598",
1691 1689 open_fr_88598, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_88598
1692 1690 },
1693 1691 {
1694 1692 "iso88598", "utf8",
1695 1693 open_to_88598, kiconv_to_sb, close_to_sb, kiconvstr_to_88598
1696 1694 },
1697 1695 {
1698 1696 "utf8", "cp862",
1699 1697 open_fr_862, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_862
1700 1698 },
1701 1699 {
1702 1700 "cp862", "utf8",
1703 1701 open_to_862, kiconv_to_sb, close_to_sb, kiconvstr_to_862
1704 1702 },
1705 1703 {
1706 1704 "utf8", "cp1257",
1707 1705 open_fr_1257, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_1257
1708 1706 },
1709 1707 {
1710 1708 "cp1257", "utf8",
1711 1709 open_to_1257, kiconv_to_sb, close_to_sb, kiconvstr_to_1257
1712 1710 },
1713 1711 {
1714 1712 "utf8", "iso885913",
1715 1713 open_fr_885913, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_885913
1716 1714 },
1717 1715 {
1718 1716 "iso885913", "utf8",
1719 1717 open_to_885913, kiconv_to_sb, close_to_sb, kiconvstr_to_885913
1720 1718 },
1721 1719 {
1722 1720 "utf8", "iso885910",
1723 1721 open_fr_885910, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_885910
1724 1722 },
1725 1723 {
1726 1724 "iso885910", "utf8",
1727 1725 open_to_885910, kiconv_to_sb, close_to_sb, kiconvstr_to_885910
1728 1726 },
1729 1727 {
1730 1728 "utf8", "iso885911",
1731 1729 open_fr_885911, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_885911
1732 1730 },
1733 1731 {
1734 1732 "iso885911", "utf8",
1735 1733 open_to_885911, kiconv_to_sb, close_to_sb, kiconvstr_to_885911
1736 1734 },
1737 1735 {
1738 1736 "utf8", "iso88593",
1739 1737 open_fr_88593, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_88593
1740 1738 },
1741 1739 {
1742 1740 "iso88593", "utf8",
1743 1741 open_to_88593, kiconv_to_sb, close_to_sb, kiconvstr_to_88593
1744 1742 },
1745 1743 {
1746 1744 "utf8", "iso88594",
1747 1745 open_fr_88594, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_88594
1748 1746 },
1749 1747 {
1750 1748 "iso88594", "utf8",
1751 1749 open_to_88594, kiconv_to_sb, close_to_sb, kiconvstr_to_88594
1752 1750 },
1753 1751 };
1754 1752
1755 1753 static kiconv_module_info_t kiconv_emea_modinfo = {
1756 1754 "kiconv_emea", /* Must be the same as in kiconv framework. */
1757 1755 KICONV_MAX_EMEA_OPS, /* size_t kiconv_num_convs */
1758 1756 kiconv_emea_ops, /* kiconv_ops_t *kiconv_ops_tbl */
1759 1757 0, /* size_t kiconv_num_aliases */
1760 1758 NULL, /* char **aliases */
1761 1759 NULL, /* char **canonicals */
1762 1760 0 /* int nowait */
↓ open down ↓ |
1725 lines elided |
↑ open up ↑ |
1763 1761 };
1764 1762
1765 1763 static struct modlkiconv kiconv_emea = {
1766 1764 &mod_kiconvops,
1767 1765 "kiconv module for EMEA",
1768 1766 &kiconv_emea_modinfo
1769 1767 };
1770 1768
1771 1769 static struct modlinkage linkage = {
1772 1770 MODREV_1,
1773 - (void *)&kiconv_emea,
1774 - NULL
1771 + { (void *)&kiconv_emea, NULL }
1775 1772 };
1776 1773
1777 1774 int
1778 1775 _init()
1779 1776 {
1780 1777 int err;
1781 1778
1782 1779 err = mod_install(&linkage);
1783 1780 if (err)
1784 1781 cmn_err(CE_WARN, "kiconv_emea: failed to load kernel module");
1785 1782
1786 1783 return (err);
1787 1784 }
1788 1785
1789 1786 int
1790 1787 _info(struct modinfo *modinfop)
1791 1788 {
1792 1789 return (mod_info(&linkage, modinfop));
1793 1790 }
1794 1791
1795 1792 int
1796 1793 _fini()
1797 1794 {
1798 1795 int err;
1799 1796
1800 1797 /*
1801 1798 * If this module is being used, then, we cannot remove the module.
1802 1799 * The following checking will catch pretty much all usual cases.
1803 1800 *
1804 1801 * Any remaining will be catached by the kiconv_unregister_module()
1805 1802 * during mod_remove() at below.
1806 1803 */
1807 1804 if (kiconv_module_ref_count(KICONV_MODULE_ID_EMEA))
1808 1805 return (EBUSY);
1809 1806
1810 1807 err = mod_remove(&linkage);
1811 1808 if (err)
1812 1809 cmn_err(CE_WARN, "kiconv_emea: failed to remove kernel module");
1813 1810
1814 1811 return (err);
1815 1812 }
↓ open down ↓ |
31 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX