HTML Tidy
0.1
buffio.h
Go to the documentation of this file.
1
#ifndef __TIDY_BUFFIO_H__
2
#define __TIDY_BUFFIO_H__
3
4
/** @file buffio.h - Treat buffer as an I/O stream.
5
6
(c) 1998-2007 (W3C) MIT, ERCIM, Keio University
7
See tidy.h for the copyright notice.
8
9
Requires buffer to automatically grow as bytes are added.
10
Must keep track of current read and write points.
11
12
*/
13
14
#include "platform.h"
15
#include "
tidy.h
"
16
17
#ifdef __cplusplus
18
extern
"C"
{
19
#endif
20
21
/** TidyBuffer - A chunk of memory */
22
TIDY_STRUCT
23
struct
_TidyBuffer
24
{
25
TidyAllocator
*
allocator
;
/**< Memory allocator */
26
byte*
bp
;
/**< Pointer to bytes */
27
uint
size
;
/**< # bytes currently in use */
28
uint
allocated
;
/**< # bytes allocated */
29
uint
next
;
/**< Offset of current input position */
30
};
31
32
/** Initialize data structure using the default allocator */
33
TIDY_EXPORT
void
TIDY_CALL
tidyBufInit
(
TidyBuffer
* buf );
34
35
/** Initialize data structure using the given custom allocator */
36
TIDY_EXPORT
void
TIDY_CALL
tidyBufInitWithAllocator
(
TidyBuffer
* buf,
TidyAllocator
* allocator );
37
38
/** Free current buffer, allocate given amount, reset input pointer,
39
use the default allocator */
40
TIDY_EXPORT
void
TIDY_CALL
tidyBufAlloc
(
TidyBuffer
* buf, uint allocSize );
41
42
/** Free current buffer, allocate given amount, reset input pointer,
43
use the given custom allocator */
44
TIDY_EXPORT
void
TIDY_CALL
tidyBufAllocWithAllocator
(
TidyBuffer
* buf,
45
TidyAllocator
* allocator,
46
uint allocSize );
47
48
/** Expand buffer to given size.
49
** Chunk size is minimum growth. Pass 0 for default of 256 bytes.
50
*/
51
TIDY_EXPORT
void
TIDY_CALL
tidyBufCheckAlloc
(
TidyBuffer
* buf,
52
uint allocSize, uint chunkSize );
53
54
/** Free current contents and zero out */
55
TIDY_EXPORT
void
TIDY_CALL
tidyBufFree
(
TidyBuffer
* buf );
56
57
/** Set buffer bytes to 0 */
58
TIDY_EXPORT
void
TIDY_CALL
tidyBufClear
(
TidyBuffer
* buf );
59
60
/** Attach to existing buffer */
61
TIDY_EXPORT
void
TIDY_CALL
tidyBufAttach
(
TidyBuffer
* buf, byte* bp, uint size );
62
63
/** Detach from buffer. Caller must free. */
64
TIDY_EXPORT
void
TIDY_CALL
tidyBufDetach
(
TidyBuffer
* buf );
65
66
67
/** Append bytes to buffer. Expand if necessary. */
68
TIDY_EXPORT
void
TIDY_CALL
tidyBufAppend
(
TidyBuffer
* buf,
void
* vp, uint size );
69
70
/** Append one byte to buffer. Expand if necessary. */
71
TIDY_EXPORT
void
TIDY_CALL
tidyBufPutByte
(
TidyBuffer
* buf, byte bv );
72
73
/** Get byte from end of buffer */
74
TIDY_EXPORT
int
TIDY_CALL
tidyBufPopByte
(
TidyBuffer
* buf );
75
76
77
/** Get byte from front of buffer. Increment input offset. */
78
TIDY_EXPORT
int
TIDY_CALL
tidyBufGetByte
(
TidyBuffer
* buf );
79
80
/** At end of buffer? */
81
TIDY_EXPORT Bool TIDY_CALL
tidyBufEndOfInput
(
TidyBuffer
* buf );
82
83
/** Put a byte back into the buffer. Decrement input offset. */
84
TIDY_EXPORT
void
TIDY_CALL
tidyBufUngetByte
(
TidyBuffer
* buf, byte bv );
85
86
87
/**************
88
TIDY
89
**************/
90
91
/* Forward declarations
92
*/
93
94
/** Initialize a buffer input source */
95
TIDY_EXPORT
void
TIDY_CALL
tidyInitInputBuffer
(
TidyInputSource
* inp,
TidyBuffer
* buf );
96
97
/** Initialize a buffer output sink */
98
TIDY_EXPORT
void
TIDY_CALL
tidyInitOutputBuffer
(
TidyOutputSink
* outp,
TidyBuffer
* buf );
99
100
#ifdef __cplusplus
101
}
102
#endif
103
#endif
/* __TIDY_BUFFIO_H__ */
104
105
/*
106
* local variables:
107
* mode: c
108
* indent-tabs-mode: nil
109
* c-basic-offset: 4
110
* eval: (c-set-offset 'substatement-open 0)
111
* end:
112
*/
include
buffio.h
Generated on Sat Nov 10 2012 07:27:03 for HTML Tidy by
1.8.1.1