check.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <sys/types.h>
  4. #include <sys/stat.h>
  5. #include "kcc.h"
  6. #include "libkcc.h"
  7. unsigned KCC_check(s, extend)
  8. char *s;
  9. int extend;
  10. {
  11. register unsigned code, c;
  12. register int len;
  13. char str[LENLINE], *dummy;
  14. unsigned KCC_guess();
  15. enum mode gsmode; /* guess: M_ASCII M_KANJI M_SO */
  16. unsigned long insi; /* JIS shift-in sequence flag */
  17. unsigned long inso; /* JIS shift-out sequence flag
  18. * including "ESC(I" */
  19. unsigned long innj; /* JIS 1990 sequence flag */
  20. unsigned long ingj; /* JIS 1990 aux flag */
  21. dummy = s;
  22. code = extend ? BIT8 : BIT8 & ~DEC;
  23. gsmode = M_ASCII;
  24. insi = inso = innj = ingj = 0;
  25. while ((len = Kcc_getstr(str, sizeof str, &dummy)) != 0) {
  26. c = Kcc_guess(str, len, extend, 0, &gsmode, &insi, &inso, &innj, &ingj);
  27. code |= c & (JIS | NONASCII), code &= c | ~BIT8;
  28. if (code & NONASCII && !(code & BIT8))
  29. break;
  30. }
  31. return Kcc_showcode(code);
  32. }