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
|
/*
* dbg_ml.c -
* by Hirotsugu Kakugawa
*
*
*/
/*
* 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 <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#ifdef __FreeBSD__
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
#define RUSAGE_SELF 0
#endif
#include "VFlib-3_6.h"
#define DEFAULT_FONT "timR18.pcf"
char *vflibcap;
char *fontname;
double mag;
void usage(void);
void test(int, int);
int
main(int argc, char **argv)
{
int code;
int w;
code = -1;
vflibcap = NULL;
fontname = DEFAULT_FONT;
mag = 1.0;
w = 1;
--argc; argv++;
while (argc > 0){
if ((argc >= 1)
&& ((strcmp(argv[0], "-h") == 0) || (strcmp(argv[0], "--help") == 0))){
usage();
exit(0);
} else if ((argc >= 2) && (strcmp(argv[0], "-v") == 0)){
--argc; argv++;
vflibcap = argv[0];
--argc; argv++;
} else if ((argc >= 2) && (strcmp(argv[0], "-f") == 0)){
--argc; argv++;
fontname = argv[0];
--argc; argv++;
} else if ((argc >= 2) && (strcmp(argv[0], "-m") == 0)){
--argc; argv++;
mag = atof(argv[0]);
--argc; argv++;
} else if ((argc >= 2) && (strcmp(argv[0], "-w") == 0)){
--argc; argv++;
w = atof(argv[0]);
--argc; argv++;
} else if (argv[0][0] == '='){
printf("Unknown option: %s\n", *argv);
usage();
exit(0);
} else {
sscanf(argv[0], "%i", &code);
break;
}
}
test(code, w);
return 0;
}
void usage(void)
{
printf("dbg_ml\n");
printf("Usage: dbg_ml [-v vflibcap] [-m mag] [-f fontname] charcode\n");
}
void
test(int code, int w)
{
int fid, i;
VF_BITMAP bm;
#ifdef __FreeBSD__
struct rusage ru;
#endif
if (VF_Init(vflibcap, NULL) < 0){
printf("VFlib initialization error\n");
exit(1);
}
printf("** font=%s, char=%d", fontname, code);
i = 1;
for (;;){
if ((i % 50) == 1){
#ifdef __FreeBSD__
printf("\n");
if (getrusage(RUSAGE_SELF, &ru) >= 0){
printf(" maxrss=%ldK", ru.ru_maxrss);
}
#endif
printf("\n");
printf("% 6d ", i);
}
printf("*"); fflush(stdout);
i++;
if ((fid = VF_OpenFont1(fontname, -1, -1, -1, mag, mag)) < 0){
printf("\nCan't open font\n");
return;
}
if (code > 0){
bm = VF_GetBitmap1(fid, code, 1, 1);
if (bm == NULL){
printf("\nCan't get bitmap\n");
return;
}
VF_FreeBitmap(bm);
}
VF_CloseFont(fid);
fid = -1;
if (w > 0)
usleep(1000*w);
}
}
/*EOF*/
|