diff options
author | NRK <nrk@disroot.org> | 2024-06-20 12:50:19 +0200 |
---|---|---|
committer | NRK <nrk@disroot.org> | 2024-06-20 12:50:19 +0200 |
commit | 0620d473c2df34d02137fb22c23fb0f166b0e1a1 (patch) | |
tree | a20656575eb726cc62d9736a28f78d6ce581a39f /options.c | |
parent | 9b8cdcff482a518c24d31ce74524543bb7015102 (diff) | |
download | nsxiv-0620d473c2df34d02137fb22c23fb0f166b0e1a1.tar.zst |
allow {white,black}listing thumbnail cache dirs (#461)
this adds the cli flags --cache-{allow,deny} along with
corresponding config.h vars which allows the user to control
which directories will have thumbnail cache written.
this is a more general version of the `cache-whitelist` patch
that existed in the nsxiv-extra repo:
https://codeberg.org/nsxiv/nsxiv-extra/src/commit/21cb27cee7/patches/cache-whitelist
Closes: https://codeberg.org/nsxiv/nsxiv/issues/454
Diffstat (limited to 'options.c')
-rw-r--r-- | options.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -75,7 +75,9 @@ void parse_options(int argc, char **argv) OPT_START = UCHAR_MAX, OPT_AA, OPT_AL, - OPT_BG + OPT_BG, + OPT_CA, + OPT_CD }; static const struct optparse_long longopts[] = { { "framerate", 'A', OPTPARSE_REQUIRED }, @@ -105,6 +107,8 @@ void parse_options(int argc, char **argv) { "alpha-layer", OPT_AL, OPTPARSE_OPTIONAL }, /* TODO: document this when it's stable */ { "bg-cache", OPT_BG, OPTPARSE_OPTIONAL }, + { "cache-allow", OPT_CA, OPTPARSE_REQUIRED }, + { "cache-deny", OPT_CD, OPTPARSE_REQUIRED }, { 0 }, /* end */ }; @@ -137,6 +141,8 @@ void parse_options(int argc, char **argv) _options.geometry = NULL; _options.res_name = NULL; + _options.tns_filters = TNS_FILTERS; + _options.tns_filters_is_blacklist = TNS_FILTERS_IS_BLACKLIST; _options.quiet = false; _options.thumb_mode = false; _options.clean_cache = false; @@ -266,6 +272,10 @@ void parse_options(int argc, char **argv) error(EXIT_FAILURE, 0, "Invalid argument for option --bg-cache: %s", op.optarg); _options.background_cache = op.optarg == NULL; break; + case OPT_CA: case OPT_CD: + _options.tns_filters = op.optarg; + _options.tns_filters_is_blacklist = (opt == OPT_CD); + break; } } |