clib/dvb_ts_lib/descriptors/parse_desc_country_availability.c

filter: Statementstmt 0.0% 0 / 23 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 27 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« clib/dvb_ts_lib/descriptors/parse_desc_content.c ↑ Summary clib/dvb_ts_lib/descriptors/parse_desc_data_broadcast.c »
1 /*
2 * parse_desc_country_availability.c
3 *
4 * Created by: si_desc.pl
5 * Created on: 20-May-2011
6 * Author: sdprice1
7 */
8
9
10 // VERSION = 1.00
11
12 /*=============================================================================================*/
13 // USES
14 /*=============================================================================================*/
15
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <unistd.h>
19 #include <string.h>
20 #include <errno.h>
21 #include <ctype.h>
22 #include <fcntl.h>
23 #include <inttypes.h>
24
25 #include "parse_desc_country_availability.h"
26 #include "descriptors/parse_desc.h"
27
28 /*=============================================================================================*/
29 // CONSTANTS
30 /*=============================================================================================*/
31
32 /*=============================================================================================*/
33 // MACROS
34 /*=============================================================================================*/
35
36 /*=============================================================================================*/
37 // FUNCTIONS
38 /*=============================================================================================*/
39
40 /* ----------------------------------------------------------------------- */
41 //
42 // country_availability_descriptor(){
43 // descriptor_tag 8 uimsbf
44 // descriptor_length 8 uimsbf
45 // country_availability_flag 1 bslbf
46 // reserved_future_use 7 bslbf
47 // for (i=0;i<N;i++){
48 // country_code 24 bslbf
49 // }
50 // }
51
52
53 /* ----------------------------------------------------------------------- */
54 0 void print_country_availability(struct Descriptor_country_availability *cad, int level)
55 {
56 struct list_head *item, *safe;
57
58 0 printf(" Descriptor: country_availability [0x%02x]\n", cad->descriptor_tag) ;
59 0 printf(" Length: %d\n", cad->descriptor_length) ;
60
61 0 printf(" country_availability_flag = %d\n", cad->country_availability_flag) ;
62 0 bits_dump("country_code", cad->country_code, cad->descriptor_length, 2) ;
63 0 }
64
65 /* ----------------------------------------------------------------------- */
66 0 struct Descriptor *parse_country_availability(struct TS_bits *bits, unsigned tag, unsigned len)
67 {
68 struct Descriptor_country_availability *cad ;
69 unsigned byte ;
70 int end_buff_len ;
71
72 0 cad = (struct Descriptor_country_availability *)malloc( sizeof(*cad) ) ;
73 0 memset(cad,0,sizeof(*cad));
74
75 //== Parse data ==
76 0 INIT_LIST_HEAD(&cad->next);
77 0 cad->descriptor_tag = tag ; // already extracted by parse_desc()
78 0 cad->descriptor_length = len ; // already extracted by parse_desc()
79 0 cad->country_availability_flag = bits_get(bits, 1) ;
80 0 bits_skip(bits, 7) ;
81
82 0 end_buff_len = bits_len_calc(bits, -(cad->descriptor_length - 1)) ;
83 0 cad->country_code[0] = 0 ;
84 0 ▶ for (byte=0; (bits->buff_len > end_buff_len) && (byte < MAX_COUNTRY_CODE_LEN); ++byte)
Branch: 2 branches
BranchTrueFalseTotal
for (byte=0; (bits->buff_len > end_buff_len) && (byte < MAX_COUNTRY_CODE_LEN); ++byte) 0 0 0
for (byte=0; (bits->buff_len > end_buff_len) && (byte < MAX_COUNTRY_CODE_LEN); ++byte) 0 0 0
85 {
86 0 cad->country_code[byte] = bits_get(bits, 8) ;
87 0 cad->country_code[byte+1] = 0 ;
88 }
89
90
91 0 return (struct Descriptor *)cad ;
92 }
93
94 /* ----------------------------------------------------------------------- */
95 0 void free_country_availability(struct Descriptor_country_availability *cad)
96 {
97 struct list_head *item, *safe;
98
99 0 free(cad) ;
100 0 }
« clib/dvb_ts_lib/descriptors/parse_desc_content.c ↑ Summary clib/dvb_ts_lib/descriptors/parse_desc_data_broadcast.c »