From 53d5c2766d90a53d3f6c0437bc59c1ad63ec701a Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Thu, 22 Mar 2018 14:06:07 -0700 Subject: Add documentation for supplemental functions. This includes platform portability stuff like mutexes and threads, etc. While here we fixed a problem with nng_opts_parse and we addressed the type of the platform API. --- docs/man/nng_opts_parse.3supp.adoc | 183 +++++++++++++++++++++++++++++++++++++ 1 file changed, 183 insertions(+) create mode 100644 docs/man/nng_opts_parse.3supp.adoc (limited to 'docs/man/nng_opts_parse.3supp.adoc') diff --git a/docs/man/nng_opts_parse.3supp.adoc b/docs/man/nng_opts_parse.3supp.adoc new file mode 100644 index 00000000..6fc22a7f --- /dev/null +++ b/docs/man/nng_opts_parse.3supp.adoc @@ -0,0 +1,183 @@ += nng_opts_parse(3supp) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_opts_parse - parse command line options + +== SYNOPSIS + +[source, c] +---- +#include +#include + +typedef struct nng_optspec { + const char *o_name; // Long style name (may be NULL for short only) + int o_short; // Short option (no clustering!) + int o_val; // Value stored on a good parse (>0) + bool o_arg; // Option takes an argument if true +} nng_optspec; + +int nng_opts_parse(int argc, const char **argv, const nng_optspec *spec, int *val, const char **arg, int *idx); +---- + +== DESCRIPTION + +The `nng_opts_parse()` is function is a supplemental funtion intened to +facilitate parsing command line arguments. +This function exists largely to stand in for `getopt()` from POSIX +systems, but it is available everywhere that _NNG_ is, and it includes +some capabilities missing from `getopt()`. + +The function parses arguments from `main()` (using _argc_ and _argv_), +starting at the index referenced by _idx_. +(New invocations typically set the value pointed to by _idx_ to 1.) + +Options are parsed as specified by _spec_ (see <