3 * Copyright (c) 1998-2001, Darren Hiebert
5 * This source code is released for free distribution under the terms of the
6 * GNU General Public License.
8 * External interface to read.c
13 #if defined(FILE_WRITE) || defined(VAXC)
16 # define CONST_FILE const
22 #include "general.h" /* must always come first */
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
50 /* White space characters.
59 /* Some hard to read characters.
65 STRING_SYMBOL
= ('S' + 0x80),
66 CHAR_SYMBOL
= ('C' + 0x80)
69 /* Maintains the state of the current source file.
71 typedef struct sInputFile
{
72 vString
*name
; /* name of input file */
73 vString
*path
; /* path of input file (if any) */
74 vString
*line
; /* last line read from file */
75 const unsigned char* currentLine
; /* current line being worked on */
76 MIO
*mio
; /* stream used for reading the file */
77 unsigned long lineNumber
; /* line number in the input file */
78 MIOPos filePosition
; /* file position of current line */
79 int ungetch
; /* a single character that was ungotten */
80 boolean eof
; /* have we reached the end of file? */
81 boolean newLine
; /* will the next character begin a new line? */
82 langType language
; /* language of input file */
84 /* Contains data pertaining to the original source file in which the tag
85 * was defined. This may be different from the input file when #line
86 * directives are processed (i.e. the input file is preprocessor output).
89 vString
*name
; /* name to report for source file */
90 char *tagPath
; /* path of source file relative to tag file */
91 unsigned long lineNumber
;/* line number in the source file */
92 boolean isHeader
; /* is source file a header file? */
93 langType language
; /* language of source file */
100 extern CONST_FILE inputFile File
;
103 * FUNCTION PROTOTYPES
105 extern void freeSourceFileResources (void);
106 extern boolean
fileOpen (const char *const fileName
, const langType language
);
107 extern boolean
fileEOF (void);
108 extern void fileClose (void);
109 extern int fileGetc (void);
110 extern void fileUngetc (int c
);
111 extern const unsigned char *fileReadLine (void);
112 extern char *readLine (vString
*const vLine
, MIO
*const mio
);
113 extern char *readSourceLine (vString
*const vLine
, MIOPos location
, long *const pSeekValue
);
114 extern boolean
bufferOpen (unsigned char *buffer
, int buffer_size
,
115 const char *const fileName
, const langType language
);
116 #define bufferClose fileClose
120 /* vi:set tabstop=8 shiftwidth=4: */