57 |
|
if (argc > 1 && !strcmp(argv[1], "-d")) { |
58 |
|
argc--; argv++; |
59 |
|
dim = 1; |
60 |
< |
SET_FILE_BINARY(stdin); |
61 |
< |
} else if (argc > 2 && !strcmp(argv[1], "-c")) { |
62 |
< |
SET_FILE_BINARY(stdin); |
60 |
> |
} |
61 |
> |
#ifdef getc_unlocked /* avoid lock/unlock overhead */ |
62 |
> |
flockfile(stdin); |
63 |
> |
#endif |
64 |
> |
SET_FILE_BINARY(stdin); |
65 |
> |
if (argc > 2 && !strcmp(argv[1], "-c")) { |
66 |
|
SET_FILE_BINARY(stdout); |
67 |
|
setvbuf(stdin, NULL, _IONBF, 2); |
68 |
|
if (getheader(stdin, (gethfunc *)fputs, stdout) < 0) |
69 |
|
return 1; |
70 |
|
printargs(argc-2, argv+2, stdout); |
71 |
|
fputc('\n', stdout); |
72 |
+ |
if (dim) { /* copy resolution string? */ |
73 |
+ |
RESOLU rs; |
74 |
+ |
if (!fgetsresolu(&rs, stdin)) { |
75 |
+ |
fputs("No resolution string\n", stderr); |
76 |
+ |
return 1; |
77 |
+ |
} |
78 |
+ |
fputsresolu(&rs, stdout); |
79 |
+ |
} |
80 |
|
fflush(stdout); |
81 |
|
execvp(argv[2], argv+2); |
82 |
|
perror(argv[2]); |
83 |
|
return 1; |
84 |
|
} else if (argc > 2 && !strcmp(argv[1], "-a")) { |
74 |
– |
SET_FILE_BINARY(stdin); |
85 |
|
SET_FILE_BINARY(stdout); |
86 |
|
if (getheader(stdin, (gethfunc *)fputs, stdout) < 0) |
87 |
|
return 1; |
96 |
|
copycat(); |
97 |
|
return 0; |
98 |
|
} else if (argc == 2 && !strcmp(argv[1], "-")) { |
89 |
– |
SET_FILE_BINARY(stdin); |
99 |
|
SET_FILE_BINARY(stdout); |
100 |
|
if (getheader(stdin, NULL, NULL) < 0) |
101 |
|
return 1; |
102 |
+ |
if (dim) { /* skip resolution string? */ |
103 |
+ |
RESOLU rs; |
104 |
+ |
if (!fgetsresolu(&rs, stdin)) { |
105 |
+ |
fputs("No resolution string\n", stderr); |
106 |
+ |
return 1; |
107 |
+ |
} |
108 |
+ |
} |
109 |
|
copycat(); |
110 |
|
return 0; |
111 |
|
} |