#include "http.h"
#include <limits.h>
-
-#include <assert.h>
+#include <errno.h>
+#include <ctype.h>
/* Utility function for scandir */
static int Filter( const char *foo )
v->value = strdup( value ? value : "" );
v->i_field = 0;
- v->field = malloc( sizeof( mvar_t * ) );
+ v->field = xmalloc( sizeof( mvar_t * ) );
v->field[0] = NULL;
return v;
void mvar_AppendVar( mvar_t *v, mvar_t *f )
{
- v->field = realloc( v->field, sizeof( mvar_t * ) * ( v->i_field + 2 ) );
+ v->field = xrealloc( v->field, sizeof( mvar_t * ) * ( v->i_field + 2 ) );
v->field[v->i_field] = f;
v->i_field++;
}
void mvar_PushVar( mvar_t *v, mvar_t *f )
{
- v->field = realloc( v->field, sizeof( mvar_t * ) * ( v->i_field + 2 ) );
+ v->field = xrealloc( v->field, sizeof( mvar_t * ) * ( v->i_field + 2 ) );
if( v->i_field > 0 )
{
memmove( &v->field[1], &v->field[0], sizeof( mvar_t * ) * v->i_field );
return NULL;
}
-char *mvar_GetValue( mvar_t *v, char *field )
+const char *mvar_GetValue( mvar_t *v, const char *field )
{
if( *field == '\0' )
{
playlist_t *p_pl )
{
mvar_t *s = mvar_New( name, "set" );
- vlc_mutex_lock( &p_pl->object_lock );
+ playlist_Lock( p_pl );
PlaylistListNode( p_intf, p_pl, p_pl->p_root_category , name, s, 0 );
- vlc_mutex_unlock( &p_pl->object_lock );
+ playlist_Unlock( p_pl );
return s;
}
mvar_t *mvar_ObjectSetNew( intf_thread_t *p_intf, char *psz_name,
const char *psz_capability )
{
+ VLC_UNUSED(p_intf);
mvar_t *s = mvar_New( psz_name, "set" );
- int i;
+ size_t i;
- vlc_list_t *p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE,
- FIND_ANYWHERE );
+ module_t **p_list = module_list_get( NULL );
- for( i = 0; i < p_list->i_count; i++ )
+ for( i = 0; p_list[i]; i++ )
{
- module_t *p_parser = (module_t *)p_list->p_values[i].p_object;
- if( module_IsCapable( p_parser, psz_capability ) )
+ module_t *p_parser = p_list[i];
+ if( module_provides( p_parser, psz_capability ) )
{
- mvar_t *sd = mvar_New( "sd", module_GetObjName( p_parser ) );
+ mvar_t *sd = mvar_New( "sd", module_get_object( p_parser ) );
mvar_AppendNewVar( sd, "name",
- module_GetName( p_parser, true ) );
+ module_get_name( p_parser, true ) );
mvar_AppendVar( s, sd );
}
}
- vlc_list_release( p_list );
+ module_list_free( p_list );
return s;
}
for( i = 0; i < val_list.p_list->i_count; i++ )
{
- char *psz, psz_int[16];
+ char psz_int[16];
mvar_t *itm;
switch( i_type & VLC_VAR_TYPE )
{
case VLC_VAR_STRING:
itm = mvar_New( name, "set" );
- /* FIXME: Memory leak here?? (remove strdup?) */
- psz = strdup( text_list.p_list->p_values[i].psz_string );
- mvar_AppendNewVar( itm, "name", psz );
+ mvar_AppendNewVar( itm, "name", text_list.p_list->p_values[i].psz_string );
mvar_AppendNewVar( itm, "id", val_list.p_list->p_values[i].psz_string );
snprintf( psz_int, sizeof(psz_int), "%d",
( !strcmp( val.psz_string,
case VLC_VAR_INTEGER:
itm = mvar_New( name, "set" );
- psz = strdup( text_list.p_list->p_values[i].psz_string );
- mvar_AppendNewVar( itm, "name", psz );
+ mvar_AppendNewVar( itm, "name", text_list.p_list->p_values[i].psz_string );
snprintf( psz_int, sizeof(psz_int), "%d",
val_list.p_list->p_values[i].i_int );
mvar_AppendNewVar( itm, "id", psz_int );
}
/* clean up everything */
if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
- var_Change( p_sys->p_input, psz_variable, VLC_VAR_FREELIST, &val_list,
- &text_list );
+ var_FreeList( &val_list, &text_list );
return s;
}
mvar_t *s = mvar_New( name, "set" );
char **ppsz_dir_content;
int i_dir_content, i;
- psz_dir = RealPath( p_intf, psz_dir );
-
-#if defined( WIN32 )
- if( psz_dir[0] != '\0' && (psz_dir[0] != '\\' || psz_dir[1] != '\0') )
- {
- free( psz_dir );
- return s;
- }
-#endif
+ psz_dir = RealPath( psz_dir );
/* parse psz_src dir */
if( ( i_dir_content = utf8_scandir( psz_dir, &ppsz_dir_content, Filter,
else
#endif
{
- char psz_ctime[26];
+ char psz_buf[26];
char psz_tmp[strlen( psz_dir ) + 1 + strlen( psz_name ) + 1];
sprintf( psz_tmp, "%s"DIR_SEP"%s", psz_dir, psz_name );
mvar_AppendNewVar( f, "type", "unknown" );
}
- sprintf( psz_ctime, "%"PRId64, (int64_t)stat_info.st_size );
- mvar_AppendNewVar( f, "size", psz_ctime );
+ snprintf( psz_buf, sizeof( psz_buf ), "%"PRId64,
+ (int64_t)stat_info.st_size );
+ mvar_AppendNewVar( f, "size", psz_buf );
/* FIXME memory leak FIXME */
# ifdef HAVE_CTIME_R
- ctime_r( &stat_info.st_mtime, psz_ctime );
- mvar_AppendNewVar( f, "date", psz_ctime );
+ ctime_r( &stat_info.st_mtime, psz_buf );
+ mvar_AppendNewVar( f, "date", psz_buf );
# else
mvar_AppendNewVar( f, "date", ctime( &stat_info.st_mtime ) );
# endif
mvar_t *mvar_VlmSetNew( char *name, vlm_t *vlm )
{
mvar_t *s = mvar_New( name, "set" );
+#ifdef ENABLE_VLM
vlm_message_t *msg;
int i;
if( vlm == NULL ) return s;
if( vlm_ExecuteCommand( vlm, "show", &msg ) )
- {
return s;
- }
for( i = 0; i < msg->i_child; i++ )
{
}
}
vlm_MessageDelete( msg );
-
+#endif /* ENABLE_VLM */
return s;
}