]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - vendor/ya_getopt/ya_getopt.h
Implement support for saving filters.
[user/henk/code/inspircd.git] / vendor / ya_getopt / ya_getopt.h
1 /* -*- indent-tabs-mode: nil -*-
2  *
3  * ya_getopt  - Yet another getopt
4  * https://github.com/kubo/ya_getopt
5  *
6  * Copyright 2015 Kubo Takehiro <kubo@jiubao.org>
7  *
8  * Redistribution and use in source and binary forms, with or without modification, are
9  * permitted provided that the following conditions are met:
10  *
11  *    1. Redistributions of source code must retain the above copyright notice, this list of
12  *       conditions and the following disclaimer.
13  *
14  *    2. Redistributions in binary form must reproduce the above copyright notice, this list
15  *       of conditions and the following disclaimer in the documentation and/or other materials
16  *       provided with the distribution.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS OR IMPLIED
19  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
21  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  * The views and conclusions contained in the software and documentation are those of the
29  * authors and should not be interpreted as representing official policies, either expressed
30  * or implied, of the authors.
31  *
32  */
33 #ifndef YA_GETOPT_H
34 #define YA_GETOPT_H 1
35
36 #if defined(__cplusplus)
37 extern "C" {
38 #endif
39
40 #define ya_no_argument        0
41 #define ya_required_argument  1
42 #define ya_optional_argument  2
43
44 struct option {
45     const char *name;
46     int has_arg;
47     int *flag;
48     int val;
49 };
50
51 int ya_getopt(int argc, char * const argv[], const char *optstring);
52 int ya_getopt_long(int argc, char * const argv[], const char *optstring,
53                    const struct option *longopts, int *longindex);
54 int ya_getopt_long_only(int argc, char * const argv[], const char *optstring,
55                         const struct option *longopts, int *longindex);
56
57 extern char *ya_optarg;
58 extern int ya_optind, ya_opterr, ya_optopt;
59
60 #ifndef YA_GETOPT_NO_COMPAT_MACRO
61 #define getopt ya_getopt
62 #define getopt_long ya_getopt_long
63 #define getopt_long_only ya_getopt_long_only
64 #define optarg ya_optarg
65 #define optind ya_optind
66 #define opterr ya_opterr
67 #define optopt ya_optopt
68 #define no_argument ya_no_argument
69 #define required_argument ya_required_argument
70 #define optional_argument ya_optional_argument
71 #endif
72
73 #if defined(__cplusplus)
74 }
75 #endif
76
77 #endif