From 9ca901c1b70b17d851426483d9f54611cfa8e395 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Mon, 19 Mar 2018 16:02:37 -0700 Subject: fixes #296 Typed options should validate option type fixes #302 nng_dialer/listener/pipe_getopt_sockaddr desired This adds plumbing to pass and check the type of options all the way through. NNG_ZT_OPT_ORBIT is type UINT64, but you can use the untyped form to pass two of them if needed. No typed access for retrieving strings yet. I think this should allocate a pointer and copy that out, but that's for later. --- docs/man/nng_dialer_getopt.3.adoc | 11 +++++++++-- docs/man/nng_listener_getopt.3.adoc | 19 +++++++++++++------ docs/man/nng_listener_setopt.3.adoc | 1 + docs/man/nng_pipe_getopt.3.adoc | 10 ++++++++++ 4 files changed, 33 insertions(+), 8 deletions(-) (limited to 'docs') diff --git a/docs/man/nng_dialer_getopt.3.adoc b/docs/man/nng_dialer_getopt.3.adoc index 61aaa576..3fde89d6 100644 --- a/docs/man/nng_dialer_getopt.3.adoc +++ b/docs/man/nng_dialer_getopt.3.adoc @@ -29,7 +29,9 @@ int nng_dialer_getopt_ms(nng_dialer d, const char *opt, nng_duration *durp); int nng_dialer_getopt_ptr(nng_dialer d, const char *opt, void **ptr); -int nng_dialer_setopt_size(nng_dialer d, const char *opt, size_t *zp); +int nng_dialer_getopt_size(nng_dialer d, const char *opt, size_t *zp); + +int nng_dialer_getopt_sockaddr(nng_dialer d, const char *opt, nng_sockaddr *sap); int nng_dialer_getopt_uint64(nng_dialer d, const char *opt, uint64_t *u64p); ---- @@ -79,7 +81,7 @@ the object. ==== `nng_dialer_getopt_bool()` This function is for options which take a boolean (`bool`). -The value will be stored at _ivalp_. +The value will be stored at _bvalp_. ==== `nng_dialer_getopt_int()` This function is for options which take an integer (`int`). @@ -101,6 +103,10 @@ not copied, but instead the *pointer* to the object is copied. This function is used to retrieve a size into the pointer _zp_, typically for buffer sizes, message maximum sizes, and similar options. +==== `nng_dialer_getopt_sockaddr()` +This function is used to retrieve an <> +into the value referenced by _sap_. + ==== `nng_dialer_getopt_uint64()` This function is used to retrieve a 64-bit unsigned value into the value referenced by _u64p_. @@ -125,4 +131,5 @@ These functions returns 0 on success, and non-zero otherwise. <>, <>, <>, +<>, <> diff --git a/docs/man/nng_listener_getopt.3.adoc b/docs/man/nng_listener_getopt.3.adoc index 6b2c2fde..1bafd1d6 100644 --- a/docs/man/nng_listener_getopt.3.adoc +++ b/docs/man/nng_listener_getopt.3.adoc @@ -19,8 +19,7 @@ nng_listener_getopt - get listener option ---- #include -int nng_listener_getopt(nng_listener l, const char *opt, void *val, - size_t *valszp); +int nng_listener_getopt(nng_listener l, const char *opt, void *val, size_t *valszp); int nng_listener_getopt_bool(nng_listener l, const char *opt, bool *bvalp); @@ -30,7 +29,9 @@ int nng_listener_getopt_ms(nng_listener l, const char *opt, nng_duration *durp); int nng_listener_getopt_ptr(nng_listener l, const char *opt, void **ptr); -int nng_listener_setopt_size(nng_listener l, const char *opt, size_t *zp); +int nng_listener_getopt_size(nng_listener l, const char *opt, size_t *zp); + +int nng_listener_getopt_sockaddr(nng_listener l, const char *opt, nng_sockaddr *sap); int nng_listener_getopt_uint64(nng_listener l, const char *opt, uint64_t *u64p); ---- @@ -80,7 +81,7 @@ the object. ==== `nng_listener_getopt_bool()` This function is for options which take a boolean (`bool`). -The value will be stored at _ivalp_. +The value will be stored at _bvalp_. ==== `nng_listener_getopt_int()` This function is for options which take an integer (`int`). @@ -89,8 +90,6 @@ The value will be stored at _ivalp_. ==== `nng_listener_getopt_ms()` This function is used to retrieve time <> (such as timeouts), stored in _durp_ as a number of milliseconds. -(The special value ((`NNG_DUR_INFINITE`)) means an infinite amount of time, and -the special value ((`NNG_DUR_DEFAULT`)) means a context-specific default.) ==== `nng_listener_getopt_ptr()` This function is used to retrieve a pointer, _ptr_, to structured data. @@ -102,6 +101,10 @@ not copied, but instead the *pointer* to the object is copied. This function is used to retrieve a size into the pointer _zp_, typically for buffer sizes, message maximum sizes, and similar options. +==== `nng_listener_getopt_sockaddr()` +This function is used to retrieve an <> +into the value referenced by _sap_. + ==== `nng_listener_getopt_uint64()` This function is used to retrieve a 64-bit unsigned value into the value referenced by _u64p_. @@ -125,4 +128,8 @@ These functions return 0 on success, and non-zero otherwise. <> <>, <>, +<>, +<>, +<>, +<>, <> diff --git a/docs/man/nng_listener_setopt.3.adoc b/docs/man/nng_listener_setopt.3.adoc index 93cae9ab..03a33a57 100644 --- a/docs/man/nng_listener_setopt.3.adoc +++ b/docs/man/nng_listener_setopt.3.adoc @@ -123,6 +123,7 @@ These functions return 0 on success, and non-zero otherwise. <> <>, <>, +<>, <>, <>, <> diff --git a/docs/man/nng_pipe_getopt.3.adoc b/docs/man/nng_pipe_getopt.3.adoc index 3198fc21..fd607198 100644 --- a/docs/man/nng_pipe_getopt.3.adoc +++ b/docs/man/nng_pipe_getopt.3.adoc @@ -29,6 +29,8 @@ int nng_pipe_getopt_ms(nng_pipe p, const char *opt, nng_duration *durp); int nng_dialer_getopt_ptr(nng_pipe p, const char *opt, void **ptr); +int nng_pipe_getopt_sockaddr(nng_pipe p, const char *opt, nng_sockaddr *sap); + int nng_pipe_getopt_size(nng_pipe p, const char *opt, size_t *zp); int nng_pipe_getopt_uint64(nng_pipe p, const char *opt, uint64_t *u64p); @@ -110,6 +112,11 @@ not copied, but instead the *pointer* to the object is copied. This function is used to retrieve a size into the pointer _zp_, typically for buffer sizes, message maximum sizes, and similar options. +==== `nng_pipe_getopt_sockaddr()` + +This function is used to retrieve an <> +into _sap_. + ==== `nng_pipe_getopt_uint64()` This function is used to retriev a 64-bit unsigned value into the value @@ -134,5 +141,8 @@ These functions return 0 on success, and non-zero otherwise. <> <> <>, +<>, <>, +<>, +<>, <> -- cgit v1.2.3-70-g09d2