/* parc * Copyright (C) 2025 Ekaitz Zarraga * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /* * This is a growable char buffer, it grows automatically on append. * It must be cleared after use as it allocates memory. */ #ifndef TEXT_BUFFER_H #define TEXT_BUFFER_H #include typedef struct { size_t used; size_t size; char *contents; } text_buffer; void text_buffer_init (text_buffer *tb); void text_buffer_resize (text_buffer *tb, size_t size); void text_buffer_append (text_buffer *tb, char c); void text_buffer_append_str (text_buffer *tb, char *c, size_t len); char text_buffer_index (text_buffer *tb, size_t pos); void text_buffer_fill (text_buffer *tb, char *fill, size_t size); void text_buffer_clear (text_buffer *tb); #endif /* TEXT_BUFFER_H */