diff options
author | Laslo Hunhold <dev@frign.de> | 2017-03-30 09:49:48 +0200 |
---|---|---|
committer | Laslo Hunhold <dev@frign.de> | 2017-03-30 09:49:48 +0200 |
commit | d25f3c73afa5beb83121c9b033bc0146c755ca3a (patch) | |
tree | 2d2407a2d07cb87f3da44e98cdd6131b3c9e5bd3 /ff2jpg.c | |
parent | d0ce307972fbc95073666e92043fc7012ffbefdf (diff) |
Add util.{c|h} to deduplicate code
Diffstat (limited to 'ff2jpg.c')
-rw-r--r-- | ff2jpg.c | 19 |
1 files changed, 5 insertions, 14 deletions
@@ -11,8 +11,7 @@ #include <jpeglib.h> #include "arg.h" - -char *argv0; +#include "util.h" METHODDEF(void) jpeg_error(j_common_ptr js) @@ -37,7 +36,7 @@ main(int argc, char *argv[]) struct jpeg_error_mgr jerr; size_t rowlen; uint64_t a; - uint32_t hdr[4], width, height, i, j, k, l; + uint32_t width, height, i, j, k, l; uint16_t *row, mask[3] = { 0xffff, 0xffff, 0xffff }; uint8_t *rowout; char *color, colfmt[] = "%#x%#x%#x"; @@ -75,19 +74,11 @@ main(int argc, char *argv[]) usage(); } ARGEND - if (argc) + if (argc) { usage(); - - /* header */ - if (fread(hdr, sizeof(*hdr), 4, stdin) != 4) { - goto readerr; } - if (memcmp("farbfeld", hdr, sizeof("farbfeld") - 1)) { - fprintf(stderr, "%s: invalid magic value\n", argv0); - return 1; - } - width = ntohl(hdr[2]); - height = ntohl(hdr[3]); + + read_ff_header(&width, &height); if (width > SIZE_MAX / ((sizeof("RGBA") - 1) * sizeof(uint16_t))) { fprintf(stderr, "%s: row length integer overflow\n", argv0); |