b729030bfd5a0ce3e2ce1b025a077a3ff952908d
[strongswan.git] / src / _copyright / _copyright.c
1 /*
2 * copyright reporter
3 * (just avoids having the info in more than one place in the source)
4 * Copyright (C) 2001 Henry Spencer.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * for more details.
15 */
16
17 #include <sys/types.h>
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <unistd.h>
22 #include <getopt.h>
23 #include <freeswan.h>
24
25 char usage[] = "Usage: ipsec _copyright";
26 struct option opts[] = {
27 {"help", 0, NULL, 'h',},
28 {"version", 0, NULL, 'v',},
29 {0, 0, NULL, 0, },
30 };
31
32 char me[] = "ipsec _copyright"; /* for messages */
33
34 int
35 main(int argc, char *argv[])
36 {
37 int opt;
38 extern int optind;
39 int errflg = 0;
40 const char *version = ipsec_version_code();
41 const char **notice = ipsec_copyright_notice();
42 const char **co;
43
44 while ((opt = getopt_long(argc, argv, "", opts, NULL)) != EOF)
45 switch (opt) {
46 case 'h': /* help */
47 printf("%s\n", usage);
48 exit(0);
49 break;
50 case 'v': /* version */
51 printf("%s %s\n", me, version);
52 exit(0);
53 break;
54 case '?':
55 default:
56 errflg = 1;
57 break;
58 }
59 if (errflg || optind != argc) {
60 fprintf(stderr, "%s\n", usage);
61 exit(2);
62 }
63
64 for (co = notice; *co != NULL; co++)
65 printf("%s\n", *co);
66 exit(0);
67 }