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