src/vflmkvfl.c

/* [<][>]
[^][v][top][bottom][index][help] */

FUNCTIONS

This source file includes following functions.
  1. main
  2. gen_class_deafult

   1 /* 
   2  * vflmkvfl.c 
   3  * - a vflibcap entry generator for VFlib default entry
   4  *
   5  * - This program prints vflibcap entries to standard output.
   6  *
   7  * - Useful for generating vflibcap for TeX DVI drivers
   8  *
   9  *
  10  * by Hirotsugu Kakugawa
  11  *
  12  *  10 May 2001
  13  */
  14 /*
  15  * Copyright (C) 2001  Hirotsugu Kakugawa. 
  16  * All rights reserved.
  17  *
  18  * This program is free software; you can redistribute it and/or modify
  19  * it under the terms of the GNU General Public License as published by
  20  * the Free Software Foundation; either version 2, or (at your option)
  21  * any later version.
  22  * 
  23  * This program is distributed in the hope that it will be useful,
  24  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  26  * GNU General Public License for more details.
  27  * 
  28  * You should have received a copy of the GNU General Public License
  29  * along with this program; if not, write to the Free Software
  30  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  
  31  */
  32 
  33 
  34 #include "config.h"
  35 #include "with.h"
  36 #include <stdio.h>
  37 #include <stdlib.h>
  38 #include <ctype.h>
  39 #include <unistd.h>
  40 #include <sys/param.h>
  41 #include <sys/time.h>
  42 
  43 #include  "VFlib-3_6.h"
  44 #include  "VFsys.h"
  45 #include  "vflibcap.h"
  46 #include  "texfonts.h"
  47 #include  "fsearch.h"
  48 #include  "vflmklib.h"
  49 
  50 
  51 
  52 void  gen_class_deafult(void);
  53 
  54 
  55 char  *mode  = DEFAULT_KPS_MODE;
  56 char  *dpi   = NULL;
  57 int    dpi_i = DEFAULT_KPS_DPI;
  58 
  59 
  60 #define NEHINTS    64
  61 int   n_eh = 0; 
  62 char  *ehint_ext[NEHINTS];
  63 char  *ehint_cls[NEHINTS];
  64 
  65 #define NIMPLS  64
  66 int   n_impl = 0; 
  67 char  *impl[NIMPLS];
  68 
  69 #define NCCVS     256
  70 int   n_ccv = 0; 
  71 char  *ccvs[NCCVS];
  72 
  73 int use_kpathsea = 0;
  74 char *kps_prog = "xgdvi";
  75 
  76 
  77 char *cmdline = NULL; 
  78 
  79 
  80 
  81 int 
  82 main(int argc, char **argv)
     /* [<][>][^][v][top][bottom][index][help] */
  83 {
  84   int     i;
  85   int    xargc;
  86   char **xargv;
  87 
  88   dpi = malloc(256);
  89   sprintf(dpi, "%d", dpi_i);
  90 
  91   cmdline = copy_cmdline(argc, argv);
  92 
  93   n_eh = 0;
  94   for (i = 0; i < NEHINTS; i++){
  95     ehint_ext[i] = NULL;
  96     ehint_cls[i] = NULL;
  97   }
  98   n_impl = 0;
  99   for (i = 0; i < NIMPLS; i++){
 100     impl[i] = NULL;
 101   }
 102   n_ccv = 0;
 103   for (i = 0; i < NCCVS; i++){
 104     ccvs[i] = NULL;
 105   }
 106 
 107 
 108   xargc = argc; 
 109   xargv = argv;
 110 
 111   for (xargc--,xargv++; xargc > 0; xargc--,xargv++){
 112     if ((strcmp(*xargv, "--help") == 0)
 113         || (strcmp(*xargv, "-help") == 0)){
 114       printf("vflmkvfl: generates vflibcap entries for TFM fonts\n");
 115       printf("Usage: vflmkvfl [options]\n");
 116       printf("Options\n");
 117       printf("  -k       : Use kpathsea for TeX file search\n");
 118       printf("  -r DPI   : Default device resolution\n");
 119       printf("  -n MODE  : Device mode name for kpathsea\n");
 120       printf("  -p PROG  : Application program name for kpathsea\n");
 121       printf("  -e EXT CLASS : extension hint\n");
 122       printf("  -i CLASS     : implicit font class\n");
 123       printf("  -c CCV   : CCV file\n");
 124       printf("Example: vflmkvfl -k -r 300 -n cx -p xgdvi\n");
 125       exit(0);
 126 
 127     } else if (strcmp(*xargv, "-k") == 0){
 128       /* kpathsea */
 129       use_kpathsea = 1;
 130 
 131     } else if (strcmp(*xargv, "-c") == 0){
 132       /* ccv */
 133       if (n_ccv == NCCVS){
 134         fprintf(stderr, "Too many CCV files\n");
 135         exit(1);
 136       }
 137       xargv++; xargc--;
 138       check_argc(xargc);
 139       ccvs[n_ccv++] = x_strdup(*xargv);
 140 
 141     } else if (strcmp(*xargv, "-r") == 0){
 142       xargv++; xargc--;
 143       check_argc(xargc);
 144       dpi = strdup(*xargv);
 145 
 146     } else if (strcmp(*xargv, "-n") == 0){
 147       /* mode name */
 148       xargv++; xargc--;
 149       check_argc(xargc);
 150       mode = x_strdup(*xargv);
 151 
 152     } else if (strcmp(*xargv, "-p") == 0){
 153       /* prog name */
 154       xargv++; xargc--;
 155       check_argc(xargc);
 156       kps_prog = x_strdup(*xargv);
 157 
 158     } else if (strcmp(*xargv, "-e") == 0){
 159       /* extension hint */
 160       if (n_eh == NEHINTS){
 161         fprintf(stderr, "Too many extension hints\n");
 162         exit(1);
 163       }
 164       xargv++; xargc--;
 165       ehint_ext[n_eh] = x_strdup(*xargv); 
 166       xargv++; xargc--;
 167       ehint_cls[n_eh] = x_strdup(*xargv); 
 168       n_eh++;
 169 
 170     } else if (strcmp(*xargv, "-i") == 0){
 171       /* implicit fonts */
 172       if (n_impl == NIMPLS){
 173         fprintf(stderr, "Too many implicit fonts\n");
 174         exit(1);
 175       }
 176       xargv++; xargc--;
 177       impl[n_impl] = x_strdup(*xargv); 
 178       n_impl++;
 179 
 180     } else {
 181       if (*xargv[0] == '-'){
 182         fprintf(stderr, "vflmkvfl: unknown option %s\n", *xargv);
 183         exit(1);
 184       }
 185       break;
 186 
 187     }
 188   }
 189 
 190   banner("VFlib defaults", "vflmkvfl", cmdline);
 191 
 192   gen_class_deafult();    
 193 
 194   return 0;
 195 }
 196 
 197 
 198 void
 199 gen_class_deafult(void)
     /* [<][>][^][v][top][bottom][index][help] */
 200 {
 201   int   i;
 202 
 203   printf("(%s %s", 
 204          VF_CAPE_VFLIBCAP_CLASS_DEFAULT_DEFINITION, VF_CAPE_VFLIB_DEFAULTS);
 205 
 206   printf("\n  (%s", VF_CAPE_EXTENSION_HINT);
 207   for (i = 0; i < n_eh; i++){
 208     if ((i%4) == 0)
 209       printf("\n     ");
 210     printf(" (\"%s\" %s)", ehint_ext[i], ehint_cls[i]);
 211   }
 212   printf(")");
 213 
 214   printf("\n  (%s", VF_CAPE_IMPLICIT_FONT_CLASSES);
 215   for (i = 0; i < n_impl; i++){
 216     printf(" %s", impl[i]);
 217   }
 218   printf(")");  
 219 
 220   printf("\n  (%s %s)", VF_CAPE_UNCOMPRESSER, 
 221          "(\".Z\" \"gzip -cd\") (\".gz\" \"gzip -cd\")");
 222   printf("\n  (%s", VF_CAPE_VARIABLE_VALUES);
 223   printf("\n      (TeX_USE_KPATHSEA     \"%s\")",
 224          (use_kpathsea==1)?"Yes":"No");
 225   printf("\n      (TeX_DPI              \"%s\")", dpi);
 226   printf("\n      (TeX_KPATHSEA_MODE    \"%s\")", mode);
 227   printf("\n      (TeX_KPATHSEA_PROGRAM \"%s\")", kps_prog);
 228   printf(")");
 229 
 230   printf("\n  (%s $TeX_USE_KPATHSEA)",     VF_CAPE_KPATHSEA_SWITCH);
 231   printf("\n  (%s $TeX_KPATHSEA_MODE)",    VF_CAPE_KPATHSEA_MODE);
 232   printf("\n  (%s $TeX_DPI)",              VF_CAPE_KPATHSEA_DPI);
 233   printf("\n  (%s $TeX_KPATHSEA_PROGRAM)", VF_CAPE_KPATHSEA_PROG_NAME);
 234 
 235   printf("\n  (%s", VF_CAPE_CODE_CONVERSION_FILES);
 236   for (i = 0; i < n_ccv; i++){
 237     if ((i%3) == 0)
 238       printf("\n     ");
 239     printf(" \"%s\"", ccvs[i]);
 240   }
 241   printf(")");  
 242 
 243   printf(")");
 244   printf("\n");
 245   printf("\n");
 246 }

/* [<][>][^][v][top][bottom][index][help] */