/*****************************************************************************
* intf_playlist.c : Playlist management functions
*****************************************************************************
- * Copyright (C) 1999, 2000 VideoLAN
- * $Id: intf_playlist.c,v 1.5 2001/05/15 01:01:44 stef Exp $
+ * Copyright (C) 1999-2001 VideoLAN
+ * $Id: intf_playlist.c,v 1.11 2001/12/07 18:33:08 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
*****************************************************************************/
#include "defs.h"
-#include "config.h"
-
#include <stdlib.h> /* free(), strtol() */
#include <stdio.h> /* sprintf() */
#include <string.h> /* strerror() */
#include <errno.h> /* ENOMEM */
#include "common.h"
+#include "intf_msg.h"
#include "threads.h"
-#include "intf_msg.h"
#include "intf_playlist.h"
-#include "main.h"
-
/*****************************************************************************
* Local prototypes
*****************************************************************************/
void intf_PlaylistPrev( playlist_t * p_playlist )
{
vlc_mutex_lock( &p_playlist->change_lock );
+
p_playlist->i_mode = -p_playlist->i_mode;
-
NextItem( p_playlist );
-
p_playlist->i_mode = -p_playlist->i_mode;
+
vlc_mutex_unlock( &p_playlist->change_lock );
}
if( i_pos < p_playlist->i_index )
p_playlist->i_index--;
-
-
+
+
/* Decrement playlist size */
p_playlist->i_size--;
p_playlist->p_item = realloc( p_playlist->p_item,
p_playlist->i_size * sizeof( playlist_item_t ) );
intf_WarnMsg( 3, "intf: removed `%s' from playlist", psz_name );
-
+
/* Delete the item */
free( psz_name );
/*****************************************************************************
* intf_PlaylistJumpto: go to a specified position in playlist.
- *****************************************************************************
- * Note that this function does NOT take the lock
*****************************************************************************/
void intf_PlaylistJumpto( playlist_t * p_playlist , int i_pos)
{
vlc_mutex_lock( &p_playlist->change_lock );
-
+
p_playlist->i_index = i_pos;
-
+
if( p_playlist->i_index != -1 )
{
if( p_playlist->current.psz_name != NULL )
= strdup( p_playlist->current.psz_name );
}
+ p_main->p_playlist->b_stopped = 0;
vlc_mutex_unlock( &p_playlist->change_lock );
-}
+}
+
+/* URL-decode a file: URL path, return NULL if it's not what we expect */
+void intf_UrlDecode( char *encoded_path )
+{
+ char *tmp = NULL, *cur = NULL, *ext = NULL;
+ int realchar;
+
+ if( !encoded_path || *encoded_path == '\0' )
+ {
+ return;
+ }
+
+ cur = encoded_path ;
+
+ tmp = calloc(strlen(encoded_path) + 1, sizeof(char) );
+
+ while ( ( ext = strchr(cur, '%') ) != NULL)
+ {
+ strncat(tmp, cur, (ext - cur) / sizeof(char));
+ ext++;
+ if (!sscanf(ext, "%2x", &realchar))
+ {
+ free(tmp);
+ return;
+ }
+
+ tmp[strlen(tmp)] = (char)realchar;
+
+ cur = ext + 2;
+ }
+
+ strcat(tmp, cur);
+ strcpy(encoded_path,tmp);
+}
/*****************************************************************************
* Following functions are local