1 /* Function prototypes for handling string buffers. 2 * Copyright (C) 2000, 2001, 2002, 2003, 2004 Shawn Betts <sabetts@vcn.bc.ca> 3 * 4 * This file is part of ratpoison. 5 * 6 * ratpoison 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 2, or (at your option) 9 * any later version. 10 * 11 * ratpoison 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 software; see the file COPYING. If not, write to 18 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, 19 * Boston, MA 02111-1307 USA 20 */ 21 22 #ifndef _RATPOISON_SBUF_H 23 #define _RATPOISON_SBUF_H 1 24 25 #include <stdlib.h> 26 27 struct sbuf 28 { 29 char *data; 30 size_t len; 31 size_t maxsz; 32 33 /* sbuf can exist in a list. */ 34 struct list_head node; 35 }; 36 37 struct sbuf *sbuf_new (size_t initsz); 38 void sbuf_free (struct sbuf *b); 39 char *sbuf_free_struct (struct sbuf *b); 40 char *sbuf_concat (struct sbuf *b, const char *str); 41 char *sbuf_nconcat (struct sbuf *b, const char *str, int len); 42 char *sbuf_copy (struct sbuf *b, const char *str); 43 char *sbuf_clear (struct sbuf *b); 44 char *sbuf_get (struct sbuf *b); 45 char *sbuf_printf (struct sbuf *b, char *fmt, ...); 46 char *sbuf_printf_concat (struct sbuf *b, char *fmt, ...); 47 void sbuf_chop (struct sbuf *b); 48 49 #endif /* ! _RATPOISON_SBUF_H */ 50