| 27 |
|
char *progname; |
| 28 |
|
|
| 29 |
|
|
| 30 |
< |
int |
| 31 |
< |
neworder() /* figure out new order from old */ |
| 30 |
> |
static void memerr(void); |
| 31 |
> |
static void scanfile(void); |
| 32 |
> |
static void flip(void); |
| 33 |
> |
|
| 34 |
> |
|
| 35 |
> |
static int |
| 36 |
> |
neworder(void) /* figure out new order from old */ |
| 37 |
|
{ |
| 38 |
|
register int no; |
| 39 |
|
|
| 49 |
|
return(no); |
| 50 |
|
} |
| 51 |
|
|
| 52 |
< |
|
| 53 |
< |
main(argc, argv) |
| 54 |
< |
int argc; |
| 55 |
< |
char *argv[]; |
| 52 |
> |
int |
| 53 |
> |
main( |
| 54 |
> |
int argc, |
| 55 |
> |
char *argv[] |
| 56 |
> |
) |
| 57 |
|
{ |
| 58 |
< |
static char picfmt[LPICFMT+1] = PICFMT; |
| 58 |
> |
static char picfmt[MAXFMTLEN] = PICFMT; |
| 59 |
|
int i, rval; |
| 60 |
|
SET_DEFAULT_BINARY(); |
| 61 |
|
SET_FILE_BINARY(stdout); |
| 70 |
|
correctorder++; |
| 71 |
|
else |
| 72 |
|
break; |
| 73 |
+ |
if (i < argc-2) |
| 74 |
+ |
goto userr; |
| 75 |
+ |
if (!fhoriz && !fvert) |
| 76 |
+ |
fprintf(stderr, "%s: warning - no operation\n", argv[0]); |
| 77 |
|
if (i >= argc || argv[i][0] == '-') { |
| 78 |
< |
fprintf(stderr, "Usage: %s [-h][-v][-c] infile [outfile]\n", |
| 79 |
< |
progname); |
| 78 |
> |
if (fvert) |
| 79 |
> |
goto userr; |
| 80 |
> |
SET_FILE_BINARY(stdin); |
| 81 |
> |
fin = stdin; |
| 82 |
> |
} else if ((fin = fopen(argv[i], "r")) == NULL) { |
| 83 |
> |
fprintf(stderr, "%s: cannot open\n", argv[i]); |
| 84 |
|
exit(1); |
| 85 |
|
} |
| 72 |
– |
if ((fin = fopen(argv[i], "r")) == NULL) { |
| 73 |
– |
fprintf(stderr, "%s: cannot open\n", argv[1]); |
| 74 |
– |
exit(1); |
| 75 |
– |
} |
| 86 |
|
if (i < argc-1 && freopen(argv[i+1], "w", stdout) == NULL) { |
| 87 |
|
fprintf(stderr, "%s: cannot open\n", argv[i+1]); |
| 88 |
|
exit(1); |
| 110 |
|
scanfile(); |
| 111 |
|
flip(); /* flip the image */ |
| 112 |
|
exit(0); |
| 113 |
+ |
userr: |
| 114 |
+ |
fprintf(stderr, "Usage: %s [-h][-v][-c] infile [outfile]\n", |
| 115 |
+ |
progname); |
| 116 |
+ |
exit(1); |
| 117 |
|
} |
| 118 |
|
|
| 119 |
|
|
| 120 |
< |
memerr() |
| 120 |
> |
static void |
| 121 |
> |
memerr(void) |
| 122 |
|
{ |
| 123 |
|
fprintf(stderr, "%s: out of memory\n", progname); |
| 124 |
|
exit(1); |
| 125 |
|
} |
| 126 |
|
|
| 127 |
|
|
| 128 |
< |
scanfile() /* scan to the end of file */ |
| 128 |
> |
static void |
| 129 |
> |
scanfile(void) /* scan to the end of file */ |
| 130 |
|
{ |
| 131 |
|
extern long ftell(); |
| 132 |
|
COLR *scanin; |
| 148 |
|
} |
| 149 |
|
|
| 150 |
|
|
| 151 |
< |
flip() /* flip the picture */ |
| 151 |
> |
static void |
| 152 |
> |
flip(void) /* flip the picture */ |
| 153 |
|
{ |
| 154 |
|
COLR *scanin, *scanout; |
| 155 |
|
int y; |