Add __syscall_execve prototype.
[glibc.git] / iconvdata / iso-2022-jp.c
blob669b65afaed47a6798761afc06de600243ceaa5f
1 /* Conversion module for ISO-2022-JP.
2 Copyright (C) 1998, 1999 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public License as
8 published by the Free Software Foundation; either version 2 of the
9 License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public
17 License along with the GNU C Library; see the file COPYING.LIB. If not,
18 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
21 #include <gconv.h>
22 #include <stdint.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include "jis0201.h"
26 #include "jis0208.h"
27 #include "jis0212.h"
28 #include "gb2312.h"
29 #include "ksc5601.h"
31 struct gap
33 uint16_t start;
34 uint16_t end;
35 int32_t idx;
38 #include "iso8859-7jp.h"
40 /* This makes obvious what everybody knows: 0x1b is the Esc character. */
41 #define ESC 0x1b
43 /* We provide our own initialization and destructor function. */
44 #define DEFINE_INIT 0
45 #define DEFINE_FINI 0
47 /* Definitions used in the body of the `gconv' function. */
48 #define FROM_LOOP from_iso2022jp_loop
49 #define TO_LOOP to_iso2022jp_loop
50 #define MIN_NEEDED_FROM 1
51 #define MAX_NEEDED_FROM 4
52 #define MIN_NEEDED_TO 4
53 #define MAX_NEEDED_TO 4
54 #define FROM_DIRECTION (dir == from_iso2022jp)
55 #define PREPARE_LOOP \
56 enum direction dir = ((struct iso2022jp_data *) step->__data)->dir; \
57 enum variant var = ((struct iso2022jp_data *) step->__data)->var; \
58 int save_set; \
59 int *setp = &data->__statep->count;
60 #define EXTRA_LOOP_ARGS , var, setp
63 /* Direction of the transformation. */
64 enum direction
66 illegal_dir,
67 to_iso2022jp,
68 from_iso2022jp
71 /* We handle ISO-2022-jp and ISO-2022-JP-2 here. */
72 enum variant
74 illegal_var,
75 iso2022jp,
76 iso2022jp2
80 struct iso2022jp_data
82 enum direction dir;
83 enum variant var;
87 /* The COUNT element of the state keeps track of the currently selected
88 character set. The possible values are: */
89 enum
91 ASCII_set = 0,
92 JISX0208_1978_set,
93 JISX0208_1983_set,
94 JISX0201_Roman_set,
95 JISX0201_Kana_set,
96 GB2312_set,
97 KSC5601_set,
98 JISX0212_set
101 /* The second value stored is the designation of the G2 set. The following
102 values are possible: */
103 enum
105 UNSPECIFIED_set = 0,
106 ISO88591_set,
107 ISO88597_set
112 gconv_init (struct __gconv_step *step)
114 /* Determine which direction. */
115 struct iso2022jp_data *new_data;
116 enum direction dir = illegal_dir;
117 enum variant var = illegal_var;
118 int result;
120 if (__strcasecmp (step->__from_name, "ISO-2022-JP//") == 0)
122 dir = from_iso2022jp;
123 var = iso2022jp;
125 else if (__strcasecmp (step->__to_name, "ISO-2022-JP//") == 0)
127 dir = to_iso2022jp;
128 var = iso2022jp;
130 else if (__strcasecmp (step->__from_name, "ISO-2022-JP-2//") == 0)
132 dir = from_iso2022jp;
133 var = iso2022jp2;
135 else if (__strcasecmp (step->__to_name, "ISO-2022-JP-2//") == 0)
137 dir = to_iso2022jp;
138 var = iso2022jp2;
141 result = __GCONV_NOCONV;
142 if (dir != illegal_dir)
144 new_data
145 = (struct iso2022jp_data *) malloc (sizeof (struct iso2022jp_data));
147 result = __GCONV_NOMEM;
148 if (new_data != NULL)
150 new_data->dir = dir;
151 new_data->var = var;
152 step->__data = new_data;
154 if (dir == from_iso2022jp)
156 step->__min_needed_from = MIN_NEEDED_FROM;
157 step->__max_needed_from = MAX_NEEDED_FROM;
158 step->__min_needed_to = MIN_NEEDED_TO;
159 step->__max_needed_to = MAX_NEEDED_TO;
161 else
163 step->__min_needed_from = MIN_NEEDED_TO;
164 step->__max_needed_from = MAX_NEEDED_TO;
165 step->__min_needed_to = MIN_NEEDED_FROM;
166 step->__max_needed_to = MAX_NEEDED_FROM + 2;
169 /* Yes, this is a stateful encoding. */
170 step->__stateful = 1;
172 result = __GCONV_OK;
176 return result;
180 void
181 gconv_end (struct __gconv_step *data)
183 free (data->__data);
187 /* Since this is a stateful encoding we have to provide code which resets
188 the output state to the initial state. This has to be done during the
189 flushing. */
190 #define EMIT_SHIFT_TO_INIT \
191 if (data->__statep->count != ASCII_set) \
193 enum direction dir = ((struct iso2022jp_data *) step->__data)->dir; \
195 if (dir == from_iso2022jp) \
196 /* It's easy, we don't have to emit anything, we just reset the \
197 state for the input. Note that this also clears the G2 \
198 designation. */ \
199 data->__statep->count = ASCII_set; \
200 else \
202 unsigned char *outbuf = data->__outbuf; \
204 /* We are not in the initial state. To switch back we have \
205 to emit the sequence `Esc ( B'. */ \
206 if (outbuf + 3 > data->__outbufend) \
207 /* We don't have enough room in the output buffer. */ \
208 status = __GCONV_FULL_OUTPUT; \
209 else \
211 /* Write out the shift sequence. */ \
212 *outbuf++ = ESC; \
213 *outbuf++ = '('; \
214 *outbuf++ = 'B'; \
215 data->__outbuf = outbuf; \
216 /* Note that this also clears the G2 designation. */ \
217 data->__statep->count = ASCII_set; \
223 /* Since we might have to reset input pointer we must be able to save
224 and retore the state. */
225 #define SAVE_RESET_STATE(Save) \
226 if (Save) \
227 save_set = *setp; \
228 else \
229 *setp = save_set
232 /* First define the conversion function from ISO-2022-JP to UCS4. */
233 #define MIN_NEEDED_INPUT MIN_NEEDED_FROM
234 #define MAX_NEEDED_INPUT MAX_NEEDED_FROM
235 #define MIN_NEEDED_OUTPUT MIN_NEEDED_TO
236 #define LOOPFCT FROM_LOOP
237 #define BODY \
239 uint32_t ch = *inptr; \
241 /* Recognize escape sequences. */ \
242 if (ch == ESC) \
244 /* We now must be prepared to read two to three more \
245 chracters. If we have a match in the first character but \
246 then the input buffer ends we terminate with an error since \
247 we must not risk missing an escape sequence just because it \
248 is not entirely in the current input buffer. */ \
249 if (inptr + 2 >= inend \
250 || (var == iso2022jp2 && inptr[1] == '$' && inptr[2] == '(' \
251 && inptr + 3 >= inend)) \
253 /* Not enough input available. */ \
254 result = __GCONV_EMPTY_INPUT; \
255 break; \
258 if (inptr[1] == '(') \
260 if (inptr[2] == 'B') \
262 /* ASCII selected. */ \
263 set = ASCII_set; \
264 inptr += 3; \
265 continue; \
267 else if (inptr[2] == 'J') \
269 /* JIS X 0201 selected. */ \
270 set = JISX0201_Roman_set; \
271 inptr += 3; \
272 continue; \
274 else if (var == iso2022jp2 && inptr[2] == 'I') \
276 /* JIS X 0201 selected. */ \
277 set = JISX0201_Kana_set; \
278 inptr += 3; \
279 continue; \
282 else if (inptr[1] == '$') \
284 if (inptr[2] == '@') \
286 /* JIS X 0208-1978 selected. */ \
287 set = JISX0208_1978_set; \
288 inptr += 3; \
289 continue; \
291 else if (inptr[2] == 'B') \
293 /* JIS X 0208-1983 selected. */ \
294 set = JISX0208_1983_set; \
295 inptr += 3; \
296 continue; \
298 else if (var == iso2022jp2) \
300 if (inptr[2] == 'A') \
302 /* GB 2312-1980 selected. */ \
303 set = GB2312_set; \
304 inptr += 3; \
305 continue; \
307 else if (inptr[2] == '(') \
309 if (inptr[3] == 'C') \
311 /* KSC 5601-1987 selected. */ \
312 set = KSC5601_set; \
313 inptr += 4; \
314 continue; \
316 else if (inptr[3] == 'D') \
318 /* JIS X 0212-1990 selected. */ \
319 set = JISX0212_set; \
320 inptr += 4; \
321 continue; \
326 else if (var == iso2022jp2 && inptr[1] == '.') \
328 if (inptr[2] == 'A') \
330 /* ISO 8859-1-GR selected. */ \
331 set2 = ISO88591_set; \
332 inptr += 3; \
333 continue; \
335 else if (inptr[2] == 'F') \
337 /* ISO 8859-7-GR selected. */ \
338 set2 = ISO88597_set; \
339 inptr += 3; \
340 continue; \
345 if (ch == ESC && var == iso2022jp2 && inptr[1] == 'N') \
347 if (set2 == ISO88591_set) \
349 ch = inptr[2] | 0x80; \
350 inptr += 3; \
352 else if (set2 == ISO88597_set) \
354 /* We use the table from the ISO 8859-7 module. */ \
355 if (inptr[2] < 0x20 || inptr[2] > 0x80) \
357 result = __GCONV_ILLEGAL_INPUT; \
358 break; \
360 ch = iso88597_to_ucs4[inptr[2] - 0x20]; \
361 if (ch == 0) \
363 result = __GCONV_ILLEGAL_INPUT; \
364 break; \
366 inptr += 3; \
368 else \
370 result = __GCONV_ILLEGAL_INPUT; \
371 break; \
374 else if (set == ASCII_set || (ch < 0x21 || ch == 0x7f)) \
375 /* Almost done, just advance the input pointer. */ \
376 ++inptr; \
377 else if (set == JISX0201_Roman_set) \
379 /* Use the JIS X 0201 table. */ \
380 ch = jisx0201_to_ucs4 (ch); \
381 if (ch == __UNKNOWN_10646_CHAR) \
383 result = __GCONV_ILLEGAL_INPUT; \
384 break; \
386 ++inptr; \
388 else if (set == JISX0201_Kana_set) \
390 /* Use the JIS X 0201 table. */ \
391 ch = jisx0201_to_ucs4 (ch + 0x80); \
392 if (ch == __UNKNOWN_10646_CHAR) \
394 result = __GCONV_ILLEGAL_INPUT; \
395 break; \
397 ++inptr; \
399 else \
401 if (set == JISX0208_1978_set || set == JISX0208_1983_set) \
402 /* XXX I don't have the tables for these two old variants of \
403 JIS X 0208. Therefore I'm using the tables for JIS X \
404 0208-1990. If somebody has problems with this please \
405 provide the appropriate tables. */ \
406 ch = jisx0208_to_ucs4 (&inptr, \
407 NEED_LENGTH_TEST ? inend - inptr : 2, 0); \
408 else if (set == JISX0212_set) \
409 /* Use the JIS X 0212 table. */ \
410 ch = jisx0212_to_ucs4 (&inptr, \
411 NEED_LENGTH_TEST ? inend - inptr : 2, 0); \
412 else if (set == GB2312_set) \
413 /* Use the GB 2312 table. */ \
414 ch = gb2312_to_ucs4 (&inptr, \
415 NEED_LENGTH_TEST ? inend - inptr : 2, 0); \
416 else \
418 assert (set == KSC5601_set); \
420 /* Use the KSC 5601 table. */ \
421 ch = ksc5601_to_ucs4 (&inptr, \
422 NEED_LENGTH_TEST ? inend - inptr : 2, 0); \
425 if (NEED_LENGTH_TEST && ch == 0) \
427 result = __GCONV_EMPTY_INPUT; \
428 break; \
430 else if (ch == __UNKNOWN_10646_CHAR) \
432 result = __GCONV_ILLEGAL_INPUT; \
433 break; \
437 *((uint32_t *) outptr)++ = ch; \
439 #define EXTRA_LOOP_DECLS , enum variant var, int *setp
440 #define INIT_PARAMS int set = *setp % 0x100, set2 = *setp / 0x100
441 #define UPDATE_PARAMS *setp = (set2 << 8) + set
442 #include <iconv/loop.c>
445 /* Next, define the other direction. */
446 #define MIN_NEEDED_INPUT MIN_NEEDED_TO
447 #define MIN_NEEDED_OUTPUT MIN_NEEDED_FROM
448 #define MAX_NEEDED_OUTPUT (MAX_NEEDED_FROM + 2)
449 #define LOOPFCT TO_LOOP
450 #define BODY \
452 uint32_t ch; \
453 size_t written = 0; \
455 ch = *((uint32_t *) inptr); \
457 /* First see whether we can write the character using the currently \
458 selected character set. */ \
459 if (set == ASCII_set) \
461 /* Please note that the NUL byte is *not* matched if we are not \
462 currently using the ASCII charset. This is because we must \
463 switch to the initial state whenever a NUL byte is written. */ \
464 if (ch <= 0x7f) \
466 *outptr++ = ch; \
467 written = 1; \
469 /* At the beginning of a line, G2 designation is cleared. */ \
470 if (var == iso2022jp2 && ch == 0x0a) \
471 set2 = UNSPECIFIED_set; \
473 /* ISO-2022-JP recommends to encode the newline character always in \
474 ASCII since this allows a context-free interpretation of the \
475 characters at the beginning of the next line. Otherwise it would \
476 have to be known whether the last line ended using ASCII or \
477 JIS X 0201. */ \
478 else if (set == JISX0201_Roman_set) \
480 unsigned char buf[2]; \
481 written = ucs4_to_jisx0201 (ch, buf); \
482 if (written != __UNKNOWN_10646_CHAR && buf[0] > 0x20 \
483 && buf[0] < 0x80) \
485 *outptr++ = buf[0]; \
486 written = 1; \
488 else \
489 written = __UNKNOWN_10646_CHAR; \
491 else if (set == JISX0201_Kana_set) \
493 unsigned char buf[2]; \
494 written = ucs4_to_jisx0201 (ch, buf); \
495 if (written != __UNKNOWN_10646_CHAR && buf[0] > 0xa0 \
496 && buf[0] < 0xe0) \
498 *outptr++ = buf[0] - 0x80; \
499 written = 1; \
501 else \
502 written = __UNKNOWN_10646_CHAR; \
504 else \
506 if (set == JISX0208_1978_set || set == JISX0208_1983_set) \
507 written = ucs4_to_jisx0208 (ch, outptr, \
508 (NEED_LENGTH_TEST \
509 ? outend - outptr : 2)); \
510 else if (set == JISX0212_set) \
511 written = ucs4_to_jisx0212 (ch, outptr, \
512 (NEED_LENGTH_TEST \
513 ? outend - outptr : 2)); \
514 else if (set == GB2312_set) \
515 written = ucs4_to_gb2312 (ch, outptr, (NEED_LENGTH_TEST \
516 ? outend - outptr : 2)); \
517 else \
519 assert (set == KSC5601_set); \
521 written = ucs4_to_ksc5601 (ch, outptr, \
522 (NEED_LENGTH_TEST \
523 ? outend - outptr : 2)); \
526 if (NEED_LENGTH_TEST && written == 0) \
528 result = __GCONV_FULL_OUTPUT; \
529 break; \
531 else if (written != __UNKNOWN_10646_CHAR) \
532 outptr += written; \
535 if (written == __UNKNOWN_10646_CHAR || written == 0) \
537 if (set2 == ISO88591_set) \
539 if (ch >= 0x80 && ch <= 0xff) \
541 *outptr++ = ESC; \
542 *outptr++ = 'N'; \
543 *outptr++ = ch & 0x7f; \
544 written = 3; \
547 else if (set2 == ISO88597_set) \
549 const struct gap *rp = from_idx; \
551 while (ch > rp->end) \
552 ++rp; \
553 if (ch >= rp->start) \
555 unsigned char res = iso88597_from_ucs4[ch - 0xa0 + rp->idx]; \
556 if (res != '\0') \
558 *outptr++ = ESC; \
559 *outptr++ = 'N'; \
560 *outptr++ = res; \
561 written = 3; \
567 if (written == __UNKNOWN_10646_CHAR || written == 0) \
569 /* Either this is an unknown character or we have to switch \
570 the currently selected character set. The character sets \
571 do not code entirely separate parts of ISO 10646 and \
572 therefore there is no single correct result. If we choose \
573 the character set to use wrong we might be end up with \
574 using yet another character set for the next character \
575 though the current and the next could be encoded with one \
576 character set. We leave this kind of optimization for \
577 later and now simply use a fixed order in which we test for \
578 availability */ \
580 if (ch <= 0x7f) \
582 /* We must encode using ASCII. First write out the \
583 escape sequence. */ \
584 if (NEED_LENGTH_TEST && outptr + 3 > outend) \
586 result = __GCONV_FULL_OUTPUT; \
587 break; \
590 *outptr++ = ESC; \
591 *outptr++ = '('; \
592 *outptr++ = 'B'; \
593 set = ASCII_set; \
595 if (NEED_LENGTH_TEST && outptr + 1 > outend) \
597 result = __GCONV_FULL_OUTPUT; \
598 break; \
600 *outptr++ = ch; \
602 /* At the beginning of a line, G2 designation is cleared. */ \
603 if (var == iso2022jp2 && ch == 0x0a) \
604 set2 = UNSPECIFIED_set; \
606 else \
608 /* Now it becomes difficult. We must search the other \
609 character sets one by one and we cannot use simple \
610 arithmetic to determine whether the character can be \
611 encoded using this set. */ \
612 size_t written; \
613 unsigned char buf[2]; \
615 written = ucs4_to_jisx0201 (ch, buf); \
616 if (written != __UNKNOWN_10646_CHAR && buf[0] < 0x80) \
618 /* We use JIS X 0201. */ \
619 if (NEED_LENGTH_TEST && outptr + 3 > outend) \
621 result = __GCONV_FULL_OUTPUT; \
622 break; \
625 *outptr++ = ESC; \
626 *outptr++ = '('; \
627 *outptr++ = 'J'; \
628 set = JISX0201_Roman_set; \
630 if (NEED_LENGTH_TEST && outptr + 1 > outend) \
632 result = __GCONV_FULL_OUTPUT; \
633 break; \
635 *outptr++ = buf[0]; \
637 else \
639 written = ucs4_to_jisx0208 (ch, buf, 2); \
640 if (written != __UNKNOWN_10646_CHAR) \
642 /* We use JIS X 0208. */ \
643 if (NEED_LENGTH_TEST && outptr + 3 > outend) \
645 result = __GCONV_FULL_OUTPUT; \
646 break; \
649 *outptr++ = ESC; \
650 *outptr++ = '$'; \
651 *outptr++ = 'B'; \
652 set = JISX0208_1983_set; \
654 if (NEED_LENGTH_TEST && outptr + 2 > outend) \
656 result = __GCONV_FULL_OUTPUT; \
657 break; \
659 *outptr++ = buf[0]; \
660 *outptr++ = buf[1]; \
662 else if (var == iso2022jp) \
664 /* We have no other choice. */ \
665 result = __GCONV_ILLEGAL_INPUT; \
666 break; \
668 else \
670 written = ucs4_to_jisx0212 (ch, buf, 2); \
671 if (written != __UNKNOWN_10646_CHAR) \
673 /* We use JIS X 0212. */ \
674 if (NEED_LENGTH_TEST && outptr + 4 > outend) \
676 result = __GCONV_FULL_OUTPUT; \
677 break; \
679 *outptr++ = ESC; \
680 *outptr++ = '$'; \
681 *outptr++ = '('; \
682 *outptr++ = 'D'; \
683 set = JISX0212_set; \
685 if (NEED_LENGTH_TEST && outptr + 2 > outend) \
687 result = __GCONV_FULL_OUTPUT; \
688 break; \
690 *outptr++ = buf[0]; \
691 *outptr++ = buf[1]; \
693 else \
695 written = ucs4_to_jisx0201 (ch, buf); \
696 if (written != __UNKNOWN_10646_CHAR \
697 && buf[0] >= 0x80) \
699 /* We use JIS X 0201. */ \
700 if (NEED_LENGTH_TEST && outptr + 3 > outend) \
702 result = __GCONV_FULL_OUTPUT; \
703 break; \
706 *outptr++ = ESC; \
707 *outptr++ = '('; \
708 *outptr++ = 'I'; \
709 set = JISX0201_Kana_set; \
711 if (NEED_LENGTH_TEST && outptr + 1 > outend) \
713 result = __GCONV_FULL_OUTPUT; \
714 break; \
716 *outptr++ = buf[0] - 0x80; \
718 else if (ch != 0xa5 && ch >= 0x80 && ch <= 0xff) \
720 /* ISO 8859-1 upper half. */ \
721 if (NEED_LENGTH_TEST && outptr + 3 > outend) \
723 result = __GCONV_FULL_OUTPUT; \
724 break; \
727 *outptr++ = ESC; \
728 *outptr++ = '.'; \
729 *outptr++ = 'A'; \
730 set2 = ISO88591_set; \
732 if (NEED_LENGTH_TEST && outptr + 3 > outend) \
734 result = __GCONV_FULL_OUTPUT; \
735 break; \
737 *outptr++ = ESC; \
738 *outptr++ = 'N'; \
739 *outptr++ = ch; \
741 else \
743 written = ucs4_to_gb2312 (ch, buf, 2); \
744 if (written != __UNKNOWN_10646_CHAR) \
746 /* We use GB 2312. */ \
747 if (NEED_LENGTH_TEST && outptr + 3 > outend) \
749 result = __GCONV_FULL_OUTPUT; \
750 break; \
753 *outptr++ = ESC; \
754 *outptr++ = '$'; \
755 *outptr++ = 'A'; \
756 set = GB2312_set; \
758 if (NEED_LENGTH_TEST && outptr + 2 > outend) \
760 result = __GCONV_FULL_OUTPUT; \
761 break; \
763 *outptr++ = buf[0]; \
764 *outptr++ = buf[1]; \
766 else \
768 written = ucs4_to_ksc5601 (ch, buf, 2); \
769 if (written != __UNKNOWN_10646_CHAR) \
771 /* We use KSC 5601. */ \
772 if (NEED_LENGTH_TEST \
773 && outptr + 4 > outend) \
775 result = __GCONV_FULL_OUTPUT; \
776 break; \
778 *outptr++ = ESC; \
779 *outptr++ = '$'; \
780 *outptr++ = '('; \
781 *outptr++ = 'C'; \
782 set = KSC5601_set; \
784 if (NEED_LENGTH_TEST \
785 && outptr + 2 > outend) \
787 result = __GCONV_FULL_OUTPUT; \
788 break; \
790 *outptr++ = buf[0]; \
791 *outptr++ = buf[1]; \
793 else \
795 const struct gap *rp = from_idx; \
796 unsigned char gch = 0; \
798 while (ch > rp->end) \
799 ++rp; \
800 if (ch >= rp->start) \
802 ch = ch - 0xa0 + rp->idx; \
803 gch = iso88597_from_ucs4[ch]; \
806 if (gch != 0) \
808 /* We use ISO 8859-7 greek. */ \
809 if (NEED_LENGTH_TEST \
810 && outptr + 3 > outend) \
812 result = __GCONV_FULL_OUTPUT; \
813 break; \
815 *outptr++ = ESC; \
816 *outptr++ = '.'; \
817 *outptr++ = 'F'; \
818 set2 = ISO88597_set; \
820 if (NEED_LENGTH_TEST \
821 && outptr + 3 > outend) \
823 result = __GCONV_FULL_OUTPUT; \
824 break; \
826 *outptr++ = ESC; \
827 *outptr++ = 'N'; \
828 *outptr++ = gch; \
830 else \
832 result = __GCONV_ILLEGAL_INPUT; \
833 break; \
844 /* Now that we wrote the output increment the input pointer. */ \
845 inptr += 4; \
847 #define EXTRA_LOOP_DECLS , enum variant var, int *setp
848 #define INIT_PARAMS int set = *setp % 0x100, set2 = *setp / 0x100
849 #define UPDATE_PARAMS *setp = (set2 << 8) + set
850 #include <iconv/loop.c>
853 /* Now define the toplevel functions. */
854 #include <iconv/skeleton.c>