-
Notifications
You must be signed in to change notification settings - Fork 3
/
cm_main.c
88 lines (74 loc) · 1.85 KB
/
cm_main.c
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/***************************************
$Header$
Main routine for mini-translater
***************************************/
/* Copyright 1998-2001 Richard P. Curnow */
/* Help options added by Björn Gohla */
/* LICENCE */
#include "cm.h"
#include "version.h"
extern FILE *yyin;
extern int yylex(void);
int
yywrap(void)
{
return 1;
}
int
main (int argc, char **argv)
{
char *filename = NULL;
FILE *in = NULL;
ofmt = OF_TEXT;
width = 80;
while (++argv,--argc) {
if (!strcmp(*argv, "-l")) {
ofmt = OF_LATEX;
} else if (!strcmp(*argv, "-b")) {
ofmt = OF_TEXTBLK;
#ifdef PLIST
} else if (!strcmp(*argv, "-p")) {
ofmt = OF_PLIST;
#endif
} else if (!strcmp(*argv, "-w")) {
++argv, --argc;
width = atoi(*argv);
} else if (!strcmp(*argv, "-v")) {
fprintf(stderr, "cmafihe version %s\n", version_string);
exit(0);
} else if ( !strcmp(*argv, "-h") || !strcmp(*argv, "--help") ) {
fprintf(stderr, "cmafihe, gloss lojban text without verifying\n"
"usage: cmafihe [-b [-w WIDTH] | -p | -l | -v] [FILENAME]\n"
"no options : output inline ascii\n"
"-b : output blocked ascii with optional WIDTH, default %i\n"
"-l : output blocked latex code\n"
#ifdef PLIST
"-p : output GNUStep property list with vocabulary\n"
#endif
"-v : version\n", width);
exit(0);
} else {
filename = *argv;
}
}
if (filename) {
in = fopen(filename, "rb");
if (!in) {
fprintf(stderr, "Could not open %s for input\n", filename);
exit(1);
}
}
if (in) {
yyin = in;
}
yylex();
if (in) {
fclose(in);
}
do_trans();
start_output();
do_output();
end_output();
output_newline();
return 0;
}