13 |
|
#include "rtmath.h" |
14 |
|
#include "normcodec.h" |
15 |
|
|
16 |
– |
char *progname; /* set in main() */ |
16 |
|
|
18 |
– |
|
17 |
|
/* Report usage error and exit */ |
18 |
|
static void |
19 |
|
usage_exit(int code) |
50 |
|
return 0; |
51 |
|
} |
52 |
|
} |
53 |
+ |
if (ncp->format == 'a') |
54 |
+ |
SET_FILE_TEXT(ncp->finp); |
55 |
|
|
56 |
|
do { |
57 |
|
int ok = 0; |
189 |
|
fputs(": can only handle standard pixel ordering\n", stderr); |
190 |
|
return 0; |
191 |
|
} |
192 |
+ |
|
193 |
|
while (scanf("%d %d", &x, &y) == 2) { |
194 |
|
|
195 |
|
y = ncp->res.yr-1 - y; |
223 |
|
int unbuffered = 0; |
224 |
|
NORMCODEC nc; |
225 |
|
int a; |
226 |
< |
|
227 |
< |
progname = argv[0]; |
226 |
> |
/* set global progname */ |
227 |
> |
fixargv0(argv[0]); |
228 |
|
set_nc_defaults(&nc); |
229 |
|
nc.hdrflags = HF_ALL; |
230 |
|
for (a = 1; a < argc && argv[a][0] == '-'; a++) |
340 |
|
fputs(": cannot open for writing\n", stderr); |
341 |
|
return 1; |
342 |
|
} |
343 |
< |
SET_FILE_BINARY(nc.finp); |
344 |
< |
if (reverse || nc.format != 'a') |
344 |
< |
SET_FILE_BINARY(stdout); |
343 |
> |
SET_FILE_BINARY(nc.finp); /* starting assumption */ |
344 |
> |
SET_FILE_BINARY(stdout); |
345 |
|
#ifdef getc_unlocked /* avoid stupid semaphores */ |
346 |
|
flockfile(nc.finp); |
347 |
|
flockfile(stdout); |
349 |
|
/* read/copy header */ |
350 |
|
if (!process_nc_header(&nc, a, argv)) |
351 |
|
return 1; |
352 |
+ |
|
353 |
+ |
if (reverse && nc.format == 'a') |
354 |
+ |
SET_FILE_TEXT(stdout); |
355 |
|
/* process data */ |
356 |
|
if (!reverse) { |
357 |
|
if (!encode_normals(&nc)) |