0
|
1 /*
|
|
2 * $Id: wnntouch.c,v 1.8 2004/07/19 18:24:26 hiroo Exp $
|
|
3 */
|
|
4
|
|
5 /*
|
|
6 * FreeWnn is a network-extensible Kana-to-Kanji conversion system.
|
|
7 * This file is part of FreeWnn.
|
|
8 *
|
|
9 * Copyright Kyoto University Research Institute for Mathematical Sciences
|
|
10 * 1987, 1988, 1989, 1990, 1991, 1992
|
|
11 * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991, 1992, 1999
|
|
12 * Copyright ASTEC, Inc. 1987, 1988, 1989, 1990, 1991, 1992
|
|
13 * Copyright FreeWnn Project 1999, 2000, 2002, 2004
|
|
14 *
|
|
15 * Maintainer: FreeWnn Project <freewnn@tomo.gr.jp>
|
|
16 *
|
|
17 * This program is free software; you can redistribute it and/or modify
|
|
18 * it under the terms of the GNU General Public License as published by
|
|
19 * the Free Software Foundation; either version 2 of the License, or
|
|
20 * (at your option) any later version.
|
|
21 *
|
|
22 * This program is distributed in the hope that it will be useful,
|
|
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
25 * GNU General Public License for more details.
|
|
26 *
|
|
27 * You should have received a copy of the GNU General Public License
|
|
28 * along with this program; if not, write to the Free Software
|
|
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
30 */
|
|
31
|
|
32 /*
|
|
33 * 辞書のヘッダを書き換えて、辞書の inode と合わせるプログラム。
|
|
34 */
|
|
35
|
|
36 #ifdef HAVE_CONFIG_H
|
|
37 # include <config.h>
|
|
38 #endif
|
|
39
|
|
40 #include <stdio.h>
|
|
41 #if STDC_HEADERS
|
|
42 # include <stdlib.h>
|
|
43 #endif /* STDC_HEADERS */
|
|
44 #if HAVE_UNISTD_H
|
|
45 # include <unistd.h>
|
|
46 #endif
|
|
47 #include "jslib.h"
|
|
48 #include "commonhd.h"
|
|
49 #include "getopt.h" /* GNU getopt in the stock */
|
|
50
|
|
51 extern int input_file_header (), check_inode (), change_file_uniq ();
|
|
52 static void usage (void);
|
|
53
|
|
54 char *com_name;
|
|
55 struct wnn_file_head fh;
|
|
56
|
|
57 static void
|
|
58 parse_options (int argc, char** argv)
|
|
59 {
|
|
60 int c;
|
|
61
|
|
62 while ((c = getopt (argc, argv, "")) != EOF)
|
|
63 {
|
|
64 }
|
|
65 if (optind)
|
|
66 {
|
|
67 optind--;
|
|
68 argc -= optind;
|
|
69 argv += optind;
|
|
70 }
|
|
71 if (argc < 2)
|
|
72 {
|
|
73 usage ();
|
|
74 }
|
|
75 }
|
|
76
|
|
77 static void
|
|
78 usage (void)
|
|
79 {
|
|
80 fprintf (stderr, "Usage: %s Wnn_file_name* \n", com_name);
|
|
81 exit (1);
|
|
82 }
|
|
83
|
|
84 int
|
|
85 main (int argc, char** argv)
|
|
86 {
|
|
87 FILE *ifpter;
|
|
88 int k;
|
|
89
|
|
90 com_name = argv[0];
|
|
91 parse_options (argc, argv);
|
|
92
|
|
93 for (k = 1; k < argc; k++)
|
|
94 {
|
|
95 if ((ifpter = fopen (argv[k], "r")) == NULL)
|
|
96 {
|
|
97 fprintf (stderr, "Can't open the input file %s.\n", argv[k]);
|
|
98 perror ("");
|
|
99 exit (1);
|
|
100 }
|
|
101 if (input_file_header (ifpter, &fh) == -1)
|
|
102 {
|
|
103 fprintf (stderr, "%s %s: It's not a Wnn File.\n", com_name, argv[k]);
|
|
104 exit (1);
|
|
105 }
|
|
106 if (check_inode (ifpter, &fh) == -1)
|
|
107 {
|
|
108 if (change_file_uniq (&fh, argv[k]) == -1)
|
|
109 {
|
|
110 fprintf (stderr, "%s %s: Can't change file_uniq.\n", com_name, argv[k]);
|
|
111 perror ("");
|
|
112 exit (1);
|
|
113 }
|
|
114 }
|
|
115 fclose (ifpter);
|
|
116 }
|
|
117 exit (0);
|
|
118 }
|