-void
-rb_linebuf_putbuf(buf_head_t * bufhead, const char *buffer)
-{
- buf_line_t *bufline;
- int len = 0;
-
- /* make sure the previous line is terminated */
- if(bufhead->list.tail)
- {
- bufline = bufhead->list.tail->data;
- lrb_assert(bufline->terminated);
- }
-
- /* Create a new line */
- bufline = rb_linebuf_new_line(bufhead);
-
- if(buffer != NULL)
- len = rb_strlcpy(bufline->buf, buffer, LINEBUF_DATA_SIZE + 1);
-
- bufline->terminated = 1;
-
- /* Truncate the data if required */
- if(len > LINEBUF_DATA_SIZE)
- {
- len = LINEBUF_DATA_SIZE;
- bufline->buf[len++] = '\r';
- bufline->buf[len++] = '\n';
- }
- else if(len == 0)
- {
- bufline->buf[len++] = '\r';
- bufline->buf[len++] = '\n';
- bufline->buf[len] = '\0';
- }
- else
- {
- /* Chop trailing CRLF's .. */
- while((bufline->buf[len] == '\r') || (bufline->buf[len] == '\n')
- || (bufline->buf[len] == '\0'))
- {
- len--;
- }
-
- bufline->buf[++len] = '\r';
- bufline->buf[++len] = '\n';
- bufline->buf[++len] = '\0';
- }
-
- bufline->len = len;
- bufhead->len += len;
-
-
-}
-
-void
-rb_linebuf_put(buf_head_t * bufhead, const char *format, ...)
-{
- buf_line_t *bufline;
- int len = 0;
- va_list args;
-
- /* make sure the previous line is terminated */
- if(bufhead->list.tail)
- {
- bufline = bufhead->list.tail->data;
- lrb_assert(bufline->terminated);
- }
-
- /* Create a new line */
- bufline = rb_linebuf_new_line(bufhead);
-
- if(format != NULL)
- {
- va_start(args, format);
- len = vsnprintf(bufline->buf, LINEBUF_DATA_SIZE + 1, format, args);
- va_end(args);
- }
-
- bufline->terminated = 1;
-
- /* Truncate the data if required */
- if(len > LINEBUF_DATA_SIZE)
- {
- len = LINEBUF_DATA_SIZE;
- bufline->buf[len++] = '\r';
- bufline->buf[len++] = '\n';
- }
- else if(len == 0)
- {
- bufline->buf[len++] = '\r';
- bufline->buf[len++] = '\n';
- bufline->buf[len] = '\0';
- }
- else
- {
- /* Chop trailing CRLF's .. */
- while((bufline->buf[len] == '\r') || (bufline->buf[len] == '\n')
- || (bufline->buf[len] == '\0'))
- {
- len--;
- }
-
- bufline->buf[++len] = '\r';
- bufline->buf[++len] = '\n';
- bufline->buf[++len] = '\0';
- }
-
- bufline->len = len;
- bufhead->len += len;
-}
-
-
-