#include #include #include #include #include #include "inc.h" #include "struct.h" #include "append.h" void stringtree_append_string_const( struct stringtree* this, const char* cstr) { ENTER; struct child* new = smalloc(sizeof(*new)); new->kind = ck_cstr; new->cstr = cstr; new->prev = NULL; new->next = NULL; if (this->tail) { this->tail->next = new; new->prev = this->tail; this->tail = new; } else { this->head = new; this->tail = new; } EXIT; } void stringtree_append_formatstr( struct stringtree* this, const char* fmt, ...) { ENTER; va_list va; va_start(va, fmt); struct string* string = new_string_from_vargs(fmt, va); stringtree_append_string(this, string); free_string(string); va_end(va); EXIT; } void stringtree_append_string( struct stringtree* this, struct string* string) { ENTER; struct child* new = smalloc(sizeof(*new)); new->kind = ck_string; new->string = inc_string(string); new->prev = NULL; new->next = NULL; if (this->tail) { this->tail->next = new; new->prev = this->tail; this->tail = new; } else { this->head = new; this->tail = new; } EXIT; } void stringtree_append_stringtree( struct stringtree* this, struct stringtree* stringtree) { ENTER; struct child* new = smalloc(sizeof(*new)); new->kind = ck_stringtree; new->stringtree = inc_stringtree(stringtree); new->prev = NULL; new->next = NULL; if (this->tail) { this->tail->next = new; new->prev = this->tail; this->tail = new; } else { this->head = new; this->tail = new; } EXIT; }