FreeCalypso > hg > gsm-codec-lib
comparison 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 |
comparison
equal
deleted
inserted
replaced
560:9a9d05a8fc75 | 561:cf62fe9fac3a |
---|---|
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 #include <string.h> | 10 #include <string.h> |
11 #include <strings.h> | 11 #include <strings.h> |
12 #include <unistd.h> | 12 #include <unistd.h> |
13 #include "../libgsmhr1/tw_gsmhr.h" | 13 #include "../libgsmhr1/tw_gsmhr.h" |
14 #include "../libtest/local_endian.h" | |
14 | 15 |
15 main(argc, argv) | 16 main(argc, argv) |
16 char **argv; | 17 char **argv; |
17 { | 18 { |
18 char *infname, *outfname; | 19 char *infname, *outfname; |
19 FILE *inf, *outf; | 20 FILE *inf, *outf; |
20 int opt, rc, big_endian = 0, emit_5993 = 0; | 21 int opt, rc, big_endian, emit_5993 = 0; |
21 unsigned frame_no; | 22 unsigned frame_no; |
22 int16_t params[GSMHR_NUM_PARAMS_ENC]; | 23 int16_t params[GSMHR_NUM_PARAMS_ENC]; |
23 extern int optind; | 24 extern int optind; |
24 | 25 |
25 while ((opt = getopt(argc, argv, "bx")) != EOF) { | 26 big_endian = is_native_big_endian(); |
27 while ((opt = getopt(argc, argv, "blx")) != EOF) { | |
26 switch (opt) { | 28 switch (opt) { |
27 case 'b': | 29 case 'b': |
28 big_endian = 1; | 30 big_endian = 1; |
31 continue; | |
32 case 'l': | |
33 big_endian = 0; | |
29 continue; | 34 continue; |
30 case 'x': | 35 case 'x': |
31 emit_5993 = 1; | 36 emit_5993 = 1; |
32 continue; | 37 continue; |
33 default: | 38 default: |
34 usage: | 39 usage: |
35 fprintf(stderr, | 40 fprintf(stderr, |
36 "usage: %s [-b] [-x] input.cod output.hex\n", | 41 "usage: %s [-b|-l] [-x] input.cod output.hex\n", |
37 argv[0]); | 42 argv[0]); |
38 exit(1); | 43 exit(1); |
39 } | 44 } |
40 } | 45 } |
41 if (argc != optind + 2) | 46 if (argc != optind + 2) |