comparison miscutil/gsmx-to-tw5a.c @ 521:68fe269b4316

gsmx-to-tw5a: actually write to the output file
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 19 Sep 2024 02:21:08 +0000
parents 785b302992f0
children 5595293e4f29
comparison
equal deleted inserted replaced
520:785b302992f0 521:68fe269b4316
14 #include "../libgsmfr2/tw_gsmfr.h" 14 #include "../libgsmfr2/tw_gsmfr.h"
15 #include "../libgsmefr/gsm_efr.h" 15 #include "../libgsmefr/gsm_efr.h"
16 #include "../libtest/binreader.h" 16 #include "../libtest/binreader.h"
17 17
18 static void 18 static void
19 emit_hex_frame(frame, nbytes) 19 emit_hex_frame(outf, frame, nbytes)
20 FILE *outf;
20 uint8_t *frame; 21 uint8_t *frame;
21 unsigned nbytes; 22 unsigned nbytes;
22 { 23 {
23 unsigned n; 24 unsigned n;
24 25
25 for (n = 0; n < nbytes; n++) 26 for (n = 0; n < nbytes; n++)
26 printf("%02X", frame[n]); 27 fprintf(outf, "%02X", frame[n]);
27 putchar('\n'); 28 putc('\n', outf);
28 } 29 }
29 30
30 main(argc, argv) 31 main(argc, argv)
31 char **argv; 32 char **argv;
32 { 33 {
62 } 63 }
63 if (!rc) 64 if (!rc)
64 break; 65 break;
65 switch (frame[0] & 0xF0) { 66 switch (frame[0] & 0xF0) {
66 case 0xB0: 67 case 0xB0:
67 printf("%02X\n", 0xE6 | frame[1] & 1); 68 fprintf(outf, "%02X\n", 0xE6 | frame[1] & 1);
68 break; 69 break;
69 case 0xC0: 70 case 0xC0:
70 emit_hex_frame(frame, EFR_RTP_FRAME_LEN); 71 emit_hex_frame(outf, frame, EFR_RTP_FRAME_LEN);
71 break; 72 break;
72 case 0xD0: 73 case 0xD0:
73 emit_hex_frame(frame, GSMFR_RTP_FRAME_LEN); 74 emit_hex_frame(outf, frame, GSMFR_RTP_FRAME_LEN);
74 break; 75 break;
75 } 76 }
76 } 77 }
77 exit(0); 78 exit(0);
78 } 79 }