Debian Codegraph @

texk/lcdf-typetools/lcdf-typetools-src/otftotfm/kpseinterface.c

raw
1 /* kpseinterface.{c,h} -- interface with the kpathsea library
2 *
3 * Copyright (c) 2003-2023 Eddie Kohler
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the Free
7 * Software Foundation; either version 2 of the License, or (at your option)
8 * any later version. This program is distributed in the hope that it will be
9 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
11 * Public License for more details.
12 */
13
14 #include <kpathsea/config.h>
15 #ifdef HAVE_CONFIG_H
16 # include <config.h>
17 #endif
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <kpathsea/progname.h>
21 #include <kpathsea/expand.h>
22 #include <kpathsea/c-pathch.h>
23 #include <kpathsea/tex-file.h>
24 #include <kpathsea/variable.h>
25 #include "kpseinterface.h"
26
27 int kpsei_env_sep_char = ENV_SEP;
28
29 void
30 kpsei_init(const char* argv0, const char* progname)
31 {
32 kpse_set_program_name(argv0, progname);
33 #ifdef SELFAUTODIR
34 putenv("SELFAUTODIR=" SELFAUTODIR);
35 #endif
36 #ifdef SELFAUTOLOC
37 putenv("SELFAUTOLOC=" SELFAUTOLOC);
38 #endif
39 #ifdef SELFAUTOPARENT
40 putenv("SELFAUTOPARENT=" SELFAUTOPARENT);
41 #endif
42 #ifdef SELFAUTOGRANDPARENT
43 putenv("SELFAUTOGRANDPARENT=" SELFAUTOGRANDPARENT);
44 #endif
45 }
46
47 char*
48 kpsei_path_expand(const char* path)
49 {
50 return kpse_path_expand(path);
51 }
52
53 char*
54 kpsei_var_value(const char *name)
55 {
56 return kpse_var_value(name);
57 }
58
59 char*
60 kpsei_find_file(const char* name, int format)
61 {
62 char *result;
63 switch (format) {
64 case KPSEI_FMT_WEB2C:
65 return kpse_find_file(name, kpse_web2c_format, true);
66 case KPSEI_FMT_ENCODING:
67 #if HAVE_DECL_KPSE_ENC_FORMAT
68 if ((result = kpse_find_file(name, kpse_enc_format, true)))
69 return result;
70 #endif
71 return kpse_find_file(name, kpse_tex_ps_header_format, true);
72 case KPSEI_FMT_TYPE1:
73 return kpse_find_file(name, kpse_type1_format, false);
74 case KPSEI_FMT_TYPE42:
75 return kpse_find_file(name, kpse_type42_format, false);
76 case KPSEI_FMT_TRUETYPE:
77 return kpse_find_file(name, kpse_truetype_format, false);
78 #if HAVE_DECL_KPSE_OPENTYPE_FORMAT
79 case KPSEI_FMT_OPENTYPE:
80 return kpse_find_file(name, kpse_opentype_format, false);
81 #endif
82 case KPSEI_FMT_OTHER_TEXT:
83 return kpse_find_file(name, kpse_program_text_format, true);
84 case KPSEI_FMT_MAP:
85 return kpse_find_file(name, kpse_fontmap_format, true);
86 default:
87 return 0;
88 }
89 }
90
91 void
92 kpsei_set_debug_flags(unsigned flags)
93 {
94 kpathsea_debug = flags;
95 }