Contrib: fix libvorbis CVEs: 2008-1419, 2008-1420, 2008-1423.
[vlc.git] / include / vlc_epg.h
blob9017089f87ef9dc070e3c315a67661cc2d0266c5
1 /*****************************************************************************
2 * vlc_epg.h: Electronic Program Guide
3 *****************************************************************************
4 * Copyright (C) 2007 the VideoLAN team
5 * $Id$
7 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 #if !defined( __LIBVLC__ )
25 #error You are not libvlc or one of its plugins. You cannot include this file
26 #endif
28 #ifndef _VLC_EPG_H
29 #define _VLC_EPG_H 1
31 typedef struct
33 int64_t i_start; /* Interpreted as a value return by time() */
34 int i_duration; /* Duration of the event in second */
36 char *psz_name;
37 char *psz_short_description;
38 char *psz_description;
40 } vlc_epg_event_t;
42 typedef struct
44 char *psz_name;
45 vlc_epg_event_t *p_current; /* Can be null or should be the same than one of pp_event entry */
47 int i_event;
48 vlc_epg_event_t **pp_event;
49 } vlc_epg_t;
51 static inline void vlc_epg_Init( vlc_epg_t *p_epg, const char *psz_name )
53 p_epg->psz_name = psz_name ? strdup( psz_name ) : NULL;
54 p_epg->p_current = NULL;
55 TAB_INIT( p_epg->i_event, p_epg->pp_event );
57 static inline void vlc_epg_Clean( vlc_epg_t *p_epg )
59 int i;
60 for( i = 0; i < p_epg->i_event; i++ )
62 vlc_epg_event_t *p_evt = p_epg->pp_event[i];
63 free( p_evt->psz_name );
64 free( p_evt->psz_short_description );
65 free( p_evt->psz_description );
66 free( p_evt );
68 TAB_CLEAN( p_epg->i_event, p_epg->pp_event );
69 free( p_epg->psz_name );
71 static inline void vlc_epg_AddEvent( vlc_epg_t *p_epg, int64_t i_start, int i_duration,
72 const char *psz_name, const char *psz_short_description, const char *psz_description )
74 vlc_epg_event_t *p_evt = (vlc_epg_event_t*)malloc( sizeof(vlc_epg_event_t) );
75 if( !p_evt )
76 return;
77 p_evt->i_start = i_start;
78 p_evt->i_duration = i_duration;
79 p_evt->psz_name = psz_name ? strdup( psz_name ) : NULL;
80 p_evt->psz_short_description = psz_short_description ? strdup( psz_short_description ) : NULL;
81 p_evt->psz_description = psz_description ? strdup( psz_description ) : NULL;
82 TAB_APPEND_CPP( vlc_epg_event_t, p_epg->i_event, p_epg->pp_event, p_evt );
85 static inline vlc_epg_t *vlc_epg_New( const char *psz_name )
87 vlc_epg_t *p_epg = (vlc_epg_t*)malloc( sizeof(vlc_epg_t) );
88 if( p_epg )
89 vlc_epg_Init( p_epg, psz_name );
90 return p_epg;
92 static inline void vlc_epg_Delete( vlc_epg_t *p_epg )
94 vlc_epg_Clean( p_epg );
95 free( p_epg );
97 static inline void vlc_epg_SetCurrent( vlc_epg_t *p_epg, int64_t i_start )
99 int i;
100 p_epg->p_current = NULL;
101 if( i_start < 0 )
102 return;
104 for( i = 0; i < p_epg->i_event; i++ )
106 if( p_epg->pp_event[i]->i_start == i_start )
108 p_epg->p_current = p_epg->pp_event[i];
109 break;
114 #endif