~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

TidyLib
tidy/include/buffio.h

Version: ~ [ 1.0 ] ~

  1 #ifndef __BUFFIO_H__
  2 #define __BUFFIO_H__
  3 
  4 /** @file buffio.h - Treat buffer as an I/O stream.
  5 
  6   (c) 1998-2005 (W3C) MIT, ERCIM, Keio University
  7   See tidy.h for the copyright notice.
  8 
  9   CVS Info :
 10 
 11     $Author: arnaud02 $ 
 12     $Date: 2005/04/08 09:11:12 $ 
 13     $Revision: 1.5 $ 
 14 
 15   Requires buffer to automatically grow as bytes are added.
 16   Must keep track of current read and write points.
 17 
 18 */
 19 
 20 #include "platform.h"
 21 #include "tidy.h"
 22 
 23 #ifdef __cplusplus
 24 extern "C" {
 25 #endif
 26 
 27 /** TidyBuffer - A chunk of memory */
 28 TIDY_STRUCT
 29 struct _TidyBuffer 
 30 {
 31     byte* bp;           /**< Pointer to bytes */
 32     uint  size;         /**< # bytes currently in use */
 33     uint  allocated;    /**< # bytes allocated */ 
 34     uint  next;         /**< Offset of current input position */
 35 };
 36 
 37 /** Zero out data structure */
 38 TIDY_EXPORT void TIDY_CALL tidyBufInit( TidyBuffer* buf );
 39 
 40 /** Free current buffer, allocate given amount, reset input pointer */
 41 TIDY_EXPORT void TIDY_CALL tidyBufAlloc( TidyBuffer* buf, uint allocSize );
 42 
 43 /** Expand buffer to given size. 
 44 **  Chunk size is minimum growth. Pass 0 for default of 256 bytes.
 45 */
 46 TIDY_EXPORT void TIDY_CALL tidyBufCheckAlloc( TidyBuffer* buf,
 47                                              uint allocSize, uint chunkSize );
 48 
 49 /** Free current contents and zero out */
 50 TIDY_EXPORT void TIDY_CALL tidyBufFree( TidyBuffer* buf );
 51 
 52 /** Set buffer bytes to 0 */
 53 TIDY_EXPORT void TIDY_CALL tidyBufClear( TidyBuffer* buf );
 54 
 55 /** Attach to existing buffer */
 56 TIDY_EXPORT void TIDY_CALL tidyBufAttach( TidyBuffer* buf, byte* bp, uint size );
 57 
 58 /** Detach from buffer.  Caller must free. */
 59 TIDY_EXPORT void TIDY_CALL tidyBufDetach( TidyBuffer* buf );
 60 
 61 
 62 /** Append bytes to buffer.  Expand if necessary. */
 63 TIDY_EXPORT void TIDY_CALL tidyBufAppend( TidyBuffer* buf, void* vp, uint size );
 64 
 65 /** Append one byte to buffer.  Expand if necessary. */
 66 TIDY_EXPORT void TIDY_CALL tidyBufPutByte( TidyBuffer* buf, byte bv );
 67 
 68 /** Get byte from end of buffer */
 69 TIDY_EXPORT int TIDY_CALL  tidyBufPopByte( TidyBuffer* buf );
 70 
 71 
 72 /** Get byte from front of buffer.  Increment input offset. */
 73 TIDY_EXPORT int TIDY_CALL  tidyBufGetByte( TidyBuffer* buf );
 74 
 75 /** At end of buffer? */
 76 TIDY_EXPORT Bool TIDY_CALL tidyBufEndOfInput( TidyBuffer* buf );
 77 
 78 /** Put a byte back into the buffer.  Decrement input offset. */
 79 TIDY_EXPORT void TIDY_CALL tidyBufUngetByte( TidyBuffer* buf, byte bv );
 80 
 81 
 82 /**************
 83    TIDY
 84 **************/
 85 
 86 /* Forward declarations
 87 */
 88 
 89 /** Initialize a buffer input source */
 90 TIDY_EXPORT void TIDY_CALL initInputBuffer( TidyInputSource* inp, TidyBuffer* buf );
 91 
 92 /** Initialize a buffer output sink */
 93 TIDY_EXPORT void TIDY_CALL initOutputBuffer( TidyOutputSink* outp, TidyBuffer* buf );
 94 
 95 #ifdef __cplusplus
 96 }
 97 #endif
 98 #endif /* __BUFFIO_H__ */
 99 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.