| 1 |
|
| 2 |
#include <stdio.h> |
| 3 |
#include <stdarg.h> |
| 4 |
#include <stdlib.h> |
| 5 |
|
| 6 |
extern int scot(FILE *inf, FILE *outf, char *fil); |
| 7 |
|
| 8 |
int main(int argc, char **argv) |
| 9 |
{ |
| 10 |
FILE *infile = NULL, *outfile = NULL; |
| 11 |
char *name = NULL, *outname = "score"; |
| 12 |
|
| 13 |
if (argc == 2 || argc == 3) { |
| 14 |
if (argc == 3) outname = argv[2]; |
| 15 |
if (!(infile = fopen(argv[1], "r"))) { |
| 16 |
fprintf(stderr, "Can't open input file \"%s\"\n", argv[1]); |
| 17 |
return -1; |
| 18 |
} |
| 19 |
name = argv[1]; |
| 20 |
} |
| 21 |
else if (argc == 1) { |
| 22 |
infile = stdin; |
| 23 |
name = ""; |
| 24 |
} |
| 25 |
else { |
| 26 |
fprintf(stderr, "Usage: scot [<infile> [<outfile>]]\n"); |
| 27 |
return -1; |
| 28 |
} |
| 29 |
if (!(outfile = fopen(outname, "w"))) { |
| 30 |
fprintf(stderr, "Can't open output file \"%s\"\n", outname); |
| 31 |
return -1; |
| 32 |
} |
| 33 |
scot(infile, outfile, name); |
| 34 |
fclose(infile); |
| 35 |
fclose(outfile); |
| 36 |
|
| 37 |
return 0; |
| 38 |
} |
| 39 |
|