# include <sys/timeb.h> /* ftime() */
#endif
-#include "vlc_vlm.h"
-#include "vlc_vod.h"
+#include <vlc_vlm.h>
+#include <vlc_vod.h>
+#include <charset.h>
#define FREE( p ) \
if( p ) { free( p ); (p) = NULL; }
static vlm_message_t *vlm_Show( vlm_t *, vlm_media_t *, vlm_schedule_t *, char * );
static vlm_message_t *vlm_Help( vlm_t *, char * );
-static vlm_media_t *vlm_MediaSearch ( vlm_t *, const char * );
static vlm_media_instance_t *vlm_MediaInstanceSearch( vlm_t *, vlm_media_t *, const char * );
static vlm_message_t *vlm_MessageNew( char *, const char *, ... );
if( !p_vlm || !psz_file ) return 1;
- file = fopen( psz_file, "wt" );
+ file = utf8_fopen( psz_file, "wt" );
if( file == NULL ) return 1;
psz_save = Save( p_vlm );
*****************************************************************************/
int vlm_Load( vlm_t *p_vlm, const char *psz_file )
{
- FILE *file;
+ stream_t *p_stream;
int64_t i_size;
char *psz_buffer;
if( !p_vlm || !psz_file ) return 1;
- file = fopen( psz_file, "r" );
- if( file == NULL ) return 1;
+ p_stream = stream_UrlNew( p_vlm, psz_file );
+ if( p_stream == NULL ) return 1;
- if( fseek( file, 0, SEEK_END) != 0 )
+ if( stream_Seek( p_stream, 0 ) != 0 )
{
- fclose( file );
+ stream_Delete( p_stream );
return 2;
}
- i_size = ftell( file );
- fseek( file, 0, SEEK_SET );
+ i_size = stream_Size( p_stream );
+
psz_buffer = malloc( i_size + 1 );
if( !psz_buffer )
{
- fclose( file );
+ stream_Delete( p_stream );
return 2;
}
- fread( psz_buffer, 1, i_size, file );
+
+ stream_Read( p_stream, psz_buffer, i_size );
psz_buffer[ i_size ] = '\0';
+
+ stream_Delete( p_stream );
+
if( Load( p_vlm, psz_buffer ) )
{
- fclose( file );
free( psz_buffer );
return 3;
}
free( psz_buffer );
- fclose( file );
return 0;
}
}
else
{
- if( i + 1 >= i_command &&
+ if( ( (i + 1) >= i_command ) &&
!strcmp(ppsz_command[0], "new") )
{
vlm_MediaDelete( p_vlm, p_media, NULL );
"Wrong properties syntax" );
goto error;
}
- else if( i + 1 >= i_command )
+ else if( (i + 1) >= i_command )
{
p_message =
vlm_MessageNew( ppsz_command[0],
return VLC_EGENERIC;
}
-static vlm_media_t *vlm_MediaSearch( vlm_t *vlm, const char *psz_name )
+vlm_media_t *vlm_MediaSearch( vlm_t *vlm, const char *psz_name )
{
int i;
vlc_input_item_Init( VLC_OBJECT(vlm), &p_instance->item );
p_instance->p_input = NULL;
- if( media->psz_output != NULL || media->psz_vod_output != NULL )
+ if( ( media->psz_output != NULL ) || ( media->psz_vod_output != NULL ) )
{
p_instance->item.ppsz_options = malloc( sizeof( char* ) );
asprintf( &p_instance->item.ppsz_options[0], "sout=%s%s%s",
TAB_APPEND( media->i_instance, media->instance, p_instance );
}
- if( psz_args && sscanf(psz_args, "%d", &i) == 1 && i < media->i_input )
+ if( ( psz_args && sscanf(psz_args, "%d", &i) == 1 ) && ( i < media->i_input ) )
{
p_instance->i_index = i;
}
{
schedule->i_date = 0;
}
- else if( p == NULL && sscanf( psz_value, "%d:%d:%d", &time.tm_hour, &time.tm_min, &time.tm_sec ) != 3 ) /* it must be a hour:minutes:seconds */
+ else if( (p == NULL) && sscanf( psz_value, "%d:%d:%d", &time.tm_hour,
+ &time.tm_min, &time.tm_sec ) != 3 )
+ /* it must be a hour:minutes:seconds */
{
return 1;
}
psz_time = psz_value;
}
-
switch( sscanf( psz_time, "%u:%u:%u", &i, &j, &k ) )
{
case 1:
return msg;
}
- else if( psz_filter == NULL && media == NULL && schedule == NULL )
+ 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" );
int vlm_ExecuteCommand( vlm_t *a, char *b, vlm_message_t **c ){ return -1; }
void vlm_MessageDelete( vlm_message_t *a ){}
vlm_media_t *vlm_MediaNew( vlm_t *a, char *b, int c ){ return NULL; }
+vlm_media_t *vlm_MediaSearch (vlm_t *a, const char *b ) { return NULL; }
void vlm_MediaDelete( vlm_t *a, vlm_media_t *b, char *c ){}
int vlm_MediaSetup( vlm_t *a, vlm_media_t *b, char *c, char *d ){ return -1; }
int vlm_MediaControl( vlm_t *a, vlm_media_t *b, char *c, char *d, char *e )