00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef VLC_EPG_H
00025 #define VLC_EPG_H 1
00026
00027 typedef struct
00028 {
00029 int64_t i_start;
00030 int i_duration;
00031
00032 char *psz_name;
00033 char *psz_short_description;
00034 char *psz_description;
00035
00036 } vlc_epg_event_t;
00037
00038 typedef struct
00039 {
00040 char *psz_name;
00041 vlc_epg_event_t *p_current;
00042
00043 int i_event;
00044 vlc_epg_event_t **pp_event;
00045 } vlc_epg_t;
00046
00047 static inline void vlc_epg_Init( vlc_epg_t *p_epg, const char *psz_name )
00048 {
00049 p_epg->psz_name = psz_name ? strdup( psz_name ) : NULL;
00050 p_epg->p_current = NULL;
00051 TAB_INIT( p_epg->i_event, p_epg->pp_event );
00052 }
00053 static inline void vlc_epg_Clean( vlc_epg_t *p_epg )
00054 {
00055 int i;
00056 for( i = 0; i < p_epg->i_event; i++ )
00057 {
00058 vlc_epg_event_t *p_evt = p_epg->pp_event[i];
00059 free( p_evt->psz_name );
00060 free( p_evt->psz_short_description );
00061 free( p_evt->psz_description );
00062 free( p_evt );
00063 }
00064 TAB_CLEAN( p_epg->i_event, p_epg->pp_event );
00065 free( p_epg->psz_name );
00066 }
00067 static inline void vlc_epg_AddEvent( vlc_epg_t *p_epg, int64_t i_start, int i_duration,
00068 const char *psz_name, const char *psz_short_description, const char *psz_description )
00069 {
00070 vlc_epg_event_t *p_evt = (vlc_epg_event_t*)malloc( sizeof(vlc_epg_event_t) );
00071 if( !p_evt )
00072 return;
00073 p_evt->i_start = i_start;
00074 p_evt->i_duration = i_duration;
00075 p_evt->psz_name = psz_name ? strdup( psz_name ) : NULL;
00076 p_evt->psz_short_description = psz_short_description ? strdup( psz_short_description ) : NULL;
00077 p_evt->psz_description = psz_description ? strdup( psz_description ) : NULL;
00078 TAB_APPEND_CPP( vlc_epg_event_t, p_epg->i_event, p_epg->pp_event, p_evt );
00079 }
00080
00081 static inline vlc_epg_t *vlc_epg_New( const char *psz_name )
00082 {
00083 vlc_epg_t *p_epg = (vlc_epg_t*)malloc( sizeof(vlc_epg_t) );
00084 if( p_epg )
00085 vlc_epg_Init( p_epg, psz_name );
00086 return p_epg;
00087 }
00088 static inline void vlc_epg_Delete( vlc_epg_t *p_epg )
00089 {
00090 vlc_epg_Clean( p_epg );
00091 free( p_epg );
00092 }
00093 static inline void vlc_epg_SetCurrent( vlc_epg_t *p_epg, int64_t i_start )
00094 {
00095 int i;
00096 p_epg->p_current = NULL;
00097 if( i_start < 0 )
00098 return;
00099
00100 for( i = 0; i < p_epg->i_event; i++ )
00101 {
00102 if( p_epg->pp_event[i]->i_start == i_start )
00103 {
00104 p_epg->p_current = p_epg->pp_event[i];
00105 break;
00106 }
00107 }
00108 }
00109
00110 #endif
00111