#ifndef __STREAMIO_H__
#define __STREAMIO_H__
#include "forward.h"
#include "buffio.h"
#include "fileio.h"
#ifdef __cplusplus
extern "C"
{
#endif
typedef enum
{
FileIO,
BufferIO,
UserIO
} IOType;
typedef enum
{
FSM_ASCII,
FSM_ESC,
FSM_ESCD,
FSM_ESCDP,
FSM_ESCP,
FSM_NONASCII
} ISO2022State;
#define CHARBUF_SIZE 5
struct _StreamIn
{
ISO2022State state;
Bool pushed;
tchar* charbuf;
uint bufpos;
uint bufsize;
int tabs;
int lastcol;
int curcol;
int curline;
int encoding;
IOType iotype;
TidyInputSource source;
#ifdef TIDY_WIN32_MLANG_SUPPORT
ulong mlang;
#endif
#ifdef TIDY_STORE_ORIGINAL_TEXT
tmbstr otextbuf;
size_t otextsize;
uint otextlen;
#endif
TidyDocImpl* doc;
};
StreamIn* TY_(initStreamIn)( TidyDocImpl* doc, int encoding );
void TY_(freeStreamIn)(StreamIn* in);
StreamIn* TY_(FileInput)( TidyDocImpl* doc, FILE* fp, int encoding );
StreamIn* TY_(BufferInput)( TidyDocImpl* doc, TidyBuffer* content, int encoding );
StreamIn* TY_(UserInput)( TidyDocImpl* doc, TidyInputSource* source, int encoding );
int TY_(ReadBOMEncoding)(StreamIn *in);
uint TY_(ReadChar)( StreamIn* in );
void TY_(UngetChar)( uint c, StreamIn* in );
Bool TY_(IsEOF)( StreamIn* in );
struct _StreamOut
{
int encoding;
ISO2022State state;
uint nl;
#ifdef TIDY_WIN32_MLANG_SUPPORT
ulong mlang;
#endif
IOType iotype;
TidyOutputSink sink;
};
StreamOut* TY_(FileOutput)( FILE* fp, int encoding, uint newln );
StreamOut* TY_(BufferOutput)( TidyBuffer* buf, int encoding, uint newln );
StreamOut* TY_(UserOutput)( TidyOutputSink* sink, int encoding, uint newln );
StreamOut* TY_(StdErrOutput)(void);
void TY_(ReleaseStreamOut)( StreamOut* out );
void TY_(WriteChar)( uint c, StreamOut* out );
void TY_(outBOM)( StreamOut *out );
ctmbstr TY_(GetEncodingNameFromTidyId)(uint id);
ctmbstr TY_(GetEncodingOptNameFromTidyId)(uint id);
int TY_(GetCharEncodingFromOptName)(ctmbstr charenc);
#define RAW 0
#define ASCII 1
#define LATIN0 2
#define LATIN1 3
#define UTF8 4
#define ISO2022 5
#define MACROMAN 6
#define WIN1252 7
#define IBM858 8
#if SUPPORT_UTF16_ENCODINGS
#define UTF16LE 9
#define UTF16BE 10
#define UTF16 11
#endif
#if SUPPORT_ASIAN_ENCODINGS
#if SUPPORT_UTF16_ENCODINGS
#define BIG5 12
#define SHIFTJIS 13
#else
#define BIG5 9
#define SHIFTJIS 10
#endif
#endif
#ifdef TIDY_WIN32_MLANG_SUPPORT
#define WIN32MLANG 36
#endif
extern const int TY_(ReplacementCharEncoding);
uint TY_(DecodeWin1252)(uint c);
uint TY_(DecodeMacRoman)(uint c);
#ifdef __cplusplus
}
#endif
#define CR 0xD
#define LF 0xA
#if defined(MAC_OS_CLASSIC)
#define DEFAULT_NL_CONFIG TidyCR
#elif defined(_WIN32) || defined(OS2_OS)
#define DEFAULT_NL_CONFIG TidyCRLF
#else
#define DEFAULT_NL_CONFIG TidyLF
#endif
#endif