From 1dc090d39eded06eee7725bd507599d8f59a3379 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Thu, 22 Mar 2018 02:52:01 -0700 Subject: Document nng_opts_parse. --- docs/man/libnng.3.adoc | 11 +++ docs/man/man3supp.desc | 3 + docs/man/man3supp.sect | 1 + docs/man/nng_opts_parse.3supp | 183 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 198 insertions(+) create mode 100644 docs/man/man3supp.desc create mode 100644 docs/man/man3supp.sect create mode 100644 docs/man/nng_opts_parse.3supp (limited to 'docs') diff --git a/docs/man/libnng.3.adoc b/docs/man/libnng.3.adoc index c5c345f6..2fd0109f 100644 --- a/docs/man/libnng.3.adoc +++ b/docs/man/libnng.3.adoc @@ -207,6 +207,17 @@ universal resource locators (URLS). |=== +=== Supplemental API + +These supplemental functions are not intrinsic to building +network applications with _NNG_, but they are made available +as a convenience to aid in creating portable applications. + +|=== +|<>|parse command line options +|=== + + === HTTP Support The library may be configured with support for HTTP, and this will diff --git a/docs/man/man3supp.desc b/docs/man/man3supp.desc new file mode 100644 index 00000000..ebd48b85 --- /dev/null +++ b/docs/man/man3supp.desc @@ -0,0 +1,3 @@ +This section documents supplemental functions that are available. +These functions are not intrinsic to building applications with +this library, but their presence may facilitate writing portable applications. diff --git a/docs/man/man3supp.sect b/docs/man/man3supp.sect new file mode 100644 index 00000000..7c8e3822 --- /dev/null +++ b/docs/man/man3supp.sect @@ -0,0 +1 @@ +Supplemental Functions diff --git a/docs/man/nng_opts_parse.3supp b/docs/man/nng_opts_parse.3supp new file mode 100644 index 00000000..6fc22a7f --- /dev/null +++ b/docs/man/nng_opts_parse.3supp @@ -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 <