Sync with sylpheed-0.4.65cvs4 and made it compile.
[claws.git] / libkcc / showcode.c
1 #include <stdio.h>
2 #include <string.h>
3 #include <sys/types.h>
4 #include <sys/stat.h>
5
6 #include "kcc.h"
7
8 /*---------------------------------------------------------------------
9     NAME
10         showcode
11  ---------------------------------------------------------------------*/
12 int Kcc_showcode(code)
13     register unsigned code;
14 {
15     /* char *s; */
16     /*    void showjis();*/
17     int k, m;
18     /* int k, m,n; */
19
20     if (!(code & NONASCII)) {
21         /*
22          * 7-bit JIS / ASCII.
23          */
24         if (code & JIS) {
25             return JIS;
26         } else { return ASCII; }
27     } else if (code & (EUC | DEC)) {
28       k = code & EUC ? code & DEC ? EUC : EUC : DEC;
29         if (code & SJIS) {
30             /*
31              * Ambiguous.
32              */
33             if (code & JIS8) {
34                 m = code & JIS ? JIS : SJIS;
35                 if (code & ASSUME) {
36                   return code & JIS ? m : k;
37                 }
38                 return k;
39             }
40             if (code & ASSUME) { return k; }
41             return SJIS;
42         } else {
43             /*
44              * EUC/DEC.
45              */
46           return k;
47         }
48     } else if (code & JIS8) {
49         /*
50          * 8-bit JIS / shift-JIS or 8-bit JIS.
51          */
52         if (!(code & JIS))
53             return SJIS;
54         return JIS8;
55     } else if (code & SJIS)
56         /*
57          * Shift-JIS.
58          */
59       return SJIS;
60     else {
61         /*
62          * Non-ASCII deteced but neither EUC/DEC nor SJIS.
63          */
64         return BINARY;
65     }
66     if (code & JIS) {
67       return JIS;
68     }
69
70     return BINARY;
71 }