FreeCalypso > hg > gsm-codec-lib
changeset 562:901753f59f88
gsmhr-cod-parse: read native endian by default
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 12 Feb 2025 00:17:56 +0000 |
parents | cf62fe9fac3a |
children | a563c7b17e16 |
files | hrutil/Makefile hrutil/cod-parse.c |
diffstat | 2 files changed, 25 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/hrutil/Makefile Wed Feb 12 00:04:33 2025 +0000 +++ b/hrutil/Makefile Wed Feb 12 00:17:56 2025 +0000 @@ -1,15 +1,16 @@ PROGS= gsmhr-cod-parse gsmhr-cod2hex gsmhr-dec-craft gsmhr-dec-parse tw5b-dump LIBHR1= ../libgsmhr1/libgsmhr1.a LIBTEST=../libtest/libtest.a +LIBS= ${LIBHR1} ${LIBTEST} include ../config.defs all: ${PROGS} -gsmhr-cod-parse: cod-parse.o print-frame.o read-cod.o ${LIBHR1} +gsmhr-cod-parse: cod-parse.o print-frame.o read-cod.o ${LIBS} ${CC} ${CFLAGS} -o $@ $^ -gsmhr-cod2hex: cod2hex.o read-cod.o tw5b-out-cod.o ${LIBHR1} ${LIBTEST} +gsmhr-cod2hex: cod2hex.o read-cod.o tw5b-out-cod.o ${LIBS} ${CC} ${CFLAGS} -o $@ $^ gsmhr-dec-craft: dec-craft.o ${LIBHR1} @@ -18,7 +19,7 @@ gsmhr-dec-parse: dec-parse.o print-frame.o read-dec.o ${LIBHR1} ${CC} ${CFLAGS} -o $@ $^ -tw5b-dump: print-frame.o tw5b-dump.o ${LIBHR1} ${LIBTEST} +tw5b-dump: print-frame.o tw5b-dump.o ${LIBS} ${CC} ${CFLAGS} -o $@ $^ install:
--- a/hrutil/cod-parse.c Wed Feb 12 00:04:33 2025 +0000 +++ b/hrutil/cod-parse.c Wed Feb 12 00:17:56 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,27 @@ int big_endian; unsigned frame_no; int16_t params[GSMHR_NUM_PARAMS_ENC]; - int rc; + int opt, rc; - 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.cod\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.cod\n", + argv[0]); + exit(1); + } } + if (argc != optind + 1) + goto usage; + infname = argv[optind]; inf = fopen(infname, "r"); if (!inf) { perror(infname);