Debian Codegraph @

read.h

raw
1 /*
2 * $Id: read.h 769 2010-09-11 21:00:16Z dhiebert $
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 */
23 #include "general.h" /* must always come first */
24
25 #include <stdio.h>
26 #include <ctype.h>
27
28 #include "parse.h"
29 #include "vstring.h"
30
31 /*
32 * MACROS
33 */
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
44
45 /*
46 * DATA DECLARATIONS
47 */
48
49 enum eCharacters {
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)
65 };
66
67 /* Maintains the state of the current source file.
68 */
69 typedef struct sInputFile {
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
81 /* Contains data pertaining to the original source file in which the tag
82 * was defined. This may be different from the input file when #line
83 * directives are processed (i.e. the input file is preprocessor output).
84 */
85 struct sSource {
86 vString *name; /* name to report for source file */
87 char *tagPath; /* path of source file relative to tag file */
88 unsigned long lineNumber;/* line number in the source file */
89 boolean isHeader; /* is source file a header file? */
90 langType language; /* language of source file */
91 } source;
92 } inputFile;
93
94 /*
95 * GLOBAL VARIABLES
96 */
97 extern CONST_FILE inputFile File;
98
99 /*
100 * FUNCTION PROTOTYPES
101 */
102 extern void freeSourceFileResources (void);
103 extern boolean fileOpen (const char *const fileName, const langType language);
104 extern boolean fileEOF (void);
105 extern void fileClose (void);
106 extern int fileGetc (void);
107 extern int fileSkipToCharacter (int c);
108 extern void fileUngetc (int c);
109 extern const unsigned char *fileReadLine (void);
110 extern char *readLine (vString *const vLine, FILE *const fp);
111 extern char *readSourceLine (vString *const vLine, fpos_t location, long *const pSeekValue);
112
113 #endif /* _READ_H */
114
115 /* vi:set tabstop=4 shiftwidth=4: */