fst-text2bin.C
1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*******************************************************************/
/* */
/* FILE fst-text2bin.C */
/* MODULE fst-text2bin */
/* PROGRAM SFST */
/* AUTHOR Helmut Schmid, IMS, University of Stuttgart */
/* */
/*******************************************************************/
#include "fst.h"
using std::cerr;
/*******************************************************************/
/* */
/* main */
/* */
/*******************************************************************/
int main( int argc, char **argv )
{
FILE *file;
if (argc < 3 || (argc > 1 && (strcmp(argv[1],"-h") == 0 ||
strcmp(argv[1],"-help") == 0 ||
strcmp(argv[1],"-?") == 0)))
{
fprintf(stderr,"\nUsage: %s file file\n\n", argv[0]);
exit(1);
}
if ((file = fopen(argv[1],"rt")) == NULL) {
fprintf(stderr,"\nError: Cannot open input file %s\n\n", argv[1]);
exit(1);
}
try {
Transducer a(file, false); // read a transducer in text format
fclose(file);
if ((file = fopen(argv[2],"wb")) == NULL) {
fprintf(stderr,"\nError: Cannot open output file %s\n\n", argv[2]);
exit(1);
}
a.store(file);
fclose(file);
}
catch (const char *p) {
cerr << p << "\n";
return 1;
}
return 0;
}