From cc4bd717537482337d2b0ba22f7ce0e22df5b854 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Fri, 11 Oct 2024 23:18:10 -0700 Subject: nng_opts_parse converted to mdbook. --- docs/ref/SUMMARY.md | 1 + docs/ref/api/util/nng_opts_parse.md | 167 ++++++++++++++++++++++++++++++++++++ 2 files changed, 168 insertions(+) create mode 100644 docs/ref/api/util/nng_opts_parse.md (limited to 'docs/ref') diff --git a/docs/ref/SUMMARY.md b/docs/ref/SUMMARY.md index 25076381..d6663a78 100644 --- a/docs/ref/SUMMARY.md +++ b/docs/ref/SUMMARY.md @@ -14,6 +14,7 @@ - [nng_clock](./api/util/nng_clock.md) - [nng_id_map](./api/util/nng_id_map.md) - [nng_msleep](./api/util/nng_msleep.md) + - [nng_opts_parse](./api/util/nng_opts_parse.md) - [nng_random](./api/util/nng_random.md) - [nng_socket_pair](./api/util/nng_socket_pair.md) - [nng_strdup](./api/util/nng_strdup.md) diff --git a/docs/ref/api/util/nng_opts_parse.md b/docs/ref/api/util/nng_opts_parse.md new file mode 100644 index 00000000..ddcea832 --- /dev/null +++ b/docs/ref/api/util/nng_opts_parse.md @@ -0,0 +1,167 @@ +# nng_opts_parse + +## NAME + +nng_opts_parse --- parse command line options + +## SYNOPSIS + +```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, char *const *argv, + const nng_optspec *spec, int *val, char **arg, int *idx); +``` + +## DESCRIPTION + +The {{i:`nng_opts_parse`}} function is a intended to facilitate parsing +{{i:command-line arguments}}. +This function exists largely to stand in for {{i:`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 <