version 1.55, 2006/07/08 09:25:44 |
version 1.56, 2007/02/02 04:24:09 |
|
|
} |
} |
|
|
/* |
/* |
* cvs_buf_set() |
|
* |
|
* Set the contents of the buffer <b> at offset <off> to the first <len> |
|
* bytes of data found at <src>. If the buffer was not created with |
|
* BUF_AUTOEXT, as many bytes as possible will be copied in the buffer. |
|
*/ |
|
ssize_t |
|
cvs_buf_set(BUF *b, const void *src, size_t len, size_t off) |
|
{ |
|
size_t rlen = 0; |
|
|
|
if (b->cb_size < (len + off)) { |
|
if ((b->cb_flags & BUF_AUTOEXT)) { |
|
cvs_buf_grow(b, len + off - b->cb_size); |
|
rlen = len + off; |
|
} else { |
|
rlen = b->cb_size - off; |
|
} |
|
} else { |
|
rlen = len; |
|
} |
|
|
|
b->cb_len = rlen; |
|
memcpy((b->cb_buf + off), src, rlen); |
|
|
|
if (b->cb_len == 0) { |
|
b->cb_cur = b->cb_buf + off; |
|
b->cb_len = rlen; |
|
} |
|
|
|
return (rlen); |
|
} |
|
|
|
/* |
|
* cvs_buf_putc() |
* cvs_buf_putc() |
* |
* |
* Append a single character <c> to the end of the buffer <b>. |
* Append a single character <c> to the end of the buffer <b>. |