2 #include "fitz-stream.h"
4 typedef struct fz_ahxd_s fz_ahxd
;
13 static inline int iswhite(int a
)
16 case '\n': case '\r': case '\t': case ' ':
17 case '\0': case '\f': case '\b': case 0177:
23 static inline int ishex(int a
)
25 return (a
>= 'A' && a
<= 'F') ||
26 (a
>= 'a' && a
<= 'f') ||
27 (a
>= '0' && a
<= '9');
30 static inline int fromhex(int a
)
32 if (a
>= 'A' && a
<= 'F')
34 if (a
>= 'a' && a
<= 'f')
36 if (a
>= '0' && a
<= '9')
42 fz_newahxd(fz_filter
**fp
, fz_obj
*params
)
44 FZ_NEWFILTER(fz_ahxd
, f
, ahxd
);
51 fz_dropahxd(fz_filter
*f
)
56 fz_processahxd(fz_filter
*filter
, fz_buffer
*in
, fz_buffer
*out
)
58 fz_ahxd
*f
= (fz_ahxd
*)filter
;
66 if (out
->wp
== out
->ep
)
78 *out
->wp
++ = (f
->a
<< 4) | b
;
85 *out
->wp
++ = (f
->a
<< 4);
90 else if (!iswhite(c
)) {
91 return fz_throw("ioerror: bad data in ahxd: '%c'", c
);
97 fz_pushbackahxd(fz_filter
*filter
, fz_buffer
*in
, fz_buffer
*out
, int n
)
101 assert(filter
->process
== fz_processahxd
);
102 assert(out
->wp
- n
>= out
->rp
);