523b57c6cd8f76ea926e05744b0c2d3e11249ded
1 /*
2 * foobar - src/foobar.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 #if HAVE_LIBGEN_H
28 # include <libgen.h>
29 #else /* HAVE_LIBGEN_H */
30 # define basename(path) (path)
31 #endif /* ! HAVE_LIBGEN_H */
33 #include <stdio.h>
34 #include <stdlib.h>
36 #include <unistd.h>
38 void exit_usage(char *name, int status)
39 {
40 printf("Usage: %s <options>\n"
42 "\nOptions:\n"
43 " -h display this help and exit\n"
44 " -V display the version number and copyright\n"
46 "\nfoobar "VERSION", http://tokkee.org\n", basename(name));
47 exit(status);
48 } /* exit_usage */
50 void exit_version(void)
51 {
52 printf("foobar version "VERSION", built "BUILD_DATE"\n"
53 "Copyright (C) 2008 Sebastian Harl <sh@tokkee.org>\n"
55 "\nThis is free software under the terms of the GNU GPLv2; see "
56 "the source for\ncopying conditions. There is NO WARRANTY; not "
57 "even for MERCHANTABILITY or\nFITNESS FOR A PARTICULAR "
58 "PURPOSE.\n");
59 exit(0);
60 } /* exit_version */
62 int main(int argc, char **argv)
63 {
64 while (42) {
65 int opt = getopt(argc, argv, "hV");
67 if (-1 == opt)
68 break;
70 switch (opt) {
71 case 'h':
72 exit_usage(argv[0], 0);
73 break;
74 case 'V':
75 exit_version();
76 break;
77 default:
78 exit_usage(argv[0], 1);
79 }
80 }
82 if (optind < argc)
83 exit_usage(argv[0], 1);
84 return 0;
85 } /* main */
87 /* vim: set tw=78 sw=4 ts=4 noexpandtab : */