summaryrefslogtreecommitdiffstats
path: root/options.c
diff options
context:
space:
mode:
authorBert <ber.t@gmx.com>2011-05-25 09:23:23 +0200
committerBert <ber.t@gmx.com>2011-05-25 09:23:23 +0200
commit2252a0148d11fc988131eb0bf6397453427d67e8 (patch)
tree7cb4e226e2405b420876709e033a8bcdffa8777c /options.c
parent00e6cd2bd1a7bfc0b9fcbf958cefee07ef41cb71 (diff)
downloadnsxiv-2252a0148d11fc988131eb0bf6397453427d67e8.tar.zst
New option: -n, start at given picture
Diffstat (limited to 'options.c')
-rw-r--r--options.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/options.c b/options.c
index 0644363..b2b3a14 100644
--- a/options.c
+++ b/options.c
@@ -31,7 +31,7 @@ options_t _options;
const options_t *options = (const options_t*) &_options;
void print_usage() {
- printf("usage: sxiv [-cdFfhpqrstvZ] [-g GEOMETRY] [-z ZOOM] FILES...\n");
+ printf("usage: sxiv [-cdFfhpqrstvZ] [-g GEOMETRY] [-n NUM] [-z ZOOM] FILES...\n");
}
void print_version() {
@@ -40,7 +40,9 @@ void print_version() {
void parse_options(int argc, char **argv) {
float z;
- int opt;
+ int n, opt;
+
+ _options.startnum = 0;
_options.scalemode = SCALE_MODE;
_options.zoom = 1.0;
@@ -55,7 +57,7 @@ void parse_options(int argc, char **argv) {
_options.clean_cache = 0;
_options.recursive = 0;
- while ((opt = getopt(argc, argv, "cdFfg:hpqrstvZz:")) != -1) {
+ while ((opt = getopt(argc, argv, "cdFfg:hn:pqrstvZz:")) != -1) {
switch (opt) {
case '?':
print_usage();
@@ -78,6 +80,15 @@ void parse_options(int argc, char **argv) {
case 'h':
print_usage();
exit(0);
+ case 'n':
+ if (!sscanf(optarg, "%d", &n) || n < 1) {
+ fprintf(stderr, "sxiv: invalid argument for option -n: %s\n",
+ optarg);
+ exit(1);
+ } else {
+ _options.startnum = n - 1;
+ }
+ break;
case 'p':
_options.aa = 0;
break;