2 |
7u83 |
1 |
/*
|
6 |
7u83 |
2 |
* Copyright (c) 2002-2005 The TenDRA Project <http://www.tendra.org/>.
|
|
|
3 |
* All rights reserved.
|
|
|
4 |
*
|
|
|
5 |
* Redistribution and use in source and binary forms, with or without
|
|
|
6 |
* modification, are permitted provided that the following conditions are met:
|
|
|
7 |
*
|
|
|
8 |
* 1. Redistributions of source code must retain the above copyright notice,
|
|
|
9 |
* this list of conditions and the following disclaimer.
|
|
|
10 |
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
11 |
* this list of conditions and the following disclaimer in the documentation
|
|
|
12 |
* and/or other materials provided with the distribution.
|
|
|
13 |
* 3. Neither the name of The TenDRA Project nor the names of its contributors
|
|
|
14 |
* may be used to endorse or promote products derived from this software
|
|
|
15 |
* without specific, prior written permission.
|
|
|
16 |
*
|
|
|
17 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
|
|
|
18 |
* IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
|
19 |
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
20 |
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
|
|
|
21 |
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
|
22 |
* EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
23 |
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
|
24 |
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
25 |
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
|
26 |
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
|
27 |
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
28 |
*
|
|
|
29 |
* $Id$
|
|
|
30 |
*/
|
|
|
31 |
/*
|
2 |
7u83 |
32 |
Crown Copyright (c) 1997
|
6 |
7u83 |
33 |
|
2 |
7u83 |
34 |
This TenDRA(r) Computer Program is subject to Copyright
|
|
|
35 |
owned by the United Kingdom Secretary of State for Defence
|
|
|
36 |
acting through the Defence Evaluation and Research Agency
|
|
|
37 |
(DERA). It is made available to Recipients with a
|
|
|
38 |
royalty-free licence for its use, reproduction, transfer
|
|
|
39 |
to other parties and amendment for any purpose not excluding
|
|
|
40 |
product development provided that any such use et cetera
|
|
|
41 |
shall be deemed to be acceptance of the following conditions:-
|
6 |
7u83 |
42 |
|
2 |
7u83 |
43 |
(1) Its Recipients shall ensure that this Notice is
|
|
|
44 |
reproduced upon any copies or amended versions of it;
|
6 |
7u83 |
45 |
|
2 |
7u83 |
46 |
(2) Any amended version of it shall be clearly marked to
|
|
|
47 |
show both the nature of and the organisation responsible
|
|
|
48 |
for the relevant amendment or amendments;
|
6 |
7u83 |
49 |
|
2 |
7u83 |
50 |
(3) Its onward transfer from a recipient to another
|
|
|
51 |
party shall be deemed to be that party's acceptance of
|
|
|
52 |
these conditions;
|
6 |
7u83 |
53 |
|
2 |
7u83 |
54 |
(4) DERA gives no warranty or assurance as to its
|
|
|
55 |
quality or suitability for any purpose and DERA accepts
|
|
|
56 |
no liability whatsoever in relation to any use to which
|
|
|
57 |
it may be put.
|
|
|
58 |
*/
|
|
|
59 |
|
|
|
60 |
|
|
|
61 |
#ifndef FILE_INCLUDED
|
|
|
62 |
#define FILE_INCLUDED
|
|
|
63 |
|
|
|
64 |
|
|
|
65 |
/*
|
|
|
66 |
FILE MANIPULATION DECLARATIONS
|
|
|
67 |
|
|
|
68 |
The routines in this module are concerned with the low level file
|
|
|
69 |
reading and manipulation, including the processing of #include
|
|
|
70 |
directives, start-up and end-up files. The routine next_char is the
|
|
|
71 |
lowest level file reading routine, which returns the next character
|
|
|
72 |
in the input file.
|
|
|
73 |
*/
|
|
|
74 |
|
6 |
7u83 |
75 |
extern int refill_char(void);
|
|
|
76 |
extern string init_buffer(unsigned long);
|
|
|
77 |
extern string make_pathname(string);
|
|
|
78 |
extern int is_full_pathname(string);
|
|
|
79 |
extern string set_crt_loc(string, int);
|
|
|
80 |
extern int start_include(string, int, int, int);
|
|
|
81 |
extern int end_include(int);
|
|
|
82 |
extern void open_startup(void);
|
|
|
83 |
extern int open_input(int);
|
|
|
84 |
extern int open_output(int, int);
|
|
|
85 |
extern void close_input(void);
|
|
|
86 |
extern void close_output(int);
|
|
|
87 |
extern void set_incl_depth(unsigned long);
|
|
|
88 |
extern void add_directory(string, string);
|
|
|
89 |
extern void directory_mode(string, OPTIONS *);
|
|
|
90 |
extern void builtin_startup(void);
|
|
|
91 |
extern void term_input(void);
|
|
|
92 |
extern long tell_buffer(unsigned long);
|
|
|
93 |
extern void seek_buffer(unsigned long, long, int);
|
|
|
94 |
extern void protection_macro(HASHID, int, int);
|
|
|
95 |
extern void update_column(void);
|
2 |
7u83 |
96 |
|
|
|
97 |
#ifdef SYSTEM_INCLUDED
|
6 |
7u83 |
98 |
extern int already_included(string, STAT_TYPE *, int);
|
2 |
7u83 |
99 |
#endif
|
|
|
100 |
|
|
|
101 |
|
|
|
102 |
/*
|
|
|
103 |
TYPE REPRESENTING AN INCLUSION DIRECTORY
|
|
|
104 |
|
|
|
105 |
This type is used to represent a directory which is searched during
|
|
|
106 |
file inclusion.
|
|
|
107 |
*/
|
|
|
108 |
|
|
|
109 |
typedef struct incl_dir_tag {
|
6 |
7u83 |
110 |
string path;
|
|
|
111 |
string name;
|
|
|
112 |
OPTIONS *mode;
|
|
|
113 |
ulong no;
|
|
|
114 |
struct incl_dir_tag *next;
|
|
|
115 |
} INCL_DIR;
|
2 |
7u83 |
116 |
|
|
|
117 |
|
|
|
118 |
/*
|
|
|
119 |
FILE READING VARIABLES
|
|
|
120 |
|
|
|
121 |
These variables relate to the file reading and writing routines.
|
|
|
122 |
*/
|
|
|
123 |
|
6 |
7u83 |
124 |
extern int crt_line_changed;
|
|
|
125 |
extern int crt_file_changed;
|
|
|
126 |
extern int crt_col_changed;
|
|
|
127 |
extern int crt_file_type;
|
|
|
128 |
extern int bad_crt_loc;
|
|
|
129 |
extern unsigned long crt_spaces;
|
|
|
130 |
extern unsigned long tab_width;
|
|
|
131 |
extern BUFFER internal_buff;
|
|
|
132 |
extern BUFFER incl_buff;
|
|
|
133 |
extern LIST(string)startup_files, endup_files;
|
|
|
134 |
extern FILE *input_file, *output_file[];
|
|
|
135 |
extern string input_name, output_name[];
|
|
|
136 |
extern unsigned long crt_buff_no;
|
|
|
137 |
extern string input_start, input_end;
|
|
|
138 |
extern string input_posn, input_eof;
|
|
|
139 |
extern string input_crt;
|
|
|
140 |
extern INCL_DIR *dir_path;
|
2 |
7u83 |
141 |
|
|
|
142 |
|
|
|
143 |
/*
|
|
|
144 |
CHARACTER READING AND UNREADING MACROS
|
|
|
145 |
|
|
|
146 |
The macro next_char reads the next character from the input buffer.
|
|
|
147 |
It needs to be checked against char_end to spot the end of the buffer.
|
|
|
148 |
The macro unread_char unreads the character A by inserting it back
|
|
|
149 |
into the input buffer.
|
|
|
150 |
*/
|
|
|
151 |
|
6 |
7u83 |
152 |
#define next_char() ((int)(*(input_posn++)))
|
|
|
153 |
#define unread_char(A) (*(--input_posn) = (character)(A))
|
2 |
7u83 |
154 |
|
|
|
155 |
|
|
|
156 |
/*
|
|
|
157 |
OUTPUT FILE NUMBERS
|
|
|
158 |
|
|
|
159 |
These values are used to represent the various output files.
|
|
|
160 |
*/
|
|
|
161 |
|
|
|
162 |
#define OUTPUT_TDF 0
|
|
|
163 |
#define OUTPUT_PREPROC 1
|
|
|
164 |
#define OUTPUT_SPEC 2
|
|
|
165 |
#define OUTPUT_DUMP 3
|
|
|
166 |
#define OUTPUT_ERROR 4
|
|
|
167 |
#define OUTPUT_FILES 5
|
|
|
168 |
|
|
|
169 |
|
|
|
170 |
#endif
|