Debian Codegraph @

src/pin-juyin.c

raw symbols SCIP
1 /* Copyright (C) 2011 Edward Der-Hua Liu, Hsin-Chu, Taiwan
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation version 2.1
6 * of the License.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17
18 #include <stdio.h>
19
20 #include "hime.h"
21
22 #include "pho.h"
23
24 int main () {
25 FILE *fp;
26 char fnamein[] = "pin-juyin.src";
27 PIN_JUYIN pinju[1024] = {0};
28 short pinjuN = 0;
29
30 if ((fp = fopen (fnamein, "r")) == NULL)
31 p_err ("cannot open %s", fnamein);
32
33 while (!feof (fp)) {
34 char tt[128];
35
36 tt[0] = 0;
37 fgets (tt, sizeof (tt), fp);
38 if (strlen (tt) < 3)
39 break;
40
41 char pin[16], ju[64];
42 memset (pin, 0, sizeof (pin));
43 sscanf (tt, "%s %s", pin, ju);
44
45 phokey_t kk = 0;
46 int len = strlen (ju);
47 int i = 0;
48 while (i < len) {
49 kk |= lookup ((u_char *) &ju[i]);
50 i += utf8_sz (&ju[i]);
51 }
52
53 // dbg("%s '%s' %d\n", pin, ju, kk);
54
55 memcpy (pinju[pinjuN].pinyin, pin, sizeof (pinju[0].pinyin));
56 pinju[pinjuN].key = kk;
57 pinjuN++;
58 }
59
60 fclose (fp);
61 dbg ("zz pinjuN:%d\n", pinjuN);
62
63 char fnameout[] = "pin-juyin.xlt";
64
65 if ((fp = fopen (fnameout, "wb")) == NULL)
66 p_err ("cannot create %s", fnameout);
67
68 fwrite (&pinjuN, sizeof (pinjuN), 1, fp);
69 fwrite (pinju, sizeof (PIN_JUYIN), pinjuN, fp);
70 fclose (fp);
71
72 return 0;
73 }