2 * Copyright Geoff Levand <geoff@infradead.org>
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; version 2 of the License.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 #if defined(HAVE_CONFIG_H)
28 void pbt_print_version(void)
30 printf("pb-twin (" PACKAGE_NAME ") " PACKAGE_VERSION "\n");
33 void pbt_print_usage(void)
37 "Usage: pb-twin [-h, --help] [-l, --log log-file] [-r, --reset-defaults]\n"
38 " [-t, --timeout] [-V, --version] [[-f --fbdev] | [-x --x11]]\n");
42 * pbt_opts_parse - Parse the command line options.
45 int pbt_opts_parse(struct pbt_opts *opts, int argc, char *argv[])
47 static const struct option long_options[] = {
48 {"fbdev", no_argument, NULL, 'f'},
49 {"help", no_argument, NULL, 'h'},
50 {"log", required_argument, NULL, 'l'},
51 {"reset-defaults", no_argument, NULL, 'r'},
52 {"timeout", no_argument, NULL, 't'},
53 {"version", no_argument, NULL, 'V'},
54 {"x11", no_argument, NULL, 'x'},
57 static const char short_options[] = "fhl:trVx";
58 static const struct pbt_opts default_values = {
59 .backend = pbt_twin_x11,
60 .log_file = "pb-twin.log",
63 *opts = default_values;
66 int c = getopt_long(argc, argv, short_options, long_options,
74 opts->backend = pbt_twin_fbdev;
77 opts->show_help = pbt_opt_yes;
80 opts->log_file = optarg;
83 opts->use_timeout = pbt_opt_yes;
86 opts->reset_defaults = pbt_opt_yes;
89 opts->show_version = pbt_opt_yes;
92 opts->backend = pbt_twin_x11;
95 opts->show_help = pbt_opt_yes;
100 return optind != argc;