]> git.sesse.net Git - vlc/blob - src/misc/playlist.c
The input-II. (more info by mail in about an hour)
[vlc] / src / misc / playlist.c
1 /*****************************************************************************
2  * playlist.c : Playlist management functions
3  *****************************************************************************
4  * Copyright (C) 1999, 2000 VideoLAN
5  *
6  * Authors:
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  * 
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
21  *****************************************************************************/
22 #include "defs.h"
23
24 #include "config.h"
25
26 #include <stdlib.h>                                      /* free(), strtol() */
27 #include <stdio.h>                                              /* sprintf() */
28 #include <string.h>                                            /* strerror() */
29 #include <errno.h>                                                 /* ENOMEM */
30
31 #include "common.h"
32
33 #include "intf_msg.h"
34 #include "playlist.h"
35
36 #include "main.h"
37
38 /* Local prototypes */
39 //int TestPlugin     ( plugin_id_t *p_plugin_id, char * psz_name );
40 //int AllocatePlugin ( plugin_id_t plugin_id, plugin_bank_t * p_bank );
41
42 playlist_t * playlist_Create ( void )
43 {
44     playlist_t *p_playlist;
45
46     /* Allocate structure */
47     p_playlist = malloc( sizeof( playlist_t ) );
48     if( !p_playlist )
49     {
50         intf_ErrMsg("playlist error: %s\n", strerror( ENOMEM ) );
51         return( NULL );
52     }
53
54     p_playlist->i_index = 0;
55     p_playlist->p_list = NULL;
56
57     intf_Msg("Playlist initialized\n");
58     return( p_playlist );
59 }
60
61 void playlist_Init( playlist_t * p_playlist, int i_optind )
62 {
63     int i_list_index = 0;
64     int i_index = 0;
65     int i_argc = p_main->i_argc;
66
67     if( i_optind < i_argc )
68     {
69         i_list_index = i_argc - i_optind;
70
71         p_playlist->p_list = malloc( i_list_index * sizeof( int ) );
72
73         while( i_argc - i_index > i_optind )
74         {
75             p_playlist->p_list[ i_index ] =
76                             p_main->ppsz_argv[ i_argc - i_index - 1];
77             i_index++;
78         }
79     }
80     else
81     {
82         /* if no file was asked, get stream from the network */
83         p_playlist->p_list = NULL;
84     }
85
86     p_main->p_playlist->i_index = i_list_index;
87 }
88
89 void playlist_Destroy( playlist_t * p_playlist )
90 {
91     free( p_playlist );
92 }
93
94 /*
95  * Following functions are local
96  */
97