1
by Colin Watson
Import upstream version 5.5.4 |
1 |
/*
|
1.1.3
by Colin Watson
Import upstream version 5.8 |
2 |
* $Id: read.h 659 2008-04-20 23:27:48Z elliotth $
|
1
by Colin Watson
Import upstream version 5.5.4 |
3 |
*
|
4 |
* Copyright (c) 1998-2002, Darren Hiebert
|
|
5 |
*
|
|
6 |
* This source code is released for free distribution under the terms of the
|
|
7 |
* GNU General Public License.
|
|
8 |
*
|
|
9 |
* External interface to read.c
|
|
10 |
*/
|
|
11 |
#ifndef _READ_H
|
|
12 |
#define _READ_H
|
|
13 |
||
14 |
#if defined(FILE_WRITE) || defined(VAXC)
|
|
15 |
# define CONST_FILE
|
|
16 |
#else
|
|
17 |
# define CONST_FILE const
|
|
18 |
#endif
|
|
19 |
||
20 |
/*
|
|
21 |
* INCLUDE FILES
|
|
22 |
*/
|
|
1.1.1
by Colin Watson
Import upstream version 5.6 |
23 |
#include "general.h" /* must always come first */ |
1
by Colin Watson
Import upstream version 5.5.4 |
24 |
|
25 |
#include <stdio.h> |
|
26 |
#include <ctype.h> |
|
27 |
||
28 |
#include "parse.h" |
|
29 |
#include "vstring.h" |
|
30 |
||
31 |
/*
|
|
32 |
* MACROS
|
|
33 |
*/
|
|
1.1.1
by Colin Watson
Import upstream version 5.6 |
34 |
#define getInputLineNumber() File.lineNumber
|
35 |
#define getInputFileName() vStringValue (File.source.name)
|
|
36 |
#define getInputFilePosition() File.filePosition
|
|
37 |
#define getSourceFileName() vStringValue (File.source.name)
|
|
38 |
#define getSourceFileTagPath() File.source.tagPath
|
|
39 |
#define getSourceLanguage() File.source.language
|
|
40 |
#define getSourceLanguageName() getLanguageName (File.source.language)
|
|
41 |
#define getSourceLineNumber() File.source.lineNumber
|
|
42 |
#define isLanguage(lang) (boolean)((lang) == File.source.language)
|
|
43 |
#define isHeaderFile() File.source.isHeader
|
|
1
by Colin Watson
Import upstream version 5.5.4 |
44 |
|
45 |
/*
|
|
46 |
* DATA DECLARATIONS
|
|
47 |
*/
|
|
48 |
||
49 |
enum eCharacters { |
|
1.1.1
by Colin Watson
Import upstream version 5.6 |
50 |
/* white space characters */
|
51 |
SPACE = ' ', |
|
52 |
NEWLINE = '\n', |
|
53 |
CRETURN = '\r', |
|
54 |
FORMFEED = '\f', |
|
55 |
TAB = '\t', |
|
56 |
VTAB = '\v', |
|
57 |
||
58 |
/* some hard to read characters */
|
|
59 |
DOUBLE_QUOTE = '"', |
|
60 |
SINGLE_QUOTE = '\'', |
|
61 |
BACKSLASH = '\\', |
|
62 |
||
63 |
STRING_SYMBOL = ('S' + 0x80), |
|
64 |
CHAR_SYMBOL = ('C' + 0x80) |
|
1
by Colin Watson
Import upstream version 5.5.4 |
65 |
};
|
66 |
||
67 |
/* Maintains the state of the current source file.
|
|
68 |
*/
|
|
69 |
typedef struct sInputFile { |
|
1.1.1
by Colin Watson
Import upstream version 5.6 |
70 |
vString *name; /* name of input file */ |
71 |
vString *path; /* path of input file (if any) */ |
|
72 |
vString *line; /* last line read from file */ |
|
73 |
const unsigned char* currentLine; /* current line being worked on */ |
|
74 |
FILE *fp; /* stream used for reading the file */ |
|
75 |
unsigned long lineNumber; /* line number in the input file */ |
|
76 |
fpos_t filePosition; /* file position of current line */ |
|
77 |
int ungetch; /* a single character that was ungotten */ |
|
78 |
boolean eof; /* have we reached the end of file? */ |
|
79 |
boolean newLine; /* will the next character begin a new line? */ |
|
80 |
langType language; /* language of input file */ |
|
1
by Colin Watson
Import upstream version 5.5.4 |
81 |
|
1.1.1
by Colin Watson
Import upstream version 5.6 |
82 |
/* Contains data pertaining to the original source file in which the tag
|
83 |
* was defined. This may be different from the input file when #line
|
|
84 |
* directives are processed (i.e. the input file is preprocessor output).
|
|
85 |
*/
|
|
86 |
struct sSource { |
|
87 |
vString *name; /* name to report for source file */ |
|
88 |
char *tagPath; /* path of source file relative to tag file */ |
|
89 |
unsigned long lineNumber;/* line number in the source file */ |
|
90 |
boolean isHeader; /* is source file a header file? */ |
|
91 |
langType language; /* language of source file */ |
|
92 |
} source; |
|
1
by Colin Watson
Import upstream version 5.5.4 |
93 |
} inputFile; |
94 |
||
95 |
/*
|
|
96 |
* GLOBAL VARIABLES
|
|
97 |
*/
|
|
98 |
extern CONST_FILE inputFile File; |
|
99 |
||
100 |
/*
|
|
101 |
* FUNCTION PROTOTYPES
|
|
102 |
*/
|
|
103 |
extern void freeSourceFileResources (void); |
|
104 |
extern boolean fileOpen (const char *const fileName, const langType language); |
|
105 |
extern boolean fileEOF (void); |
|
106 |
extern void fileClose (void); |
|
107 |
extern int fileGetc (void); |
|
1.1.3
by Colin Watson
Import upstream version 5.8 |
108 |
extern int fileSkipToCharacter (int c); |
1
by Colin Watson
Import upstream version 5.5.4 |
109 |
extern void fileUngetc (int c); |
110 |
extern const unsigned char *fileReadLine (void); |
|
111 |
extern char *readLine (vString *const vLine, FILE *const fp); |
|
112 |
extern char *readSourceLine (vString *const vLine, fpos_t location, long *const pSeekValue); |
|
113 |
||
1.1.1
by Colin Watson
Import upstream version 5.6 |
114 |
#endif /* _READ_H */ |
1
by Colin Watson
Import upstream version 5.5.4 |
115 |
|
1.1.1
by Colin Watson
Import upstream version 5.6 |
116 |
/* vi:set tabstop=4 shiftwidth=4: */
|