summaryrefslogtreecommitdiff
path: root/muggle-plugin/muggle.c
diff options
context:
space:
mode:
authorlvw <lvw@e10066b5-e1e2-0310-b819-94efdf66514b>2004-09-12 22:35:18 +0000
committerlvw <lvw@e10066b5-e1e2-0310-b819-94efdf66514b>2004-09-12 22:35:18 +0000
commit55b857e38b7b03dd4d20a95f4530daa32aa86820 (patch)
treece0d9010d525cb08db9994aa2f9f6aed34001cf4 /muggle-plugin/muggle.c
parentcd91dbfedcbd7d293b8e5333f92b12669bfc9fb7 (diff)
downloadvdr-plugin-muggle-55b857e38b7b03dd4d20a95f4530daa32aa86820.tar.gz
vdr-plugin-muggle-55b857e38b7b03dd4d20a95f4530daa32aa86820.tar.bz2
Integrated patch from eloy for command line option handling
git-svn-id: https://vdr-muggle.svn.sourceforge.net/svnroot/vdr-muggle/trunk@161 e10066b5-e1e2-0310-b819-94efdf66514b
Diffstat (limited to 'muggle-plugin/muggle.c')
-rw-r--r--muggle-plugin/muggle.c87
1 files changed, 46 insertions, 41 deletions
diff --git a/muggle-plugin/muggle.c b/muggle-plugin/muggle.c
index a9b6c75..ecb1824 100644
--- a/muggle-plugin/muggle.c
+++ b/muggle-plugin/muggle.c
@@ -48,13 +48,13 @@ const char* mgMuggle::MainMenuEntry(void)
mgMuggle::mgMuggle(void)
{
// defaults for database arguments
- the_setup.DbHost = "localhost";
+ the_setup.DbHost = strdup ("localhost");
the_setup.DbPort = 0;
- the_setup.DbName = "GiantDisc";
- the_setup.DbUser = "";
- the_setup.DbPass = "" ;
+ the_setup.DbName = strdup ("GiantDisc");
+ the_setup.DbUser = strdup ("");
+ the_setup.DbPass = strdup ("");
the_setup.GdCompatibility = false;
- the_setup.ToplevelDir = "/mnt/music/";
+ the_setup.ToplevelDir = strdup ("/mnt/music/");
}
mgMuggle::~mgMuggle()
@@ -93,46 +93,51 @@ bool mgMuggle::ProcessArgs(int argc, char *argv[])
};
int c, option_index = 0;
- while( ( c = getopt_long( argc, argv, "h:p:u:n:t:w:g:", long_options, &option_index ) ) != -1 )
- {
- switch (c)
- {
- case 'h':
- {
- the_setup.DbHost = optarg;
- } break;
- case 'n':
- {
- the_setup.DbName = optarg;
- } break;
- case 'p':
- {
- the_setup.DbPort = atoi( optarg );
- } break;
- case 'u':
- {
- the_setup.DbUser = optarg;
+ while( ( c = getopt_long( argc, argv, "gh:n:p:t:u:w:", long_options, &option_index ) ) != -1 )
+ {
+ switch (c)
+ {
+ case 'h':
+ {
+ the_setup.DbHost = strcpyrealloc (the_setup.DbHost, optarg);
+ } break;
+ case 'n':
+ {
+ the_setup.DbName = strcpyrealloc (the_setup.DbName, optarg);
} break;
- case 'w':
- {
- the_setup.DbPass = optarg;
- } break;
- case 't':
- {
- string res = string(optarg) + "/";
- the_setup.ToplevelDir = strdup( res.c_str() );
- } break;
- case 'g':
- {
- the_setup.DbName = "GiantDisc";
- the_setup.GdCompatibility = true;
- } break;
- default: return false;
+ case 'p':
+ {
+ the_setup.DbPort = atoi( optarg );
+ } break;
+ case 'u':
+ {
+ the_setup.DbUser = strcpyrealloc (the_setup.DbUser, optarg);
+ } break;
+ case 'w':
+ {
+ the_setup.DbPass = strcpyrealloc (the_setup.DbPass, optarg);
+ } break;
+ case 't':
+ {
+ if (optarg[strlen(optarg) - 1] != '/')
+ {
+ string res = string(optarg) + "/";
+ the_setup.ToplevelDir = strdup( res.c_str() );
+ }
+ else
+ {
+ the_setup.ToplevelDir = strcpyrealloc (the_setup.ToplevelDir, optarg);
+ }
+ } break;
+ case 'g':
+ {
+ the_setup.DbName = strcpyrealloc (the_setup.DbName, "GiantDisc");
+ the_setup.GdCompatibility = true;
+ } break;
+ default: return false;
}
}
- // check for GD compatibility and override
-
return true;
}