3 /* buff -- buffers as needed by tesh */
5 /* Copyright (c) 2007 Martin Quinson. */
6 /* All rights reserved. */
8 /* This program is free software; you can redistribute it and/or modify it
9 * under the terms of the license (GNU LGPL) which comes with this package. */
11 /* specific to Borland Compiler */
22 void buff_empty(buff_t *b) {
27 buff_t *buff_new(void) {
28 buff_t *res=malloc(sizeof(buff_t));
29 res->data=malloc(512);
34 void buff_free(buff_t *b) {
41 void buff_append(buff_t *b, char *toadd) {
42 int addlen=strlen(toadd);
43 int needed_space=b->used+addlen+1;
45 if (needed_space > b->size) {
46 b->data = realloc(b->data, needed_space);
47 b->size = needed_space;
49 strcpy(b->data+b->used, toadd);
52 void buff_chomp(buff_t *b) {
53 while (b->data[b->used] == '\n') {
54 b->data[b->used] = '\0';
60 void buff_trim(buff_t* b) {
61 xbt_str_trim(b->data," ");
62 b->used = strlen(b->data);