Refactor snippets_complete_constructs().
[geany-mirror.git] / tagmanager / read.h
blob30fd424d8239522460c1b3544e5460dac24987b3
1 /*
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
9 */
10 #ifndef _READ_H
11 #define _READ_H
13 #if defined(FILE_WRITE) || defined(VAXC)
14 # define CONST_FILE
15 #else
16 # define CONST_FILE const
17 #endif
20 * INCLUDE FILES
22 #include "general.h" /* must always come first */
24 #include <stdio.h>
25 #include <ctype.h>
27 #include "parse.h"
28 #include "vstring.h"
31 * MACROS
33 #define getInputLineNumber() File.lineNumber
34 #define getInputFileName() vStringValue (File.source.name)
35 #define getInputFilePosition() File.filePosition
36 #define getInputBufferPosition() File.fpBufferPosition
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
46 * DATA DECLARATIONS
49 enum eCharacters {
50 /* 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.
61 DOUBLE_QUOTE = '"',
62 SINGLE_QUOTE = '\'',
63 BACKSLASH = '\\',
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 FILE *fp; /* stream used for reading the file */
77 unsigned char* fpBuffer; /* buffer which contains the text to be parsed.
78 This is optional to the use of a file-descriptor */
79 int fpBufferSize; /* size of the fpBuffer */
80 int fpBufferPosition; /* pointer to the current position in buffer */
81 unsigned long lineNumber; /* line number in the input file */
82 fpos_t filePosition; /* file position of current line */
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 #ifdef NEED_PROTO_FGETPOS
110 extern int fgetpos (FILE *stream, fpos_t *pos);
111 extern int fsetpos (FILE *stream, const fpos_t *pos);
112 #endif
114 extern void freeSourceFileResources (void);
115 extern boolean fileOpen (const char *const fileName, const langType language);
116 extern boolean fileEOF (void);
117 extern void fileClose (void);
118 extern int fileGetc (void);
119 extern void fileUngetc (int c);
120 extern const unsigned char *fileReadLine (void);
121 extern char *readLine (vString *const vLine, FILE *const fp);
122 extern char *readSourceLine (vString *const vLine, fpos_t location, long *const pSeekValue);
124 extern boolean bufferOpen (unsigned char *buffer, int buffer_size,
125 const char *const fileName, const langType language );
126 extern void bufferClose (void);
127 extern void setBufPos (int new_position);
128 extern int getBufPos (void);
129 extern boolean useFile (void);
131 #endif /* _READ_H */
133 /* vi:set tabstop=8 shiftwidth=4: */