]> git.sesse.net Git - vlc/blob - modules/misc/playlist/old.c
Clone video filter : fix potential memleak.
[vlc] / modules / misc / playlist / old.c
1 /*****************************************************************************
2  * old.c : Old playlist format import/export
3  *****************************************************************************
4  * Copyright (C) 2004 the VideoLAN team
5  * $Id$
6  *
7  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27
28 #ifdef HAVE_CONFIG_H
29 # include "config.h"
30 #endif
31
32 #include <vlc_common.h>
33 #include <vlc_interface.h>
34 #include <vlc_playlist.h>
35 #include <vlc_input.h>
36 #include <vlc_charset.h>
37
38 #include <errno.h>                                                 /* ENOMEM */
39
40 #define PLAYLIST_FILE_HEADER "# vlc playlist file version 0.5"
41
42 /*****************************************************************************
43  * Local prototypes
44  *****************************************************************************/
45 int Export_Old ( vlc_object_t * );
46
47 /*****************************************************************************
48  * Export_Old : main export function
49  *****************************************************************************/
50 int Export_Old( vlc_object_t *p_this )
51 {
52     playlist_t *p_playlist = (playlist_t*)p_this;
53     playlist_export_t *p_export = (playlist_export_t *)p_playlist->p_private;
54     int i;
55
56     msg_Dbg(p_playlist, "saving using old format");
57
58     /* Write header */
59     fprintf( p_export->p_file , PLAYLIST_FILE_HEADER "\n" );
60
61     for ( i = 0 ; i < p_export->p_root->i_children ; i++ )
62         utf8_fprintf( p_export->p_file , "%s\n" ,
63                       p_export->p_root->pp_children[i]->p_input->psz_name );
64
65     return VLC_SUCCESS;
66 }