1 /*
2 * foobar - src/fb.c
3 * Copyright (C) 2009 Sebastian Harl <sh@tokkee.org>
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; only version 2 of the License is applicable.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
19 /*
20 * A short description of this module...
21 */
23 #if HAVE_CONFIG_H
24 # include "config.h"
25 #endif /* HAVE_CONFIG_H */
27 #include "foobar.h"
29 #if HAVE_LIBGEN_H
30 # include <libgen.h>
31 #else /* HAVE_LIBGEN_H */
32 # define basename(path) (path)
33 #endif /* ! HAVE_LIBGEN_H */
35 #include <stdio.h>
36 #include <stdlib.h>
38 #include <unistd.h>
40 static void
41 exit_usage(char *name, int status)
42 {
43 printf(
44 "Usage: %s <options>\n"
46 "\nOptions:\n"
47 " -h display this help and exit\n"
48 " -V display the version number and copyright\n"
50 "\nfb "VERSION", http://tokkee.org\n", basename(name));
51 exit(status);
52 } /* exit_usage */
54 static void
55 exit_version(void)
56 {
57 printf("fb version "VERSION", built "BUILD_DATE"\n"
58 "Copyright (C) 2009 Sebastian Harl <sh@tokkee.org>\n"
60 "\nThis is free software under the terms of the GNU GPLv2; see "
61 "the source for\ncopying conditions. There is NO WARRANTY; not "
62 "even for MERCHANTABILITY or\nFITNESS FOR A PARTICULAR "
63 "PURPOSE.\n");
64 exit(0);
65 } /* exit_version */
67 int
68 main(int argc, char **argv)
69 {
70 while (42) {
71 int opt = getopt(argc, argv, "hV");
73 if (-1 == opt)
74 break;
76 switch (opt) {
77 case 'h':
78 exit_usage(argv[0], 0);
79 break;
80 case 'V':
81 exit_version();
82 break;
83 default:
84 exit_usage(argv[0], 1);
85 }
86 }
88 if (optind < argc)
89 exit_usage(argv[0], 1);
90 return 0;
91 } /* main */
93 /* vim: set tw=78 sw=4 ts=4 noexpandtab : */