Edinburgh Speech Tools  2.1-release
input.h
Go to the documentation of this file.
1 /*************************************************************************/
2 /* */
3 /* Copyright (c) 1997-98 Richard Tobin, Language Technology Group, HCRC, */
4 /* University of Edinburgh. */
5 /* */
6 /* THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, */
7 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
8 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
9 /* IN NO EVENT SHALL THE AUTHOR OR THE UNIVERSITY OF EDINBURGH BE LIABLE */
10 /* FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF */
11 /* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION */
12 /* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
13 /* */
14 /*************************************************************************/
15 #ifndef INPUT_H
16 #define INPUT_H
17 
18 #ifndef FOR_LT
19 #define XML_API
20 #endif
21 
22 #include <stdio.h>
23 #include "charset.h"
24 #include "stdio16.h"
25 #include "dtd.h"
26 
27 /* Typedefs */
28 
29 typedef struct input_source *InputSource;
30 typedef struct stream_ops *StreamOps;
31 typedef int ReadProc(StreamOps ops, unsigned char *buf, int max_count);
32 typedef int WriteProc(StreamOps ops, unsigned char *buf, int count);
33 typedef void CloseProc(StreamOps ops);
34 typedef int SeekProc(StreamOps ops, int offset);
35 
36 /* Input sources */
37 
38 XML_API InputSource SourceFromStream(const char8 *description, FILE *file);
39 XML_API InputSource EntityOpen(Entity e);
40 XML_API InputSource NewInputSource(Entity e, FILE16 *f16);
41 XML_API int SourceTell(InputSource s);
42 XML_API int SourceSeek(InputSource s, int offset);
43 XML_API int SourceLineAndChar(InputSource s, int *linenum, int *charnum);
44 XML_API void SourcePosition(InputSource s, Entity *entity, int *char_number);
45 XML_API int get_with_fill(InputSource s);
46 XML_API void determine_character_encoding(InputSource s);
47 
48 struct input_source {
49  Entity entity; /* The entity from which the source reads */
50 
51  FILE16 *file16;
52 
53  Char *line;
55  int next;
56 
57  int seen_eoe;
62 
65 
67 
68  int nextin;
69  int insize;
70  unsigned char inbuf[4096];
71 };
72 
73 /* EOE used to be -2, but that doesn't work if Char is signed char */
74 #define XEOE (-999)
75 
76 #define at_eol(s) ((s)->next == (s)->line_length)
77 #define get(s) (at_eol(s) ? get_with_fill(s) : (s)->line[(s)->next++])
78 #define unget(s) ((s)->seen_eoe ? (s)->seen_eoe= 0 : (s)->next--)
79 
80 #endif /* INPUT_H */
int ReadProc(StreamOps ops, unsigned char *buf, int max_count)
Definition: input.h:31
XML_API int SourceLineAndChar(InputSource s, int *linenum, int *charnum)
Definition: input.c:118
int nextin
Definition: input.h:68
int line_length
Definition: input.h:54
int complicated_utf8_line
Definition: input.h:58
XML_API int get_with_fill(InputSource s)
Definition: input.c:529
int SeekProc(StreamOps ops, int offset)
Definition: input.h:34
int line_end_was_cr
Definition: input.h:61
XML_API InputSource NewInputSource(Entity e, FILE16 *f16)
Definition: input.c:88
Char * line
Definition: input.h:53
XML_API void determine_character_encoding(InputSource s)
Definition: input.c:480
Definition: dtd.h:71
XML_API InputSource EntityOpen(Entity e)
Definition: input.c:68
int seen_eoe
Definition: input.h:57
XML_API int SourceTell(InputSource s)
Definition: input.c:163
void CloseProc(StreamOps ops)
Definition: input.h:33
FILE16 * file16
Definition: input.h:51
int bytes_before_current_line
Definition: input.h:60
int line_number
Definition: input.h:63
int insize
Definition: input.h:69
Entity entity
Definition: input.h:49
int not_read_yet
Definition: input.h:64
#define XML_API
Definition: input.h:19
struct input_source * parent
Definition: input.h:66
unsigned char inbuf[4096]
Definition: input.h:70
int next
Definition: input.h:55
int bytes_consumed
Definition: input.h:59
struct stream_ops * StreamOps
Definition: input.h:30
int WriteProc(StreamOps ops, unsigned char *buf, int count)
Definition: input.h:32
char char8
Definition: charset.h:31
int line_alloc
Definition: input.h:54
XML_API int SourceSeek(InputSource s, int offset)
Definition: input.c:221
XML_API InputSource SourceFromStream(const char8 *description, FILE *file)
Definition: input.c:57
XML_API void SourcePosition(InputSource s, Entity *entity, int *char_number)
Definition: input.c:157