aboutsummaryrefslogtreecommitdiffstats
path: root/options.c
diff options
context:
space:
mode:
authorBert Münnich <ber.t@posteo.de>2014-02-04 23:05:29 +0100
committerBert Münnich <ber.t@posteo.de>2014-02-04 23:05:29 +0100
commit997c8518c5884fecf03fb3d677dbc6d80d11c9df (patch)
tree18d841eb7868d3524f7e870b7138858c40651eef /options.c
parent43a04c4757f4a20c3b9b1487ea7894c0f3e73708 (diff)
downloadnsxiv-997c8518c5884fecf03fb3d677dbc6d80d11c9df.tar.zst
Set scale mode at startup via argument to -s option
Diffstat (limited to 'options.c')
-rw-r--r--options.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/options.c b/options.c
index c074677..bf993e3 100644
--- a/options.c
+++ b/options.c
@@ -33,8 +33,8 @@ const options_t *options = (const options_t*) &_options;
void print_usage(void)
{
- printf("usage: sxiv [-bcFfhioqrstvZ] [-G GAMMA] [-g GEOMETRY] [-n NUM] "
- "[-N NAME] [-S DELAY] [-z ZOOM] FILES...\n");
+ printf("usage: sxiv [-bcFfhioqrtvZ] [-G GAMMA] [-g GEOMETRY] [-n NUM] "
+ "[-N NAME] [-S DELAY] [-s MODE] [-z ZOOM] FILES...\n");
}
void print_version(void)
@@ -45,7 +45,8 @@ void print_version(void)
void parse_options(int argc, char **argv)
{
int n, opt;
- char *end;
+ char *end, *s;
+ const char *scalemodes = "dfwh";
_options.from_stdin = false;
_options.to_stdout = false;
@@ -67,7 +68,7 @@ void parse_options(int argc, char **argv)
_options.thumb_mode = false;
_options.clean_cache = false;
- while ((opt = getopt(argc, argv, "bcFfG:g:hin:N:oqrS:stvZz:")) != -1) {
+ while ((opt = getopt(argc, argv, "bcFfG:g:hin:N:oqrS:s:tvZz:")) != -1) {
switch (opt) {
case '?':
print_usage();
@@ -130,7 +131,12 @@ void parse_options(int argc, char **argv)
_options.slideshow = n;
break;
case 's':
- _options.scalemode = SCALE_FIT;
+ s = strchr(scalemodes, optarg[0]);
+ if (s == NULL || *s == '\0' || strlen(optarg) != 1) {
+ fprintf(stderr, "sxiv: invalid argument for option -s: %s\n", optarg);
+ exit(EXIT_FAILURE);
+ }
+ _options.scalemode = s - scalemodes;
break;
case 't':
_options.thumb_mode = true;