FreeCalypso > hg > gsm-codec-lib
diff hrutil/cod2hex.c @ 561:cf62fe9fac3a
gsmhr-cod2hex: read native endian by default
Let's change gsmhr-* utilities to read *.cod and *.dec files
in the local machine's native byte order by default, and support
both -b and -l override options. This approach is the only sane
one when we write *.cod and *.dec files in the local endian.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 12 Feb 2025 00:04:33 +0000 |
parents | 129c895a0564 |
children |
line wrap: on
line diff
--- a/hrutil/cod2hex.c Tue Feb 11 23:59:21 2025 +0000 +++ b/hrutil/cod2hex.c Wed Feb 12 00:04:33 2025 +0000 @@ -11,29 +11,34 @@ #include <strings.h> #include <unistd.h> #include "../libgsmhr1/tw_gsmhr.h" +#include "../libtest/local_endian.h" main(argc, argv) char **argv; { char *infname, *outfname; FILE *inf, *outf; - int opt, rc, big_endian = 0, emit_5993 = 0; + int opt, rc, big_endian, emit_5993 = 0; unsigned frame_no; int16_t params[GSMHR_NUM_PARAMS_ENC]; extern int optind; - while ((opt = getopt(argc, argv, "bx")) != EOF) { + big_endian = is_native_big_endian(); + while ((opt = getopt(argc, argv, "blx")) != EOF) { switch (opt) { case 'b': big_endian = 1; continue; + case 'l': + big_endian = 0; + continue; case 'x': emit_5993 = 1; continue; default: usage: fprintf(stderr, - "usage: %s [-b] [-x] input.cod output.hex\n", + "usage: %s [-b|-l] [-x] input.cod output.hex\n", argv[0]); exit(1); }