# I/O and Messages

## Data Structures
struct | _TidyInputSource
struct | _TidyOutputSink
## Defines
#define | EndOfStream (~0u)
## Typedefs
typedef int(* | TidyGetByteFunc )(uint sourceData)
typedef void(* | TidyUngetByteFunc )(uint sourceData, byte bt)
typedef Bool(* | TidyEOFFunc )(uint sourceData)
typedef TIDY_STRUCT struct _TidyInputSource | TidyInputSource
typedef void(* | TidyPutByteFunc )(uint sinkData, byte bt)
typedef TIDY_STRUCT struct _TidyOutputSink | TidyOutputSink
typedef Bool(* | TidyReportFilter )(TidyDoc tdoc, TidyReportLevel lvl, uint line, uint col, ctmbstr mssg)
## Functions
Bool | tidyInitSource (TidyInputSource *source, void *srcData, TidyGetByteFunc gbFunc, TidyUngetByteFunc ugbFunc, TidyEOFFunc endFunc)
uint | tidyGetByte (TidyInputSource *source)
void | tidyUngetByte (TidyInputSource *source, uint byteValue)
Bool | tidyIsEOF (TidyInputSource *source)
Bool | tidyInitSink (TidyOutputSink *sink, void *snkData, TidyPutByteFunc pbFunc)
void | tidyPutByte (TidyOutputSink *sink, uint byteValue)
Bool | tidySetReportFilter (TidyDoc tdoc, TidyReportFilter filtCallback)
FILE * | tidySetErrorFile (TidyDoc tdoc, ctmbstr errfilnam)
int | tidySetErrorBuffer (TidyDoc tdoc, TidyBuffer *errbuf)
int | tidySetErrorSink (TidyDoc tdoc, TidyOutputSink *sink)

## Detailed Description

By default, Tidy will define, create and use instances of input and output handlers for standard C buffered I/O (i.e. FILE* stdin, FILE* stdout and FILE* stderr for content input, content output and diagnostic output, respectively. A FILE* cfgFile input handler will be used for config files. Command line options will just be set directly.

## Define Documentation

#define EndOfStream (~0u)

| End of input "character"

## Typedef Documentation

typedef int(* TidyGetByteFunc)( uint sourceData )

| Input Callback: get next byte of input

typedef void(* TidyUngetByteFunc)( uint sourceData, byte bt )

| Input Callback: unget a byte of input

typedef Bool(* TidyEOFFunc)( uint sourceData )

| Input Callback: is end of input?

typedef TIDY_STRUCT struct _TidyInputSource TidyInputSource

| TidyInputSource - Delivers raw bytes of input

typedef void(* TidyPutByteFunc)( uint sinkData, byte bt )

| Output callback: send a byte to output

typedef TIDY_STRUCT struct _TidyOutputSink TidyOutputSink

| TidyOutputSink - accepts raw bytes of output

typedef Bool(* TidyReportFilter)( TidyDoc tdoc, TidyReportLevel lvl, uint line, uint col, ctmbstr mssg )

| Callback to filter messages by diagnostic level: info, warning, etc. Just set diagnostic output handler to redirect all diagnostics output. Return true to proceed with output, false to cancel.

## Function Documentation

Bool tidyInitSource | ( | TidyInputSource * | source,
|  | void * | srcData,
|  | TidyGetByteFunc | gbFunc,
|  | TidyUngetByteFunc | ugbFunc,
|  | TidyEOFFunc | endFunc
| ) |

| Facilitates user defined source by providing an entry point to marshal pointers-to-functions. Needed by .NET and possibly other language bindings.

uint tidyGetByte | ( | TidyInputSource * | source | ) |

| Helper: get next byte from input source

void tidyUngetByte | ( | TidyInputSource * | source,
|  | uint | byteValue
| ) |

| Helper: unget byte back to input source

Bool tidyIsEOF | ( | TidyInputSource * | source | ) |

| Helper: check if input source at end

Bool tidyInitSink | ( | TidyOutputSink * | sink,
|  | void * | snkData,
|  | TidyPutByteFunc | pbFunc
| ) |

| Facilitates user defined sinks by providing an entry point to marshal pointers-to-functions. Needed by .NET and possibly other language bindings.

void tidyPutByte | ( | TidyOutputSink * | sink,
|  | uint | byteValue
| ) |

| Helper: send a byte to output

Bool tidySetReportFilter | ( | TidyDoc | tdoc,
|  | TidyReportFilter | filtCallback
| ) |

| Give Tidy a filter callback to use

FILE* tidySetErrorFile | ( | TidyDoc | tdoc,
|  | ctmbstr | errfilnam
| ) |

| Set error sink to named file

int tidySetErrorBuffer | ( | TidyDoc | tdoc,
|  | TidyBuffer * | errbuf
| ) |

| Set error sink to given buffer

int tidySetErrorSink | ( | TidyDoc | tdoc,
|  | TidyOutputSink * | sink
| ) |

| Set error sink to given generic sink