File: kpse.c

package info (click to toggle)
dvi2dvi 2.0alpha-12
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 928 kB
  • sloc: ansic: 6,645; makefile: 96; sh: 8
file content (123 lines) | stat: -rw-r--r-- 3,189 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#ifdef KPATHSEA

#include	"defs.h"
#include	"global.h"
extern struct str_llist_elt *value;	       /* Forward declaration */
#include	<kpathsea/config.h>
#include	<kpathsea/pathsearch.h>
#include	<kpathsea/tex-file.h>
#include	<kpathsea/tex-glyph.h>

char *
kpsearch_glyph(proto, n, format, acca, name)
char *proto, *n;
kpse_file_format_type format;
struct accarg *acca;
char *name;
{
    char *path, *base;
    const_string save_path, save_orpath;
    kpse_format_info_type *spec = &kpse_format_info[format];
    kpse_glyph_file_type font_file;
    char *filename;

    pavek(name, &path, &base, proto, acca);
    if (path != NULL) {
	save_path = spec->path;
	save_orpath = spec->override_path;
	spec->path = NULL;
	spec->override_path = path;
    }
    if (spec->path == NULL)
	kpse_init_format(format);
    if (acca->acc_mode&ACC_GEN)
	spec->program_enabled_p = true;
    if (base == NULL)
	filename = kpse_find_glyph(n, acca->pv_mag, format, &font_file);
    else if (path == NULL)
	filename = kpse_find_glyph(base, acca->pv_mag, format, &font_file);
    else if (path == NULL)
	filename = kpse_find_file(base, format, true);
    else
	filename = kpse_path_search(spec->path, base, false);
    if (path != NULL) {
	spec->path = save_path;
	spec->override_path = save_orpath;
    }
    if (acca->acc_mode&ACC_GEN)
	spec->program_enabled_p = false;
    return filename;
}

char *
kpsearch_make(proto, n, format, acca, name)
char *proto, *n;
kpse_file_format_type format;
struct accarg *acca;
char *name;
{
    char *path, *base;
    const_string save_path, save_orpath;
    kpse_format_info_type *spec = &kpse_format_info[format];
    char *filename;

    pavek(name, &path, &base, proto, acca);
    if (path != NULL) {
	save_path = spec->path;
	save_orpath = spec->override_path;
	spec->path = NULL;
	spec->override_path = path;
    }
    if (spec->path == NULL)
	kpse_init_format(format);
    if (acca->acc_mode&ACC_GEN)
	spec->program_enabled_p = true;
    if (base == NULL)
	filename = kpse_find_file(n, format, true);
    else if (path == NULL)
	filename = kpse_find_file(base, format, true);
    else
	filename = kpse_path_search(spec->path, base, false);
    if (path != NULL) {
	spec->path = save_path;
	spec->override_path = save_orpath;
    }
    if (acca->acc_mode&ACC_GEN)
	spec->program_enabled_p = false;
    return filename;
}

char *
kpsearch_file(proto, n, format)
char *proto, *n;
kpse_file_format_type format;
{
    char pathname[PATHLEN];	/* dummy */
    char *path, *base;
    const_string save_path, save_orpath;
    kpse_format_info_type *spec = &kpse_format_info[format];
    char *filename;

    pavek(pathname, &path, &base, proto, NULL);
    if (path != NULL) {
	save_path = spec->path;
	save_orpath = spec->override_path;
	spec->path = NULL;
	spec->override_path = path;
    }
    if (spec->path == NULL)
	kpse_init_format(format);
    if (base == NULL)
	filename = kpse_find_file(n, format, true);
    else if (path == NULL)
	filename = kpse_find_file(base, format, true);
    else
	filename = kpse_path_search(spec->path, base, false);
    if (path != NULL) {
	spec->path = save_path;
	spec->override_path = save_orpath;
    }
    return filename;
}

#endif