ulib uprintf to pipe not termdev, ulib Add stringbuffer and linearlist, tb Capture subshell output
This commit is contained in:
26
ulib/string/stringbuffer.c
Normal file
26
ulib/string/stringbuffer.c
Normal file
@ -0,0 +1,26 @@
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <string/stringbuffer.h>
|
||||
#include <umalloc/umalloc.h>
|
||||
#include <string/string.h>
|
||||
#include <linearlist.h>
|
||||
|
||||
void stringbuffer_init(StringBuffer *sb) {
|
||||
string_memset(sb, 0, sizeof(*sb));
|
||||
}
|
||||
|
||||
void stringbuffer_free(StringBuffer *sb) {
|
||||
LINLIST_FREE(sb);
|
||||
}
|
||||
|
||||
void stringbuffer_appendchar(StringBuffer *sb, char c) {
|
||||
LINLIST_APPEND(sb, c);
|
||||
}
|
||||
|
||||
void stringbuffer_appendcstr(StringBuffer *sb, char *cstr) {
|
||||
char *s = cstr;
|
||||
while (*s) {
|
||||
stringbuffer_appendchar(sb, *s);
|
||||
s++;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user