FreeCalypso > hg > gsm-codec-lib
changeset 564:30c57cf6e87d
gsmhr-dec-parse: read native endian by default
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 12 Feb 2025 00:33:32 +0000 |
parents | a563c7b17e16 |
children | ec146b5b9c91 |
files | hrutil/Makefile hrutil/dec-parse.c |
diffstat | 2 files changed, 23 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/hrutil/Makefile Wed Feb 12 00:32:35 2025 +0000 +++ b/hrutil/Makefile Wed Feb 12 00:33:32 2025 +0000 @@ -16,7 +16,7 @@ gsmhr-dec-craft: dec-craft.o ${LIBHR1} ${CC} ${CFLAGS} -o $@ $^ -gsmhr-dec-parse: dec-parse.o print-frame.o read-dec.o ${LIBHR1} +gsmhr-dec-parse: dec-parse.o print-frame.o read-dec.o ${LIBS} ${CC} ${CFLAGS} -o $@ $^ tw5b-dump: print-frame.o tw5b-dump.o ${LIBS}
--- a/hrutil/dec-parse.c Wed Feb 12 00:32:35 2025 +0000 +++ b/hrutil/dec-parse.c Wed Feb 12 00:33:32 2025 +0000 @@ -8,7 +8,9 @@ #include <stdlib.h> #include <string.h> #include <strings.h> +#include <unistd.h> #include "../libgsmhr1/tw_gsmhr.h" +#include "../libtest/local_endian.h" main(argc, argv) char **argv; @@ -18,18 +20,28 @@ int big_endian; unsigned frame_no; int16_t params[GSMHR_NUM_PARAMS_DEC]; - int rc; + int opt, rc; + extern int optind; - if (argc == 2 && argv[1][0] != '-') { - big_endian = 0; - infname = argv[1]; - } else if (argc == 3 && !strcmp(argv[1], "-b")) { - big_endian = 1; - infname = argv[2]; - } else { - fprintf(stderr, "usage: %s [-b] file.dec\n", argv[0]); - exit(1); + big_endian = is_native_big_endian(); + while ((opt = getopt(argc, argv, "bl")) != EOF) { + switch (opt) { + case 'b': + big_endian = 1; + continue; + case 'l': + big_endian = 0; + continue; + default: + usage: + fprintf(stderr, "usage: %s [-b|-l] file.dec\n", + argv[0]); + exit(1); + } } + if (argc != optind + 1) + goto usage; + infname = argv[optind]; inf = fopen(infname, "r"); if (!inf) { perror(infname);