diff options
Diffstat (limited to 'Utilities/cmlibarchive/libarchive/archive_options.c')
-rw-r--r-- | Utilities/cmlibarchive/libarchive/archive_options.c | 53 |
1 files changed, 50 insertions, 3 deletions
diff --git a/Utilities/cmlibarchive/libarchive/archive_options.c b/Utilities/cmlibarchive/libarchive/archive_options.c index 79b4ffb..220ebd4 100644 --- a/Utilities/cmlibarchive/libarchive/archive_options.c +++ b/Utilities/cmlibarchive/libarchive/archive_options.c @@ -38,6 +38,7 @@ _archive_set_option(struct archive *a, int magic, const char *fn, option_handler use_option) { const char *mp, *op, *vp; + int r; archive_check_magic(a, magic, ARCHIVE_STATE_NEW, fn); @@ -47,10 +48,24 @@ _archive_set_option(struct archive *a, if (op == NULL && vp == NULL) return (ARCHIVE_OK); - if (op == NULL) + if (op == NULL) { + archive_set_error(a, ARCHIVE_ERRNO_MISC, "Empty option"); return (ARCHIVE_FAILED); + } - return use_option(a, mp, op, vp); + r = use_option(a, mp, op, vp); + if (r == ARCHIVE_WARN - 1) { + archive_set_error(a, ARCHIVE_ERRNO_MISC, + "Unknown module name: `%s'", mp); + return (ARCHIVE_FAILED); + } + if (r == ARCHIVE_WARN) { + archive_set_error(a, ARCHIVE_ERRNO_MISC, + "Undefined option: `%s%s%s%s%s%s'", + vp?"":"!", mp?mp:"", mp?":":"", op, vp?"=":"", vp?vp:""); + return (ARCHIVE_FAILED); + } + return (r); } int @@ -72,6 +87,8 @@ _archive_set_either_option(struct archive *a, const char *m, const char *o, cons if (r2 == ARCHIVE_FATAL) return (ARCHIVE_FATAL); + if (r2 == ARCHIVE_WARN - 1) + return r1; return r1 > r2 ? r1 : r2; } @@ -79,7 +96,7 @@ int _archive_set_options(struct archive *a, const char *options, int magic, const char *fn, option_handler use_option) { - int allok = 1, anyok = 0, r; + int allok = 1, anyok = 0, ignore_mod_err = 0, r; char *data; const char *s, *mod, *opt, *val; @@ -96,12 +113,42 @@ _archive_set_options(struct archive *a, const char *options, mod = opt = val = NULL; parse_option(&s, &mod, &opt, &val); + if (mod == NULL && opt != NULL && + strcmp("__ignore_wrong_module_name__", opt) == 0) { + /* Ignore module name error */ + if (val != NULL) { + ignore_mod_err = 1; + anyok = 1; + } + continue; + } r = use_option(a, mod, opt, val); if (r == ARCHIVE_FATAL) { free(data); return (ARCHIVE_FATAL); } + if (r == ARCHIVE_FAILED && mod != NULL) { + free(data); + return (ARCHIVE_FAILED); + } + if (r == ARCHIVE_WARN - 1) { + if (ignore_mod_err) + continue; + /* The module name is wrong. */ + archive_set_error(a, ARCHIVE_ERRNO_MISC, + "Unknown module name: `%s'", mod); + free(data); + return (ARCHIVE_FAILED); + } + if (r == ARCHIVE_WARN) { + /* The option name is wrong. No-one used this. */ + archive_set_error(a, ARCHIVE_ERRNO_MISC, + "Undefined option: `%s%s%s'", + mod?mod:"", mod?":":"", opt); + free(data); + return (ARCHIVE_FAILED); + } if (r == ARCHIVE_OK) anyok = 1; else |