Tidy provides flexible I/O.
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.
Data Structures | |
| struct | TidyBuffer |
| A TidyBuffer is chunk of memory that can be used for multiple I/O purposes within Tidy. More... | |
| struct | TidyInputSource |
| This type defines an input source capable of delivering raw bytes of input. More... | |
| struct | TidyOutputSink |
| This type defines an output destination capable of accepting raw bytes of output. More... | |
Input Source | |
If you wish to write to your own input sources, then these types, structs, and functions will allow them to work seamlessly with Tidy. | |
| typedef int(TIDY_CALL * | TidyGetByteFunc) (void *sourceData) |
| Input Callback: get next byte of input. | |
| typedef void(TIDY_CALL * | TidyUngetByteFunc) (void *sourceData, byte bt) |
| Input Callback: unget a byte of input. | |
| typedef Bool(TIDY_CALL * | TidyEOFFunc) (void *sourceData) |
| Input Callback: is end of input? | |
| Bool TIDY_CALL | 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. | |
| uint TIDY_CALL | tidyGetByte (TidyInputSource *source) |
| Helper: get next byte from input source. | |
| void TIDY_CALL | tidyUngetByte (TidyInputSource *source, uint byteValue) |
| Helper: unget byte back to input source. | |
| Bool TIDY_CALL | tidyIsEOF (TidyInputSource *source) |
| Helper: check if input source at end. | |
| #define | EndOfStream (~0u) |
| End of input "character". | |
Output Sink | |
| typedef void(TIDY_CALL * | TidyPutByteFunc) (void *sinkData, byte bt) |
| Output callback: send a byte to output. | |
| Bool TIDY_CALL | tidyInitSink (TidyOutputSink *sink, void *snkData, TidyPutByteFunc pbFunc) |
| Facilitates user defined sinks by providing an entry point to marshal pointers-to-functions. | |
| void TIDY_CALL | tidyPutByte (TidyOutputSink *sink, uint byteValue) |
| Helper: send a byte to output. | |
Error and Message Callbacks - TidyReportFilter | |
A simple callback to filter or collect messages by diagnostic level, for example, TidyInfo, TidyWarning, etc. Its name reflects its original purpose as a filter, by which your application can inform LibTidy whether or not to output a particular report. | |
| typedef Bool(TIDY_CALL * | TidyReportFilter) (TidyDoc tdoc, TidyReportLevel lvl, uint line, uint col, ctmbstr mssg) |
| This typedef represents the required signature for your provided callback function should you wish to register one with tidySetReportFilter(). | |
| Bool TIDY_CALL | tidySetReportFilter (TidyDoc tdoc, TidyReportFilter filtCallback) |
| This function informs Tidy to use the specified callback to send reports. | |
Error and Message Callbacks - TidyReportCallback | |
A simple callback to filter or collect messages reported by Tidy. Unlike TidyReportFilter, more data are provided (including a va_list), making this callback suitable for applications that provide more sophisticated handling of reports.
| |
| typedef Bool(TIDY_CALL * | TidyReportCallback) (TidyDoc tdoc, TidyReportLevel lvl, uint line, uint col, ctmbstr code, va_list args) |
| This typedef represents the required signature for your provided callback function should you wish to register one with tidySetReportCallback(). | |
| Bool TIDY_CALL | tidySetReportCallback (TidyDoc tdoc, TidyReportCallback filtCallback) |
| This function informs Tidy to use the specified callback to send reports. | |
Error and Message Callbacks - TidyMessageCallback | |
A sophisticated and extensible callback to filter or collect messages reported by Tidy. It returns only an opaque type TidyMessage for every report and dialogue message, and this message can be queried with the TidyMessageCallback API, below. Note that unlike the older filters, this callback exposes all output that LibTidy emits (excluding the console application, which is a client of LibTidy). | |
| typedef Bool(TIDY_CALL * | TidyMessageCallback) (TidyMessage tmessage) |
| This typedef represents the required signature for your provided callback function should you wish to register one with tidySetMessageCallback(). | |
| Bool TIDY_CALL | tidySetMessageCallback (TidyDoc tdoc, TidyMessageCallback filtCallback) |
| This function informs Tidy to use the specified callback to send reports. | |
Printing | |
LibTidy applications can somewhat track the progress of the tidying process by using this provided callback. It relates where something in the source document ended up in the output. | |
| typedef void(TIDY_CALL * | TidyPPProgress) (TidyDoc tdoc, uint line, uint col, uint destLine) |
| This typedef represents the required signature for your provided callback function should you wish to register one with tidySetMessageCallback(). | |
| Bool TIDY_CALL | tidySetPrettyPrinterCallback (TidyDoc tdoc, TidyPPProgress callback) |
| This function informs Tidy to use the specified callback for tracking the pretty-printing process progress. | |
Emacs-compatible reporting support. | |
If you work with Emacs and prefer Tidy's report output to be in a form that is easy for Emacs to parse, then these functions may be valuable. | |
| void TIDY_CALL | tidySetEmacsFile (TidyDoc tdoc, ctmbstr filePath) |
| Set the file path to use for reports when TidyEmacs is being used. | |
| ctmbstr TIDY_CALL | tidyGetEmacsFile (TidyDoc tdoc) |
| Get the file path to use for reports when TidyEmacs is being used. | |
Error Sink | |
Send Tidy's output to any of several destinations with these functions. | |
| FILE *TIDY_CALL | tidySetErrorFile (TidyDoc tdoc, ctmbstr errfilnam) |
| Set error sink to named file. | |
| int TIDY_CALL | tidySetErrorBuffer (TidyDoc tdoc, TidyBuffer *errbuf) |
| Set error sink to given buffer. | |
| int TIDY_CALL | tidySetErrorSink (TidyDoc tdoc, TidyOutputSink *sink) |
| Set error sink to given generic sink. | |
TidyMessageCallback API | |
When using TidyMessageCallback you will be supplied with a TidyMessage object, which is used as a token to be interrogated with the following API before the callback returns.
| |
| TidyDoc TIDY_CALL | tidyGetMessageDoc (TidyMessage tmessage) |
| Get the tidy document this message comes from. | |
| uint TIDY_CALL | tidyGetMessageCode (TidyMessage tmessage) |
| Get the message code. | |
| ctmbstr TIDY_CALL | tidyGetMessageKey (TidyMessage tmessage) |
| Get the message key string. | |
| int TIDY_CALL | tidyGetMessageLine (TidyMessage tmessage) |
| Get the line number the message applies to. | |
| int TIDY_CALL | tidyGetMessageColumn (TidyMessage tmessage) |
| Get the column the message applies to. | |
| TidyReportLevel TIDY_CALL | tidyGetMessageLevel (TidyMessage tmessage) |
| Get the TidyReportLevel of the message. | |
| Bool TIDY_CALL | tidyGetMessageIsMuted (TidyMessage tmessage) |
| Get the muted status of the message, that is, whether or not the current configuration indicated that this message should be muted. | |
| ctmbstr TIDY_CALL | tidyGetMessageFormatDefault (TidyMessage tmessage) |
| Get the default format string, which is the format string for the message in Tidy's default localization (en_us). | |
| ctmbstr TIDY_CALL | tidyGetMessageFormat (TidyMessage tmessage) |
| Get the localized format string. | |
| ctmbstr TIDY_CALL | tidyGetMessageDefault (TidyMessage tmessage) |
| Get the message with the format string already completed, in Tidy's default localization. | |
| ctmbstr TIDY_CALL | tidyGetMessage (TidyMessage tmessage) |
| Get the message with the format string already completed, in Tidy's current localization. | |
| ctmbstr TIDY_CALL | tidyGetMessagePosDefault (TidyMessage tmessage) |
| Get the position part part of the message in the default language. | |
| ctmbstr TIDY_CALL | tidyGetMessagePos (TidyMessage tmessage) |
| Get the position part part of the message in the current language. | |
| ctmbstr TIDY_CALL | tidyGetMessagePrefixDefault (TidyMessage tmessage) |
| Get the prefix part of a message in the default language. | |
| ctmbstr TIDY_CALL | tidyGetMessagePrefix (TidyMessage tmessage) |
| Get the prefix part of a message in the current language. | |
| ctmbstr TIDY_CALL | tidyGetMessageOutputDefault (TidyMessage tmessage) |
| Get the complete message as Tidy would emit it in the default localization. | |
| ctmbstr TIDY_CALL | tidyGetMessageOutput (TidyMessage tmessage) |
| Get the complete message as Tidy would emit it in the current localization. | |
TidyMessageCallback Arguments API | |
When using TidyMessageCallback you will be supplied with a TidyMessage object which can be used as a token against which to query using this API. This API deals strictly with arguments that a message may or may not have; these are the same arguments that Tidy would apply to a format string in order to fill in the placeholder fields and deliver a complete report or dialogue string to you. | |
| TidyIterator TIDY_CALL | tidyGetMessageArguments (TidyMessage tmessage) |
| Initiates an iterator for a list of arguments related to a given message. | |
| TidyMessageArgument TIDY_CALL | tidyGetNextMessageArgument (TidyMessage tmessage, TidyIterator *iter) |
| Given a valid TidyIterator initiated with tidyGetMessageArguments(), returns an instance of the opaque type TidyMessageArgument, which serves as a token against which the remaining argument API functions may be used to query information. | |
| TidyFormatParameterType TIDY_CALL | tidyGetArgType (TidyMessage tmessage, TidyMessageArgument *arg) |
| Returns the TidyFormatParameterType of the given message argument. | |
| ctmbstr TIDY_CALL | tidyGetArgFormat (TidyMessage tmessage, TidyMessageArgument *arg) |
| Returns the format specifier of the given message argument. | |
| ctmbstr TIDY_CALL | tidyGetArgValueString (TidyMessage tmessage, TidyMessageArgument *arg) |
| Returns the string value of the given message argument. | |
| uint TIDY_CALL | tidyGetArgValueUInt (TidyMessage tmessage, TidyMessageArgument *arg) |
| Returns the unsigned integer value of the given message argument. | |
| int TIDY_CALL | tidyGetArgValueInt (TidyMessage tmessage, TidyMessageArgument *arg) |
| Returns the integer value of the given message argument. | |
| double TIDY_CALL | tidyGetArgValueDouble (TidyMessage tmessage, TidyMessageArgument *arg) |
| Returns the double value of the given message argument. | |
| struct _TidyBuffer |
A TidyBuffer is chunk of memory that can be used for multiple I/O purposes within Tidy.
| Data Fields | ||
|---|---|---|
| uint | allocated | Number of bytes allocated. |
| TidyAllocator * | allocator | Memory allocator. |
| byte * | bp | Pointer to bytes. |
| uint | next | Offset of current input position. |
| uint | size | Number of bytes currently in use. |
| struct TidyInputSource |
This type defines an input source capable of delivering raw bytes of input.
| Data Fields | ||
|---|---|---|
| TidyEOFFunc | eof | Pointer to "eof" callback. |
| TidyGetByteFunc | getByte | Pointer to "get byte" callback. |
| void * | sourceData |
Input context. Passed to callbacks. |
| TidyUngetByteFunc | ungetByte | Pointer to "unget" callback. |
| struct TidyOutputSink |
This type defines an output destination capable of accepting raw bytes of output.
| Data Fields | ||
|---|---|---|
| TidyPutByteFunc | putByte | Pointer to "put byte" callback. |
| void * | sinkData |
Output context. Passed to callbacks. |
| #define EndOfStream (~0u) |
End of input "character".
| typedef int(TIDY_CALL * TidyGetByteFunc) (void *sourceData) |
Input Callback: get next byte of input.
| typedef Bool(TIDY_CALL * TidyMessageCallback) (TidyMessage tmessage) |
This typedef represents the required signature for your provided callback function should you wish to register one with tidySetMessageCallback().
Your callback function will be provided with the following parameters.
| tmessage | An opaque type used as a token against which other API calls can be made. |
This typedef represents the required signature for your provided callback function should you wish to register one with tidySetMessageCallback().
Your callback function will be provided with the following parameters.
| tdoc | Indicates the source tidy document. |
| line | Indicates the line in the source document at this point in the process. |
| col | Indicates the column in the source document at this point in the process. |
| destLine | Indicates the line number in the output document at this point in the process. |
Output callback: send a byte to output.
| typedef Bool(TIDY_CALL * TidyReportCallback) (TidyDoc tdoc, TidyReportLevel lvl, uint line, uint col, ctmbstr code, va_list args) |
This typedef represents the required signature for your provided callback function should you wish to register one with tidySetReportCallback().
Your callback function will be provided with the following parameters.
| tdoc | Indicates the tidy document the message comes from. |
| lvl | Specifies the TidyReportLevel of the message. |
| line | Indicates the line number in the source document the message applies to. |
| col | Indicates the column in the source document the message applies to. |
| code | Specifies the message code representing the message. Note that this code is a string value that the API promises to hold constant, as opposed to an enum value that can change at any time. Although this is intended so that you can look up your own application's strings, you can retrieve Tidy's format string with this code by using tidyErrorCodeFromKey() and then the tidyLocalizedString() family of functions. |
| args | Is a va_list of arguments used to fill Tidy's message format string. |
| typedef Bool(TIDY_CALL * TidyReportFilter) (TidyDoc tdoc, TidyReportLevel lvl, uint line, uint col, ctmbstr mssg) |
This typedef represents the required signature for your provided callback function should you wish to register one with tidySetReportFilter().
Your callback function will be provided with the following parameters.
| tdoc | Indicates the tidy document the message comes from. |
| lvl | Specifies the TidyReportLevel of the message. |
| line | Indicates the line number in the source document the message applies to. |
| col | Indicates the column in the source document the message applies to. |
| mssg | Specifies the complete message as Tidy would emit it. |
Input Callback: unget a byte of input.
| ctmbstr TIDY_CALL tidyGetArgFormat | ( | TidyMessage | tmessage, |
| TidyMessageArgument * | arg ) |
Returns the format specifier of the given message argument.
The memory for this string is cleared upon termination of the callback, so do be sure to make your own copy.
| tmessage | The message whose arguments you want to access. |
| arg | The argument that you are querying. |
| TidyFormatParameterType TIDY_CALL tidyGetArgType | ( | TidyMessage | tmessage, |
| TidyMessageArgument * | arg ) |
Returns the TidyFormatParameterType of the given message argument.
| tmessage | The message whose arguments you want to access. |
| arg | The argument that you are querying. |
| double TIDY_CALL tidyGetArgValueDouble | ( | TidyMessage | tmessage, |
| TidyMessageArgument * | arg ) |
Returns the double value of the given message argument.
An assertion will be generated if the argument type is not a double.
| tmessage | The message whose arguments you want to access. |
| arg | The argument that you are querying. |
| int TIDY_CALL tidyGetArgValueInt | ( | TidyMessage | tmessage, |
| TidyMessageArgument * | arg ) |
Returns the integer value of the given message argument.
An assertion will be generated if the argument type is not an integer.
| tmessage | The message whose arguments you want to access. |
| arg | The argument that you are querying. |
| ctmbstr TIDY_CALL tidyGetArgValueString | ( | TidyMessage | tmessage, |
| TidyMessageArgument * | arg ) |
Returns the string value of the given message argument.
An assertion will be generated if the argument type is not a string.
| tmessage | The message whose arguments you want to access. |
| arg | The argument that you are querying. |
| uint TIDY_CALL tidyGetArgValueUInt | ( | TidyMessage | tmessage, |
| TidyMessageArgument * | arg ) |
Returns the unsigned integer value of the given message argument.
An assertion will be generated if the argument type is not an unsigned int.
| tmessage | The message whose arguments you want to access. |
| arg | The argument that you are querying. |
| uint TIDY_CALL tidyGetByte | ( | TidyInputSource * | source | ) |
Helper: get next byte from input source.
| source | A pointer to your input source. |
Get the file path to use for reports when TidyEmacs is being used.
This function provides a proper interface for using the hidden, internal-only TidyEmacsFile configuration option.
| tdoc | The tidy document for which you want to fetch the file path. |
| ctmbstr TIDY_CALL tidyGetMessage | ( | TidyMessage | tmessage | ) |
Get the message with the format string already completed, in Tidy's current localization.
| tmessage | Specify the message that you are querying. |
| TidyIterator TIDY_CALL tidyGetMessageArguments | ( | TidyMessage | tmessage | ) |
Initiates an iterator for a list of arguments related to a given message.
This iterator allows you to iterate through all of the arguments, if any. In order to iterate through the arguments, initiate the iterator with this function, and then use tidyGetNextMessageArgument() to retrieve the first and subsequent arguments. For example:
| tmessage | The message about whose arguments you wish to query. |
| uint TIDY_CALL tidyGetMessageCode | ( | TidyMessage | tmessage | ) |
Get the message code.
| tmessage | Specify the message that you are querying. |
| int TIDY_CALL tidyGetMessageColumn | ( | TidyMessage | tmessage | ) |
Get the column the message applies to.
| tmessage | Specify the message that you are querying. |
| ctmbstr TIDY_CALL tidyGetMessageDefault | ( | TidyMessage | tmessage | ) |
Get the message with the format string already completed, in Tidy's default localization.
| tmessage | Specify the message that you are querying. |
| TidyDoc TIDY_CALL tidyGetMessageDoc | ( | TidyMessage | tmessage | ) |
Get the tidy document this message comes from.
| tmessage | Specify the message that you are querying. |
| ctmbstr TIDY_CALL tidyGetMessageFormat | ( | TidyMessage | tmessage | ) |
Get the localized format string.
If a localized version of the format string doesn't exist, then the default version will be returned.
| tmessage | Specify the message that you are querying. |
| ctmbstr TIDY_CALL tidyGetMessageFormatDefault | ( | TidyMessage | tmessage | ) |
Get the default format string, which is the format string for the message in Tidy's default localization (en_us).
| tmessage | Specify the message that you are querying. |
| Bool TIDY_CALL tidyGetMessageIsMuted | ( | TidyMessage | tmessage | ) |
Get the muted status of the message, that is, whether or not the current configuration indicated that this message should be muted.
| tmessage | Specify the message that you are querying. |
| ctmbstr TIDY_CALL tidyGetMessageKey | ( | TidyMessage | tmessage | ) |
Get the message key string.
| tmessage | Specify the message that you are querying. |
| TidyReportLevel TIDY_CALL tidyGetMessageLevel | ( | TidyMessage | tmessage | ) |
Get the TidyReportLevel of the message.
| tmessage | Specify the message that you are querying. |
| int TIDY_CALL tidyGetMessageLine | ( | TidyMessage | tmessage | ) |
Get the line number the message applies to.
| tmessage | Specify the message that you are querying. |
| ctmbstr TIDY_CALL tidyGetMessageOutput | ( | TidyMessage | tmessage | ) |
Get the complete message as Tidy would emit it in the current localization.
| tmessage | Specify the message that you are querying. |
| ctmbstr TIDY_CALL tidyGetMessageOutputDefault | ( | TidyMessage | tmessage | ) |
Get the complete message as Tidy would emit it in the default localization.
| tmessage | Specify the message that you are querying. |
| ctmbstr TIDY_CALL tidyGetMessagePos | ( | TidyMessage | tmessage | ) |
Get the position part part of the message in the current language.
| tmessage | Specify the message that you are querying. |
| ctmbstr TIDY_CALL tidyGetMessagePosDefault | ( | TidyMessage | tmessage | ) |
Get the position part part of the message in the default language.
| tmessage | Specify the message that you are querying. |
| ctmbstr TIDY_CALL tidyGetMessagePrefix | ( | TidyMessage | tmessage | ) |
Get the prefix part of a message in the current language.
| tmessage | Specify the message that you are querying. |
| ctmbstr TIDY_CALL tidyGetMessagePrefixDefault | ( | TidyMessage | tmessage | ) |
Get the prefix part of a message in the default language.
| tmessage | Specify the message that you are querying. |
| TidyMessageArgument TIDY_CALL tidyGetNextMessageArgument | ( | TidyMessage | tmessage, |
| TidyIterator * | iter ) |
Given a valid TidyIterator initiated with tidyGetMessageArguments(), returns an instance of the opaque type TidyMessageArgument, which serves as a token against which the remaining argument API functions may be used to query information.
| tmessage | The message whose arguments you want to access. |
| iter | The TidyIterator (initiated with tidyOptGetDocLinksList()) token. |
| Bool TIDY_CALL tidyInitSink | ( | TidyOutputSink * | sink, |
| void * | snkData, | ||
| TidyPutByteFunc | pbFunc ) |
Facilitates user defined sinks by providing an entry point to marshal pointers-to-functions.
This is needed by .NET, and possibly other language bindings.
| sink | The sink to populate with data. |
| snkData | The output context. |
| pbFunc | Pointer to the "put byte" callback function. |
| Bool TIDY_CALL 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.
This is needed by .NET, and possibly other language bindings.
| source | The source to populate with data. |
| srcData | The input context. |
| gbFunc | Pointer to the "get byte" callback. |
| ugbFunc | Pointer to the "unget" callback. |
| endFunc | Pointer to the "eof" callback. |
| Bool TIDY_CALL tidyIsEOF | ( | TidyInputSource * | source | ) |
Helper: check if input source at end.
| source | The input source. |
| void TIDY_CALL tidyPutByte | ( | TidyOutputSink * | sink, |
| uint | byteValue ) |
Helper: send a byte to output.
| sink | The output sink to send a byte. |
| byteValue | The byte to be sent. |
Set the file path to use for reports when TidyEmacs is being used.
This function provides a proper interface for using the hidden, internal-only TidyEmacsFile configuration option.
| tdoc | The tidy document for which you are setting the filePath. |
| filePath | The path of the document that should be reported. |
Set error sink to given buffer.
| tdoc | The document to set. |
| errbuf | The TidyBuffer to collect output. |
Set error sink to named file.
| tdoc | The document to set. |
| errfilnam | The file path to send output. |
| int TIDY_CALL tidySetErrorSink | ( | TidyDoc | tdoc, |
| TidyOutputSink * | sink ) |
Set error sink to given generic sink.
| tdoc | The document to set. |
| sink | The TidyOutputSink to collect output. |
| Bool TIDY_CALL tidySetMessageCallback | ( | TidyDoc | tdoc, |
| TidyMessageCallback | filtCallback ) |
This function informs Tidy to use the specified callback to send reports.
| tdoc | The tidy document for which the callback applies. |
| filtCallback | A pointer to your callback function of type TidyMessageCallback. |
| Bool TIDY_CALL tidySetPrettyPrinterCallback | ( | TidyDoc | tdoc, |
| TidyPPProgress | callback ) |
This function informs Tidy to use the specified callback for tracking the pretty-printing process progress.
| Bool TIDY_CALL tidySetReportCallback | ( | TidyDoc | tdoc, |
| TidyReportCallback | filtCallback ) |
This function informs Tidy to use the specified callback to send reports.
| tdoc | The tidy document for which the callback applies. |
| filtCallback | A pointer to your callback function of type TidyReportCallback. |
| Bool TIDY_CALL tidySetReportFilter | ( | TidyDoc | tdoc, |
| TidyReportFilter | filtCallback ) |
This function informs Tidy to use the specified callback to send reports.
| tdoc | The tidy document for which the callback applies. |
| filtCallback | A pointer to your callback function of type TidyReportFilter. |
| void TIDY_CALL tidyUngetByte | ( | TidyInputSource * | source, |
| uint | byteValue ) |
Helper: unget byte back to input source.
| source | The input source. |
| byteValue | The byte to push back. |