aboutsummaryrefslogtreecommitdiff
path: root/src/core/options.h
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-04-04 11:07:56 -0700
committerGarrett D'Amore <garrett@damore.org>2018-04-04 11:07:56 -0700
commit505a9bce029e51540739c853a6c9eef0ecfb2e90 (patch)
treed907679b6ab99bcb5da919db3d005d4976590c21 /src/core/options.h
parent0aa1de1316b46bb4af23fdf26759bca08008eaf5 (diff)
downloadnng-505a9bce029e51540739c853a6c9eef0ecfb2e90.tar.gz
nng-505a9bce029e51540739c853a6c9eef0ecfb2e90.tar.bz2
nng-505a9bce029e51540739c853a6c9eef0ecfb2e90.zip
fixes #329 type checking not done for setopt
Diffstat (limited to 'src/core/options.h')
-rw-r--r--src/core/options.h38
1 files changed, 13 insertions, 25 deletions
diff --git a/src/core/options.h b/src/core/options.h
index 35c3232f..dfc15d31 100644
--- a/src/core/options.h
+++ b/src/core/options.h
@@ -11,39 +11,27 @@
#ifndef CORE_OPTIONS_H
#define CORE_OPTIONS_H
-// Option helpers. These can be called from protocols or transports
-// in their own option handling, centralizing the logic for dealing with
-// variable sized options.
-
-// nni_setopt_buf sets the queue size for the message queue.
-extern int nni_setopt_buf(nni_msgq *, const void *, size_t);
-
-// nni_setopt_duration sets the duration. Durations must be legal,
-// either a positive value, 0, or -1 to indicate forever.
-extern int nni_setopt_ms(nni_duration *, const void *, size_t);
-
-// nni_setopt_bool sets a bool, or _Bool
-extern int nni_setopt_bool(bool *, const void *, size_t);
-
-// nni_setopt_int sets an integer, which must be between the minimum and
-// maximum values (inclusive).
-extern int nni_setopt_int(int *, const void *, size_t, int, int);
-
+// Integer limits.
#define NNI_MAXINT ((int) 2147483647)
#define NNI_MININT ((int) -2147483648)
-// nni_setopt_size sets a size_t option.
-extern int nni_setopt_size(size_t *, const void *, size_t, size_t, size_t);
-
// We limit the maximum size to 4GB. That's intentional because some of the
// underlying protocols cannot cope with anything bigger than 32-bits.
#define NNI_MINSZ (0)
#define NNI_MAXSZ ((size_t) 0xffffffff)
-extern int nni_chkopt_bool(size_t);
-extern int nni_chkopt_ms(const void *, size_t);
-extern int nni_chkopt_int(const void *, size_t, int, int);
-extern int nni_chkopt_size(const void *, size_t, size_t, size_t);
+// Option helpers. These can be called from protocols or transports
+// in their own option handling, centralizing the logic for dealing with
+// variable sized options.
+
+extern int nni_copyin_ms(nni_duration *, const void *, size_t, int);
+extern int nni_copyin_bool(bool *, const void *, size_t, int);
+extern int nni_copyin_int(int *, const void *, size_t, int, int, int);
+extern int nni_copyin_size(
+ size_t *, const void *, size_t, size_t, size_t, int);
+extern int nni_copyin_str(char *, const void *, size_t, size_t, int);
+extern int nni_copyin_ptr(void **, const void *, size_t, int);
+extern int nni_copyin_u64(uint64_t *, const void *, size_t, int);
// nni_copyout_xxx copies out a type of the named value. It assumes that
// the type is aligned and the size correct, unless NNI_TYPE_OPAQUE is passed.