#include <u.h>#include <libc.h>#include "pdf.h" /* 7.4.3 ASCII85Decode filter */ static intflreadall(void *aux, Buffer *bi, Buffer *bo){ uchar *in, c[4]; int i, j, insz; u32int x; USED(aux); in = bufdata(bi, &insz); for(i = 0; i < insz;){ if(isws(in[i])){ i++; continue; } if(in[i] == 'z'){ x = 0; i++; }else{ for(x = 0, j = 0; j < 5; j++, i++){ if(in[i] < '!' || in[i] > 'u'){ werrstr("invalid ascii85 char 0x%02x", in[i]); return -1; } x = x*85 + ((i < insz ? in[i] : 'u') - '!'); } } c[0] = x >> 24; c[1] = x >> 16; c[2] = x >> 8; c[3] = x; bufput(bo, c, 4); } bi->off = bi->sz; return 0;} Filter filterASCII85 = { .name = "ASCII85Decode", .readall = flreadall,};
#include <u.h>
#include <libc.h>
#include "pdf.h"
/* 7.4.3 ASCII85Decode filter */
static int
flreadall(void *aux, Buffer *bi, Buffer *bo)
{
uchar *in, c[4];
int i, j, insz;
u32int x;
USED(aux);
in = bufdata(bi, &insz);
for(i = 0; i < insz;){
if(isws(in[i])){
i++;
continue;
}
if(in[i] == 'z'){
x = 0;
i++;
}else{
for(x = 0, j = 0; j < 5; j++, i++){
if(in[i] < '!' || in[i] > 'u'){
werrstr("invalid ascii85 char 0x%02x", in[i]);
return -1;
}
x = x*85 + ((i < insz ? in[i] : 'u') - '!');
}
}
c[0] = x >> 24;
c[1] = x >> 16;
c[2] = x >> 8;
c[3] = x;
bufput(bo, c, 4);
}
bi->off = bi->sz;
return 0;
}
Filter filterASCII85 = {
.name = "ASCII85Decode",
.readall = flreadall,
};