1 /*
2 * $Id: sort.c,v 1.5 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, 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 sort program
34 */
35
36 #ifndef lint
37 static char *rcs_id = "$Id: sort.c,v 1.5 2004/07/19 18:24:26 hiroo Exp $";
38 #endif /* lint */
39
40 #include <stdio.h>
41 #include "commonhd.h"
42 #include "wnn_config.h"
43 #include "jslib.h"
44 #include "jh.h"
45 #include "jdata.h"
46 #include "getopt.h" /* GNU getopt in the stock */
47
48 extern int init_heap ();
49 extern void ujis_header (), read_ujis (), reverse_yomi (), sort (), output_ujis ();
50 int reverse = 0;
51 struct JT jt;
52 struct wnn_file_head file_head;
53
54 void
main(int argc,char ** argv)55 main (int argc, char** argv)
56 {
57 int c;
58 char *cswidth_name;
59 extern char *get_cswidth_name ();
60 extern void set_cswidth ();
61
62 if (cswidth_name = get_cswidth_name (WNN_DEFAULT_LANG))
63 set_cswidth (create_cswidth (cswidth_name));
64 while ((c = getopt (argc, argv, "r")) != EOF)
65 {
66 switch (c)
67 {
68 case 'r':
69 reverse = 1;
70 break;
71 }
72 }
73 init_heap (MAX_ENTRIES * HEAP_PER_LINE, MAX_ENTRIES * YOMI_PER_LINE, MAX_ENTRIES, MAX_ENTRIES, stdin);
74
75 #ifdef CHINESE
76 {
77 int which_dict;
78 ujis_header (&which_dict);
79 }
80 #else
81 ujis_header ();
82 #endif
83 read_ujis (NORMAL, 0, 0);
84 #ifdef CHINESE
85 sort ();
86 #else
87 if (reverse)
88 reverse_yomi ();
89 sort ();
90 if (reverse)
91 reverse_yomi ();
92 #endif
93 output_ujis (stdout, 0, 1);
94 }
95