HTML Tidy 5.8.0
The HTACG Tidy HTML Project
 
Loading...
Searching...
No Matches
streamio.h
Go to the documentation of this file.
1#ifndef __STREAMIO_H__
2#define __STREAMIO_H__
3
4/* streamio.h -- handles character stream I/O
5
6 (c) 1998-2007 (W3C) MIT, ERCIM, Keio University
7 See tidy.h for the copyright notice.
8
9 Wrapper around Tidy input source and output sink
10 that calls appropriate interfaces, and applies
11 necessary char encoding transformations: to/from
12 ISO-10646 and/or UTF-8.
13
14*/
15
16#include "forward.h"
17#include "tidybuffio.h"
18#include "fileio.h"
19
20#ifdef __cplusplus
21extern "C"
22{
23#endif
24typedef enum
25{
28 UserIO
30
31/* states for ISO 2022
32
33 A document in ISO-2022 based encoding uses some ESC sequences called
34 "designator" to switch character sets. The designators defined and
35 used in ISO-2022-JP are:
36
37 "ESC" + "(" + ? for ISO646 variants
38
39 "ESC" + "$" + ? and
40 "ESC" + "$" + "(" + ? for multibyte character sets
41*/
51
52/************************
53** Source
54************************/
55
56enum
57{
60};
61
62/* non-raw input is cleaned up*/
64{
65 ISO2022State state; /* FSM for ISO2022 */
67 TidyAllocator *allocator;
71 int tabs;
73 unsigned short curlastpos; /* current last position in lastcols */
74 unsigned short firstlastpos; /* first valid last position in lastcols */
75 int curcol;
79
81
82 /* Pointer back to document for error reporting */
83 TidyDocImpl* doc;
84};
85
86TY_PRIVATE StreamIn* TY_(initStreamIn)( TidyDocImpl* doc, int encoding );
87TY_PRIVATE void TY_(freeStreamIn)(StreamIn* in);
88
89TY_PRIVATE StreamIn* TY_(FileInput)( TidyDocImpl* doc, FILE* fp, int encoding );
90TY_PRIVATE StreamIn* TY_(BufferInput)( TidyDocImpl* doc, TidyBuffer* content, int encoding );
91TY_PRIVATE StreamIn* TY_(UserInput)( TidyDocImpl* doc, TidyInputSource* source, int encoding );
92
93TY_PRIVATE int TY_(ReadBOMEncoding)(StreamIn *in);
94TY_PRIVATE uint TY_(ReadChar)( StreamIn* in );
95TY_PRIVATE void TY_(UngetChar)( uint c, StreamIn* in );
96TY_PRIVATE Bool TY_(IsEOF)( StreamIn* in );
97
98
99/************************
100** Sink
101************************/
102
111
112TY_PRIVATE StreamOut* TY_(FileOutput)( TidyDocImpl *doc, FILE* fp, int encoding, uint newln );
113TY_PRIVATE StreamOut* TY_(BufferOutput)( TidyDocImpl *doc, TidyBuffer* buf, int encoding, uint newln );
114TY_PRIVATE StreamOut* TY_(UserOutput)( TidyDocImpl *doc, TidyOutputSink* sink, int encoding, uint newln );
115
116TY_PRIVATE StreamOut* TY_(StdErrOutput)(void);
117/* StreamOut* StdOutOutput(void); */
118TY_PRIVATE void TY_(ReleaseStreamOut)( TidyDocImpl *doc, StreamOut* out );
119
120TY_PRIVATE void TY_(WriteChar)( uint c, StreamOut* out );
121TY_PRIVATE void TY_(outBOM)( StreamOut *out );
122
123TY_PRIVATE ctmbstr TY_(GetEncodingNameFromTidyId)(uint id);
124TY_PRIVATE ctmbstr TY_(GetEncodingOptNameFromTidyId)(uint id);
125TY_PRIVATE int TY_(GetCharEncodingFromOptName)(ctmbstr charenc);
126
127/************************
128** Misc
129************************/
130
131/* character encodings
132*/
133#define RAW 0
134#define ASCII 1
135#define LATIN0 2
136#define LATIN1 3
137#define UTF8 4
138#define ISO2022 5
139#define MACROMAN 6
140#define WIN1252 7
141#define IBM858 8
142#define UTF16LE 9
143#define UTF16BE 10
144#define UTF16 11
145#define BIG5 12
146#define SHIFTJIS 13
147
148/* Function for conversion from Windows-1252 to Unicode */
149TY_PRIVATE uint TY_(DecodeWin1252)(uint c);
150
151/* Function to convert from MacRoman to Unicode */
152TY_PRIVATE uint TY_(DecodeMacRoman)(uint c);
153
154#ifdef __cplusplus
155}
156#endif
157
158
159/* Use numeric constants as opposed to escape chars (\r, \n)
160** to avoid conflict Mac compilers that may re-define these.
161*/
162#define CR 0xD
163#define LF 0xA
164
165#if defined(MAC_OS_CLASSIC)
166# define DEFAULT_NL_CONFIG TidyCR
167#elif defined(_WIN32) || defined(OS2_OS)
168# define DEFAULT_NL_CONFIG TidyCRLF
169#else
170# define DEFAULT_NL_CONFIG TidyLF
171#endif
172
173
174#endif /* __STREAMIO_H__ */
does standard C I/O
#define TY_PRIVATE
Definition forward.h:29
#define TY_(str)
Definition forward.h:23
This type defines an input source capable of delivering raw bytes of input.
Definition tidy.h:1079
This type defines an output destination capable of accepting raw bytes of output.
Definition tidy.h:1129
IOType
Definition streamio.h:25
@ FileIO
Definition streamio.h:26
@ UserIO
Definition streamio.h:28
@ BufferIO
Definition streamio.h:27
int curline
Definition streamio.h:76
uint bufsize
Definition streamio.h:70
int curcol
Definition streamio.h:75
unsigned short firstlastpos
Definition streamio.h:74
uint bufpos
Definition streamio.h:69
uint nl
Definition streamio.h:107
int lastcols[LASTPOS_SIZE]
Definition streamio.h:72
Bool pushed
Definition streamio.h:66
tchar * charbuf
Definition streamio.h:68
IOType iotype
Definition streamio.h:78
TidyInputSource source
Definition streamio.h:80
unsigned short curlastpos
Definition streamio.h:73
TidyOutputSink sink
Definition streamio.h:109
TidyAllocator * allocator
Definition streamio.h:67
@ CHARBUF_SIZE
Definition streamio.h:58
@ LASTPOS_SIZE
Definition streamio.h:59
ISO2022State state
Definition streamio.h:65
int encoding
Definition streamio.h:77
int tabs
Definition streamio.h:71
TidyDocImpl * doc
Definition streamio.h:83
ISO2022State
Definition streamio.h:43
@ FSM_ESCD
Definition streamio.h:46
@ FSM_ESC
Definition streamio.h:45
@ FSM_ESCP
Definition streamio.h:48
@ FSM_NONASCII
Definition streamio.h:49
@ FSM_ESCDP
Definition streamio.h:47
@ FSM_ASCII
Definition streamio.h:44
Definition streamio.h:64
Definition streamio.h:104
Treat buffer as a stream that Tidy can use for I/O operations.
Bool
Definition tidyplatform.h:647
uint tchar
Definition tidyplatform.h:605
unsigned int uint
Definition tidyplatform.h:569
const tmbchar * ctmbstr
Definition tidyplatform.h:609