Krolyxon
Commit fdf24d4

Branches

Refs →

nsxivoptions.c

59 lines · 1.5 KB · C

1/* sxiv: options.c
2 * Copyright (c) 2011 Bert Muennich <muennich at informatik.hu-berlin.de>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19#define _XOPEN_SOURCE
20
21#include <stdlib.h>
22#include <stdio.h>
23#include <unistd.h>
24
25#include "sxiv.h"
26#include "options.h"
27
28options_t _options;
29const options_t *options = (const options_t*) &_options;
30
31void print_usage() {
32 printf("usage: sxiv [-hv] FILES...\n");
33}
34
35void print_version() {
36 printf("sxiv - simple x image viewer\n");
37 printf("Version %s, written by Bert Muennich\n", VERSION);
38}
39
40void parse_options(int argc, char **argv) {
41 int opt;
42
43 while ((opt = getopt(argc, argv, "hv")) != -1) {
44 switch (opt) {
45 case '?':
46 print_usage();
47 exit(1);
48 case 'h':
49 print_usage();
50 exit(0);
51 case 'v':
52 print_version();
53 exit(0);
54 }
55 }
56
57 _options.filenames = (const char**) argv + optind;
58 _options.filecnt = argc - optind;
59}