Win32: add support for play and pause buttons in media keys (different from a plya...
[vlc/solaris.git] / src / misc / sql.c
blobb2177bda9d883152427b9c1fd3fe0bfbe6fb3136
1 /*****************************************************************************
2 * sql.c: SQL Connection: Creators and destructors
3 *****************************************************************************
4 * Copyright (C) 2008-2009 the VideoLAN team
5 * $Id$
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
26 #endif
28 #ifdef HAVE_CONFIG_H
29 #include "config.h"
30 #endif
32 #include <vlc_common.h>
33 #include <vlc_sql.h>
34 #include <assert.h>
35 #include "libvlc.h"
37 #undef sql_Create
38 sql_t *sql_Create( vlc_object_t *p_this, const char *psz_name,
39 const char* psz_host, int i_port,
40 const char* psz_user, const char* psz_pass )
42 sql_t *p_sql;
44 p_sql = ( sql_t * ) vlc_custom_create( p_this, sizeof( sql_t ),
45 VLC_OBJECT_GENERIC, "sql" );
46 if( !p_sql )
48 msg_Err( p_this, "unable to create sql object" );
49 return NULL;
51 vlc_object_attach( p_sql, p_this );
53 p_sql->psz_host = strdup( psz_host );
54 p_sql->psz_user = strdup( psz_user );
55 p_sql->psz_pass = strdup( psz_pass );
56 p_sql->i_port = i_port;
58 p_sql->p_module = module_need( p_sql, "sql", psz_name,
59 psz_name && *psz_name );
60 if( !p_sql->p_module )
62 free( p_sql->psz_host );
63 free( p_sql->psz_user );
64 free( p_sql->psz_pass );
65 vlc_object_release( p_sql );
66 msg_Err( p_this, "SQL provider not found" );
67 return NULL;
70 return p_sql;
73 #undef sql_Destroy
74 void sql_Destroy( vlc_object_t* obj )
76 sql_t *p_sql = (sql_t *)obj;
77 assert( p_sql );
79 free( p_sql->psz_host );
80 free( p_sql->psz_user );
81 free( p_sql->psz_pass );
83 module_unneed( p_sql, p_sql->p_module );
85 vlc_object_release( obj );