add buffer_putm and buffer_putmflush
parent
5dfea5617e
commit
38ef27207a
@ -0,0 +1,15 @@
|
||||
.TH buffer_putm 3
|
||||
.SH NAME
|
||||
buffer_putm \- write ASCIIZ string(s) to buffer
|
||||
.SH SYNTAX
|
||||
.B #include <buffer.h>
|
||||
|
||||
int \fBbuffer_putm\fP(buffer* \fIb\fR,const char* \fIx\fR,...);
|
||||
.SH DESCRIPTION
|
||||
buffer_putm is like buffer_puts, but it can be passed more than one
|
||||
string.
|
||||
.SH "RETURN VALUE"
|
||||
buffer_putm returns 0 if everything was fine, -1 on error (setting
|
||||
errno).
|
||||
.SH "SEE ALSO"
|
||||
buffer_putsalign(3), buffer_put(3), buffer_flush(3), buffer(3)
|
@ -0,0 +1,16 @@
|
||||
#include <stdarg.h>
|
||||
#include "buffer.h"
|
||||
|
||||
int buffer_putm_internal(buffer* b, ...) {
|
||||
int r=0;
|
||||
va_list a;
|
||||
const char* s;
|
||||
va_start(a,b);
|
||||
while ((s=va_arg(a,const char*)))
|
||||
if (buffer_puts(b,s)==-1) {
|
||||
r=-1;
|
||||
break;
|
||||
}
|
||||
va_end(a);
|
||||
return r;
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
#include <stdarg.h>
|
||||
#include "buffer.h"
|
||||
|
||||
int buffer_putm_internal_flush(buffer* b, ...) {
|
||||
int r=0;
|
||||
va_list a;
|
||||
const char* s;
|
||||
va_start(a,b);
|
||||
while ((s=va_arg(a,const char*)))
|
||||
if (buffer_puts(b,s)==-1) {
|
||||
r=-1;
|
||||
break;
|
||||
}
|
||||
va_end(a);
|
||||
buffer_flush(b);
|
||||
return r;
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
.TH stralloc_catm 3
|
||||
.SH NAME
|
||||
stralloc_catm \- append string(s) to a stralloc
|
||||
.SH SYNTAX
|
||||
.B #include <stralloc.h>
|
||||
|
||||
int \fBstralloc_cats\fP(stralloc* \fIsa\fR,const char* \fIs\fR, ...);
|
||||
.SH DESCRIPTION
|
||||
stralloc_cats appends \\0-terminated strings from \fIs\fR... to the
|
||||
end of the string stored in \fIsa\fR, allocating space if necessary, and
|
||||
returns 1. If \fIsa\fR is unallocated, stralloc_cats is the same as
|
||||
stralloc_copys.
|
||||
|
||||
If it runs out of memory, stralloc_cats returns 0. At that point, it
|
||||
may already have copied a few of the strings to sa.
|
||||
.SH "SEE ALSO"
|
||||
stralloc_cats(3)
|
@ -0,0 +1,15 @@
|
||||
#include <stdarg.h>
|
||||
#include "stralloc.h"
|
||||
|
||||
int stralloc_catm_internal(stralloc* sa, ...) {
|
||||
va_list a;
|
||||
const char* s;
|
||||
va_start(a,sa);
|
||||
while ((s=va_arg(a,const char*)))
|
||||
if (stralloc_cats(sa,s)==0) {
|
||||
va_end(a);
|
||||
return 0;
|
||||
}
|
||||
va_end(a);
|
||||
return 1;
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
.TH stralloc_catm 3
|
||||
.SH NAME
|
||||
stralloc_copym \- copy string(s) to a stralloc
|
||||
.SH SYNTAX
|
||||
.B #include <stralloc.h>
|
||||
|
||||
int \fBstralloc_copys\fP(stralloc* \fIsa\fR,const char* \fIs\fR, ...);
|
||||
.SH DESCRIPTION
|
||||
stralloc_cats copies \\0-terminated strings from \fIs\fR... to \fIsa\fR,
|
||||
allocating space if necessary, and returns 1. If there is data in the
|
||||
\fIsa\fR, it is cleared first.
|
||||
|
||||
If it runs out of memory, stralloc_copys returns 0. At that point, it
|
||||
may already have copied a few of the strings to sa.
|
||||
.SH "SEE ALSO"
|
||||
stralloc_copys(3)
|
Loading…
Reference in New Issue