wmusic: Drop "-1.0" from playerctl pkg-config check.
[dockapps.git] / wmmemfree / options.c
blob1c41d5ff7804a4e2d72d2efd27d2d1efcce7970c
1 /*
2 * options.c - option parser
4 * Copyright (C) 2003 Draghicioiu Mihai <misuceldestept@go.ro>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
25 #include "wmmemfree.h"
26 #include "options.h"
28 char *opt_display = OPT_DISPLAY;
29 int opt_buffers = OPT_BUFFERS;
30 int opt_cache = OPT_CACHE;
31 int opt_window = OPT_WINDOW;
32 int opt_shape = OPT_SHAPE;
33 int opt_milisecs = OPT_MILISECS;
35 void print_usage()
37 printf("Usage: %s [OPTIONS]\n"
38 "-h, --help print this help and exit\n"
39 "-v, --version print version number and exit\n"
40 "-display <DISPLAY> specify the X11 display to connect to\n"
41 "-m, --milisecs <MILISECS> number of miliseconds between updates\n"
42 "-b, --buffers consider buffer memory\n"
43 "-nb, --no-buffers ignore buffer memory\n"
44 "-c, --cache consider cache memory\n"
45 "-nc, --no-cache ignore cache memory\n"
46 "-w, --window run in a window\n"
47 "-nw, --no-window don't run in a window\n"
48 "-s, --shape use the XShape extension\n"
49 "-ns, --no-shape don't use XShape extension\n",
50 argv[0]);
53 void print_version()
55 printf("WMMemFree version " OPT_VERSION "\n");
58 void parse_args()
60 int n;
62 for(n=1;n<argc;n++)
64 if(!strcmp(argv[n], "-h") ||
65 !strcmp(argv[n], "--help"))
67 print_usage();
68 exit(0);
70 else if(!strcmp(argv[n], "-v") ||
71 !strcmp(argv[n], "--version"))
73 print_version();
74 exit(0);
76 else if(!strcmp(argv[n], "-display"))
78 if(argc <= (++n))
80 print_usage();
81 exit(1);
83 else opt_display = argv[n];
85 else if(!strcmp(argv[n], "-m") ||
86 !strcmp(argv[n], "--milisecs"))
88 if(argc <= (++n))
90 print_usage();
91 exit(1);
93 else
94 opt_milisecs = atoi(argv[n]);
96 else if(!strcmp(argv[n], "-b") ||
97 !strcmp(argv[n], "--buffers"))
98 opt_buffers = 1;
99 else if(!strcmp(argv[n], "-nb") ||
100 !strcmp(argv[n], "--no-buffers"))
101 opt_buffers = 0;
102 else if(!strcmp(argv[n], "-c") ||
103 !strcmp(argv[n], "--cache"))
104 opt_cache = 1;
105 else if(!strcmp(argv[n], "-nc") ||
106 !strcmp(argv[n], "--no-cache"))
107 opt_cache = 0;
108 else if(!strcmp(argv[n], "-w") ||
109 !strcmp(argv[n], "--window"))
110 opt_window = 1;
111 else if(!strcmp(argv[n], "-nw") ||
112 !strcmp(argv[n], "--no-window"))
113 opt_window = 0;
114 else if(!strcmp(argv[n], "-s") ||
115 !strcmp(argv[n], "--shape"))
116 opt_shape = 1;
117 else if(!strcmp(argv[n], "-ns") ||
118 !strcmp(argv[n], "--no-shape"))
119 opt_shape = 0;
120 else
122 print_usage();
123 exit(1);