From 96a406000111f766b67c05d18b41def8efdaafdc Mon Sep 17 00:00:00 2001 From: enselic Date: Sun, 11 Jan 2009 11:54:29 +0000 Subject: src/rmd_parseargs.c: Stop parsing on error and report the error. git-svn-id: https://recordmydesktop.svn.sourceforge.net/svnroot/recordmydesktop/trunk@596 f606c939-3180-4ac9-a4b8-4b8779d57d0a --- recordmydesktop/src/rmd_parseargs.c | 47 ++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/recordmydesktop/src/rmd_parseargs.c b/recordmydesktop/src/rmd_parseargs.c index 7eba70f..384ef37 100644 --- a/recordmydesktop/src/rmd_parseargs.c +++ b/recordmydesktop/src/rmd_parseargs.c @@ -383,22 +383,47 @@ boolean rmdParseArgs(int argc, char **argv, ProgArgs *arg_return) { } } - // Parsing is complete, perform final adjustments - if (no_cursor) - arg_return->xfixes_cursor = FALSE; + if (arg_id == -1) { + // Parsing is complete, perform final adjustments + if (no_cursor) + arg_return->xfixes_cursor = FALSE; - if (quick_subsampling) - arg_return->no_quick_subsample = FALSE; + if (quick_subsampling) + arg_return->no_quick_subsample = FALSE; - if (compress_cache) - arg_return->zerocompression = FALSE; + if (compress_cache) + arg_return->zerocompression = FALSE; - if (arg_return->follow_mouse) - arg_return->full_shots = TRUE; + if (arg_return->follow_mouse) + arg_return->full_shots = TRUE; - if (!arg_return->filename) - arg_return->filename = strdup(poptGetArg(popt_context)); + if (!arg_return->filename) + arg_return->filename = strdup(poptGetArg(popt_context)); + } + else { + // Parsing error, say what went wrong + const char *str = poptBadOption(popt_context, 0); + + success = FALSE; + fprintf(stderr, + "Error when parsing `%s': ", str); + + switch (arg_id) { + case POPT_ERROR_NOARG: + fprintf(stderr, "Missing argument\n"); + break; + + case POPT_ERROR_BADNUMBER: + fprintf(stderr, "Bad number\n"); + break; + + default: + fprintf(stderr, "libpopt error: %d\n", arg_id); + break; + } + } + // Make sure argument ranges are valid success = success && rmdValidateArguments(arg_return); -- cgit v1.2.1