Lines Matching refs:st

76 int isGB2312Char(_iconv_st * st);
77 int isBIG5Char(_iconv_st * st);
80 int gb_to_iso(_iconv_st * st, char* buf, int buflen);
81 int isGBK2(_iconv_st * st);
82 int big5_to_iso(_iconv_st * st, int unidx, unsigned long cnscode, char * buf,
86 int isGBK2(_iconv_st * st) { in isGBK2() argument
89 c0 = st->keepc[0] & ONEBYTE; in isGBK2()
90 c1 = st->keepc[1] & ONEBYTE; in isGBK2()
95 st->_errno = EILSEQ; in isGBK2()
103 _iconv_st *st; in _icv_open() local
105 if ((st = (_iconv_st *)malloc(sizeof(_iconv_st))) == NULL) { in _icv_open()
110 st->gstate = G0; in _icv_open()
111 st->istate = IN; in _icv_open()
112 st->plane = st->last_plane = -1;/* give it an invalid initnumber */ in _icv_open()
113 st->_errno = 0; in _icv_open()
114 return ((void *) st); in _icv_open()
121 void _icv_close(_iconv_st *st) { in _icv_close() argument
122 if (st == NULL) in _icv_close()
125 free(st); in _icv_close()
171 size_t _icv_iconv( _iconv_st *st, in _icv_iconv() argument
178 if (st == NULL) { in _icv_iconv()
184 if (st->gstate == G1) { in _icv_iconv()
195 st->gstate = G0; in _icv_iconv()
196 st->istate = IN; in _icv_iconv()
197 st->plane = 0; in _icv_iconv()
198 st->last_plane = 0; in _icv_iconv()
199 st->_errno = 0; in _icv_iconv()
203 errno = st->_errno = 0; /* reset internal & external errno */ in _icv_iconv()
209 switch (st->gstate) { in _icv_iconv()
212 st->keepc[0] = (**inbuf); in _icv_iconv()
213 st->gstate = G1; in _icv_iconv()
215 if (st->istate == OUT) { in _icv_iconv()
216 st->gstate = G0; in _icv_iconv()
217 st->istate = IN; in _icv_iconv()
223 errno = st->_errno = E2BIG; in _icv_iconv()
226 st->last_plane = st->plane; in _icv_iconv()
234 st->keepc[1] = (**inbuf); in _icv_iconv()
236 st->gstate = G2; in _icv_iconv()
237 } else if (!isGBK2(st)) { in _icv_iconv()
238 errno = st->_errno; in _icv_iconv()
240 } else if (isGB2312Char(st)) { in _icv_iconv()
241 st->plane = 0; /* 0 is for GB2312 */ in _icv_iconv()
242 if (st->last_plane == -1 || \ in _icv_iconv()
243 st->plane != st->last_plane) { in _icv_iconv()
245 errno = st->_errno = E2BIG; in _icv_iconv()
255 st->last_plane = st->plane; in _icv_iconv()
256 } else if (st->istate == IN) { in _icv_iconv()
261 n = gb_to_iso(st, *outbuf, *outbytesleft); in _icv_iconv()
266 errno = st->_errno; in _icv_iconv()
269 st->istate = OUT; in _icv_iconv()
270 st->gstate = G0; in _icv_iconv()
271 } else if (isBIG5Char(st)) { in _icv_iconv()
272 get_plane_no_by_big5(st, &unidx, &cnscode); in _icv_iconv()
277 if (st->last_plane != st->plane) { in _icv_iconv()
278 switch (st->plane) { in _icv_iconv()
281 st->_errno = errno = E2BIG; in _icv_iconv()
294 errno = st->_errno = E2BIG; in _icv_iconv()
314 errno = st->_errno = E2BIG; in _icv_iconv()
320 *(*outbuf + 3) = GET_PLANEC(st->plane); in _icv_iconv()
327 errno = st->_errno = EILSEQ; in _icv_iconv()
330 st->last_plane = st->plane; in _icv_iconv()
331 } else if (st->istate == IN) { in _icv_iconv()
332 switch (st->plane) { in _icv_iconv()
345 errno = st->_errno = E2BIG; in _icv_iconv()
362 errno = st->_errno = E2BIG; in _icv_iconv()
370 n = big5_to_iso(st, unidx, cnscode, in _icv_iconv()
376 errno = st->_errno; in _icv_iconv()
379 st->istate = OUT; in _icv_iconv()
380 st->gstate = G0; in _icv_iconv()
382 nonindentify: st->plane = 0; in _icv_iconv()
383 if (st->plane != st->last_plane) { in _icv_iconv()
393 st->_errno = errno = E2BIG; in _icv_iconv()
396 st->last_plane = st->plane; in _icv_iconv()
397 } else if (st->istate == IN) { in _icv_iconv()
403 st->_errno = errno = E2BIG; in _icv_iconv()
409 errno = st->_errno = E2BIG; in _icv_iconv()
416 st->istate = OUT; in _icv_iconv()
417 st->gstate = G0; in _icv_iconv()
418 st->_errno = 0; in _icv_iconv()
423 st->gstate = G3; in _icv_iconv()
425 errno = st->_errno = EILSEQ; in _icv_iconv()
431 st->plane = 0; in _icv_iconv()
432 if ( st->plane != st->last_plane ) { in _icv_iconv()
442 st->_errno = errno = E2BIG; in _icv_iconv()
445 st->last_plane = st->plane; in _icv_iconv()
446 } else if (st->istate == IN) { in _icv_iconv()
452 st->_errno = errno = E2BIG; in _icv_iconv()
458 errno = st->_errno = E2BIG; in _icv_iconv()
466 st->istate = OUT; in _icv_iconv()
467 st->gstate = G0; in _icv_iconv()
468 st->_errno = 0; in _icv_iconv()
470 errno = st->_errno = EILSEQ; in _icv_iconv()
475 st->_errno = errno = EILSEQ; in _icv_iconv()
476 st->istate = IN; in _icv_iconv()
477 st->gstate = G0; /* reset state */ in _icv_iconv()
484 if (st->_errno) { in _icv_iconv()
491 if (*inbytesleft == 0 && st->gstate != G0 ) { in _icv_iconv()
497 st->_errno = errno = E2BIG; in _icv_iconv()
504 int isGB2312Char(_iconv_st * st) { in isGB2312Char() argument
505 unsigned char buf1 = (unsigned char) (st->keepc[0] & ONEBYTE); in isGB2312Char()
506 unsigned char buf2 = (unsigned char) (st->keepc[1] & ONEBYTE); in isGB2312Char()
516 int isBIG5Char(_iconv_st * st) { in isBIG5Char() argument
518 (unsigned int) (((st->keepc[0] & ONEBYTE) << 8) | \ in isBIG5Char()
519 (st->keepc[1] & ONEBYTE)); in isBIG5Char()
532 st->keepc[0] = (unsigned char)((big5code >> 8) & ONEBYTE); in isBIG5Char()
533 st->keepc[1] = (unsigned char)(big5code & ONEBYTE); in isBIG5Char()
563 void get_plane_no_by_big5(_iconv_st * st, in get_plane_no_by_big5() argument
569 big5code = (unsigned long) ((st->keepc[0] & ONEBYTE) << 8) + \ in get_plane_no_by_big5()
570 (st->keepc[1] & ONEBYTE); in get_plane_no_by_big5()
594 st->plane = ret - 0x20; /* so that we can use GET_PLANEC() */ in get_plane_no_by_big5()
597 st->plane = 3; /* CNS 11643-1992 */ in get_plane_no_by_big5()
600 st->_errno = EILSEQ; in get_plane_no_by_big5()
603 st->_errno = 0; in get_plane_no_by_big5()
612 int big5_to_iso(_iconv_st * st, int unidx, in big5_to_iso() argument
618 st->_errno = E2BIG; in big5_to_iso()
623 st->_errno = EILSEQ; in big5_to_iso()
676 int gb_to_iso(_iconv_st * st, char* buf, int buflen) { in gb_to_iso() argument
678 st->_errno = E2BIG; in gb_to_iso()
681 *buf = st->keepc[0] & MSB_OFF; in gb_to_iso()
682 *(buf+1) = st->keepc[1] & MSB_OFF; in gb_to_iso()
688 _iconv_st * st; in main() local
716 st = _icv_open(); in main()
717 if (st == (_iconv_st *) -1) { in main()
721 if (_icv_iconv(st, &inbuf, &inlen, &outbuf, &outlen)) in main()
731 _icv_close(st); in main()