10 int parseTOThead(unsigned char *data, TOThead *toth) {
13 memset(toth, 0, sizeof(TOThead));
15 toth->table_id = getBit(data, &boff, 8);
16 toth->section_syntax_indicator = getBit(data, &boff, 1);
17 toth->reserved_future_use1 = getBit(data, &boff, 1);
18 toth->reserved1 = getBit(data, &boff, 2);
19 toth->section_length = getBit(data, &boff, 12);
20 memcpy(toth->JST_time, data + boff / 8, 5);
22 // toth->JST_time = getBit(data, &boff, 40);
23 toth->reserved2 = getBit(data, &boff, 4);
24 toth->descriptors_loop_length = getBit(data, &boff, 12);
29 int parseTOTdesc(unsigned char *data, TOTdesc *totd) {
32 memset(totd, 0, sizeof(TOTdesc));
34 totd->descriptor_tag = getBit(data, &boff, 8);
35 totd->descriptor_length = getBit(data, &boff, 8);
37 return totd->descriptor_length + 2;
40 void dumpTOT(unsigned char *ptr)
51 len = parseTOThead(ptr, &toth);
53 loop_len = toth.section_length - (len - 3 + 4); // 3は共通ヘッダ長 4はCRC
55 tot = parseMJD( toth.JST_time );
56 printf("TOT diff:%d[秒] %s",
57 (int)difftime( time(NULL), tot ), ctime(&tot));
58 //ptm = localtime(time(NULL));
60 desc_len = toth.descriptors_loop_length;
62 len = parseTOTdesc(ptr, &totd);