Change the translation of the "Help" menu item to "?", so that the menu can be displa...
[reactos.git] / rosapps / smartpdf / fitz / stream / filt_ahxe.c
1 #include "fitz-base.h"
2 #include "fitz-stream.h"
3
4 typedef struct fz_ahxe_s fz_ahxe;
5
6 struct fz_ahxe_s
7 {
8 fz_filter super;
9 int c;
10 };
11
12 static const char tohex[16] = "0123456789ABCDEF";
13
14 fz_error *
15 fz_newahxe(fz_filter **fp, fz_obj *params)
16 {
17 FZ_NEWFILTER(fz_ahxe, f, ahxe);
18 f->c = 0;
19 return nil;
20 }
21
22 void
23 fz_dropahxe(fz_filter *f)
24 {
25 }
26
27 fz_error *
28 fz_processahxe(fz_filter *filter, fz_buffer *in, fz_buffer *out)
29 {
30 fz_ahxe *f = (fz_ahxe*)filter;
31 int a, b, c;
32
33 while (1)
34 {
35 if (in->rp == in->wp)
36 goto needinput;
37
38 if (out->wp + 2 >= out->ep) /* can write 3 bytes from 1 */
39 return fz_ioneedout;
40
41 c = *in->rp++;
42 a = tohex[(c >> 4) & 0x0f];
43 b = tohex[c & 0x0f];
44
45 *out->wp++ = a;
46 *out->wp++ = b;
47
48 f->c += 2;
49 if (f->c == 60) {
50 *out->wp++ = '\n';
51 f->c = 0;
52 }
53 }
54
55 needinput:
56 if (in->eof) {
57 if (out->wp == out->ep)
58 return fz_ioneedout;
59 *out->wp++ = '>';
60 out->eof = 1;
61 return fz_iodone;
62 }
63 return fz_ioneedin;
64 }
65