diff options
author | enselic <enselic@f606c939-3180-4ac9-a4b8-4b8779d57d0a> | 2009-01-11 11:54:29 +0000 |
---|---|---|
committer | enselic <enselic@f606c939-3180-4ac9-a4b8-4b8779d57d0a> | 2009-01-11 11:54:29 +0000 |
commit | 96a406000111f766b67c05d18b41def8efdaafdc (patch) | |
tree | 25f38f4f1b9b91f3324f7c07b82bdd3d93dbf560 /recordmydesktop | |
parent | b7fa18f12d81005e19b8e11e34db65369741c1bb (diff) |
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
Diffstat (limited to 'recordmydesktop')
-rw-r--r-- | recordmydesktop/src/rmd_parseargs.c | 47 |
1 files 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); |