diff options
| author | Garrett D'Amore <garrett@damore.org> | 2018-08-31 11:25:50 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2018-08-31 11:25:50 -0700 |
| commit | 49c8c264057c4c7b0f9ff45f352168cb1deeb1a1 (patch) | |
| tree | 30836d3dfe020380216113784b4ab74c633d9b45 | |
| parent | 2426984f20a8363e52fef5cd69221da05c0b1756 (diff) | |
| download | nng-49c8c264057c4c7b0f9ff45f352168cb1deeb1a1.tar.gz nng-49c8c264057c4c7b0f9ff45f352168cb1deeb1a1.tar.bz2 nng-49c8c264057c4c7b0f9ff45f352168cb1deeb1a1.zip | |
fixes #691 Desire 16 and 64 bit message manipulators
We use macros to generate message bodies for each of the various
variants, reducing source code size (but not compiled size). The
documentation is updated to indicate each of these variants.
| -rw-r--r-- | docs/man/nng_msg_append.3.adoc | 14 | ||||
| -rw-r--r-- | docs/man/nng_msg_chop.3.adoc | 12 | ||||
| -rw-r--r-- | docs/man/nng_msg_header_append.3.adoc | 15 | ||||
| -rw-r--r-- | docs/man/nng_msg_header_chop.3.adoc | 12 | ||||
| -rw-r--r-- | docs/man/nng_msg_header_insert.3.adoc | 16 | ||||
| -rw-r--r-- | docs/man/nng_msg_header_trim.3.adoc | 10 | ||||
| -rw-r--r-- | docs/man/nng_msg_insert.3.adoc | 15 | ||||
| -rw-r--r-- | docs/man/nng_msg_trim.3.adoc | 12 | ||||
| -rw-r--r-- | src/core/message.c | 152 | ||||
| -rw-r--r-- | src/core/message.h | 16 | ||||
| -rw-r--r-- | src/nng.c | 104 | ||||
| -rw-r--r-- | src/nng.h | 25 |
12 files changed, 243 insertions, 160 deletions
diff --git a/docs/man/nng_msg_append.3.adoc b/docs/man/nng_msg_append.3.adoc index 7bceb223..fc87e15d 100644 --- a/docs/man/nng_msg_append.3.adoc +++ b/docs/man/nng_msg_append.3.adoc @@ -11,7 +11,7 @@ == NAME -nng_msg_append, nng_msg_append_u32 - append to message body +nng_msg_append - append to message body == SYNOPSIS @@ -20,20 +20,22 @@ nng_msg_append, nng_msg_append_u32 - append to message body #include <nng/nng.h> int nng_msg_append(nng_msg *msg, const void *val, size_t size); - +int nng_msg_append_u16(nng_msg *msg, uint16_t val16); int nng_msg_append_u32(nng_msg *msg, uint32_t val32); +int nng_msg_append_u64(nng_msg *msg, uint64_t val64); ---- == DESCRIPTION -The `nng_msg_append()` and `nng_msg_append_u32()` functions append data to +The `nng_msg_append()` family of functions appends data to the end of the body of message _msg_, reallocating it if necessary. -The first function appends _size_ bytes, copying them from _val_. The -second function appends the value _val32_ in network-byte order (big-endian). +The first function appends _size_ bytes, copying them from _val_. +The remaining functions append the value specified (such as _val32_) in +network-byte order (big-endian). == RETURN VALUES -This function returns 0 on success, and non-zero otherwise. +These functions return 0 on success, and non-zero otherwise. == ERRORS diff --git a/docs/man/nng_msg_chop.3.adoc b/docs/man/nng_msg_chop.3.adoc index 44f15ac6..1ecde435 100644 --- a/docs/man/nng_msg_chop.3.adoc +++ b/docs/man/nng_msg_chop.3.adoc @@ -11,7 +11,7 @@ == NAME -nng_msg_chop, nng_msg_chop_u32 - remove data from end of message body +nng_msg_chop - remove data from end of message body == SYNOPSIS @@ -20,21 +20,23 @@ nng_msg_chop, nng_msg_chop_u32 - remove data from end of message body #include <nng/nng.h> int nng_msg_chop(nng_msg *msg, size_t size); - +int nng_msg_chop_u16(nng_msg *msg, uint16_t *val16); int nng_msg_chop_u32(nng_msg *msg, uint32_t *val32); +int nng_msg_chop_u64(nng_msg *msg, uint64_t *val64); ---- == DESCRIPTION -The `nng_msg_chop()` and `nng_msg_chop_u32()` functions remove data from +The `nng_msg_chop()` family of functions removes data from the end of the body of message _msg_. The first function removes _size_ bytes. -The second function removes 4 bytes, and stores them in the value _val32_, +The remaining functions remove 2, 4, or 8 bytes, and stores them in the value +(such as _val32_), after converting them from network-byte order (big-endian) to native byte order. == RETURN VALUES -This function returns 0 on success, and non-zero otherwise. +These functions return 0 on success, and non-zero otherwise. == ERRORS diff --git a/docs/man/nng_msg_header_append.3.adoc b/docs/man/nng_msg_header_append.3.adoc index b711b9f6..08e48b74 100644 --- a/docs/man/nng_msg_header_append.3.adoc +++ b/docs/man/nng_msg_header_append.3.adoc @@ -11,7 +11,7 @@ == NAME -nng_msg_header_append, nng_msg_header_append_u32 - append to message header +nng_msg_header_append - append to message header == SYNOPSIS @@ -20,23 +20,24 @@ nng_msg_header_append, nng_msg_header_append_u32 - append to message header #include <nng/nng.h> int nng_msg_header_append(nng_msg *msg, const void *val, size_t size); - +int nng_msg_header_append_u16(nng_msg *msg, uint16_t val16); int nng_msg_header_append_u32(nng_msg *msg, uint32_t val32); +int nng_msg_header_append_u64(nng_msg *msg, uint64_t val64); ---- == DESCRIPTION -The `nng_msg_header_append()` and `nng_msg_header_append_u32()` -functions append data to +The `nng_msg_header_append()` family of functions appends data to the end of the headers of message _msg_, reallocating it if necessary. The first function appends _size_ bytes, copying them from _val_. -The second function appends the value _val32_ in network-byte order -(big-endian). + +The remaining functions append the value (such as _val32_) in +network-byte order (big-endian). == RETURN VALUES -This function returns 0 on success, and non-zero otherwise. +These functions return 0 on success, and non-zero otherwise. == ERRORS diff --git a/docs/man/nng_msg_header_chop.3.adoc b/docs/man/nng_msg_header_chop.3.adoc index 6536b6fb..c9c9113b 100644 --- a/docs/man/nng_msg_header_chop.3.adoc +++ b/docs/man/nng_msg_header_chop.3.adoc @@ -11,7 +11,7 @@ == NAME -nng_msg_header_chop, nng_msg_header_chop_u32 - remove data from end of message header +nng_msg_header_chop - remove data from end of message header == SYNOPSIS @@ -20,22 +20,24 @@ nng_msg_header_chop, nng_msg_header_chop_u32 - remove data from end of message h #include <nng/nng.h> int nng_msg_header_chop(nng_msg *msg, size_t size); - +int nng_msg_header_chop_u16(nng_msg *msg, uint16_t *val16); int nng_msg_header_chop_u32(nng_msg *msg, uint32_t *val32); +int nng_msg_header_chop_u64(nng_msg *msg, uint64_t *val64); ---- == DESCRIPTION -The `nng_msg_header_chop()` and `nng_msg_header_chop_u32()` functions remove +The `nng_msg_header_chop()` family of functions removes data from the end of the header of message _msg_. The first function removes _size_ bytes. -The second function removes 4 bytes, and stores them in the value _val32_, +The remaining functions remove 2, 4, or 8 bytes, and stores them in the value +(such as _val32_), after converting them from network-byte order (big-endian) to native byte order. == RETURN VALUES -This function returns 0 on success, and non-zero otherwise. +These function return 0 on success, and non-zero otherwise. == ERRORS diff --git a/docs/man/nng_msg_header_insert.3.adoc b/docs/man/nng_msg_header_insert.3.adoc index f7934738..1b1437f7 100644 --- a/docs/man/nng_msg_header_insert.3.adoc +++ b/docs/man/nng_msg_header_insert.3.adoc @@ -11,7 +11,7 @@ == NAME -nng_msg_header_insert, nng_msg_header_insert_u32 - prepend to message header +nng_msg_header_insert - prepend to message header == SYNOPSIS @@ -20,21 +20,23 @@ nng_msg_header_insert, nng_msg_header_insert_u32 - prepend to message header #include <nng/nng.h> int nng_msg_header_insert(nng_msg *msg, const void *val, size_t size); - +int nng_msg_header_insert_u16(nng_msg *msg, uint16_t val16); int nng_msg_header_insert_u32(nng_msg *msg, uint32_t val32); +int nng_msg_header_insert_u64(nng_msg *msg, uint64_t val64); ---- == DESCRIPTION -The `nng_msg_header_insert()` and `nng_msg_header_insert_u32()` functions -prepend data to the front of the headers of message _msg_, reallocating +The `nng_msg_header_insert()` family of functions +prepends data to the front of the headers of message _msg_, reallocating if necessary. -The first function prepends _size_ bytes, copying them from _val_. The -second function prepends the value _val32_ in network-byte order (big-endian). +The first function prepends _size_ bytes, copying them from _val_. +The remaining functions prepend the specified value (such as _val32_) in +network-byte order (big-endian). == RETURN VALUES -This function returns 0 on success, and non-zero otherwise. +These functions return 0 on success, and non-zero otherwise. == ERRORS diff --git a/docs/man/nng_msg_header_trim.3.adoc b/docs/man/nng_msg_header_trim.3.adoc index 39d8052e..0a9caea3 100644 --- a/docs/man/nng_msg_header_trim.3.adoc +++ b/docs/man/nng_msg_header_trim.3.adoc @@ -11,7 +11,7 @@ == NAME -nng_msg_header_trim, nng_msg_header_trim_u32 - remove data from start of message header +nng_msg_header_trim - remove data from start of message header == SYNOPSIS @@ -20,16 +20,18 @@ nng_msg_header_trim, nng_msg_header_trim_u32 - remove data from start of message #include <nng/nng.h> int nng_msg_header_trim(nng_msg *msg, size_t size); - +int nng_msg_header_trim_u16(nng_msg *msg, uint16_t *val16); int nng_msg_header_trim_u32(nng_msg *msg, uint32_t *val32); +int nng_msg_header_trim_u64(nng_msg *msg, uint64_t *val64); ---- == DESCRIPTION -The `nng_msg_header_trim()` and `nng_msg_header_trim_u32()` functions remove +The `nng_msg_header_trim()` family of functions remove data from the start of the header of message _msg_. The first function removes _size_ bytes. -The second function removes 4 bytes, and stores them in the value _val32_, +The remaining functions removes 2, 4, or 8 bytes, and stores them in the +value (such as _val32_), after converting them from network-byte order (big-endian) to native byte order. diff --git a/docs/man/nng_msg_insert.3.adoc b/docs/man/nng_msg_insert.3.adoc index 911dabbb..cc910531 100644 --- a/docs/man/nng_msg_insert.3.adoc +++ b/docs/man/nng_msg_insert.3.adoc @@ -11,7 +11,7 @@ == NAME -nng_msg_insert, nng_msg_insert_u32 - prepend to message body +nng_msg_insert - prepend to message body == SYNOPSIS @@ -20,26 +20,27 @@ nng_msg_insert, nng_msg_insert_u32 - prepend to message body #include <nng/nng.h> int nng_msg_insert(nng_msg *msg, const void *val, size_t size); - +int nng_msg_insert(nng_msg *msg, uint16_t val16); int nng_msg_insert(nng_msg *msg, uint32_t val32); +int nng_msg_insert(nng_msg *msg, uint64_t val64); ---- == DESCRIPTION -The `nng_msg_insert()` and `nng_msg_insert_u32()` functions prepend data to +The `nng_msg_insert()` family of functions prepends data to the front of the body of message _msg_, reallocating it if necessary. The first function prepends _size_ bytes, copying them from _val_. -The second function prepends the value _val32_ in network-byte order -(big-endian). +The remaining functions prepend the specified value (such as _val32_) +in network-byte order (big-endian). -TIP: This function makes use of pre-allocated "`headroom`" in the message if +TIP: These functions make use of pre-allocated "`headroom`" in the message if available, so it can often avoid performing any reallocation. Applications should use this instead of reallocating and copying message content themselves, in order to benefit from this capability. == RETURN VALUES -This function returns 0 on success, and non-zero otherwise. +These functions return 0 on success, and non-zero otherwise. == ERRORS diff --git a/docs/man/nng_msg_trim.3.adoc b/docs/man/nng_msg_trim.3.adoc index a599b13c..644b6f44 100644 --- a/docs/man/nng_msg_trim.3.adoc +++ b/docs/man/nng_msg_trim.3.adoc @@ -11,7 +11,7 @@ == NAME -nng_msg_trim, nng_msg_trim_u32 - remove data from start of message body +nng_msg_trim - remove data from start of message body == SYNOPSIS @@ -20,22 +20,24 @@ nng_msg_trim, nng_msg_trim_u32 - remove data from start of message body #include <nng/nng.h> int nng_msg_trim(nng_msg *msg, size_t size); - +int nng_msg_trim_u16(nng_msg *msg, uint16_t *val16); int nng_msg_trim_u32(nng_msg *msg, uint32_t *val32); +int nng_msg_trim_u64(nng_msg *msg, uint64_t *val64); ---- == DESCRIPTION -The `nng_msg_trim()` and `nng_msg_trim_u32()` functions remove data from +The `nng_msg_trim()` family of functions removes data from the start of the body of message _msg_. The first function removes _size_ bytes. -The second function removes 4 bytes, and stores them in the value _val32_, +The remaining functions remove 2, 4, or 8 bytes, and stores them in the value +(such as _val32_), after converting them from network-byte order (big-endian) to native byte order. == RETURN VALUES -This function returns 0 on success, and non-zero otherwise. +These functions return 0 on success, and non-zero otherwise. == ERRORS diff --git a/src/core/message.c b/src/core/message.c index f17240a4..f3151230 100644 --- a/src/core/message.c +++ b/src/core/message.c @@ -286,6 +286,42 @@ nni_chunk_insert(nni_chunk *ch, const void *data, size_t len) } static int +nni_chunk_insert_u16(nni_chunk *ch, uint16_t val) +{ + unsigned char buf[sizeof(uint16_t)]; + NNI_PUT16(buf, val); + return (nni_chunk_insert(ch, buf, sizeof(buf))); +} + +static int +nni_chunk_append_u16(nni_chunk *ch, uint16_t val) +{ + unsigned char buf[sizeof(uint16_t)]; + NNI_PUT16(buf, val); + return (nni_chunk_append(ch, buf, sizeof(buf))); +} + +static uint16_t +nni_chunk_trim_u16(nni_chunk *ch) +{ + uint16_t v; + NNI_ASSERT(ch->ch_len >= sizeof(v)); + NNI_GET16(ch->ch_ptr, v); + nni_chunk_trim(ch, sizeof(v)); + return (v); +} + +static uint16_t +nni_chunk_chop_u16(nni_chunk *ch) +{ + uint16_t v; + NNI_ASSERT(ch->ch_len >= sizeof(v)); + NNI_GET16(ch->ch_ptr + ch->ch_len - sizeof(v), v); + nni_chunk_chop(ch, sizeof(v)); + return (v); +} + +static int nni_chunk_insert_u32(nni_chunk *ch, uint32_t val) { unsigned char buf[sizeof(uint32_t)]; @@ -321,6 +357,42 @@ nni_chunk_chop_u32(nni_chunk *ch) return (v); } +static int +nni_chunk_insert_u64(nni_chunk *ch, uint64_t val) +{ + unsigned char buf[sizeof(uint64_t)]; + NNI_PUT64(buf, val); + return (nni_chunk_insert(ch, buf, sizeof(buf))); +} + +static int +nni_chunk_append_u64(nni_chunk *ch, uint64_t val) +{ + unsigned char buf[sizeof(uint64_t)]; + NNI_PUT64(buf, val); + return (nni_chunk_append(ch, buf, sizeof(buf))); +} + +static uint64_t +nni_chunk_trim_u64(nni_chunk *ch) +{ + uint64_t v; + NNI_ASSERT(ch->ch_len >= sizeof(v)); + NNI_GET64(ch->ch_ptr, v); + nni_chunk_trim(ch, sizeof(v)); + return (v); +} + +static uint64_t +nni_chunk_chop_u64(nni_chunk *ch) +{ + uint64_t v; + NNI_ASSERT(ch->ch_len >= sizeof(v)); + NNI_GET64(ch->ch_ptr + ch->ch_len - sizeof(v), v); + nni_chunk_chop(ch, sizeof(v)); + return (v); +} + int nni_msg_alloc(nni_msg **mp, size_t sz) { @@ -558,52 +630,40 @@ nni_msg_header_chop(nni_msg *m, size_t len) return (nni_chunk_chop(&m->m_header, len)); } -int -nni_msg_append_u32(nni_msg *m, uint32_t val) -{ - return (nni_chunk_append_u32(&m->m_body, val)); -} - -int -nni_msg_insert_u32(nni_msg *m, uint32_t val) -{ - return (nni_chunk_insert_u32(&m->m_body, val)); -} - -int -nni_msg_header_append_u32(nni_msg *m, uint32_t val) -{ - return (nni_chunk_append_u32(&m->m_header, val)); -} - -int -nni_msg_header_insert_u32(nni_msg *m, uint32_t val) -{ - return (nni_chunk_insert_u32(&m->m_header, val)); -} - -uint32_t -nni_msg_chop_u32(nni_msg *m) -{ - return (nni_chunk_chop_u32(&m->m_body)); -} - -uint32_t -nni_msg_trim_u32(nni_msg *m) -{ - return (nni_chunk_trim_u32(&m->m_body)); -} - -uint32_t -nni_msg_header_chop_u32(nni_msg *m) -{ - return (nni_chunk_chop_u32(&m->m_header)); -} -uint32_t -nni_msg_header_trim_u32(nni_msg *m) -{ - return (nni_chunk_trim_u32(&m->m_header)); -} +#define DEF_MSG_ADD_N(z, x) \ + int nni_msg_##z##_u##x(nni_msg *m, uint##x##_t v) \ + { \ + return (nni_chunk_##z##_u##x(&m->m_body, v)); \ + } \ + int nni_msg_header_##z##_u##x(nni_msg *m, uint##x##_t v) \ + { \ + return (nni_chunk_##z##_u##x(&m->m_header, v)); \ + } + +#define DEF_MSG_REM_N(z, x) \ + uint##x##_t nni_msg_##z##_u##x(nni_msg *m) \ + { \ + return (nni_chunk_##z##_u##x(&m->m_body)); \ + } \ + uint##x##_t nni_msg_header_##z##_u##x(nni_msg *m) \ + { \ + return (nni_chunk_##z##_u##x(&m->m_header)); \ + } + +#define DEF_MSG_ADD(op) \ + DEF_MSG_ADD_N(op, 16) DEF_MSG_ADD_N(op, 32) DEF_MSG_ADD_N(op, 64) +#define DEF_MSG_REM(op) \ + DEF_MSG_REM_N(op, 16) DEF_MSG_REM_N(op, 32) DEF_MSG_REM_N(op, 64) + +DEF_MSG_ADD(append) +DEF_MSG_ADD(insert) +DEF_MSG_REM(chop) +DEF_MSG_REM(trim) + +#undef DEF_MSG_ADD_N +#undef DEF_MSG_REM_N +#undef DEF_MSG_ADD +#undef DEF_MSG_REM void nni_msg_clear(nni_msg *m) diff --git a/src/core/message.h b/src/core/message.h index 00d31436..5ec1d9a1 100644 --- a/src/core/message.h +++ b/src/core/message.h @@ -35,14 +35,30 @@ extern int nni_msg_header_chop(nni_msg *, size_t); extern int nni_msg_setopt(nni_msg *, int, const void *, size_t); extern int nni_msg_getopt(nni_msg *, int, void *, size_t *); extern void nni_msg_dump(const char *, const nni_msg *); +extern int nni_msg_append_u16(nni_msg *, uint16_t); extern int nni_msg_append_u32(nni_msg *, uint32_t); +extern int nni_msg_append_u64(nni_msg *, uint64_t); +extern int nni_msg_insert_u16(nni_msg *, uint16_t); extern int nni_msg_insert_u32(nni_msg *, uint32_t); +extern int nni_msg_insert_u64(nni_msg *, uint64_t); +extern int nni_msg_header_append_u16(nni_msg *, uint16_t); extern int nni_msg_header_append_u32(nni_msg *, uint32_t); +extern int nni_msg_header_append_u64(nni_msg *, uint64_t); +extern int nni_msg_header_insert_u16(nni_msg *, uint16_t); extern int nni_msg_header_insert_u32(nni_msg *, uint32_t); +extern int nni_msg_header_insert_u64(nni_msg *, uint64_t); +extern uint16_t nni_msg_trim_u16(nni_msg *); extern uint32_t nni_msg_trim_u32(nni_msg *); +extern uint64_t nni_msg_trim_u64(nni_msg *); +extern uint16_t nni_msg_chop_u16(nni_msg *); extern uint32_t nni_msg_chop_u32(nni_msg *); +extern uint64_t nni_msg_chop_u64(nni_msg *); +extern uint16_t nni_msg_header_trim_u16(nni_msg *); extern uint32_t nni_msg_header_trim_u32(nni_msg *); +extern uint64_t nni_msg_header_trim_u64(nni_msg *); +extern uint16_t nni_msg_header_chop_u16(nni_msg *); extern uint32_t nni_msg_header_chop_u32(nni_msg *); +extern uint64_t nni_msg_header_chop_u64(nni_msg *); extern void nni_msg_set_pipe(nni_msg *, uint32_t); extern uint32_t nni_msg_get_pipe(const nni_msg *); @@ -1329,69 +1329,47 @@ nng_msg_header_append(nng_msg *msg, const void *data, size_t sz) return (nni_msg_header_append(msg, data, sz)); } -int -nng_msg_header_append_u32(nng_msg *msg, uint32_t val) -{ - return (nni_msg_header_append_u32(msg, val)); -} - -int -nng_msg_header_insert_u32(nng_msg *msg, uint32_t val) -{ - return (nni_msg_header_insert_u32(msg, val)); -} - -int -nng_msg_header_chop_u32(nng_msg *msg, uint32_t *valp) -{ - if (nni_msg_header_len(msg) < sizeof(uint32_t)) { - return (NNG_EINVAL); - } - *valp = nni_msg_header_chop_u32(msg); - return (0); -} - -int -nng_msg_header_trim_u32(nng_msg *msg, uint32_t *valp) -{ - if (nni_msg_header_len(msg) < sizeof(uint32_t)) { - return (NNG_EINVAL); - } - *valp = nni_msg_header_trim_u32(msg); - return (0); -} - -int -nng_msg_append_u32(nng_msg *msg, uint32_t val) -{ - return (nni_msg_append_u32(msg, val)); -} - -int -nng_msg_insert_u32(nng_msg *msg, uint32_t val) -{ - return (nni_msg_insert_u32(msg, val)); -} - -int -nng_msg_chop_u32(nng_msg *msg, uint32_t *valp) -{ - if (nni_msg_len(msg) < sizeof(uint32_t)) { - return (NNG_EINVAL); - } - *valp = nni_msg_chop_u32(msg); - return (0); -} - -int -nng_msg_trim_u32(nng_msg *msg, uint32_t *valp) -{ - if (nni_msg_len(msg) < sizeof(uint32_t)) { - return (NNG_EINVAL); - } - *valp = nni_msg_trim_u32(msg); - return (0); -} +#define DEF_MSG_ADD_N(op, n) \ + int nng_msg_header_##op##_u##n(nng_msg *m, uint##n##_t v) \ + { \ + return (nni_msg_header_##op##_u##n(m, v)); \ + } \ + int nng_msg_##op##_u##n(nng_msg *m, uint##n##_t v) \ + { \ + return (nni_msg_##op##_u##n(m, v)); \ + } +#define DEF_MSG_REM_N(op, n) \ + int nng_msg_header_##op##_u##n(nng_msg *m, uint##n##_t *vp) \ + { \ + if (nni_msg_header_len(m) < sizeof(*vp)) { \ + return (NNG_EINVAL); \ + } \ + *vp = nni_msg_header_##op##_u##n(m); \ + return (0); \ + } \ + int nng_msg_##op##_u##n(nng_msg *m, uint##n##_t *vp) \ + { \ + if (nni_msg_len(m) < sizeof(*vp)) { \ + return (NNG_EINVAL); \ + } \ + *vp = nni_msg_##op##_u##n(m); \ + return (0); \ + } + +#define DEF_MSG_ADD(op) \ + DEF_MSG_ADD_N(op, 16) DEF_MSG_ADD_N(op, 32) DEF_MSG_ADD_N(op, 64) +#define DEF_MSG_REM(op) \ + DEF_MSG_REM_N(op, 16) DEF_MSG_REM_N(op, 32) DEF_MSG_REM_N(op, 64) + +DEF_MSG_ADD(append) +DEF_MSG_ADD(insert) +DEF_MSG_REM(chop) +DEF_MSG_REM(trim) + +#undef DEF_MSG_ADD_N +#undef DEF_MSG_REM_N +#undef DEF_MSG_ADD +#undef DEF_MSG_REM int nng_msg_header_insert(nng_msg *msg, const void *data, size_t sz) @@ -610,19 +610,34 @@ NNG_DECL int nng_msg_header_append(nng_msg *, const void *, size_t); NNG_DECL int nng_msg_header_insert(nng_msg *, const void *, size_t); NNG_DECL int nng_msg_header_trim(nng_msg *, size_t); NNG_DECL int nng_msg_header_chop(nng_msg *, size_t); +NNG_DECL int nng_msg_header_append_u16(nng_msg *, uint16_t); NNG_DECL int nng_msg_header_append_u32(nng_msg *, uint32_t); +NNG_DECL int nng_msg_header_append_u64(nng_msg *, uint64_t); +NNG_DECL int nng_msg_header_insert_u16(nng_msg *, uint16_t); NNG_DECL int nng_msg_header_insert_u32(nng_msg *, uint32_t); +NNG_DECL int nng_msg_header_insert_u64(nng_msg *, uint64_t); +NNG_DECL int nng_msg_header_chop_u16(nng_msg *, uint16_t *); NNG_DECL int nng_msg_header_chop_u32(nng_msg *, uint32_t *); +NNG_DECL int nng_msg_header_chop_u64(nng_msg *, uint64_t *); +NNG_DECL int nng_msg_header_trim_u16(nng_msg *, uint16_t *); NNG_DECL int nng_msg_header_trim_u32(nng_msg *, uint32_t *); +NNG_DECL int nng_msg_header_trim_u64(nng_msg *, uint64_t *); +NNG_DECL int nng_msg_append_u16(nng_msg *, uint16_t); NNG_DECL int nng_msg_append_u32(nng_msg *, uint32_t); +NNG_DECL int nng_msg_append_u64(nng_msg *, uint64_t); +NNG_DECL int nng_msg_insert_u16(nng_msg *, uint16_t); NNG_DECL int nng_msg_insert_u32(nng_msg *, uint32_t); +NNG_DECL int nng_msg_insert_u64(nng_msg *, uint64_t); +NNG_DECL int nng_msg_chop_u16(nng_msg *, uint16_t *); NNG_DECL int nng_msg_chop_u32(nng_msg *, uint32_t *); +NNG_DECL int nng_msg_chop_u64(nng_msg *, uint64_t *); +NNG_DECL int nng_msg_trim_u16(nng_msg *, uint16_t *); NNG_DECL int nng_msg_trim_u32(nng_msg *, uint32_t *); - -NNG_DECL int nng_msg_dup(nng_msg **, const nng_msg *); -NNG_DECL void nng_msg_clear(nng_msg *); -NNG_DECL void nng_msg_header_clear(nng_msg *); -NNG_DECL void nng_msg_set_pipe(nng_msg *, nng_pipe); +NNG_DECL int nng_msg_trim_u64(nng_msg *, uint64_t *); +NNG_DECL int nng_msg_dup(nng_msg **, const nng_msg *); +NNG_DECL void nng_msg_clear(nng_msg *); +NNG_DECL void nng_msg_header_clear(nng_msg *); +NNG_DECL void nng_msg_set_pipe(nng_msg *, nng_pipe); NNG_DECL nng_pipe nng_msg_get_pipe(const nng_msg *); NNG_DECL int nng_msg_getopt(nng_msg *, int, void *, size_t *); |
