struct dispatch d
[256], nd
;
if (open(argv
[0], 0) < 0)
perror(argv
[0]), exit(1);
if (read(0, &h
, sizeof(h
)) != sizeof(h
))
fprintf(stderr
, "header read error\n"), exit(1);
fprintf(stderr
, "bad magic number\n"), exit(1);
if (read(0, d
, sizeof(d
)) != sizeof(d
))
fprintf(stderr
, "dispatch read error\n"), exit(1);
size
= stb
.st_size
- tell(0);
fprintf(stderr
, "%d bytes of characters\n", size
);
write(1, &h
, sizeof (h
));
for (i
= 0; i
< 256; i
++)
if (d
[i
].addr
+ d
[i
].nbytes
> size
) {
fprintf(stderr
, "char %d out of range\n", i
);
cvt(&d
[i
], chp
+d
[i
].addr
, &nd
, scr
);
d
[i
].addr
= tell(1) - beg
;
write(1, scr
, d
[i
].nbytes
);
fprintf(stderr
, "done, new size %d\n", tell(1) - beg
);
write(1, &h
, sizeof (h
));
struct dispatch
*odp
, *dp
;
max
= (odp
->up
+odp
->down
+7)/8;
extra
= max
*8 - (odp
->down
+odp
->up
);
dp
->nbytes
= max
*(dp
->right
+dp
->left
);
for (byte
= 0; byte
< dp
->nbytes
; byte
++)
bpl
= (dp
->right
+dp
->left
+7)/8;
for (row
= 0; row
< odp
->up
+odp
->down
; row
++) {
for (byte
= 0; byte
< bpl
; byte
++) {
for (bit
= 0; bit
< 8; bit
++) {
ep
= cp
+ max
*(byte
*8+bit
);
bitoff
= max
*8 - row
- 1 - extra
;
*ep
|= 0x80 >> (bitoff
%8);