1  /* Copyright 2014-2023 Free Software Foundation, Inc.
       2  
       3     This program is free software: you can redistribute it and/or modify
       4     it under the terms of the GNU General Public License as published by
       5     the Free Software Foundation, either version 3 of the License, or
       6     (at your option) any later version.
       7  
       8     This program is distributed in the hope that it will be useful,
       9     but WITHOUT ANY WARRANTY; without even the implied warranty of
      10     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      11     GNU General Public License for more details.
      12  
      13     You should have received a copy of the GNU General Public License
      14     along with this program.  If not, see <http://www.gnu.org/licenses/>. */
      15  
      16  #ifndef TEXT_H
      17  #define TEXT_H
      18  
      19  typedef struct TEXT {
      20      char *text;
      21      size_t space;
      22      size_t end;
      23  } TEXT;
      24  
      25  void text_init (TEXT *t);
      26  void text_reset (TEXT *t);
      27  void text_append (TEXT *t, char *s);
      28  void text_append_n (TEXT *t, char *s, size_t len);
      29  void text_printf (TEXT *t, char *format, ...);
      30  void text_destroy (TEXT *t);
      31  
      32  #define text_base(t) ((t)->space ? (t)->text : (char *) 0)
      33  
      34  #endif