Mercurial > freewnn
annotate Wnn/jutil/wddel.c @ 23:e1aadb6dcbd4
- fixed the build rule for build_stamp.h. keywords in template for hg tip should surrounded by curly braces instead of hash marks.
- fixed usage of libtool in building jlib.V3. newer libtool does not work without mode specifier.
- replaced some libtool related files. (should remove these?)
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Fri, 23 Jan 2009 16:36:13 +0900 |
parents | c966456648ad |
children | a7ccf412ba02 |
rev | line source |
---|---|
0 | 1 /* |
2 * $Id: wddel.c,v 1.8 2002/05/12 22:51:17 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 | |
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 * UJIS ファイルを読みとって、単語登録を行なう。 | |
34 */ | |
35 | |
36 #ifndef lint | |
37 static char *rcs_id = "$Id: wddel.c,v 1.8 2002/05/12 22:51:17 hiroo Exp $"; | |
38 #endif /* lint */ | |
39 | |
40 #ifdef HAVE_CONFIG_H | |
41 # include <config.h> | |
42 #endif | |
43 | |
44 #include <stdio.h> | |
45 #if STDC_HEADERS | |
46 # include <stdlib.h> | |
47 #else | |
48 # if HAVE_MALLOC_H | |
49 # include <malloc.h> | |
50 # endif | |
51 #endif /* STDC_HEADERS */ | |
52 #if HAVE_UNISTD_H | |
53 # include <unistd.h> | |
54 #endif | |
55 | |
56 #include "commonhd.h" | |
57 #include "wnn_config.h" | |
58 #include "jllib.h" | |
59 #include "jslib.h" | |
60 #include "wnn_string.h" | |
61 #include "wnn_os.h" | |
62 | |
63 #define WORD_DELETE 1 | |
64 #define COMMENT_SET 2 | |
65 #define HINDO_SET 3 | |
66 | |
67 #define LINE_SIZE 256 | |
68 | |
69 char *def_server; | |
70 | |
71 int dic_no = -1; | |
72 char *server_n; | |
73 char *env_n = "wddel"; | |
74 char *fname = NULL; | |
75 int fid; | |
76 int client = 0; /* server site dict */ | |
77 int what = WORD_DELETE; | |
78 | |
79 WNN_JSERVER_ID *js; | |
80 struct wnn_env *env, *rev_env; | |
81 static struct wnn_ret_buf rb = { 0, NULL }; | |
82 | |
83 static void | |
22
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
84 usage (void) |
0 | 85 { |
86 fprintf (stderr, "wddel [-D server_name] [-n env_name][-d dic_no][-L][-E][-H][-C] [file_name] < text dict\n"); | |
87 fprintf (stderr, "file_name or -d dic_no must be specified\n"); | |
88 fprintf (stderr, "default env_name = wddel\n"); | |
89 fprintf (stderr, "default server_name = %s\n", def_server); | |
90 fprintf (stderr, "L is to specify that the file at the client site.\n"); | |
91 fprintf (stderr, "-E is word_delete, -C is word_comment_set, -H is hindo_set.\n"); | |
92 exit (1); | |
93 } | |
94 | |
95 static void | |
22
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
96 err (void) |
0 | 97 { |
98 printf ((char *) wnn_perror ()); | |
99 printf ("\n bye.\n"); | |
100 exit (1); | |
101 } | |
102 | |
103 int | |
22
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
104 main (int argc, char **argv) |
0 | 105 { |
106 extern char *getenv (); | |
107 extern int optind; | |
108 extern char *optarg; | |
109 struct wnn_dic_info *info; | |
110 int c; | |
111 int k; | |
112 int num; | |
113 int sno; | |
114 char s[LINE_SIZE]; | |
115 char *cswidth_name; | |
116 extern char *get_cswidth_name (); | |
117 extern void set_cswidth (); | |
118 | |
119 if (getenv (WNN_DEF_SERVER_ENV)) | |
120 { | |
121 def_server = getenv (WNN_DEF_SERVER_ENV); | |
122 } | |
123 else | |
124 { | |
125 def_server = ""; | |
126 } | |
127 server_n = def_server; | |
128 | |
129 if (cswidth_name = get_cswidth_name (WNN_DEFAULT_LANG)) | |
130 set_cswidth (create_cswidth (cswidth_name)); | |
131 while ((c = getopt (argc, argv, "D:n:d:CHEL")) != EOF) | |
132 { | |
133 switch (c) | |
134 { | |
135 case 'D': | |
136 server_n = optarg; | |
137 break; | |
138 case 'n': | |
139 env_n = optarg; | |
140 break; | |
141 case 'd': | |
142 dic_no = atoi (optarg); | |
143 break; | |
144 case 'C': | |
145 what = COMMENT_SET; | |
146 break; | |
147 case 'H': | |
148 what = HINDO_SET; | |
149 break; | |
150 case 'E': | |
151 what = WORD_DELETE; | |
152 break; | |
153 case 'L': | |
154 client = 1; | |
155 break; | |
156 default: | |
157 usage (); | |
158 break; | |
159 } | |
160 } | |
161 if (optind) | |
162 { | |
163 optind--; | |
164 argc -= optind; | |
165 argv += optind; | |
166 } | |
167 if (argc > 1) | |
168 { | |
169 fname = argv[1]; | |
170 } | |
171 if (fname && dic_no != -1) | |
172 usage (); | |
173 if (!fname && dic_no == -1) | |
174 usage (); | |
175 | |
176 | |
177 rb.buf = (char *) malloc ((unsigned) (rb.size = 0)); | |
178 | |
179 if ((js = js_open (server_n, WNN_TIMEOUT)) == NULL) | |
180 err (); | |
181 if ((env = js_connect (js, env_n)) == NULL) | |
182 err (); | |
183 if (fname) | |
184 { | |
185 if (client) | |
186 { | |
187 if ((fid = js_file_send (env, fname)) == -1) | |
188 err (); | |
189 } | |
190 else | |
191 { | |
192 if ((fid = js_file_read (env, fname)) == -1) | |
193 err (); | |
194 } | |
195 if ((dic_no = js_dic_add (env, fid, -1, 0, 0, WNN_DIC_RW, WNN_DIC_RW, "", "")) == -1) | |
196 err (); | |
197 } | |
198 | |
199 if ((num = js_dic_list (env, &rb)) == -1) | |
200 err (); | |
201 | |
202 info = (struct wnn_dic_info *) (rb.buf); | |
203 for (k = 0; k < num; k++) | |
204 { | |
205 if (info[k].dic_no == dic_no) | |
206 break; | |
207 } | |
208 if (k == num) | |
209 { | |
210 /* | |
211 fprintf(stderr, "指定された番号の辞書は、環境に存在しません。\n"); | |
212 */ | |
213 fprintf (stderr, "The specified dictionary isn't exist in current environment\n"); | |
214 exit (1); | |
215 } | |
216 if (info[k].type != WNN_UD_DICT && info[k].type != WNN_REV_DICT) | |
217 { | |
218 /* | |
219 fprintf(stderr, "指定された番号の辞書は、登録可能ではありません。\n"); | |
220 */ | |
221 fprintf (stderr, "The specified dictionary isn't registable\n"); | |
222 exit (1); | |
223 } | |
224 while (fgets (s, sizeof (s), stdin)) | |
225 { | |
226 char com[LENGTHYOMI]; | |
227 char Com[LENGTHYOMI]; | |
228 int ima, hindo; | |
229 if (s[0] == '\\') | |
230 continue; | |
231 switch (what) | |
232 { | |
233 case WORD_DELETE: | |
234 if (sscanf (s, "%d", &sno) <= 0) | |
235 { | |
236 fprintf (stderr, "Bad line \"%s\"", s); | |
237 continue; | |
238 } | |
239 if (js_word_delete (env, dic_no, sno) == -1) | |
240 { | |
241 fprintf (stderr, "serial-no = %d\n", sno); | |
242 err (); | |
243 } | |
244 break; | |
245 case COMMENT_SET: | |
246 if (sscanf (s, "%d %s", &sno, com) <= 1) | |
247 { | |
248 fprintf (stderr, "Bad line \"%s\"", s); | |
249 continue; | |
250 } | |
251 wnn_Sstrcpy (Com, com); | |
22
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
252 if (js_word_comment_set (env, dic_no, sno, (w_char *)Com) == -1) // casting may be wrong --yaz |
0 | 253 { |
254 fprintf (stderr, "serial-no = %d\n", sno); | |
255 err (); | |
256 } | |
257 break; | |
258 case HINDO_SET: | |
259 if (sscanf (s, "%d %n %n", &sno, &ima, &hindo) <= 2) | |
260 { | |
261 fprintf (stderr, "Bad line \"%s\"", s); | |
262 continue; | |
263 } | |
264 if (js_hindo_set (env, dic_no, sno, ima, hindo) == -1) | |
265 { | |
266 fprintf (stderr, "serial-no = %d\n", sno); | |
267 err (); | |
268 } | |
269 break; | |
270 } | |
271 } | |
272 if (fname) | |
273 { | |
274 if (client) | |
275 { | |
276 if (js_file_receive (env, fid, "") == -1) | |
277 err (); | |
278 } | |
279 else | |
280 { | |
281 if (js_file_write (env, fid, "") == -1) | |
282 err (); | |
283 } | |
284 fprintf (stderr, "Wrote the file back.\n"); | |
285 } | |
286 exit (0); | |
287 } |