10 |
|
#include <string.h> |
11 |
|
#include "bmpfile.h" |
12 |
|
|
13 |
+ |
#ifdef getc_unlocked /* avoid horrendous overhead of flockfile */ |
14 |
+ |
#define getc getc_unlocked |
15 |
+ |
#define putc putc_unlocked |
16 |
+ |
#endif |
17 |
+ |
|
18 |
|
/* get corresponding error message */ |
19 |
|
const char * |
20 |
|
BMPerrorMessage(int ec) |
605 |
|
{ |
606 |
|
if (pos == bw->fpos) |
607 |
|
return BIR_OK; |
608 |
< |
if (bw->seek == NULL) { |
609 |
< |
if (pos < bw->fpos) |
605 |
< |
return BIR_SEEKERR; |
606 |
< |
while (bw->fpos < pos) |
607 |
< |
wrbyte(0, bw); |
608 |
< |
return BIR_OK; |
609 |
< |
} |
608 |
> |
if (bw->seek == NULL) |
609 |
> |
return BIR_SEEKERR; |
610 |
|
if ((*bw->seek)(pos, bw->c_data) != 0) |
611 |
|
return BIR_SEEKERR; |
612 |
|
bw->fpos = pos; |
753 |
|
break; |
754 |
|
val = *sp; /* output run */ |
755 |
|
for (cnt = 1; cnt < 255; cnt++) |
756 |
< |
if (!--n | *++sp != val) |
756 |
> |
if ((!--n) | (*++sp != val)) |
757 |
|
break; |
758 |
|
wrbyte(cnt, bw); |
759 |
|
wrbyte(val, bw); |
761 |
|
bw->yscan++; /* write line break or EOD */ |
762 |
|
if (bw->yscan == bw->hdr->height) { |
763 |
|
wrbyte(0, bw); wrbyte(1, bw); /* end of bitmap marker */ |
764 |
< |
if (bw->seek == NULL || (*bw->seek)(2, bw->c_data) != 0) |
764 |
> |
if (wrseek(2, bw) != BIR_OK) |
765 |
|
return BIR_OK; /* no one may care */ |
766 |
< |
bw->fpos = 2; |
766 |
> |
wrint32(bw->flen, bw); /* correct file length */ |
767 |
> |
if (wrseek(34, bw) != BIR_OK) |
768 |
> |
return BIR_OK; |
769 |
|
wrint32(bw->flen-bw->fbmp, bw); /* correct bitmap length */ |
770 |
|
} else { |
771 |
|
wrbyte(0, bw); wrbyte(0, bw); /* end of line marker */ |