consistent display of strongSwan version
[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 **notice = ipsec_copyright_notice();
41 const char **co;
42
43 while ((opt = getopt_long(argc, argv, "", opts, NULL)) != EOF)
44 switch (opt) {
45 case 'h': /* help */
46 printf("%s\n", usage);
47 exit(0);
48 break;
49 case 'v': /* version */
50 printf("%s strongSwan "VERSION"\n", me);
51 exit(0);
52 break;
53 case '?':
54 default:
55 errflg = 1;
56 break;
57 }
58 if (errflg || optind != argc) {
59 fprintf(stderr, "%s\n", usage);
60 exit(2);
61 }
62
63 for (co = notice; *co != NULL; co++)
64 printf("%s\n", *co);
65 exit(0);
66 }