summaryrefslogtreecommitdiff
path: root/ref/print.html
diff options
context:
space:
mode:
authorgdamore <gdamore@users.noreply.github.com>2025-01-01 19:37:21 +0000
committergdamore <gdamore@users.noreply.github.com>2025-01-01 19:37:21 +0000
commit69bcd1d0babc5ab10a84555f29523d4f02119f67 (patch)
tree66839caf6db8d39582bd484773c4d955724c1b16 /ref/print.html
parent76e14b3a60e3c3d440022af84c0cb05a806abb29 (diff)
downloadnng-69bcd1d0babc5ab10a84555f29523d4f02119f67.tar.gz
nng-69bcd1d0babc5ab10a84555f29523d4f02119f67.tar.bz2
nng-69bcd1d0babc5ab10a84555f29523d4f02119f67.zip
deploy: f8a2abaf931557030fd6e6683617c6a7877eebf7
Diffstat (limited to 'ref/print.html')
-rw-r--r--ref/print.html48
1 files changed, 34 insertions, 14 deletions
diff --git a/ref/print.html b/ref/print.html
index 3089c77a..c6027f55 100644
--- a/ref/print.html
+++ b/ref/print.html
@@ -983,11 +983,31 @@ properly.</p>
</code></pre>
<p>The <a name="a020"></a><code>nng_msg_header_clear</code> simply resets the total message header length to zero.</p>
<h3 id="append-or-insert-header"><a class="header" href="#append-or-insert-header">Append or Insert Header</a></h3>
+<pre><code class="language-c">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);
+
+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);
+</code></pre>
<p>Appending data to a message header is done by using the <a name="a021"></a><code>nng_msg_header_append</code> functions,
and inserting data in the header is done using the <a name="a022"></a><code>nng_msg_header_insert</code> functions.</p>
<p>These functions act just like the <a href="api//api/msg.html#add-to-body"><code>nng_msg_append</code></a> and <a href="api//api/msg.html#add-to-body"><code>nng_msg_insert</code></a> functions,
except that they operate on the message header rather than the message body.</p>
<h3 id="consume-from-header"><a class="header" href="#consume-from-header">Consume from Header</a></h3>
+<pre><code class="language-c">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);
+
+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);
+</code></pre>
<p>The <a name="a023"></a><code>nng_msg_header_trim</code> functions remove data from the beginning of the message header,
and the <a name="a024"></a><code>nng_msg_header_chop</code> functions remove data from the end of the message header.</p>
<p>These functions act just like the <a href="api//api/msg.html#consume-from-body"><code>nng_msg_trim</code></a> and <a href="api//api/msg.html#consume-from-body"><code>nng_msg_chop</code></a> functions,
@@ -1012,23 +1032,23 @@ either directly by the application, or when the message was received by the prot
</div>
<h2 id="examples"><a class="header" href="#examples">Examples</a></h2>
<h3 id="example-1-preparing-a-message-for-use"><a class="header" href="#example-1-preparing-a-message-for-use">Example 1: Preparing a message for use</a></h3>
-<pre><code class="language-c"> #include &lt;nng/nng.h&gt;
+<pre><code class="language-c">#include &lt;nng/nng.h&gt;
- nng_msg *m;
- if (nng_msg_alloc(&amp;m, strlen("content") + 1) != 0) {
- // handle error
- }
- strcpy(nng_msg_body(m), "content");
+nng_msg *m;
+if (nng_msg_alloc(&amp;m, strlen("content") + 1) != 0) {
+ // handle error
+}
+strcpy(nng_msg_body(m), "content");
</code></pre>
<h3 id="example-2-preallocating-message-content"><a class="header" href="#example-2-preallocating-message-content">Example 2: Preallocating message content</a></h3>
-<pre><code class="language-c"> if (nng_msg_alloc(&amp;m, 1024) != 0) {
- // handle error
- }
- while ((val64 = next_datum()) != 0) P
- if (nng_msg_append_u64(m, val64) != 0) {
- // handle error
- }
- }
+<pre><code class="language-c">if (nng_msg_alloc(&amp;m, 1024) != 0) {
+ // handle error
+}
+while ((val64 = next_datum()) != 0) P
+ if (nng_msg_append_u64(m, val64) != 0) {
+ // handle error
+ }
+}
</code></pre>
<!-- Symbol cross reference -->
<!-- Macros -->