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