OSDN Git Service

2013.10.24
[uclinux-h8/uClinux-dist.git] / freeswan / utils / _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  * RCSID $Id: _copyright.c,v 1.4 2001/11/22 04:15:56 henry Exp $
17  */
18
19 #include <sys/types.h>
20 #include <stdio.h>
21 #include <string.h>
22 #include <unistd.h>
23 #include <getopt.h>
24 #include <freeswan.h>
25
26 char usage[] = "Usage: ipsec _copyright";
27 struct option opts[] = {
28         "help",         0,      NULL,   'h',
29         "version",      0,      NULL,   'v',
30         0,              0,      NULL,   0,
31 };
32
33 char me[] = "ipsec _copyright"; /* for messages */
34
35 main(argc, argv)
36 int argc;
37 char *argv[];
38 {
39         int opt;
40         extern int optind;
41         int errflg = 0;
42         const char *version = ipsec_version_code();
43         const char **notice = ipsec_copyright_notice();
44         const char **co;
45
46         while ((opt = getopt_long(argc, argv, "", opts, NULL)) != EOF)
47                 switch (opt) {
48                 case 'h':       /* help */
49                         printf("%s\n", usage);
50                         exit(0);
51                         break;
52                 case 'v':       /* version */
53                         printf("%s %s\n", me, version);
54                         exit(0);
55                         break;
56                 case '?':
57                 default:
58                         errflg = 1;
59                         break;
60                 }
61         if (errflg || optind != argc) {
62                 fprintf(stderr, "%s\n", usage);
63                 exit(2);
64         }
65
66         for (co = notice; *co != NULL; co++)
67                 printf("%s\n", *co);
68         exit(0);
69 }