12a6b7db3Sskrll /* An abstract string datatype. 2*cb63e24eSchristos Copyright (C) 1998-2024 Free Software Foundation, Inc. 32a6b7db3Sskrll Contributed by Mark Mitchell (mark@markmitchell.com). 42a6b7db3Sskrll 52a6b7db3Sskrll This file is part of GCC. 62a6b7db3Sskrll 72a6b7db3Sskrll GCC is free software; you can redistribute it and/or modify 82a6b7db3Sskrll it under the terms of the GNU General Public License as published by 92a6b7db3Sskrll the Free Software Foundation; either version 2, or (at your option) 102a6b7db3Sskrll any later version. 112a6b7db3Sskrll 122a6b7db3Sskrll GCC is distributed in the hope that it will be useful, 132a6b7db3Sskrll but WITHOUT ANY WARRANTY; without even the implied warranty of 142a6b7db3Sskrll MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 152a6b7db3Sskrll GNU General Public License for more details. 162a6b7db3Sskrll 172a6b7db3Sskrll You should have received a copy of the GNU General Public License 182a6b7db3Sskrll along with GCC; see the file COPYING. If not, write to 192a6b7db3Sskrll the Free Software Foundation, 51 Franklin Street - Fifth Floor, 202a6b7db3Sskrll Boston, MA 02110-1301, USA. */ 212a6b7db3Sskrll 2245548106Schristos #ifndef DYN_STRING_H 2345548106Schristos #define DYN_STRING_H 2445548106Schristos 2545548106Schristos #ifdef __cplusplus 2645548106Schristos extern "C" { 2745548106Schristos #endif 282a6b7db3Sskrll 292a6b7db3Sskrll typedef struct dyn_string 302a6b7db3Sskrll { 312a6b7db3Sskrll int allocated; /* The amount of space allocated for the string. */ 322a6b7db3Sskrll int length; /* The actual length of the string. */ 332a6b7db3Sskrll char *s; /* The string itself, NUL-terminated. */ 342a6b7db3Sskrll }* dyn_string_t; 352a6b7db3Sskrll 362a6b7db3Sskrll /* The length STR, in bytes, not including the terminating NUL. */ 372a6b7db3Sskrll #define dyn_string_length(STR) \ 382a6b7db3Sskrll ((STR)->length) 392a6b7db3Sskrll 402a6b7db3Sskrll /* The NTBS in which the contents of STR are stored. */ 412a6b7db3Sskrll #define dyn_string_buf(STR) \ 422a6b7db3Sskrll ((STR)->s) 432a6b7db3Sskrll 442a6b7db3Sskrll /* Compare DS1 to DS2 with strcmp. */ 452a6b7db3Sskrll #define dyn_string_compare(DS1, DS2) \ 462a6b7db3Sskrll (strcmp ((DS1)->s, (DS2)->s)) 472a6b7db3Sskrll 482a6b7db3Sskrll 492a6b7db3Sskrll extern int dyn_string_init (struct dyn_string *, int); 502a6b7db3Sskrll extern dyn_string_t dyn_string_new (int); 512a6b7db3Sskrll extern void dyn_string_delete (dyn_string_t); 522a6b7db3Sskrll extern char *dyn_string_release (dyn_string_t); 532a6b7db3Sskrll extern dyn_string_t dyn_string_resize (dyn_string_t, int); 542a6b7db3Sskrll extern void dyn_string_clear (dyn_string_t); 552a6b7db3Sskrll extern int dyn_string_copy (dyn_string_t, dyn_string_t); 562a6b7db3Sskrll extern int dyn_string_copy_cstr (dyn_string_t, const char *); 572a6b7db3Sskrll extern int dyn_string_prepend (dyn_string_t, dyn_string_t); 582a6b7db3Sskrll extern int dyn_string_prepend_cstr (dyn_string_t, const char *); 592a6b7db3Sskrll extern int dyn_string_insert (dyn_string_t, int, dyn_string_t); 602a6b7db3Sskrll extern int dyn_string_insert_cstr (dyn_string_t, int, const char *); 612a6b7db3Sskrll extern int dyn_string_insert_char (dyn_string_t, int, int); 622a6b7db3Sskrll extern int dyn_string_append (dyn_string_t, dyn_string_t); 632a6b7db3Sskrll extern int dyn_string_append_cstr (dyn_string_t, const char *); 642a6b7db3Sskrll extern int dyn_string_append_char (dyn_string_t, int); 652a6b7db3Sskrll extern int dyn_string_substring (dyn_string_t, dyn_string_t, int, int); 662a6b7db3Sskrll extern int dyn_string_eq (dyn_string_t, dyn_string_t); 6745548106Schristos 6845548106Schristos #ifdef __cplusplus 6945548106Schristos } 7045548106Schristos #endif 7145548106Schristos 7245548106Schristos #endif /* !defined (DYN_STRING_H) */ 73