« clib/dvb_ts_lib/descriptors/parse_desc_announcement_support.c
↑ Summary
clib/dvb_ts_lib/descriptors/parse_desc_ca_identifier.c »
| 1 | /* | ||||||||||||||
| 2 | * parse_desc_bouquet_name.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_bouquet_name.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 | // bouquet_name_descriptor(){ | ||||||||||||||
| 43 | // descriptor_tag 8 uimsbf | ||||||||||||||
| 44 | // descriptor_length 8 uimsbf | ||||||||||||||
| 45 | // for(i=0;i<N;i++){ | ||||||||||||||
| 46 | // char 8 uimsbf | ||||||||||||||
| 47 | // } | ||||||||||||||
| 48 | // } | ||||||||||||||
| 49 | |||||||||||||||
| 50 | |||||||||||||||
| 51 | /* ----------------------------------------------------------------------- */ | ||||||||||||||
| 52 | 0 | void print_bouquet_name(struct Descriptor_bouquet_name *bnd, int level) | |||||||||||||
| 53 | { | ||||||||||||||
| 54 | struct list_head *item, *safe; | ||||||||||||||
| 55 | |||||||||||||||
| 56 | 0 | printf(" Descriptor: bouquet_name [0x%02x]\n", bnd->descriptor_tag) ; | |||||||||||||
| 57 | 0 | printf(" Length: %d\n", bnd->descriptor_length) ; | |||||||||||||
| 58 | |||||||||||||||
| 59 | 0 | printf(" descriptor = \"%s\"\n", bnd->descriptor) ; | |||||||||||||
| 60 | 0 | } | |||||||||||||
| 61 | |||||||||||||||
| 62 | /* ----------------------------------------------------------------------- */ | ||||||||||||||
| 63 | 0 | struct Descriptor *parse_bouquet_name(struct TS_bits *bits, unsigned tag, unsigned len) | |||||||||||||
| 64 | { | ||||||||||||||
| 65 | struct Descriptor_bouquet_name *bnd ; | ||||||||||||||
| 66 | unsigned byte ; | ||||||||||||||
| 67 | int end_buff_len ; | ||||||||||||||
| 68 | |||||||||||||||
| 69 | 0 | bnd = (struct Descriptor_bouquet_name *)malloc( sizeof(*bnd) ) ; | |||||||||||||
| 70 | 0 | memset(bnd,0,sizeof(*bnd)); | |||||||||||||
| 71 | |||||||||||||||
| 72 | //== Parse data == | ||||||||||||||
| 73 | 0 | INIT_LIST_HEAD(&bnd->next); | |||||||||||||
| 74 | 0 | bnd->descriptor_tag = tag ; // already extracted by parse_desc() | |||||||||||||
| 75 | 0 | bnd->descriptor_length = len ; // already extracted by parse_desc() | |||||||||||||
| 76 | |||||||||||||||
| 77 | 0 | end_buff_len = bits_len_calc(bits, -bnd->descriptor_length) ; | |||||||||||||
| 78 | 0 | bnd->descriptor[0] = 0 ; | |||||||||||||
| 79 | 0 | ▶ | for (byte=0; (bits->buff_len > end_buff_len) && (byte < MAX_DESCRIPTOR_LEN); ++byte) | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 80 | { | ||||||||||||||
| 81 | 0 | bnd->descriptor[byte] = bits_get(bits, 8) ; | |||||||||||||
| 82 | 0 | bnd->descriptor[byte+1] = 0 ; | |||||||||||||
| 83 | } | ||||||||||||||
| 84 | |||||||||||||||
| 85 | |||||||||||||||
| 86 | 0 | return (struct Descriptor *)bnd ; | |||||||||||||
| 87 | } | ||||||||||||||
| 88 | |||||||||||||||
| 89 | /* ----------------------------------------------------------------------- */ | ||||||||||||||
| 90 | 0 | void free_bouquet_name(struct Descriptor_bouquet_name *bnd) | |||||||||||||
| 91 | { | ||||||||||||||
| 92 | struct list_head *item, *safe; | ||||||||||||||
| 93 | |||||||||||||||
| 94 | 0 | free(bnd) ; | |||||||||||||
| 95 | 0 | } | |||||||||||||