summaryrefslogtreecommitdiff
path: root/muggle-plugin/mugglei.c
diff options
context:
space:
mode:
authorlvw <lvw@e10066b5-e1e2-0310-b819-94efdf66514b>2004-10-04 07:30:45 +0000
committerlvw <lvw@e10066b5-e1e2-0310-b819-94efdf66514b>2004-10-04 07:30:45 +0000
commitac0b4a4ad469f9689a4f83f1e3b9ebc823ba4703 (patch)
tree0cb30b1131eacb3869c4c70e79f1d0927c2103d9 /muggle-plugin/mugglei.c
parentc252169fa4948d7bfd7ac7b6b7e13d2b913d8f76 (diff)
downloadvdr-plugin-muggle-ac0b4a4ad469f9689a4f83f1e3b9ebc823ba4703.tar.gz
vdr-plugin-muggle-ac0b4a4ad469f9689a4f83f1e3b9ebc823ba4703.tar.bz2
Added patch for using sockets and improved menu translations
git-svn-id: https://vdr-muggle.svn.sourceforge.net/svnroot/vdr-muggle/trunk@199 e10066b5-e1e2-0310-b819-94efdf66514b
Diffstat (limited to 'muggle-plugin/mugglei.c')
-rwxr-xr-xmuggle-plugin/mugglei.c40
1 files changed, 31 insertions, 9 deletions
diff --git a/muggle-plugin/mugglei.c b/muggle-plugin/mugglei.c
index 4d8477b..21aa90e 100755
--- a/muggle-plugin/mugglei.c
+++ b/muggle-plugin/mugglei.c
@@ -12,9 +12,7 @@ using namespace std;
#include <stdio.h>
#include <sys/stat.h>
#include <sys/time.h>
-
#include <mysql/mysql.h>
-
#include <getopt.h>
#include <tag.h>
@@ -24,21 +22,38 @@ using namespace std;
MYSQL *db;
-string host, user, pass, dbname;
+string host, user, pass, dbname, socket;
bool import_assorted;
int init_database()
{
- db = mysql_init(NULL);
+ db = mysql_init(0); // NULL?
+
if( db == NULL )
{
+ cout << "mysql_init failed." << endl;
return -1;
}
-
- if( mysql_real_connect( db, host.c_str(), user.c_str(), pass.c_str(), dbname.c_str(),
- 0, NULL, 0 ) == NULL )
+
+ // check for use of sockets
+ if( socket != "" )
+ {
+ if( mysql_real_connect( db, NULL, user.c_str(), pass.c_str(), dbname.c_str(),
+ 0, socket.c_str(), 0 ) == NULL )
+
+ {
+ cout << "mysql_real_connect using sockets failed." << endl;
+ return -2;
+ }
+ }
+ else
{
- return -2;
+ if( mysql_real_connect( db, host.c_str(), user.c_str(), pass.c_str(), dbname.c_str(),
+ 0, NULL, 0 ) == NULL )
+ {
+ cout << "mysql_real_connect via TCP failed." << endl;
+ return -2;
+ }
}
return 0;
@@ -288,6 +303,7 @@ int main( int argc, char *argv[] )
cout << "" << endl;
cout << "Options:" << endl;
cout << " -h <hostname> - specify host of mySql database server (default is 'localhost')" << endl;
+ cout << " -s <socket> - specify a socket for mySQL communication (default is TCP)" << endl;
cout << " -n <database> - specify database name (default is 'GiantDisc')" << endl;
cout << " -u <username> - specify user of mySql database (default is empty)" << endl;
cout << " -p <password> - specify password of user (default is empty password)" << endl;
@@ -302,12 +318,13 @@ int main( int argc, char *argv[] )
dbname = "GiantDisc";
user = "";
pass = "";
+ socket = "";
import_assorted = false;
// parse command line options
while( 1 )
{
- int c = getopt(argc, argv, "h:u:p:n:af:");
+ int c = getopt(argc, argv, "h:u:p:n:af:s:");
if (c == -1)
break;
@@ -342,6 +359,10 @@ int main( int argc, char *argv[] )
{
filename = optarg;
} break;
+ case 's':
+ {
+ socket = optarg;
+ } break;
}
}
@@ -353,6 +374,7 @@ int main( int argc, char *argv[] )
int res = init_database();
+
if( !res )
{
update_db( 0, filename );