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
16 #include "general.h" /* must always come first */
28 #define getInputLineNumber() File.lineNumber
29 #define getInputFileName() vStringValue (File.source.name)
30 #define getInputFilePosition() File.filePosition
31 #define getSourceFileName() vStringValue (File.source.name)
32 #define getSourceFileTagPath() File.source.tagPath
33 #define getSourceLanguage() File.source.language
34 #define getSourceLanguageName() getLanguageName (File.source.language)
35 #define getSourceLineNumber() File.source.lineNumber
36 #define isLanguage(lang) (boolean)((lang) == File.source.language)
37 #define isHeaderFile() File.source.isHeader
44 /* White space characters.
53 /* Some hard to read characters.
59 STRING_SYMBOL
= ('S' + 0x80),
60 CHAR_SYMBOL
= ('C' + 0x80)
63 /* Maintains the state of the current source file.
65 typedef struct sInputFile
{
66 vString
*name
; /* name of input file */
67 vString
*path
; /* path of input file (if any) */
68 vString
*line
; /* last line read from file */
69 const unsigned char* currentLine
; /* current line being worked on */
70 MIO
*mio
; /* stream used for reading the file */
71 unsigned long lineNumber
; /* line number in the input file */
72 MIOPos filePosition
; /* file position of current line */
73 int ungetch
; /* a single character that was ungotten */
74 boolean eof
; /* have we reached the end of file? */
75 boolean newLine
; /* will the next character begin a new line? */
77 /* Contains data pertaining to the original source file in which the tag
78 * was defined. This may be different from the input file when #line
79 * directives are processed (i.e. the input file is preprocessor output).
82 vString
*name
; /* name to report for source file */
83 char *tagPath
; /* path of source file relative to tag file */
84 unsigned long lineNumber
;/* line number in the source file */
85 boolean isHeader
; /* is source file a header file? */
86 langType language
; /* language of source file */
93 /* should not be modified externally */
94 extern inputFile File
;
99 extern void freeSourceFileResources (void);
100 extern boolean
fileOpen (const char *const fileName
, const langType language
);
101 extern boolean
fileEOF (void);
102 extern void fileClose (void);
103 extern int fileGetc (void);
104 extern void fileUngetc (int c
);
105 extern const unsigned char *fileReadLine (void);
106 extern char *readLine (vString
*const vLine
, MIO
*const mio
);
107 extern char *readSourceLine (vString
*const vLine
, MIOPos location
, long *const pSeekValue
);
108 extern boolean
bufferOpen (unsigned char *buffer
, int buffer_size
,
109 const char *const fileName
, const langType language
);
110 #define bufferClose fileClose
114 /* vi:set tabstop=8 shiftwidth=4: */