File: vflmkvfl.c

package info (click to toggle)
vflib3 3.6.14.dfsg-3+nmu3
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 11,536 kB
  • ctags: 3,710
  • sloc: ansic: 35,811; sh: 10,357; asm: 3,290; makefile: 962; lisp: 123; perl: 109; awk: 43
file content (246 lines) | stat: -rw-r--r-- 5,853 bytes parent folder | download | duplicates (8)
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
/* 
 * vflmkvfl.c 
 * - a vflibcap entry generator for VFlib default entry
 *
 * - This program prints vflibcap entries to standard output.
 *
 * - Useful for generating vflibcap for TeX DVI drivers
 *
 *
 * by Hirotsugu Kakugawa
 *
 *  10 May 2001
 */
/*
 * Copyright (C) 2001  Hirotsugu Kakugawa. 
 * All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  
 */


#include "config.h"
#include "with.h"
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <unistd.h>
#include <sys/param.h>
#include <sys/time.h>

#include  "VFlib-3_6.h"
#include  "VFsys.h"
#include  "vflibcap.h"
#include  "texfonts.h"
#include  "fsearch.h"
#include  "vflmklib.h"



void  gen_class_deafult(void);


char  *mode  = DEFAULT_KPS_MODE;
char  *dpi   = NULL;
int    dpi_i = DEFAULT_KPS_DPI;


#define NEHINTS    64
int   n_eh = 0; 
char  *ehint_ext[NEHINTS];
char  *ehint_cls[NEHINTS];

#define NIMPLS  64
int   n_impl = 0; 
char  *impl[NIMPLS];

#define NCCVS     256
int   n_ccv = 0; 
char  *ccvs[NCCVS];

int use_kpathsea = 0;
char *kps_prog = "xgdvi";


char *cmdline = NULL; 



int 
main(int argc, char **argv)
{
  int     i;
  int    xargc;
  char **xargv;

  dpi = malloc(256);
  sprintf(dpi, "%d", dpi_i);

  cmdline = copy_cmdline(argc, argv);

  n_eh = 0;
  for (i = 0; i < NEHINTS; i++){
    ehint_ext[i] = NULL;
    ehint_cls[i] = NULL;
  }
  n_impl = 0;
  for (i = 0; i < NIMPLS; i++){
    impl[i] = NULL;
  }
  n_ccv = 0;
  for (i = 0; i < NCCVS; i++){
    ccvs[i] = NULL;
  }


  xargc = argc; 
  xargv = argv;

  for (xargc--,xargv++; xargc > 0; xargc--,xargv++){
    if ((strcmp(*xargv, "--help") == 0)
	|| (strcmp(*xargv, "-help") == 0)){
      printf("vflmkvfl: generates vflibcap entries for TFM fonts\n");
      printf("Usage: vflmkvfl [options]\n");
      printf("Options\n");
      printf("  -k       : Use kpathsea for TeX file search\n");
      printf("  -r DPI   : Default device resolution\n");
      printf("  -n MODE  : Device mode name for kpathsea\n");
      printf("  -p PROG  : Application program name for kpathsea\n");
      printf("  -e EXT CLASS : extension hint\n");
      printf("  -i CLASS     : implicit font class\n");
      printf("  -c CCV   : CCV file\n");
      printf("Example: vflmkvfl -k -r 300 -n cx -p xgdvi\n");
      exit(0);

    } else if (strcmp(*xargv, "-k") == 0){
      /* kpathsea */
      use_kpathsea = 1;

    } else if (strcmp(*xargv, "-c") == 0){
      /* ccv */
      if (n_ccv == NCCVS){
	fprintf(stderr, "Too many CCV files\n");
	exit(1);
      }
      xargv++; xargc--;
      check_argc(xargc);
      ccvs[n_ccv++] = x_strdup(*xargv);

    } else if (strcmp(*xargv, "-r") == 0){
      xargv++; xargc--;
      check_argc(xargc);
      dpi = strdup(*xargv);

    } else if (strcmp(*xargv, "-n") == 0){
      /* mode name */
      xargv++; xargc--;
      check_argc(xargc);
      mode = x_strdup(*xargv);

    } else if (strcmp(*xargv, "-p") == 0){
      /* prog name */
      xargv++; xargc--;
      check_argc(xargc);
      kps_prog = x_strdup(*xargv);

    } else if (strcmp(*xargv, "-e") == 0){
      /* extension hint */
      if (n_eh == NEHINTS){
	fprintf(stderr, "Too many extension hints\n");
	exit(1);
      }
      xargv++; xargc--;
      ehint_ext[n_eh] = x_strdup(*xargv); 
      xargv++; xargc--;
      ehint_cls[n_eh] = x_strdup(*xargv); 
      n_eh++;

    } else if (strcmp(*xargv, "-i") == 0){
      /* implicit fonts */
      if (n_impl == NIMPLS){
	fprintf(stderr, "Too many implicit fonts\n");
	exit(1);
      }
      xargv++; xargc--;
      impl[n_impl] = x_strdup(*xargv); 
      n_impl++;

    } else {
      if (*xargv[0] == '-'){
	fprintf(stderr, "vflmkvfl: unknown option %s\n", *xargv);
	exit(1);
      }
      break;

    }
  }

  banner("VFlib defaults", "vflmkvfl", cmdline);

  gen_class_deafult();    

  return 0;
}


void
gen_class_deafult(void)
{
  int   i;

  printf("(%s %s", 
	 VF_CAPE_VFLIBCAP_CLASS_DEFAULT_DEFINITION, VF_CAPE_VFLIB_DEFAULTS);

  printf("\n  (%s", VF_CAPE_EXTENSION_HINT);
  for (i = 0; i < n_eh; i++){
    if ((i%4) == 0)
      printf("\n     ");
    printf(" (\"%s\" %s)", ehint_ext[i], ehint_cls[i]);
  }
  printf(")");

  printf("\n  (%s", VF_CAPE_IMPLICIT_FONT_CLASSES);
  for (i = 0; i < n_impl; i++){
    printf(" %s", impl[i]);
  }
  printf(")");  

  printf("\n  (%s %s)", VF_CAPE_UNCOMPRESSER, 
	 "(\".Z\" \"gzip -cd\") (\".gz\" \"gzip -cd\")");
  printf("\n  (%s", VF_CAPE_VARIABLE_VALUES);
  printf("\n      (TeX_USE_KPATHSEA     \"%s\")",
	 (use_kpathsea==1)?"Yes":"No");
  printf("\n      (TeX_DPI              \"%s\")", dpi);
  printf("\n      (TeX_KPATHSEA_MODE    \"%s\")", mode);
  printf("\n      (TeX_KPATHSEA_PROGRAM \"%s\")", kps_prog);
  printf(")");

  printf("\n  (%s $TeX_USE_KPATHSEA)",     VF_CAPE_KPATHSEA_SWITCH);
  printf("\n  (%s $TeX_KPATHSEA_MODE)",    VF_CAPE_KPATHSEA_MODE);
  printf("\n  (%s $TeX_DPI)",              VF_CAPE_KPATHSEA_DPI);
  printf("\n  (%s $TeX_KPATHSEA_PROGRAM)", VF_CAPE_KPATHSEA_PROG_NAME);

  printf("\n  (%s", VF_CAPE_CODE_CONVERSION_FILES);
  for (i = 0; i < n_ccv; i++){
    if ((i%3) == 0)
      printf("\n     ");
    printf(" \"%s\"", ccvs[i]);
  }
  printf(")");  

  printf(")");
  printf("\n");
  printf("\n");
}