2 /* Install modified versions of certain ANSI-incompatible system header
3 files which are fixed to work correctly with ANSI C and placed in a
4 directory that GNU C will search.
6 Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
8 This file is part of GNU CC.
10 GNU CC is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2, or (at your option)
15 GNU CC is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with GNU CC; see the file COPYING. If not, write to
22 the Free Software Foundation, 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA. */
25 #ifndef FIXINCLUDES_FIXLIB_H
26 #define FIXINCLUDES_FIXLIB_H
28 #include "auto-host.h"
29 #include "gansidecl.h"
32 #include "gnu-regex.h"
34 #include "libiberty.h"
39 # define STDIN_FILENO 0
42 # define STDOUT_FILENO 1
45 typedef int t_success;
51 #define SUCCEEDED(p) ((p) == SUCCESS)
52 #define SUCCESSFUL(p) SUCCEEDED (p)
53 #define FAILED(p) ((p) < SUCCESS)
54 #define HADGLITCH(p) ((p) > SUCCESS)
57 #define tSCC static const char
58 #define tCC const char
59 #define tSC static char
61 /* If this particular system's header files define the macro `MAXPATHLEN',
62 we happily take advantage of it; otherwise we use a value which ought
63 to be large enough. */
65 # define MAXPATHLEN 4096
69 # define EXIT_SUCCESS 0
72 # define EXIT_FAILURE 1
80 #define NOPROCESS ((pid_t) -1)
81 #define NULLPROCESS ((pid_t)0)
85 #ifndef HAVE_T_BOOL_ENUM
86 #define HAVE_T_BOOL_ENUM
93 typedef int apply_fix_p_t; /* Apply Fix Predicate Type */
102 _ENV_( pz_machine, BOOL_TRUE, "TARGET_MACHINE", \
103 "output from config.guess" ) \
105 _ENV_( pz_src_dir, BOOL_TRUE, "SRCDIR", \
106 "directory of original files" ) \
108 _ENV_( pz_input_dir, BOOL_TRUE, "INPUT", \
109 "current directory for fixincl" ) \
111 _ENV_( pz_dest_dir, BOOL_TRUE, "DESTDIR", \
112 "output directory" ) \
114 _ENV_( pz_verbose, BOOL_FALSE, "VERBOSE", \
115 "amount of user entertainment" ) \
117 _ENV_( pz_find_base, BOOL_TRUE, "FIND_BASE", \
118 "leader to trim from file names" )
122 Each fix may have associated tests that determine
123 whether the fix needs to be applied or not.
124 Each test has a type (from the te_test_type enumeration);
125 associated test text; and, if the test is TT_EGREP or
126 the negated form TT_NEGREP, a pointer to the compiled
127 version of the text string.
132 TT_TEST, TT_EGREP, TT_NEGREP, TT_FUNCTION
135 typedef struct test_desc tTestDesc;
140 const char *pz_test_text;
141 regex_t *p_test_regex;
144 typedef struct patch_desc tPatchDesc;
148 Everything you ever wanted to know about how to apply
149 a particular fix (which files, how to qualify them,
150 how to actually make the fix, etc...)
152 NB: the FD_ defines are BIT FLAGS
155 #define FD_MACH_ONLY 0x0000
156 #define FD_MACH_IFNOT 0x0001
157 #define FD_SHELL_SCRIPT 0x0002
158 #define FD_SUBROUTINE 0x0004
159 #define FD_REPLACEMENT 0x0008
160 #define FD_SKIP_TEST 0x8000
162 typedef struct fix_desc tFixDesc;
165 tCC* fix_name; /* Name of the fix */
166 tCC* file_list; /* List of files it applies to */
167 tCC** papz_machs; /* List of machine/os-es it applies to */
170 tTestDesc* p_test_desc;
182 extern int gnu_type_map_ct;
184 #ifdef HAVE_MMAP_FILE
185 #define UNLOAD_DATA() do { if (curr_data_mapped) { \
186 munmap ((void*)pz_curr_data, data_map_size); close (data_map_fd); } \
187 else free ((void*)pz_curr_data); } while(0)
189 #define UNLOAD_DATA() free ((void*)pz_curr_data)
193 * Exported procedures
195 char * load_file_data _P_(( FILE* fp ));
196 #ifdef IS_CXX_HEADER_NEEDED
197 t_bool is_cxx_header _P_(( tCC* filename, tCC* filetext ));
198 #endif /* IS_CXX_HEADER_NEEDED */
199 #ifdef SKIP_QUOTE_NEEDED
200 tCC* skip_quote _P_(( char q, char* text ));
202 void compile_re _P_(( tCC* pat, regex_t* re, int match,
205 void apply_fix _P_(( tFixDesc* p_fixd, tCC* filname ));
206 apply_fix_p_t run_test _P_((tCC* t_name, tCC* f_name, tCC* text ));
209 void mn_get_regexps _P_(( regex_t** label_re, regex_t** name_re,
212 #endif /* FIXINCLUDES_FIXLIB_H */