| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- '\" t
- .\" Title: ne_buffer_append
- .\" Author:
- .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
- .\" Date: 23 November 2025
- .\" Manual: neon API reference
- .\" Source: neon 0.36.0
- .\" Language: English
- .\"
- .TH "NE_BUFFER_APPEND" "3" "23 November 2025" "neon 0.36.0" "neon API reference"
- .\" -----------------------------------------------------------------
- .\" * Define some portability stuff
- .\" -----------------------------------------------------------------
- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- .\" http://bugs.debian.org/507673
- .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- .ie \n(.g .ds Aq \(aq
- .el .ds Aq '
- .\" -----------------------------------------------------------------
- .\" * set default formatting
- .\" -----------------------------------------------------------------
- .\" disable hyphenation
- .nh
- .\" disable justification (adjust text to left margin only)
- .ad l
- .\" -----------------------------------------------------------------
- .\" * MAIN CONTENT STARTS HERE *
- .\" -----------------------------------------------------------------
- .SH "NAME"
- ne_buffer_append, ne_buffer_zappend, ne_buffer_qappend, ne_buffer_concat, ne_buffer_snprintf \- append data to a string buffer
- .SH "SYNOPSIS"
- .sp
- .ft B
- .nf
- #include <ne_string\&.h>
- .fi
- .ft
- .HP \w'void\ ne_buffer_append('u
- .BI "void ne_buffer_append(ne_buffer\ *" "buf" ", const\ char\ *" "string" ", size_t\ " "len" ");"
- .HP \w'void\ ne_buffer_zappend('u
- .BI "void ne_buffer_zappend(ne_buffer\ *" "buf" ", const\ char\ *" "string" ");"
- .HP \w'void\ ne_buffer_qappend('u
- .BI "void ne_buffer_qappend(ne_buffer\ *" "buf" ", const\ char\ *" "string" ", size_t\ " "len" ");"
- .HP \w'void\ ne_buffer_concat('u
- .BI "void ne_buffer_concat(ne_buffer\ *" "buf" ", \&.\&.\&.);"
- .HP \w'size_t\ ne_buffer_snprintf('u
- .BI "size_t ne_buffer_snprintf(ne_buffer\ *" "buf" ", size_t\ " "max" ", const\ char\ *" "format" ", \&.\&.\&.);"
- .SH "DESCRIPTION"
- .PP
- The
- \fBne_buffer_append\fR
- and
- \fBne_buffer_zappend\fR
- functions append a string to the end of a buffer; extending the buffer as necessary\&. The
- \fIlen\fR
- passed to
- \fBne_buffer_append\fR
- specifies the length of the string to append; there must be no
- NUL
- terminator in the first
- \fIlen\fR
- bytes of the string\&.
- \fBne_buffer_zappend\fR
- must be passed a
- NUL\-terminated string\&.
- .PP
- The
- \fBne_buffer_qappend\fR
- function behaves similarly to
- \fBne_buffer_append\fR, except that any non\-ASCII characters or ASCII control characters are escaped using C\-style hex escaping\&. For example, the C string
- "foo<TAB>bar", where TAB represents ASCII character 9, would be appended as
- "foo\ex09bar"\&. Any
- NUL
- bytes within the length specified are also escaped\&. This function is useful to make strings from untrusted sources safe for logging or output in a user interface\&.
- .PP
- The
- \fBne_buffer_concat\fR
- function takes a variable\-length argument list; each argument must be a
- \fBchar *\fR
- pointer to a
- NUL\-terminated string\&. A
- NULL
- pointer must be given as the last argument to mark the end of the list\&. The strings are appended to the buffer in the order given\&. None of the strings passed to
- \fBne_buffer_concat\fR
- are modified\&.
- .PP
- The
- \fBne_buffer_snprintf\fR
- function behaves like
- \fBsnprintf\fR, appending the output string formatted according to the
- \fIformat\fR
- parameter\&. At most
- \fImax\fR
- bytes are written including the trailing
- NUL
- terminator\&.
- .SH "RETURN VALUE"
- .PP
- The
- \fBne_buffer_snprintf\fR
- function returns the number of bytes appended
- \fIexcluding\fR
- the trailing
- NUL
- terminator\&.
- .SH "EXAMPLES"
- .PP
- The following code will output "Hello, world\&. And goodbye\&."\&.
- .sp
- .if n \{\
- .RS 4
- .\}
- .nf
- ne_buffer *buf = ne_buffer_create();
- ne_buffer_zappend(buf, "Hello");
- ne_buffer_concat(buf, ", world\&. ", "And ", NULL);
- ne_buffer_snprintf(buf, 10, "%s\&.", "goodbye");
- puts(buf\->data);
- ne_buffer_destroy(buf);
- .fi
- .if n \{\
- .RE
- .\}
- .SH "SEE ALSO"
- .PP
- ne_buffer,
- ne_buffer_create,
- ne_buffer_destroy
- .SH "COPYRIGHT"
- .br
- Copyright \(co 2001-2025 Joe Orton
- .br
|