Implemented Sensor class; Added LoRaWAN subagent
[public/netxms.git] / include / netxms_getopt.h
CommitLineData
9ade43e2
VK
1/*
2 * Copyright (c) 2014 Raden Solutions
3 *
4 * Custom header file for getopt implementation derived from NetBSD implementation
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18/*
19 * Copyright (c) 2002 Todd C. Miller <Todd.Miller@courtesan.com>
20 *
21 * Permission to use, copy, modify, and distribute this software for any
22 * purpose with or without fee is hereby granted, provided that the above
23 * copyright notice and this permission notice appear in all copies.
24 *
25 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
26 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
27 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
28 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
29 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
30 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
31 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
32 *
33 * Sponsored in part by the Defense Advanced Research Projects
34 * Agency (DARPA) and Air Force Research Laboratory, Air Force
35 * Materiel Command, USAF, under agreement number F39502-99-1-0512.
36 */
37/*-
38 * Copyright (c) 2000 The NetBSD Foundation, Inc.
39 * All rights reserved.
40 *
41 * This code is derived from software contributed to The NetBSD Foundation
42 * by Dieter Baron and Thomas Klausner.
43 *
44 * Redistribution and use in source and binary forms, with or without
45 * modification, are permitted provided that the following conditions
46 * are met:
47 * 1. Redistributions of source code must retain the above copyright
48 * notice, this list of conditions and the following disclaimer.
49 * 2. Redistributions in binary form must reproduce the above copyright
50 * notice, this list of conditions and the following disclaimer in the
51 * documentation and/or other materials provided with the distribution.
52 * 3. All advertising materials mentioning features or use of this software
53 * must display the following acknowledgement:
54 * This product includes software developed by the NetBSD
55 * Foundation, Inc. and its contributors.
56 * 4. Neither the name of The NetBSD Foundation nor the names of its
57 * contributors may be used to endorse or promote products derived
58 * from this software without specific prior written permission.
59 *
60 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
61 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
62 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
63 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
64 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
65 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
66 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
67 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
68 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
69 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
70 * POSSIBILITY OF SUCH DAMAGE.
71 */
72
73#ifndef _NETXMS_GETOPT_H
74#define _NETXMS_GETOPT_H
75
76#include <nms_util.h>
3046f9a4 77
df9812a9
VK
78#undef HAVE_GETOPT_LONG
79#define HAVE_GETOPT_LONG 1
80
81#undef HAVE_DECL_GETOPT_LONG
82#define HAVE_DECL_GETOPT_LONG 1
83
9ade43e2
VK
84#if defined(_WIN32) && !defined(REPLACE_GETOPT)
85#define REPLACE_GETOPT
3046f9a4
VK
86#endif
87
88#ifdef __cplusplus
89extern "C" {
90#endif
91
9ade43e2
VK
92extern LIBNETXMS_EXPORTABLE char *optarg;
93extern LIBNETXMS_EXPORTABLE int optind;
94extern LIBNETXMS_EXPORTABLE int opterr;
95extern LIBNETXMS_EXPORTABLE int optopt;
3046f9a4
VK
96
97struct option
98{
9ade43e2 99#if __STDC__
3046f9a4
VK
100 const char *name;
101#else
102 char *name;
103#endif
3046f9a4
VK
104 int has_arg;
105 int *flag;
106 int val;
107};
108
9ade43e2
VK
109#define no_argument 0
110#define required_argument 1
111#define optional_argument 2
3046f9a4 112
9ade43e2
VK
113#ifdef REPLACE_GETOPT
114int LIBNETXMS_EXPORTABLE nx_getopt(int nargc, char * const *nargv, const char *options);
115#define getopt nx_getopt
116#endif
3046f9a4 117
9ade43e2
VK
118int LIBNETXMS_EXPORTABLE getopt_long(int nargc, char * const *nargv, const char *options, const struct option *long_options, int *idx);
119int LIBNETXMS_EXPORTABLE getopt_long_only(int nargc, char * const *nargv, const char *options, const struct option *long_options, int *idx);
3046f9a4
VK
120
121#ifdef __cplusplus
122}
123#endif
124
9ade43e2 125#endif /* _NETXMS_GETOPT_H */