blob: c2a493426e088ab6775872e49ca339df2e348447 (
plain)
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
|
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include "xex.h"
#define SELF "f2toxex"
void version() {
printf(SELF " " VERSION "\n");
}
void usage() {
version();
printf(" Usage: " SELF " [-h | -v] | infile [outfile]\n");
}
char *make_outfile(char *infile) {
}
int main(int argc, char **argv) {
int c;
char *infile, *outfile;
while( (c = getopt(argc, argv, "hv")) > 0) {
switch(c) {
case 'h':
usage();
exit(0);
break;
case 'v':
version();
exit(0);
break;
default:
fprintf(stderr, SELF ": unknown option '-%c'.\n", c);
usage();
exit(1);
break;
}
}
if(argc > optind) {
infile = argv[optind];
optind++;
}
if(argc > optind) {
strcpy(outfile, argv[optind]);
optind++;
if(argc > optind)
fprintf(stderr, SELF ": "
"ignoring extra junk on command line: '%s'.\n", argv[optind]);
} else if(strcmp(infile, "-") != 0) {
outfile = make_outfile(infile);
}
return 0;
}
|