comparison hrutil/cod-out-endian.c @ 609:a2b2ca082dd7 default tip

hrutil: new program gsmhr-tfo-xfrm-dc
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 24 Feb 2026 04:16:57 +0000
parents hrutil/tw5b-out-cod.c@129c895a0564
children
comparison
equal deleted inserted replaced
608:d4e42ec4a688 609:a2b2ca082dd7
1 /*
2 * The helper function implemented in this module emits an encoder output
3 * array of params (*.cod format) in either BE or LE format. This helper
4 * function will be used for gsmhr-etsi-enc and gsmhr-tfo-xfrm-dc utilities,
5 * which need to both read and write ETSI-format files that are subject to
6 * endian concerns.
7 */
8
9 #include <stdint.h>
10 #include <stdio.h>
11 #include "../libgsmhr1/tw_gsmhr.h"
12
13 void
14 emit_cod_to_endian(outf, params, big_endian)
15 FILE *outf;
16 int16_t *params;
17 {
18 uint8_t file_bytes[GSMHR_NUM_PARAMS_ENC * 2], *dp;
19 unsigned n;
20 uint16_t val;
21
22 dp = file_bytes;
23 for (n = 0; n < GSMHR_NUM_PARAMS_ENC; n++) {
24 val = params[n];
25 if (big_endian) {
26 *dp++ = val >> 8;
27 *dp++ = val;
28 } else {
29 *dp++ = val;
30 *dp++ = val >> 8;
31 }
32 }
33 fwrite(file_bytes, 2, GSMHR_NUM_PARAMS_ENC, outf);
34 }