1 /*** sbuffer.h **************************************************************** 2 ** 3 ** This file is part of BibTool. 4 ** It is distributed under the GNU General Public License. 5 ** See the file COPYING for details. 6 ** 7 ** (c) 1996-2020 Gerd Neugebauer 8 ** 9 ** Net: gene@gerd-neugebauer.de 10 ** 11 ** This program is free software; you can redistribute it and/or modify 12 ** it under the terms of the GNU General Public License as published by 13 ** the Free Software Foundation; either version 2, or (at your option) 14 ** any later version. 15 ** 16 ** This program is distributed in the hope that it will be useful, 17 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 18 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 ** GNU General Public License for more details. 20 ** 21 ** You should have received a copy of the GNU General Public License 22 ** along with this program; if not, write to the Free Software 23 ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 ** 25 **----------------------------------------------------------------------------- 26 ** Description: 27 ** This header file makes accessible the functions to treat 28 ** strings like streams In addition to the functions defined in 29 ** |sbuffer.c| one macro is defined here. 30 ** 31 ******************************************************************************/ 32 33 #ifndef sbputchar 34 35 typedef struct 36 { char *sb__string; 37 int sb__size; 38 int sb__ptr; 39 } StringBuffer; 40 41 #define StringBufferIncrement 256 42 43 44 extern StringBuffer* sbopen( 45 #ifdef __STDC__ 46 void 47 #endif 48 ); 49 extern bool sbclose( 50 #ifdef __STDC__ 51 StringBuffer* 52 #endif 53 ); 54 extern bool sbputs( 55 #ifdef __STDC__ 56 char *, 57 StringBuffer* 58 #endif 59 ); 60 extern bool sbputc( 61 #ifdef __STDC__ 62 int, 63 StringBuffer* 64 #endif 65 ); 66 extern char* sbflush( 67 #ifdef __STDC__ 68 StringBuffer* 69 #endif 70 ); 71 extern int sbtell( 72 #ifdef __STDC__ 73 StringBuffer* 74 #endif 75 ); 76 extern void sbrewind( 77 #ifdef __STDC__ 78 StringBuffer* 79 #endif 80 ); 81 extern bool sbseek( 82 #ifdef __STDC__ 83 StringBuffer*, 84 int 85 #endif 86 ); 87 88 /*----------------------------------------------------------------------------- 89 ** Macro: sbputchar() 90 ** Purpose: Put the character |C| into the string buffer |SB|. 91 ** 92 ** This macro is not sane. The arguments are expanded 93 ** several times. Thus they must not contain side 94 ** effects. 95 ** Arguments: 96 ** C Character to put. 97 ** SB Destination string buffer. 98 ** Returns: nothing 99 **___________________________________________________ */ 100 #define sbputchar(C,SB) ((SB)->sb__ptr < (SB)->sb__size \ 101 ? (SB)->sb__string[(SB)->sb__ptr++] = C \ 102 : sbputc(C,SB)) 103 104 #endif 105