Code

Updated templates for GPLv2 OR 2-clause BSD license.
[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"
52 #if HAVE_LIBGEN_H
53 #       include <libgen.h>
54 #else /* HAVE_LIBGEN_H */
55 #       define basename(path) (path)
56 #endif /* ! HAVE_LIBGEN_H */
58 #include <stdio.h>
59 #include <stdlib.h>
61 #include <unistd.h>
63 static void
64 exit_usage(char *name, int status)
65 {
66         printf(
67 "Usage: %s <options>\n"
69 "\nOptions:\n"
70 "  -h    display this help and exit\n"
71 "  -V    display the version number and copyright\n"
73 "\nfb "VERSION", http://tokkee.org\n", basename(name));
74         exit(status);
75 } /* exit_usage */
77 static void
78 exit_version(void)
79 {
80         printf("fb version "VERSION", built "BUILD_DATE"\n"
81                         "Copyright (C) 2010 Sebastian Harl <sh@tokkee.org>\n"
83                         "\nThis is free software under the terms of the GNU GPLv2; see "
84 OR:
85                         "\nThis is free software under the terms of the BSD license, see "
86                         "the source for\ncopying conditions. There is NO WARRANTY; not "
87                         "even for MERCHANTABILITY or\nFITNESS FOR A PARTICULAR "
88                         "PURPOSE.\n");
89         exit(0);
90 } /* exit_version */
92 int
93 main(int argc, char **argv)
94 {
95         while (42) {
96                 int opt = getopt(argc, argv, "hV");
98                 if (-1 == opt)
99                         break;
101                 switch (opt) {
102                         case 'h':
103                                 exit_usage(argv[0], 0);
104                                 break;
105                         case 'V':
106                                 exit_version();
107                                 break;
108                         default:
109                                 exit_usage(argv[0], 1);
110                 }
111         }
113         if (optind < argc)
114                 exit_usage(argv[0], 1);
115         return 0;
116 } /* main */
118 /* vim: set tw=78 sw=4 ts=4 noexpandtab : */