1/*---------------------------------------------------------------------------* 2 | PDFlib - A library for generating PDF on the fly | 3 +---------------------------------------------------------------------------+ 4 | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | 5 +---------------------------------------------------------------------------+ 6 | | 7 | This software is subject to the PDFlib license. It is NOT in the | 8 | public domain. Extended versions and commercial licenses are | 9 | available, please check http://www.pdflib.com. | 10 | | 11 *---------------------------------------------------------------------------*/ 12 13/* $Id: pc_sbuf.h 14574 2005-10-29 16:27:43Z bonefish $ 14 * 15 * Dynamically growing string buffers. 16 * 17 */ 18 19#ifndef PC_SBUF_H 20#define PC_SBUF_H 21 22#include "pc_core.h" 23 24typedef struct pdc_sbuf_s pdc_sbuf; 25 26/* TODO: init_len parameter */ 27pdc_sbuf * pdc_sb_new(pdc_core *pdc); 28void pdc_sb_delete(pdc_sbuf *sb); 29 30void pdc_sb_copy(pdc_sbuf *dst, const pdc_sbuf *src); 31void pdc_sb_write(pdc_sbuf *dst, const char *src, int len); 32 33/* public macros. 34*/ 35#define pdc_sb_putc(b, c) \ 36 (((b)->scan < (b)->limit) \ 37 ? (void) (*(b)->scan++ = (char) (c)) \ 38 : pdc_sb_put_c((b), (c))) 39 40#define pdc_sb_get_cptr(b) \ 41 ((b)->buf) 42 43#define pdc_sb_get_size(b) \ 44 ((b)->scan - (b)->buf) 45 46#define pdc_sb_rewrite(b) \ 47 ((void) ((b)->scan = (b)->buf)) 48 49 50/* the declarations below are strictly private to pc_sbuf.c! 51** use the above macros only! 52*/ 53struct pdc_sbuf_s 54{ 55 pdc_core * pdc; 56 57 char * buf; 58 char * scan; 59 char * limit; 60}; 61 62void pdc_sb_put_c(pdc_sbuf *sb, int ch); 63 64#endif /* PC_SBUF_H */ 65