From df8e71908273ec2bb645ef96d0b76775d1d6a164 Mon Sep 17 00:00:00 2001 From: wr61 Date: Sun, 22 Jan 2006 00:42:57 +0000 Subject: better error messages for mugglei when called incorrectly put myself into the copyright message of mugglei git-svn-id: https://vdr-muggle.svn.sourceforge.net/svnroot/vdr-muggle/trunk/muggle-plugin@911 e10066b5-e1e2-0310-b819-94efdf66514b --- mg_setup.c | 2 ++ mugglei.c | 37 ++++++++++++++++++++----------------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/mg_setup.c b/mg_setup.c index ffc5c83..a86f953 100644 --- a/mg_setup.c +++ b/mg_setup.c @@ -215,6 +215,8 @@ bool mgSetup::ProcessArguments (int argc, char *argv[]) CreateMode = true; } break; + case '?': + return false; } } return true; diff --git a/mugglei.c b/mugglei.c index 1e3d059..8df672d 100644 --- a/mugglei.c +++ b/mugglei.c @@ -80,15 +80,12 @@ path_within_tld() return !strncmp(path,the_setup.ToplevelDir,tldlen); } -int main( int argc, char *argv[] ) + +static void +usage() { - the_setup.SetMugglei(); - mgSetDebugLevel(1); - - if( argc < 2 ) - { // we need at least a filename! std::cout << "mugglei -- import helper for Muggle VDR plugin" << std::endl; - std::cout << "(C) Lars von Wedel" << std::endl; + std::cout << "(C) Lars von Wedel, Wolfgang Rohdewald" << std::endl; std::cout << "This is free software; see the source for copying conditions." << std::endl; std::cout << "" << std::endl; std::cout << "Usage: mugglei [OPTION]... [FILE]..." << std::endl; @@ -101,9 +98,18 @@ int main( int argc, char *argv[] ) std::cout << the_setup.HelpText(); exit( 2 ); - } +} + +int main( int argc, char *argv[] ) +{ + the_setup.SetMugglei(); + mgSetDebugLevel(1); + + if( argc < 2 ) + usage(); - the_setup.ProcessArguments(argc,argv); + if (!the_setup.ProcessArguments(argc,argv)) + usage(); if (!path_within_tld()) { @@ -111,13 +117,10 @@ int main( int argc, char *argv[] ) << " or below" << std::endl; exit( 2 ); } - if (optindSync(argv+optind); - delete sync; - delete DbServer; - } - return 0; + if (optind==argc) + usage(); + mgDb *sync = GenerateDB(); + sync->Sync(argv+optind); + delete sync; } -- cgit v1.2.3