0
|
1 /*
|
|
2 * $Id: wnnrc_op.c,v 1.10 2002/06/22 13:26:21 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 /* uumrc operations */
|
|
33 #ifdef HAVE_CONFIG_H
|
|
34 # include <config.h>
|
|
35 #endif
|
|
36
|
|
37 #include <stdio.h>
|
|
38 #include <ctype.h>
|
|
39 #include <errno.h>
|
|
40 #if STDC_HEADERS
|
|
41 # include <stdlib.h>
|
|
42 # include <string.h>
|
|
43 #else
|
|
44 # if HAVE_MALLOC_H
|
|
45 # include <malloc.h>
|
|
46 # endif
|
|
47 # if HAVE_STRINGS_H
|
|
48 # include <strings.h>
|
|
49 # endif
|
|
50 #endif /* STDC_HEADERS */
|
|
51 #include <pwd.h>
|
|
52
|
|
53 #include "jllib.h"
|
|
54 #include "commonhd.h"
|
|
55 #include "wnn_config.h"
|
|
56 #include "buffer.h"
|
|
57 #include "rk_spclval.h"
|
|
58 #include "sdefine.h"
|
|
59 #include "sheader.h"
|
|
60 #include "wnn_os.h"
|
|
61
|
|
62 extern int conv_keyin ();
|
|
63 extern int keyin2 ();
|
|
64
|
|
65
|
|
66 void
|
|
67 getfname (file, path)
|
|
68 char *path, *file;
|
|
69 {
|
|
70 char *c;
|
|
71
|
|
72 c = path + strlen (path);
|
|
73 for (; *c != '/' && c >= path; c--);
|
|
74 strcpy (file, c + 1);
|
|
75 }
|
|
76
|
|
77
|
|
78
|
|
79 /** s1とs2がマッチしたら非0を返す。s1にはワイルドカード '*' を
|
|
80 含んでよい(s2にはだめ)。*/
|
|
81 int
|
|
82 strmatch (s1, s2)
|
|
83 char *s1, *s2;
|
|
84 {
|
|
85 while (1)
|
|
86 {
|
|
87 if (*s1 == '\0')
|
|
88 return (*s2 == '\0');
|
|
89 if (*s1 != '*')
|
|
90 {
|
|
91 if (*s1 != *s2)
|
|
92 return (0);
|
|
93 s1++;
|
|
94 s2++;
|
|
95 continue;
|
|
96 }
|
|
97
|
|
98 s1++;
|
|
99 do
|
|
100 {
|
|
101 if (strmatch (s1, s2))
|
|
102 return (1);
|
|
103 }
|
|
104 while (*s2++ != '\0');
|
|
105 return (0);
|
|
106 }
|
|
107 }
|
|
108
|
|
109 /** KEYBOARDという環境変数が設定されていればそれが、又、いなければTERMが
|
|
110 返る */
|
|
111 char *
|
|
112 get_kbd_env ()
|
|
113 {
|
|
114 char *term;
|
|
115
|
|
116 return (NULL != (term = getenv (WNN_KEYBOARD_ENV)) ? term : getenv ("TERM"));
|
|
117 }
|
|
118
|
|
119 /** KEYBOARDという環境変数が設定されていればそれが、又、いなければTERMが、
|
|
120 引き数とマッチするかどうかの検査(マッチしたら非0が返る)。convert_key
|
|
121 の初期設定に使う。*/
|
|
122 int
|
|
123 lookWnnterm (s)
|
|
124 char *s;
|
|
125 {
|
|
126 char *term;
|
|
127
|
|
128 return (NULL == (term = get_kbd_env ())? 0 : strmatch (s, term));
|
|
129 }
|
|
130
|
|
131 int
|
|
132 expand_expr (s)
|
|
133 /** ~user、@HOME、@LIBDIRの展開(但し、文字列の先頭のみ)。できない時は-1が
|
|
134 返り、その場合sの中身は着々とそのまんま。sの長さ<256と仮定してる。*/
|
|
135 /** @USR (env名、logname), @LANG の展開 */
|
|
136 char *s;
|
|
137 {
|
|
138 char tmp[EXPAND_PATH_LENGTH];
|
|
139 register char *p, *s1;
|
|
140 int noerr, expandsuc;
|
|
141 struct passwd *u;
|
|
142 extern struct passwd *getpwnam ();
|
|
143
|
|
144 if (*s != '~' && *s != '@')
|
|
145 {
|
|
146 strcpy (tmp, s);
|
|
147 *s = '\0';
|
|
148 noerr = 1;
|
|
149 }
|
|
150 else
|
|
151 {
|
|
152 if ((int) strlen (s) >= EXPAND_PATH_LENGTH)
|
|
153 return (-1);
|
|
154
|
|
155 s1 = s;
|
|
156 if (NULL != (p = strchr (++s1, '/')))
|
|
157 {
|
|
158 strcpy (tmp, p);
|
|
159 *p = '\0';
|
|
160 }
|
|
161 else
|
|
162 *tmp = '\0';
|
|
163 /* ここまでは準備。s…先頭、s1…2文字目、p…最初の'/'のあったところ
|
|
164 (ここで一旦切る)、tmp…それ以後のコピー。 */
|
|
165
|
|
166 if (*s == '~')
|
|
167 {
|
|
168 if (*s1)
|
|
169 {
|
|
170 noerr = expandsuc = (NULL != (u = getpwnam (s1)) && (int) (strlen (p = u->pw_dir) + strlen (tmp)) < EXPAND_PATH_LENGTH);
|
|
171
|
|
172 }
|
|
173 else
|
|
174 {
|
|
175 noerr = expandsuc = (NULL != (p = getenv ("HOME")) && (int) (strlen (p) + strlen (tmp)) < EXPAND_PATH_LENGTH);
|
|
176 }
|
|
177
|
|
178 }
|
|
179 else
|
|
180 { /* then, *s must be '@' */
|
|
181 if (!strcmp (s1, "HOME"))
|
|
182 {
|
|
183 noerr = expandsuc = (NULL != (p = getenv ("HOME")) && (int) (strlen (p) + strlen (tmp)) < EXPAND_PATH_LENGTH);
|
|
184 }
|
|
185 else if (!strcmp (s1, "LIBDIR"))
|
|
186 {
|
|
187 noerr = expandsuc = ((int) (strlen (p = LIBDIR) + strlen (tmp)) < EXPAND_PATH_LENGTH);
|
|
188 }
|
|
189 else
|
|
190 { /* @HOME, @LIBDIR igai ha kaenai */
|
|
191 noerr = 1;
|
|
192 expandsuc = 0;
|
|
193 }
|
|
194 }
|
|
195 if (expandsuc)
|
|
196 strcpy (s, p);
|
|
197 }
|
|
198
|
|
199 if (noerr)
|
|
200 {
|
|
201 int len = strlen ("@USR");
|
|
202 int len1 = strlen ("@LANG");
|
|
203 p = tmp;
|
|
204 for (; *p; p++)
|
|
205 {
|
|
206 if (!strncmp (p, "@USR", len))
|
|
207 {
|
|
208 if ((int) (strlen (username) + strlen (p) + strlen (s) - len) < EXPAND_PATH_LENGTH)
|
|
209 {
|
|
210 strcat (s, username);
|
|
211 p += len - 1;
|
|
212 }
|
|
213 else
|
|
214 {
|
|
215 return (-1);
|
|
216 }
|
|
217 }
|
|
218 else if (!strncmp (p, "@LANG", len1))
|
|
219 {
|
|
220 if ((int) (strlen (lang_dir) + strlen (p) + strlen (s) - len1) < EXPAND_PATH_LENGTH)
|
|
221 {
|
|
222 strcat (s, lang_dir);
|
|
223 p += len1 - 1;
|
|
224 }
|
|
225 else
|
|
226 {
|
|
227 return (-1);
|
|
228 }
|
|
229 }
|
|
230 else
|
|
231 {
|
|
232 strncat (s, p, 1);
|
|
233 }
|
|
234 }
|
|
235 }
|
|
236 return (noerr ? 0 : -1);
|
|
237 }
|
|
238
|
|
239
|
|
240
|
|
241 /** uumrc を見てのパラメータの設定 */
|
|
242 int
|
|
243 uumrc_set_entry (data, dn)
|
|
244 char *data;
|
|
245 int *dn;
|
|
246 {
|
|
247 int num, d1;
|
|
248 char code[256];
|
|
249 char s[7][EXPAND_PATH_LENGTH];
|
|
250 char tmp[1024];
|
|
251 FILE *fp;
|
|
252 char *s0or1;
|
|
253
|
|
254 num = sscanf (data, "%s %s %s %s %s %s %s %s", code, s[0], s[1], s[2], s[3], s[4], s[5], s[6]);
|
|
255 if (num <= 0)
|
|
256 {
|
|
257 return (-1);
|
|
258 }
|
|
259
|
|
260 if (code[0] == ';')
|
|
261 {
|
|
262 return (0);
|
|
263 }
|
|
264 else if (strcmp (code, "include") == 0)
|
|
265 {
|
|
266 if (expand_expr (s[0]) != 0)
|
|
267 {
|
|
268 fprintf (stderr, "Can't expand %s.\r\n", s[0]);
|
|
269 }
|
|
270 if ((fp = fopen (s[0], "r")) != NULL)
|
|
271 {
|
|
272 while (fgets (tmp, 1024, fp) != NULL)
|
|
273 {
|
|
274 uumrc_set_entry (tmp, dn);
|
|
275 }
|
|
276 fclose (fp);
|
|
277 }
|
|
278 else
|
|
279 {
|
|
280 fprintf (stderr, "Can't open %s.\r\n", s[0]);
|
|
281 }
|
|
282 }
|
|
283 else if (strcmp (code, "setuumkey") == 0)
|
|
284 {
|
|
285 /* setuumkey --- this must be a file. */
|
|
286 if (!uumkey_defined_by_option && (num > 1))
|
|
287 {
|
|
288 if (expand_expr (s[0]) != 0)
|
|
289 {
|
|
290 fprintf (stderr, "Can't expand %s.\r\n", s[0]);
|
|
291 }
|
|
292 strncpy (uumkey_name_in_uumrc, s[0], PATHNAMELEN);
|
|
293 }
|
|
294 }
|
|
295 else if (strcmp (code, "setconvenv") == 0)
|
|
296 {
|
|
297 if (num > 1)
|
|
298 {
|
|
299 get_new_env (0);
|
|
300 /* setconvenv */
|
|
301 if (num > 2)
|
|
302 {
|
|
303 if (!(strcmp (s[num - 2], "sticky")))
|
|
304 {
|
|
305 normal_sticky = 1;
|
|
306 num--;
|
|
307 }
|
|
308 }
|
|
309 if (num == 2)
|
|
310 s0or1 = s[0];
|
|
311 else
|
|
312 {
|
|
313 s0or1 = s[1];
|
|
314 if (def_servername && *def_servername)
|
|
315 {
|
|
316 servername = (char *) malloc (strlen (def_servername) + 1);
|
|
317 strcpy (servername, def_servername);
|
|
318 }
|
|
319 else
|
|
320 {
|
|
321 servername = (char *) malloc (strlen (s[0]) + 1);
|
|
322 strcpy (servername, s[0]);
|
|
323 }
|
|
324 }
|
|
325 if (expand_expr (s0or1) != 0)
|
|
326 {
|
|
327 fprintf (stderr, "Can't expand %s.\r\n", s0or1);
|
|
328 }
|
|
329 envrcname = (char *) malloc (strlen (s0or1) + 1);
|
|
330 strcpy (envrcname, s0or1);
|
|
331 }
|
|
332 }
|
|
333 else if (strcmp (code, "setkankanaenv") == 0)
|
|
334 {
|
|
335 if (num > 1)
|
|
336 {
|
|
337 get_new_env (1);
|
|
338 /* setkankanaenv */
|
|
339 if (num > 2)
|
|
340 {
|
|
341 if (!(strcmp (s[num - 2], "sticky")))
|
|
342 {
|
|
343 reverse_sticky = 1;
|
|
344 num--;
|
|
345 }
|
|
346 }
|
|
347 if (num == 2)
|
|
348 s0or1 = s[0];
|
|
349 else
|
|
350 {
|
|
351 s0or1 = s[1];
|
|
352 if (def_reverse_servername && *def_reverse_servername)
|
|
353 {
|
|
354 reverse_servername = (char *) malloc (strlen (def_reverse_servername) + 1);
|
|
355 strcpy (reverse_servername, def_reverse_servername);
|
|
356 }
|
|
357 else
|
|
358 {
|
|
359 reverse_servername = (char *) malloc (strlen (s[0]) + 1);
|
|
360 strcpy (reverse_servername, s[0]);
|
|
361 }
|
|
362 }
|
|
363 if (expand_expr (s0or1) != 0)
|
|
364 {
|
|
365 fprintf (stderr, "Can't expand %s.\r\n", s0or1);
|
|
366 }
|
|
367 reverse_envrcname = (char *) malloc (strlen (s0or1) + 1);
|
|
368 strcpy (reverse_envrcname, s0or1);
|
|
369 }
|
|
370 }
|
|
371 else if (strcmp (code, "setenv") == 0)
|
|
372 {
|
|
373 if (num > 2)
|
|
374 {
|
|
375 get_new_env (0);
|
|
376 if (!(strcmp (s[num - 2], "sticky")))
|
|
377 {
|
|
378 normal_sticky = 1;
|
|
379 num--;
|
|
380 }
|
|
381 if (num == 3)
|
|
382 s0or1 = s[1];
|
|
383 else
|
|
384 {
|
|
385 s0or1 = s[2];
|
|
386 if (def_servername && *def_servername)
|
|
387 {
|
|
388 servername = (char *) malloc (strlen (def_servername) + 1);
|
|
389 strcpy (servername, def_servername);
|
|
390 }
|
|
391 else
|
|
392 {
|
|
393 servername = (char *) malloc (strlen (s[1]) + 1);
|
|
394 strcpy (servername, s[1]);
|
|
395 }
|
|
396 }
|
|
397 if (expand_expr (s0or1) != 0)
|
|
398 {
|
|
399 fprintf (stderr, "Can't expand %s.\r\n", s0or1);
|
|
400 }
|
|
401 envrcname = (char *) malloc (strlen (s0or1) + 1);
|
|
402 strcpy (envrcname, s0or1);
|
|
403 strcpy (env_name_s, s[0]);
|
|
404 }
|
|
405 }
|
|
406 else if (strcmp (code, "setenv_R") == 0)
|
|
407 {
|
|
408 if (num > 2)
|
|
409 {
|
|
410 get_new_env (1);
|
|
411 if (!(strcmp (s[num - 2], "sticky")))
|
|
412 {
|
|
413 reverse_sticky = 1;
|
|
414 num--;
|
|
415 }
|
|
416 if (num == 3)
|
|
417 s0or1 = s[1];
|
|
418 else
|
|
419 {
|
|
420 s0or1 = s[2];
|
|
421 if (def_reverse_servername && *def_reverse_servername)
|
|
422 {
|
|
423 reverse_servername = (char *) malloc (strlen (def_reverse_servername) + 1);
|
|
424 strcpy (reverse_servername, def_reverse_servername);
|
|
425 }
|
|
426 else
|
|
427 {
|
|
428 reverse_servername = (char *) malloc (strlen (s[1]) + 1);
|
|
429 strcpy (reverse_servername, s[1]);
|
|
430 }
|
|
431 }
|
|
432 if (expand_expr (s0or1) != 0)
|
|
433 {
|
|
434 fprintf (stderr, "Can't expand %s.\r\n", s0or1);
|
|
435 }
|
|
436 reverse_envrcname = (char *) malloc (strlen (s0or1) + 1);
|
|
437 strcpy (reverse_envrcname, s0or1);
|
|
438 strcpy (reverse_env_name_s, s[0]);
|
|
439 }
|
|
440 }
|
|
441 else if (strcmp (code, "setrkfile") == 0)
|
|
442 {
|
|
443 /* setrkfile */
|
|
444 if (!rkfile_defined_by_option && (num > 1))
|
|
445 {
|
|
446 if (expand_expr (s[0]) != 0)
|
|
447 {
|
|
448 fprintf (stderr, "Can't expand %s.\r\n", s[0]);
|
|
449 }
|
|
450 strncpy (rkfile_name_in_uumrc, s[0], PATHNAMELEN);
|
|
451 }
|
|
452 }
|
|
453 else if (strcmp (code, "setconvkey") == 0)
|
|
454 {
|
|
455 /* setconvkey --- pair of TERM name and used table name */
|
|
456 if (!convkey_defined_by_option)
|
|
457 {
|
|
458 if (num == 2)
|
|
459 s0or1 = s[0];
|
|
460 else if ((num > 2) && lookWnnterm (s[0]))
|
|
461 s0or1 = s[1];
|
|
462 else
|
|
463 goto NOMATCH;
|
|
464
|
|
465 if (expand_expr (s0or1) != 0)
|
|
466 {
|
|
467 fprintf (stderr, "Can't expand %s.\r\n", s0or1);
|
|
468 }
|
|
469 strncpy (convkey_name_in_uumrc, s0or1, PATHNAMELEN);
|
|
470 NOMATCH:;
|
|
471 }
|
|
472 }
|
|
473 else if (strcmp (code, "flow_control_on") == 0)
|
|
474 {
|
|
475 /* setflowctrl */
|
|
476 if (!(defined_by_option & OPT_FLOW_CTRL))
|
|
477 {
|
|
478 flow_control = 1;
|
|
479 }
|
|
480 }
|
|
481 else if (strcmp (code, "flow_control_off") == 0)
|
|
482 {
|
|
483 /* setflowctrl */
|
|
484 if (!(defined_by_option & OPT_FLOW_CTRL))
|
|
485 {
|
|
486 flow_control = 0;
|
|
487 }
|
|
488 }
|
|
489 else if (strcmp (code, "waking_up_in_henkan_mode") == 0 || strcmp (code, "waking_up_in_convert_mode") == 0)
|
|
490 {
|
|
491 /* */
|
|
492 if (!(defined_by_option & OPT_WAKING_UP_MODE))
|
|
493 {
|
|
494 henkan_off_flag = 0;
|
|
495 }
|
|
496 }
|
|
497 else if (strcmp (code, "waking_up_no_henkan_mode") == 0 || strcmp (code, "waking_up_no_convert_mode") == 0)
|
|
498 {
|
|
499 /* */
|
|
500 if (!(defined_by_option & OPT_WAKING_UP_MODE))
|
|
501 {
|
|
502 henkan_off_flag = 1;
|
|
503 }
|
|
504 }
|
|
505 else if (strcmp (code, "convkey_always_on") == 0)
|
|
506 {
|
|
507 convkey_on = 1;
|
|
508 }
|
|
509 else if (strcmp (code, "convkey_not_always_on") == 0)
|
|
510 {
|
|
511 convkey_on = 0;
|
|
512 }
|
|
513 else if (strcmp (code, "simple_delete") == 0)
|
|
514 {
|
|
515 excellent_delete = 0;
|
|
516 }
|
|
517 else if (strcmp (code, "excellent_delete") == 0)
|
|
518 {
|
|
519 excellent_delete = 1;
|
|
520 }
|
|
521 else if (strcmp (code, "send_ascii_char") == 0)
|
|
522 {
|
|
523 /* send ascii char or not */
|
|
524 send_ascii_char = 1;
|
|
525 }
|
|
526 else if (strcmp (code, "not_send_ascii_char") == 0)
|
|
527 {
|
|
528 send_ascii_char = 0;
|
|
529 }
|
|
530 else if (strcmp (code, "setmaxchg") == 0)
|
|
531 {
|
|
532 /* setmaxchg ----- henkan kanou saidai mojisuu */
|
|
533 if (change_ascii_to_int (s[0], &d1) != -1)
|
|
534 {
|
|
535 maxchg = (d1 <= 0) ? maxchg : d1;
|
|
536 }
|
|
537 }
|
|
538 else if (strcmp (code, "setmaxbunsetsu") == 0)
|
|
539 {
|
|
540 /* setmaxbunsetsu ---- kaiseki kanou saidai bunsetsu kosuu */
|
|
541 if (num >= 2)
|
|
542 {
|
|
543 if (change_ascii_to_int (s[0], &d1) != -1)
|
|
544 {
|
|
545 maxbunsetsu = (d1 <= 0) ? maxbunsetsu : d1;
|
|
546 }
|
|
547 }
|
|
548 }
|
|
549 else if (strcmp (code, "setmaxichirankosu") == 0)
|
|
550 {
|
|
551 /* setmaxichirankosuu --- jikouho ichiran hyouji kosuu */
|
|
552 if (num >= 2)
|
|
553 {
|
|
554 if (change_ascii_to_int (s[0], &d1) != -1)
|
|
555 {
|
|
556 max_ichiran_kosu = (d1 <= 0) ? max_ichiran_kosu : d1;
|
|
557 }
|
|
558 }
|
|
559 }
|
|
560 else if (strcmp (code, "setmaxhistory") == 0)
|
|
561 {
|
|
562 /* setmaxhistory --- set depth of history */
|
|
563 if (num >= 2)
|
|
564 {
|
|
565 if (change_ascii_to_int (s[0], &d1) != -1)
|
|
566 {
|
|
567 max_history = (d1 <= 0) ? max_history : d1 + 1;
|
|
568 }
|
|
569 }
|
|
570 }
|
|
571 else if (strcmp (code, "remove_cs") == 0)
|
|
572 {
|
|
573 remove_cs_from_termcap = 1;
|
|
574 }
|
|
575 else if (strcmp (code, "not_remove_cs") == 0)
|
|
576 {
|
|
577 remove_cs_from_termcap = 0;
|
|
578 }
|
|
579 else if (strcmp (code, "setjishopath") == 0 || strcmp (code, "setdicpath") == 0)
|
|
580 {
|
|
581 /* setjishopath --- 辞書のあるディレクトリ */
|
|
582 if (num >= 2)
|
|
583 {
|
|
584 if (expand_expr (s[0]) != 0)
|
|
585 {
|
|
586 fprintf (stderr, "Can't expand %s.\r\n", s[0]);
|
|
587 }
|
|
588 Sstrcpy (jishopath, s[0]);
|
|
589 }
|
|
590 }
|
|
591 else if (strcmp (code, "sethindopath") == 0 || strcmp (code, "setfreqpath") == 0)
|
|
592 {
|
|
593 /* sethindopath --- 頻度のあるディレクトリ */
|
|
594 if (num >= 2)
|
|
595 {
|
|
596 if (expand_expr (s[0]) != 0)
|
|
597 {
|
|
598 fprintf (stderr, "Can't expand %s.\r\n", s[0]);
|
|
599 }
|
|
600 Sstrcpy (hindopath, s[0]);
|
|
601 }
|
|
602 }
|
|
603 else if ((strcmp (code, "setfuzokugopath") == 0) || (strcmp (code, "setgrammarpath") == 0))
|
|
604 {
|
|
605 if (num >= 2)
|
|
606 {
|
|
607 if (expand_expr (s[0]) != 0)
|
|
608 {
|
|
609 fprintf (stderr, "Can't expand %s.\r\n", s[0]);
|
|
610 }
|
|
611 Sstrcpy (fuzokugopath, s[0]);
|
|
612 }
|
|
613 /*
|
|
614 } else if (strcmp(code, "dai_kugiri_str") == 0){
|
|
615 if(num >= 2){
|
|
616 char tmp[MAXKUGIRI * 2];
|
|
617 read_kanji_str(tmp, s[0]);
|
|
618 Sstrcpy(kugiri_str, tmp);
|
|
619 }else{
|
|
620 kugiri_str[0] = 0;
|
|
621 }
|
|
622 */
|
|
623 }
|
|
624 else if (strcmp (code, "touroku_comment") == 0)
|
|
625 {
|
|
626 touroku_comment = 1;
|
|
627 }
|
|
628 else if (strcmp (code, "touroku_no_comment") == 0)
|
|
629 {
|
|
630 touroku_comment = 0;
|
|
631 }
|
|
632 else
|
|
633 {
|
|
634 /* printf("Undefined entry \"%s\" in uumrc.\r\n",code); */
|
|
635 }
|
|
636 return (0);
|
|
637 }
|
|
638
|
|
639 int
|
|
640 change_ascii_to_int (st, dp)
|
|
641 char *st;
|
|
642 int *dp;
|
|
643 {
|
|
644 register int total, flag;
|
|
645
|
|
646 total = 0;
|
|
647 flag = 0;
|
|
648 while (*st != NULL)
|
|
649 {
|
|
650 if (isdigit (*st))
|
|
651 {
|
|
652 total = total * 10 + (*st - '0');
|
|
653 }
|
|
654 else if (*st == '+')
|
|
655 {
|
|
656 if (flag != 0)
|
|
657 {
|
|
658 return (-1);
|
|
659 }
|
|
660 flag = 1;
|
|
661 }
|
|
662 else if (*st == '-')
|
|
663 {
|
|
664 if (flag != 0)
|
|
665 {
|
|
666 return (-1);
|
|
667 }
|
|
668 flag = -1;
|
|
669 }
|
|
670 else
|
|
671 {
|
|
672 return (-1);
|
|
673 }
|
|
674 st++;
|
|
675 }
|
|
676 if (flag == 0)
|
|
677 {
|
|
678 flag = 1;
|
|
679 }
|
|
680 *dp = total * flag;
|
|
681 return (1);
|
|
682 }
|
|
683
|
|
684
|
|
685 /* uumrc ファイルからデータを読みその設定を行う。*/
|
|
686 int
|
|
687 uumrc_get_entries ()
|
|
688 {
|
|
689 extern FILE *open_uumrc ();
|
|
690 FILE *fp;
|
|
691 int dn;
|
|
692 char data[1024];
|
|
693
|
|
694 /* default setting */
|
|
695
|
|
696 maxchg = MAXCHG;
|
|
697 maxbunsetsu = MAXBUNSETSU;
|
|
698 max_ichiran_kosu = MAX_ICHIRAN_KOSU;
|
|
699
|
|
700 max_history = MAX_HISTORY + 1;
|
|
701
|
|
702 if ((fp = open_uumrc ()) == NULL)
|
|
703 {
|
|
704 return -1;
|
|
705 }
|
|
706 dn = 0;
|
|
707 while (fgets (data, 1024, fp) != NULL)
|
|
708 {
|
|
709 uumrc_set_entry (data, &dn);
|
|
710 }
|
|
711 fclose (fp);
|
|
712 return (0);
|
|
713 }
|
|
714
|
|
715
|
|
716 /** uumrc ファイルのオープン */
|
|
717 FILE *
|
|
718 open_uumrc ()
|
|
719 {
|
|
720 FILE *fp;
|
|
721 char *n, buf[1024];
|
|
722
|
|
723 if (n = getenv (WNN_UUM_ENV))
|
|
724 {
|
|
725 if (fp = fopen (n, "r"))
|
|
726 {
|
|
727 if (verbose_option)
|
|
728 fprintf (stderr, "uumrc: using uumrc %s\r\n", n);
|
|
729 return fp;
|
|
730 }
|
|
731 else
|
|
732 {
|
|
733 goto error;
|
|
734 }
|
|
735 }
|
|
736 if (n = getenv ("HOME"))
|
|
737 {
|
|
738 strcat (strcpy (buf, n), USR_UUMRC);
|
|
739 if (fp = fopen (buf, "r"))
|
|
740 {
|
|
741 if (verbose_option)
|
|
742 fprintf (stderr, "uumrc: using uumrc %s\r\n", buf);
|
|
743 return fp;
|
|
744 }
|
|
745 }
|
|
746 strcpy (buf, LIBDIR);
|
|
747 strcat (buf, "/");
|
|
748 strcat (buf, lang_dir);
|
|
749 strcat (buf, RCFILE);
|
|
750 if ((fp = fopen (buf, "r")) != NULL)
|
|
751 {
|
|
752 if (verbose_option)
|
|
753 fprintf (stderr, "uumrc: using uumrc %s\r\n", buf);
|
|
754 return fp;
|
|
755 }
|
|
756 error:
|
|
757 fprintf (stderr, MSG_GET (14));
|
|
758 /*
|
|
759 fprintf(stderr , "uumrc ファイルがありません。");
|
|
760 */
|
|
761 fflush (stderr);
|
|
762 return (0);
|
|
763 }
|
|
764
|
|
765
|
|
766 #ifdef nodef
|
|
767 read_kanji_str (c, o)
|
|
768 register char *c, *o;
|
|
769 {
|
|
770 for (; *o; c++)
|
|
771 {
|
|
772 if (*o == '\\')
|
|
773 {
|
|
774 if (*++o == '0')
|
|
775 {
|
|
776 o += 1;
|
|
777 if (*o >= '0' && *o <= '7')
|
|
778 {
|
|
779 *c = (*o++ - '0');
|
|
780 }
|
|
781 else
|
|
782 continue;
|
|
783 if (*o >= '0' && *o <= '7')
|
|
784 {
|
|
785 *c *= 8;
|
|
786 *c |= (*o++ - '0');
|
|
787 }
|
|
788 else
|
|
789 continue;
|
|
790 }
|
|
791 else
|
|
792 {
|
|
793 *c = *o++;
|
|
794 }
|
|
795 }
|
|
796 else
|
|
797 {
|
|
798 *c = *o++;
|
|
799 }
|
|
800 }
|
|
801 *c = 0;
|
|
802 }
|
|
803 #endif
|