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
|
#ifndef lint
static char rcsid[] = "$Header$";
#endif
/*
* fixfix - fix the number of FIXes for a particular character in
* a particular font.
*
* Compilation:
% cc -O -o fixfix fixfix.c
*/
#include <stdio.h>
main (argc, argv)
int argc;
register char **argv;
{
register int i, fd, newn, t;
static char buf[4];
if (argc != 4) {
fprintf (stderr, "usage: fixfix font index fixes\n");
exit (1);
}
if ((fd = open (argv[1], 2)) < 0) {
perror (argv[1]);
exit (1);
}
i = atoi (argv[2]);
if (i < 0 || i > 127) {
fprintf (stderr, "%d: invalid char index (<0 || >127)", i);
exit (1);
}
newn = atoi (argv[3]);
(void) lseek (fd, 0L, 2);
(void) lseek (fd, -2068L + 16L*i + 12L, 1);
if (read (fd, buf, 4) != 4) {
perror ("read");
exit (1);
}
t = get (buf);
printf ("fixfix: char %d: old size = %d\n", i, t);
put (newn, buf);
(void) lseek (fd, -4L, 1);
if (write (fd, buf, 4) != 4) {
perror ("write");
exit (1);
}
exit (0);
}
int
get (buf)
register unsigned char *buf;
{
return (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3];
}
put (n, buf)
register int n;
register unsigned char *buf;
{
buf[0] = n >> 24;
buf[1] = n >> 16;
buf[2] = n >> 8;
buf[3] = n;
}
|