1
#ifndef __TIDY_BUFFIO_H__
2
#define __TIDY_BUFFIO_H__
4
4
/** @file buffio.h - Treat buffer as an I/O stream.
6
(c) 1998-2005 (W3C) MIT, ERCIM, Keio University
6
(c) 1998-2007 (W3C) MIT, ERCIM, Keio University
7
7
See tidy.h for the copyright notice.
11
11
$Author: arnaud02 $
12
$Date: 2005/04/08 09:11:12 $
12
$Date: 2007/01/23 11:17:45 $
15
15
Requires buffer to automatically grow as bytes are added.
16
16
Must keep track of current read and write points.
31
TidyAllocator* allocator; /**< Memory allocator */
31
32
byte* bp; /**< Pointer to bytes */
32
33
uint size; /**< # bytes currently in use */
33
34
uint allocated; /**< # bytes allocated */
34
35
uint next; /**< Offset of current input position */
37
/** Zero out data structure */
38
/** Initialize data structure using the default allocator */
38
39
TIDY_EXPORT void TIDY_CALL tidyBufInit( TidyBuffer* buf );
40
/** Free current buffer, allocate given amount, reset input pointer */
41
/** Initialize data structure using the given custom allocator */
42
TIDY_EXPORT void TIDY_CALL tidyBufInitWithAllocator( TidyBuffer* buf, TidyAllocator* allocator );
44
/** Free current buffer, allocate given amount, reset input pointer,
45
use the default allocator */
41
46
TIDY_EXPORT void TIDY_CALL tidyBufAlloc( TidyBuffer* buf, uint allocSize );
48
/** Free current buffer, allocate given amount, reset input pointer,
49
use the given custom allocator */
50
TIDY_EXPORT void TIDY_CALL tidyBufAllocWithAllocator( TidyBuffer* buf,
51
TidyAllocator* allocator,
43
54
/** Expand buffer to given size.
44
55
** Chunk size is minimum growth. Pass 0 for default of 256 bytes.
46
57
TIDY_EXPORT void TIDY_CALL tidyBufCheckAlloc( TidyBuffer* buf,
47
uint allocSize, uint chunkSize );
58
uint allocSize, uint chunkSize );
49
60
/** Free current contents and zero out */
50
61
TIDY_EXPORT void TIDY_CALL tidyBufFree( TidyBuffer* buf );
89
100
/** Initialize a buffer input source */
90
TIDY_EXPORT void TIDY_CALL initInputBuffer( TidyInputSource* inp, TidyBuffer* buf );
101
TIDY_EXPORT void TIDY_CALL tidyInitInputBuffer( TidyInputSource* inp, TidyBuffer* buf );
92
103
/** Initialize a buffer output sink */
93
TIDY_EXPORT void TIDY_CALL initOutputBuffer( TidyOutputSink* outp, TidyBuffer* buf );
104
TIDY_EXPORT void TIDY_CALL tidyInitOutputBuffer( TidyOutputSink* outp, TidyBuffer* buf );
95
106
#ifdef __cplusplus
98
#endif /* __BUFFIO_H__ */
109
#endif /* __TIDY_BUFFIO_H__ */
114
* indent-tabs-mode: nil
116
* eval: (c-set-offset 'substatement-open 0)