3
* - commn functions used in vflmkXXX.c
6
* by Hirotsugu Kakugawa
11
* Copyright (C) 2001 Hirotsugu Kakugawa.
12
* All rights reserved.
14
* This program is free software; you can redistribute it and/or modify
15
* it under the terms of the GNU General Public License as published by
16
* the Free Software Foundation; either version 2, or (at your option)
19
* This program is distributed in the hope that it will be useful,
20
* but WITHOUT ANY WARRANTY; without even the implied warranty of
21
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
* GNU General Public License for more details.
24
* You should have received a copy of the GNU General Public License
25
* along with this program; if not, write to the Free Software
26
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
36
#include <sys/param.h>
40
# include "kpathsea/kpathsea.h"
43
#include "VFlib-3_6.h"
51
copy_cmdline(int xargc, char **xargv)
57
for (i = 0; i < xargc; i++)
58
t = t + strlen(xargv[i]) + 1;
59
if ((s = malloc(t)) == NULL){
60
fprintf(stderr, "no memory.\n");
65
for (i = 0; i < xargc; i++){
67
p += strlen(xargv[i]);
77
banner(char *name, char *prog, char *cline)
79
char host[256], ts[256], *p;
82
if (gethostname(host, sizeof(host)) < 0)
86
strcpy(ts, asctime(localtime(&t)));
87
if ((p = strchr(ts, '\n')) != NULL)
90
printf(";; -------------------------------------------------------\n");
91
printf(";; *** %s ***\n", name);
92
printf(";; Generated by %s\n", prog);
93
printf(";; at %s on %s\n", ts, host);
94
printf(";; Commandline:\n");
95
printf(";; %s\n", cline);
105
fprintf(stderr, "internal error.");
109
p = malloc(strlen(s) + 1);
111
fprintf(stderr, "no memory.");
120
check_font_exist(char *file, char **dirs, int ndirs, int kptype, char **ext)
123
char path[MAXPATHLEN], *p, **e;
124
char *e0[] = { "", NULL };
127
return 0; /* may or may not exist */
129
for (i = 0; i < ndirs; i++){
130
if ((strcmp(dirs[i], "TEXMF") == 0)
131
|| (strcmp(dirs[i], "KPATHSEA") == 0)
132
|| (strcmp(dirs[i], "texmf") == 0)
133
|| (strcmp(dirs[i], "kpathsea") == 0)){
134
p = kpse_find_file(file, kptype, 0);
135
if (access(p, R_OK) >= 0)
136
return 0; /* exist */
141
for (j = 0; e[j] != NULL; j++){
142
sprintf(path, "%s", dirs[i]);
144
if ((l >= 2) && (dirs[i][l-2] == '/') && (dirs[i][l-1] == '/')){
145
sprintf(&path[l-2], "/%s", file);
146
} else if ((l >= 2) && (dirs[i][l-2] != '/') && (dirs[i][l-1] == '/')){
147
sprintf(&path[l-1], "/%s", file);
149
sprintf(&path[l], "/%s", file);
153
printf("***%s\n", path);
155
if (access(path, R_OK) >= 0){
156
sprintf(path, "%s%s", file, e[j]);
157
return x_strdup(path); /* exist */
163
return NULL; /* not exist */
171
fprintf(stderr,"Illegal command line argument\n");
172
fprintf(stderr,"Use '--help' option for help\n");
179
map_need_tfm(char *fontclass)
182
static char *db[] = {
187
for (i = 0; db[i] != NULL; i++){
188
if (strcmp(fontclass, db[i]) == 0)