Code

src/fb.c: Use FB_VERSION… rather than VERSION.
[template.git] / src / fb.c
1 /*
2  * foobar - src/fb.c
3  * Copyright (C) 2010 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  *OR:
18  * All rights reserved.
19  *
20  * Redistribution and use in source and binary forms, with or without
21  * modification, are permitted provided that the following conditions
22  * are met:
23  * 1. Redistributions of source code must retain the above copyright
24  *    notice, this list of conditions and the following disclaimer.
25  * 2. Redistributions in binary form must reproduce the above copyright
26  *    notice, this list of conditions and the following disclaimer in the
27  *    documentation and/or other materials provided with the distribution.
28  *
29  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
31  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
32  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
33  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
34  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
35  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
36  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
37  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
38  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
39  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40  */
42 /*
43  * A short description of this module...
44  */
46 #if HAVE_CONFIG_H
47 #       include "config.h"
48 #endif /* HAVE_CONFIG_H */
50 #include "foobar.h"
51 #include "fb_features.h"
53 #if HAVE_LIBGEN_H
54 #       include <libgen.h>
55 #else /* HAVE_LIBGEN_H */
56 #       define basename(path) (path)
57 #endif /* ! HAVE_LIBGEN_H */
59 #include <stdio.h>
60 #include <stdlib.h>
62 #include <unistd.h>
64 static void
65 exit_usage(char *name, int status)
66 {
67         printf(
68 "Usage: %s <options>\n"
70 "\nOptions:\n"
71 "  -h    display this help and exit\n"
72 "  -V    display the version number and copyright\n"
74 "\nfb "FB_VERSION_STRING FB_VERSION_EXTRA", http://tokkee.org\n",
75 basename(name));
76         exit(status);
77 } /* exit_usage */
79 static void
80 exit_version(void)
81 {
82         printf("fb version "FB_VERSION_STRING FB_VERSION_EXTRA", "
83                         "built "BUILD_DATE"\n"
84                         "Copyright (C) 2010 Sebastian Harl <sh@tokkee.org>\n"
86                         "\nThis is free software under the terms of the GNU GPLv2; see "
87 /* OR: */
88                         "\nThis is free software under the terms of the BSD license, see "
89                         "the source for\ncopying conditions. There is NO WARRANTY; not "
90                         "even for MERCHANTABILITY or\nFITNESS FOR A PARTICULAR "
91                         "PURPOSE.\n");
92         exit(0);
93 } /* exit_version */
95 int
96 main(int argc, char **argv)
97 {
98         while (42) {
99                 int opt = getopt(argc, argv, "hV");
101                 if (-1 == opt)
102                         break;
104                 switch (opt) {
105                         case 'h':
106                                 exit_usage(argv[0], 0);
107                                 break;
108                         case 'V':
109                                 exit_version();
110                                 break;
111                         default:
112                                 exit_usage(argv[0], 1);
113                 }
114         }
116         if (optind < argc)
117                 exit_usage(argv[0], 1);
118         return 0;
119 } /* main */
121 /* vim: set tw=78 sw=4 ts=4 noexpandtab : */