4 #define between(x,min,max) (((min-1-x) & (x-max-1))>>8)
11 c = between(o, 0, 25) & ('A'+o);
12 c |= between(o, 26, 31) & ('2'+(o-26));
21 o = between(c, 'A', 'Z') & (1+(c-'A'));
22 o |= between(c, 'a', 'z') & (1+(c-'a'));
23 o |= between(c, '2', '7') & (1+26+(c-'2'));
28 dec32x(uchar *dest, int ndest, char *src, int nsrc, int (*chr)(int))
33 if(ndest+1 < (5*nsrc+7)/8)
43 *dest++ = (u[0]<<3) | (0x7 & (u[1]>>2));
44 *dest++ = ((0x3 & u[1])<<6) | (u[2]<<1) | (0x1 & (u[3]>>4));
45 *dest++ = ((0xf & u[3])<<4) | (0xf & (u[4]>>1));
46 *dest++ = ((0x1 & u[4])<<7) | (u[5]<<2) | (0x3 & (u[6]>>3));
47 *dest++ = ((0x7 & u[6])<<5) | u[7];
52 if(nsrc == 1 || nsrc == 3 || nsrc == 6)
54 for(i=0; i<nsrc; i++){
60 *dest++ = (u[0]<<3) | (0x7 & (u[1]>>2));
63 *dest++ = ((0x3 & u[1])<<6) | (u[2]<<1) | (0x1 & (u[3]>>4));
66 *dest++ = ((0xf & u[3])<<4) | (0xf & (u[4]>>1));
69 *dest++ = ((0x1 & u[4])<<7) | (u[5]<<2) | (0x3 & (u[6]>>3));
76 enc32x(char *dest, int ndest, uchar *src, int nsrc, int (*chr)(int))
81 if(ndest <= (8*nsrc+4)/5)
85 j = (0x1f & (src[0]>>3));
87 j = (0x1c & (src[0]<<2)) | (0x03 & (src[1]>>6));
89 j = (0x1f & (src[1]>>1));
91 j = (0x10 & (src[1]<<4)) | (0x0f & (src[2]>>4));
93 j = (0x1e & (src[2]<<1)) | (0x01 & (src[3]>>7));
95 j = (0x1f & (src[3]>>2));
97 j = (0x18 & (src[3]<<3)) | (0x07 & (src[4]>>5));
99 j = (0x1f & (src[4]));
105 j = (0x1f & (src[0]>>3));
107 j = (0x1c & (src[0]<<2));
110 j |= (0x03 & (src[1]>>6));
112 j = (0x1f & (src[1]>>1));
114 j = (0x10 & (src[1]<<4));
117 j |= (0x0f & (src[2]>>4));
119 j = (0x1e & (src[2]<<1));
122 j |= (0x01 & (src[3]>>7));
124 j = (0x1f & (src[3]>>2));
126 j = (0x18 & (src[3]<<3));
135 enc32(char *dest, int ndest, uchar *src, int nsrc)
137 return enc32x(dest, ndest, src, nsrc, enc32chr);
141 dec32(uchar *dest, int ndest, char *src, int nsrc)
143 return dec32x(dest, ndest, src, nsrc, dec32chr);