Integrate adding files with the file manager
[anjuta-git-plugin.git] / tagmanager / read.h
blobb23763eb10719f8e7c05ef72e079f10983ae37d3
1 /*
2 * $Id$
4 * Copyright (c) 1998-2002, Darren Hiebert
6 * This source code is released for free distribution under the terms of the
7 * GNU General Public License.
9 * External interface to read.c
11 #ifndef _READ_H
12 #define _READ_H
14 #if defined(FILE_WRITE) || defined(VAXC)
15 # define CONST_FILE
16 #else
17 # define CONST_FILE const
18 #endif
21 * INCLUDE FILES
23 #include "general.h" /* must always come first */
25 #include <stdio.h>
26 #include <ctype.h>
28 #include "parse.h"
29 #include "vstring.h"
32 * MACROS
34 #define getInputLineNumber() File.lineNumber
35 #define getInputFileName() vStringValue (File.source.name)
36 #define getInputFilePosition() File.filePosition
37 #define getInputBufferPosition() File.fpBufferPosition
38 #define getSourceFileName() vStringValue (File.source.name)
39 #define getSourceFileTagPath() File.source.tagPath
40 #define getSourceLanguage() File.source.language
41 #define getSourceLanguageName() getLanguageName (File.source.language)
42 #define getSourceLineNumber() File.source.lineNumber
43 #define isLanguage(lang) (boolean)((lang) == File.source.language)
44 #define isHeaderFile() File.source.isHeader
47 * DATA DECLARATIONS
50 enum eCharacters {
51 /* white space characters */
52 SPACE = ' ',
53 NEWLINE = '\n',
54 CRETURN = '\r',
55 FORMFEED = '\f',
56 TAB = '\t',
57 VTAB = '\v',
59 /* some hard to read characters */
60 DOUBLE_QUOTE = '"',
61 SINGLE_QUOTE = '\'',
62 BACKSLASH = '\\',
64 STRING_SYMBOL = ('S' + 0x80),
65 CHAR_SYMBOL = ('C' + 0x80)
68 /* Maintains the state of the current source file.
70 typedef struct sInputFile {
71 vString *name; /* name of input file */
72 vString *path; /* path of input file (if any) */
73 vString *line; /* last line read from file */
74 const unsigned char* currentLine; /* current line being worked on */
75 FILE *fp; /* stream used for reading the file */
76 unsigned long lineNumber; /* line number in the input file */
77 fpos_t filePosition; /* file position of current line */
78 unsigned char* fpBuffer; /* buffer which contains the text to be parsed.
79 This is optional to the use of a file-descriptor */
80 int fpBufferSize; /* size of the fpBuffer */
81 int fpBufferPosition; /* pointer to the current position in buffer */
83 int ungetch; /* a single character that was ungotten */
84 boolean eof; /* have we reached the end of file? */
85 boolean newLine; /* will the next character begin a new line? */
86 langType language; /* language of input file */
88 /* Contains data pertaining to the original source file in which the tag
89 * was defined. This may be different from the input file when #line
90 * directives are processed (i.e. the input file is preprocessor output).
92 struct sSource {
93 vString *name; /* name to report for source file */
94 char *tagPath; /* path of source file relative to tag file */
95 unsigned long lineNumber;/* line number in the source file */
96 boolean isHeader; /* is source file a header file? */
97 langType language; /* language of source file */
98 } source;
99 } inputFile;
102 * GLOBAL VARIABLES
104 extern CONST_FILE inputFile File;
107 * FUNCTION PROTOTYPES
109 extern void freeSourceFileResources (void);
110 extern boolean fileOpen (const char *const fileName, const langType language);
111 extern boolean fileEOF (void);
112 extern void fileClose (void);
113 extern int fileGetc (void);
114 extern void fileUngetc (int c);
115 extern const unsigned char *fileReadLine (void);
116 extern char *readLine (vString *const vLine, FILE *const fp);
117 extern char *readSourceLine (vString *const vLine, fpos_t location, long *const pSeekValue);
119 extern boolean bufferOpen (unsigned char *buffer, int buffer_size,
120 const char *const fileName, const langType language );
121 extern void bufferClose (void);
122 extern void setBufPos (int new_position);
123 extern int getBufPos (void);
124 extern boolean useFile (void);
127 #endif /* _READ_H */
129 /* vi:set tabstop=4 shiftwidth=4: */