beta-0.89.2
[luatex.git] / source / texk / kpathsea / types.h
blob54fd59c604ed6b558fa5a22852a4426934b986a7
1 /* types.h: general types for kpathsea.
3 Copyright 1993, 1995, 1996, 2005, 2008-2014 Karl Berry.
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this library; if not, see <http://www.gnu.org/licenses/>. */
18 #ifndef KPATHSEA_TYPES_H
19 #define KPATHSEA_TYPES_H
21 /* Our string, boolean, etc. */
22 #include <kpathsea/simpletypes.h>
24 /* Required until all programs use the new API, if ever. */
25 #define KPSE_COMPAT_API 1
27 #include <stdio.h> /* for FILE* */
29 /* Declare int64_t and uint64_t, and define PRId64 etc. */
30 #ifdef HAVE_INTTYPES_H
31 # include <inttypes.h>
32 #endif
33 #ifdef HAVE_STDINT_H
34 # include <stdint.h>
35 #endif
36 #if (!defined __cplusplus || defined __STDC_FORMAT_MACROS) && !defined PRId64
37 # if SIZEOF_LONG == 8
38 # define __PRI64_PREFIX "l"
39 # else
40 # define __PRI64_PREFIX "ll"
41 # endif
42 # define PRId64 __PRI64_PREFIX "d"
43 # define PRIi64 __PRI64_PREFIX "i"
44 # define PRIo64 __PRI64_PREFIX "o"
45 # define PRIu64 __PRI64_PREFIX "u"
46 # define PRIx64 __PRI64_PREFIX "x"
47 # define PRIX64 __PRI64_PREFIX "X"
48 #endif
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
54 /* function pointer prototype definitions for recorder */
55 typedef void (*p_record_input) (const_string);
56 typedef void (*p_record_output) (const_string);
58 #ifdef __cplusplus
60 #endif
62 /* the cache structure from elt-dirs.c */
63 #include <kpathsea/str-llist.h>
65 #ifdef __cplusplus
66 extern "C" {
67 #endif
69 typedef struct
71 const_string key;
72 str_llist_type *value;
73 } cache_entry;
75 /* from variable.c */
76 typedef struct {
77 const_string var;
78 boolean expanding;
79 } expansion_type;
81 #ifdef __cplusplus
83 #endif
86 #include <kpathsea/hash.h>
87 #include <kpathsea/str-list.h>
89 #ifdef __cplusplus
90 extern "C" {
91 #endif
93 /* from old tex-file.h */
95 /* We put the glyphs first so we don't waste space in an array in
96 tex-glyph.c. Accompany a new format here with appropriate changes in
97 tex-file.c and kpsewhich.c (the suffix variable). */
98 typedef enum
100 kpse_gf_format,
101 kpse_pk_format,
102 kpse_any_glyph_format, /* ``any'' meaning gf or pk */
103 kpse_tfm_format,
104 kpse_afm_format,
105 kpse_base_format,
106 kpse_bib_format,
107 kpse_bst_format,
108 kpse_cnf_format,
109 kpse_db_format,
110 kpse_fmt_format,
111 kpse_fontmap_format,
112 kpse_mem_format,
113 kpse_mf_format,
114 kpse_mfpool_format,
115 kpse_mft_format,
116 kpse_mp_format,
117 kpse_mppool_format,
118 kpse_mpsupport_format,
119 kpse_ocp_format,
120 kpse_ofm_format,
121 kpse_opl_format,
122 kpse_otp_format,
123 kpse_ovf_format,
124 kpse_ovp_format,
125 kpse_pict_format,
126 kpse_tex_format,
127 kpse_texdoc_format,
128 kpse_texpool_format,
129 kpse_texsource_format,
130 kpse_tex_ps_header_format,
131 kpse_troff_font_format,
132 kpse_type1_format,
133 kpse_vf_format,
134 kpse_dvips_config_format,
135 kpse_ist_format,
136 kpse_truetype_format,
137 kpse_type42_format,
138 kpse_web2c_format,
139 kpse_program_text_format,
140 kpse_program_binary_format,
141 kpse_miscfonts_format,
142 kpse_web_format,
143 kpse_cweb_format,
144 kpse_enc_format,
145 kpse_cmap_format,
146 kpse_sfd_format,
147 kpse_opentype_format,
148 kpse_pdftex_config_format,
149 kpse_lig_format,
150 kpse_texmfscripts_format,
151 kpse_lua_format,
152 kpse_fea_format,
153 kpse_cid_format,
154 kpse_mlbib_format,
155 kpse_mlbst_format,
156 kpse_clua_format,
157 kpse_ris_format,
158 kpse_bltxml_format,
159 kpse_last_format /* one past last index */
160 } kpse_file_format_type;
163 /* Perhaps we could use this for path values themselves; for now, we use
164 it only for the program_enabled_p value. */
165 typedef enum
167 kpse_src_implicit, /* C initialization to zero */
168 kpse_src_compile, /* configure/compile-time default */
169 kpse_src_texmf_cnf, /* texmf.cnf, the kpathsea config file */
170 kpse_src_client_cnf, /* application config file, e.g., config.ps */
171 kpse_src_env, /* environment variable */
172 kpse_src_x, /* X Window System resource */
173 kpse_src_cmdline /* command-line option */
174 } kpse_src_type;
177 /* For each file format, we record the following information. The main
178 thing that is not part of this structure is the environment variable
179 lists. They are used directly in tex-file.c. We could incorporate
180 them here, but it would complicate the code a bit. We could also do
181 it via variable expansion, but not now, maybe not ever:
182 ${PKFONTS-${TEXFONTS-/usr/local/lib/texmf/fonts//}}. */
184 typedef struct
186 const_string type; /* Human-readable description. */
187 string path; /* The search path to use. */
188 const_string raw_path; /* Pre-$~ (but post-default) expansion. */
189 const_string path_source; /* Where the path started from. */
190 const_string override_path; /* From client environment variable. */
191 const_string client_path; /* E.g., from dvips's config.ps. */
192 const_string cnf_path; /* From texmf.cnf. */
193 const_string default_path; /* If all else fails. */
194 const_string *suffix; /* For kpse_find_file to check for/append. */
195 const_string *alt_suffix; /* More suffixes to check for. */
196 boolean suffix_search_only; /* Only search with a suffix? */
197 const_string program; /* ``mktexpk'', etc. */
198 int argc; /* Count of standard arguments. */
199 const_string *argv; /* Standard arguments to `program'. */
200 boolean program_enabled_p; /* Invoke `program'? */
201 kpse_src_type program_enable_level; /* Who said to invoke `program'. */
202 boolean binmode; /* Open files in binary mode? */
203 } kpse_format_info_type;
205 #if defined(WIN32) && !defined(__MINGW32__)
206 struct passwd {
207 char *pw_name;
208 char *pw_passwd;
209 int pw_uid;
210 int pw_gid;
211 int pw_quota;
212 char *pw_gecos;
213 char *pw_dir;
214 char *pw_shell;
216 #endif /* WIN32 && !__MINGW32 */
218 typedef struct kpathsea_instance *kpathsea;
220 typedef struct kpathsea_instance {
221 /* from cnf.c */
222 p_record_input record_input; /* for --recorder */
223 p_record_output record_output; /* for --recorder */
224 hash_table_type cnf_hash; /* used by read_all_cnf */
225 boolean doing_cnf_init; /* for kpse_cnf_get */
226 /* from db.c */
227 hash_table_type db; /* The hash table for all ls-R's */
228 hash_table_type alias_db; /* The hash table for the aliases */
229 str_list_type db_dir_list; /* list of ls-R's */
230 /* from debug.c */
231 unsigned debug; /* for --kpathsea-debug */
232 /* from dir.c */
233 hash_table_type link_table; /* a hash of links-per-dir */
234 /* from elt-dir.c */
235 cache_entry *the_cache;
236 unsigned cache_length;
237 /* from fontmap.c */
238 hash_table_type map; /* the font mapping hash */
239 const_string map_path; /* path for kpse_fontmap_format */
240 /* from hash.c */
241 /* Print the hash values as integers if this is nonzero. */
242 boolean debug_hash_lookup_int;
243 /* from path-elt.c */
244 string elt; /* static buffer for return value */
245 unsigned elt_alloc;
246 const_string path; /* path we're currently working on */
247 /* from pathsearch.c */
248 boolean followup_search;
249 FILE *log_file;
250 boolean log_opened; /* Need to open the log file? */
251 /* from progname.c */
252 string invocation_name;
253 string invocation_short_name;
254 string program_name; /* pretended name */
255 int ll_verbose; /* for symlinks (conditional) */
256 /* from tex-file.c */
257 /* If non-NULL, try looking for this if can't find the real font. */
258 const_string fallback_font;
259 /* If non-NULL, default list of fallback resolutions comes from this
260 instead of the compile-time value. Set by dvipsk for the R config
261 cmd. *SIZES environment variables override/use as default. */
262 const_string fallback_resolutions_string;
263 /* If non-NULL, check these if can't find (within a few percent of) the
264 given resolution. List must end with a zero element. */
265 unsigned *fallback_resolutions;
266 kpse_format_info_type format_info[kpse_last_format];
267 /* from tex-make.c */
268 /* We never throw away stdout, since that is supposed to be the filename
269 found, if all is successful. This variable controls whether stderr
270 is thrown away. */
271 boolean make_tex_discard_errors;
272 FILE *missfont;
273 /* from variable.c */
274 expansion_type *expansions; /* sole variable of this type */
275 unsigned expansion_len ;
276 /* from xputenv.c */
277 /* These record the strings we've set and have to keep around.
278 This function can be called many times during a run, and this
279 allows us to reclaim memory we allocated. */
280 char **saved_env; /* keep track of changed items */
281 int saved_count;
282 #if defined(WIN32) || defined(__CYGWIN__)
283 char **suffixlist;
284 #endif /* WIN32 || __CYGWIN__ */
286 #if defined(WIN32) && !defined(__MINGW32__)
287 char the_passwd_name[256];
288 char the_passwd_passwd[256];
289 char the_passwd_gecos[256];
290 char the_passwd_dir[256];
291 char the_passwd_shell[256];
292 struct passwd the_passwd;
293 int __system_allow_multiple_cmds;
294 #endif /* WIN32 && !__MINGW32__ */
295 } kpathsea_instance;
297 /* these come from kpathsea.c */
298 extern KPSEDLL kpathsea kpathsea_new (void) ;
299 extern KPSEDLL void kpathsea_finish (kpathsea kpse) ;
301 #if defined (KPSE_COMPAT_API)
303 #define kpse_bug_address kpathsea_bug_address
305 extern KPSEDLL kpathsea_instance kpse_def_inst;
306 extern KPSEDLL kpathsea kpse_def;
308 #define kpathsea_debug kpse_def_inst.debug
309 #define kpse_program_name kpse_def_inst.program_name
310 #define kpse_record_input kpse_def_inst.record_input
311 #define kpse_record_output kpse_def_inst.record_output
312 #define kpse_make_tex_discard_errors kpse_def_inst.make_tex_discard_errors
313 #define kpse_fallback_font kpse_def_inst.fallback_font
314 #define kpse_fallback_resolutions_string kpse_def_inst.fallback_resolutions_string
315 #define kpse_fallback_resolutions kpse_def_inst.fallback_resolutions
316 #define kpse_format_info kpse_def_inst.format_info
317 #define kpse_debug_hash_lookup_int kpse_def_inst.debug_hash_lookup_int
319 #undef kpse_invocation_name
320 #define kpse_invocation_name kpse_def_inst.invocation_name
321 #undef kpse_invocation_short_name
322 #define kpse_invocation_short_name kpse_def_inst.invocation_short_name
324 #endif /* KPSE_COMPAT_API */
326 #ifdef __cplusplus
328 #endif
330 #endif /* not KPATHSEA_TYPES_H */