@ -57,17 +57,11 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
static vlm_message_t * vlm_Show ( vlm_t * , vlm_media_sys_t * , vlm_schedule_sys_t * , const char * ) ;
static vlm_schedule_sys_t * vlm_ScheduleSearch ( vlm_t * , const char * ) ;
static vlm_message_t * vlm_Show ( vlm_t * , vlm_media_sys_t * , const char * ) ;
VLC_MALLOC static char * Save ( vlm_t * ) ;
static int Load ( vlm_t * , char * ) ;
static vlm_schedule_sys_t * vlm_ScheduleNew ( vlm_t * vlm , const char * psz_name ) ;
static int vlm_ScheduleSetup ( vlm_t * vlm , vlm_schedule_sys_t * schedule ,
const char * psz_cmd , const char * psz_value ) ;
/* */
static vlm_media_sys_t * vlm_MediaSearch ( vlm_t * , const char * ) ;
@ -222,26 +216,14 @@ static bool ExecuteIsMedia( vlm_t *p_vlm, const char *psz_name )
return false ;
return true ;
}
static bool ExecuteIsSchedule ( vlm_t * p_vlm , const char * psz_name )
{
if ( ! psz_name | | ! vlm_ScheduleSearch ( p_vlm , psz_name ) )
return false ;
return true ;
}
static int ExecuteDel ( vlm_t * p_vlm , const char * psz_name , vlm_message_t * * pp_status )
{
vlm_media_sys_t * p_media ;
vlm_schedule_sys_t * p_schedule ;
p_media = vlm_MediaSearch ( p_vlm , psz_name ) ;
p_schedule = vlm_ScheduleSearch ( p_vlm , psz_name ) ;
if ( p_schedule ! = NULL )
{
vlm_ScheduleDelete ( p_vlm , p_schedule ) ;
}
else if ( p_media ! = NULL )
if ( p_media ! = NULL )
{
vlm_ControlInternal ( p_vlm , VLM_DEL_MEDIA , p_media - > cfg . id ) ;
}
@ -249,14 +231,9 @@ static int ExecuteDel( vlm_t *p_vlm, const char *psz_name, vlm_message_t **pp_st
{
vlm_ControlInternal ( p_vlm , VLM_CLEAR_MEDIAS ) ;
}
else if ( ! strcmp ( psz_name , " schedule " ) )
{
vlm_ControlInternal ( p_vlm , VLM_CLEAR_SCHEDULES ) ;
}
else if ( ! strcmp ( psz_name , " all " ) )
{
vlm_ControlInternal ( p_vlm , VLM_CLEAR_MEDIAS ) ;
vlm_ControlInternal ( p_vlm , VLM_CLEAR_SCHEDULES ) ;
}
else
{
@ -271,23 +248,19 @@ static int ExecuteDel( vlm_t *p_vlm, const char *psz_name, vlm_message_t **pp_st
static int ExecuteShow ( vlm_t * p_vlm , const char * psz_name , vlm_message_t * * pp_status )
{
vlm_media_sys_t * p_media ;
vlm_schedule_sys_t * p_schedule ;
if ( ! psz_name )
{
* pp_status = vlm_Show ( p_vlm , NULL , NULL , NULL ) ;
* pp_status = vlm_Show ( p_vlm , NULL , NULL ) ;
return VLC_SUCCESS ;
}
p_media = vlm_MediaSearch ( p_vlm , psz_name ) ;
p_schedule = vlm_ScheduleSearch ( p_vlm , psz_name ) ;
if ( p_schedule ! = NULL )
* pp_status = vlm_Show ( p_vlm , NULL , p_schedule , NULL ) ;
else if ( p_media ! = NULL )
* pp_status = vlm_Show ( p_vlm , p_media , NULL , NULL ) ;
if ( p_media ! = NULL )
* pp_status = vlm_Show ( p_vlm , p_media , NULL ) ;
else
* pp_status = vlm_Show ( p_vlm , NULL , NULL , psz_name ) ;
* pp_status = vlm_Show ( p_vlm , NULL , psz_name ) ;
return VLC_SUCCESS ;
}
@ -304,10 +277,10 @@ static int ExecuteHelp( vlm_message_t **pp_status )
* pp_status = vlm_MessageSimpleNew ( " help " ) ;
message_child = MessageAdd ( " Commands Syntax: " ) ;
MessageAddChild ( " new (name) broadcast|schedule [properties] " ) ;
MessageAddChild ( " new (name) broadcast [properties] " ) ;
MessageAddChild ( " setup (name) (properties) " ) ;
MessageAddChild ( " show [(name)|media|schedule ] " ) ;
MessageAddChild ( " del (name)|all|media|schedule " ) ;
MessageAddChild ( " show [(name)|media] " ) ;
MessageAddChild ( " del (name)|all|media " ) ;
MessageAddChild ( " control (name) [instance_name] (command) " ) ;
MessageAddChild ( " save (config_file) " ) ;
MessageAddChild ( " export " ) ;
@ -322,15 +295,6 @@ static int ExecuteHelp( vlm_message_t **pp_status )
MessageAddChild ( " enabled|disabled " ) ;
MessageAddChild ( " loop|unloop " ) ;
message_child = MessageAdd ( " Schedule Proprieties Syntax: " ) ;
MessageAddChild ( " enabled|disabled " ) ;
MessageAddChild ( " append (command_until_rest_of_the_line) " ) ;
MessageAddChild ( " date (year)/(month)/(day)-(hour):(minutes): "
" (seconds)|now " ) ;
MessageAddChild ( " period (years_aka_12_months)/(months_aka_30_days)/ "
" (days)-(hours):(minutes):(seconds) " ) ;
MessageAddChild ( " repeat (number_of_repetitions) " ) ;
message_child = MessageAdd ( " Control Commands Syntax: " ) ;
MessageAddChild ( " play [input_number] " ) ;
MessageAddChild ( " pause " ) ;
@ -560,88 +524,6 @@ static int ExecuteLoad( vlm_t *p_vlm, const char *psz_path, vlm_message_t **pp_s
return VLC_SUCCESS ;
}
static int ExecuteScheduleProperty ( vlm_t * p_vlm , vlm_schedule_sys_t * p_schedule , bool b_new ,
const int i_property , char * ppsz_property [ ] , vlm_message_t * * pp_status )
{
const char * psz_cmd = b_new ? " new " : " setup " ;
int i ;
for ( i = 0 ; i < i_property ; i + + )
{
if ( ! strcmp ( ppsz_property [ i ] , " enabled " ) | |
! strcmp ( ppsz_property [ i ] , " disabled " ) )
{
if ( vlm_ScheduleSetup ( p_vlm , p_schedule , ppsz_property [ i ] , NULL ) )
goto error ;
}
else if ( ! strcmp ( ppsz_property [ i ] , " append " ) )
{
char * psz_line , * psz_realloc ;
int j , i_ret = VLC_SUCCESS ;
/* Beware: everything behind append is considered as
* command line */
if ( + + i > = i_property )
break ;
psz_line = strdup ( ppsz_property [ i ] ) ;
if ( unlikely ( psz_line = = NULL ) )
goto error ;
for ( j = i + 1 ; j < i_property ; j + + )
{
psz_realloc = realloc ( psz_line ,
strlen ( psz_line ) + strlen ( ppsz_property [ j ] ) + 1 + 1 ) ;
if ( likely ( psz_realloc ) )
{
psz_line = psz_realloc ;
strcat ( psz_line , " " ) ;
strcat ( psz_line , ppsz_property [ j ] ) ;
}
else
{
i_ret = VLC_ENOMEM ;
break ;
}
}
if ( i_ret = = VLC_SUCCESS )
i_ret = vlm_ScheduleSetup ( p_vlm , p_schedule , " append " , psz_line ) ;
free ( psz_line ) ;
if ( i_ret )
goto error ;
break ;
}
else
{
if ( i + 1 > = i_property )
{
if ( b_new )
vlm_ScheduleDelete ( p_vlm , p_schedule ) ;
return ExecuteSyntaxError ( psz_cmd , pp_status ) ;
}
if ( vlm_ScheduleSetup ( p_vlm , p_schedule , ppsz_property [ i ] , ppsz_property [ i + 1 ] ) )
goto error ;
i + + ;
}
}
* pp_status = vlm_MessageSimpleNew ( psz_cmd ) ;
vlc_mutex_lock ( & p_vlm - > lock_manage ) ;
p_vlm - > input_state_changed = true ;
vlc_cond_signal ( & p_vlm - > wait_manage ) ;
vlc_mutex_unlock ( & p_vlm - > lock_manage ) ;
return VLC_SUCCESS ;
error :
* pp_status = vlm_MessageNew ( psz_cmd , " Error while setting the property '%s' to the schedule " ,
ppsz_property [ i ] ) ;
return VLC_EGENERIC ;
}
static int ExecuteMediaProperty ( vlm_t * p_vlm , int64_t id , bool b_new ,
const int i_property , char * ppsz_property [ ] , vlm_message_t * * pp_status )
{
@ -759,28 +641,18 @@ error:
static int ExecuteNew ( vlm_t * p_vlm , const char * psz_name , const char * psz_type , const int i_property , char * ppsz_property [ ] , vlm_message_t * * pp_status )
{
/* Check name */
if ( ! strcmp ( psz_name , " all " ) | | ! strcmp ( psz_name , " media " ) | | ! strcmp ( psz_name , " schedule " ) )
if ( ! strcmp ( psz_name , " all " ) | | ! strcmp ( psz_name , " media " ) )
{
* pp_status = vlm_MessageNew ( " new " , " \" all \" , \" media \" and \" schedule \" are reserved names " ) ;
* pp_status = vlm_MessageNew ( " new " , " \" all \" and \" media \" are reserved names " ) ;
return VLC_EGENERIC ;
}
if ( ExecuteIsMedia ( p_vlm , psz_name ) | | ExecuteIsSchedule ( p_vlm , psz_name ) )
if ( ExecuteIsMedia ( p_vlm , psz_name ) )
{
* pp_status = vlm_MessageNew ( " new " , " %s: Name already in use " , psz_name ) ;
return VLC_EGENERIC ;
}
/* */
if ( ! strcmp ( psz_type , " schedule " ) )
{
vlm_schedule_sys_t * p_schedule = vlm_ScheduleNew ( p_vlm , psz_name ) ;
if ( ! p_schedule )
{
* pp_status = vlm_MessageNew ( " new " , " could not create schedule " ) ;
return VLC_EGENERIC ;
}
return ExecuteScheduleProperty ( p_vlm , p_schedule , true , i_property , ppsz_property , pp_status ) ;
}
else if ( ! strcmp ( psz_type , " broadcast " ) )
if ( ! strcmp ( psz_type , " broadcast " ) )
{
vlm_media_t cfg ;
int64_t id ;
@ -797,26 +669,16 @@ static int ExecuteNew( vlm_t *p_vlm, const char *psz_name, const char *psz_type,
vlm_media_Clean ( & cfg ) ;
return ExecuteMediaProperty ( p_vlm , id , true , i_property , ppsz_property , pp_status ) ;
}
else if ( ! strcmp ( psz_type , " vod " ) )
{
* pp_status = vlm_MessageNew ( " new " , " VoD support was removed " ) ;
return VLC_EGENERIC ;
}
else
{
* pp_status = vlm_MessageNew ( " new " , " %s: Choose between broadcast or schedul e " , psz_type ) ;
* pp_status = vlm_MessageNew ( " new " , " %s: unsupported type " , psz_type ) ;
return VLC_EGENERIC ;
}
}
static int ExecuteSetup ( vlm_t * p_vlm , const char * psz_name , const int i_property , char * ppsz_property [ ] , vlm_message_t * * pp_status )
{
if ( ExecuteIsSchedule ( p_vlm , psz_name ) )
{
vlm_schedule_sys_t * p_schedule = vlm_ScheduleSearch ( p_vlm , psz_name ) ;
return ExecuteScheduleProperty ( p_vlm , p_schedule , false , i_property , ppsz_property , pp_status ) ;
}
else if ( ExecuteIsMedia ( p_vlm , psz_name ) )
if ( ExecuteIsMedia ( p_vlm , psz_name ) )
{
int64_t id ;
if ( vlm_ControlInternal ( p_vlm , VLM_GET_MEDIA_ID , psz_name , & id ) )
@ -950,252 +812,6 @@ vlm_media_sys_t *vlm_MediaSearch( vlm_t *vlm, const char *psz_name )
return NULL ;
}
/*****************************************************************************
* Schedule handling
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static vlm_schedule_sys_t * vlm_ScheduleNew ( vlm_t * vlm , const char * psz_name )
{
if ( ! psz_name )
return NULL ;
vlm_schedule_sys_t * p_sched = malloc ( sizeof ( vlm_schedule_sys_t ) ) ;
if ( ! p_sched )
return NULL ;
p_sched - > psz_name = strdup ( psz_name ) ;
p_sched - > b_enabled = false ;
p_sched - > i_command = 0 ;
p_sched - > command = NULL ;
p_sched - > date = 0 ;
p_sched - > period = 0 ;
p_sched - > i_repeat = - 1 ;
TAB_APPEND ( vlm - > i_schedule , vlm - > schedule , p_sched ) ;
return p_sched ;
}
/* for now, simple delete. After, del with options (last arg) */
void vlm_ScheduleDelete ( vlm_t * vlm , vlm_schedule_sys_t * sched )
{
int i ;
if ( sched = = NULL ) return ;
TAB_REMOVE ( vlm - > i_schedule , vlm - > schedule , sched ) ;
if ( vlm - > i_schedule = = 0 ) free ( vlm - > schedule ) ;
free ( sched - > psz_name ) ;
for ( i = 0 ; i < sched - > i_command ; i + + )
free ( sched - > command [ i ] ) ;
free ( sched - > command ) ;
free ( sched ) ;
}
static vlm_schedule_sys_t * vlm_ScheduleSearch ( vlm_t * vlm , const char * psz_name )
{
int i ;
for ( i = 0 ; i < vlm - > i_schedule ; i + + )
{
if ( strcmp ( psz_name , vlm - > schedule [ i ] - > psz_name ) = = 0 )
{
return vlm - > schedule [ i ] ;
}
}
return NULL ;
}
/* Ok, setup schedule command will be able to support only one (argument value) at a time */
static int vlm_ScheduleSetup ( vlm_t * vlm , vlm_schedule_sys_t * schedule ,
const char * psz_cmd , const char * psz_value )
{
if ( ! strcmp ( psz_cmd , " enabled " ) )
{
schedule - > b_enabled = true ;
}
else if ( ! strcmp ( psz_cmd , " disabled " ) )
{
schedule - > b_enabled = false ;
}
else if ( ! strcmp ( psz_cmd , " date " ) )
{
struct tm time ;
const char * p ;
time . tm_sec = 0 ; /* seconds */
time . tm_min = 0 ; /* minutes */
time . tm_hour = 0 ; /* hours */
time . tm_mday = 0 ; /* day of the month */
time . tm_mon = 0 ; /* month */
time . tm_year = 0 ; /* year */
time . tm_wday = 0 ; /* day of the week */
time . tm_yday = 0 ; /* day in the year */
time . tm_isdst = - 1 ; /* daylight saving time */
/* date should be year/month/day-hour:minutes:seconds */
p = strchr ( psz_value , ' - ' ) ;
if ( ! strcmp ( psz_value , " now " ) )
{
schedule - > date = 0 ;
}
else if ( p = = NULL )
{
return 1 ;
}
else
{
unsigned i , j , k ;
switch ( sscanf ( p + 1 , " %u:%u:%u " , & i , & j , & k ) )
{
case 1 :
time . tm_sec = i ;
break ;
case 2 :
time . tm_min = i ;
time . tm_sec = j ;
break ;
case 3 :
time . tm_hour = i ;
time . tm_min = j ;
time . tm_sec = k ;
break ;
default :
return 1 ;
}
switch ( sscanf ( psz_value , " %d/%d/%d " , & i , & j , & k ) )
{
case 1 :
time . tm_mday = i ;
break ;
case 2 :
time . tm_mon = i - 1 ;
time . tm_mday = j ;
break ;
case 3 :
time . tm_year = i - 1900 ;
time . tm_mon = j - 1 ;
time . tm_mday = k ;
break ;
default :
return 1 ;
}
schedule - > date = mktime ( & time ) ;
}
}
else if ( ! strcmp ( psz_cmd , " period " ) )
{
struct tm time ;
const char * p ;
const char * psz_time = NULL , * psz_date = NULL ;
unsigned i , j , k ;
/* First, if date or period are modified, repeat should be equal to -1 */
schedule - > i_repeat = - 1 ;
time . tm_sec = 0 ; /* seconds */
time . tm_min = 0 ; /* minutes */
time . tm_hour = 0 ; /* hours */
time . tm_mday = 0 ; /* day of the month */
time . tm_mon = 0 ; /* month */
time . tm_year = 0 ; /* year */
time . tm_wday = 0 ; /* day of the week */
time . tm_yday = 0 ; /* day in the year */
time . tm_isdst = - 1 ; /* daylight saving time */
/* date should be year/month/day-hour:minutes:seconds */
p = strchr ( psz_value , ' - ' ) ;
if ( p )
{
psz_date = psz_value ;
psz_time = p + 1 ;
}
else
{
psz_time = psz_value ;
}
switch ( sscanf ( psz_time , " %u:%u:%u " , & i , & j , & k ) )
{
case 1 :
time . tm_sec = i ;
break ;
case 2 :
time . tm_min = i ;
time . tm_sec = j ;
break ;
case 3 :
time . tm_hour = i ;
time . tm_min = j ;
time . tm_sec = k ;
break ;
default :
return 1 ;
}
if ( psz_date )
{
switch ( sscanf ( psz_date , " %u/%u/%u " , & i , & j , & k ) )
{
case 1 :
time . tm_mday = i ;
break ;
case 2 :
time . tm_mon = i ;
time . tm_mday = j ;
break ;
case 3 :
time . tm_year = i ;
time . tm_mon = j ;
time . tm_mday = k ;
break ;
default :
return 1 ;
}
}
/* ok, that's stupid... who is going to schedule streams every 42 years ? */
schedule - > period = ( ( ( ( time . tm_year * 12 + time . tm_mon ) * 30
+ time . tm_mday ) * 24 + time . tm_hour ) * 60 + time . tm_min ) * 60
+ time . tm_sec ;
if ( schedule - > period > = 86400 | | ( schedule - > period > 0 & &
86400 % schedule - > period = = 0 & & 3600 % schedule - > period ! = 0 ) )
{
msg_Warn ( vlm , " Repeating VLM schedules neither adjust for DST nor properly count calendar months or years " ) ;
}
}
else if ( ! strcmp ( psz_cmd , " repeat " ) )
{
int i ;
if ( sscanf ( psz_value , " %d " , & i ) = = 1 )
{
schedule - > i_repeat = i ;
}
else
{
return 1 ;
}
}
else if ( ! strcmp ( psz_cmd , " append " ) )
{
char * command = strdup ( psz_value ) ;
TAB_APPEND ( schedule - > i_command , schedule - > command , command ) ;
}
else
{
return 1 ;
}
return 0 ;
}
/*****************************************************************************
* Message handling functions
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@ -1350,7 +966,6 @@ static vlm_message_t *vlm_ShowMedia( vlm_media_sys_t *p_media )
}
static vlm_message_t * vlm_Show ( vlm_t * vlm , vlm_media_sys_t * media ,
vlm_schedule_sys_t * schedule ,
const char * psz_filter )
{
if ( media ! = NULL )
@ -1361,80 +976,6 @@ static vlm_message_t *vlm_Show( vlm_t *vlm, vlm_media_sys_t *media,
return p_msg ;
}
else if ( schedule ! = NULL )
{
int i ;
vlm_message_t * msg ;
vlm_message_t * msg_schedule ;
vlm_message_t * msg_child ;
char buffer [ 100 ] ;
msg = vlm_MessageSimpleNew ( " show " ) ;
msg_schedule =
vlm_MessageAdd ( msg , vlm_MessageSimpleNew ( schedule - > psz_name ) ) ;
vlm_MessageAdd ( msg_schedule , vlm_MessageNew ( " type " , " schedule " ) ) ;
vlm_MessageAdd ( msg_schedule ,
vlm_MessageNew ( " enabled " , schedule - > b_enabled ?
" yes " : " no " ) ) ;
if ( schedule - > date ! = 0 )
{
struct tm date ;
localtime_r ( & schedule - > date , & date ) ;
vlm_MessageAdd ( msg_schedule ,
vlm_MessageNew ( " date " , " %d/%d/%d-%d:%d:%d " ,
date . tm_year + 1900 , date . tm_mon + 1 ,
date . tm_mday , date . tm_hour , date . tm_min ,
date . tm_sec ) ) ;
}
else
vlm_MessageAdd ( msg_schedule , vlm_MessageNew ( " date " , " now " ) ) ;
if ( schedule - > period ! = 0 )
{
div_t d ;
struct tm date ;
d = div ( schedule - > period , 60 ) ;
date . tm_sec = d . rem ;
d = div ( d . quot , 60 ) ;
date . tm_min = d . rem ;
d = div ( d . quot , 24 ) ;
date . tm_hour = d . rem ;
/* okay, okay, months are not always 30 days long */
d = div ( d . quot , 30 ) ;
date . tm_mday = d . rem ;
d = div ( d . quot , 12 ) ;
date . tm_mon = d . rem ;
date . tm_year = d . quot ;
sprintf ( buffer , " %d/%d/%d-%d:%d:%d " , date . tm_year , date . tm_mon ,
date . tm_mday , date . tm_hour , date . tm_min , date . tm_sec ) ;
vlm_MessageAdd ( msg_schedule , vlm_MessageNew ( " period " , " %s " , buffer ) ) ;
}
else
vlm_MessageAdd ( msg_schedule , vlm_MessageNew ( " period " , " 0 " ) ) ;
sprintf ( buffer , " %d " , schedule - > i_repeat ) ;
vlm_MessageAdd ( msg_schedule , vlm_MessageNew ( " repeat " , " %s " , buffer ) ) ;
msg_child =
vlm_MessageAdd ( msg_schedule , vlm_MessageSimpleNew ( " commands " ) ) ;
for ( i = 0 ; i < schedule - > i_command ; i + + )
{
vlm_MessageAdd ( msg_child ,
vlm_MessageSimpleNew ( schedule - > command [ i ] ) ) ;
}
return msg ;
}
else if ( psz_filter & & ! strcmp ( psz_filter , " media " ) )
{
vlm_message_t * p_msg ;
@ -1451,72 +992,9 @@ static vlm_message_t *vlm_Show( vlm_t *vlm, vlm_media_sys_t *media,
return p_msg ;
}
else if ( psz_filter & & ! strcmp ( psz_filter , " schedule " ) )
else if ( ( psz_filter = = NULL ) & & ( media = = NULL ) )
{
int i ;
vlm_message_t * msg ;
vlm_message_t * msg_child ;
msg = vlm_MessageSimpleNew ( " show " ) ;
msg_child = vlm_MessageAdd ( msg , vlm_MessageSimpleNew ( " schedule " ) ) ;
for ( i = 0 ; i < vlm - > i_schedule ; i + + )
{
vlm_schedule_sys_t * s = vlm - > schedule [ i ] ;
vlm_message_t * msg_schedule ;
time_t now , next_date ;
msg_schedule = vlm_MessageAdd ( msg_child ,
vlm_MessageSimpleNew ( s - > psz_name ) ) ;
vlm_MessageAdd ( msg_schedule ,
vlm_MessageNew ( " enabled " , s - > b_enabled ?
" yes " : " no " ) ) ;
/* calculate next date */
time ( & now ) ;
next_date = s - > date ;
if ( s - > period ! = 0 )
{
int j = 0 ;
while ( ( ( s - > date + j * s - > period ) < = now ) & &
( s - > i_repeat > j | | s - > i_repeat < 0 ) )
{
j + + ;
}
next_date = s - > date + j * s - > period ;
}
if ( next_date > now )
{
struct tm tm ;
char psz_date [ 32 ] ;
strftime ( psz_date , sizeof ( psz_date ) , " %Y-%m-%d %H:%M:%S (%a) " ,
localtime_r ( & next_date , & tm ) ) ;
vlm_MessageAdd ( msg_schedule ,
vlm_MessageNew ( " next launch " , " %s " , psz_date ) ) ;
}
}
return msg ;
}
else if ( ( psz_filter = = NULL ) & & ( media = = NULL ) & & ( schedule = = NULL ) )
{
vlm_message_t * show1 = vlm_Show ( vlm , NULL , NULL , " media " ) ;
vlm_message_t * show2 = vlm_Show ( vlm , NULL , NULL , " schedule " ) ;
vlm_MessageAdd ( show1 , show2 - > child [ 0 ] ) ;
/* We must destroy the parent node "show" of show2
* and not the children */
free ( show2 - > child ) ;
free ( show2 - > psz_name ) ;
free ( show2 ) ;
return show1 ;
return vlm_Show ( vlm , NULL , " media " ) ;
}
else
@ -1607,54 +1085,6 @@ VLC_MALLOC static char *Save( vlm_t *vlm )
p_cfg - > psz_name , p_cfg - > ppsz_option [ j ] ) ;
}
/* and now, the schedule scripts */
for ( int i = 0 ; i < vlm - > i_schedule ; i + + )
{
vlm_schedule_sys_t * schedule = vlm - > schedule [ i ] ;
struct tm tm ;
localtime_r ( & schedule - > date , & tm ) ;
vlc_memstream_printf ( & stream , " new %s schedule date "
" %d/%d/%d-%d:%d:%d %sabled \n " ,
schedule - > psz_name ,
tm . tm_year + 1900 , tm . tm_mon + 1 , tm . tm_mday ,
tm . tm_hour , tm . tm_min , tm . tm_sec ,
schedule - > b_enabled ? " en " : " dis " ) ;
if ( schedule - > period ! = 0 )
{
div_t d ;
d = div ( schedule - > period , 60 ) ;
tm . tm_sec = d . rem ;
d = div ( d . quot , 60 ) ;
tm . tm_min = d . rem ;
d = div ( d . quot , 24 ) ;
tm . tm_hour = d . rem ;
d = div ( d . quot , 30 ) ;
tm . tm_mday = d . rem ;
/* okay, okay, months are not always 30 days long */
d = div ( d . quot , 12 ) ;
tm . tm_mon = d . rem ;
tm . tm_year = d . quot ;
vlc_memstream_printf ( & stream , " setup %s "
" period %d/%d/%d-%d:%d:%d \n " ,
schedule - > psz_name ,
tm . tm_year , tm . tm_mon , tm . tm_mday ,
tm . tm_hour , tm . tm_min , tm . tm_sec ) ;
}
if ( schedule - > i_repeat > = 0 )
vlc_memstream_printf ( & stream , " setup %s repeat %d " ,
schedule - > psz_name , schedule - > i_repeat ) ;
vlc_memstream_putc ( & stream , ' \n ' ) ;
for ( int j = 0 ; j < schedule - > i_command ; j + + )
vlc_memstream_printf ( & stream , " setup %s append %s \n " ,
schedule - > psz_name , schedule - > command [ j ] ) ;
}
if ( vlc_memstream_close ( & stream ) )
return NULL ;
return stream . ptr ;