Commit 08f5b0d0 authored by Antoine Cellerier's avatar Antoine Cellerier

Hopefully fix #1910 'When I use the command "mrl playlist_add vlc_play",...

Hopefully fix #1910 'When I use the command "mrl playlist_add vlc_play", "playlist_add" used to return the index of the item added to the playlist wheras in the last nightly build, "playlist_add" just add 0 to the stack. Thus, "vlc_play" just play the first element of the playlist in spite of playing the desired file.' ... and fix an unrelated compilation warning which ended up being a bit more complex to fix than I though.
parent e30dd13c
...@@ -118,10 +118,10 @@ void HandleSeek( intf_thread_t *p_intf, char *p_value ); ...@@ -118,10 +118,10 @@ void HandleSeek( intf_thread_t *p_intf, char *p_value );
/** This function extracts the value for a given argument name /** This function extracts the value for a given argument name
* from an HTTP request */ * from an HTTP request */
char *ExtractURIValue( char *restrict psz_uri, const char *ExtractURIValue( const char *restrict psz_uri,
const char *restrict psz_name, const char *restrict psz_name,
char *restrict psz_value, size_t i_value_max ); char *restrict psz_value, size_t i_value_max );
char *ExtractURIString( char *restrict psz_uri, char *ExtractURIString( const char *restrict psz_uri,
const char *restrict psz_name ); const char *restrict psz_name );
/** \todo Describe this function */ /** \todo Describe this function */
int TestURIParam( char *psz_uri, const char *psz_name ); int TestURIParam( char *psz_uri, const char *psz_name );
...@@ -177,7 +177,7 @@ void mvar_RemoveVar( mvar_t *v, mvar_t *f ); ...@@ -177,7 +177,7 @@ void mvar_RemoveVar( mvar_t *v, mvar_t *f );
/** This function retrieves the child variable named "name" */ /** This function retrieves the child variable named "name" */
mvar_t *mvar_GetVar( mvar_t *s, const char *name ); mvar_t *mvar_GetVar( mvar_t *s, const char *name );
/** This function retrieves the value of the child variable named "field" */ /** This function retrieves the value of the child variable named "field" */
char *mvar_GetValue( mvar_t *v, char *field ); const char *mvar_GetValue( mvar_t *v, const char *field );
/** This function creates a variable with the given name and value and /** This function creates a variable with the given name and value and
* adds it as first child of vars */ * adds it as first child of vars */
void mvar_PushNewVar( mvar_t *vars, const char *name, void mvar_PushNewVar( mvar_t *vars, const char *name,
......
...@@ -362,7 +362,8 @@ static void MacroDo( httpd_file_sys_t *p_args, ...@@ -362,7 +362,8 @@ static void MacroDo( httpd_file_sys_t *p_args,
case MVLC_DEL: case MVLC_DEL:
{ {
int i_item, *p_items = NULL, i_nb_items = 0; int i_item, *p_items = NULL, i_nb_items = 0;
char item[512], *p_parser = p_request; char item[512];
const char *p_parser = p_request;
/* Get the list of items to delete */ /* Get the list of items to delete */
while( (p_parser = while( (p_parser =
...@@ -396,7 +397,8 @@ static void MacroDo( httpd_file_sys_t *p_args, ...@@ -396,7 +397,8 @@ static void MacroDo( httpd_file_sys_t *p_args,
case MVLC_KEEP: case MVLC_KEEP:
{ {
int i_item, *p_items = NULL, i_nb_items = 0; int i_item, *p_items = NULL, i_nb_items = 0;
char item[512], *p_parser = p_request; char item[512];
const char *p_parser = p_request;
int i,j; int i,j;
/* Get the list of items to keep */ /* Get the list of items to keep */
...@@ -769,7 +771,8 @@ static void MacroDo( httpd_file_sys_t *p_args, ...@@ -769,7 +771,8 @@ static void MacroDo( httpd_file_sys_t *p_args,
} }
case MVLC_VALUE: case MVLC_VALUE:
{ {
char *s, *v; char *s;
const char *v;
if( m->param1 ) if( m->param1 )
{ {
......
...@@ -182,7 +182,7 @@ mvar_t *mvar_GetVar( mvar_t *s, const char *name ) ...@@ -182,7 +182,7 @@ mvar_t *mvar_GetVar( mvar_t *s, const char *name )
return NULL; return NULL;
} }
char *mvar_GetValue( mvar_t *v, char *field ) const char *mvar_GetValue( mvar_t *v, const char *field )
{ {
if( *field == '\0' ) if( *field == '\0' )
{ {
......
...@@ -100,7 +100,6 @@ char *SSPop( rpn_stack_t *st ) ...@@ -100,7 +100,6 @@ char *SSPop( rpn_stack_t *st )
int SSPopN( rpn_stack_t *st, mvar_t *vars ) int SSPopN( rpn_stack_t *st, mvar_t *vars )
{ {
char *name; char *name;
char *value;
char *end; char *end;
int i; int i;
...@@ -109,7 +108,7 @@ int SSPopN( rpn_stack_t *st, mvar_t *vars ) ...@@ -109,7 +108,7 @@ int SSPopN( rpn_stack_t *st, mvar_t *vars )
i = strtol( name, &end, 0 ); i = strtol( name, &end, 0 );
if( end == name ) if( end == name )
{ {
value = mvar_GetValue( vars, name ); const char *value = mvar_GetValue( vars, name );
i = atoi( value ); i = atoi( value );
} }
free( name ); free( name );
...@@ -348,7 +347,7 @@ void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars, ...@@ -348,7 +347,7 @@ void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars,
} }
else if( !strcmp( s, "url_extract" ) ) else if( !strcmp( s, "url_extract" ) )
{ {
char *url = mvar_GetValue( vars, "url_value" ); const char *url = mvar_GetValue( vars, "url_value" );
char *name = SSPop( st ); char *name = SSPop( st );
char *value = ExtractURIString( url, name ); char *value = ExtractURIString( url, name );
if( value != NULL ) if( value != NULL )
...@@ -483,7 +482,7 @@ void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars, ...@@ -483,7 +482,7 @@ void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars,
else if( !strcmp( s, "value" ) ) else if( !strcmp( s, "value" ) )
{ {
char *name = SSPop( st ); char *name = SSPop( st );
char *value = mvar_GetValue( vars, name ); const char *value = mvar_GetValue( vars, name );
SSPush( st, value ); SSPush( st, value );
...@@ -855,11 +854,19 @@ void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars, ...@@ -855,11 +854,19 @@ void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars,
i_ret = playlist_AddInput( p_sys->p_playlist, p_input, i_ret = playlist_AddInput( p_sys->p_playlist, p_input,
PLAYLIST_APPEND, PLAYLIST_END, true, PLAYLIST_APPEND, PLAYLIST_END, true,
pl_Unlocked ); pl_Unlocked );
vlc_gc_decref( p_input );
if( i_ret == VLC_SUCCESS ) if( i_ret == VLC_SUCCESS )
{
playlist_item_t *p_item;
msg_Dbg( p_intf, "requested mrl add: %s", mrl ); msg_Dbg( p_intf, "requested mrl add: %s", mrl );
p_item = playlist_ItemGetByInput( p_sys->p_playlist,
p_input,
pl_Unlocked );
if( p_item )
i_ret = p_item->i_id;
}
else else
msg_Warn( p_intf, "adding mrl %s failed", mrl ); msg_Warn( p_intf, "adding mrl %s failed", mrl );
vlc_gc_decref( p_input );
} }
free( psz_uri ); free( psz_uri );
SSPushN( st, i_ret ); SSPushN( st, i_ret );
......
...@@ -650,10 +650,10 @@ int TestURIParam( char *psz_uri, const char *psz_name ) ...@@ -650,10 +650,10 @@ int TestURIParam( char *psz_uri, const char *psz_name )
return false; return false;
} }
static char *FindURIValue( char *psz_uri, const char *restrict psz_name, static const char *FindURIValue( const char *psz_uri, const char *restrict psz_name,
size_t *restrict p_len ) size_t *restrict p_len )
{ {
char *p = psz_uri, *end; const char *p = psz_uri, *end;
size_t len; size_t len;
while( (p = strstr( p, psz_name )) ) while( (p = strstr( p, psz_name )) )
...@@ -695,13 +695,13 @@ static char *FindURIValue( char *psz_uri, const char *restrict psz_name, ...@@ -695,13 +695,13 @@ static char *FindURIValue( char *psz_uri, const char *restrict psz_name,
return p; return p;
} }
char *ExtractURIValue( char *restrict psz_uri, const char *ExtractURIValue( const char *restrict psz_uri,
const char *restrict psz_name, const char *restrict psz_name,
char *restrict psz_buf, size_t bufsize ) char *restrict psz_buf, size_t bufsize )
{ {
size_t len; size_t len;
char *psz_value = FindURIValue( psz_uri, psz_name, &len ); const char *psz_value = FindURIValue( psz_uri, psz_name, &len );
char *psz_next; const char *psz_next;
if( psz_value == NULL ) if( psz_value == NULL )
{ {
...@@ -723,11 +723,11 @@ char *ExtractURIValue( char *restrict psz_uri, ...@@ -723,11 +723,11 @@ char *ExtractURIValue( char *restrict psz_uri,
return psz_next; return psz_next;
} }
char *ExtractURIString( char *restrict psz_uri, char *ExtractURIString( const char *restrict psz_uri,
const char *restrict psz_name ) const char *restrict psz_name )
{ {
size_t len; size_t len;
char *psz_value = FindURIValue( psz_uri, psz_name, &len ); const char *psz_value = FindURIValue( psz_uri, psz_name, &len );
if( psz_value == NULL ) if( psz_value == NULL )
return NULL; return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment