FreeCalypso > hg > gsm-net-reveng
comparison trau-ul-prep/binreader.c @ 19:4ab8762be333
trau-ul-prep: starting with gsmx2tsrc program
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 23 Jun 2024 21:55:03 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
18:b36419bbc2c4 | 19:4ab8762be333 |
---|---|
1 /* | |
2 * Here we implement our binfile_read_frame() function. | |
3 */ | |
4 | |
5 #include <stdio.h> | |
6 #include <stdint.h> | |
7 #include "binreader.h" | |
8 | |
9 int binfile_read_frame(FILE *binf, uint8_t *frame) | |
10 { | |
11 int cc, morelen; | |
12 | |
13 cc = fread(frame, 1, 1, binf); | |
14 if (cc != 1) | |
15 return 0; | |
16 if (frame[0] == 0xBF) | |
17 morelen = 1; | |
18 else if ((frame[0] & 0xF0) == 0xC0) | |
19 morelen = 30; | |
20 else if ((frame[0] & 0xF0) == 0xD0) | |
21 morelen = 32; | |
22 else | |
23 return -1; | |
24 cc = fread(frame+1, 1, morelen, binf); | |
25 if (cc == morelen) | |
26 return 1; | |
27 else | |
28 return -2; | |
29 } |