Add isc_buffer_putstr().

This commit is contained in:
Mark Andrews
1999-12-13 02:18:02 +00:00
parent e8cf926e39
commit 8a21ac0f09
2 changed files with 29 additions and 0 deletions

View File

@@ -397,6 +397,23 @@ isc_buffer_putmem(isc_buffer_t *b, unsigned char *base, unsigned int length)
b->used += length;
}
isc_result_t
isc_buffer_putstr(isc_buffer_t *b, const char *source) {
unsigned int l;
isc_region_t region;
REQUIRE(ISC_BUFFER_VALID(b));
REQUIRE(source != NULL);
l = strlen(source);
if (l > (b->length - b->used))
return (ISC_R_NOSPACE);
memcpy(b->base + b->used, source, l);
b->used += l;
return (ISC_R_SUCCESS);
}
isc_result_t
isc_buffer_copyregion(isc_buffer_t *b, isc_region_t *r) {
unsigned char *base;

View File

@@ -549,6 +549,18 @@ isc_buffer_putmem(isc_buffer_t *b, unsigned char *base, unsigned int length);
*
* 'base' points to 'length' bytes of valid memory.
*
*/
isc_result_t
isc_buffer_putstr(isc_buffer_t *b, const char *source);
/*
* Copy 'length' bytes of memory at 'base' into 'b'.
*
* Requires:
* 'b' is a valid buffer.
*
* 'source' to be a valid NULL terminated string.
*
* Returns:
*
* ISC_R_SUCCESS