• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2011-2012 - Mauro Carvalho Chehab
3  * Copyright (c) 2012 - Andre Roth <neolynx@gmail.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation version 2.1 of the License.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
18  *
19  */
20 
21 #include <libdvbv5/desc_event_short.h>
22 #include <libdvbv5/dvb-fe.h>
23 #include <parse_string.h>
24 
25 #if __GNUC__ >= 9
26 #pragma GCC diagnostic ignored "-Waddress-of-packed-member"
27 #endif
28 
dvb_desc_event_short_init(struct dvb_v5_fe_parms * parms,const uint8_t * buf,struct dvb_desc * desc)29 int dvb_desc_event_short_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, struct dvb_desc *desc)
30 {
31 	struct dvb_desc_event_short *event = (struct dvb_desc_event_short *) desc;
32 	uint8_t len;        /* the length of the string in the input data */
33 	uint8_t len1, len2; /* the lenght of the output strings */
34 
35 	/*dvb_hexdump(parms, "event short desc: ", buf - 2, desc->length + 2);*/
36 
37 	event->language[0] = buf[0];
38 	event->language[1] = buf[1];
39 	event->language[2] = buf[2];
40 	event->language[3] = '\0';
41 	buf += 3;
42 
43 	event->name = NULL;
44 	event->name_emph = NULL;
45 	len = buf[0];
46 	buf++;
47 	len1 = len;
48 	dvb_parse_string(parms, &event->name, &event->name_emph, buf, len1);
49 	buf += len;
50 
51 	event->text = NULL;
52 	event->text_emph = NULL;
53 	len = buf[0];
54 	len2 = len;
55 	buf++;
56 	dvb_parse_string(parms, &event->text, &event->text_emph, buf, len2);
57 	buf += len;
58 	return 0;
59 }
60 
dvb_desc_event_short_free(struct dvb_desc * desc)61 void dvb_desc_event_short_free(struct dvb_desc *desc)
62 {
63 	struct dvb_desc_event_short *event = (struct dvb_desc_event_short *) desc;
64 	free(event->name);
65 	free(event->name_emph);
66 	free(event->text);
67 	free(event->text_emph);
68 }
69 
dvb_desc_event_short_print(struct dvb_v5_fe_parms * parms,const struct dvb_desc * desc)70 void dvb_desc_event_short_print(struct dvb_v5_fe_parms *parms, const struct dvb_desc *desc)
71 {
72 	const struct dvb_desc_event_short *event = (const struct dvb_desc_event_short *) desc;
73 	dvb_loginfo("|           name          '%s'", event->name);
74 	dvb_loginfo("|           language      '%s'", event->language);
75 	dvb_loginfo("|           description   '%s'", event->text);
76 }
77 
78