![]()
|
buffio.hGo to the documentation of this file.00001 #ifndef __BUFFIO_H__ 00002 #define __BUFFIO_H__ 00003 00004 /** @file buffio.h - Treat buffer as an I/O stream. 00005 00006 (c) 1998-2002 (W3C) MIT, INRIA, Keio University 00007 See tidy.h for the copyright notice. 00008 00009 CVS Info : 00010 00011 $Author: creitzel $ 00012 $Date: 2002/12/13 23:29:41 $ 00013 $Revision: 1.1.2.1 $ 00014 00015 Requires buffer to automatically grow as bytes are added. 00016 Must keep track of current read and write points. 00017 00018 */ 00019 00020 #include "platform.h" 00021 #include "tidy.h" 00022 00023 #ifdef __cplusplus 00024 extern "C" { 00025 #endif 00026 00027 /** TidyBuffer - A chunk of memory */ 00028 TIDY_STRUCT 00029 struct _TidyBuffer 00030 { 00031 byte* bp; /**< Pointer to bytes */ 00032 uint size; /**< # bytes currently in use */ 00033 uint allocated; /**< # bytes allocated */ 00034 uint next; /**< Offset of current input position */ 00035 }; 00036 00037 /** Zero out data structure */ 00038 TIDY_EXPORT void tidyBufInit( TidyBuffer* buf ); 00039 00040 /** Free current buffer, allocate given amount, reset input pointer */ 00041 TIDY_EXPORT void tidyBufAlloc( TidyBuffer* buf, uint allocSize ); 00042 00043 /** Expand buffer to given size. 00044 ** Chunk size is minimum growth. Pass 0 for default of 256 bytes. 00045 */ 00046 TIDY_EXPORT void tidyBufCheckAlloc( TidyBuffer* buf, 00047 uint allocSize, uint chunkSize ); 00048 00049 /** Free current contents and zero out */ 00050 TIDY_EXPORT void tidyBufFree( TidyBuffer* buf ); 00051 00052 /** Set buffer bytes to 0 */ 00053 TIDY_EXPORT void tidyBufClear( TidyBuffer* buf ); 00054 00055 /** Attach to existing buffer */ 00056 TIDY_EXPORT void tidyBufAttach( TidyBuffer* buf, void* bp, uint size ); 00057 00058 /** Detach from buffer. Caller must free. */ 00059 TIDY_EXPORT void tidyBufDetach( TidyBuffer* buf ); 00060 00061 00062 /** Append bytes to buffer. Expand if necessary. */ 00063 TIDY_EXPORT void tidyBufAppend( TidyBuffer* buf, void* vp, uint size ); 00064 00065 /** Append one byte to buffer. Expand if necessary. */ 00066 TIDY_EXPORT void tidyBufPutByte( TidyBuffer* buf, byte bv ); 00067 00068 /** Get byte from end of buffer */ 00069 TIDY_EXPORT int tidyBufPopByte( TidyBuffer* buf ); 00070 00071 00072 /** Get byte from front of buffer. Increment input offset. */ 00073 TIDY_EXPORT int tidyBufGetByte( TidyBuffer* buf ); 00074 00075 /** At end of buffer? */ 00076 TIDY_EXPORT Bool tidyBufEndOfInput( TidyBuffer* buf ); 00077 00078 /** Put a byte back into the buffer. Decrement input offset. */ 00079 TIDY_EXPORT void tidyBufUngetByte( TidyBuffer* buf, byte bv ); 00080 00081 00082 /************** 00083 TIDY 00084 **************/ 00085 00086 /* Forward declarations 00087 */ 00088 00089 /** Initialize a buffer input source */ 00090 TIDY_EXPORT void initInputBuffer( TidyInputSource* inp, TidyBuffer* buf ); 00091 00092 /** Initialize a buffer output sink */ 00093 TIDY_EXPORT void initOutputBuffer( TidyOutputSink* outp, TidyBuffer* buf ); 00094 00095 #ifdef __cplusplus 00096 } 00097 #endif 00098 #endif /* __BUFFIO_H__ */ Generated on Fri Dec 13 18:27:08 2002 for HTML Tidy by ![]() |