diff --git a/man/Makefile.am b/man/Makefile.am index f609602..542b3e4 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -1,4 +1,5 @@ man_MANS = ndbuf_new.3 ndbuf_new_palloc.3 ndbuf_new_wmops.3 ndbuf_new_frombuf.3 \ ndbuf_free.3 ndbuf_free_item.3 ndbuf_read_raw.3 ndbuf_read_u8.3 ndbuf_read_u16.3 \ - ndbuf_read_u32.3 ndbuf_read_u64.3 + ndbuf_read_u32.3 ndbuf_read_u64.3 ndbuf_write_raw.3 ndbuf_write_u8.3 ndbuf_write_u16.3 \ + ndbuf_write_u32.3 ndbuf_write_u64.3 diff --git a/man/ndbuf_write_raw.3 b/man/ndbuf_write_raw.3 new file mode 100644 index 0000000..c067f96 --- /dev/null +++ b/man/ndbuf_write_raw.3 @@ -0,0 +1,77 @@ +.TH NDBUF_WRITE_RAW 3 "15 September 2018" "NDBUF" "Binary buffers lib manual" +.SH NAME +ndbuf_write_u8, ndbuf_write_u16, ndbuf_write_u32, ndbuf_write_u64, +ndbuf_write_raw - write data to the buffer of specified length and type +.SH SYNOPSIS +.B "#include " +.PP +.nf +uint32_t ndbuf_write_u8(ndbuf_t *b, uint8_t val); +uint32_t ndbuf_write_u16(ndbuf_t *b, uint16_t val); +uint32_t ndbuf_write_u32(ndbuf_t *b, uint32_t val); +uint32_t ndbuf_write_u64(ndbuf_t *b, uint64_t val); +uint32_t ndbuf_write_raw(ndbuf_t *b, void *src, uint32_t len); +.fi +.SH DESCRIPTION +The ndbuf_write_ family writes data to an +.B ndbuf_t +instance from caller-provided storage. On success each function returns the number of bytes written; on error it returns 0. + +.TP +.B ndbuf_write_u8(ndbuf_t *b, uint8_t val) +Write one unsigned 8‑bit value to the current buffer position from +.I val +and advance the buffer cursor by one byte. Returned value is the number of bytes written (1) or 0 on error. + +.TP +.B ndbuf_write_u16(ndbuf_t *b, uint16_t val) +Writes one unsigned 16‑bit value, from +.I val +and advance the cursor by two bytes. Returns 2 on success or 0 on error. + +.TP +.B ndbuf_write_u32(ndbuf_t *b, uint32_t val) +Write one unsigned 32‑bit value, from +.I val +and advance the cursor by four bytes. Returns 4 on success or 0 on error. + +.TP +.B ndbuf_write_u64(ndbuf_t *b, uint64_t val) +Write one unsigned 64‑bit value, from +.I val +and advance the cursor by eight bytes. Returns 8 on success or 0 on error. + +.TP +.B ndbuf_read_raw(ndbuf_t *b, void *dst, uint32_t len) +Copy +.I len +from +.I dst +to the buffer and advance the cursor by +.I len. The caller must ensure +.I dst +points to memory at least +.I len +bytes long. Returns the number of bytes copied or 0 on error. +.SH RETURN VALUE +On success each function returns the number of bytes read. On error they return 0; no specific +.I errno +value is set. +.SH ERRORS +Functions return 0 when the requested read would exceed the available data, when +.I b +is NULL, or on other internal errors. Callers must validate the return value before using output data. +.SH RATIONALE +None +.SH EXAMPLES +None +.PP +.SH SEE ALSO +.BR ndbuf_read_raw(3), +.BR ndbuf_print(3) +.SH COPYRIGHT +This software licensed under GNU LGPL v2.1 or later. See COPYING for further details. +.PP +(c) Authors of libndbuf 2017-2018 +.SH AUTHOR +Alexander Vdolainen (alex@vapaa.xyz) diff --git a/man/ndbuf_write_u16.3 b/man/ndbuf_write_u16.3 new file mode 120000 index 0000000..ff5a416 --- /dev/null +++ b/man/ndbuf_write_u16.3 @@ -0,0 +1 @@ +ndbuf_write_raw.3 \ No newline at end of file diff --git a/man/ndbuf_write_u32.3 b/man/ndbuf_write_u32.3 new file mode 120000 index 0000000..ff5a416 --- /dev/null +++ b/man/ndbuf_write_u32.3 @@ -0,0 +1 @@ +ndbuf_write_raw.3 \ No newline at end of file diff --git a/man/ndbuf_write_u64.3 b/man/ndbuf_write_u64.3 new file mode 120000 index 0000000..ff5a416 --- /dev/null +++ b/man/ndbuf_write_u64.3 @@ -0,0 +1 @@ +ndbuf_write_raw.3 \ No newline at end of file diff --git a/man/ndbuf_write_u8.3 b/man/ndbuf_write_u8.3 new file mode 120000 index 0000000..ff5a416 --- /dev/null +++ b/man/ndbuf_write_u8.3 @@ -0,0 +1 @@ +ndbuf_write_raw.3 \ No newline at end of file