Update NEWS with the latest changes
[geany-mirror.git] / ctags / main / read.h
blob72823c11a3a979741bb474d76d5c7ebcd390b0cb
1 /*
2 * Copyright (c) 1998-2002, Darren Hiebert
4 * This source code is released for free distribution under the terms of the
5 * GNU General Public License version 2 or (at your option) any later version.
7 * External interface to read.c
8 */
9 #ifndef CTAGS_MAIN_READ_H
10 #define CTAGS_MAIN_READ_H
13 * INCLUDE FILES
15 #include "general.h" /* must always come first */
17 #include <stdio.h>
18 #include <ctype.h>
20 #include "mio.h"
21 #include "parse.h"
22 #include "vstring.h"
25 * MACROS
27 #define getInputLineNumber() File.input.lineNumber
28 #define getInputFileName() vStringValue (File.input.name)
29 #define getInputFilePosition() File.filePosition
30 #define getSourceFileTagPath() vStringValue (File.source.tagPath)
31 #define getSourceLanguage() File.source.language
32 #define getSourceLanguageName() getLanguageName (File.source.language)
33 #define getSourceLineNumber() File.source.lineNumber
34 #define isInputLanguage(lang) (bool)((lang) == File.input.language)
35 #define isInputHeaderFile() File.input.isHeader
38 * DATA DECLARATIONS
41 enum eCharacters {
42 /* white space characters */
43 SPACE = ' ',
44 NEWLINE = '\n',
45 CRETURN = '\r',
46 FORMFEED = '\f',
47 TAB = '\t',
48 VTAB = '\v',
50 /* some hard to read characters */
51 DOUBLE_QUOTE = '"',
52 SINGLE_QUOTE = '\'',
53 BACKSLASH = '\\',
55 STRING_SYMBOL = ('S' + 0x80),
56 CHAR_SYMBOL = ('C' + 0x80)
59 /* Maintains the state of the current input file.
61 typedef struct sInputFileInfo {
62 vString *name; /* name to report for input file */
63 vString *tagPath; /* path of input file relative to tag file */
64 unsigned long lineNumber;/* line number in the input file */
65 unsigned long lineNumberOrigin; /* The value set to `lineNumber'
66 when `resetInputFile' is called
67 on the input stream.
68 This is needed for nested stream. */
69 bool isHeader; /* is input file a header file? */
70 langType language; /* language of input file */
71 } inputFileInfo;
73 typedef struct sInputFile {
74 vString *path; /* path of input file (if any) */
75 vString *line; /* last line read from file */
76 const unsigned char* currentLine; /* current line being worked on */
77 MIO *mio; /* MIO stream used for reading the file */
78 MIOPos filePosition; /* file position of current line */
79 unsigned int ungetchIdx;
80 int ungetchBuf[3]; /* characters that were ungotten */
81 bool eof; /* have we reached the end of file? */
82 bool newLine; /* will the next character begin a new line? */
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).
88 inputFileInfo input; /* name, lineNumber */
89 inputFileInfo source;
90 } inputFile;
93 * GLOBAL VARIABLES
95 /* should not be modified externally */
96 extern inputFile File;
99 * FUNCTION PROTOTYPES
102 /* InputFile: reading from fp in inputFile with updating fields in input fields */
103 extern kindOption *getInputLanguageFileKind (void);
105 extern void freeSourceFileResources (void);
106 extern bool fileOpen (const char *const fileName, const langType language);
107 extern bool fileEOF (void);
108 extern void fileClose (void);
109 extern int getcFromInputFile (void);
110 extern int getNthPrevCFromInputFile (unsigned int nth, int def);
111 extern int skipToCharacterInInputFile (int c);
112 extern void ungetcToInputFile (int c);
113 extern const unsigned char *readLineFromInputFile (void);
114 extern char *readLineRaw (vString *const vLine, MIO *const mio);
115 extern char *readSourceLine (vString *const vLine, MIOPos location, long *const pSeekValue);
116 extern bool bufferOpen (unsigned char *buffer, size_t buffer_size,
117 const char *const fileName, const langType language );
118 #define bufferClose fileClose
120 /* Bypass: reading from fp in inputFile WITHOUT updating fields in input fields */
121 extern char *readLineFromBypass (vString *const vLine, MIOPos location, long *const pSeekValue);
123 #endif /* CTAGS_MAIN_READ_H */