diff options
| author | Garrett D'Amore <garrett@damore.org> | 2024-03-26 23:09:01 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2024-03-26 23:09:01 -0700 |
| commit | 43331fdf0e5cf98e6aa553985df5113a8a7718f6 (patch) | |
| tree | 7da1501077e10eaeb53ce387cf90fb4e3a9d6184 /docs/reference | |
| parent | 90b02493491e7ea6f962081efde4e29a1fd794c4 (diff) | |
| download | nng-43331fdf0e5cf98e6aa553985df5113a8a7718f6.tar.gz nng-43331fdf0e5cf98e6aa553985df5113a8a7718f6.tar.bz2 nng-43331fdf0e5cf98e6aa553985df5113a8a7718f6.zip | |
Finished the nng_msg_ pages
Diffstat (limited to 'docs/reference')
27 files changed, 519 insertions, 723 deletions
diff --git a/docs/reference/src/SUMMARY.md b/docs/reference/src/SUMMARY.md index 81d2f24c..aa705d44 100644 --- a/docs/reference/src/SUMMARY.md +++ b/docs/reference/src/SUMMARY.md @@ -29,6 +29,19 @@ - [nng_msg_clear](api/msg/nng_msg_clear.md) - [nng_msg_dup](api/msg/nng_msg_dup.md) - [nng_msg_free](api/msg/nng_msg_free.md) + - [nng_msg_get_pipe](api/msg/nng_msg_get_pipe.md) + - [nng_msg_header](api/msg/nng_msg_header.md) + - [nng_msg_header_append](api/msg/nng_msg_header_append.md) + - [nng_msg_header_chop](api/msg/nng_msg_header_chop.md) + - [nng_msg_header_clear](api/msg/nng_msg_header_clear.md) + - [nng_msg_header_insert](api/msg/nng_msg_header_insert.md) + - [nng_msg_header_len](api/msg/nng_msg_header_len.md) + - [nng_msg_header_trim](api/msg/nng_msg_header_trim.md) + - [nng_msg_insert](api/msg/nng_msg_insert.md) + - [nng_msg_len](api/msg/nng_msg_len.md) + - [nng_msg_realloc](api/msg/nng_msg_realloc.md) + - [nng_msg_reserve](api/msg/nng_msg_reserve.md) + - [nng_msg_set_pipe](api/msg/nng_msg_set_pipe.md) - [nng_msg_trim](api/msg/nng_msg_trim.md) - [Sockets](api/socket/index.md) diff --git a/docs/reference/src/api/msg/nng_msg_get_pipe.3.adoc b/docs/reference/src/api/msg/nng_msg_get_pipe.3.adoc deleted file mode 100644 index 154f4c43..00000000 --- a/docs/reference/src/api/msg/nng_msg_get_pipe.3.adoc +++ /dev/null @@ -1,60 +0,0 @@ -= nng_msg_get_pipe(3) -// -// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech> -// Copyright 2018 Capitar IT Group BV <info@capitar.com> -// -// This document is supplied under the terms of the MIT License, a -// copy of which should be located in the distribution where this -// file was obtained (LICENSE.txt). A copy of the license may also be -// found online at https://opensource.org/licenses/MIT. -// - -== NAME - -nng_msg_get_pipe - get pipe for message - -== SYNOPSIS - -[source, c] ----- -#include <nng/nng.h> - -nng_pipe nng_msg_get_pipe(nng_msg *msg); ----- - -== DESCRIPTION - -The `nng_msg_get_pipe()` returns the xref:nng_pipe.5.adoc[`nng_pipe`] object -associated with message _msg_. -On receive, this is the pipe from which a message was received. -On transmit, this would be the pipe that the message should be delivered -to, if a specific peer is required. - -NOTE: Not all protocols support overriding the destination pipe. - -The most usual use case for this is to obtain information about the peer -from which the message was received. -This can be used to provide different behaviors for different peers, such as -a higher level of authentication for peers located on an untrusted network. -The xref:nng_pipe_getopt.3.adoc[`nng_pipe_getopt()`] function -is useful in this situation. - - -== RETURN VALUES - -This function returns the pipe associated with this message, which will -be a positive value. -If the pipe is non-positive, then that indicates that -no specific pipe is associated with the message. - -== ERRORS - -None. - -== SEE ALSO - -[.text-left] -xref:nng_msg_alloc.3.adoc[nng_msg_alloc(3)], -xref:nng_msg_set_pipe.3.adoc[nng_msg_set_pipe(3)], -xref:nng_pipe_getopt.3.adoc[nng_pipe_getopt(3)], -xref:nng.7.adoc[nng(7)] diff --git a/docs/reference/src/api/msg/nng_msg_get_pipe.md b/docs/reference/src/api/msg/nng_msg_get_pipe.md new file mode 100644 index 00000000..5f935347 --- /dev/null +++ b/docs/reference/src/api/msg/nng_msg_get_pipe.md @@ -0,0 +1,44 @@ +# nng_msg_get_pipe + +## NAME + +nng_msg_get_pipe --- get pipe for message + +## SYNOPSIS + +```c +#include <nng/nng.h> + +nng_pipe nng_msg_get_pipe(nng_msg *msg); +``` + +## DESCRIPTION + +The `nng_msg_get_pipe()` returns the [`nng_pipe`](../conn/nng_pipe.md) object +associated with message _msg_. +On receive, this is the pipe from which a message was received. +On transmit, this would be the pipe that the message should be delivered +to, if a specific peer is required. + +> [!NOTE] +> Not all protocols support overriding the destination pipe. + +The most usual use case for this is to obtain information about the peer +from which the message was received. +This can be used to provide different behaviors for different peers, such as +a higher level of authentication for peers located on an untrusted network. +The [`nng_pipe_get()`](../conn/nng_pipe_get.md) function +is useful in this situation. + +## RETURN VALUES + +This function returns the pipe associated with this message, which will +be a positive value. +If the pipe is non-positive, then that indicates that +no specific pipe is associated with the message. + +## SEE ALSO + +[nng_msg_alloc](nng_msg_alloc.md), +[nng_msg_set_pipe](nng_msg_set_pipe.md), +[nng_pipe_get](../conn/nng_pipe_get.md) diff --git a/docs/reference/src/api/msg/nng_msg_header.3.adoc b/docs/reference/src/api/msg/nng_msg_header.3.adoc deleted file mode 100644 index eac45ffd..00000000 --- a/docs/reference/src/api/msg/nng_msg_header.3.adoc +++ /dev/null @@ -1,58 +0,0 @@ -= nng_msg_header(3) -// -// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech> -// Copyright 2018 Capitar IT Group BV <info@capitar.com> -// -// This document is supplied under the terms of the MIT License, a -// copy of which should be located in the distribution where this -// file was obtained (LICENSE.txt). A copy of the license may also be -// found online at https://opensource.org/licenses/MIT. -// - -== NAME - -nng_msg_header - return message header - -== SYNOPSIS - -[source, c] ----- -#include <nng/nng.h> - -void *nng_msg_header(nng_msg *msg); ----- - -== DESCRIPTION - -The `nng_msg_header()` function returns a pointer to the start of the header -content of the message _msg_. - -NOTE: The message header contains protocol-specific header content. Most -applications should not need to access this content, but it is available -for raw mode sockets (set with the -xref:nng_options.5.adoc#NNG_OPT_RAW[`NNG_OPT_RAW`] option.) - -NOTE: The value returned by this is invalidated by a call to any of the -functions that modify the message or the header content. - -== RETURN VALUES - -Pointer to start of message header. - -== ERRORS - -None. - -== SEE ALSO - -[.text-left] -xref:nng_msg_alloc.3.adoc[nng_msg_alloc(3)], -xref:nng_msg_body.3.adoc[nng_msg_body(3)], -xref:nng_msg_free.3.adoc[nng_msg_free(3)], -xref:nng_msg_header_append.3.adoc[nng_msg_header_append(3)], -xref:nng_msg_header_chop.3.adoc[nng_msg_header_chop(3)], -xref:nng_msg_header_insert.3.adoc[nng_msg_header_insert(3)] -xref:nng_msg_header_len.3.adoc[nng_msg_header_len(3)], -xref:nng_msg_header_trim.3.adoc[nng_msg_header_trim(3)], -xref:nng_msg.5.adoc[nng_msg(5)], -xref:nng.7.adoc[nng(7)] diff --git a/docs/reference/src/api/msg/nng_msg_header.md b/docs/reference/src/api/msg/nng_msg_header.md new file mode 100644 index 00000000..7a75464d --- /dev/null +++ b/docs/reference/src/api/msg/nng_msg_header.md @@ -0,0 +1,42 @@ +# nng_msg_header + +## NAME + +nng_msg_header --- return message header + +## SYNOPSIS + +```c +#include <nng/nng.h> + +void *nng_msg_header(nng_msg *msg); +``` + +## DESCRIPTION + +The `nng_msg_header()` function returns a pointer to the start of the header +content of the message _msg_. + +> [!NOTE] +> The message header contains protocol-specific header content. Most +> applications should not need to access this content, but it is available +> for [raw](../../overview/raw.md) mode sockets. + +> [!NOTE] +> The value returned by this is invalidated by a call to any of the +> functions that modify the message or the header content. + +## RETURN VALUES + +Pointer to start of message header. + +## SEE ALSO + +[nng_msg_alloc](nng_msg_alloc.md), +[nng_msg_body](nng_msg_body.md), +[nng_msg_free](nng_msg_free.md), +[nng_msg_header_append](nng_msg_header_append.md), +[nng_msg_header_chop](nng_msg_header_chop.md), +[nng_msg_header_insert](nng_msg_header_insert.md) +[nng_msg_header_len](nng_msg_header_len.md), +[nng_msg_header_trim](nng_msg_header_trim.md) diff --git a/docs/reference/src/api/msg/nng_msg_header_append.3.adoc b/docs/reference/src/api/msg/nng_msg_header_append.3.adoc deleted file mode 100644 index 16badf0b..00000000 --- a/docs/reference/src/api/msg/nng_msg_header_append.3.adoc +++ /dev/null @@ -1,58 +0,0 @@ -= nng_msg_header_append(3) -// -// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech> -// Copyright 2018 Capitar IT Group BV <info@capitar.com> -// -// This document is supplied under the terms of the MIT License, a -// copy of which should be located in the distribution where this -// file was obtained (LICENSE.txt). A copy of the license may also be -// found online at https://opensource.org/licenses/MIT. -// - -== NAME - -nng_msg_header_append - append to message header - -== SYNOPSIS - -[source, c] ----- -#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()` 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 remaining functions append the value (such as _val32_) in -network-byte order (big-endian). - - -== RETURN VALUES - -These functions return 0 on success, and non-zero otherwise. - -== ERRORS - -[horizontal] -`NNG_ENOMEM`:: Insufficient free memory exists. - -== SEE ALSO - -[.text-left] -xref:nng_msg_alloc.3.adoc[nng_msg_alloc(3)], -xref:nng_msg_header.3.adoc[nng_msg_header(3)], -xref:nng_msg_header_chop.3.adoc[nng_msg_header_chop(3)], -xref:nng_msg_header_insert.3.adoc[nng_msg_header_insert(3)], -xref:nng_msg_header_len.3.adoc[nng_msg_header_len(3)], -xref:nng_msg_header_trim.3.adoc[nng_msg_header_trim(3)], -xref:nng_msg_free.3.adoc[nng_msg_free(3)], -xref:nng_strerror.3.adoc[nng_strerror(3)], -xref:nng.7.adoc[nng(7)] diff --git a/docs/reference/src/api/msg/nng_msg_header_append.md b/docs/reference/src/api/msg/nng_msg_header_append.md new file mode 100644 index 00000000..f87649a5 --- /dev/null +++ b/docs/reference/src/api/msg/nng_msg_header_append.md @@ -0,0 +1,41 @@ +# nng_msg_header_append + +## NAME + +nng_msg_header_append --- append to message header + +## SYNOPSIS + +```c +#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()` 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 remaining functions append the value (such as _val32_) in +network-byte order (big-endian). + +## RETURN VALUES + +These functions return 0 on success, and non-zero otherwise. + +## ERRORS + +- `NNG_ENOMEM`: Insufficient free memory exists. + +## SEE ALSO + +[nng_msg_header](nng_msg_body.md), +[nng_msg_header_chop](nng_msg_header_chop.md), +[nng_msg_header_insert](nng_msg_header_insert.md) +[nng_msg_header_len](nng_msg_header_len.md), +[nng_msg_header_trim](nng_msg_header_trim.md) diff --git a/docs/reference/src/api/msg/nng_msg_header_chop.3.adoc b/docs/reference/src/api/msg/nng_msg_header_chop.3.adoc deleted file mode 100644 index 454e9e51..00000000 --- a/docs/reference/src/api/msg/nng_msg_header_chop.3.adoc +++ /dev/null @@ -1,58 +0,0 @@ -= nng_msg_header_chop(3) -// -// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech> -// Copyright 2018 Capitar IT Group BV <info@capitar.com> -// -// This document is supplied under the terms of the MIT License, a -// copy of which should be located in the distribution where this -// file was obtained (LICENSE.txt). A copy of the license may also be -// found online at https://opensource.org/licenses/MIT. -// - -== NAME - -nng_msg_header_chop - remove data from end of message header - -== SYNOPSIS - -[source, c] ----- -#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()` family of functions removes -data from the end of the header of message _msg_. -The first function removes _size_ bytes. -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 - -These function return 0 on success, and non-zero otherwise. - -== ERRORS - -[horizontal] -`NNG_EINVAL`:: The message header is too short to remove the requested data. - -== SEE ALSO - -[.text-left] -xref:nng_msg_alloc.3.adoc[nng_msg_alloc(3)], -xref:nng_msg_header.3.adoc[nng_msg_header(3)], -xref:nng_msg_header_append.3.adoc[nng_msg_header_append(3)], -xref:nng_msg_header_insert.3.adoc[nng_msg_header_insert(3)], -xref:nng_msg_header_len.3.adoc[nng_msg_header_len(3)], -xref:nng_msg_header_trim.3.adoc[nng_msg_header_trim(3)], -xref:nng_msg_free.3.adoc[nng_msg_free(3)], -xref:nng_strerror.3.adoc[nng_strerror(3)], -xref:nng.7.adoc[nng(7)] diff --git a/docs/reference/src/api/msg/nng_msg_header_chop.md b/docs/reference/src/api/msg/nng_msg_header_chop.md new file mode 100644 index 00000000..9419d88f --- /dev/null +++ b/docs/reference/src/api/msg/nng_msg_header_chop.md @@ -0,0 +1,42 @@ +# nng_msg_header_chop + +## NAME + +nng_msg_header_chop --- remove data from end of message header + +## SYNOPSIS + +```c +#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()` family of functions removes +data from the end of the header of message _msg_. +The first function removes _size_ bytes. +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 + +These function return 0 on success, and non-zero otherwise. + +## ERRORS + +- `NNG_EINVAL`: The message header is too short to remove the requested data. + +## SEE ALSO + +[nng_msg_header](nng_msg_body.md), +[nng_msg_header_append](nng_msg_header_append.md), +[nng_msg_header_insert](nng_msg_header_insert.md) +[nng_msg_header_len](nng_msg_header_len.md), +[nng_msg_header_trim](nng_msg_header_trim.md) diff --git a/docs/reference/src/api/msg/nng_msg_header_clear.3.adoc b/docs/reference/src/api/msg/nng_msg_header_clear.3.adoc deleted file mode 100644 index d00286ed..00000000 --- a/docs/reference/src/api/msg/nng_msg_header_clear.3.adoc +++ /dev/null @@ -1,42 +0,0 @@ -= nng_msg_header_clear(3) -// -// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech> -// Copyright 2018 Capitar IT Group BV <info@capitar.com> -// -// This document is supplied under the terms of the MIT License, a -// copy of which should be located in the distribution where this -// file was obtained (LICENSE.txt). A copy of the license may also be -// found online at https://opensource.org/licenses/MIT. -// - -== NAME - -nng_msg_header_clear - clear message header - -== SYNOPSIS - -[source, c] ----- -#include <nng/nng.h> - -void nng_msg_header_clear(nng_msg *msg); ----- - -== DESCRIPTION - -The `nng_msg_clear()` function resets the header length of _msg_ to zero. - -== RETURN VALUES - -None. - -== ERRORS - -None. - -== SEE ALSO - -[.text-left] -xref:nng_msg_alloc.3.adoc[nng_msg_alloc(3)], -xref:nng_msg_free.3.adoc[nng_msg_free(3)], -xref:nng.7.adoc[nng(7)] diff --git a/docs/reference/src/api/msg/nng_msg_header_clear.md b/docs/reference/src/api/msg/nng_msg_header_clear.md new file mode 100644 index 00000000..7f3b8387 --- /dev/null +++ b/docs/reference/src/api/msg/nng_msg_header_clear.md @@ -0,0 +1,22 @@ +# nng_msg_header_clear + +## NAME + +nng_msg_header_clear --- clear message header + +## SYNOPSIS + +```c +#include <nng/nng.h> + +void nng_msg_header_clear(nng_msg *msg); +``` + +## DESCRIPTION + +The `nng_msg_clear()` function resets the header length of _msg_ to zero. + +## SEE ALSO + +[nng_msg_header](nng_msg_header.md), +[nng_msg_header_len](nng_msg_header_len.md) diff --git a/docs/reference/src/api/msg/nng_msg_header_insert.3.adoc b/docs/reference/src/api/msg/nng_msg_header_insert.3.adoc deleted file mode 100644 index a2bf0d63..00000000 --- a/docs/reference/src/api/msg/nng_msg_header_insert.3.adoc +++ /dev/null @@ -1,60 +0,0 @@ -= nng_msg_header_insert(3) -// -// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech> -// Copyright 2018 Capitar IT Group BV <info@capitar.com> -// -// This document is supplied under the terms of the MIT License, a -// copy of which should be located in the distribution where this -// file was obtained (LICENSE.txt). A copy of the license may also be -// found online at https://opensource.org/licenses/MIT. -// - -== NAME - -nng_msg_header_insert - prepend to message header - -== SYNOPSIS - -[source, c] ----- -#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()` 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 remaining functions prepend the specified value (such as _val32_) in -network-byte order (big-endian). - -== RETURN VALUES - -These functions return 0 on success, and non-zero otherwise. - -== ERRORS - -[horizontal] -`NNG_ENOMEM`:: Insufficient free memory exists. - -== SEE ALSO - -[.text-left] -xref:nng_msg_alloc.3.adoc[nng_msg_alloc(3)], -xref:nng_msg_header.3.adoc[nng_msg_header(3)], -xref:nng_msg_header_append.3.adoc[nng_msg_header_append(3)], -xref:nng_msg_header_chop.3.adoc[nng_msg_header_chop(3)], -xref:nng_msg_header_len.3.adoc[nng_msg_header_len(3)], -xref:nng_msg_header_trim.3.adoc[nng_msg_header_trim(3)], -xref:nng_msg_free.3.adoc[nng_msg_free(3)], -xref:nng_msg_capacity.3.adoc[nng_msg_capacity(3)], -xref:nng_msg_reserve.3.adoc[nng_msg_reserve(3)], -xref:nng_msg_realloc.3.adoc[nng_msg_realloc(3)], -xref:nng_strerror.3.adoc[nng_strerror(3)], -xref:nng.7.adoc[nng(7)] diff --git a/docs/reference/src/api/msg/nng_msg_header_insert.md b/docs/reference/src/api/msg/nng_msg_header_insert.md new file mode 100644 index 00000000..07124fd9 --- /dev/null +++ b/docs/reference/src/api/msg/nng_msg_header_insert.md @@ -0,0 +1,41 @@ +# nng_msg_header_insert + +## NAME + +nng_msg_header_insert --- prepend to message header + +## SYNOPSIS + +```c +#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()` 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 remaining functions prepend the specified value (such as _val32_) in +network-byte order (big-endian). + +## RETURN VALUES + +These functions return 0 on success, and non-zero otherwise. + +## ERRORS + +- `NNG_ENOMEM`: Insufficient free memory exists. + +## SEE ALSO + +[nng_msg_header](nng_msg_body.md), +[nng_msg_header_append](nng_msg_header_append.md) +[nng_msg_header_chop](nng_msg_header_chop.md), +[nng_msg_header_len](nng_msg_header_len.md), +[nng_msg_header_trim](nng_msg_header_trim.md) diff --git a/docs/reference/src/api/msg/nng_msg_header_len.3.adoc b/docs/reference/src/api/msg/nng_msg_header_len.3.adoc deleted file mode 100644 index 0a7b3613..00000000 --- a/docs/reference/src/api/msg/nng_msg_header_len.3.adoc +++ /dev/null @@ -1,43 +0,0 @@ -= nng_msg_header_len(3) -// -// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech> -// Copyright 2018 Capitar IT Group BV <info@capitar.com> -// -// This document is supplied under the terms of the MIT License, a -// copy of which should be located in the distribution where this -// file was obtained (LICENSE.txt). A copy of the license may also be -// found online at https://opensource.org/licenses/MIT. -// - -== NAME - -nng_msg_header_len - return message header length - -== SYNOPSIS - -[source, c] ----- -#include <nng/nng.h> - -size_t nng_msg_header_len(nng_msg *msg); ----- - -== DESCRIPTION - -The `nng_msg_header_len()` returns the length of message header of _msg_. - -== RETURN VALUES - -Length of message header. - -== ERRORS - -None. - -== SEE ALSO - -[.text-left] -xref:nng_msg_alloc.3.adoc[nng_msg_alloc(3)], -xref:nng_msg_header.3.adoc[nng_msg_header(3)], -xref:nng_msg.5.adoc[nng_msg(5)], -xref:nng.7.adoc[nng(7)] diff --git a/docs/reference/src/api/msg/nng_msg_header_len.md b/docs/reference/src/api/msg/nng_msg_header_len.md new file mode 100644 index 00000000..51bbf537 --- /dev/null +++ b/docs/reference/src/api/msg/nng_msg_header_len.md @@ -0,0 +1,25 @@ +# nng_msg_header_len + +## NAME + +nng_msg_header_len --- return message header length + +## SYNOPSIS + +```c +#include <nng/nng.h> + +size_t nng_msg_header_len(nng_msg *msg); +``` + +## DESCRIPTION + +The `nng_msg_header_len()` returns the length of message header of _msg_. + +## RETURN VALUES + +Length of message header. + +## SEE ALSO + +[nng_msg_header](nng_msg_header) diff --git a/docs/reference/src/api/msg/nng_msg_header_trim.3.adoc b/docs/reference/src/api/msg/nng_msg_header_trim.3.adoc deleted file mode 100644 index 6df504ff..00000000 --- a/docs/reference/src/api/msg/nng_msg_header_trim.3.adoc +++ /dev/null @@ -1,59 +0,0 @@ -= nng_msg_header_trim(3) -// -// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech> -// Copyright 2018 Capitar IT Group BV <info@capitar.com> -// -// This document is supplied under the terms of the MIT License, a -// copy of which should be located in the distribution where this -// file was obtained (LICENSE.txt). A copy of the license may also be -// found online at https://opensource.org/licenses/MIT. -// - -== NAME - -nng_msg_header_trim - remove data from start of message header - -== SYNOPSIS - -[source, c] ----- -#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()` family of functions remove -data from the start of the header of message _msg_. -The first function removes _size_ bytes. -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. - -== RETURN VALUES - -This function returns 0 on success, and non-zero otherwise. - -== ERRORS - -[horizontal] -`NNG_EINVAL`:: The message header is too short to remove the requested data. - -== SEE ALSO - -[.text-left] -xref:nng_msg_alloc.3.adoc[nng_msg_alloc(3)], -xref:nng_msg_header.3.adoc[nng_msg_header(3)], -xref:nng_msg_header_append.3.adoc[nng_msg_header_append(3)], -xref:nng_msg_header_chop.3.adoc[nng_msg_header_chop(3)], -xref:nng_msg_header_insert.3.adoc[nng_msg_header_insert(3)], -xref:nng_msg_header_len.3.adoc[nng_msg_header_len(3)], -xref:nng_msg_free.3.adoc[nng_msg_free(3)], -xref:nng_strerror.3.adoc[nng_strerror(3)], -xref:nng_msg.5.adoc[nng_msg(5)], -xref:nng.7.adoc[nng(7)] diff --git a/docs/reference/src/api/msg/nng_msg_header_trim.md b/docs/reference/src/api/msg/nng_msg_header_trim.md new file mode 100644 index 00000000..ef596dbc --- /dev/null +++ b/docs/reference/src/api/msg/nng_msg_header_trim.md @@ -0,0 +1,42 @@ +# nng_msg_header_trim + +## NAME + +nng_msg_header_trim --- remove data from start of message header + +## SYNOPSIS + +```c +#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()` family of functions remove +data from the start of the header of message _msg_. +The first function removes _size_ bytes. +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. + +## RETURN VALUES + +This function returns 0 on success, and non-zero otherwise. + +## ERRORS + +- `NNG_EINVAL`: The message header is too short to remove the requested data. + +## SEE ALSO + +[nng_msg_header](nng_msg_body.md), +[nng_msg_header_append](nng_msg_header_append.md), +[nng_msg_header_chop](nng_msg_header_chop.md) +[nng_msg_header_insert](nng_msg_header_insert.md) +[nng_msg_header_len](nng_msg_header_len.md), diff --git a/docs/reference/src/api/msg/nng_msg_insert.3.adoc b/docs/reference/src/api/msg/nng_msg_insert.3.adoc deleted file mode 100644 index 25f98fce..00000000 --- a/docs/reference/src/api/msg/nng_msg_insert.3.adoc +++ /dev/null @@ -1,63 +0,0 @@ -= nng_msg_insert(3) -// -// Copyright 2020 Staysail Systems, Inc. <info@staysail.tech> -// Copyright 2018 Capitar IT Group BV <info@capitar.com> -// -// This document is supplied under the terms of the MIT License, a -// copy of which should be located in the distribution where this -// file was obtained (LICENSE.txt). A copy of the license may also be -// found online at https://opensource.org/licenses/MIT. -// - -== NAME - -nng_msg_insert - prepend to message body - -== SYNOPSIS - -[source, c] ----- -#include <nng/nng.h> - -int nng_msg_insert(nng_msg *msg, const void *val, size_t size); -int nng_msg_insert_u16(nng_msg *msg, uint16_t val16); -int nng_msg_insert_u32(nng_msg *msg, uint32_t val32); -int nng_msg_insert_u64(nng_msg *msg, uint64_t val64); ----- - -== DESCRIPTION - -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 remaining functions prepend the specified value (such as _val32_) -in network-byte order (big-endian). - -TIP: These functions make use of space pre-allocated in front of the -message body if available, so they can often avoid performing any reallocation. -Applications should use these instead of reallocating and copying message -content themselves, in order to benefit from this capability. - -== RETURN VALUES - -These functions return 0 on success, and non-zero otherwise. - -== ERRORS - -[horizontal] -`NNG_ENOMEM`:: Insufficient free memory exists. - -== SEE ALSO - -[.text-left] -xref:nng_msg_alloc.3.adoc[nng_msg_alloc(3)], -xref:nng_msg_append.3.adoc[nng_msg_append(3)], -xref:nng_msg_body.3.adoc[nng_msg_body(3)], -xref:nng_msg_chop.3.adoc[nng_msg_chop(3)], -xref:nng_msg_free.3.adoc[nng_msg_free(3)], -xref:nng_msg_len.3.adoc[nng_msg_len(3)], -xref:nng_msg_realloc.3.adoc[nng_msg_realloc(3)], -xref:nng_msg_trim.3.adoc[nng_msg_trim(3)], -xref:nng_strerror.3.adoc[nng_strerror(3)], -xref:nng_msg.5.adoc[nng_msg(5)], -xref:nng.7.adoc[nng(7)] diff --git a/docs/reference/src/api/msg/nng_msg_insert.md b/docs/reference/src/api/msg/nng_msg_insert.md new file mode 100644 index 00000000..a369d3c4 --- /dev/null +++ b/docs/reference/src/api/msg/nng_msg_insert.md @@ -0,0 +1,53 @@ +# nng_msg_insert + +## NAME + +nng_msg_insert --- prepend to message body + +## SYNOPSIS + +```c +#include <nng/nng.h> + +int nng_msg_insert(nng_msg *msg, const void *val, size_t size); +int nng_msg_insert_u16(nng_msg *msg, uint16_t val16); +int nng_msg_insert_u32(nng_msg *msg, uint32_t val32); +int nng_msg_insert_u64(nng_msg *msg, uint64_t val64); +``` + +## DESCRIPTION + +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 remaining functions prepend the specified value (such as _val32_) +in network-byte order (big-endian). + +> [!TIP] +> These functions make use of space pre-allocated in front of the +> message body if available, so they can often avoid performing any reallocation. +> Applications should use these instead of reallocating and copying message +> content themselves, in order to benefit from this capability. + +## RETURN VALUES + +These functions return 0 on success, and non-zero otherwise. + +## ERRORS + +- `NNG_ENOMEM`: Insufficient free memory exists. + +## SEE ALSO + +[nng_msg_alloc](nng_msg_alloc.md), +[nng_msg_append](nng_msg_append.md), +[nng_msg_body](nng_msg_body.md), +[nng_msg_capacity](nng_msg_capacity.md), +[nng_msg_chop](nng_msg_chop.md), +[nng_msg_clear](nng_msg_chop.md), +[nng_msg_free](nng_msg_free.md), +[nng_msg_insert](nng_msg_insert.md), +[nng_msg_len](nng_msg_len.md), +[nng_msg_reserve](nng_msg_reserve.md), +[nng_msg_realloc](nng_msg_realloc.md), +[nng_msg_trim](nng_msg_trim.md) diff --git a/docs/reference/src/api/msg/nng_msg_len.3.adoc b/docs/reference/src/api/msg/nng_msg_len.3.adoc deleted file mode 100644 index 2a3dfe67..00000000 --- a/docs/reference/src/api/msg/nng_msg_len.3.adoc +++ /dev/null @@ -1,43 +0,0 @@ -= nng_msg_len(3) -// -// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech> -// Copyright 2018 Capitar IT Group BV <info@capitar.com> -// -// This document is supplied under the terms of the MIT License, a -// copy of which should be located in the distribution where this -// file was obtained (LICENSE.txt). A copy of the license may also be -// found online at https://opensource.org/licenses/MIT. -// - -== NAME - -nng_msg_len - return message body length - -== SYNOPSIS - -[source, c] ----- -#include <nng/nng.h> - -size_t nng_msg_len(nng_msg *msg); ----- - -== DESCRIPTION - -The `nng_msg_len()` returns the length of the body of message _msg_. - -== RETURN VALUES - -Length of message body. - -== ERRORS - -None. - -== SEE ALSO - -[.text-left] -xref:nng_msg_alloc.3.adoc[nng_msg_alloc(3)], -xref:nng_msg_body.3.adoc[nng_msg_body(3)], -xref:nng_msg.5.adoc[nng_msg(5)], -xref:nng.7.adoc[nng(7)] diff --git a/docs/reference/src/api/msg/nng_msg_len.md b/docs/reference/src/api/msg/nng_msg_len.md new file mode 100644 index 00000000..c470955c --- /dev/null +++ b/docs/reference/src/api/msg/nng_msg_len.md @@ -0,0 +1,26 @@ +# nng_msg_len + +## NAME + +nng_msg_len --- return message body length + +## SYNOPSIS + +```c +#include <nng/nng.h> + +size_t nng_msg_len(nng_msg *msg); +``` + +## DESCRIPTION + +The `nng_msg_len()` returns the length of the body of message _msg_. + +## RETURN VALUES + +Length of message body. + +## SEE ALSO + +[nng_msg_alloc](nng_msg_alloc), +[nng_msg_body](nng_msg_body) diff --git a/docs/reference/src/api/msg/nng_msg_realloc.3.adoc b/docs/reference/src/api/msg/nng_msg_realloc.3.adoc deleted file mode 100644 index bf407289..00000000 --- a/docs/reference/src/api/msg/nng_msg_realloc.3.adoc +++ /dev/null @@ -1,66 +0,0 @@ -= nng_msg_realloc(3) -// -// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech> -// Copyright 2018 Capitar IT Group BV <info@capitar.com> -// -// This document is supplied under the terms of the MIT License, a -// copy of which should be located in the distribution where this -// file was obtained (LICENSE.txt). A copy of the license may also be -// found online at https://opensource.org/licenses/MIT. -// - -== NAME - -nng_msg_realloc - reallocate a message - -== SYNOPSIS - -[source, c] ----- -#include <nng/nng.h> - -int nng_msg_realloc(nng_msg *msg, size_t size); ----- - -== DESCRIPTION - -The `nng_msg_realloc()` function re-allocates a message so that it has -a body of length _size_. -This message attempts to avoid extra allocations, -and will reuse the existing memory when possible. - -TIP: `nng_msg_realloc` is suitable for creating space for direct writing of data. -When appending many small pieces of data to a message using xref:nng_msg_append.3.adoc[`nng_msg_append()`], -allocations may be reduced by first using xref:nng_msg_reserve.3.adoc[`nng_msg_reserve()`] -to create sufficient space. -In any case, reallocating or appending to a message is guaranteed to succeed if the resulting -body length is less than xref:nng_msg_capacity.3.adoc[`nng_msg_capacity()`]. - -NOTE: Pointers to message body and header content obtained prior to this -function must not be in use, as the underlying memory used for the message -may have changed, particularly if the message size is increasing. - -== RETURN VALUES - -This function returns 0 on success, and non-zero otherwise. - -== ERRORS - -[horizontal] -`NNG_ENOMEM`:: Insufficient free memory exists to reallocate a message. - -== SEE ALSO - -[.text-left] -xref:nng_msg_reserve.3.adoc[nng_msg_reserve(3)], -xref:nng_msg_alloc.3.adoc[nng_msg_alloc(3)], -xref:nng_msg_append.3.adoc[nng_msg_append(3)], -xref:nng_msg_body.3.adoc[nng_msg_body(3)], -xref:nng_msg_chop.3.adoc[nng_msg_chop(3)], -xref:nng_msg_free.3.adoc[nng_msg_free(3)], -xref:nng_msg_insert.3.adoc[nng_msg_insert(3)], -xref:nng_msg_len.3.adoc[nng_msg_len(3)], -xref:nng_msg_trim.3.adoc[nng_msg_trim(3)], -xref:nng_strerror.3.adoc[nng_strerror(3)], -xref:nng_msg.5.adoc[nng_msg(5)], -xref:nng.7.adoc[nng(7)] diff --git a/docs/reference/src/api/msg/nng_msg_realloc.md b/docs/reference/src/api/msg/nng_msg_realloc.md new file mode 100644 index 00000000..66d113aa --- /dev/null +++ b/docs/reference/src/api/msg/nng_msg_realloc.md @@ -0,0 +1,53 @@ +# nng_msg_realloc(3) + +## NAME + +nng_msg_realloc --- reallocate a message + +## SYNOPSIS + +```c +#include <nng/nng.h> + +int nng_msg_realloc(nng_msg *msg, size_t size); +``` + +## DESCRIPTION + +The `nng_msg_realloc()` function re-allocates a message so that it has +a body of length _size_. +This message attempts to avoid extra allocations, +and will reuse the existing memory when possible. + +TIP: `nng_msg_realloc` is suitable for creating space for direct writing of data. +When appending many small pieces of data to a message using [`nng_msg_append()`](nng_msg_append.md), +allocations may be reduced by first using +[`nng_msg_reserve()`](nng_msg_reserve.md) +to create sufficient space. +In any case, reallocating or appending to a message is guaranteed to succeed if the resulting +body length is less than [`nng_msg_capacity()`](nng_msg_capacity.md). + +> [!NOTE] +> Pointers to message body and header content obtained prior to this +> function must not be in use, as the underlying memory used for the message +> may have changed, particularly if the message size is increasing. + +## RETURN VALUES + +This function returns 0 on success, and non-zero otherwise. + +## ERRORS + +- `NNG_ENOMEM`: Insufficient free memory exists to reallocate a message. + +## SEE ALSO + +[nng_msg_alloc](nng_msg_alloc.md), +[nng_msg_reserve](nng_msg_reserve.md), +[nng_msg_append](nng_msg_append.md), +[nng_msg_body](nng_msg_body.md), +[nng_msg_chop](nng_msg_chop.md), +[nng_msg_free](nng_msg_free.md), +[nng_msg_insert](nng_msg_insert.md), +[nng_msg_len](nng_msg_len.md), +[nng_msg_trim](nng_msg_trim.md) diff --git a/docs/reference/src/api/msg/nng_msg_reserve.3.adoc b/docs/reference/src/api/msg/nng_msg_reserve.3.adoc deleted file mode 100644 index 254c1e94..00000000 --- a/docs/reference/src/api/msg/nng_msg_reserve.3.adoc +++ /dev/null @@ -1,63 +0,0 @@ -= nng_msg_reserve(3) -// -// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech> -// Copyright 2018 Capitar IT Group BV <info@capitar.com> -// -// This document is supplied under the terms of the MIT License, a -// copy of which should be located in the distribution where this -// file was obtained (LICENSE.txt). A copy of the license may also be -// found online at https://opensource.org/licenses/MIT. -// - -== NAME - -nng_msg_reserve - reserve storage for a message - -== SYNOPSIS - -[source, c] ----- -#include <nng/nng.h> - -int nng_msg_reserve(nng_msg *msg, size_t capacity); ----- - -== DESCRIPTION - -The `nng_msg_reserve()` function ensures a message has allocated enough storage -to accommodate a body of the given length. -This message attempts to avoid extra allocations, -and will reuse the existing memory when possible. - -TIP: Using this message before xref:nng_msg_append.3.adoc[`nng_msg_append()`] -will prevent additional memory allocations until the message's length exceeds -the alotted capacity. - -NOTE: Pointers to message body and header content obtained prior to this -function must not be in use, as the underlying memory used for the message -may have changed, particularly if the message capacity is increasing. - -== RETURN VALUES - -This function returns 0 on success, and non-zero otherwise. - -== ERRORS - -[horizontal] -`NNG_ENOMEM`:: Insufficient free memory exists to reallocate a message. - -== SEE ALSO - -[.text-left] -xref:nng_msg_capacity.3.adoc[nng_msg_capacity(3)], -xref:nng_msg_alloc.3.adoc[nng_msg_alloc(3)], -xref:nng_msg_append.3.adoc[nng_msg_append(3)], -xref:nng_msg_body.3.adoc[nng_msg_body(3)], -xref:nng_msg_chop.3.adoc[nng_msg_chop(3)], -xref:nng_msg_free.3.adoc[nng_msg_free(3)], -xref:nng_msg_insert.3.adoc[nng_msg_insert(3)], -xref:nng_msg_len.3.adoc[nng_msg_len(3)], -xref:nng_msg_trim.3.adoc[nng_msg_trim(3)], -xref:nng_strerror.3.adoc[nng_strerror(3)], -xref:nng_msg.5.adoc[nng_msg(5)], -xref:nng.7.adoc[nng(7)] diff --git a/docs/reference/src/api/msg/nng_msg_reserve.md b/docs/reference/src/api/msg/nng_msg_reserve.md new file mode 100644 index 00000000..2d96ac8b --- /dev/null +++ b/docs/reference/src/api/msg/nng_msg_reserve.md @@ -0,0 +1,46 @@ +# nng_msg_reserve + +## NAME + +nng_msg_reserve --- reserve storage for a message + +## SYNOPSIS + +```c +#include <nng/nng.h> + +int nng_msg_reserve(nng_msg *msg, size_t capacity); +``` + +## DESCRIPTION + +The `nng_msg_reserve()` function ensures a message has allocated enough storage +to accommodate a body of the given length. +This message attempts to avoid extra allocations, +and will reuse the existing memory when possible. + +> [!TIP] +> Using this message before [`nng_msg_append()`](nng_msg_append.md) +> will prevent additional memory allocations until the message's length exceeds +> the alotted capacity. + +> [!IMPORTANT] +> Pointers to message body and header content obtained prior to this +> function must not be in use, as the underlying memory used for the message +> may have changed, particularly if the message capacity is increasing. + +## RETURN VALUES + +This function returns 0 on success, and non-zero otherwise. + +## ERRORS + +- `NNG_ENOMEM`: Insufficient free memory exists to reallocate a message. + +## SEE ALSO + +[nng_msg_alloc](nng_msg_alloc.md), +[nng_msg_append](nng_msg_append.md), +[nng_msg_capacity](nng_msg_capacity.md), +[nng_msg_insert](nng_msg_insert.md), +[nng_msg_len](nng_msg_len.md) diff --git a/docs/reference/src/api/msg/nng_msg_set_pipe.3.adoc b/docs/reference/src/api/msg/nng_msg_set_pipe.3.adoc deleted file mode 100644 index c95cc83f..00000000 --- a/docs/reference/src/api/msg/nng_msg_set_pipe.3.adoc +++ /dev/null @@ -1,50 +0,0 @@ -= nng_msg_set_pipe(3) -// -// Copyright 2019 Staysail Systems, Inc. <info@staysail.tech> -// Copyright 2018 Capitar IT Group BV <info@capitar.com> -// -// This document is supplied under the terms of the MIT License, a -// copy of which should be located in the distribution where this -// file was obtained (LICENSE.txt). A copy of the license may also be -// found online at https://opensource.org/licenses/MIT. -// - -== NAME - -nng_msg_set_pipe - set pipe for message - -== SYNOPSIS - -[source, c] ----- -#include <nng/nng.h> - -void nng_msg_set_pipe(nng_msg *msg, nng_pipe p); ----- - -== DESCRIPTION - -The `nng_msg_set_pipe()` sets the pipe associated with message _m_ to _p_. -This is most often useful when used with protocols that support directing -a message to a specific peer. -For example the xref:nng_pair.7.adoc[_pair_] version 1 protocol can do -this when `NNG_OPT_PAIR1_POLY` mode is set. - -NOTE: Not all protocols support overriding the destination pipe. - -== RETURN VALUES - -None. - -== ERRORS - -None. - -== SEE ALSO - -[.text-left] -xref:nng_msg_alloc.3.adoc[nng_msg_alloc(3)], -xref:nng_msg_get_pipe.3.adoc[nng_msg_get_pipe(3)], -xref:nng_pipe_getopt.3.adoc[nng_pipe_getopt(3)], -xref:nng_msg.5.adoc[nng_msg(5)], -xref:nng.7.adoc[nng(7)] diff --git a/docs/reference/src/api/msg/nng_msg_set_pipe.md b/docs/reference/src/api/msg/nng_msg_set_pipe.md new file mode 100644 index 00000000..58f339ca --- /dev/null +++ b/docs/reference/src/api/msg/nng_msg_set_pipe.md @@ -0,0 +1,29 @@ +# nng_msg_set_pipe + +## NAME + +nng_msg_set_pipe --- set pipe for message + +## SYNOPSIS + +```c +#include <nng/nng.h> + +void nng_msg_set_pipe(nng_msg *msg, nng_pipe p); +``` + +## DESCRIPTION + +The `nng_msg_set_pipe()` sets the pipe associated with message _m_ to _p_. +This is most often useful when used with protocols that support directing +a message to a specific peer. +For example the [_PAIR_](../protocols/pair.md) version 1 protocol can do +this when `NNG_OPT_PAIR1_POLY` mode is set. + +> [!NOTE] +> Not all protocols support overriding the destination pipe. + +## SEE ALSO + +[nng_msg_alloc](nng_msg_alloc.md), +[nng_msg_get_pipe](nng_msg_get_pipe.md) |
