]> git.sesse.net Git - vlc/blobdiff - src/interface/intf_playlist.c
* Fixed a total breakage of decoder plugins introduced by fast_memcpy.
[vlc] / src / interface / intf_playlist.c
index 6971aee1028ab1ff4827d7679be3829593d11011..d7e2639f775a9bca2c9f460bcfbc13ba30021c87 100644 (file)
@@ -1,8 +1,8 @@
 /*****************************************************************************
  * 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
  *****************************************************************************/
@@ -164,11 +160,11 @@ void intf_PlaylistNext( playlist_t * p_playlist )
 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 );
 }
 
@@ -202,15 +198,15 @@ int intf_PlaylistDelete( playlist_t * p_playlist, int i_pos )
 
     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 );
@@ -248,15 +244,13 @@ void intf_PlaylistDestroy( playlist_t * p_playlist )
 
 /*****************************************************************************
  * 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 )
@@ -269,10 +263,45 @@ void intf_PlaylistJumpto( playlist_t * p_playlist , int i_pos)
                             = 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