1 /*****************************************************************************
2 * sql.c: SQL Connection: Creators and destructors
3 *****************************************************************************
4 * Copyright (C) 2008-2009 the VideoLAN team
7 * Authors: Srikanth Raju <srikiraju at gmail dot com>
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.
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.
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 *****************************************************************************/
24 #if !defined( __LIBVLC__ )
25 #error You are not libvlc or one of its plugins. You cannot include this file
32 #include <vlc_common.h>
34 #include <vlc_modules.h>
39 sql_t *sql_Create( vlc_object_t *p_this, const char *psz_name,
40 const char* psz_host, int i_port,
41 const char* psz_user, const char* psz_pass )
45 p_sql = ( sql_t * ) vlc_custom_create( p_this, sizeof( sql_t ),
46 VLC_OBJECT_GENERIC, "sql" );
49 msg_Err( p_this, "unable to create sql object" );
52 vlc_object_attach( p_sql, p_this );
54 p_sql->psz_host = strdup( psz_host );
55 p_sql->psz_user = strdup( psz_user );
56 p_sql->psz_pass = strdup( psz_pass );
57 p_sql->i_port = i_port;
59 p_sql->p_module = module_need( p_sql, "sql", psz_name,
60 psz_name && *psz_name );
61 if( !p_sql->p_module )
63 free( p_sql->psz_host );
64 free( p_sql->psz_user );
65 free( p_sql->psz_pass );
66 vlc_object_release( p_sql );
67 msg_Err( p_this, "SQL provider not found" );
75 void sql_Destroy( vlc_object_t* obj )
77 sql_t *p_sql = (sql_t *)obj;
80 free( p_sql->psz_host );
81 free( p_sql->psz_user );
82 free( p_sql->psz_pass );
84 module_unneed( p_sql, p_sql->p_module );
86 vlc_object_release( obj );