0
|
1 /*
|
|
2 * $Id: jutil.c,v 1.4 2002/03/30 01:45:41 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 /* jisho utility routine for otasuke (user interface) process */
|
|
33 /* 活辞書とはカレントユーザ辞書のことだよ */
|
|
34 #ifdef HAVE_CONFIG_H
|
|
35 # include <config.h>
|
|
36 #endif
|
|
37
|
|
38 #include <stdio.h>
|
|
39 #if STDC_HEADERS
|
|
40 # include <stdlib.h>
|
|
41 # include <string.h>
|
|
42 #else
|
|
43 # if HAVE_STRINGS_H
|
|
44 # include <strings.h>
|
|
45 # endif
|
|
46 #endif /* STDC_HEADERS */
|
|
47
|
|
48 #include "commonhd.h"
|
|
49 #include "jslib.h"
|
|
50 #include "jllib.h"
|
|
51 #include "sdefine.h"
|
|
52 #include "sheader.h"
|
|
53 #include "wnn_os.h"
|
|
54
|
|
55 #define MESSAGE_REC 3
|
|
56 #define MESSAGE_NUM 5
|
|
57
|
|
58
|
|
59 #ifdef nodef
|
|
60 char *sh_fname ();
|
|
61 #endif
|
|
62
|
|
63 static void ret (); /* remove sonota() , nullfun() */
|
|
64 void touroku ();
|
|
65 void kensaku ();
|
|
66 void jishoadd (), dicsv (), fuzoku_set ();
|
|
67 void paramchg (), dicinfoout (), select_one_dict8 ();
|
|
68
|
|
69 /*
|
|
70 static struct msg_fun {
|
|
71 char *msg;
|
|
72 void (*fun)();
|
|
73 };
|
|
74
|
|
75 static struct msg_fun message1[] = {
|
|
76 {"辞書追加", jishoadd},
|
|
77 {"辞書一覧",select_one_dict8},
|
|
78 {"登録", touroku},
|
|
79 {"検索", kensaku},
|
|
80 {"パラメータ変更",paramchg},
|
|
81 {"頻度セーブ",dicsv},
|
|
82 {"辞書情報",dicinfoout},
|
|
83 {"付属語変更", fuzoku_set},
|
|
84 {"終了",ret}
|
|
85 };
|
|
86 */
|
|
87
|
|
88 struct msg_fun
|
|
89 {
|
|
90 void (*fun) ();
|
|
91 };
|
|
92
|
|
93 static struct msg_fun message1[] = {
|
|
94 {jishoadd},
|
|
95 {select_one_dict8},
|
|
96 {touroku},
|
|
97 {kensaku},
|
|
98 {paramchg},
|
|
99 {dicsv},
|
|
100 {dicinfoout},
|
|
101 {fuzoku_set},
|
|
102 {ret}
|
|
103 };
|
|
104
|
|
105 int
|
|
106 jutil ()
|
|
107 {
|
|
108 static int last = 3;
|
|
109 int not_redrawtmp = not_redraw;
|
|
110 int c;
|
|
111 int k;
|
|
112 char *buf[sizeof (message1) / sizeof (struct msg_fun)];
|
|
113
|
|
114 not_redraw = 1;
|
|
115 for (k = 0; k < (sizeof (message1) / sizeof (struct msg_fun)); k++)
|
|
116 {
|
|
117 /*
|
|
118 buf[k]=message1[k].msg;
|
|
119 */
|
|
120 buf[k] = MSG_GET (61 + k);
|
|
121 }
|
|
122
|
|
123 c = select_one_element (buf, sizeof (message1) / sizeof (struct msg_fun), last, "", 0, 1, main_table[4]);
|
|
124 if (c == -1)
|
|
125 {
|
|
126 not_redraw = not_redrawtmp;
|
|
127 return (0);
|
|
128 }
|
|
129 last = c;
|
|
130 (*message1[c].fun) ();
|
|
131 not_redraw = not_redrawtmp;
|
|
132 return (0);
|
|
133 }
|
|
134
|
|
135 static void
|
|
136 ret ()
|
|
137 {
|
|
138 }
|
|
139
|
|
140
|
|
141 void
|
|
142 paramchg ()
|
|
143 {
|
|
144 int c, k;
|
|
145 int newval;
|
|
146 char *ch;
|
|
147 char st[80];
|
|
148 char message[80];
|
|
149 w_char kana_buf[1024];
|
|
150
|
|
151 #ifdef nodef
|
|
152 static char *ccc[] = { "解析文節数", "小文節の最大数",
|
|
153 "頻度重み", "小文節長重み", "自立語長重み", "最近使用状況重み", "辞書優先度重み", "小文節の評価値重み", "大文節長重み", "小文節数重み", /* "幹語長重み", */
|
|
154 "数字の頻度", "カナの頻度", "英数の頻度", "記号の頻度", "閉括弧の頻度", "付属語の頻度", "開括弧の頻度"
|
|
155 };
|
|
156 #endif
|
|
157 struct wnn_param para;
|
|
158 int *paraary;
|
|
159 /*
|
|
160 char *cccmsg[(sizeof(ccc) / sizeof(char *))];
|
|
161 */
|
|
162 char *cccmsg[86 - 70 + 1];
|
|
163 char buf[1024];
|
|
164
|
|
165 paraary = (int *) ¶
|
|
166 if (jl_param_get (bun_data_, ¶) < 0)
|
|
167 {
|
|
168 errorkeyin ();
|
|
169 }
|
|
170 /*
|
|
171 for(k = 0,ch = buf ; k < (sizeof(ccc) / sizeof(char *)) ; k++){
|
|
172 */
|
|
173 for (k = 0, ch = buf; k < (86 - 70 + 1); k++)
|
|
174 {
|
|
175 cccmsg[k] = ch;
|
|
176 /*
|
|
177 sprintf(ch,"%s[%d]",ccc[k],paraary[k]);
|
|
178 */
|
|
179 sprintf (ch, "%s[%d]", MSG_GET (70 + k), paraary[k]);
|
|
180 ch += strlen (ch) + 1;
|
|
181 }
|
|
182 repeat:
|
|
183 /*
|
|
184 if((c = select_one_element(cccmsg,(sizeof(ccc) / sizeof(char *)),
|
|
185 */
|
|
186 if ((c = select_one_element (cccmsg, (86 - 70 + 1), 0, "", 0, 1, main_table[4])) == -1)
|
|
187 {
|
|
188 return;
|
|
189 }
|
|
190
|
|
191 throw_c (0);
|
|
192 clr_line ();
|
|
193
|
|
194 if (c == 0)
|
|
195 {
|
|
196 /*
|
|
197 sprintf(message , "現在 %d文節解析法を用いています。何文節解析法を用いますか ?" , paraary[0]);
|
|
198 */
|
|
199 sprintf (message, MSG_GET (45), paraary[0]);
|
|
200 }
|
|
201 else
|
|
202 {
|
|
203 /*
|
|
204 sprintf(message , "現在の%sは %dです、幾つにしますか ? ", ccc[c] , paraary[c] );
|
|
205 */
|
|
206 sprintf (message, MSG_GET (46), MSG_GET (70 + c), paraary[c]);
|
|
207 }
|
|
208 kana_buf[0] = 0;
|
|
209 if (kana_in (message, UNDER_LINE_MODE, kana_buf, 1024) == -1)
|
|
210 return;
|
|
211 if (wchartochar (kana_buf, st) || sscanf (st, "%d", &newval) <= 0)
|
|
212 {
|
|
213 /*
|
|
214 print_msg_getc("数字を入力してください。(如何?)");
|
|
215 */
|
|
216 print_msg_getc (MSG_GET (47));
|
|
217 goto repeat;
|
|
218 }
|
|
219 if (c == 0 && newval <= 0)
|
|
220 {
|
|
221 /*
|
|
222 print_msg_getc("正の数字を入力してください。(如何?)");
|
|
223 */
|
|
224 print_msg_getc (MSG_GET (48));
|
|
225 goto repeat;
|
|
226 }
|
|
227 paraary[c] = newval;
|
|
228 if (jl_param_set (bun_data_, ¶) < 0)
|
|
229 {
|
|
230 errorkeyin ();
|
|
231 }
|
|
232 }
|
|
233
|
|
234
|
|
235 void
|
|
236 dicsv ()
|
|
237 {
|
|
238 /*
|
|
239 print_msg("只今、辞書の頻度とユーザ辞書をセーブしています。");
|
|
240 */
|
|
241 print_msg (MSG_GET (49));
|
|
242 flush ();
|
|
243 if (jl_dic_save_all (bun_data_) == -1)
|
|
244 {
|
|
245 errorkeyin ();
|
|
246 }
|
|
247 }
|
|
248
|
|
249 int
|
|
250 update_dic_list (buf)
|
|
251 struct wnn_buf *buf;
|
|
252 {
|
|
253 if ((dic_list_size = jl_dic_list (bun_data_, &dicinfo)) == -1)
|
|
254 {
|
|
255 errorkeyin ();
|
|
256 return (-1);
|
|
257 }
|
|
258 return (0);
|
|
259 }
|
|
260
|
|
261 int
|
|
262 dic_nickname (dic_no, buf)
|
|
263 int dic_no;
|
|
264 char *buf;
|
|
265 {
|
|
266 int j;
|
|
267
|
|
268 if ((j = find_dic_by_no (dic_no)) == -1)
|
|
269 return (-1);
|
|
270 if (*dicinfo[j].comment)
|
|
271 sStrcpy (buf, dicinfo[j].comment);
|
|
272 else
|
|
273 strcpy (buf, dicinfo[j].fname);
|
|
274 return (0);
|
|
275 }
|
|
276
|
|
277 int
|
|
278 find_dic_by_no (dic_no)
|
|
279 int dic_no;
|
|
280 {
|
|
281 int j;
|
|
282
|
|
283 for (j = 0; j < dic_list_size; j++)
|
|
284 {
|
|
285 if (dicinfo[j].dic_no == dic_no)
|
|
286 return (j);
|
|
287 }
|
|
288 return (-1);
|
|
289 }
|
|
290
|
|
291
|
|
292
|
|
293 void
|
|
294 dicinfoout ()
|
|
295 {
|
|
296 int k;
|
|
297 int cnt;
|
|
298 char buf[4096];
|
|
299 char *info[JISHOKOSUU];
|
|
300 int size;
|
|
301
|
|
302 if (update_dic_list (bun_data_) == -1)
|
|
303 {
|
|
304 errorkeyin ();
|
|
305 return;
|
|
306 }
|
|
307 cnt = dic_list_size;
|
|
308
|
|
309 cnt += 1; /* for the comment line */
|
|
310 size = 4096 / cnt;
|
|
311 if (make_info_out (buf, size, dicinfo, cnt) == -1)
|
|
312 {
|
|
313 /*
|
|
314 print_msg("残念、辞書が多すぎます。");
|
|
315 */
|
|
316 print_msg (MSG_GET (50));
|
|
317 return;
|
|
318 }
|
|
319 for (k = 0; k < cnt; k++)
|
|
320 {
|
|
321 info[k] = buf + k * size;
|
|
322 }
|
|
323 set_lc_offset (1);
|
|
324 select_line_element (info, cnt, 0, "", 0, 0, main_table[8]);
|
|
325 set_lc_offset (0);
|
|
326 }
|
|
327
|
|
328
|
|
329 void
|
|
330 select_one_dict8 ()
|
|
331 {
|
|
332 set_lc_offset (0);
|
|
333 select_one_dict1 (8);
|
|
334 }
|
|
335
|
|
336 int
|
|
337 select_one_dict1 (tbl)
|
|
338 int tbl;
|
|
339 {
|
|
340 int l;
|
|
341 char *c;
|
|
342 char buf[4096];
|
|
343 char *buf_ptr[JISHOKOSUU];
|
|
344 char baka[1024];
|
|
345
|
|
346 if (update_dic_list (bun_data_) == -1)
|
|
347 {
|
|
348 errorkeyin ();
|
|
349 return (0);
|
|
350 }
|
|
351 if (dic_list_size == 0)
|
|
352 {
|
|
353 /*
|
|
354 print_msg_getc("辞書が一つも有りません。");
|
|
355 */
|
|
356 print_msg_getc (MSG_GET (51));
|
|
357 return (0);
|
|
358 }
|
|
359
|
|
360 for (c = buf, l = 0; l < dic_list_size; l++)
|
|
361 {
|
|
362 buf_ptr[l] = c;
|
|
363 dic_nickname (dicinfo[l].dic_no, baka);
|
|
364 sprintf (c, "%s(%s) %s %d/%d", baka, dicinfo[l].hfname,
|
|
365 /*
|
|
366 dicinfo[l].enablef? "使用中":"中断中",
|
|
367 */
|
|
368 dicinfo[l].enablef ? MSG_GET (52) : MSG_GET (53), l + 1, dic_list_size);
|
|
369 c += strlen (c) + 1;
|
|
370 }
|
|
371 return (select_line_element (buf_ptr, dic_list_size, 0, "", 0, 0, main_table[tbl]));
|
|
372 }
|
|
373
|
|
374 void
|
|
375 print_msg1 (X)
|
|
376 char *X;
|
|
377 {
|
|
378 push_cursor ();
|
|
379 throw_c (0);
|
|
380 clr_line ();
|
|
381 printf (X);
|
|
382 flush ();
|
|
383 pop_cursor ();
|
|
384 }
|
|
385
|
|
386 void
|
|
387 fuzoku_set ()
|
|
388 {
|
|
389 /*
|
|
390 char *message = "付属語ファイル名 >";
|
|
391 */
|
|
392 char fname[128];
|
|
393 w_char kana_buf[1024];
|
|
394
|
|
395 Strcpy (kana_buf, fuzokugopath);
|
|
396 if (kana_in (MSG_GET (54), UNDER_LINE_MODE, kana_buf, 1024) == -1)
|
|
397 return;
|
|
398 wchartochar (kana_buf, fname);
|
|
399 if (strlen (fname) == 0)
|
|
400 return;
|
|
401 Strcpy (fuzokugopath, kana_buf);
|
|
402 if (jl_fuzokugo_set (bun_data_, fname) == -1)
|
|
403 {
|
|
404 errorkeyin ();
|
|
405 }
|
|
406 }
|
|
407
|
|
408 void
|
|
409 jishoadd ()
|
|
410 {
|
|
411 /*
|
|
412 char *message = "新しい辞書は > ";
|
|
413 char *hmessage = "頻度ファイル名 > ";
|
|
414 char *priomessage = "辞書の優先度の数字を指定して下さい。 > ";
|
|
415 */
|
|
416 char fname[128];
|
|
417 char tmp[128];
|
|
418 char hfname[128];
|
|
419 int prio;
|
|
420 int rdonly;
|
|
421 int hrdonly;
|
|
422 int id, l;
|
|
423 w_char kana_buf[1024];
|
|
424
|
|
425 Strcpy (kana_buf, jishopath);
|
|
426 if (kana_in (MSG_GET (55), UNDER_LINE_MODE, kana_buf, 1024) == -1)
|
|
427 return;
|
|
428 wchartochar (kana_buf, fname);
|
|
429 if (strlen (fname) == 0)
|
|
430 return;
|
|
431 Strcpy (jishopath, kana_buf);
|
|
432
|
|
433 Strcpy (kana_buf, hindopath);
|
|
434 getfname (hfname, fname);
|
|
435 if (strcmp (hfname + strlen (hfname) - 4, ".usr") == 0 ||
|
|
436 strcmp (hfname + strlen (hfname) - 4, ".sys") == 0 || strcmp (hfname + strlen (hfname) - 4, ".dic") == 0 || strcmp (hfname + strlen (hfname) - 4, ".rev") == 0)
|
|
437 {
|
|
438 hfname[strlen (hfname) - 4] = 0;
|
|
439 strcat (hfname, ".h");
|
|
440 }
|
|
441 else if (strcmp (hfname + strlen (hfname) - 5, ".usrR") == 0 || strcmp (hfname + strlen (hfname) - 5, ".sysR") == 0)
|
|
442 {
|
|
443 hfname[strlen (hfname) - 5] = 0;
|
|
444 strcat (hfname, ".hR");
|
|
445 }
|
|
446 else
|
|
447 {
|
|
448 strcat (hfname, ".h");
|
|
449 }
|
|
450 Sstrcpy (kana_buf + Strlen (kana_buf), hfname);
|
|
451 if (kana_in (MSG_GET (56), UNDER_LINE_MODE, kana_buf, 1024) == -1)
|
|
452 {
|
|
453 return;
|
|
454 }
|
|
455 wchartochar (kana_buf, hfname);
|
|
456 sprintf (tmp, "%d", JISHO_PRIO_DEFAULT);
|
|
457 Sstrcpy (kana_buf, tmp);
|
|
458 if (kana_in (MSG_GET (57), UNDER_LINE_MODE, kana_buf, 1024) == -1)
|
|
459 return;
|
|
460 wchartochar (kana_buf, tmp);
|
|
461 prio = atoi (tmp);
|
|
462 /*
|
|
463 if(yes_or_no_or_newline("辞書を更新するモードで使いますか?(Y or Newline / N)") == 1){
|
|
464 */
|
|
465 if (yes_or_no_or_newline (MSG_GET (58)) == 1)
|
|
466 {
|
|
467 rdonly = 0;
|
|
468 }
|
|
469 else
|
|
470 {
|
|
471 rdonly = 1;
|
|
472 }
|
|
473 /*
|
|
474 if(yes_or_no_or_newline("頻度を更新するモードで使いますか?(Y or Newline / N)") == 1){
|
|
475 */
|
|
476 if (yes_or_no_or_newline (MSG_GET (59)) == 1)
|
|
477 {
|
|
478 hrdonly = 0;
|
|
479 }
|
|
480 else
|
|
481 {
|
|
482 hrdonly = 1;
|
|
483 }
|
|
484
|
|
485 throw_c (0);
|
|
486 clr_line ();
|
|
487 /*
|
|
488 printf("只今、辞書を読み込んでいます。");
|
|
489 */
|
|
490 printf (MSG_GET (60));
|
|
491 flush ();
|
|
492
|
|
493 if ((id = jl_dic_add (bun_data_, fname, hfname, 0, prio, rdonly, hrdonly, NULL, NULL, yes_or_no_or_newline, print_msg1)) == -1 && wnn_errorno != -1)
|
|
494 {
|
|
495 errorkeyin ();
|
|
496 }
|
|
497 update_dic_list (bun_data_);
|
|
498 for (l = 0; l < dic_list_size; l++)
|
|
499 {
|
|
500 if (dicinfo[l].dic_no == id)
|
|
501 {
|
|
502 break;
|
|
503 }
|
|
504 }
|
|
505 if (l != dic_list_size && env_reverse && (dicinfo[l].type == WNN_REV_DICT || dicinfo[l].type == BWNN_REV_DICT || dicinfo[l].type == CWNN_REV_DICT))
|
|
506 {
|
|
507 if (jl_dic_add_e (env_reverse, fname, hfname, 1, prio, rdonly, hrdonly, NULL, NULL, yes_or_no_or_newline, print_msg1) == -1 && wnn_errorno != -1)
|
|
508 {
|
|
509 errorkeyin ();
|
|
510 }
|
|
511 }
|
|
512 }
|
|
513
|
|
514 #ifdef nodef
|
|
515 char *
|
|
516 sh_fname (s, n, d) /* file名 sが長い時に、その最後の方を取って n文字にまとめて dに入れる */
|
|
517 char *s, *d;
|
|
518 int n;
|
|
519 {
|
|
520 int k;
|
|
521 char *c, *c1;
|
|
522
|
|
523 k = strlen (s);
|
|
524 if (k < n)
|
|
525 {
|
|
526 strcpy (d, s);
|
|
527 return (d);
|
|
528 }
|
|
529 else
|
|
530 {
|
|
531 c = s + k - n + 2;
|
|
532 c1 = d;
|
|
533 *c1++ = '-';
|
|
534 *c1++ = '-';
|
|
535 for (; *c && *c != '/'; c++)
|
|
536 {
|
|
537 *c1++ = '-';
|
|
538 }
|
|
539 strcpy (c1, c);
|
|
540 return (d);
|
|
541 }
|
|
542 }
|
|
543 #endif
|
|
544
|
|
545 int
|
|
546 yes_or_no (string)
|
|
547 char *string;
|
|
548 {
|
|
549 int x;
|
|
550 throw_c (0);
|
|
551 clr_line ();
|
|
552 printf (string);
|
|
553 flush ();
|
|
554 for (;;)
|
|
555 {
|
|
556 x = keyin ();
|
|
557 if (x == 'n' || x == 'N')
|
|
558 return (0);
|
|
559 if (x == 'y' || x == 'Y')
|
|
560 return (1);
|
|
561 }
|
|
562 }
|
|
563
|
|
564
|
|
565 int
|
|
566 yes_or_no_or_newline (string)
|
|
567 char *string;
|
|
568 {
|
|
569 int x;
|
|
570 throw_c (0);
|
|
571 clr_line ();
|
|
572 printf (string);
|
|
573 flush ();
|
|
574 for (;;)
|
|
575 {
|
|
576 x = keyin ();
|
|
577 if (x == 'n' || x == 'N')
|
|
578 return (0);
|
|
579 if (x == 'y' || x == 'Y' || x == '\n' || x == CR)
|
|
580 return (1);
|
|
581 }
|
|
582 }
|
|
583
|
|
584
|
|
585
|
|
586
|
|
587 /*
|
|
588 static char *info_out_data[] ={
|
|
589 "No.",
|
|
590 "Type",
|
|
591 "こめんと",
|
|
592 "ファイル名",
|
|
593 "頻度ファイル名",
|
|
594 "語彙数",
|
|
595 "優先度",
|
|
596 "登録可能",
|
|
597 "頻度更新可能",
|
|
598 "使用中か",
|
|
599 "登録パスワード",
|
|
600 "頻度更新パスワード",
|
|
601 ""
|
|
602 };
|
|
603 */
|
|
604
|
|
605 int
|
|
606 make_info_out (buf, size, infobuf, cnt)
|
|
607 char buf[];
|
|
608 WNN_DIC_INFO infobuf[];
|
|
609 int cnt;
|
|
610 int size;
|
|
611 {
|
|
612 int max1 = 0;
|
|
613 int max0 = 0;
|
|
614 int i, k, j;
|
|
615
|
|
616 for (k = 0; k < cnt; k++)
|
|
617 {
|
|
618 for (j = 0; j < size; j++)
|
|
619 {
|
|
620 buf[k * size + j] = 0;
|
|
621 }
|
|
622 }
|
|
623
|
|
624 for (i = 0; i < 13; i++)
|
|
625 {
|
|
626 if (i == 12)
|
|
627 {
|
|
628 sprintf (buf + max0, "%3d/%-3d", 0, cnt - 1);
|
|
629 }
|
|
630 else
|
|
631 {
|
|
632 /*
|
|
633 sprintf(buf + max0,"%s",info_out_data[i]);
|
|
634 */
|
|
635 sprintf (buf + max0, "%s", MSG_GET (87 + i));
|
|
636 }
|
|
637 max1 = max (max1, strlen (buf));
|
|
638 if (max1 >= size)
|
|
639 return (-1);
|
|
640 for (k = 1; k < cnt; k++)
|
|
641 {
|
|
642 switch (i)
|
|
643 {
|
|
644 case 0:
|
|
645 sprintf (buf + size * k + max0, "%3d ", infobuf[k - 1].dic_no);
|
|
646 break;
|
|
647 case 1:
|
|
648 {
|
|
649 char *tmp;
|
|
650 if ((0xff00 & infobuf[k - 1].type) == (BWNN_REV_DICT & 0xff00))
|
|
651 tmp = bwnn_dic_types[0xff & infobuf[k - 1].type];
|
|
652 else if ((0xff00 & infobuf[k - 1].type) == (CWNN_REV_DICT & 0xff00))
|
|
653 tmp = cwnn_dic_types[0xff & infobuf[k - 1].type];
|
|
654 else
|
|
655 tmp = wnn_dic_types[infobuf[k - 1].type];
|
|
656 sprintf (buf + size * k + max0, "%8s", tmp);
|
|
657 break;
|
|
658 }
|
|
659 case 2:
|
|
660 sStrcpy (buf + size * k + max0, infobuf[k - 1].comment);
|
|
661 break;
|
|
662 case 3:
|
|
663 strcpy (buf + size * k + max0, infobuf[k - 1].fname);
|
|
664 break;
|
|
665 case 4:
|
|
666 strcpy (buf + size * k + max0, infobuf[k - 1].hfname);
|
|
667 break;
|
|
668 case 5:
|
|
669 sprintf (buf + size * k + max0, "%6d", infobuf[k - 1].gosuu);
|
|
670 break;
|
|
671 case 6:
|
|
672 sprintf (buf + size * k + max0, "%4d", infobuf[k - 1].nice);
|
|
673 break;
|
|
674 case 7:
|
|
675 strcpy (buf + size * k + max0, (!infobuf[k - 1].rw) ? "Yes" : "No");
|
|
676 break;
|
|
677 case 8:
|
|
678 strcpy (buf + size * k + max0, (!infobuf[k - 1].hindo_rw) ? "Yes" : "No");
|
|
679 break;
|
|
680 case 9:
|
|
681 /*
|
|
682 strcpy(buf + size * k + max0,(infobuf[k - 1].enablef)? "使用中":"中断中");
|
|
683 */
|
|
684 strcpy (buf + size * k + max0, (infobuf[k - 1].enablef) ? MSG_GET (52) : MSG_GET (53));
|
|
685 break;
|
|
686 case 10:
|
|
687 strcpy (buf + size * k + max0, infobuf[k - 1].passwd);
|
|
688 break;
|
|
689 case 11:
|
|
690 strcpy (buf + size * k + max0, infobuf[k - 1].hpasswd);
|
|
691 break;
|
|
692 case 12:
|
|
693 sprintf (buf + size * k + max0, "%3d/%-3d", k, cnt - 1);
|
|
694 break;
|
|
695 }
|
|
696 max1 = max (max1, strlen (buf + size * k));
|
|
697 if (max1 >= size)
|
|
698 return (-1);
|
|
699 }
|
|
700 max0 = max1 + 1;
|
|
701 for (k = 0; k < cnt; k++)
|
|
702 {
|
|
703 fill (buf + size * k, max0);
|
|
704 }
|
|
705 }
|
|
706 return (1);
|
|
707 }
|
|
708
|
|
709
|
|
710 void
|
|
711 fill (c, x)
|
|
712 char *c;
|
|
713 int x;
|
|
714 {
|
|
715 for (; *c; c++, x--);
|
|
716 for (; x; x--, c++)
|
|
717 {
|
|
718 *c = ' ';
|
|
719 }
|
|
720 }
|