|
1826
|
1 |
/* Title: Tools/8bit/c-sources/a2isa/main.c
|
|
|
2 |
ID: $Id$
|
|
|
3 |
Author: David von Oheimb
|
|
|
4 |
Copyright 1996 TU Muenchen
|
|
|
5 |
|
|
|
6 |
converter for isabelle files, from ASCII to graphical characters
|
|
|
7 |
main file (ANSI-C)
|
|
|
8 |
*/
|
|
|
9 |
|
|
|
10 |
#include <stdio.h>
|
|
|
11 |
|
|
|
12 |
extern int yylex(void);
|
|
|
13 |
|
|
|
14 |
FILE* finput; /* input file, default = stdin */
|
|
|
15 |
FILE* foutput; /* output file,default = stdout */
|
|
|
16 |
|
|
|
17 |
void error(char* s, char* t)
|
|
|
18 |
{
|
|
|
19 |
fprintf(stderr, "Error! %s: %s\n", s, t);
|
|
|
20 |
}
|
|
|
21 |
|
|
|
22 |
void usage(void)
|
|
|
23 |
{
|
|
|
24 |
fprintf(stderr, "Isabelle ASCII to 8bit converter. Valid Options:\n");
|
|
|
25 |
fprintf(stderr, "<file>: input file other than stdin\n");
|
|
|
26 |
fprintf(stderr, "-o <file>: output file other than stdout\n");
|
|
|
27 |
fprintf(stderr, "-h(elp): print this message\n");
|
|
|
28 |
}
|
|
|
29 |
|
|
|
30 |
int main(int argc, char* argv[])
|
|
|
31 |
{
|
|
|
32 |
char *s; /* pointer to traverse components of argv */
|
|
|
33 |
|
|
|
34 |
finput = stdin;
|
|
|
35 |
foutput = stdout;
|
|
|
36 |
|
|
|
37 |
while (--argc > 0) {
|
|
|
38 |
s = *++argv;
|
|
|
39 |
if (*s++ == '-')
|
|
|
40 |
switch (*s) {
|
|
|
41 |
case 'h':
|
|
|
42 |
usage();
|
|
|
43 |
exit(0);
|
|
|
44 |
case 'o':
|
|
|
45 |
if (--argc) {
|
|
|
46 |
if ((foutput = fopen(*++argv, "w")) == NULL) {
|
|
|
47 |
error("Creating output file", *argv);
|
|
|
48 |
exit(-1);
|
|
|
49 |
}
|
|
|
50 |
} else {
|
|
|
51 |
error("No output file specified for option", s);
|
|
|
52 |
usage();
|
|
|
53 |
exit(-1);
|
|
|
54 |
}
|
|
|
55 |
break;
|
|
|
56 |
default:
|
|
|
57 |
error("Unknown option", s);
|
|
|
58 |
usage();
|
|
|
59 |
exit(-1);
|
|
|
60 |
} /* switch */
|
|
|
61 |
else
|
|
|
62 |
/*
|
|
|
63 |
* no further parameters with "-"; therefore we see input file:
|
|
|
64 |
*/
|
|
|
65 |
if ((finput = fopen(--s, "r")) == NULL) {
|
|
|
66 |
error("Opening input file", s);
|
|
|
67 |
exit(-1);
|
|
|
68 |
}
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
yylex();
|
|
|
72 |
|
|
|
73 |
return(0);
|
|
|
74 |
}
|
|
|
75 |
|
|
|
76 |
|