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