renatofilho@320: /** renatofilho@320: * GMyth Library renatofilho@320: * renatofilho@320: * @file gmyth/gmyth_common.c renatofilho@320: * renatofilho@320: * @brief

This file contains basic common functions for the gmyth library. renatofilho@320: * renatofilho@320: * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia. renatofilho@320: * @author Leonardo Sobral Cunha renatofilho@320: * renatofilho@320: *//* renatofilho@320: * renatofilho@320: * This program is free software; you can redistribute it and/or modify renatofilho@320: * it under the terms of the GNU Lesser General Public License as published by renatofilho@320: * the Free Software Foundation; either version 2 of the License, or renatofilho@320: * (at your option) any later version. renatofilho@320: * renatofilho@320: * This program is distributed in the hope that it will be useful, renatofilho@320: * but WITHOUT ANY WARRANTY; without even the implied warranty of renatofilho@320: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the renatofilho@320: * GNU General Public License for more details. renatofilho@320: * renatofilho@320: * You should have received a copy of the GNU Lesser General Public License renatofilho@320: * along with this program; if not, write to the Free Software renatofilho@320: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA renatofilho@320: */ renatofilho@320: renatofilho@320: #ifdef HAVE_CONFIG_H renatofilho@320: #include "config.h" renatofilho@320: #endif renatofilho@320: renatofilho@320: #include "gmyth_common.h" renatofilho@320: #include "gmyth_debug.h" renatofilho@320: #include "gmyth_util.h" renatofilho@320: renatofilho@320: static void free_channel_data(gpointer data, gpointer user_data); renatofilho@320: static void free_program_data(gpointer data, gpointer user_data); renatofilho@320: renatofilho@320: /** Frees the memory allocated to the GMythChannelInfo objects inside list. renatofilho@320: * The list memory is also released by g_list_free(). If LIST is NULL it renatofilho@320: * simply returns. renatofilho@320: * renatofilho@320: * @param list the GList containing a list of GMythChannelInfo to free. renatofilho@320: */ renatofilho@320: void renatofilho@320: gmyth_free_channel_list(GList *list) renatofilho@320: { renatofilho@320: if (list == NULL) { renatofilho@320: g_warning ("%s received null GList as parameter", __FUNCTION__); renatofilho@320: return; renatofilho@320: } renatofilho@320: renatofilho@320: g_list_foreach (list, free_channel_data, NULL); renatofilho@320: renatofilho@320: g_list_free (list); renatofilho@320: } renatofilho@320: renatofilho@320: /** Frees the memory allocated to the GMythProgramInfo objects inside list. renatofilho@320: * The list memory is also released by g_list_free(). If list is NULL it renatofilho@320: * simply returns. renatofilho@320: * renatofilho@320: * @param list the GList containing a list of GMythProgramInfo to free. renatofilho@320: */ renatofilho@320: void renatofilho@320: gmyth_free_program_list(GList *list) renatofilho@320: { renatofilho@320: if (list == NULL) { renatofilho@320: g_warning ("%s received null GList as parameter", __FUNCTION__); renatofilho@320: return; renatofilho@320: } renatofilho@320: renatofilho@320: g_list_foreach (list, free_program_data, NULL); renatofilho@320: renatofilho@320: g_list_free (list); renatofilho@320: } renatofilho@320: renatofilho@320: void renatofilho@320: gmyth_channel_info_print(GMythChannelInfo *channel_info) renatofilho@320: { renatofilho@320: if ( channel_info != NULL ) renatofilho@320: { renatofilho@320: gmyth_debug("ChannelInfo (Name, Num, ID) = (%s, %s, %d)\n", renatofilho@320: channel_info->channel_name->str, channel_info->channel_num->str, renatofilho@320: channel_info->channel_ID); renatofilho@320: } renatofilho@320: } renatofilho@320: renatofilho@320: void renatofilho@320: gmyth_program_info_print(GMythProgramInfo *program_info) renatofilho@320: { renatofilho@320: renatofilho@320: if ( program_info != NULL ) { renatofilho@320: renatofilho@320: gmyth_debug( "ProgramInfo\n\tTitle = %s\n\t" renatofilho@320: "Description = %s\n\t" renatofilho@320: "Start time= %s\t" renatofilho@320: "End time = %s\n" renatofilho@320: "Path name = %s\n" renatofilho@320: "File size = %lld\n" renatofilho@320: , program_info->title->str, renatofilho@320: program_info->description->str, renatofilho@320: gmyth_util_time_to_string_from_time_val(program_info->startts), renatofilho@320: gmyth_util_time_to_string_from_time_val(program_info->endts), renatofilho@320: program_info->pathname->str, renatofilho@320: program_info->filesize ); renatofilho@320: renatofilho@320: } renatofilho@320: renatofilho@320: } renatofilho@320: renatofilho@320: static void renatofilho@320: free_channel_data(gpointer data, gpointer user_data) renatofilho@320: { renatofilho@320: if(data) renatofilho@320: g_free((GMythChannelInfo*) data); renatofilho@320: } renatofilho@320: renatofilho@320: static void renatofilho@320: free_program_data(gpointer data, gpointer user_data) renatofilho@320: { renatofilho@320: if(data) renatofilho@320: g_object_unref((GMythProgramInfo*) data); renatofilho@320: } renatofilho@320: