summaryrefslogtreecommitdiff
path: root/tools/options.h
diff options
context:
space:
mode:
authorPaul Colomiets <paul@colomiets.name>2013-09-05 10:31:22 +0200
committerMartin Sustrik <sustrik@250bpm.com>2013-09-05 10:31:22 +0200
commit7572276b0dbf251663235489d58cb6f9a3584469 (patch)
treee151d392a29cb4375d7f51873b1267c125aaeed0 /tools/options.h
parentb25474a6037c0839cc5fa8a3da378d065ff3cb61 (diff)
downloadnanomsg-7572276b0dbf251663235489d58cb6f9a3584469.tar.gz
Nanocat the command-line interface for nanomsg
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'tools/options.h')
-rw-r--r--tools/options.h90
1 files changed, 90 insertions, 0 deletions
diff --git a/tools/options.h b/tools/options.h
new file mode 100644
index 0000000..ca148c4
--- /dev/null
+++ b/tools/options.h
@@ -0,0 +1,90 @@
+/*
+ Copyright (c) 2013 Insollo Entertainment, LLC. All rights reserved.
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom
+ the Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ IN THE SOFTWARE.
+*/
+
+#ifndef NN_OPTIONS_HEADER
+#define NN_OPTIONS_HEADER
+
+enum nn_option_type {
+ NN_OPT_HELP,
+ NN_OPT_INT,
+ NN_OPT_INCREMENT,
+ NN_OPT_DECREMENT,
+ NN_OPT_ENUM,
+ NN_OPT_SET_ENUM,
+ NN_OPT_STRING,
+ NN_OPT_BLOB,
+ NN_OPT_FLOAT,
+ NN_OPT_LIST_APPEND,
+ NN_OPT_LIST_APPEND_FMT,
+ NN_OPT_READ_FILE
+};
+
+struct nn_option {
+ /* Option names */
+ char *longname;
+ char shortname;
+ char *arg0name;
+
+ /* Parsing specification */
+ enum nn_option_type type;
+ int offset; /* offsetof() where to store the value */
+ const void *pointer; /* type specific pointer */
+
+ /* Conflict mask for options */
+ unsigned long mask_set;
+ unsigned long conflicts_mask;
+ unsigned long requires_mask;
+
+ /* Group and description for --help */
+ char *group;
+ char *metavar;
+ char *description;
+};
+
+struct nn_commandline {
+ char *short_description;
+ char *long_description;
+ struct nn_option *options;
+ int required_options;
+};
+
+struct nn_enum_item {
+ char *name;
+ int value;
+};
+
+struct nn_string_list {
+ char **items;
+ int num;
+};
+
+struct nn_blob {
+ char *data;
+ int length;
+};
+
+
+void nn_parse_options (struct nn_commandline *cline,
+ void *target, int argc, char **argv);
+
+
+#endif /* NN_OPTIONS_HEADER */