src/test-gen.c

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

FUNCTIONS

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

   1 /*
   2  * test-gen.c - a test input generator for vfserver
   3  * by Hirotsugu Kakugawa
   4  *
   5  *   6 Aug 1997  Upgraded for VFlib 3.3
   6  */
   7 /*
   8  * Copyright (C) 1996, 1997 Hirotsugu Kakugawa. 
   9  * All rights reserved.
  10  *
  11  * This program is free software; you can redistribute it and/or modify
  12  * it under the terms of the GNU General Public License as published by
  13  * the Free Software Foundation; either version 2, or (at your option)
  14  * any later version.
  15  * 
  16  * This program is distributed in the hope that it will be useful,
  17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19  * GNU General Public License for more details.
  20  * 
  21  * You should have received a copy of the GNU General Public License
  22  * along with this program; if not, write to the Free Software
  23  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  
  24  */
  25 
  26 
  27 #include <stdio.h>
  28 #include <stdlib.h>
  29 
  30 
  31 void  usage(void);
  32 
  33 int
  34 main(int argc, char **argv)
     /* [<][>][^][v][top][bottom][index][help] */
  35 {
  36   int   i, ch0, ch1, font_id;
  37   char  *font;
  38   double mag, point, dpi;
  39 
  40   argc--;
  41   argv++;
  42 
  43   font  = NULL;
  44   mag   = 1;
  45   point = -1;
  46   dpi   = -1;
  47   ch0   = 0x21;
  48   ch1   = 0x7e;
  49   font_id = 0;
  50 
  51   while ((argc > 0) && (*argv[0] == '-')){
  52     if (strcmp(argv[0], "-m") == 0){
  53       mag = atof(argv[1]); 
  54       argc--; argv++;
  55     } else if (strcmp(argv[0], "-p") == 0){
  56       point = atof(argv[1]); 
  57       argc--; argv++;
  58     } else if (strcmp(argv[0], "-d") == 0){
  59       dpi = atof(argv[1]); 
  60       argc--; argv++;
  61     } if ((strcmp(argv[0], "-h") == 0)|| (strcmp(argv[0], "-h") == 0)){
  62       usage();
  63     }
  64     argc--; argv++;
  65   }
  66 
  67   if (argc <= 0)
  68     usage();
  69 
  70   font = argv[0];
  71   if (argc == 2){
  72     sscanf(argv[1], "%i", &ch0);
  73     ch1 = ch0;
  74   } else if (argc >= 3) {
  75     sscanf(argv[1], "%i", &ch0);
  76     sscanf(argv[2], "%i", &ch1);
  77   }
  78 
  79   printf("COMMENT AN INPUT FOR VFSERVER GENERATED BY TEST-GEN.\n");
  80   printf("DEBUG BITMAP 1\n");
  81   printf("OPEN1 %s  %.2f  %.4f %.4f  %.2f %.2f\n", 
  82          font, point, mag, mag, dpi, dpi);
  83   for (i = ch0; i <= ch1; i++){
  84     printf("BITMAP1 %d 0x%x\n", font_id, i);
  85   }
  86   printf("%s\n", "QUIT");
  87 
  88   return 0;
  89 }
  90 
  91 
  92 void 
  93 usage(void)
     /* [<][>][^][v][top][bottom][index][help] */
  94 {
  95   printf("test-gen - Generate an input for vfserver.\n");
  96   printf("Usage: test-gen [Options] FONT [CODE_POINT_FROM [CODE_POINT_TO]]\n");
  97   printf("Options: -m MAG      magnification\n");
  98   printf("         -p POINT    point size\n");
  99   printf("         -d DPI      device resolution in dpi\n");
 100   printf("         -h          print this.\n");
 101   printf("Example: test-gen timR24.pcf 0x21 0x7e | vfserver \n");
 102   printf("Example: test-gen timR24.pcf 0x31 | vfserver \n");
 103   printf("Example: test-gen jiskan16.bdf 0x4121 0x417e | vfserver \n");
 104   exit(0);
 105 }
 106 
 107 /*EOF*/

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