clib/dvb_ts_lib/descriptors/parse_desc_local_time_offset.c

filter: Statementstmt 0.0% 0 / 39 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 45 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« clib/dvb_ts_lib/descriptors/parse_desc_linkage.c ↑ Summary clib/dvb_ts_lib/descriptors/parse_desc_mosaic.c »
1 /*
2 * parse_desc_local_time_offset.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_local_time_offset.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 // local_time_offset_descriptor(){
43 // descriptor_tag 8 uimsbf
44 // descriptor_length 8 uimsbf
45 // for(i=0;i<N;i++){
46 // country_code 24 bslbf
47 // country_region_id 6 bslbf
48 // reserved 1 bslbf
49 // local_time_offset_polarity 1 bslbf
50 // local_time_offset 16 bslbf
51 // time_of_change 40 bslbf
52 // next_time_offset 16 bslbf
53 // }
54 // }
55
56
57 /* ----------------------------------------------------------------------- */
58 0 void print_local_time_offset(struct Descriptor_local_time_offset *ltod, int level)
59 {
60 struct list_head *item, *safe;
61
62 0 printf(" Descriptor: local_time_offset [0x%02x]\n", ltod->descriptor_tag) ;
63 0 printf(" Length: %d\n", ltod->descriptor_length) ;
64
65
66 0 ▶ list_for_each_safe(item,safe,&ltod->ltod_array) {
Branch: 1 branch
BranchTrueFalseTotal
list_for_each_safe(item,safe,&ltod->ltod_array) { 0 0 0
67 0 struct LTOD_entry *ltod_entry = list_entry(item, struct LTOD_entry, next);
68
69 // LTOD entry
70 0 printf(" -LTOD entry-\n") ;
71
72 0 printf(" country_code = %d\n", ltod_entry->country_code) ;
73 0 printf(" country_region_id = %d\n", ltod_entry->country_region_id) ;
74 0 printf(" local_time_offset_polarity = %d\n", ltod_entry->local_time_offset_polarity) ;
75 0 printf(" local_time_offset = %d\n", ltod_entry->local_time_offset) ;
76 0 printf(" time_of_change = %02d-%02d-%04d %02d:%02d:%02d\n",
77 ltod_entry->time_of_change.tm_mday, ltod_entry->time_of_change.tm_mon, ltod_entry->time_of_change.tm_year,
78 ltod_entry->time_of_change.tm_hour, ltod_entry->time_of_change.tm_min, ltod_entry->time_of_change.tm_sec
79 ) ;
80 0 printf(" next_time_offset = %d\n", ltod_entry->next_time_offset) ;
81 }
82
83 0 }
84
85 /* ----------------------------------------------------------------------- */
86 0 struct Descriptor *parse_local_time_offset(struct TS_bits *bits, unsigned tag, unsigned len)
87 {
88 struct Descriptor_local_time_offset *ltod ;
89 unsigned byte ;
90 int end_buff_len ;
91
92 0 ltod = (struct Descriptor_local_time_offset *)malloc( sizeof(*ltod) ) ;
93 0 memset(ltod,0,sizeof(*ltod));
94
95 //== Parse data ==
96 0 INIT_LIST_HEAD(&ltod->next);
97 0 ltod->descriptor_tag = tag ; // already extracted by parse_desc()
98 0 ltod->descriptor_length = len ; // already extracted by parse_desc()
99
100 0 INIT_LIST_HEAD(&ltod->ltod_array) ;
101 0 end_buff_len = bits_len_calc(bits, -ltod->descriptor_length ) ;
102 0 ▶ while (bits->buff_len > end_buff_len)
Branch: 1 branch
BranchTrueFalseTotal
while (bits->buff_len > end_buff_len) 0 0 0
103 {
104 0 struct LTOD_entry *ltod_entry = malloc(sizeof(*ltod_entry));
105 0 memset(ltod_entry,0,sizeof(*ltod_entry));
106 0 list_add_tail(&ltod_entry->next,&ltod->ltod_array);
107
108 0 ltod_entry->country_code = bits_get(bits, 24) ;
109 0 ltod_entry->country_region_id = bits_get(bits, 6) ;
110 0 bits_skip(bits, 1) ;
111 0 ltod_entry->local_time_offset_polarity = bits_get(bits, 1) ;
112 0 ltod_entry->local_time_offset = bits_get(bits, 16) ;
113 0 ltod_entry->time_of_change = bits_get_mjd_time(bits) ;
114 0 ltod_entry->next_time_offset = bits_get(bits, 16) ;
115 }
116
117
118 0 return (struct Descriptor *)ltod ;
119 }
120
121 /* ----------------------------------------------------------------------- */
122 0 void free_local_time_offset(struct Descriptor_local_time_offset *ltod)
123 {
124 struct list_head *item, *safe;
125
126 0 ▶ list_for_each_safe(item,safe,&ltod->ltod_array) {
Branch: 1 branch
BranchTrueFalseTotal
list_for_each_safe(item,safe,&ltod->ltod_array) { 0 0 0
127 0 struct LTOD_entry *ltod_entry = list_entry(item, struct LTOD_entry, next);
128 0 free(ltod_entry) ;
129 }
130
131
132 0 free(ltod) ;
133 0 }
« clib/dvb_ts_lib/descriptors/parse_desc_linkage.c ↑ Summary clib/dvb_ts_lib/descriptors/parse_desc_mosaic.c »