libmp3splt
|
00001 /********************************************************** 00002 * 00003 * libmp3splt -- library based on mp3splt, 00004 * for mp3/ogg splitting without decoding 00005 * 00006 * Copyright (c) 2002-2005 M. Trotta - <mtrotta@users.sourceforge.net> 00007 * Copyright (c) 2005-2011 Alexandru Munteanu - io_fx@yahoo.fr 00008 * 00009 * http://mp3splt.sourceforge.net 00010 * 00011 *********************************************************/ 00012 00013 /********************************************************** 00014 * 00015 * This program is free software; you can redistribute it and/or 00016 * modify it under the terms of the GNU General Public License 00017 * as published by the Free Software Foundation; either version 2 00018 * of the License, or (at your option) any later version. 00019 * 00020 * This program is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * You should have received a copy of the GNU General Public License 00026 * along with this program; if not, write to the Free Software 00027 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00028 * 02111-1307, 00029 * USA. 00030 * 00031 *********************************************************/ 00032 00038 #include <string.h> 00039 00040 #include "splt.h" 00041 00043 void splt_w_set_wrap_default_values(splt_state *state) 00044 { 00045 splt_wrap *wrap = state->wrap; 00046 wrap->wrap_files = NULL; 00047 wrap->wrap_files_num = 0; 00048 } 00049 00051 int splt_w_wrap_put_file(splt_state *state, int wrapfiles, int index, 00052 const char *filename) 00053 { 00054 splt_wrap *wrap = state->wrap; 00055 00056 if (index == 0) 00057 { 00058 if ((wrap->wrap_files = malloc(wrapfiles * sizeof(char*))) == NULL) 00059 { 00060 return SPLT_ERROR_CANNOT_ALLOCATE_MEMORY; 00061 } 00062 memset(wrap->wrap_files, 0x0, sizeof(char *) * wrapfiles); 00063 00064 wrap->wrap_files_num = 0; 00065 } 00066 00067 int err = splt_su_copy(filename, &wrap->wrap_files[index]); 00068 if (err < 0) { return err; } 00069 00070 wrap->wrap_files_num++; 00071 00072 return SPLT_OK; 00073 } 00074 00076 static void splt_w_free_files(char **files, int number) 00077 { 00078 if (files != NULL) 00079 { 00080 if (number != 0) 00081 { 00082 int i = 0; 00083 for (i = 0; i < number; i++) 00084 { 00085 if (files[i]) 00086 { 00087 free(files[i]); 00088 files[i] = NULL; 00089 } 00090 } 00091 } 00092 00093 free(files); 00094 files = NULL; 00095 } 00096 } 00097 00099 void splt_w_wrap_free(splt_state *state) 00100 { 00101 splt_wrap *wrap = state->wrap; 00102 if (!wrap) 00103 { 00104 return; 00105 } 00106 splt_w_free_files(wrap->wrap_files, wrap->wrap_files_num); 00107 wrap->wrap_files_num = 0; 00108 } 00109