dvitomp fix from Akira
[mplib] / src / texk / kpathsea / tex-file.h
1 /* tex-file.h: find files in a particular format.
2
3    Copyright 1993, 1994, 1995, 1996, 2007, 2008 Karl Berry.
4    Copyright 1998-2005 Olaf Weber.
5
6    This library is free software; you can redistribute it and/or
7    modify it under the terms of the GNU Lesser General Public
8    License as published by the Free Software Foundation; either
9    version 2.1 of the License, or (at your option) any later version.
10
11    This library is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14    Lesser General Public License for more details.
15
16    You should have received a copy of the GNU Lesser General Public License
17    along with this library; if not, see <http://www.gnu.org/licenses/>.  */
18
19 #ifndef KPATHSEA_TEX_FILE_H
20 #define KPATHSEA_TEX_FILE_H
21
22 #include <kpathsea/c-proto.h>
23 #include <kpathsea/c-vararg.h>
24 #include <kpathsea/types.h>
25
26
27 /* If non-NULL, try looking for this if can't find the real font.  */
28 extern const_string kpse_fallback_font;
29
30
31 /* If non-NULL, default list of fallback resolutions comes from this
32    instead of the compile-time value.  Set by dvipsk for the R config
33    cmd.  *SIZES environment variables override/use as default.  */
34 extern KPSEDLL const_string kpse_fallback_resolutions_string;
35
36 /* If non-NULL, check these if can't find (within a few percent of) the
37    given resolution.  List must end with a zero element.  */
38 extern unsigned *kpse_fallback_resolutions;
39
40 /* This initializes the fallback resolution list.  If ENVVAR
41    is set, it is used; otherwise, the envvar `TEXSIZES' is looked at; if
42    that's not set either, a compile-time default is used.  */
43 extern void kpse_init_fallback_resolutions P1H(string envvar);
44 \f
45 /* We put the glyphs first so we don't waste space in an array in
46    tex-glyph.c.  Accompany a new format here with appropriate changes in
47    tex-file.c and kpsewhich.c (the suffix variable).  */
48 typedef enum
49 {
50   kpse_gf_format,
51   kpse_pk_format,
52   kpse_any_glyph_format,        /* ``any'' meaning gf or pk */
53   kpse_tfm_format, 
54   kpse_afm_format, 
55   kpse_base_format, 
56   kpse_bib_format, 
57   kpse_bst_format, 
58   kpse_cnf_format,
59   kpse_db_format,
60   kpse_fmt_format,
61   kpse_fontmap_format,
62   kpse_mem_format,
63   kpse_mf_format, 
64   kpse_mfpool_format, 
65   kpse_mft_format, 
66   kpse_mp_format, 
67   kpse_mppool_format, 
68   kpse_mpsupport_format,
69   kpse_ocp_format,
70   kpse_ofm_format, 
71   kpse_opl_format,
72   kpse_otp_format,
73   kpse_ovf_format,
74   kpse_ovp_format,
75   kpse_pict_format,
76   kpse_tex_format,
77   kpse_texdoc_format,
78   kpse_texpool_format,
79   kpse_texsource_format,
80   kpse_tex_ps_header_format,
81   kpse_troff_font_format,
82   kpse_type1_format, 
83   kpse_vf_format,
84   kpse_dvips_config_format,
85   kpse_ist_format,
86   kpse_truetype_format,
87   kpse_type42_format,
88   kpse_web2c_format,
89   kpse_program_text_format,
90   kpse_program_binary_format,
91   kpse_miscfonts_format,
92   kpse_web_format,
93   kpse_cweb_format,
94   kpse_enc_format,
95   kpse_cmap_format,
96   kpse_sfd_format,
97   kpse_opentype_format,
98   kpse_pdftex_config_format,
99   kpse_lig_format,
100   kpse_texmfscripts_format,
101   kpse_lua_format,
102   kpse_last_format /* one past last index */
103 } kpse_file_format_type;
104
105
106 /* Perhaps we could use this for path values themselves; for now, we use
107    it only for the program_enabled_p value.  */
108 typedef enum
109 {
110   kpse_src_implicit,   /* C initialization to zero */
111   kpse_src_compile,    /* configure/compile-time default */
112   kpse_src_texmf_cnf,  /* texmf.cnf, the kpathsea config file */
113   kpse_src_client_cnf, /* application config file, e.g., config.ps */
114   kpse_src_env,        /* environment variable */
115   kpse_src_x,          /* X Window System resource */
116   kpse_src_cmdline     /* command-line option */
117 } kpse_src_type;
118
119
120 /* For each file format, we record the following information.  The main
121    thing that is not part of this structure is the environment variable
122    lists. They are used directly in tex-file.c. We could incorporate
123    them here, but it would complicate the code a bit. We could also do
124    it via variable expansion, but not now, maybe not ever:
125    ${PKFONTS-${TEXFONTS-/usr/local/lib/texmf/fonts//}}.  */
126
127 typedef struct
128 {
129   const_string type;            /* Human-readable description.  */
130   const_string path;            /* The search path to use.  */
131   const_string raw_path;        /* Pre-$~ (but post-default) expansion.  */
132   const_string path_source;     /* Where the path started from.  */
133   const_string override_path;   /* From client environment variable.  */
134   const_string client_path;     /* E.g., from dvips's config.ps.  */
135   const_string cnf_path;        /* From texmf.cnf.  */
136   const_string default_path;    /* If all else fails.  */
137   const_string *suffix;         /* For kpse_find_file to check for/append.  */
138   const_string *alt_suffix;     /* More suffixes to check for.  */
139   boolean suffix_search_only;   /* Only search with a suffix?  */
140   const_string program;         /* ``mktexpk'', etc.  */
141   int          argc;            /* Count of standard arguments. */
142   const_string *argv;           /* Standard arguments to `program'.  */
143   boolean program_enabled_p;    /* Invoke `program'?  */
144   kpse_src_type program_enable_level; /* Who said to invoke `program'.  */
145   boolean binmode;              /* The files must be opened in binary mode. */
146 } kpse_format_info_type;
147
148 /* The sole variable of that type, indexed by `kpse_file_format_type'.
149    Initialized by calls to `kpse_find_file' for `kpse_init_format'.  */
150 extern KPSEDLL kpse_format_info_type kpse_format_info[kpse_last_format];
151
152
153 /* If LEVEL is higher than `program_enabled_level' for FMT, set
154    `program_enabled_p' to VALUE.  */
155 extern KPSEDLL void kpse_set_program_enabled P3H(kpse_file_format_type fmt,
156                                          boolean value, kpse_src_type level);
157 /* Call kpse_set_program_enabled with VALUE and the format corresponding
158    to FMTNAME.  */
159 extern KPSEDLL void kpse_maketex_option P2H(const_string fmtname,  boolean value);
160
161 /* Change the list of searched suffixes (alternate suffixes if alternate is
162    true).  */
163 extern KPSEDLL void kpse_set_suffixes PVAR2H(kpse_file_format_type format,
164                                              boolean alternate);
165
166 /* Initialize the info for the given format.  This is called
167    automatically by `kpse_find_file', but the glyph searching (for
168    example) can't use that function, so make it available.  */
169 extern KPSEDLL const_string kpse_init_format P1H(kpse_file_format_type);
170
171 /* If FORMAT has a non-null `suffix' member, append it to NAME "."
172    and call `kpse_path_search' with the result and the other arguments.
173    If that fails, try just NAME.  */
174 extern KPSEDLL string kpse_find_file P3H(const_string name,
175                             kpse_file_format_type format,  boolean must_exist);
176
177 /* Ditto, allowing ALL parameter and hence returning a NULL-terminated
178    list of results.  */
179 extern KPSEDLL string *kpse_find_file_generic
180   P4H(const_string name, kpse_file_format_type format,
181       boolean must_exist, boolean all);
182
183 /* Here are some abbreviations.  */
184 #define kpse_find_mf(name)   kpse_find_file (name, kpse_mf_format, true)
185 #define kpse_find_mft(name)  kpse_find_file (name, kpse_mft_format, true)
186 #define kpse_find_pict(name) kpse_find_file (name, kpse_pict_format, true)
187 #define kpse_find_tex(name)  kpse_find_file (name, kpse_tex_format, true)
188 #define kpse_find_tfm(name)  kpse_find_file (name, kpse_tfm_format, true)
189 #define kpse_find_ofm(name)  kpse_find_file (name, kpse_ofm_format, true)
190
191 /* The `false' is correct for DVI translators, which should clearly not
192    require vf files for every font (e.g., cmr10.vf).  But it's wrong for
193    VF translators, such as vftovp.  */
194 #define kpse_find_vf(name) kpse_find_file (name, kpse_vf_format, false)
195 #define kpse_find_ovf(name) kpse_find_file (name, kpse_ovf_format, false)
196
197 /* Don't just look up the name, actually open the file.  */
198 extern KPSEDLL FILE *kpse_open_file P2H(const_string, kpse_file_format_type);
199
200 /* This function is used to set kpse_program_name (from progname.c) to
201    a different value.  It will clear the path searching information, to
202    ensure that the search paths are appropriate to the new name. */
203 extern KPSEDLL void kpse_reset_program_name P1H(const_string progname);
204
205 #endif /* not KPATHSEA_TEX_FILE_H */