plugins: Wire up rust plugin support for NBD_INFO_INIT_STATE
[nbdkit/ericb.git] / server / options.h
blob50a7ba844dd1e81f19600ab508ead173380006f7
1 /* nbdkit
2 * Copyright (C) 2013-2019 Red Hat Inc.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * * Neither the name of Red Hat nor the names of its contributors may be
16 * used to endorse or promote products derived from this software without
17 * specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
29 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
33 #ifndef NBDKIT_OPTIONS_H
34 #define NBDKIT_OPTIONS_H
36 #include <stdbool.h>
37 #include <getopt.h>
38 #include <limits.h>
39 #include <string.h>
41 enum {
42 HELP_OPTION = CHAR_MAX + 1,
43 DUMP_CONFIG_OPTION,
44 DUMP_PLUGIN_OPTION,
45 EXIT_WITH_PARENT_OPTION,
46 FILTER_OPTION,
47 LOG_OPTION,
48 LONG_OPTIONS_OPTION,
49 MASK_HANDSHAKE_OPTION,
50 NO_SR_OPTION,
51 RUN_OPTION,
52 SELINUX_LABEL_OPTION,
53 SHORT_OPTIONS_OPTION,
54 SWAP_OPTION,
55 TLS_OPTION,
56 TLS_CERTIFICATES_OPTION,
57 TLS_PSK_OPTION,
58 TLS_VERIFY_PEER_OPTION,
59 VSOCK_OPTION,
62 static const char *short_options = "D:e:fg:i:nop:P:rst:u:U:vV";
63 static const struct option long_options[] = {
64 { "debug", required_argument, NULL, 'D' },
65 { "dump-config", no_argument, NULL, DUMP_CONFIG_OPTION },
66 { "dump-plugin", no_argument, NULL, DUMP_PLUGIN_OPTION },
67 { "exit-with-parent", no_argument, NULL, EXIT_WITH_PARENT_OPTION },
68 { "export", required_argument, NULL, 'e' },
69 { "export-name", required_argument, NULL, 'e' },
70 { "exportname", required_argument, NULL, 'e' },
71 { "filter", required_argument, NULL, FILTER_OPTION },
72 { "foreground", no_argument, NULL, 'f' },
73 { "no-fork", no_argument, NULL, 'f' },
74 { "group", required_argument, NULL, 'g' },
75 { "help", no_argument, NULL, HELP_OPTION },
76 { "ip-addr", required_argument, NULL, 'i' },
77 { "ipaddr", required_argument, NULL, 'i' },
78 { "log", required_argument, NULL, LOG_OPTION },
79 { "long-options", no_argument, NULL, LONG_OPTIONS_OPTION },
80 { "mask-handshake", required_argument, NULL, MASK_HANDSHAKE_OPTION },
81 { "new-style", no_argument, NULL, 'n' },
82 { "newstyle", no_argument, NULL, 'n' },
83 { "no-sr", no_argument, NULL, NO_SR_OPTION },
84 { "old-style", no_argument, NULL, 'o' },
85 { "oldstyle", no_argument, NULL, 'o' },
86 { "pid-file", required_argument, NULL, 'P' },
87 { "pidfile", required_argument, NULL, 'P' },
88 { "port", required_argument, NULL, 'p' },
89 { "read-only", no_argument, NULL, 'r' },
90 { "readonly", no_argument, NULL, 'r' },
91 { "run", required_argument, NULL, RUN_OPTION },
92 { "selinux-label", required_argument, NULL, SELINUX_LABEL_OPTION },
93 { "short-options", no_argument, NULL, SHORT_OPTIONS_OPTION },
94 { "single", no_argument, NULL, 's' },
95 { "stdin", no_argument, NULL, 's' },
96 { "swap", no_argument, NULL, SWAP_OPTION },
97 { "threads", required_argument, NULL, 't' },
98 { "tls", required_argument, NULL, TLS_OPTION },
99 { "tls-certificates", required_argument, NULL, TLS_CERTIFICATES_OPTION },
100 { "tls-psk", required_argument, NULL, TLS_PSK_OPTION },
101 { "tls-verify-peer", no_argument, NULL, TLS_VERIFY_PEER_OPTION },
102 { "unix", required_argument, NULL, 'U' },
103 { "user", required_argument, NULL, 'u' },
104 { "verbose", no_argument, NULL, 'v' },
105 { "version", no_argument, NULL, 'V' },
106 { "vsock", no_argument, NULL, VSOCK_OPTION },
107 { NULL },
110 /* Is it a plugin or filter name relative to the plugindir/filterdir? */
111 static inline bool
112 is_short_name (const char *filename)
114 return strchr (filename, '.') == NULL && strchr (filename, '/') == NULL;
117 #endif /* NBDKIT_OPTIONS_H */