summaryrefslogtreecommitdiff
path: root/ff2ppm.c
diff options
context:
space:
mode:
Diffstat (limited to 'ff2ppm.c')
-rw-r--r--ff2ppm.c18
1 files changed, 4 insertions, 14 deletions
diff --git a/ff2ppm.c b/ff2ppm.c
index b34d870..5e11eb5 100644
--- a/ff2ppm.c
+++ b/ff2ppm.c
@@ -53,16 +53,8 @@ main(int argc, char *argv[])
printf("P6\n%" PRIu32 " %" PRIu32 "\n255\n", width, height);
for (i = 0; i < height; ++i) {
- if (fread(row, sizeof(uint16_t), rowlen, stdin) != rowlen) {
- if (ferror(stdin)) {
- fprintf(stderr, "%s: fread: %s\n", argv0,
- strerror(errno));
- } else {
- fprintf(stderr, "%s: unexpected end of file\n",
- argv0);
- }
- return 1;
- }
+ efread(row, sizeof(uint16_t), rowlen, stdin);
+
for (j = 0, k = 0; j < rowlen; j += 4, k += 3) {
a = ntohs(row[j + 3]);
for (l = 0; l < 3; l++) {
@@ -73,10 +65,8 @@ main(int argc, char *argv[])
(UINT16_MAX / UINT8_MAX));
}
}
- if (fwrite(rowout, sizeof(uint8_t), rowoutlen, stdout) != rowoutlen) {
- fprintf(stderr, "%s: fwrite: %s\n", argv0, strerror(errno));
- return 1;
- }
+
+ efwrite(rowout, sizeof(uint8_t), rowoutlen, stdout);
}
return fshut(stdout, "<stdout>");