fz_stream * fz_opennull(fz_stream *chain, int len) { struct nullfilter *state; state = fz_malloc(sizeof(struct nullfilter)); state->chain = chain; state->remain = len; return fz_newstream(state, readnull, closenull); }
fz_stream * fz_openahxd(fz_stream *chain) { fz_ahxd *state; state = fz_malloc(sizeof(fz_ahxd)); state->chain = chain; state->eod = 0; return fz_newstream(state, readahxd, closeahxd); }
fz_stream * fz_openfile(int fd) { fz_stream *stm; int *state; state = fz_malloc(sizeof(int)); *state = fd; stm = fz_newstream(state, readfile, closefile); stm->seek = seekfile; return stm; }
fz_stream * fz_openbuffer(fz_buffer *buf) { fz_stream *stm; stm = fz_newstream(fz_keepbuffer(buf), readbuffer, closebuffer); stm->seek = seekbuffer; stm->bp = buf->data; stm->rp = buf->data; stm->wp = buf->data + buf->len; stm->ep = buf->data + buf->len; stm->pos = buf->len; return stm; }
fz_stream * fz_opendctd(fz_stream *chain, fz_obj *params) { fz_dctd *state; fz_obj *obj; state = fz_malloc(sizeof(fz_dctd)); memset(state, 0, sizeof(fz_dctd)); state->chain = chain; state->colortransform = -1; /* unset */ state->init = 0; obj = fz_dictgets(params, "ColorTransform"); if (obj) state->colortransform = fz_toint(obj); return fz_newstream(state, readdctd, closedctd); }
fz_stream * fz_openlzwd(fz_stream *chain, fz_obj *params) { fz_lzwd *lzw; fz_obj *obj; int i; lzw = fz_malloc(sizeof(fz_lzwd)); lzw->chain = chain; lzw->eod = 0; lzw->earlychange = 1; obj = fz_dictgets(params, "EarlyChange"); if (obj) lzw->earlychange = !!fz_toint(obj); lzw->bidx = 32; lzw->word = 0; for (i = 0; i < 256; i++) { lzw->table[i].value = i; lzw->table[i].firstchar = i; lzw->table[i].length = 1; lzw->table[i].prev = -1; } for (i = 256; i < NUMCODES; i++) { lzw->table[i].value = 0; lzw->table[i].firstchar = 0; lzw->table[i].length = 0; lzw->table[i].prev = -1; } lzw->codebits = MINBITS; lzw->code = -1; lzw->nextcode = LZW_FIRST; lzw->oldcode = -1; lzw->rp = lzw->bp; lzw->wp = lzw->bp; return fz_newstream(lzw, readlzwd, closelzwd); }
fz_stream * fz_openflated(fz_stream *chain) { fz_flate *state; int code; state = fz_malloc(sizeof(fz_flate)); state->chain = chain; state->z.zalloc = zalloc; state->z.zfree = zfree; state->z.opaque = nil; state->z.next_in = nil; state->z.avail_in = 0; code = inflateInit(&state->z); if (code != Z_OK) fz_warn("zlib error: inflateInit: %s", state->z.msg); return fz_newstream(state, readflated, closeflated); }