farbfeld

suckless image format with conversion tools
git clone git://git.suckless.org/farbfeld
Log | Files | Refs | README | LICENSE

commit ba60aa33d91ba7329218117c067c4f5940b9d001
parent bc58a701d118e074c935bf29af095d72b95f8a31
Author: FRIGN <dev@frign.de>
Date:   Tue, 10 Nov 2015 18:51:57 +0100

Remove arg.h

No need for this when the tools don't accept arguments.

Diffstat:
Darg.h | 63---------------------------------------------------------------
Mff2png.c | 26+++++++-------------------
Mpng2ff.c | 24++++++------------------
3 files changed, 13 insertions(+), 100 deletions(-)

diff --git a/arg.h b/arg.h @@ -1,63 +0,0 @@ -/* - * Copy me if you can. - * by 20h - */ - -#ifndef ARG_H__ -#define ARG_H__ - -extern char *argv0; - -/* use main(int argc, char *argv[]) */ -#define ARGBEGIN for (argv0 = *argv, argv++, argc--;\ - argv[0] && argv[0][1]\ - && argv[0][0] == '-';\ - argc--, argv++) {\ - char argc_;\ - char **argv_;\ - int brk_;\ - if (argv[0][1] == '-' && argv[0][2] == '\0') {\ - argv++;\ - argc--;\ - break;\ - }\ - for (brk_ = 0, argv[0]++, argv_ = argv;\ - argv[0][0] && !brk_;\ - argv[0]++) {\ - if (argv_ != argv)\ - break;\ - argc_ = argv[0][0];\ - switch (argc_) - -/* Handles obsolete -NUM syntax */ -#define ARGNUM case '0':\ - case '1':\ - case '2':\ - case '3':\ - case '4':\ - case '5':\ - case '6':\ - case '7':\ - case '8':\ - case '9' - -#define ARGEND }\ - } - -#define ARGC() argc_ - -#define ARGNUMF(base) (brk_ = 1, estrtol(argv[0], (base))) - -#define EARGF(x) ((argv[0][1] == '\0' && argv[1] == NULL)?\ - ((x), abort(), (char *)0) :\ - (brk_ = 1, (argv[0][1] != '\0')?\ - (&argv[0][1]) :\ - (argc--, argv++, argv[0]))) - -#define ARGF() ((argv[0][1] == '\0' && argv[1] == NULL)?\ - (char *)0 :\ - (brk_ = 1, (argv[0][1] != '\0')?\ - (&argv[0][1]) :\ - (argc--, argv++, argv[0]))) - -#endif diff --git a/ff2png.c b/ff2png.c @@ -4,38 +4,25 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <png.h> - -#include "arg.h" -char *argv0; +#include <png.h> #define HEADER_FORMAT "farbfeld########" -static void -usage(void) -{ - fprintf(stderr, "usage: %s\n", argv0); - exit(1); -} - int main(int argc, char *argv[]) { png_structp png_struct_p; png_infop png_info_p; - uint8_t hdr[17], *png_row; + uint8_t hdr[16], *png_row; uint16_t tmp16; png_uint_32 width, height, i; png_size_t png_row_len, j; - ARGBEGIN { - default: - usage(); - } ARGEND; - - if (argc) - usage(); + if (argc > 1) { + fprintf(stderr, "usage: %s\n", argv[0]); + return 1; + } /* header */ if (fread(hdr, 1, strlen(HEADER_FORMAT), stdin) != strlen(HEADER_FORMAT)) { @@ -87,5 +74,6 @@ main(int argc, char *argv[]) png_free_data(png_struct_p, png_info_p, PNG_FREE_ALL, -1); png_destroy_write_struct(&png_struct_p, NULL); free(png_row); + return 0; } diff --git a/png2ff.c b/png2ff.c @@ -3,18 +3,8 @@ #include <stdint.h> #include <stdio.h> #include <stdlib.h> -#include <png.h> - -#include "arg.h" - -char *argv0; -static void -usage(void) -{ - fprintf(stderr, "usage:%s\n", argv0); - exit(1); -} +#include <png.h> int main(int argc, char *argv[]) @@ -26,13 +16,10 @@ main(int argc, char *argv[]) uint32_t width, height, png_row_len, tmp32, r, i; uint16_t tmp16; - ARGBEGIN { - default: - usage(); - } ARGEND - - if (argc) - usage(); + if (argc > 1) { + fprintf(stderr, "usage:%s\n", argv[0]); + return 1; + } /* load png */ png_struct_p = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, @@ -72,5 +59,6 @@ main(int argc, char *argv[]) /* cleanup */ png_destroy_read_struct(&png_struct_p, &png_info_p, NULL); + return 0; }