aboutsummaryrefslogtreecommitdiff
path: root/src/nng.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-04-24 09:29:34 -0700
committerGarrett D'Amore <garrett@damore.org>2018-04-24 14:55:10 -0700
commitea741e0285e70e2ca417fbd2c874bb990bdbf833 (patch)
tree6d2cf8deb714c0457b4972840cd4759b79257c26 /src/nng.c
parent5902d02ad0a056a146231568f1293ffbcd59f61c (diff)
downloadnng-ea741e0285e70e2ca417fbd2c874bb990bdbf833.tar.gz
nng-ea741e0285e70e2ca417fbd2c874bb990bdbf833.tar.bz2
nng-ea741e0285e70e2ca417fbd2c874bb990bdbf833.zip
fixes #363 context option plumbing missing
Diffstat (limited to 'src/nng.c')
-rw-r--r--src/nng.c50
1 files changed, 45 insertions, 5 deletions
diff --git a/src/nng.c b/src/nng.c
index e3108e47..9eb33f50 100644
--- a/src/nng.c
+++ b/src/nng.c
@@ -326,17 +326,57 @@ nng_ctx_getopt_size(nng_ctx id, const char *name, size_t *vp)
}
int
-nng_ctx_getopt_string(nng_ctx id, const char *name, char **vp)
+nng_ctx_getopt_ms(nng_ctx id, const char *name, nng_duration *vp)
{
size_t sz = sizeof(*vp);
- return (nng_ctx_getx(id, name, vp, &sz, NNI_TYPE_STRING));
+ return (nng_ctx_getx(id, name, vp, &sz, NNI_TYPE_DURATION));
+}
+
+static int
+nng_ctx_setx(nng_ctx id, const char *n, const void *v, size_t sz, int t)
+{
+ nni_ctx *ctx;
+ int rv;
+
+ if ((rv = nni_init()) != 0) {
+ return (rv);
+ }
+ if ((rv = nni_ctx_find(&ctx, id, false)) != 0) {
+ return (rv);
+ }
+ rv = nni_ctx_setopt(ctx, n, v, sz, t);
+ nni_ctx_rele(ctx);
+ return (rv);
}
int
-nng_ctx_getopt_ms(nng_ctx id, const char *name, nng_duration *vp)
+nng_ctx_setopt(nng_ctx id, const char *name, const void *val, size_t sz)
{
- size_t sz = sizeof(*vp);
- return (nng_ctx_getx(id, name, vp, &sz, NNI_TYPE_DURATION));
+ return (nng_ctx_setx(id, name, val, sz, NNI_TYPE_OPAQUE));
+}
+
+int
+nng_ctx_setopt_bool(nng_ctx id, const char *name, bool v)
+{
+ return (nng_ctx_setx(id, name, &v, sizeof(v), NNI_TYPE_BOOL));
+}
+
+int
+nng_ctx_setopt_int(nng_ctx id, const char *name, int v)
+{
+ return (nng_ctx_setx(id, name, &v, sizeof(v), NNI_TYPE_INT32));
+}
+
+int
+nng_ctx_setopt_size(nng_ctx id, const char *name, size_t v)
+{
+ return (nng_ctx_setx(id, name, &v, sizeof(v), NNI_TYPE_SIZE));
+}
+
+int
+nng_ctx_setopt_ms(nng_ctx id, const char *name, nng_duration v)
+{
+ return (nng_ctx_setx(id, name, &v, sizeof(v), NNI_TYPE_DURATION));
}
int