1 /*
2 * foobar - src/fb.c
3 * Copyright (C) 2008 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("Usage: %s <options>\n"
45 "\nOptions:\n"
46 " -h display this help and exit\n"
47 " -V display the version number and copyright\n"
49 "\nfb "VERSION", http://tokkee.org\n", basename(name));
50 exit(status);
51 } /* exit_usage */
53 static void
54 exit_version(void)
55 {
56 printf("fb version "VERSION", built "BUILD_DATE"\n"
57 "Copyright (C) 2008 Sebastian Harl <sh@tokkee.org>\n"
59 "\nThis is free software under the terms of the GNU GPLv2; see "
60 "the source for\ncopying conditions. There is NO WARRANTY; not "
61 "even for MERCHANTABILITY or\nFITNESS FOR A PARTICULAR "
62 "PURPOSE.\n");
63 exit(0);
64 } /* exit_version */
66 int
67 main(int argc, char **argv)
68 {
69 while (42) {
70 int opt = getopt(argc, argv, "hV");
72 if (-1 == opt)
73 break;
75 switch (opt) {
76 case 'h':
77 exit_usage(argv[0], 0);
78 break;
79 case 'V':
80 exit_version();
81 break;
82 default:
83 exit_usage(argv[0], 1);
84 }
85 }
87 if (optind < argc)
88 exit_usage(argv[0], 1);
89 return 0;
90 } /* main */
92 /* vim: set tw=78 sw=4 ts=4 noexpandtab : */