Appends the specified number of bytes from a particular buffer to the IO buffer.
int INKIOBufferWrite (INKIOBuffer
bufp
, const char
*buf
, int
len
)
INKIOBuffer
is the target
IOBuffer that receives the data.bufp
const char
is
the buffer that contains the data.*buf
int
is the
length of the data to write.len
This function appends data from
to IOBuffer
*buf
; the length of data
being appended is specified in
bufp
. The returned value
is the actual length of data being appended.len
INKIOBufferWrite
offers the same
functionality as the deprecated functions
INKIOBufferAppend
,
INKIOBufferDataCreate
, and
INKIOBufferBlockCreate
. To append the
content of a buffer
of size buf
into an
len
IOBuffer
, we recommend using
INKIOBufferWrite
. It has the following
prototype:
int INKIOBufferWrite (INKIOBuffer bufp, const char *buf, int len); The equivalent of this API in SDK2.0 is the following snippet of code: INKIOBufferBlock block; int avail, ndone, ntodo, towrite; char *ptr_block; ndone = 0; ntodo = len; while (ntodo > 0) { /* INKIOBufferStart allocates more blocks if required */ block = INKIOBufferStart(bufp); ptr_block = INKIOBufferBlockWriteStart (block, &avail); towrite = min(ntodo, avail); memcpy (ptr_block, buf+ndone, towrite); INKIOBufferProduce(bufp, towrite); ntodo -= towrite; ndone += towrite; }
The length of data copied if the API call is successful.
INK_ERROR
if an error occurs while calling
the API or if an argument is invalid.