manual.ps
资源名称:bzip.tar.gz [点击查看]
上传用户:zswatin
上传日期:2007-01-06
资源大小:440k
文件大小:457k
源码类别:
压缩解压
开发平台:
C/C++
- Fl(.)150 808 y(F)-8 b(or)36 b(general)e(bac)m(kground)h(information,)f
- (particularly)f(ab)s(out)h(memory)h(use)f(and)g(p)s(erformance)g(as-)
- 150 917 y(p)s(ects,)d(y)m(ou'd)f(b)s(e)g(w)m(ell)f(advised)g(to)j(read)
- e(Chapter)g(2)g(as)h(w)m(ell.)150 1218 y Fk(3.1)68 b(T)-11
- b(op-lev)l(el)46 b(structure)150 1411 y Fj(libbzip2)33
- b Fl(is)i(a)h( 15exible)e(library)f(for)j(compressing)f(and)g
- (decompressing)f(data)j(in)d(the)i Fj(bzip2)e Fl(data)150
- 1520 y(format.)39 b(Although)24 b(pac)m(k)-5 b(aged)26
- b(as)e(a)h(single)e(en)m(tit)m(y)-8 b(,)27 b(it)d(helps)f(to)i(regard)g
- (the)g(library)d(as)i(three)h(separate)150 1630 y(parts:)40
- b(the)31 b(lo)m(w)f(lev)m(el)g(in)m(terface,)h(and)f(the)h(high)e(lev)m
- (el)h(in)m(terface,)h(and)f(some)h(utilit)m(y)d(functions.)150
- 1787 y(The)38 b(structure)g(of)g Fj(libbzip2)p Fl('s)e(in)m(terfaces)j
- (is)e(similar)f(to)j(that)g(of)g(Jean-loup)e(Gailly's)g(and)h(Mark)150
- 1896 y(Adler's)29 b(excellen)m(t)i Fj(zlib)e Fl(library)-8
- b(.)150 2157 y Ff(3.1.1)63 b(Lo)m(w-lev)m(el)39 b(summary)150
- 2349 y Fl(This)21 b(in)m(terface)h(pro)m(vides)g(services)g(for)g
- (compressing)f(and)h(decompressing)f(data)i(in)e(memory)-8
- b(.)38 b(There's)150 2459 y(no)43 b(pro)m(vision)e(for)h(dealing)g
- (with)f( 14les,)k(streams)e(or)g(an)m(y)g(other)g(I/O)g(mec)m
- (hanisms,)i(just)e(straigh)m(t)150 2568 y(memory-to-memory)25
- b(w)m(ork.)38 b(In)23 b(fact,)k(this)22 b(part)i(of)f(the)h(library)d
- (can)j(b)s(e)f(compiled)f(without)h(inclusion)150 2678
- y(of)31 b Fj(stdio.h)p Fl(,)d(whic)m(h)h(ma)m(y)i(b)s(e)f(helpful)d
- (for)k(em)m(b)s(edded)e(applications.)150 2835 y(The)h(lo)m(w-lev)m(el)
- g(part)g(of)h(the)f(library)e(has)i(no)h(global)e(v)-5
- b(ariables)29 b(and)h(is)g(therefore)g(thread-safe.)150
- 2992 y(Six)f(routines)g(mak)m(e)j(up)d(the)i(lo)m(w)f(lev)m(el)g(in)m
- (terface:)41 b Fj(bzCompressInit)p Fl(,)27 b Fj(bzCompress)p
- Fl(,)h(and)150 3101 y Fj(bzCompressEnd)f Fl(for)j(compression,)g(and)f
- (a)i(corresp)s(onding)d(trio)i Fj(bzDecompressInit)p
- Fl(,)150 3211 y Fj(bzDecompress)41 b Fl(and)k Fj(bzDecompressEnd)40
- b Fl(for)45 b(decompression.)83 b(The)44 b Fj(*Init)f
- Fl(functions)g(allo)s(cate)150 3321 y(memory)31 b(for)g
- (compression/decompression)e(and)i(do)g(other)g(initialisations,)d
- (whilst)h(the)j Fj(*End)e Fl(func-)150 3430 y(tions)g(close)g(do)m(wn)g
- (op)s(erations)g(and)g(release)g(memory)-8 b(.)150 3587
- y(The)23 b(real)g(w)m(ork)h(is)f(done)g(b)m(y)g Fj(bzCompress)e
- Fl(and)i Fj(bzDecompress)p Fl(.)35 b(These)24 b(compress/decompress)f
- (data)150 3697 y(from)i(a)g(user-supplied)d(input)h(bu 13er)h(to)i(a)g
- (user-supplied)c(output)i(bu 13er.)38 b(These)25 b(bu 13ers)f(can)i
- (b)s(e)f(an)m(y)150 3806 y(size;)35 b(arbitrary)d(quan)m(tities)g(of)i
- (data)f(are)h(handled)d(b)m(y)i(making)g(rep)s(eated)g(calls)g(to)g
- (these)h(functions.)150 3916 y(This)f(is)h(a)i( 15exible)d(mec)m
- (hanism)i(allo)m(wing)f(a)h(consumer-pull)d(st)m(yle)k(of)f(activit)m
- (y)-8 b(,)37 b(or)f(pro)s(ducer-push,)150 4025 y(or)30
- b(a)h(mixture)e(of)i(b)s(oth.)150 4286 y Ff(3.1.2)63
- b(High-lev)m(el)41 b(summary)150 4478 y Fl(This)d(in)m(terface)j(pro)m
- (vides)e(some)h(handy)f(wrapp)s(ers)f(around)h(the)i(lo)m(w-lev)m(el)f
- (in)m(terface)g(to)h(facilitate)150 4588 y(reading)26
- b(and)g(writing)f Fj(bzip2)g Fl(format)i( 14les)f(()p
- Fj(.bz2)g Fl( 14les).)38 b(The)27 b(routines)e(pro)m(vide)h(ho)s(oks)
- h(to)g(facilitate)150 4698 y(reading)43 b( 14les)f(in)h(whic)m(h)f
- (the)i Fj(bzip2)f Fl(data)h(stream)g(is)f(em)m(b)s(edded)f(within)g
- (some)i(larger-scale)g( 14le)150 4807 y(structure,)30
- b(or)h(where)e(there)i(are)g(m)m(ultiple)d Fj(bzip2)h
- Fl(data)i(streams)f(concatenated)j(end-to-end.)150 4964
- y(F)-8 b(or)36 b(reading)e( 14les,)i Fj(bzReadOpen)p
- Fl(,)e Fj(bzRead)p Fl(,)h Fj(bzReadClose)d Fl(and)i Fj(bzReadGetUnused)
- d Fl(are)36 b(supplied.)150 5074 y(F)-8 b(or)31 b(writing)e( 14les,)g
- Fj(bzWriteOpen)p Fl(,)f Fj(bzWrite)g Fl(and)i Fj(bzWriteFinish)d
- Fl(are)j(a)m(v)-5 b(ailable.)150 5230 y(As)24 b(with)f(the)h(lo)m
- (w-lev)m(el)h(library)-8 b(,)23 b(no)h(global)g(v)-5
- b(ariables)23 b(are)h(used)g(so)g(the)h(library)c(is)j(p)s(er)f(se)h
- (thread-safe.)150 5340 y(Ho)m(w)m(ev)m(er,)32 b(if)c(I/O)h(errors)g(o)s
- (ccur)g(whilst)e(reading)i(or)g(writing)e(the)j(underlying)c
- (compressed)j( 14les,)g(y)m(ou)p eop
- %%Page: 12 13
- 12 12 bop 150 -116 a Fl(Chapter)30 b(3:)41 b(Programming)29
- b(with)g Fj(libbzip2)1881 b Fl(12)150 366 y(ma)m(y)32
- b(ha)m(v)m(e)g(to)g(consult)e Fj(errno)g Fl(to)h(determine)g(the)g
- (cause)g(of)h(the)f(error.)42 b(In)30 b(that)i(case,)h(y)m(ou'd)e(need)
- g(a)150 476 y(C)f(library)e(whic)m(h)h(correctly)i(supp)s(orts)d
- Fj(errno)h Fl(in)g(a)i(m)m(ultithreaded)e(en)m(vironmen)m(t.)150
- 633 y(T)-8 b(o)44 b(mak)m(e)h(the)f(library)d(a)j(little)f(simpler)e
- (and)j(more)g(p)s(ortable,)i Fj(bzReadOpen)41 b Fl(and)i
- Fj(bzWriteOpen)150 742 y Fl(require)20 b(y)m(ou)h(to)h(pass)e(them)h
- ( 14le)f(handles)f(()p Fj(FILE*)p Fl(s))h(whic)m(h)g(ha)m(v)m(e)i
- (previously)d(b)s(een)h(op)s(ened)g(for)h(reading)150
- 852 y(or)j(writing)d(resp)s(ectiv)m(ely)-8 b(.)39 b(That)23
- b(a)m(v)m(oids)h(p)s(ortabilit)m(y)e(problems)g(asso)s(ciated)i(with)f
- ( 14le)g(op)s(erations)g(and)150 962 y( 14le)29 b(attributes,)i
- (whilst)d(not)i(b)s(eing)f(m)m(uc)m(h)i(of)f(an)h(imp)s(osition)c(on)j
- (the)h(programmer.)150 1202 y Ff(3.1.3)63 b(Utilit)m(y)40
- b(functions)h(summary)150 1394 y Fl(F)-8 b(or)46 b(v)m(ery)g(simple)e
- (needs,)49 b Fj(bzBuffToBuffCompress)40 b Fl(and)45 b
- Fj(bzBuffToBuffDecompress)39 b Fl(are)46 b(pro-)150 1504
- y(vided.)37 b(These)23 b(compress)f(data)i(in)e(memory)h(from)f(one)i
- (bu 13er)e(to)h(another)g(bu 13er)f(in)g(a)i(single)d(function)150
- 1614 y(call.)60 b(Y)-8 b(ou)37 b(should)e(assess)j(whether)e(these)h
- (functions)f(ful 14ll)d(y)m(our)k(memory-to-memory)i(compres-)150
- 1723 y(sion/decompression)28 b(requiremen)m(ts)g(b)s(efore)g(in)m(v)m
- (esting)h(e 13ort)h(in)e(understanding)e(the)k(more)f(general)150
- 1833 y(but)h(more)g(complex)g(lo)m(w-lev)m(el)g(in)m(terface.)150
- 1990 y(Y)-8 b(oshiok)j(a)47 b(Tsuneo)e(()p Fj
- (QWF00133@niftyserve.or.jp)40 b Fl(/)46 b Fj(tsuneo-y@is.aist-nara.ac.)
- o(jp)p Fl())40 b(has)150 2099 y(con)m(tributed)30 b(some)h(functions)e
- (to)i(giv)m(e)g(b)s(etter)f Fj(zlib)g Fl(compatibilit)m(y)-8
- b(.)39 b(These)31 b(functions)e(are)h Fj(bzopen)p Fl(,)150
- 2209 y Fj(bzread)p Fl(,)43 b Fj(bzwrite)p Fl(,)f Fj(bzflush)p
- Fl(,)g Fj(bzclose)p Fl(,)g Fj(bzerror)e Fl(and)g Fj(bzlibVersion)p
- Fl(.)70 b(Y)-8 b(ou)42 b(ma)m(y)g( 14nd)d(these)150
- 2318 y(functions)31 b(more)i(con)m(v)m(enien)m(t)h(for)f(simple)d
- ( 14le)i(reading)g(and)g(writing,)g(than)h(those)g(in)e(the)i
- (high-lev)m(el)150 2428 y(in)m(terface.)61 b(These)37
- b(functions)e(are)j(not)f((y)m(et))i(o 16cially)c(part)i(of)g(the)g
- (library)-8 b(,)37 b(and)g(are)g(not)g(further)150 2538
- y(do)s(cumen)m(ted)32 b(here.)48 b(If)33 b(they)f(break,)i(y)m(ou)f
- (get)h(to)g(k)m(eep)f(all)f(the)h(pieces.)47 b(I)33 b(hop)s(e)f(to)h
- (do)s(cumen)m(t)g(them)150 2647 y(prop)s(erly)28 b(when)i(time)g(p)s
- (ermits.)150 2804 y(Y)-8 b(oshiok)j(a)27 b(also)g(con)m(tributed)f(mo)s
- (di 14cations)f(to)i(allo)m(w)f(the)h(library)e(to)i(b)s(e)f(built)f
- (as)i(a)g(Windo)m(ws)f(DLL.)150 3077 y Fk(3.2)68 b(Error)45
- b(handling)150 3270 y Fl(The)23 b(library)f(is)h(designed)g(to)i(reco)m
- (v)m(er)g(cleanly)f(in)e(all)h(situations,)h(including)d(the)j(w)m
- (orst-case)i(situation)150 3380 y(of)j(decompressing)e(random)g(data.)
- 41 b(I'm)28 b(not)h(100 45)g(sure)f(that)h(it)f(can)h(alw)m(a)m(ys)g
- (do)f(this,)g(so)g(y)m(ou)h(migh)m(t)150 3489 y(w)m(an)m(t)i(to)g(add)e
- (a)i(signal)d(handler)g(to)j(catc)m(h)h(segmen)m(tation)f(violations)e
- (during)f(decompression)h(if)g(y)m(ou)150 3599 y(are)g(feeling)f(esp)s
- (ecially)f(paranoid.)39 b(I)28 b(w)m(ould)g(b)s(e)g(in)m(terested)h(in)
- e(hearing)h(more)h(ab)s(out)f(the)h(robustness)150 3708
- y(of)i(the)f(library)e(to)j(corrupted)f(compressed)g(data.)150
- 3865 y(The)25 b( 14le)g Fj(bzlib.h)f Fl(con)m(tains)i(all)f
- (de 14nitions)e(needed)i(to)i(use)e(the)h(library)-8
- b(.)37 b(In)26 b(particular,)f(y)m(ou)h(should)150 3975
- y(de 14nitely)i(not)j(include)d Fj(bzlib_private.h)p
- Fl(.)150 4132 y(In)39 b Fj(bzlib.h)p Fl(,)h(the)g(v)-5
- b(arious)39 b(return)f(v)-5 b(alues)39 b(are)h(de 14ned.)68
- b(The)39 b(follo)m(wing)f(list)h(is)f(not)i(in)m(tended)f(as)150
- 4241 y(an)c(exhaustiv)m(e)h(description)d(of)i(the)h(circumstances)f
- (in)f(whic)m(h)g(a)i(giv)m(en)f(v)-5 b(alue)35 b(ma)m(y)h(b)s(e)e
- (returned)h({)150 4351 y(those)h(descriptions)d(are)j(giv)m(en)f
- (later.)56 b(Rather,)37 b(it)d(is)h(in)m(tended)f(to)i(con)m(v)m(ey)h
- (the)e(rough)g(meaning)g(of)150 4460 y(eac)m(h)j(return)d(v)-5
- b(alue.)59 b(The)36 b( 14rst)g( 14v)m(e)g(actions)h(are)g(normal)f
- (and)f(not)i(in)m(tended)f(to)h(denote)g(an)f(error)150
- 4570 y(situation.)150 4749 y Fj(BZ_OK)240 b Fl(The)30
- b(requested)g(action)h(w)m(as)g(completed)f(successfully)-8
- b(.)150 4902 y Fj(BZ_RUN_OK)150 5011 y(BZ_FLUSH_OK)150
- 5121 y(BZ_FINISH_OK)630 5230 y Fl(In)21 b Fj(bzCompress)p
- Fl(,)f(the)h(requested)h( 15ush/ 14nish/nothing-sp)s(ecial)16
- b(action)21 b(w)m(as)h(completed)630 5340 y(successfully)-8
- b(.)p eop
- %%Page: 13 14
- 13 13 bop 150 -116 a Fl(Chapter)30 b(3:)41 b(Programming)29
- b(with)g Fj(libbzip2)1881 b Fl(13)150 366 y Fj(BZ_STREAM_END)630
- 476 y Fl(Compression)38 b(of)j(data)f(w)m(as)h(completed,)h(or)f(the)f
- (logical)f(stream)i(end)e(w)m(as)i(detected)630 586 y(during)28
- b(decompression.)150 760 y(The)i(follo)m(wing)f(return)g(v)-5
- b(alues)30 b(indicate)f(an)h(error)g(of)h(some)g(kind.)150
- 934 y Fj(BZ_SEQUENCE_ERROR)630 1043 y Fl(When)43 b(using)f(the)i
- (library)-8 b(,)45 b(it)e(is)f(imp)s(ortan)m(t)h(to)h(call)e(the)i
- (functions)e(in)g(the)i(correct)630 1153 y(sequence)28
- b(and)f(with)f(data)j(structures)e((bu 13ers)f(etc))j(in)e(the)g
- (correct)i(states.)41 b Fj(libbzip2)630 1263 y Fl(c)m(hec)m(ks)26
- b(as)e(m)m(uc)m(h)h(as)f(it)g(can)g(to)h(ensure)f(this)f(is)g(happ)s
- (ening,)h(and)f(returns)g Fj(BZ_SEQUENCE_)630 1372 y(ERROR)36
- b Fl(if)h(not.)62 b(Co)s(de)37 b(whic)m(h)g(complies)f(precisely)g
- (with)h(the)g(function)g(seman)m(tics,)j(as)630 1482
- y(detailed)d(b)s(elo)m(w,)i(should)d(nev)m(er)i(receiv)m(e)h(this)d(v)
- -5 b(alue;)41 b(suc)m(h)d(an)g(ev)m(en)m(t)h(denotes)f(buggy)630
- 1591 y(co)s(de)31 b(whic)m(h)e(y)m(ou)h(should)f(in)m(v)m(estigate.)150
- 1736 y Fj(BZ_PARAM_ERROR)630 1845 y Fl(Returned)43 b(when)f(a)i
- (parameter)g(to)h(a)f(function)e(call)h(is)f(out)i(of)g(range)g(or)g
- (otherwise)630 1955 y(manifestly)34 b(incorrect.)57 b(As)36
- b(with)e Fj(BZ_SEQUENCE_ERROR)p Fl(,)f(this)i(denotes)h(a)g(bug)f(in)g
- (the)630 2064 y(clien)m(t)23 b(co)s(de.)39 b(The)22 b(distinction)f(b)s
- (et)m(w)m(een)j Fj(BZ_PARAM_ERROR)c Fl(and)j Fj(BZ_SEQUENCE_ERROR)630
- 2174 y Fl(is)29 b(a)i(bit)f(hazy)-8 b(,)31 b(but)f(still)e(w)m(orth)i
- (making.)150 2318 y Fj(BZ_MEM_ERROR)630 2428 y Fl(Returned)g(when)f(a)i
- (request)f(to)i(allo)s(cate)f(memory)f(failed.)40 b(Note)31
- b(that)g(the)g(quan)m(tit)m(y)g(of)630 2537 y(memory)21
- b(needed)g(to)i(decompress)e(a)g(stream)h(cannot)g(b)s(e)f(determined)f
- (un)m(til)g(the)h(stream's)630 2647 y(header)j(has)g(b)s(een)f(read.)39
- b(So)24 b Fj(bzDecompress)d Fl(and)i Fj(bzRead)g Fl(ma)m(y)h(return)f
- Fj(BZ_MEM_ERROR)630 2756 y Fl(ev)m(en)43 b(though)f(some)g(of)h(the)f
- (compressed)g(data)h(has)f(b)s(een)f(read.)76 b(The)42
- b(same)g(is)g(not)630 2866 y(true)32 b(for)g(compression;)g(once)h
- Fj(bzCompressInit)28 b Fl(or)k Fj(bzWriteOpen)d Fl(ha)m(v)m(e)k
- (successfully)630 2976 y(completed,)e Fj(BZ_MEM_ERROR)c
- Fl(cannot)k(o)s(ccur.)150 3120 y Fj(BZ_DATA_ERROR)630
- 3229 y Fl(Returned)h(when)g(a)h(data)g(in)m(tegrit)m(y)g(error)g(is)e
- (detected)k(during)30 b(decompression.)47 b(Most)630
- 3339 y(imp)s(ortan)m(tly)-8 b(,)31 b(this)f(means)i(when)f(stored)g
- (and)g(computed)h(CR)m(Cs)f(for)g(the)h(data)g(do)g(not)630
- 3448 y(matc)m(h.)41 b(This)28 b(v)-5 b(alue)29 b(is)f(also)i(returned)e
- (up)s(on)g(detection)i(of)g(an)m(y)g(other)f(anomaly)h(in)e(the)630
- 3558 y(compressed)i(data.)150 3702 y Fj(BZ_DATA_ERROR_MAGIC)630
- 3812 y Fl(As)k(a)g(sp)s(ecial)f(case)i(of)f Fj(BZ_DATA_ERROR)p
- Fl(,)d(it)i(is)g(sometimes)h(useful)e(to)j(kno)m(w)f(when)f(the)630
- 3921 y(compressed)d(stream)h(do)s(es)f(not)g(start)h(with)e(the)i
- (correct)h(magic)e(b)m(ytes)h(()p Fj('B')f('Z')f('h')p
- Fl().)150 4065 y Fj(BZ_IO_ERROR)630 4175 y Fl(Returned)42
- b(b)m(y)i Fj(bzRead)d Fl(and)i Fj(bzRead)e Fl(when)i(there)g(is)f(an)h
- (error)g(reading)g(or)g(writing)630 4285 y(in)34 b(the)i(compressed)f
- ( 14le,)h(and)f(b)m(y)g Fj(bzReadOpen)e Fl(and)i Fj(bzWriteOpen)d
- Fl(for)k(attempts)g(to)630 4394 y(use)43 b(a)g( 14le)f(for)g(whic)m(h)
- g(the)h(error)f(indicator)g((viz,)k Fj(ferror(f))p
- Fl())41 b(is)g(set.)79 b(On)42 b(receipt)630 4504 y(of)j
- Fj(BZ_IO_ERROR)p Fl(,)h(the)f(caller)f(should)f(consult)h
- Fj(errno)g Fl(and/or)h Fj(perror)e Fl(to)i(acquire)630
- 4613 y(op)s(erating-system)30 b(sp)s(eci 14c)f(information)g(ab)s(out)
- h(the)h(problem.)150 4758 y Fj(BZ_UNEXPECTED_EOF)630
- 4867 y Fl(Returned)d(b)m(y)g Fj(bzRead)f Fl(when)h(the)g(compressed)h
- ( 14le)e( 14nishes)g(b)s(efore)h(the)h(logical)f(end)g(of)630
- 4977 y(stream)j(is)e(detected.)150 5121 y Fj(BZ_OUTBUFF_FULL)630
- 5230 y Fl(Returned)39 b(b)m(y)h Fj(bzBuffToBuffCompress)35
- b Fl(and)k Fj(bzBuffToBuffDecompress)34 b Fl(to)41 b(indi-)630
- 5340 y(cate)32 b(that)f(the)f(output)g(data)i(will)27
- b(not)k( 14t)f(in)m(to)g(the)h(output)f(bu 13er)f(pro)m(vided.)p
- eop
- %%Page: 14 15
- 14 14 bop 150 -116 a Fl(Chapter)30 b(3:)41 b(Programming)29
- b(with)g Fj(libbzip2)1881 b Fl(14)150 366 y Fk(3.3)68
- b(Lo)l(w-lev)l(el)47 b(in)l(terface)150 661 y Ff(3.3.1)63
- b Fe(bzCompressInit)390 848 y Fj(typedef)533 952 y(struct)46
- b({)676 1056 y(char)h(*next_in;)676 1159 y(unsigned)f(int)h(avail_in;)
- 676 1263 y(unsigned)f(int)h(total_in;)676 1471 y(char)g(*next_out;)676
- 1575 y(unsigned)f(int)h(avail_out;)676 1678 y(unsigned)f(int)h
- (total_out;)676 1886 y(void)g(*state;)676 2093 y(void)g
- (*(*bzalloc)(void)c(*,int,int);)676 2197 y(void)k
- ((*bzfree)(void)d(*,void)i(*);)676 2301 y(void)h(*opaque;)533
- 2405 y(})533 2509 y(bz_stream;)390 2716 y(int)g(bzCompressInit)d(()j
- (bz_stream)f(*strm,)1392 2820 y(int)h(blockSize100k,)1392
- 2924 y(int)g(verbosity,)1392 3027 y(int)g(workFactor)e();)150
- 3288 y Fl(Prepares)32 b(for)h(compression.)47 b(The)32
- b Fj(bz_stream)e Fl(structure)j(holds)e(all)h(data)h(p)s(ertaining)e
- (to)i(the)g(com-)150 3398 y(pression)i(activit)m(y)-8
- b(.)62 b(A)37 b Fj(bz_stream)e Fl(structure)h(should)f(b)s(e)i(allo)s
- (cated)g(and)f(initialised)e(prior)h(to)j(the)150 3507
- y(call.)67 b(The)39 b( 14elds)e(of)j Fj(bz_stream)d
- Fl(comprise)h(the)i(en)m(tiret)m(y)g(of)f(the)h(user-visible)c(data.)68
- b Fj(state)38 b Fl(is)h(a)150 3617 y(p)s(oin)m(ter)29
- b(to)i(the)g(priv)-5 b(ate)30 b(data)h(structures)f(required)e(for)i
- (compression.)150 3774 y(Custom)37 b(memory)g(allo)s(cators)g(are)h
- (supp)s(orted,)f(via)g( 14elds)f Fj(bzalloc)p Fl(,)h
- Fj(bzfree)p Fl(,)g(and)g Fj(opaque)p Fl(.)59 b(The)150
- 3883 y(v)-5 b(alue)32 b Fj(opaque)e Fl(is)i(passed)f(to)i(as)g(the)f
- ( 14rst)g(argumen)m(t)h(to)g(all)e(calls)g(to)i Fj(bzalloc)d
- Fl(and)i Fj(bzfree)p Fl(,)f(but)h(is)150 3993 y(otherwise)d(ignored)g
- (b)m(y)h(the)g(library)-8 b(.)38 b(The)29 b(call)h Fj(bzalloc)e(()i
- (opaque,)e(n,)i(m)g())g Fl(is)e(exp)s(ected)j(to)f(return)150
- 4102 y(a)g(p)s(oin)m(ter)e Fj(p)h Fl(to)h Fj(n)g(*)g(m)f
- Fl(b)m(ytes)h(of)g(memory)-8 b(,)30 b(and)e Fj(bzfree)h(()h(opaque,)f
- (p)h())f Fl(should)e(free)i(that)h(memory)-8 b(.)150
- 4259 y(If)33 b(y)m(ou)g(don't)h(w)m(an)m(t)g(to)g(use)f(a)g(custom)h
- (memory)f(allo)s(cator,)h(set)g Fj(bzalloc)p Fl(,)e Fj(bzfree)g
- Fl(and)h Fj(opaque)e Fl(to)150 4369 y Fj(NULL)p Fl(,)e(and)h(the)h
- (library)d(will)f(then)k(use)f(the)g(standard)g Fj(malloc)p
- Fl(/)p Fj(free)e Fl(routines.)150 4526 y(Before)h(calling)e
- Fj(bzCompressInit)p Fl(,)e( 14elds)i Fj(bzalloc)p Fl(,)g
- Fj(bzfree)g Fl(and)h Fj(opaque)f Fl(should)f(b)s(e)i( 14lled)e(appro-)
- 150 4635 y(priately)-8 b(,)40 b(as)e(just)g(describ)s(ed.)62
- b(Up)s(on)37 b(return,)j(the)e(in)m(ternal)f(state)j(will)35
- b(ha)m(v)m(e)40 b(b)s(een)d(allo)s(cated)i(and)150 4745
- y(initialised,)31 b(and)h Fj(total_in)f Fl(and)i Fj(total_out)e
- Fl(will)g(ha)m(v)m(e)j(b)s(een)f(set)h(to)g(zero.)50
- b(These)34 b(last)f(t)m(w)m(o)h( 14elds)150 4854 y(are)29
- b(used)e(b)m(y)h(the)g(library)e(to)j(inform)e(the)h(caller)g(of)g(the)
- g(total)h(amoun)m(t)g(of)f(data)h(passed)f(in)m(to)g(and)g(out)150
- 4964 y(of)j(the)f(library)-8 b(,)29 b(resp)s(ectiv)m(ely)-8
- b(.)40 b(Y)-8 b(ou)31 b(should)d(not)j(try)f(to)h(c)m(hange)h(them.)150
- 5121 y(P)m(arameter)e Fj(blockSize100k)25 b Fl(sp)s(eci 14es)i(the)h
- (blo)s(c)m(k)g(size)h(to)g(b)s(e)f(used)f(for)h(compression.)40
- b(It)28 b(should)f(b)s(e)150 5230 y(a)k(v)-5 b(alue)30
- b(b)s(et)m(w)m(een)i(1)f(and)f(9)h(inclusiv)m(e,)e(and)h(the)h(actual)g
- (blo)s(c)m(k)f(size)g(used)g(is)g(100000)j(x)e(this)e( 14gure.)42
- b(9)150 5340 y(giv)m(es)31 b(the)f(b)s(est)g(compression)g(but)f(tak)m
- (es)j(most)f(memory)-8 b(.)p eop
- %%Page: 15 16
- 15 15 bop 150 -116 a Fl(Chapter)30 b(3:)41 b(Programming)29
- b(with)g Fj(libbzip2)1881 b Fl(15)150 366 y(P)m(arameter)29
- b Fj(verbosity)c Fl(should)h(b)s(e)h(set)i(to)f(a)h(n)m(um)m(b)s(er)d
- (b)s(et)m(w)m(een)j(0)f(and)f(4)h(inclusiv)m(e.)38 b(0)28
- b(is)f(silen)m(t,)h(and)150 476 y(greater)j(n)m(um)m(b)s(ers)c(giv)m(e)
- j(increasingly)d(v)m(erb)s(ose)j(monitoring/debugging)d(output.)40
- b(If)29 b(the)g(library)e(has)150 586 y(b)s(een)j(compiled)e(with)i
- Fj(-DBZ_NO_STDIO)p Fl(,)d(no)j(suc)m(h)g(output)g(will)e(app)s(ear)h
- (for)h(an)m(y)h(v)m(erb)s(osit)m(y)f(setting.)150 742
- y(P)m(arameter)35 b Fj(workFactor)d Fl(con)m(trols)i(ho)m(w)g(the)g
- (compression)f(phase)h(b)s(eha)m(v)m(es)g(when)f(presen)m(ted)h(with)
- 150 852 y(w)m(orst)40 b(case,)j(highly)37 b(rep)s(etitiv)m(e,)k(input)d
- (data.)68 b(If)39 b(compression)g(runs)e(in)m(to)j(di 16culties)d
- (caused)i(b)m(y)150 962 y(rep)s(etitiv)m(e)22 b(data,)j(some)e
- (pseudo-random)f(v)-5 b(ariations)22 b(are)h(inserted)e(in)m(to)i(the)g
- (blo)s(c)m(k,)h(and)e(compression)150 1071 y(is)29 b(restarted.)42
- b(Lo)m(w)m(er)31 b(v)-5 b(alues)30 b(of)h Fj(workFactor)c
- Fl(reduce)j(the)h(tolerance)g(of)g(compression)e(to)i(rep)s(etitiv)m(e)
- 150 1181 y(data.)50 b(Y)-8 b(ou)33 b(should)f(set)h(this)f(parameter)i
- (carefully;)f(to)s(o)h(lo)m(w,)g(and)f(compression)f(ratio)h
- (su 13ers,)g(to)s(o)150 1290 y(high,)25 b(and)g(y)m(our)h(a)m(v)m
- (erage-to-w)m(orst)k(case)d(compression)d(times)i(can)f(b)s(ecome)h(v)m
- (ery)g(large.)40 b(The)25 b(default)150 1400 y(v)-5 b(alue)30
- b(of)g(30)i(giv)m(es)e(reasonable)h(b)s(eha)m(viour)d(o)m(v)m(er)k(a)f
- (wide)e(range)i(of)f(circumstances.)150 1557 y(Allo)m(w)m(able)h(v)-5
- b(alues)31 b(range)i(from)e(0)i(to)f(250)h(inclusiv)m(e.)44
- b(0)32 b(is)f(a)h(sp)s(ecial)f(case,)i(equiv)-5 b(alen)m(t)32
- b(to)g(using)f(the)150 1666 y(default)f(v)-5 b(alue)29
- b(of)i(30.)150 1823 y(Note)j(that)g(the)f(randomisation)e(pro)s(cess)i
- (is)f(en)m(tirely)g(transparen)m(t.)49 b(If)32 b(the)i(library)c
- (decides)i(to)i(ran-)150 1933 y(domise)43 b(and)g(restart)h
- (compression)e(on)i(a)g(blo)s(c)m(k,)i(it)d(do)s(es)h(so)f(without)g
- (commen)m(t.)81 b(Randomised)150 2042 y(blo)s(c)m(ks)38
- b(are)i(automatically)e(de-randomised)g(during)f(decompression,)j(so)f
- (data)h(in)m(tegrit)m(y)f(is)f(nev)m(er)150 2152 y(compromised.)150
- 2309 y(P)m(ossible)29 b(return)h(v)-5 b(alues:)572 2460
- y Fj(BZ_PARAM_ERROR)663 2564 y Fl(if)29 b Fj(strm)g Fl(is)h
- Fj(NULL)663 2667 y Fl(or)g Fj(blockSize)e(<)i Fl(1)h(or)f
- Fj(blockSize)e(>)i Fl(9)663 2771 y(or)g Fj(verbosity)e(<)i
- Fl(0)h(or)f Fj(verbosity)e(>)i Fl(4)663 2875 y(or)g Fj(workFactor)e(<)i
- Fl(0)g(or)h Fj(workFactor)c(>)j Fl(250)572 2979 y Fj(BZ_MEM_ERROR)663
- 3083 y Fl(if)f(not)i(enough)f(memory)g(is)f(a)m(v)-5
- b(ailable)572 3186 y Fj(BZ_OK)663 3290 y Fl(otherwise)150
- 3447 y(Allo)m(w)m(able)30 b(next)g(actions:)572 3598
- y Fj(bzCompress)663 3702 y Fl(if)f Fj(BZ_OK)g Fl(is)g(returned)572
- 3806 y(no)h(sp)s(eci 14c)f(action)i(needed)f(in)f(case)i(of)g(error)
- 150 4135 y Ff(3.3.2)63 b Fe(bzCompress)533 4322 y Fj(int)47
- b(bzCompress)e(()j(bz_stream)d(*strm,)h(int)h(action)f();)150
- 4478 y Fl(Pro)m(vides)28 b(more)g(input)f(and/or)h(output)g(bu 13er)g
- (space)h(for)f(the)h(library)-8 b(.)38 b(The)28 b(caller)g(main)m
- (tains)f(input)150 4588 y(and)j(output)g(bu 13ers,)f(and)h(calls)g
- Fj(bzCompress)d Fl(to)k(transfer)f(data)h(b)s(et)m(w)m(een)g(them.)150
- 4745 y(Before)k(eac)m(h)g(call)d(to)j Fj(bzCompress)p
- Fl(,)d Fj(next_in)g Fl(should)f(p)s(oin)m(t)i(at)h(the)g(data)h(to)f(b)
- s(e)f(compressed,)i(and)150 4854 y Fj(avail_in)42 b Fl(should)g
- (indicate)g(ho)m(w)i(man)m(y)g(b)m(ytes)h(the)f(library)d(ma)m(y)k
- (read.)81 b Fj(bzCompress)41 b Fl(up)s(dates)150 4964
- y Fj(next_in)p Fl(,)29 b Fj(avail_in)f Fl(and)i Fj(total_in)e
- Fl(to)j(re 15ect)g(the)f(n)m(um)m(b)s(er)f(of)i(b)m(ytes)g(it)f(has)g
- (read.)150 5121 y(Similarly)-8 b(,)27 b Fj(next_out)h
- Fl(should)g(p)s(oin)m(t)h(to)i(a)f(bu 13er)f(in)g(whic)m(h)g(the)h
- (compressed)g(data)h(is)e(to)i(b)s(e)e(placed,)150 5230
- y(with)24 b Fj(avail_out)f Fl(indicating)g(ho)m(w)i(m)m(uc)m(h)h
- (output)f(space)h(is)e(a)m(v)-5 b(ailable.)38 b Fj(bzCompress)23
- b Fl(up)s(dates)h Fj(next_)150 5340 y(out)p Fl(,)30 b
- Fj(avail_out)e Fl(and)h Fj(total_out)f Fl(to)j(re 15ect)g(the)g(n)m
- (um)m(b)s(er)e(of)h(b)m(ytes)h(output.)p eop
- %%Page: 16 17
- 16 16 bop 150 -116 a Fl(Chapter)30 b(3:)41 b(Programming)29
- b(with)g Fj(libbzip2)1881 b Fl(16)150 366 y(Y)-8 b(ou)23
- b(ma)m(y)f(pro)m(vide)f(and)h(remo)m(v)m(e)h(as)g(little)e(or)h(as)g(m)
- m(uc)m(h)g(data)h(as)f(y)m(ou)g(lik)m(e)g(on)g(eac)m(h)h(call)e(of)h
- Fj(bzCompress)p Fl(.)150 476 y(In)33 b(the)g(limit,)f(it)h(is)f
- (acceptable)i(to)g(supply)d(and)i(remo)m(v)m(e)h(data)g(one)g(b)m(yte)g
- (at)g(a)f(time,)h(although)f(this)150 586 y(w)m(ould)k(b)s(e)h
- (terribly)e(ine 16cien)m(t.)64 b(Y)-8 b(ou)39 b(should)d(alw)m(a)m(ys)
- j(ensure)f(that)h(at)g(least)f(one)h(b)m(yte)g(of)f(output)150
- 695 y(space)31 b(is)e(a)m(v)-5 b(ailable)30 b(at)h(eac)m(h)h(call.)150
- 852 y(A)d(second)g(purp)s(ose)e(of)i Fj(bzCompress)d
- Fl(is)i(to)h(request)g(a)g(c)m(hange)h(of)f(mo)s(de)g(of)g(the)g
- (compressed)f(stream.)150 1009 y(Conceptually)-8 b(,)56
- b(a)c(compressed)f(stream)h(can)g(b)s(e)f(in)f(one)i(of)g(four)f
- (states:)84 b(IDLE,)51 b(R)m(UNNING,)150 1119 y(FLUSHING)39
- b(and)f(FINISHING.)i(Before)g(initialisation)35 b(()p
- Fj(bzCompressInit)p Fl())h(and)i(after)h(termina-)150
- 1228 y(tion)30 b(()p Fj(bzCompressEnd)p Fl(),)e(a)i(stream)h(is)e
- (regarded)i(as)f(IDLE.)150 1385 y(Up)s(on)i(initialisation)d(()p
- Fj(bzCompressInit)p Fl(),)h(the)i(stream)h(is)f(placed)g(in)f(the)i(R)
- m(UNNING)h(state.)48 b(Sub-)150 1495 y(sequen)m(t)31
- b(calls)f(to)i Fj(bzCompress)c Fl(should)h(pass)h Fj(BZ_RUN)f
- Fl(as)i(the)g(requested)g(action;)g(other)h(actions)f(are)150
- 1604 y(illegal)e(and)g(will)f(result)h(in)g Fj(BZ_SEQUENCE_ERROR)p
- Fl(.)150 1761 y(A)m(t)38 b(some)f(p)s(oin)m(t,)h(the)f(calling)e
- (program)i(will)d(ha)m(v)m(e)k(pro)m(vided)e(all)f(the)i(input)e(data)j
- (it)e(w)m(an)m(ts)i(to.)61 b(It)150 1871 y(will)28 b(then)h(w)m(an)m(t)
- i(to)g( 14nish)d(up)h({)i(in)d(e 13ect,)k(asking)e(the)g(library)e
- (to)j(pro)s(cess)f(an)m(y)g(data)h(it)f(migh)m(t)g(ha)m(v)m(e)150
- 1980 y(bu 13ered)38 b(in)m(ternally)-8 b(.)67 b(In)39
- b(this)g(state,)k Fj(bzCompress)37 b Fl(will)g(no)i(longer)h(attempt)g
- (to)h(read)e(data)h(from)150 2090 y Fj(next_in)p Fl(,)33
- b(but)g(it)h(will)d(w)m(an)m(t)k(to)g(write)e(data)h(to)h
- Fj(next_out)p Fl(.)49 b(Because)36 b(the)e(output)f(bu 13er)g
- (supplied)150 2199 y(b)m(y)e(the)h(user)e(can)i(b)s(e)f(arbitrarily)d
- (small,)j(the)g( 14nishing-up)d(op)s(eration)i(cannot)i(necessarily)e
- (b)s(e)h(done)150 2309 y(with)e(a)i(single)e(call)h(of)g
- Fj(bzCompress)p Fl(.)150 2466 y(Instead,)j(the)g(calling)e(program)i
- (passes)f Fj(BZ_FINISH)e Fl(as)j(an)g(action)g(to)g Fj(bzCompress)p
- Fl(.)45 b(This)31 b(c)m(hanges)150 2575 y(the)36 b(stream's)f(state)i
- (to)f(FINISHING.)g(An)m(y)f(remaining)f(input)f((ie,)k
- Fj(next_in[0)28 b(..)i(avail_in-1])p Fl())150 2685 y(is)e(compressed)g
- (and)h(transferred)e(to)j(the)f(output)f(bu 13er.)40
- b(T)-8 b(o)29 b(do)g(this,)f Fj(bzCompress)e Fl(m)m(ust)j(b)s(e)f
- (called)150 2794 y(rep)s(eatedly)40 b(un)m(til)f(all)g(the)i(output)f
- (has)h(b)s(een)e(consumed.)71 b(A)m(t)42 b(that)f(p)s(oin)m(t,)h
- Fj(bzCompress)c Fl(returns)150 2904 y Fj(BZ_STREAM_END)p
- Fl(,)33 b(and)i(the)g(stream's)h(state)g(is)e(set)i(bac)m(k)g(to)g
- (IDLE.)f Fj(bzCompressEnd)d Fl(should)h(then)150 3014
- y(b)s(e)d(called.)150 3170 y(Just)25 b(to)i(mak)m(e)g(sure)e(the)i
- (calling)d(program)i(do)s(es)g(not)g(c)m(heat,)i(the)f(library)c(mak)m
- (es)k(a)f(note)h(of)f Fj(avail_in)150 3280 y Fl(at)f(the)g(time)g(of)f
- (the)h( 14rst)f(call)g(to)i Fj(bzCompress)21 b Fl(whic)m(h)j(has)g
- Fj(BZ_FINISH)e Fl(as)j(an)g(action)g((ie,)h(at)f(the)g(time)150
- 3390 y(the)h(program)g(has)g(announced)f(its)g(in)m(ten)m(tion)h(to)g
- (not)h(supply)c(an)m(y)k(more)f(input).)37 b(By)27 b(comparing)e(this)
- 150 3499 y(v)-5 b(alue)23 b(with)f(that)i(of)g Fj(avail_in)d
- Fl(o)m(v)m(er)k(subsequen)m(t)e(calls)g(to)h Fj(bzCompress)p
- Fl(,)e(the)i(library)d(can)j(detect)h(an)m(y)150 3609
- y(attempts)32 b(to)g(slip)d(in)g(more)j(data)f(to)h(compress.)42
- b(An)m(y)32 b(calls)e(for)h(whic)m(h)e(this)h(is)g(detected)j(will)28
- b(return)150 3718 y Fj(BZ_SEQUENCE_ERROR)p Fl(.)36 b(This)29
- b(indicates)g(a)i(programming)e(mistak)m(e)i(whic)m(h)e(should)f(b)s(e)
- i(corrected.)150 3875 y(Instead)21 b(of)f(asking)h(to)g( 14nish,)g
- (the)g(calling)e(program)h(ma)m(y)i(ask)f Fj(bzCompress)c
- Fl(to)22 b(tak)m(e)g(all)e(the)h(remaining)150 3985 y(input,)32
- b(compress)h(it)g(and)g(terminate)g(the)h(curren)m(t)f((Burro)m
- (ws-Wheeler))g(compression)g(blo)s(c)m(k.)49 b(This)150
- 4094 y(could)23 b(b)s(e)h(useful)f(for)h(error)g(con)m(trol)h(purp)s
- (oses.)37 b(The)24 b(mec)m(hanism)f(is)h(analogous)h(to)g(that)g(for)f
- ( 14nishing:)150 4204 y(call)j Fj(bzCompress)e Fl(with)h(an)i(action)f
- (of)h Fj(BZ_FLUSH)p Fl(,)e(remo)m(v)m(e)j(output)f(data,)h(and)e(p)s
- (ersist)f(with)g(the)i Fj(BZ_)150 4314 y(FLUSH)d Fl(action)i(un)m(til)d
- (the)j(v)-5 b(alue)26 b Fj(BZ_RUN)e Fl(is)i(returned.)38
- b(As)26 b(with)f( 14nishing,)f Fj(bzCompress)g Fl(detects)k(an)m(y)150
- 4423 y(attempt)j(to)h(pro)m(vide)d(more)i(input)d(data)j(once)g(the)g
- ( 15ush)d(has)j(b)s(egun.)150 4580 y(Once)f(the)h( 15ush)e(is)g
- (complete,)i(the)g(stream)f(returns)g(to)h(the)f(normal)g(R)m(UNNING)h
- (state.)150 4737 y(This)f(all)h(sounds)g(prett)m(y)h(complex,)h(but)e
- (isn't)g(really)-8 b(.)45 b(Here's)33 b(a)f(table)g(whic)m(h)f(sho)m
- (ws)h(whic)m(h)f(actions)150 4846 y(are)e(allo)m(w)m(able)f(in)f(eac)m
- (h)j(state,)g(what)f(action)g(will)c(b)s(e)j(tak)m(en,)j(what)d(the)h
- (next)f(state)i(is,)e(and)g(what)h(the)150 4956 y(non-error)h(return)f
- (v)-5 b(alues)29 b(are.)41 b(Note)32 b(that)e(y)m(ou)h(can't)g
- (explicitly)d(ask)i(what)g(state)i(the)e(stream)h(is)e(in,)150
- 5066 y(but)h(nor)g(do)g(y)m(ou)h(need)f(to)h({)g(it)e(can)i(b)s(e)f
- (inferred)e(from)i(the)h(v)-5 b(alues)29 b(returned)h(b)m(y)g
- Fj(bzCompress)p Fl(.)390 5217 y(IDLE/)p Fj(any)572 5320
- y Fl(Illegal.)60 b(IDLE)30 b(state)i(only)d(exists)h(after)h
- Fj(bzCompressEnd)c Fl(or)p eop
- %%Page: 17 18
- 17 17 bop 150 -116 a Fl(Chapter)30 b(3:)41 b(Programming)29
- b(with)g Fj(libbzip2)1881 b Fl(17)572 366 y(b)s(efore)30
- b Fj(bzCompressInit)p Fl(.)572 470 y(Return)f(v)-5 b(alue)30
- b(=)g Fj(BZ_SEQUENCE_ERROR)390 678 y Fl(R)m(UNNING/)p
- Fj(BZ_RUN)572 782 y Fl(Compress)f(from)h Fj(next_in)f
- Fl(to)i Fj(next_out)d Fl(as)i(m)m(uc)m(h)h(as)f(p)s(ossible.)572
- 885 y(Next)h(state)h(=)e(R)m(UNNING)572 989 y(Return)f(v)-5
- b(alue)30 b(=)g Fj(BZ_RUN_OK)390 1197 y Fl(R)m(UNNING/)p
- Fj(BZ_FLUSH)572 1300 y Fl(Remem)m(b)s(er)g(curren)m(t)g(v)-5
- b(alue)30 b(of)g Fj(next_in)p Fl(.)59 b(Compress)30 b(from)g
- Fj(next_in)572 1404 y Fl(to)h Fj(next_out)d Fl(as)j(m)m(uc)m(h)f(as)h
- (p)s(ossible,)d(but)i(do)g(not)g(accept)i(an)m(y)f(more)f(input.)572
- 1508 y(Next)h(state)h(=)e(FLUSHING)572 1612 y(Return)f(v)-5
- b(alue)30 b(=)g Fj(BZ_FLUSH_OK)390 1819 y Fl(R)m(UNNING/)p
- Fj(BZ_FINISH)572 1923 y Fl(Remem)m(b)s(er)g(curren)m(t)g(v)-5
- b(alue)30 b(of)g Fj(next_in)p Fl(.)59 b(Compress)30 b(from)g
- Fj(next_in)572 2027 y Fl(to)h Fj(next_out)d Fl(as)j(m)m(uc)m(h)f(as)h
- (p)s(ossible,)d(but)i(do)g(not)g(accept)i(an)m(y)f(more)f(input.)572
- 2131 y(Next)h(state)h(=)e(FINISHING)572 2234 y(Return)f(v)-5
- b(alue)30 b(=)g Fj(BZ_FINISH_OK)390 2442 y Fl(FLUSHING/)p
- Fj(BZ_FLUSH)572 2546 y Fl(Compress)f(from)h Fj(next_in)f
- Fl(to)i Fj(next_out)d Fl(as)i(m)m(uc)m(h)h(as)f(p)s(ossible,)572
- 2650 y(but)f(do)i(not)f(accept)i(an)m(y)f(more)f(input.)572
- 2753 y(If)g(all)f(the)i(existing)e(input)f(has)i(b)s(een)g(used)g(up)f
- (and)h(all)f(compressed)572 2857 y(output)h(has)g(b)s(een)g(remo)m(v)m
- (ed)663 2961 y(Next)h(state)h(=)e(R)m(UNNING;)i(Return)d(v)-5
- b(alue)30 b(=)g Fj(BZ_RUN_OK)572 3065 y Fl(else)663 3168
- y(Next)h(state)h(=)e(FLUSHING;)h(Return)e(v)-5 b(alue)30
- b(=)g Fj(BZ_FLUSH_OK)390 3376 y Fl(FLUSHING/other)572
- 3480 y(Illegal.)572 3584 y(Return)f(v)-5 b(alue)30 b(=)g
- Fj(BZ_SEQUENCE_ERROR)390 3791 y Fl(FINISHING/)p Fj(BZ_FINISH)572
- 3895 y Fl(Compress)f(from)h Fj(next_in)f Fl(to)i Fj(next_out)d
- Fl(as)i(m)m(uc)m(h)h(as)f(p)s(ossible,)572 3999 y(but)f(to)j(not)e
- (accept)i(an)m(y)f(more)f(input.)572 4102 y(If)g(all)f(the)i(existing)e
- (input)f(has)i(b)s(een)g(used)g(up)f(and)h(all)f(compressed)572
- 4206 y(output)h(has)g(b)s(een)g(remo)m(v)m(ed)663 4310
- y(Next)h(state)h(=)e(IDLE;)g(Return)g(v)-5 b(alue)30
- b(=)g Fj(BZ_STREAM_END)572 4414 y Fl(else)663 4518 y(Next)h(state)h(=)e
- (FINISHING;)g(Return)g(v)-5 b(alue)30 b(=)g Fj(BZ_FINISHING)390
- 4725 y Fl(FINISHING/other)572 4829 y(Illegal.)572 4933
- y(Return)f(v)-5 b(alue)30 b(=)g Fj(BZ_SEQUENCE_ERROR)150
- 5090 y Fl(That)24 b(still)f(lo)s(oks)g(complicated?)39
- b(W)-8 b(ell,)25 b(fair)f(enough.)38 b(The)24 b(usual)f(sequence)i(of)f
- (calls)g(for)g(compressing)150 5199 y(a)31 b(load)f(of)g(data)h(is:)p
- eop
- %%Page: 18 19
- 18 18 bop 150 -116 a Fl(Chapter)30 b(3:)41 b(Programming)29
- b(with)g Fj(libbzip2)1881 b Fl(18)225 366 y Fi( 17)60
- b Fl(Get)31 b(started)g(with)e Fj(bzCompressInit)p Fl(.)225
- 496 y Fi( 17)60 b Fl(Sho)m(v)m(el)54 b(data)i(in)d(and)h(shlurp)d(out)
- k(its)f(compressed)g(form)g(using)f(zero)i(or)g(more)f(calls)g(of)330
- 605 y Fj(bzCompress)28 b Fl(with)h(action)h(=)g Fj(BZ_RUN)p
- Fl(.)225 734 y Fi( 17)60 b Fl(Finish)39 b(up.)71 b(Rep)s(eatedly)40
- b(call)g Fj(bzCompress)e Fl(with)i(action)h(=)g Fj(BZ_FINISH)p
- Fl(,)g(cop)m(ying)g(out)g(the)330 844 y(compressed)30
- b(output,)g(un)m(til)f Fj(BZ_STREAM_END)e Fl(is)i(returned.)225
- 973 y Fi( 17)60 b Fl(Close)30 b(up)f(and)h(go)h(home.)41
- b(Call)29 b Fj(bzCompressEnd)p Fl(.)150 1149 y(If)23
- b(the)h(data)h(y)m(ou)f(w)m(an)m(t)h(to)f(compress)g( 14ts)f(in)m(to)h
- (y)m(our)g(input)e(bu 13er)h(all)f(at)j(once,)h(y)m(ou)e(can)g(skip)f
- (the)h(calls)150 1259 y(of)31 b Fj(bzCompress)c(()j(...,)f(BZ_RUN)g
- ())h Fl(and)g(just)g(do)g(the)g Fj(bzCompress)e(()i(...,)f(BZ_FINISH)
- f())i Fl(calls.)150 1416 y(All)39 b(required)f(memory)i(is)g(allo)s
- (cated)g(b)m(y)g Fj(bzCompressInit)p Fl(.)67 b(The)39
- b(compression)g(library)f(can)j(ac-)150 1525 y(cept)e(an)m(y)h(data)f
- (at)h(all)e((ob)m(viously).)65 b(So)39 b(y)m(ou)g(shouldn't)e(get)k
- (an)m(y)e(error)f(return)g(v)-5 b(alues)38 b(from)h(the)150
- 1635 y Fj(bzCompress)29 b Fl(calls.)43 b(If)31 b(y)m(ou)h(do,)f(they)h
- (will)d(b)s(e)i Fj(BZ_SEQUENCE_ERROR)p Fl(,)c(and)k(indicate)f(a)i(bug)
- f(in)f(y)m(our)150 1744 y(programming.)150 1901 y(T)-8
- b(rivial)28 b(other)j(p)s(ossible)d(return)h(v)-5 b(alues:)572
- 2052 y Fj(BZ_PARAM_ERROR)663 2156 y Fl(if)29 b Fj(strm)g
- Fl(is)h Fj(NULL)p Fl(,)f(or)i Fj(strm->s)d Fl(is)h Fj(NULL)150
- 2392 y Ff(3.3.3)63 b Fe(bzCompressEnd)390 2579 y Fj(int)47
- b(bzCompressEnd)d(()k(bz_stream)d(*strm)h();)150 2735
- y Fl(Releases)31 b(all)e(memory)h(asso)s(ciated)h(with)e(a)i
- (compression)e(stream.)150 2892 y(P)m(ossible)g(return)h(v)-5
- b(alues:)481 3043 y Fj(BZ_PARAM_ERROR)117 b Fl(if)30
- b Fj(strm)f Fl(is)g Fj(NULL)g Fl(or)i Fj(strm->s)d Fl(is)i
- Fj(NULL)481 3147 y(BZ_OK)120 b Fl(otherwise)150 3383
- y Ff(3.3.4)63 b Fe(bzDecompressInit)390 3570 y Fj(int)47
- b(bzDecompressInit)c(()48 b(bz_stream)d(*strm,)h(int)h(verbosity,)e
- (int)i(small)f();)150 3726 y Fl(Prepares)28 b(for)h(decompression.)39
- b(As)29 b(with)f Fj(bzCompressInit)p Fl(,)d(a)k Fj(bz_stream)e
- Fl(record)h(should)f(b)s(e)h(allo-)150 3836 y(cated)i(and)f
- (initialised)d(b)s(efore)j(the)g(call.)40 b(Fields)28
- b Fj(bzalloc)p Fl(,)f Fj(bzfree)h Fl(and)h Fj(opaque)e
- Fl(should)h(b)s(e)g(set)i(if)f(a)150 3946 y(custom)i(memory)g(allo)s
- (cator)h(is)e(required,)g(or)h(made)g Fj(NULL)f Fl(for)h(the)g(normal)f
- Fj(malloc)p Fl(/)p Fj(free)f Fl(routines.)150 4055 y(Up)s(on)24
- b(return,)h(the)g(in)m(ternal)f(state)i(will)c(ha)m(v)m(e)k(b)s(een)f
- (initialised,)d(and)i Fj(total_in)f Fl(and)h Fj(total_out)f
- Fl(will)150 4165 y(b)s(e)30 b(zero.)150 4322 y(F)-8 b(or)31
- b(the)g(meaning)e(of)i(parameter)g Fj(verbosity)p Fl(,)d(see)j
- Fj(bzCompressInit)p Fl(.)150 4478 y(If)e Fj(small)e Fl(is)h(nonzero,)i
- (the)f(library)e(will)f(use)j(an)g(alternativ)m(e)h(decompression)e
- (algorithm)g(whic)m(h)f(uses)150 4588 y(less)c(memory)g(but)g(at)h(the)
- g(cost)h(of)e(decompressing)g(more)g(slo)m(wly)g((roughly)f(sp)s
- (eaking,)i(half)f(the)h(sp)s(eed,)150 4698 y(but)34 b(the)i(maxim)m(um)
- d(memory)i(requiremen)m(t)g(drops)e(to)j(around)e(2300k).)57
- b(See)35 b(Chapter)g(2)g(for)g(more)150 4807 y(information)29
- b(on)h(memory)g(managemen)m(t.)150 4964 y(Note)24 b(that)f(the)g(amoun)
- m(t)g(of)f(memory)h(needed)f(to)h(decompress)g(a)g(stream)f(cannot)i(b)
- s(e)d(determined)h(un)m(til)150 5074 y(the)38 b(stream's)g(header)f
- (has)g(b)s(een)g(read,)i(so)f(ev)m(en)g(if)f Fj(bzDecompressInit)c
- Fl(succeeds,)40 b(a)e(subsequen)m(t)150 5183 y Fj(bzDecompress)27
- b Fl(could)i(fail)g(with)h Fj(BZ_MEM_ERROR)p Fl(.)150
- 5340 y(P)m(ossible)f(return)h(v)-5 b(alues:)p eop
- %%Page: 19 20
- 19 19 bop 150 -116 a Fl(Chapter)30 b(3:)41 b(Programming)29
- b(with)g Fj(libbzip2)1881 b Fl(19)572 366 y Fj(BZ_PARAM_ERROR)663
- 470 y Fl(if)29 b Fj((small)46 b(!=)h(0)h(&&)f(small)f(!=)h(1))663
- 574 y Fl(or)30 b Fj((verbosity)45 b(<)j(0)f(||)g(verbosity)e(>)j(4))
- 572 678 y(BZ_MEM_ERROR)663 782 y Fl(if)29 b(insu 16cien)m(t)g(memory)h
- (is)f(a)m(v)-5 b(ailable)150 938 y(Allo)m(w)m(able)30
- b(next)g(actions:)572 1089 y Fj(bzDecompress)663 1193
- y Fl(if)f Fj(BZ_OK)g Fl(w)m(as)i(returned)572 1297 y(no)f(sp)s
- (eci 14c)f(action)i(required)e(in)g(case)i(of)g(error)150
- 1591 y Ff(3.3.5)63 b Fe(bzDecompress)390 1777 y Fj(int)47
- b(bzDecompress)d(()k(bz_stream)d(*strm)h();)150 1934
- y Fl(Pro)m(vides)24 b(more)g(input)f(and/out)h(output)g(bu 13er)g
- (space)h(for)f(the)g(library)-8 b(.)37 b(The)24 b(caller)g(main)m
- (tains)f(input)150 2044 y(and)30 b(output)g(bu 13ers,)f(and)h(uses)g
- Fj(bzDecompress)d Fl(to)k(transfer)f(data)h(b)s(et)m(w)m(een)g(them.)
- 150 2201 y(Before)46 b(eac)m(h)h(call)e(to)h Fj(bzDecompress)p
- Fl(,)g Fj(next_in)d Fl(should)g(p)s(oin)m(t)i(at)h(the)f(compressed)g
- (data,)51 b(and)150 2310 y Fj(avail_in)34 b Fl(should)h(indicate)g(ho)m
- (w)i(man)m(y)g(b)m(ytes)g(the)f(library)e(ma)m(y)k(read.)59
- b Fj(bzDecompress)33 b Fl(up)s(dates)150 2420 y Fj(next_in)p
- Fl(,)c Fj(avail_in)f Fl(and)i Fj(total_in)e Fl(to)j(re 15ect)g(the)f
- (n)m(um)m(b)s(er)f(of)i(b)m(ytes)g(it)f(has)g(read.)150
- 2577 y(Similarly)-8 b(,)37 b Fj(next_out)f Fl(should)g(p)s(oin)m(t)i
- (to)g(a)h(bu 13er)e(in)g(whic)m(h)g(the)i(uncompressed)e(output)g(is)h
- (to)h(b)s(e)150 2686 y(placed,)23 b(with)d Fj(avail_out)f
- Fl(indicating)g(ho)m(w)i(m)m(uc)m(h)h(output)f(space)h(is)e(a)m(v)-5
- b(ailable.)37 b Fj(bzCompress)19 b Fl(up)s(dates)150
- 2796 y Fj(next_out)p Fl(,)28 b Fj(avail_out)g Fl(and)i
- Fj(total_out)e Fl(to)j(re 15ect)g(the)f(n)m(um)m(b)s(er)g(of)g(b)m
- (ytes)h(output.)150 2953 y(Y)-8 b(ou)53 b(ma)m(y)h(pro)m(vide)e(and)g
- (remo)m(v)m(e)j(as)e(little)e(or)i(as)h(m)m(uc)m(h)e(data)i(as)f(y)m
- (ou)g(lik)m(e)g(on)f(eac)m(h)j(call)d(of)150 3062 y Fj(bzDecompress)p
- Fl(.)72 b(In)41 b(the)i(limit,)g(it)e(is)g(acceptable)i(to)g(supply)c
- (and)j(remo)m(v)m(e)h(data)g(one)f(b)m(yte)h(at)g(a)150
- 3172 y(time,)c(although)e(this)g(w)m(ould)f(b)s(e)h(terribly)e
- (ine 16cien)m(t.)62 b(Y)-8 b(ou)38 b(should)d(alw)m(a)m(ys)j(ensure)f
- (that)h(at)h(least)150 3281 y(one)31 b(b)m(yte)g(of)f(output)g(space)h
- (is)f(a)m(v)-5 b(ailable)29 b(at)i(eac)m(h)h(call.)150
- 3438 y(Use)f(of)f Fj(bzDecompress)d Fl(is)j(simpler)e(than)i
- Fj(bzCompress)p Fl(.)150 3595 y(Y)-8 b(ou)49 b(should)d(pro)m(vide)h
- (input)g(and)g(remo)m(v)m(e)j(output)e(as)g(describ)s(ed)e(ab)s(o)m(v)m
- (e,)54 b(and)48 b(rep)s(eatedly)g(call)150 3705 y Fj(bzDecompress)35
- b Fl(un)m(til)i Fj(BZ_STREAM_END)e Fl(is)j(returned.)64
- b(App)s(earance)39 b(of)g Fj(BZ_STREAM_END)c Fl(denotes)150
- 3814 y(that)d Fj(bzDecompress)c Fl(has)k(detected)g(the)g(logical)f
- (end)g(of)h(the)f(compressed)h(stream.)44 b Fj(bzDecompress)150
- 3924 y Fl(will)18 b(not)k(pro)s(duce)e Fj(BZ_STREAM_END)d
- Fl(un)m(til)i(all)h(output)h(data)h(has)f(b)s(een)f(placed)h(in)m(to)g
- (the)g(output)g(bu 13er,)150 4033 y(so)27 b(once)h Fj(BZ_STREAM_END)23
- b Fl(app)s(ears,)k(y)m(ou)g(are)h(guaran)m(teed)f(to)h(ha)m(v)m(e)g(a)m
- (v)-5 b(ailable)26 b(all)g(the)h(decompressed)150 4143
- y(output,)j(and)g Fj(bzDecompressEnd)c Fl(can)31 b(safely)f(b)s(e)g
- (called.)150 4300 y(If)i(case)i(of)f(an)g(error)f(return)g(v)-5
- b(alue,)33 b(y)m(ou)h(should)c(call)j Fj(bzDecompressEnd)28
- b Fl(to)34 b(clean)f(up)e(and)i(release)150 4409 y(memory)-8
- b(.)150 4566 y(P)m(ossible)29 b(return)h(v)-5 b(alues:)572
- 4717 y Fj(BZ_PARAM_ERROR)663 4821 y Fl(if)29 b Fj(strm)g
- Fl(is)h Fj(NULL)f Fl(or)h Fj(strm->s)f Fl(is)g Fj(NULL)663
- 4925 y Fl(or)h Fj(strm->avail_out)44 b(<)j(1)572 5029
- y(BZ_DATA_ERROR)663 5132 y Fl(if)29 b(a)i(data)g(in)m(tegrit)m(y)f
- (error)g(is)g(detected)h(in)e(the)i(compressed)f(stream)572
- 5236 y Fj(BZ_DATA_ERROR_MAGIC)663 5340 y Fl(if)f(the)i(compressed)f
- (stream)g(do)s(esn't)h(b)s(egin)e(with)g(the)h(righ)m(t)g(magic)h(b)m
- (ytes)p eop
- %%Page: 20 21
- 20 20 bop 150 -116 a Fl(Chapter)30 b(3:)41 b(Programming)29
- b(with)g Fj(libbzip2)1881 b Fl(20)572 366 y Fj(BZ_MEM_ERROR)663
- 470 y Fl(if)29 b(there)i(w)m(asn't)f(enough)h(memory)f(a)m(v)-5
- b(ailable)572 574 y Fj(BZ_STREAM_END)663 678 y Fl(if)29
- b(the)i(logical)e(end)h(of)h(the)f(data)h(stream)g(w)m(as)g(detected)g
- (and)f(all)663 782 y(output)g(in)f(has)h(b)s(een)g(consumed,)f(eg)j
- Fj(s->avail_out)44 b(>)k(0)572 885 y(BZ_OK)663 989 y
- Fl(otherwise)150 1146 y(Allo)m(w)m(able)30 b(next)g(actions:)572
- 1297 y Fj(bzDecompress)663 1401 y Fl(if)f Fj(BZ_OK)g
- Fl(w)m(as)i(returned)572 1505 y Fj(bzDecompressEnd)663
- 1608 y Fl(otherwise)150 1864 y Ff(3.3.6)63 b Fe(bzDecompressEnd)390
- 2050 y Fj(int)47 b(bzDecompressEnd)d(()j(bz_stream)e(*strm)i();)150
- 2207 y Fl(Releases)31 b(all)e(memory)h(asso)s(ciated)h(with)e(a)i
- (decompression)e(stream.)150 2364 y(P)m(ossible)g(return)h(v)-5
- b(alues:)572 2515 y Fj(BZ_PARAM_ERROR)663 2619 y Fl(if)29
- b Fj(strm)g Fl(is)h Fj(NULL)f Fl(or)h Fj(strm->s)f Fl(is)g
- Fj(NULL)572 2723 y(BZ_OK)663 2826 y Fl(otherwise)150
- 2983 y(Allo)m(w)m(able)h(next)g(actions:)572 3134 y(None.)150
- 3427 y Fk(3.4)68 b(High-lev)l(el)47 b(in)l(terface)150
- 3620 y Fl(This)35 b(in)m(terface)j(pro)m(vides)d(functions)h(for)g
- (reading)g(and)h(writing)e Fj(bzip2)g Fl(format)i( 14les.)59
- b(First,)39 b(some)150 3729 y(general)30 b(p)s(oin)m(ts.)225
- 3886 y Fi( 17)60 b Fl(All)35 b(of)h(the)g(functions)e(tak)m(e)k(an)e
- Fj(int*)f Fl( 14rst)g(argumen)m(t,)j Fj(bzerror)p Fl(.)56
- b(After)36 b(eac)m(h)h(call,)g Fj(bzerror)330 3996 y
- Fl(should)23 b(b)s(e)i(consulted)g( 14rst)g(to)h(determine)e(the)i
- (outcome)h(of)e(the)h(call.)38 b(If)25 b Fj(bzerror)f
- Fl(is)g Fj(BZ_OK)p Fl(,)i(the)330 4105 y(call)35 b(completed)g
- (successfully)-8 b(,)36 b(and)f(only)g(then)g(should)f(the)h(return)g
- (v)-5 b(alue)35 b(of)h(the)f(function)g((if)330 4215
- y(an)m(y))30 b(b)s(e)f(consulted.)39 b(If)29 b Fj(bzerror)e
- Fl(is)h Fj(BZ_IO_ERROR)p Fl(,)f(there)i(w)m(as)h(an)f(error)g
- (reading/writing)e(the)330 4324 y(underlying)32 b(compressed)j( 14le,)
- h(and)f(y)m(ou)h(should)d(then)i(consult)g Fj(errno)p
- Fl(/)p Fj(perror)e Fl(to)j(determine)330 4434 y(the)i(cause)g(of)g(the)
- g(di 16cult)m(y)-8 b(.)61 b Fj(bzerror)36 b Fl(ma)m(y)i(also)g(b)s(e)f
- (set)h(to)g(v)-5 b(arious)37 b(other)h(v)-5 b(alues;)41
- b(precise)330 4544 y(details)29 b(are)i(giv)m(en)g(on)f(a)h(p)s
- (er-function)d(basis)h(b)s(elo)m(w.)225 4682 y Fi( 17)60
- b Fl(If)40 b Fj(bzerror)f Fl(indicates)g(an)i(error)f((ie,)j(an)m
- (ything)d(except)h Fj(BZ_OK)f Fl(and)g Fj(BZ_STREAM_END)p
- Fl(),)g(y)m(ou)330 4792 y(should)19 b(immediately)h(call)h
- Fj(bzReadClose)d Fl((or)k Fj(bzWriteClose)p Fl(,)e(dep)s(ending)f(on)i
- (whether)g(y)m(ou)h(are)330 4902 y(attempting)g(to)h(read)f(or)g(to)h
- (write))e(to)i(free)f(up)f(all)g(resources)h(asso)s(ciated)h(with)d
- (the)j(stream.)38 b(Once)330 5011 y(an)24 b(error)g(has)h(b)s(een)e
- (indicated,)i(b)s(eha)m(viour)e(of)i(all)e(calls)h(except)h
- Fj(bzReadClose)d Fl(()p Fj(bzWriteClose)p Fl())330
- 5121 y(is)36 b(unde 14ned.)56 b(The)36 b(implication)e(is)i(that)h
- ((1))g Fj(bzerror)e Fl(should)f(b)s(e)i(c)m(hec)m(k)m(ed)j(after)e
- (eac)m(h)g(call,)330 5230 y(and)g((2))h(if)e Fj(bzerror)f
- Fl(indicates)i(an)g(error,)i Fj(bzReadClose)34 b Fl(()p
- Fj(bzWriteClose)p Fl())g(should)i(then)h(b)s(e)330 5340
- y(called)30 b(to)h(clean)f(up.)p eop
- %%Page: 21 22
- 21 21 bop 150 -116 a Fl(Chapter)30 b(3:)41 b(Programming)29
- b(with)g Fj(libbzip2)1881 b Fl(21)225 366 y Fi( 17)60
- b Fl(The)42 b Fj(FILE*)f Fl(argumen)m(ts)i(passed)g(to)g
- Fj(bzReadOpen)p Fl(/)p Fj(bzWriteOpen)37 b Fl(should)k(b)s(e)h(set)h
- (to)h(binary)330 476 y(mo)s(de.)85 b(Most)46 b(Unix)f(systems)g(will)e
- (do)i(this)f(b)m(y)h(default,)k(but)44 b(other)i(platforms,)i
- (including)330 586 y(Windo)m(ws)42 b(and)g(Mac,)48 b(will)40
- b(not.)79 b(If)43 b(y)m(ou)g(omit)g(this,)i(y)m(ou)f(ma)m(y)f(encoun)m
- (ter)h(problems)d(when)330 695 y(mo)m(ving)30 b(co)s(de)h(to)g(new)f
- (platforms.)225 858 y Fi( 17)60 b Fl(Memory)23 b(allo)s(cation)f
- (requests)h(are)g(handled)e(b)m(y)i Fj(malloc)p Fl(/)p
- Fj(free)p Fl(.)36 b(A)m(t)23 b(presen)m(t)g(there)g(is)f(no)h(facilit)m
- (y)330 967 y(for)40 b(user-de 14ned)e(memory)i(allo)s(cators)g(in)f
- (the)h( 14le)g(I/O)g(functions)e((could)i(easily)f(b)s(e)g(added,)330
- 1077 y(though).)150 1379 y Ff(3.4.1)63 b Fe(bzReadOpen)533
- 1566 y Fj(typedef)46 b(void)h(BZFILE;)533 1773 y(BZFILE)f(*bzReadOpen)f
- (()i(int)g(*bzerror,)f(FILE)g(*f,)1535 1877 y(int)h(small,)f(int)h
- (verbosity,)1535 1981 y(void)g(*unused,)f(int)h(nUnused)e();)150
- 2138 y Fl(Prepare)29 b(to)g(read)g(compressed)f(data)i(from)e( 14le)g
- (handle)f Fj(f)p Fl(.)40 b Fj(f)29 b Fl(should)d(refer)j(to)h(a)f
- ( 14le)f(whic)m(h)f(has)i(b)s(een)150 2247 y(op)s(ened)h(for)h
- (reading,)f(and)h(for)f(whic)m(h)g(the)h(error)g(indicator)e(()p
- Fj(ferror(f))p Fl()is)f(not)k(set.)42 b(If)31 b Fj(small)e
- Fl(is)h(1,)150 2357 y(the)h(library)d(will)f(try)j(to)i(decompress)e
- (using)f(less)g(memory)-8 b(,)31 b(at)g(the)g(exp)s(ense)f(of)g(sp)s
- (eed.)150 2514 y(F)-8 b(or)26 b(reasons)f(explained)e(b)s(elo)m(w,)j
- Fj(bzRead)d Fl(will)g(decompress)i(the)g Fj(nUnused)e
- Fl(b)m(ytes)j(starting)f(at)g Fj(unused)p Fl(,)150 2623
- y(b)s(efore)k(starting)g(to)h(read)f(from)g(the)g( 14le)g
- Fj(f)p Fl(.)40 b(A)m(t)30 b(most)g Fj(BZ_MAX_UNUSED)25
- b Fl(b)m(ytes)30 b(ma)m(y)g(b)s(e)f(supplied)d(lik)m(e)150
- 2733 y(this.)53 b(If)34 b(this)g(facilit)m(y)g(is)g(not)h(required,)f
- (y)m(ou)h(should)e(pass)h Fj(NULL)g Fl(and)g Fj(0)g Fl(for)h
- Fj(unused)e Fl(and)h(n)p Fj(Unused)150 2842 y Fl(resp)s(ectiv)m(ely)-8
- b(.)150 2999 y(F)g(or)31 b(the)g(meaning)e(of)i(parameters)g
- Fj(small)e Fl(and)g Fj(verbosity)p Fl(,)f(see)j Fj(bzDecompressInit)p
- Fl(.)150 3156 y(The)k(amoun)m(t)g(of)g(memory)g(needed)g(to)g
- (decompress)g(a)h( 14le)e(cannot)h(b)s(e)g(determined)e(un)m(til)h
- (the)h( 14le's)150 3266 y(header)g(has)g(b)s(een)f(read.)55
- b(So)35 b(it)g(is)f(p)s(ossible)f(that)j Fj(bzReadOpen)c
- Fl(returns)i Fj(BZ_OK)g Fl(but)g(a)i(subsequen)m(t)150
- 3375 y(call)30 b(of)g Fj(bzRead)f Fl(will)f(return)h
- Fj(BZ_MEM_ERROR)p Fl(.)150 3532 y(P)m(ossible)g(assignmen)m(ts)h(to)h
- Fj(bzerror)p Fl(:)572 3683 y Fj(BZ_PARAM_ERROR)663 3787
- y Fl(if)e Fj(f)h Fl(is)g Fj(NULL)663 3891 y Fl(or)g Fj(small)f
- Fl(is)g(neither)h Fj(0)g Fl(nor)g Fj(1)663 3994 y Fl(or)g
- Fj((unused)46 b(==)h(NULL)g(&&)g(nUnused)f(!=)h(0))663
- 4098 y Fl(or)30 b Fj((unused)46 b(!=)h(NULL)g(&&)g(!(0)g(<=)g
- (nUnused)f(<=)h(BZ_MAX_UNUSED)))572 4202 y(BZ_IO_ERROR)663
- 4306 y Fl(if)29 b Fj(ferror(f))f Fl(is)h(nonzero)572
- 4409 y Fj(BZ_MEM_ERROR)663 4513 y Fl(if)g(insu 16cien)m(t)g(memory)h
- (is)f(a)m(v)-5 b(ailable)572 4617 y Fj(BZ_OK)663 4721
- y Fl(otherwise.)150 4878 y(P)m(ossible)29 b(return)h(v)-5
- b(alues:)572 5029 y(P)m(oin)m(ter)31 b(to)g(an)f(abstract)h
- Fj(BZFILE)663 5132 y Fl(if)e Fj(bzerror)f Fl(is)i Fj(BZ_OK)572
- 5236 y(NULL)663 5340 y Fl(otherwise)p eop
- %%Page: 22 23
- 22 22 bop 150 -116 a Fl(Chapter)30 b(3:)41 b(Programming)29
- b(with)g Fj(libbzip2)1881 b Fl(22)150 366 y(Allo)m(w)m(able)30
- b(next)g(actions:)572 518 y Fj(bzRead)663 621 y Fl(if)f
- Fj(bzerror)f Fl(is)i Fj(BZ_OK)572 725 y(bzClose)663 829
- y Fl(otherwise)150 1103 y Ff(3.4.2)63 b Fe(bzRead)533
- 1290 y Fj(int)47 b(bzRead)f(()i(int)f(*bzerror,)e(BZFILE)h(*b,)h(void)
- f(*buf,)h(int)g(len)g();)150 1447 y Fl(Reads)35 b(up)f(to)h
- Fj(len)f Fl((uncompressed))h(b)m(ytes)g(from)f(the)h(compressed)g
- ( 14le)f Fj(b)g Fl(in)m(to)h(the)g(bu 13er)f Fj(buf)p
- Fl(.)53 b(If)150 1556 y(the)30 b(read)f(w)m(as)h(successful,)f
- Fj(bzerror)e Fl(is)i(set)h(to)g Fj(BZ_OK)e Fl(and)h(the)h(n)m(um)m(b)s
- (er)e(of)i(b)m(ytes)g(read)f(is)g(returned.)150 1666
- y(If)k(the)g(logical)g(end-of-stream)h(w)m(as)g(detected,)i
- Fj(bzerror)31 b Fl(will)g(b)s(e)h(set)i(to)g Fj(BZ_STREAM_END)p
- Fl(,)d(and)i(the)150 1776 y(n)m(um)m(b)s(er)c(of)i(b)m(ytes)f(read)h
- (is)e(returned.)40 b(All)29 b(other)h Fj(bzerror)f Fl(v)-5
- b(alues)29 b(denote)i(an)g(error.)150 1932 y Fj(bzRead)f
- Fl(will)e(supply)h Fj(len)h Fl(b)m(ytes,)j(unless)c(the)j(logical)f
- (stream)g(end)g(is)f(detected)j(or)e(an)g(error)g(o)s(ccurs.)150
- 2042 y(Because)22 b(of)f(this,)h(it)f(is)f(p)s(ossible)e(to)k(detect)g
- (the)f(stream)h(end)e(b)m(y)h(observing)f(when)g(the)h(n)m(um)m(b)s(er)
- e(of)i(b)m(ytes)150 2152 y(returned)33 b(is)h(less)f(than)i(the)f(n)m
- (um)m(b)s(er)f(requested.)53 b(Nev)m(ertheless,)37 b(this)c(is)g
- (regarded)i(as)f(inadvisable;)150 2261 y(y)m(ou)d(should)d(instead)i(c)
- m(hec)m(k)i Fj(bzerror)c Fl(after)j(ev)m(ery)g(call)f(and)g(w)m(atc)m
- (h)h(out)g(for)f Fj(BZ_STREAM_END)p Fl(.)150 2418 y(In)m(ternally)-8
- b(,)37 b Fj(bzRead)d Fl(copies)i(data)h(from)f(the)g(compressed)g
- ( 14le)f(in)g(c)m(h)m(unks)h(of)h(size)f Fj(BZ_MAX_UNUSED)150
- 2528 y Fl(b)m(ytes)31 b(b)s(efore)e(decompressing)h(it.)40
- b(If)29 b(the)i( 14le)e(con)m(tains)h(more)h(b)m(ytes)f(than)g
- (strictly)f(needed)h(to)h(reac)m(h)150 2637 y(the)26
- b(logical)g(end-of-stream,)i Fj(bzRead)c Fl(will)f(almost)j(certainly)g
- (read)g(some)g(of)g(the)g(trailing)f(data)h(b)s(efore)150
- 2747 y(signalling)31 b Fj(BZ_SEQUENCE_END)p Fl(.)45 b(T)-8
- b(o)34 b(collect)g(the)f(read)g(but)g(un)m(used)f(data)i(once)g
- Fj(BZ_SEQUENCE_END)150 2856 y Fl(has)c(app)s(eared,)g(call)g
- Fj(bzReadGetUnused)c Fl(immediately)j(b)s(efore)h Fj(bzReadClose)p
- Fl(.)150 3013 y(P)m(ossible)f(assignmen)m(ts)h(to)h Fj(bzerror)p
- Fl(:)572 3164 y Fj(BZ_PARAM_ERROR)663 3268 y Fl(if)e
- Fj(b)h Fl(is)g Fj(NULL)f Fl(or)h Fj(buf)g Fl(is)f Fj(NULL)g
- Fl(or)i Fj(len)46 b(<)i(0)572 3372 y(BZ_SEQUENCE_ERROR)663
- 3475 y Fl(if)29 b Fj(b)h Fl(w)m(as)h(op)s(ened)e(with)h
- Fj(bzWriteOpen)572 3579 y(BZ_IO_ERROR)663 3683 y Fl(if)f(there)i(is)e
- (an)h(error)g(reading)g(from)g(the)g(compressed)g( 14le)572
- 3787 y Fj(BZ_UNEXPECTED_EOF)663 3891 y Fl(if)f(the)i(compressed)f
- ( 14le)f(ended)h(b)s(efore)g(the)g(logical)g(end-of-stream)h(w)m(as)g
- (detected)572 3994 y Fj(BZ_DATA_ERROR)663 4098 y Fl(if)e(a)i(data)g(in)
- m(tegrit)m(y)f(error)g(w)m(as)h(detected)h(in)d(the)h(compressed)g
- (stream)572 4202 y Fj(BZ_DATA_ERROR_MAGIC)663 4306 y
- Fl(if)f(the)i(stream)f(do)s(es)g(not)h(b)s(egin)e(with)g(the)i
- (requisite)e(header)h(b)m(ytes)h((ie,)f(is)g(not)663
- 4409 y(a)g Fj(bzip2)f Fl(data)i( 14le).)61 b(This)28
- b(is)i(really)f(a)i(sp)s(ecial)e(case)i(of)g Fj(BZ_DATA_ERROR)p
- Fl(.)572 4513 y Fj(BZ_MEM_ERROR)663 4617 y Fl(if)e(insu 16cien)m(t)g
- (memory)h(w)m(as)h(a)m(v)-5 b(ailable)572 4721 y Fj(BZ_STREAM_END)663
- 4825 y Fl(if)29 b(the)i(logical)e(end)h(of)h(stream)f(w)m(as)h
- (detected.)572 4928 y Fj(BZ_OK)663 5032 y Fl(otherwise.)150
- 5189 y(P)m(ossible)e(return)h(v)-5 b(alues:)572 5340
- y(n)m(um)m(b)s(er)29 b(of)h(b)m(ytes)h(read)p eop
- %%Page: 23 24
- 23 23 bop 150 -116 a Fl(Chapter)30 b(3:)41 b(Programming)29
- b(with)g Fj(libbzip2)1881 b Fl(23)663 366 y(if)29 b Fj(bzerror)f
- Fl(is)i Fj(BZ_OK)f Fl(or)h Fj(BZ_STREAM_END)572 470 y
- Fl(unde 14ned)663 574 y(otherwise)150 731 y(Allo)m(w)m(able)g(next)g
- (actions:)572 882 y(collect)h(data)g(from)f Fj(buf)p
- Fl(,)f(then)h Fj(bzRead)f Fl(or)h Fj(bzReadClose)663
- 986 y Fl(if)f Fj(bzerror)f Fl(is)i Fj(BZ_OK)572 1089
- y Fl(collect)h(data)g(from)f Fj(buf)p Fl(,)f(then)h Fj(bzReadClose)e
- Fl(or)i Fj(bzReadGetUnused)663 1193 y Fl(if)f Fj(bzerror)f
- Fl(is)i Fj(BZ_SEQUENCE_END)572 1297 y(bzReadClose)663
- 1401 y Fl(otherwise)150 1642 y Ff(3.4.3)63 b Fe(bzReadGetUnused)533
- 1829 y Fj(void)47 b(bzReadGetUnused)c(()48 b(int*)f(bzerror,)e(BZFILE)
- h(*b,)1631 1932 y(void**)g(unused,)g(int*)g(nUnused)g();)150
- 2089 y Fl(Returns)36 b(data)i(whic)m(h)d(w)m(as)j(read)f(from)f(the)h
- (compressed)g( 14le)f(but)g(w)m(as)h(not)h(needed)e(to)i(get)g(to)g
- (the)150 2199 y(logical)k(end-of-stream.)78 b Fj(*unused)41
- b Fl(is)h(set)h(to)g(the)g(address)f(of)g(the)h(data,)k(and)42
- b Fj(*nUnused)e Fl(to)k(the)150 2308 y(n)m(um)m(b)s(er)29
- b(of)i(b)m(ytes.)41 b Fj(*nUnused)28 b Fl(will)g(b)s(e)h(set)i(to)g(a)g
- (v)-5 b(alue)30 b(b)s(et)m(w)m(een)h Fj(0)f Fl(and)g
- Fj(BZ_MAX_UNUSED)d Fl(inclusiv)m(e.)150 2465 y(This)40
- b(function)h(ma)m(y)h(only)f(b)s(e)h(called)f(once)h
- Fj(bzRead)e Fl(has)i(signalled)e Fj(BZ_STREAM_END)e Fl(but)j(b)s(efore)
- 150 2575 y Fj(bzReadClose)p Fl(.)150 2732 y(P)m(ossible)29
- b(assignmen)m(ts)h(to)h Fj(bzerror)p Fl(:)572 2883 y
- Fj(BZ_PARAM_ERROR)663 2986 y Fl(if)e Fj(b)h Fl(is)g Fj(NULL)663
- 3090 y Fl(or)g Fj(unused)f Fl(is)g Fj(NULL)g Fl(or)i
- Fj(nUnused)d Fl(is)i Fj(NULL)572 3194 y(BZ_SEQUENCE_ERROR)663
- 3298 y Fl(if)f Fj(BZ_STREAM_END)e Fl(has)j(not)h(b)s(een)e(signalled)
- 663 3402 y(or)h(if)f Fj(b)h Fl(w)m(as)h(op)s(ened)f(with)f
- Fj(bzWriteOpen)542 3505 y(BZ_OK)663 3609 y Fl(otherwise)150
- 3766 y(Allo)m(w)m(able)h(next)g(actions:)572 3917 y Fj(bzReadClose)150
- 4158 y Ff(3.4.4)63 b Fe(bzReadClose)533 4345 y Fj(void)47
- b(bzReadClose)e(()i(int)g(*bzerror,)e(BZFILE)h(*b)h();)150
- 4502 y Fl(Releases)26 b(all)f(memory)g(p)s(ertaining)e(to)k(the)e
- (compressed)h( 14le)e Fj(b)p Fl(.)39 b Fj(bzReadClose)23
- b Fl(do)s(es)i(not)h(call)f Fj(fclose)150 4611 y Fl(on)33
- b(the)f(underlying)e( 14le)i(handle,)g(so)h(y)m(ou)g(should)d(do)j
- (that)g(y)m(ourself)f(if)f(appropriate.)47 b Fj(bzReadClose)150
- 4721 y Fl(should)28 b(b)s(e)i(called)g(to)h(clean)f(up)f(after)i(all)f
- (error)g(situations.)150 4878 y(P)m(ossible)f(assignmen)m(ts)h(to)h
- Fj(bzerror)p Fl(:)572 5029 y Fj(BZ_SEQUENCE_ERROR)663
- 5132 y Fl(if)e Fj(b)h Fl(w)m(as)h(op)s(ened)e(with)h
- Fj(bzOpenWrite)572 5236 y(BZ_OK)663 5340 y Fl(otherwise)p
- eop
- %%Page: 24 25
- 24 24 bop 150 -116 a Fl(Chapter)30 b(3:)41 b(Programming)29
- b(with)g Fj(libbzip2)1881 b Fl(24)150 366 y(Allo)m(w)m(able)30
- b(next)g(actions:)572 518 y(none)150 766 y Ff(3.4.5)63
- b Fe(bzWriteOpen)533 953 y Fj(BZFILE)46 b(*bzWriteOpen)f(()i(int)g
- (*bzerror,)e(FILE)i(*f,)1583 1057 y(int)g(blockSize100k,)d(int)j
- (verbosity,)1583 1160 y(int)g(workFactor)e();)150 1317
- y Fl(Prepare)33 b(to)g(write)f(compressed)h(data)h(to)f( 14le)f
- (handle)g Fj(f)p Fl(.)47 b Fj(f)33 b Fl(should)e(refer)i(to)g(a)g
- ( 14le)f(whic)m(h)g(has)h(b)s(een)150 1427 y(op)s(ened)d(for)g
- (writing,)e(and)i(for)g(whic)m(h)f(the)i(error)f(indicator)f(()p
- Fj(ferror(f))p Fl()is)f(not)i(set.)150 1584 y(F)-8
- b(or)31 b(the)g(meaning)e(of)i(parameters)g Fj(blockSize100k)p
- Fl(,)c Fj(verbosity)g Fl(and)j Fj(workFactor)p Fl(,)e(see)150
- 1693 y Fj(bzCompressInit)p Fl(.)150 1850 y(All)d(required)f(memory)i
- (is)f(allo)s(cated)i(at)g(this)e(stage,)j(so)f(if)e(the)h(call)g
- (completes)g(successfully)-8 b(,)26 b Fj(BZ_MEM_)150
- 1960 y(ERROR)j Fl(cannot)i(b)s(e)f(signalled)e(b)m(y)i(a)h(subsequen)m
- (t)f(call)f(to)i Fj(bzWrite)p Fl(.)150 2117 y(P)m(ossible)e(assignmen)m
- (ts)h(to)h Fj(bzerror)p Fl(:)572 2268 y Fj(BZ_PARAM_ERROR)663
- 2371 y Fl(if)e Fj(f)h Fl(is)g Fj(NULL)663 2475 y Fl(or)g
- Fj(blockSize100k)44 b(<)k(1)30 b Fl(or)g Fj(blockSize100k)44
- b(>)k(9)572 2579 y(BZ_IO_ERROR)663 2683 y Fl(if)29 b
- Fj(ferror(f))f Fl(is)h(nonzero)572 2786 y Fj(BZ_MEM_ERROR)663
- 2890 y Fl(if)g(insu 16cien)m(t)g(memory)h(is)f(a)m(v)-5
- b(ailable)572 2994 y Fj(BZ_OK)663 3098 y Fl(otherwise)150
- 3255 y(P)m(ossible)29 b(return)h(v)-5 b(alues:)572 3406
- y(P)m(oin)m(ter)31 b(to)g(an)f(abstract)h Fj(BZFILE)663
- 3509 y Fl(if)e Fj(bzerror)f Fl(is)i Fj(BZ_OK)572 3613
- y(NULL)663 3717 y Fl(otherwise)150 3874 y(Allo)m(w)m(able)g(next)g
- (actions:)572 4025 y Fj(bzWrite)663 4129 y Fl(if)f Fj(bzerror)f
- Fl(is)i Fj(BZ_OK)663 4232 y Fl((y)m(ou)h(could)e(go)i(directly)e(to)j
- Fj(bzWriteClose)p Fl(,)27 b(but)j(this)f(w)m(ould)g(b)s(e)h(prett)m(y)h
- (p)s(oin)m(tless))572 4336 y Fj(bzWriteClose)663 4440
- y Fl(otherwise)150 4689 y Ff(3.4.6)63 b Fe(bzWrite)533
- 4875 y Fj(void)47 b(bzWrite)f(()h(int)g(*bzerror,)e(BZFILE)h(*b,)h
- (void)g(*buf,)f(int)h(len)g();)150 5032 y Fl(Absorbs)26
- b Fj(len)g Fl(b)m(ytes)i(from)e(the)i(bu 13er)e Fj(buf)p
- Fl(,)h(ev)m(en)m(tually)g(to)h(b)s(e)e(compressed)h(and)f(written)g(to)
- i(the)g( 14le.)150 5189 y(P)m(ossible)h(assignmen)m(ts)h(to)h
- Fj(bzerror)p Fl(:)572 5340 y Fj(BZ_PARAM_ERROR)p eop
- %%Page: 25 26
- 25 25 bop 150 -116 a Fl(Chapter)30 b(3:)41 b(Programming)29
- b(with)g Fj(libbzip2)1881 b Fl(25)663 366 y(if)29 b Fj(b)h
- Fl(is)g Fj(NULL)f Fl(or)h Fj(buf)g Fl(is)f Fj(NULL)g
- Fl(or)i Fj(len)46 b(<)i(0)572 470 y(BZ_SEQUENCE_ERROR)663
- 574 y Fl(if)29 b(b)h(w)m(as)h(op)s(ened)e(with)g Fj(bzReadOpen)572
- 678 y(BZ_IO_ERROR)663 782 y Fl(if)g(there)i(is)e(an)h(error)g(writing)f
- (the)h(compressed)g( 14le.)572 885 y Fj(BZ_OK)663 989
- y Fl(otherwise)150 1253 y Ff(3.4.7)63 b Fe(bzWriteClose)533
- 1440 y Fj(int)47 b(bzWriteClose)e(()i(int)g(*bzerror,)e(BZFILE*)h(f,)
- 1440 1544 y(int)h(abandon,)1440 1648 y(unsigned)f(int*)g(nbytes_in,)
- 1440 1751 y(unsigned)g(int*)g(nbytes_out)f();)150 1908
- y Fl(Compresses)37 b(and)g( 15ushes)f(to)j(the)f(compressed)f( 14le)g
- (all)f(data)j(so)e(far)h(supplied)c(b)m(y)k Fj(bzWrite)p
- Fl(.)60 b(The)150 2018 y(logical)34 b(end-of-stream)i(mark)m(ers)f(are)
- g(also)g(written,)h(so)f(subsequen)m(t)f(calls)g(to)i
- Fj(bzWrite)d Fl(are)i(illegal.)150 2128 y(All)42 b(memory)h(asso)s
- (ciated)h(with)e(the)i(compressed)f( 14le)g Fj(b)g Fl(is)f(released.)
- 80 b Fj(fflush)41 b Fl(is)i(called)f(on)i(the)150 2237
- y(compressed)30 b( 14le,)g(but)f(it)h(is)g(not)g Fj(fclose)p
- Fl('d.)150 2394 y(If)22 b Fj(bzWriteClose)e Fl(is)i(called)g(to)h
- (clean)g(up)f(after)h(an)g(error,)h(the)f(only)f(action)h(is)f(to)h
- (release)g(the)g(memory)-8 b(.)150 2504 y(The)23 b(library)e(records)i
- (the)h(error)f(co)s(des)g(issued)f(b)m(y)h(previous)f(calls,)i(so)g
- (this)e(situation)g(will)f(b)s(e)i(detected)150 2613
- y(automatically)-8 b(.)44 b(There)31 b(is)g(no)g(attempt)i(to)f
- (complete)g(the)g(compression)e(op)s(eration,)h(nor)g(to)i
- Fj(fflush)150 2723 y Fl(the)h(compressed)g( 14le.)51
- b(Y)-8 b(ou)34 b(can)h(force)f(this)f(b)s(eha)m(viour)g(to)i(happ)s(en)
- d(ev)m(en)j(in)e(the)h(case)h(of)f(no)g(error,)150 2832
- y(b)m(y)c(passing)f(a)i(nonzero)g(v)-5 b(alue)30 b(to)h
- Fj(abandon)p Fl(.)150 2989 y(If)j Fj(nbytes_in)d Fl(is)j(non-n)m(ull,)f
- Fj(*nbytes_in)e Fl(will)h(b)s(e)h(set)i(to)g(b)s(e)f(the)g(total)h(v)m
- (olume)f(of)g(uncompressed)150 3099 y(data)k(handled.)60
- b(Similarly)-8 b(,)35 b Fj(nbytes_out)g Fl(will)g(b)s(e)h(set)i(to)g
- (the)g(total)g(v)m(olume)f(of)g(compressed)g(data)150
- 3208 y(written.)150 3365 y(P)m(ossible)29 b(assignmen)m(ts)h(to)h
- Fj(bzerror)p Fl(:)572 3516 y Fj(BZ_SEQUENCE_ERROR)663
- 3620 y Fl(if)e Fj(b)h Fl(w)m(as)h(op)s(ened)e(with)h
- Fj(bzReadOpen)572 3724 y(BZ_IO_ERROR)663 3827 y Fl(if)f(there)i(is)e
- (an)h(error)g(writing)f(the)h(compressed)g( 14le)572
- 3931 y Fj(BZ_OK)663 4035 y Fl(otherwise)150 4299 y Ff(3.4.8)63
- b(Handling)41 b(em)m(b)s(edded)g(compressed)h(data)e(streams)150
- 4492 y Fl(The)i(high-lev)m(el)g(library)f(facilitates)h(use)h(of)g
- Fj(bzip2)e Fl(data)j(streams)f(whic)m(h)f(form)g(some)i(part)e(of)i(a)
- 150 4601 y(surrounding,)27 b(larger)j(data)h(stream.)225
- 4758 y Fi( 17)60 b Fl(F)-8 b(or)22 b(writing,)f(the)g(library)e(tak)m
- (es)k(an)e(op)s(en)f( 14le)g(handle,)i(writes)e(compressed)h(data)h
- (to)g(it,)g Fj(fflush)p Fl(es)330 4868 y(it)34 b(but)f(do)s(es)h(not)h
- Fj(fclose)d Fl(it.)52 b(The)34 b(calling)f(application)g(can)h(write)g
- (its)f(o)m(wn)i(data)g(b)s(efore)f(and)330 4977 y(after)d(the)f
- (compressed)h(data)g(stream,)g(using)d(that)j(same)g( 14le)f(handle.)
- 225 5121 y Fi( 17)60 b Fl(Reading)34 b(is)f(more)i(complex,)g(and)f
- (the)h(facilities)d(are)j(not)g(as)g(general)f(as)h(they)f(could)g(b)s
- (e)g(since)330 5230 y(generalit)m(y)27 b(is)f(hard)f(to)j(reconcile)e
- (with)g(e 16ciency)-8 b(.)40 b Fj(bzRead)25 b Fl(reads)i(from)f(the)h
- (compressed)f( 14le)g(in)330 5340 y(blo)s(c)m(ks)f(of)h(size)g
- Fj(BZ_MAX_UNUSED)c Fl(b)m(ytes,)27 b(and)e(in)g(doing)f(so)i(probably)e
- (will)f(o)m(v)m(ersho)s(ot)28 b(the)d(logical)p eop
- %%Page: 26 27
- 26 26 bop 150 -116 a Fl(Chapter)30 b(3:)41 b(Programming)29
- b(with)g Fj(libbzip2)1881 b Fl(26)330 366 y(end)37 b(of)h(compressed)f
- (stream.)63 b(T)-8 b(o)39 b(reco)m(v)m(er)g(this)e(data)h(once)h
- (decompression)d(has)i(ended,)h(call)330 476 y Fj(bzReadGetUnused)23
- b Fl(after)k(the)g(last)g(call)g(of)g Fj(bzRead)e Fl((the)j(one)f
- (returning)e Fj(BZ_STREAM_END)p Fl())f(but)330 586 y(b)s(efore)30
- b(calling)f Fj(bzReadClose)p Fl(.)150 784 y(This)36 b(mec)m(hanism)g
- (mak)m(es)i(it)f(easy)h(to)g(decompress)f(m)m(ultiple)e
- Fj(bzip2)h Fl(streams)i(placed)f(end-to-end.)150 893
- y(As)j(the)h(end)f(of)h(one)f(stream,)k(when)c Fj(bzRead)e
- Fl(returns)i Fj(BZ_STREAM_END)p Fl(,)f(call)h Fj(bzReadGetUnused)150
- 1003 y Fl(to)i(collect)f(the)h(un)m(used)d(data)j((cop)m(y)g(it)f(in)m
- (to)g(y)m(our)g(o)m(wn)g(bu 13er)f(somewhere).)73 b(That)41
- b(data)h(forms)150 1112 y(the)c(start)h(of)g(the)f(next)g(compressed)g
- (stream.)65 b(T)-8 b(o)39 b(start)f(uncompressing)f(that)h(next)h
- (stream,)i(call)150 1222 y Fj(bzReadOpen)30 b Fl(again,)j(feeding)f(in)
- f(the)i(un)m(used)e(data)i(via)f(the)h Fj(unused)p Fl(/)p
- Fj(nUnused)c Fl(parameters.)48 b(Keep)150 1332 y(doing)26
- b(this)g(un)m(til)f Fj(BZ_STREAM_END)f Fl(return)i(coincides)g(with)g
- (the)h(ph)m(ysical)f(end)g(of)h( 14le)f(()p Fj(feof(f))p
- Fl().)39 b(In)150 1441 y(this)29 b(situation)h Fj(bzReadGetUnused)c
- Fl(will)h(of)k(course)g(return)e(no)h(data.)150 1598
- y(This)c(should)f(giv)m(e)j(some)g(feel)f(for)g(ho)m(w)h(the)g
- (high-lev)m(el)e(in)m(terface)i(can)f(b)s(e)g(used.)39
- b(If)27 b(y)m(ou)h(require)e(extra)150 1708 y( 15exibilit)m(y)-8
- b(,)28 b(y)m(ou'll)i(ha)m(v)m(e)h(to)g(bite)f(the)h(bullet)d(and)i(get)
- i(to)f(grips)e(with)g(the)h(lo)m(w-lev)m(el)h(in)m(terface.)150
- 1987 y Ff(3.4.9)63 b(Standard)40 b( 14le-reading/writing)j(co)s(de)150
- 2179 y Fl(Here's)31 b(ho)m(w)f(y)m(ou'd)h(write)e(data)j(to)f(a)f
- (compressed)g( 14le:)390 2538 y Fj(FILE*)142 b(f;)390
- 2642 y(BZFILE*)46 b(b;)390 2746 y(int)238 b(nBuf;)390
- 2849 y(char)190 b(buf[)46 b(/*)i(whatever)d(size)i(you)g(like)f(*/)i
- (];)390 2953 y(int)238 b(bzerror;)390 3057 y(int)g(nWritten;)390
- 3264 y(f)47 b(=)h(fopen)e(()i("myfile.bz2",)c("w")j();)390
- 3368 y(if)g((!f))g({)533 3472 y(/*)g(handle)f(error)h(*/)390
- 3576 y(})390 3680 y(b)g(=)h(bzWriteOpen)d(()i(&bzerror,)e(f,)j(9)f
- ();)390 3783 y(if)g((bzerror)f(!=)h(BZ_OK))f({)533
- 3887 y(bzWriteClose)f(()i(b)h();)533 3991 y(/*)f(handle)f(error)h(*/)
- 390 4095 y(})390 4302 y(while)f(()i(/*)f(condition)e(*/)i())h({)533
- 4406 y(/*)f(get)g(data)g(to)g(write)f(into)h(buf,)g(and)g(set)g(nBuf)f
- (appropriately)e(*/)533 4510 y(nWritten)i(=)h(bzWrite)f(()h(&bzerror,)
- f(b,)h(buf,)g(nBuf)f();)533 4614 y(if)h((bzerror)f(==)h
- (BZ_IO_ERROR))e({)676 4717 y(bzWriteClose)g(()i(&bzerror,)f(b)h();)
- 676 4821 y(/*)h(handle)e(error)g(*/)533 4925 y(})390
- 5029 y(})390 5236 y(bzWriteClose)e(()k(&bzerror,)d(b)j();)390
- 5340 y(if)f((bzerror)f(==)h(BZ_IO_ERROR))d({)p eop
- %%Page: 27 28
- 27 27 bop 150 -116 a Fl(Chapter)30 b(3:)41 b(Programming)29
- b(with)g Fj(libbzip2)1881 b Fl(27)533 366 y Fj(/*)47
- b(handle)f(error)h(*/)390 470 y(})150 627 y Fl(And)29
- b(to)j(read)e(from)g(a)h(compressed)f( 14le:)390 778
- y Fj(FILE*)142 b(f;)390 882 y(BZFILE*)46 b(b;)390 986
- y(int)238 b(nBuf;)390 1089 y(char)190 b(buf[)46 b(/*)i(whatever)d(size)
- i(you)g(like)f(*/)i(];)390 1193 y(int)238 b(bzerror;)390
- 1297 y(int)g(nWritten;)390 1505 y(f)47 b(=)h(fopen)e(()i
- ("myfile.bz2",)c("r")j();)390 1608 y(if)g((!f))g({)533
- 1712 y(/*)g(handle)f(error)h(*/)390 1816 y(})390 1920
- y(b)g(=)h(bzReadOpen)d(()i(&bzerror,)f(f,)h(0,)g(NULL,)f(0)i();)390
- 2023 y(if)f((bzerror)f(!=)h(BZ_OK))f({)533 2127 y(bzReadClose)f(()i
- (&bzerror,)f(b)h();)533 2231 y(/*)g(handle)f(error)h(*/)390
- 2335 y(})390 2542 y(bzerror)f(=)h(BZ_OK;)390 2646 y(while)f((bzerror)g
- (==)h(BZ_OK)f(&&)i(/*)f(arbitrary)e(other)h(conditions)f(*/))i({)533
- 2750 y(nBuf)g(=)g(bzRead)f(()i(&bzerror,)d(b,)i(buf,)g(/*)g(size)g(of)
- g(buf)g(*/)g();)533 2854 y(if)g((bzerror)f(==)h(BZ_OK))f({)676
- 2957 y(/*)i(do)f(something)e(with)i(buf[0)f(..)h(nBuf-1])f(*/)533
- 3061 y(})390 3165 y(})390 3269 y(if)h((bzerror)f(!=)h(BZ_STREAM_END))
- d({)533 3373 y(bzReadClose)h(()i(&bzerror,)f(b)h();)533
- 3476 y(/*)g(handle)f(error)h(*/)390 3580 y(})g(else)g({)533
- 3684 y(bzReadClose)e(()i(&bzerror)f();)390 3788 y(})150
- 4176 y Fk(3.5)68 b(Utilit)l(y)47 b(functions)150 4531
- y Ff(3.5.1)63 b Fe(bzBuffToBuffCompress)533 4717 y Fj(int)47
- b(bzBuffToBuffCompress()42 b(char*)428 b(dest,)1774
- 4821 y(unsigned)46 b(int*)g(destLen,)1774 4925 y(char*)428
- b(source,)1774 5029 y(unsigned)46 b(int)94 b(sourceLen,)1774
- 5132 y(int)524 b(blockSize100k,)1774 5236 y(int)g(verbosity,)1774
- 5340 y(int)g(workFactor)45 b();)p eop
- %%Page: 28 29
- 28 28 bop 150 -116 a Fl(Chapter)30 b(3:)41 b(Programming)29
- b(with)g Fj(libbzip2)1881 b Fl(28)150 366 y(A)m(ttempts)33
- b(to)g(compress)f(the)g(data)h(in)e Fj(source[0)d(..)i(sourceLen-1])e
- Fl(in)m(to)k(the)h(destination)e(bu 13er,)150 476 y
- Fj(dest[0)e(..)g(*destLen-1])p Fl(.)37 b(If)26 b(the)g(destination)g
- (bu 13er)f(is)h(big)f(enough,)j Fj(*destLen)c Fl(is)h(set)i(to)g(the)g
- (size)150 586 y(of)i(the)f(compressed)h(data,)g(and)f
- Fj(BZ_OK)f Fl(is)h(returned.)39 b(If)28 b(the)h(compressed)f(data)h(w)m
- (on't)g( 14t,)g Fj(*destLen)150 695 y Fl(is)g(unc)m(hanged,)i(and)e
- Fj(BZ_OUTBUFF_FULL)e Fl(is)i(returned.)150 852 y(Compression)22
- b(in)g(this)h(manner)g(is)g(a)h(one-shot)g(ev)m(en)m(t,)j(done)c(with)g
- (a)h(single)e(call)h(to)i(this)d(function.)37 b(The)150
- 962 y(resulting)25 b(compressed)i(data)i(is)d(a)i(complete)f
- Fj(bzip2)f Fl(format)i(data)g(stream.)40 b(There)27 b(is)f(no)i(mec)m
- (hanism)150 1071 y(for)23 b(making)g(additional)e(calls)i(to)h(pro)m
- (vide)f(extra)h(input)e(data.)39 b(If)23 b(y)m(ou)h(w)m(an)m(t)g(that)g
- (kind)e(of)h(mec)m(hanism,)150 1181 y(use)30 b(the)h(lo)m(w-lev)m(el)f
- (in)m(terface.)150 1338 y(F)-8 b(or)31 b(the)g(meaning)e(of)i
- (parameters)g Fj(blockSize100k)p Fl(,)c Fj(verbosity)g
- Fl(and)j Fj(workFactor)p Fl(,)150 1447 y(see)h Fj(bzCompressInit)p
- Fl(.)150 1604 y(T)-8 b(o)27 b(guaran)m(tee)h(that)e(the)h(compressed)f
- (data)h(will)d( 14t)i(in)f(its)g(bu 13er,)i(allo)s(cate)f(an)g
- (output)g(bu 13er)g(of)g(size)150 1714 y(1 45)31 b(larger)f(than)g
- (the)g(uncompressed)f(data,)j(plus)c(six)h(h)m(undred)g(extra)i(b)m
- (ytes.)150 1871 y Fj(bzBuffToBuffDecompress)25 b Fl(will)k(not)i(write)
- g(data)h(at)g(or)f(b)s(ey)m(ond)f Fj(dest[*destLen])p
- Fl(,)e(ev)m(en)k(in)e(case)150 1980 y(of)h(bu 13er)e(o)m(v)m(er 15o)m
- (w.)150 2137 y(P)m(ossible)g(return)h(v)-5 b(alues:)572
- 2288 y Fj(BZ_PARAM_ERROR)663 2392 y Fl(if)29 b Fj(dest)g
- Fl(is)h Fj(NULL)f Fl(or)h Fj(destLen)f Fl(is)g Fj(NULL)663
- 2496 y Fl(or)h Fj(blockSize100k)44 b(<)k(1)30 b Fl(or)g
- Fj(blockSize100k)44 b(>)k(9)663 2599 y Fl(or)30 b Fj(verbosity)45
- b(<)j(0)30 b Fl(or)g Fj(verbosity)45 b(>)j(4)663 2703
- y Fl(or)30 b Fj(workFactor)45 b(<)j(0)30 b Fl(or)g Fj(workFactor)45
- b(>)i(250)572 2807 y(BZ_MEM_ERROR)663 2911 y Fl(if)29
- b(insu 16cien)m(t)g(memory)h(is)f(a)m(v)-5 b(ailable)572
- 3014 y Fj(BZ_OUTBUFF_FULL)663 3118 y Fl(if)29 b(the)i(size)f(of)g(the)h
- (compressed)f(data)h(exceeds)g Fj(*destLen)572 3222 y(BZ_OK)663
- 3326 y Fl(otherwise)150 3725 y Ff(3.5.2)63 b Fe(bzBuffToBuffDecompress)
- 533 3912 y Fj(int)47 b(bzBuffToBuffDecompress)42 b(()47
- b(char*)428 b(dest,)1917 4016 y(unsigned)46 b(int*)g(destLen,)1917
- 4120 y(char*)428 b(source,)1917 4224 y(unsigned)46 b(int)94
- b(sourceLen,)1917 4327 y(int)524 b(small,)1917 4431 y(int)g(verbosity)
- 46 b();)150 4588 y Fl(A)m(ttempts)24 b(to)g(decompress)f(the)g(data)g
- (in)f Fj(source[0)28 b(..)i(sourceLen-1])20 b Fl(in)m(to)j(the)g
- (destination)f(bu 13er,)150 4698 y Fj(dest[0)29 b(..)g(*destLen-1])p
- Fl(.)37 b(If)26 b(the)g(destination)g(bu 13er)f(is)h(big)f(enough,)j
- Fj(*destLen)c Fl(is)h(set)i(to)g(the)g(size)150 4807
- y(of)21 b(the)g(uncompressed)e(data,)24 b(and)c Fj(BZ_OK)f
- Fl(is)h(returned.)36 b(If)20 b(the)h(compressed)g(data)g(w)m(on't)h
- ( 14t,)g Fj(*destLen)150 4917 y Fl(is)29 b(unc)m(hanged,)i(and)e
- Fj(BZ_OUTBUFF_FULL)e Fl(is)i(returned.)150 5074 y Fj(source)19
- b Fl(is)g(assumed)h(to)i(hold)d(a)i(complete)g Fj(bzip2)e
- Fl(format)i(data)g(stream.)38 b Fj(bzBuffToBuffDecompress)150
- 5183 y Fl(tries)30 b(to)h(decompress)f(the)h(en)m(tiret)m(y)g(of)f(the)
- h(stream)f(in)m(to)h(the)f(output)g(bu 13er.)150 5340
- y(F)-8 b(or)31 b(the)g(meaning)e(of)i(parameters)g Fj(small)e
- Fl(and)g Fj(verbosity)p Fl(,)f(see)j Fj(bzDecompressInit)p
- Fl(.)p eop
- %%Page: 29 30
- 29 29 bop 150 -116 a Fl(Chapter)30 b(3:)41 b(Programming)29
- b(with)g Fj(libbzip2)1881 b Fl(29)150 366 y(Because)34
- b(the)f(compression)e(ratio)i(of)g(the)g(compressed)f(data)h(cannot)g
- (b)s(e)f(kno)m(wn)g(in)g(adv)-5 b(ance,)34 b(there)150
- 476 y(is)d(no)h(easy)g(w)m(a)m(y)h(to)f(guaran)m(tee)i(that)e(the)g
- (output)f(bu 13er)g(will)e(b)s(e)i(big)g(enough.)45
- b(Y)-8 b(ou)32 b(ma)m(y)h(of)f(course)150 586 y(mak)m(e)k(arrangemen)m
- (ts)f(in)e(y)m(our)i(co)s(de)g(to)g(record)g(the)g(size)f(of)h(the)g
- (uncompressed)f(data,)i(but)e(suc)m(h)h(a)150 695 y(mec)m(hanism)30
- b(is)f(b)s(ey)m(ond)h(the)g(scop)s(e)h(of)f(this)g(library)-8
- b(.)150 852 y Fj(bzBuffToBuffDecompress)25 b Fl(will)k(not)i(write)g
- (data)h(at)g(or)f(b)s(ey)m(ond)f Fj(dest[*destLen])p
- Fl(,)e(ev)m(en)k(in)e(case)150 962 y(of)h(bu 13er)e(o)m(v)m(er 15o)m
- (w.)150 1119 y(P)m(ossible)g(return)h(v)-5 b(alues:)572
- 1270 y Fj(BZ_PARAM_ERROR)663 1373 y Fl(if)29 b Fj(dest)g
- Fl(is)h Fj(NULL)f Fl(or)h Fj(destLen)f Fl(is)g Fj(NULL)663
- 1477 y Fl(or)h Fj(small)46 b(!=)i(0)f(&&)g(small)g(!=)g(1)663
- 1581 y Fl(or)30 b Fj(verbosity)45 b(<)j(0)30 b Fl(or)g
- Fj(verbosity)45 b(>)j(4)572 1685 y(BZ_MEM_ERROR)663 1788
- y Fl(if)29 b(insu 16cien)m(t)g(memory)h(is)f(a)m(v)-5
- b(ailable)572 1892 y Fj(BZ_OUTBUFF_FULL)663 1996 y Fl(if)29
- b(the)i(size)f(of)g(the)h(compressed)f(data)h(exceeds)g
- Fj(*destLen)572 2100 y(BZ_DATA_ERROR)663 2204 y Fl(if)e(a)i(data)g(in)m
- (tegrit)m(y)f(error)g(w)m(as)h(detected)h(in)d(the)h(compressed)g(data)
- 572 2307 y Fj(BZ_DATA_ERROR_MAGIC)663 2411 y Fl(if)f(the)i(compressed)f
- (data)h(do)s(esn't)f(b)s(egin)f(with)g(the)i(righ)m(t)e(magic)i(b)m
- (ytes)572 2515 y Fj(BZ_UNEXPECTED_EOF)663 2619 y Fl(if)e(the)i
- (compressed)f(data)h(ends)e(unexp)s(ectedly)572 2722
- y Fj(BZ_OK)663 2826 y Fl(otherwise)150 3141 y Fk(3.6)68
- b(Using)46 b(the)f(library)g(in)g(a)g Fd(stdio)p Fk(-free)f(en)l
- (vironmen)l(t)150 3447 y Ff(3.6.1)63 b(Getting)40 b(rid)h(of)g
- Fe(stdio)150 3640 y Fl(In)i(a)g(deeply)g(em)m(b)s(edded)f(application,)
- j(y)m(ou)f(migh)m(t)f(w)m(an)m(t)h(to)g(use)f(just)g(the)h
- (memory-to-memory)150 3749 y(functions.)39 b(Y)-8 b(ou)30
- b(can)f(do)g(this)g(con)m(v)m(enien)m(tly)g(b)m(y)g(compiling)e(the)j
- (library)d(with)h(prepro)s(cessor)g(sym)m(b)s(ol)150
- 3859 y Fj(BZ_NO_STDIO)35 b Fl(de 14ned.)63 b(Doing)39
- b(this)e(giv)m(es)h(y)m(ou)h(a)f(library)e(con)m(taining)i(only)f(the)i
- (follo)m(wing)e(eigh)m(t)150 3968 y(functions:)150 4125
- y Fj(bzCompressInit)p Fl(,)27 b Fj(bzCompress)p Fl(,)h
- Fj(bzCompressEnd)150 4235 y(bzDecompressInit)p Fl(,)e
- Fj(bzDecompress)p Fl(,)h Fj(bzDecompressEnd)150 4344
- y(bzBuffToBuffCompress)p Fl(,)e Fj(bzBuffToBuffDecompress)150
- 4501 y Fl(When)30 b(compiled)f(lik)m(e)h(this,)f(all)g(functions)g
- (will)f(ignore)i Fj(verbosity)e Fl(settings.)150 4771
- y Ff(3.6.2)63 b(Critical)40 b(error)h(handling)150 4964
- y Fj(libbzip2)20 b Fl(con)m(tains)j(a)g(n)m(um)m(b)s(er)f(of)g(in)m
- (ternal)g(assertion)g(c)m(hec)m(ks)i(whic)m(h)d(should,)i(needless)f
- (to)h(sa)m(y)-8 b(,)26 b(nev)m(er)150 5074 y(b)s(e)g(activ)-5
- b(ated.)40 b(Nev)m(ertheless,)28 b(if)d(an)i(assertion)f(should)e
- (fail,)i(b)s(eha)m(viour)f(dep)s(ends)f(on)j(whether)e(or)i(not)150
- 5183 y(the)k(library)d(w)m(as)i(compiled)f(with)g Fj(BZ_NO_STDIO)e
- Fl(set.)150 5340 y(F)-8 b(or)31 b(a)g(normal)e(compile,)h(an)g
- (assertion)g(failure)f(yields)f(the)j(message)p eop
- %%Page: 30 31
- 30 30 bop 150 -116 a Fl(Chapter)30 b(3:)41 b(Programming)29
- b(with)g Fj(libbzip2)1881 b Fl(30)533 366 y Fj(bzip2/libbzip2,)44
- b(v0.9.0:)i(internal)f(error)i(number)f(N.)533 470 y(This)h(is)g(a)g
- (bug)g(in)h(bzip2/libbzip2,)43 b(v0.9.0.)94 b(Please)46
- b(report)533 574 y(it)h(to)h(me)f(at:)g(jseward@acm.org.)91
- b(If)47 b(this)g(happened)e(when)533 678 y(you)i(were)g(using)f(some)h
- (program)f(which)g(uses)h(libbzip2)e(as)i(a)533 782 y(component,)e(you)
- i(should)f(also)h(report)f(this)h(bug)f(to)i(the)f(author(s))533
- 885 y(of)g(that)g(program.)93 b(Please)46 b(make)h(an)g(effort)f(to)h
- (report)g(this)f(bug;)533 989 y(timely)g(and)h(accurate)f(bug)h
- (reports)e(eventually)g(lead)i(to)g(higher)533 1093 y(quality)f
- (software.)93 b(Thx.)h(Julian)46 b(Seward,)g(27)h(June)g(1998.)150
- 1250 y Fl(where)30 b Fj(N)g Fl(is)f(some)i(error)f(co)s(de)h(n)m(um)m
- (b)s(er.)39 b Fj(exit(3))28 b Fl(is)i(then)g(called.)150
- 1407 y(F)-8 b(or)31 b(a)g Fj(stdio)p Fl(-free)e(library)-8
- b(,)29 b(assertion)h(failures)e(result)i(in)f(a)i(call)e(to)i(a)g
- (function)e(declared)h(as:)533 1558 y Fj(extern)46 b(void)h
- (bz_internal_error)c(()k(int)g(errcode)f();)150 1714
- y Fl(The)30 b(relev)-5 b(an)m(t)31 b(co)s(de)f(is)g(passed)f(as)i(a)g
- (parameter.)41 b(Y)-8 b(ou)31 b(should)d(supply)g(suc)m(h)i(a)h
- (function.)150 1871 y(In)g(either)g(case,)j(once)e(an)g(assertion)g
- (failure)e(has)h(o)s(ccurred,)h(an)m(y)g Fj(bz_stream)e
- Fl(records)h(in)m(v)m(olv)m(ed)h(can)150 1981 y(b)s(e)e(regarded)g(as)h
- (in)m(v)-5 b(alid.)38 b(Y)-8 b(ou)31 b(should)d(not)j(attempt)g(to)g
- (resume)f(normal)g(op)s(eration)f(with)g(them.)150 2138
- y(Y)-8 b(ou)22 b(ma)m(y)-8 b(,)25 b(of)d(course,)h(c)m(hange)g
- (critical)e(error)g(handling)e(to)j(suit)f(y)m(our)g(needs.)38
- b(As)21 b(I)h(said)e(ab)s(o)m(v)m(e,)25 b(critical)150
- 2247 y(errors)30 b(indicate)g(bugs)g(in)g(the)h(library)d(and)i(should)
- f(not)i(o)s(ccur.)42 b(All)29 b Fj(")p Fl(normal)p Fj(")h
- Fl(error)g(situations)g(are)150 2357 y(indicated)f(via)h(error)g
- (return)f(co)s(des)i(from)f(functions,)f(and)g(can)i(b)s(e)f(reco)m(v)m
- (ered)i(from.)150 2637 y Fk(3.7)68 b(Making)45 b(a)g(Windo)l(ws)h(DLL)
- 150 2829 y Fl(Ev)m(erything)30 b(related)g(to)h(Windo)m(ws)f(has)g(b)s
- (een)f(con)m(tributed)h(b)m(y)g(Y)-8 b(oshiok)j(a)31
- b(Tsuneo)150 2939 y(()p Fj(QWF00133@niftyserve.or.jp)46
- b Fl(/)52 b Fj(tsuneo-y@is.aist-nara.ac.j)o(p)p Fl(),)g(so)h(y)m(ou)f
- (should)f(send)150 3048 y(y)m(our)30 b(queries)g(to)h(him)e((but)h(p)s
- (erhaps)e(Cc:)41 b(me,)31 b Fj(jseward@acm.org)p Fl().)150
- 3205 y(My)43 b(v)-5 b(ague)44 b(understanding)d(of)i(what)g(to)h(do)f
- (is:)65 b(using)41 b(Visual)h(C)p Fj(++)g Fl(5.0,)48
- b(op)s(en)42 b(the)h(pro)5 b(ject)44 b( 14le)150 3315
- y Fj(libbz2.dsp)p Fl(,)28 b(and)i(build.)37 b(That's)31
- b(all.)150 3472 y(If)41 b(y)m(ou)g(can't)h(op)s(en)e(the)h(pro)5
- b(ject)42 b( 14le)e(for)h(some)g(reason,)j(mak)m(e)e(a)g(new)e(one,)k
- (naming)c(these)i( 14les:)150 3581 y Fj(blocksort.c)p
- Fl(,)28 b Fj(bzlib.c)p Fl(,)g Fj(compress.c)p Fl(,)g
- Fj(crctable.c)p Fl(,)g Fj(decompress.c)p Fl(,)f Fj(huffman.c)p
- Fl(,)150 3691 y Fj(randtable.c)f Fl(and)j Fj(libbz2.def)p
- Fl(.)38 b(Y)-8 b(ou)29 b(migh)m(t)g(also)h(need)f(to)h(name)f(the)h
- (header)f( 14les)f Fj(bzlib.h)g Fl(and)150 3800 y Fj(bzlib_private.h)p
- Fl(.)150 3957 y(If)i(y)m(ou)h(don't)f(use)g(V)m(C)p Fj(++)p
- Fl(,)g(y)m(ou)h(ma)m(y)g(need)f(to)h(de 14ne)f(the)h(propro)s(cessor)e
- (sym)m(b)s(ol)g Fj(_WIN32)p Fl(.)150 4114 y(Finally)-8
- b(,)28 b Fj(dlltest.c)e Fl(is)h(a)i(sample)f(program)g(using)g(the)g
- (DLL.)h(It)g(has)f(a)h(pro)5 b(ject)29 b( 14le,)g Fj(dlltest.dsp)p
- Fl(.)150 4271 y(I)h(ha)m(v)m(en't)i(tried)d(an)m(y)i(of)g(this)e
- (stu 13)h(m)m(yself,)g(but)g(it)f(all)h(lo)s(oks)g(plausible.)p
- eop
- %%Page: 31 32
- 31 31 bop 150 -116 a Fl(Chapter)30 b(4:)41 b(Miscellanea)2586
- b(31)150 366 y Fh(4)80 b(Miscellanea)150 594 y Fl(These)30
- b(are)h(just)f(some)g(random)g(though)m(ts)h(of)f(mine.)40
- b(Y)-8 b(our)30 b(mileage)h(ma)m(y)g(v)-5 b(ary)d(.)150
- 860 y Fk(4.1)68 b(Limitations)47 b(of)e(the)g(compressed)g( 14le)h
- (format)150 1052 y Fj(bzip2-0.9.0)21 b Fl(uses)j(exactly)h(the)f(same)g
- ( 14le)g(format)g(as)g(the)h(previous)d(v)m(ersion,)j
- Fj(bzip2-0.1)p Fl(.)36 b(This)23 b(de-)150 1162 y(cision)j(w)m(as)i
- (made)g(in)e(the)i(in)m(terests)g(of)g(stabilit)m(y)-8
- b(.)39 b(Creating)27 b(y)m(et)i(another)f(incompatible)d(compressed)150
- 1271 y( 14le)k(format)i(w)m(ould)e(create)j(further)d(confusion)g(and)
- h(disruption)d(for)j(users.)150 1428 y(Nev)m(ertheless,)h(this)e(is)g
- (not)h(a)g(painless)e(decision.)39 b(Dev)m(elopmen)m(t)31
- b(w)m(ork)f(since)f(the)h(release)h(of)f Fj(bzip2-)150
- 1538 y(0.1)19 b Fl(in)g(August)i(1997)h(has)e(sho)m(wn)f(complexities)h
- (in)f(the)h( 14le)g(format)g(whic)m(h)f(slo)m(w)h(do)m(wn)g
- (decompression)150 1647 y(and,)30 b(in)f(retrosp)s(ect,)i(are)g
- (unnecessary)-8 b(.)40 b(These)31 b(are:)225 1804 y Fi( 17)60
- b Fl(The)20 b(run-length)g(enco)s(der,)i(whic)m(h)e(is)g(the)h( 14rst)
- f(of)h(the)g(compression)f(transformations,)i(is)e(en)m(tirely)330
- 1914 y(irrelev)-5 b(an)m(t.)63 b(The)38 b(original)e(purp)s(ose)g(w)m
- (as)j(to)g(protect)g(the)f(sorting)g(algorithm)f(from)g(the)i(v)m(ery)
- 330 2023 y(w)m(orst)h(case)h(input:)58 b(a)41 b(string)e(of)h(rep)s
- (eated)g(sym)m(b)s(ols.)68 b(But)40 b(algorithm)f(steps)h(Q6a)h(and)e
- (Q6b)330 2133 y(in)30 b(the)i(original)e(Burro)m(ws-Wheeler)i(tec)m
- (hnical)g(rep)s(ort)f((SR)m(C-124))i(sho)m(w)f(ho)m(w)g(rep)s(eats)g
- (can)g(b)s(e)330 2243 y(handled)c(without)i(di 16cult)m(y)f(in)g(blo)s
- (c)m(k)h(sorting.)225 2370 y Fi( 17)60 b Fl(The)30 b(randomisation)e
- (mec)m(hanism)i(do)s(esn't)g(really)f(need)h(to)g(b)s(e)g(there.)41
- b(Udi)29 b(Man)m(b)s(er)h(and)f(Gene)330 2479 y(My)m(ers)j(published)c
- (a)33 b(su 16x)e(arra)m(y)h(construction)f(algorithm)g(a)h(few)g(y)m
- (ears)h(bac)m(k,)g(whic)m(h)d(can)j(b)s(e)330 2589 y(emplo)m(y)m(ed)27
- b(to)h(sort)g(an)m(y)f(blo)s(c)m(k,)h(no)f(matter)h(ho)m(w)f(rep)s
- (etitiv)m(e,)h(in)d(O(N)j(log)f(N))h(time.)39 b(Subsequen)m(t)330
- 2699 y(w)m(ork)25 b(b)m(y)f(Kunihik)m(o)f(Sadak)-5 b(ane)24
- b(has)h(pro)s(duced)e(a)i(deriv)-5 b(ativ)m(e)24 b(O(N)h((log)g(N))p
- Fj(^)p Fl(2))h(algorithm)d(whic)m(h)330 2808 y(usually)28
- b(outp)s(erforms)h(the)i(Man)m(b)s(er-My)m(ers)g(algorithm.)330
- 2936 y(I)g(could)g(ha)m(v)m(e)i(c)m(hanged)f(to)g(Sadak)-5
- b(ane's)32 b(algorithm,)f(but)g(I)g( 14nd)f(it)h(to)h(b)s(e)f(slo)m(w)
- m(er)h(than)f Fj(bzip2)p Fl('s)330 3045 y(existing)38
- b(algorithm)g(for)h(most)h(inputs,)f(and)g(the)g(randomisation)f(mec)m
- (hanism)g(protects)i(ade-)330 3155 y(quately)34 b(against)f(bad)g
- (cases.)52 b(I)33 b(didn't)f(think)g(it)i(w)m(as)g(a)g(go)s(o)s(d)f
- (tradeo 13)i(to)f(mak)m(e.)51 b(P)m(artly)34 b(this)330
- 3264 y(is)39 b(due)h(to)h(the)f(fact)h(that)g(I)f(w)m(as)g(not)h( 15o)
- s(o)s(ded)e(with)g(email)g(complain)m(ts)g(ab)s(out)h
- Fj(bzip2-0.1)p Fl('s)330 3374 y(p)s(erformance)30 b(on)g(rep)s(etitiv)m
- (e)g(data,)h(so)g(p)s(erhaps)d(it)i(isn't)g(a)h(problem)d(for)j(real)f
- (inputs.)330 3501 y(Probably)h(the)h(b)s(est)g(long-term)h(solution)d
- (is)i(to)h(use)f(the)g(existing)g(sorting)f(algorithm)h(initially)-8
- b(,)330 3611 y(and)32 b(fall)g(bac)m(k)i(to)g(a)f(O(N)g((log)h(N))p
- Fj(^)p Fl(2))g(algorithm)e(if)g(the)h(standard)f(algorithm)g(gets)i
- (in)m(to)f(di 16-)330 3720 y(culties.)39 b(This)27 b(can)j(b)s(e)e
- (done)h(without)f(m)m(uc)m(h)h(di 16cult)m(y;)f(I)g(made)h(a)h(protot)
- m(yp)s(e)f(implemen)m(tation)330 3830 y(of)i(it)e(some)i(mon)m(ths)f
- (no)m(w.)225 3957 y Fi( 17)60 b Fl(The)31 b(compressed)f( 14le)g
- (format)i(w)m(as)f(nev)m(er)h(designed)d(to)j(b)s(e)f(handled)e(b)m(y)i
- (a)g(library)-8 b(,)29 b(and)i(I)g(ha)m(v)m(e)330 4067
- y(had)d(to)i(jump)e(though)g(some)i(ho)s(ops)e(to)i(pro)s(duce)e(an)h
- (e 16cien)m(t)g(implemen)m(tation)f(of)h(decompres-)330
- 4177 y(sion.)38 b(It's)26 b(a)h(bit)e(hairy)-8 b(.)38
- b(T)-8 b(ry)26 b(passing)f Fj(decompress.c)d Fl(through)k(the)g(C)f
- (prepro)s(cessor)g(and)h(y)m(ou'll)330 4286 y(see)32
- b(what)g(I)f(mean.)45 b(Muc)m(h)32 b(of)g(this)e(complexit)m(y)i(could)
- f(ha)m(v)m(e)i(b)s(een)e(a)m(v)m(oided)h(if)e(the)i(compressed)330
- 4396 y(size)e(of)h(eac)m(h)g(blo)s(c)m(k)f(of)h(data)g(w)m(as)g
- (recorded)f(in)f(the)h(data)h(stream.)225 4523 y Fi( 17)60
- b Fl(An)30 b(Adler-32)g(c)m(hec)m(ksum,)i(rather)e(than)g(a)h(CR)m(C32)
- g(c)m(hec)m(ksum,)g(w)m(ould)e(b)s(e)h(faster)h(to)g(compute.)150
- 4698 y(It)e(w)m(ould)f(b)s(e)g(fair)g(to)h(sa)m(y)h(that)g(the)f
- Fj(bzip2)e Fl(format)i(w)m(as)h(frozen)f(b)s(efore)f(I)h(prop)s(erly)d
- (and)j(fully)d(under-)150 4807 y(sto)s(o)s(d)k(the)h(p)s(erformance)e
- (consequences)i(of)g(doing)e(so.)150 4964 y(Impro)m(v)m(emen)m(ts)i
- (whic)m(h)f(I)g(ha)m(v)m(e)i(b)s(een)e(able)g(to)i(incorp)s(orate)e(in)
- m(to)g(0.9.0,)j(despite)d(using)f(the)i(same)g( 14le)150
- 5074 y(format,)g(are:)225 5230 y Fi( 17)60 b Fl(Single)30
- b(arra)m(y)i(implemen)m(tation)e(of)h(the)h(in)m(v)m(erse)f(BWT.)h
- (This)e(signi 14can)m(tly)f(sp)s(eeds)i(up)f(decom-)330
- 5340 y(pression,)f(presumably)f(b)s(ecause)i(it)g(reduces)g(the)h(n)m
- (um)m(b)s(er)e(of)i(cac)m(he)h(misses.)p eop
- %%Page: 32 33
- 32 32 bop 150 -116 a Fl(Chapter)30 b(4:)41 b(Miscellanea)2586
- b(32)225 366 y Fi( 17)60 b Fl(F)-8 b(aster)27 b(in)m(v)m(erse)e(MTF)h
- (transform)f(for)g(large)h(MTF)f(v)-5 b(alues.)39 b(The)25
- b(new)g(implemen)m(tation)f(is)g(based)330 476 y(on)30
- b(the)h(notion)f(of)g(sliding)e(blo)s(c)m(ks)h(of)i(v)-5
- b(alues.)225 636 y Fi( 17)60 b Fj(bzip2-0.9.0)24 b Fl(no)m(w)k(reads)f
- (and)f(writes)h( 14les)f(with)g Fj(fread)g Fl(and)h
- Fj(fwrite)p Fl(;)f(v)m(ersion)h(0.1)i(used)d Fj(putc)330
- 746 y Fl(and)k Fj(getc)p Fl(.)39 b(Duh!)h(I'm)31 b(em)m(barrassed)f(at)
- h(m)m(y)f(o)m(wn)h(moronicness)e((moronicit)m(y?))41
- b(on)30 b(this)f(one.)150 953 y(F)-8 b(urther)30 b(ahead,)g(it)f(w)m
- (ould)g(b)s(e)g(nice)h(to)g(b)s(e)g(able)f(to)i(do)e(random)g(access)j
- (in)m(to)d( 14les.)40 b(This)28 b(will)f(require)150
- 1062 y(some)k(careful)e(design)h(of)g(compressed)g( 14le)g(formats.)
- 150 1419 y Fk(4.2)68 b(P)l(ortabilit)l(y)47 b(issues)150
- 1611 y Fl(After)31 b(some)f(consideration,)g(I)g(ha)m(v)m(e)i(decided)d
- (not)i(to)g(use)f(GNU)h Fj(autoconf)d Fl(to)j(con 14gure)f(0.9.0.)150
- 1768 y Fj(autoconf)p Fl(,)h(admirable)g(and)h(w)m(onderful)f(though)i
- (it)f(is,)h(mainly)d(assists)j(with)e(p)s(ortabilit)m(y)g(problems)150
- 1878 y(b)s(et)m(w)m(een)f(Unix-lik)m(e)d(platforms.)40
- b(But)29 b Fj(bzip2)f Fl(do)s(esn't)h(ha)m(v)m(e)h(m)m(uc)m(h)f(in)f
- (the)h(w)m(a)m(y)h(of)g(p)s(ortabilit)m(y)d(prob-)150
- 1987 y(lems)35 b(on)h(Unix;)j(most)d(of)g(the)h(di 16culties)d(app)s
- (ear)h(when)g(p)s(orting)g(to)i(the)f(Mac,)j(or)d(to)h(Microsoft's)150
- 2097 y(op)s(erating)26 b(systems.)40 b Fj(autoconf)25
- b Fl(do)s(esn't)h(help)g(in)f(those)j(cases,)h(and)d(brings)f(in)g(a)j
- (whole)e(load)g(of)h(new)150 2206 y(complexit)m(y)-8
- b(.)150 2363 y(Most)28 b(p)s(eople)f(should)f(b)s(e)h(able)g(to)h
- (compile)e(the)i(library)d(and)i(program)h(under)e(Unix)g(straigh)m(t)i
- (out-of-)150 2473 y(the-b)s(o)m(x,)j(so)g(to)g(sp)s(eak,)f(esp)s
- (ecially)f(if)g(y)m(ou)i(ha)m(v)m(e)g(a)g(v)m(ersion)f(of)g(GNU)h(C)f
- (a)m(v)-5 b(ailable.)150 2630 y(There)32 b(are)h(a)g(couple)f(of)h
- Fj(__inline__)d Fl(directiv)m(es)i(in)f(the)i(co)s(de.)48
- b(GNU)33 b(C)f(()p Fj(gcc)p Fl())g(should)f(b)s(e)h(able)g(to)150
- 2739 y(handle)26 b(them.)40 b(If)28 b(y)m(our)g(compiler)e(do)s(esn't)i
- (lik)m(e)f(them,)h(just)g Fj(#define)e(__inline__)f Fl(to)j(b)s(e)g(n)m
- (ull.)37 b(One)150 2849 y(easy)27 b(w)m(a)m(y)g(to)g(do)f(this)e(is)i
- (to)g(compile)f(with)g(the)h( 15ag)h Fj(-D__inline__=)p
- Fl(,)c(whic)m(h)i(should)f(b)s(e)i(understo)s(o)s(d)150
- 2958 y(b)m(y)k(most)h(Unix)e(compilers.)150 3115 y(If)35
- b(y)m(ou)g(still)e(ha)m(v)m(e)j(di 16culties,)e(try)h(compiling)e
- (with)g(the)j(macro)f Fj(BZ_STRICT_ANSI)c Fl(de 14ned.)54
- b(This)150 3225 y(should)28 b(enable)i(y)m(ou)h(to)g(build)d(the)i
- (library)e(in)h(a)i(strictly)f(ANSI)g(complian)m(t)f(en)m(vironmen)m
- (t.)41 b(Building)150 3334 y(the)25 b(program)f(itself)f(lik)m(e)g
- (this)h(is)f(dangerous)h(and)g(not)g(supp)s(orted,)g(since)g(y)m(ou)h
- (remo)m(v)m(e)g Fj(bzip2)p Fl('s)e(c)m(hec)m(ks)150 3444
- y(against)30 b(compressing)f(directories,)g(sym)m(b)s(olic)g(links,)f
- (devices,)i(and)f(other)h(not-really-a- 14le)g(en)m(tities.)150
- 3554 y(This)f(could)g(cause)i( 14lesystem)f(corruption!)150
- 3710 y(One)e(other)i(thing:)39 b(if)27 b(y)m(ou)j(create)g(a)f
- Fj(bzip2)f Fl(binary)f(for)i(public)d(distribution,)g(please)i(try)h
- (and)g(link)d(it)150 3820 y(statically)g(()p Fj(gcc)k(-s)p
- Fl().)39 b(This)25 b(a)m(v)m(oids)i(all)f(sorts)h(of)g(library-v)m
- (ersion)d(issues)h(that)i(others)g(ma)m(y)g(encoun)m(ter)150
- 3930 y(later)j(on.)150 4286 y Fk(4.3)68 b(Rep)t(orting)46
- b(bugs)150 4478 y Fl(I)25 b(tried)f(prett)m(y)i(hard)e(to)i(mak)m(e)g
- (sure)f Fj(bzip2)e Fl(is)i(bug)f(free,)j(b)s(oth)d(b)m(y)h(design)f
- (and)h(b)m(y)g(testing.)39 b(Hop)s(efully)150 4588 y(y)m(ou'll)29
- b(nev)m(er)i(need)f(to)h(read)g(this)e(section)h(for)h(real.)150
- 4745 y(Nev)m(ertheless,)36 b(if)c Fj(bzip2)h Fl(dies)g(with)f(a)i
- (segmen)m(tation)h(fault,)g(a)f(bus)f(error)g(or)h(an)g(in)m(ternal)e
- (assertion)150 4854 y(failure,)i(it)h(will)d(ask)j(y)m(ou)g(to)g(email)
- f(me)h(a)g(bug)f(rep)s(ort.)54 b(Exp)s(erience)33 b(with)h(v)m(ersion)g
- (0.1)i(sho)m(ws)e(that)150 4964 y(almost)c(all)g(these)h(problems)d
- (can)j(b)s(e)f(traced)h(to)g(either)f(compiler)e(bugs)i(or)g(hardw)m
- (are)g(problems.)225 5121 y Fi( 17)60 b Fl(Recompile)22
- b(the)h(program)g(with)f(no)h(optimisation,)g(and)f(see)i(if)e(it)g(w)m
- (orks.)39 b(And/or)22 b(try)h(a)g(di 13eren)m(t)330
- 5230 y(compiler.)77 b(I)43 b(heard)f(all)g(sorts)h(of)h(stories)e(ab)s
- (out)h(v)-5 b(arious)42 b( 15a)m(v)m(ours)h(of)h(GNU)f(C)g((and)g
- (other)330 5340 y(compilers))20 b(generating)i(bad)e(co)s(de)i(for)f
- Fj(bzip2)p Fl(,)h(and)f(I'v)m(e)h(run)e(across)i(t)m(w)m(o)g(suc)m(h)f
- (examples)g(m)m(yself.)p eop
- %%Page: 33 34
- 33 33 bop 150 -116 a Fl(Chapter)30 b(4:)41 b(Miscellanea)2586
- b(33)330 366 y(2.7.X)35 b(v)m(ersions)e(of)g(GNU)h(C)f(are)h(kno)m(wn)f
- (to)h(generate)h(bad)d(co)s(de)i(from)f(time)g(to)h(time,)g(at)g(high)
- 330 476 y(optimisation)20 b(lev)m(els.)37 b(If)21 b(y)m(ou)g(get)i
- (problems,)e(try)g(using)f(the)i( 15ags)f Fj(-O2)f
- (-fomit-frame-pointer)330 586 y(-fno-strength-reduce)p
- Fl(.)35 b(Y)-8 b(ou)31 b(should)d(sp)s(eci 14cally)h
- Fc(not)j Fl(use)e Fj(-funroll-loops)p Fl(.)330 716 y(Y)-8
- b(ou)35 b(ma)m(y)g(notice)g(that)h(the)f(Mak)m(e 14le)g(runs)e(four)h
- (tests)i(as)e(part)h(of)g(the)g(build)c(pro)s(cess.)54
- b(If)34 b(the)330 826 y(program)43 b(passes)g(all)f(of)h(these,)k(it's)
- c(a)h(prett)m(y)f(go)s(o)s(d)g((but)g(not)g(100 45))i(indication)c
- (that)j(the)330 935 y(compiler)29 b(has)h(done)g(its)g(job)g(correctly)
- -8 b(.)225 1066 y Fi( 17)60 b Fl(If)33 b Fj(bzip2)f
- Fl(crashes)i(randomly)-8 b(,)33 b(and)g(the)h(crashes)g(are)g(not)g
- (rep)s(eatable,)g(y)m(ou)g(ma)m(y)g(ha)m(v)m(e)h(a)f( 15aky)330
- 1176 y(memory)k(subsystem.)64 b Fj(bzip2)37 b Fl(really)g(hammers)h(y)m
- (our)g(memory)g(hierarc)m(h)m(y)-8 b(,)41 b(and)d(if)f(it's)h(a)h(bit)
- 330 1285 y(marginal,)33 b(y)m(ou)h(ma)m(y)g(get)h(these)f(problems.)49
- b(Ditto)34 b(if)f(y)m(our)h(disk)e(or)h(I/O)h(subsystem)e(is)h(slo)m
- (wly)330 1395 y(failing.)39 b(Y)-8 b(up,)30 b(this)f(really)g(do)s(es)h
- (happ)s(en.)330 1526 y(T)-8 b(ry)28 b(using)f(a)i(di 13eren)m(t)f(mac)
- m(hine)g(of)h(the)g(same)f(t)m(yp)s(e,)i(and)e(see)h(if)e(y)m(ou)i(can)
- g(rep)s(eat)g(the)f(problem.)225 1656 y Fi( 17)60 b
- Fl(This)21 b(isn't)i(really)f(a)h(bug,)i(but)d(...)39
- b(If)23 b Fj(bzip2)f Fl(tells)g(y)m(ou)h(y)m(our)h( 14le)e(is)g
- (corrupted)h(on)g(decompression,)330 1766 y(and)29 b(y)m(ou)g(obtained)
- f(the)i( 14le)e(via)h(FTP)-8 b(,)29 b(there)h(is)e(a)h(p)s(ossibilit)m
- (y)d(that)k(y)m(ou)f(forgot)h(to)g(tell)e(FTP)h(to)330
- 1875 y(do)23 b(a)g(binary)e(mo)s(de)i(transfer.)38 b(That)23
- b(absolutely)f(will)e(cause)j(the)h( 14le)e(to)h(b)s(e)g
- (non-decompressible.)330 1985 y(Y)-8 b(ou'll)30 b(ha)m(v)m(e)h(to)g
- (transfer)f(it)g(again.)150 2163 y(If)i(y)m(ou'v)m(e)h(incorp)s(orated)
- e Fj(libbzip2)f Fl(in)m(to)i(y)m(our)g(o)m(wn)g(program)g(and)g(are)g
- (getting)h(problems,)e(please,)150 2272 y(please,)d(please,)h(c)m(hec)m
- (k)g(that)f(the)g(parameters)g(y)m(ou)g(are)g(passing)f(in)f(calls)h
- (to)h(the)g(library)-8 b(,)26 b(are)j(correct,)150 2382
- y(and)e(in)f(accordance)k(with)c(what)i(the)g(do)s(cumen)m(tation)f(sa)
- m(ys)h(is)f(allo)m(w)m(able.)39 b(I)28 b(ha)m(v)m(e)h(tried)e(to)h(mak)
- m(e)h(the)150 2492 y(library)f(robust)i(against)g(suc)m(h)g(problems,)f
- (but)h(I'm)g(sure)g(I)g(ha)m(v)m(en't)h(succeeded.)150
- 2648 y(Finally)-8 b(,)32 b(if)g(the)h(ab)s(o)m(v)m(e)i(commen)m(ts)e
- (don't)g(help,)g(y)m(ou'll)f(ha)m(v)m(e)i(to)g(send)e(me)h(a)g(bug)g
- (rep)s(ort.)48 b(No)m(w,)34 b(it's)150 2758 y(just)c(amazing)g(ho)m(w)h
- (man)m(y)f(p)s(eople)g(will)d(send)j(me)g(a)h(bug)f(rep)s(ort)g(sa)m
- (ying)g(something)g(lik)m(e)481 2909 y(bzip2)f(crashed)h(with)f(segmen)
- m(tation)j(fault)e(on)g(m)m(y)g(mac)m(hine)150 3066 y(and)h(absolutely)
- f(nothing)h(else.)44 b(Needless)32 b(to)g(sa)m(y)-8 b(,)33
- b(a)f(suc)m(h)f(a)h(rep)s(ort)f(is)g Fc(totally)-8 b(,)32
- b(utterly)-8 b(,)32 b(completely)150 3175 y(and)40 b(comprehensiv)m
- (ely)g(100 45)h(useless;)46 b(a)41 b(w)m(aste)g(of)g(y)m(our)g(time,)i
- (m)m(y)e(time,)i(and)e(net)g(bandwidth)p Fl(.)150 3285
- y(With)31 b(no)h(details)f(at)i(all,)e(there's)h(no)g(w)m(a)m(y)h(I)f
- (can)g(p)s(ossibly)d(b)s(egin)h(to)j( 14gure)e(out)i(what)e(the)i
- (problem)150 3395 y(is.)150 3551 y(The)d(rules)e(of)i(the)g(game)h
- (are:)41 b(facts,)32 b(facts,)f(facts.)41 b(Don't)31
- b(omit)f(them)g(b)s(ecause)g Fj(")p Fl(oh,)g(they)g(w)m(on't)h(b)s(e)
- 150 3661 y(relev)-5 b(an)m(t)p Fj(")p Fl(.)41 b(A)m(t)31
- b(the)g(bare)f(minim)m(um:)481 3812 y(Mac)m(hine)h(t)m(yp)s(e.)61
- b(Op)s(erating)29 b(system)h(v)m(ersion.)481 3916 y(Exact)h(v)m(ersion)
- f(of)h Fj(bzip2)e Fl((do)h Fj(bzip2)47 b(-V)p Fl().)481
- 4020 y(Exact)31 b(v)m(ersion)f(of)h(the)f(compiler)f(used.)481
- 4123 y(Flags)i(passed)e(to)j(the)e(compiler.)150 4280
- y(Ho)m(w)m(ev)m(er,)i(the)d(most)h(imp)s(ortan)m(t)f(single)f(thing)g
- (that)i(will)d(help)h(me)h(is)f(the)i( 14le)e(that)i(y)m(ou)g(w)m(ere)
- g(trying)150 4390 y(to)f(compress)f(or)g(decompress)g(at)h(the)f(time)g
- (the)g(problem)f(happ)s(ened.)38 b(Without)28 b(that,)h(m)m(y)g(abilit)
- m(y)d(to)150 4499 y(do)k(an)m(ything)g(more)h(than)f(sp)s(eculate)g(ab)
- s(out)g(the)g(cause,)i(is)d(limited.)150 4656 y(Please)34
- b(remem)m(b)s(er)f(that)h(I)f(connect)i(to)f(the)g(In)m(ternet)g(with)e
- (a)i(mo)s(dem,)g(so)f(y)m(ou)h(should)e(con)m(tact)k(me)150
- 4766 y(b)s(efore)30 b(mailing)e(me)j(h)m(uge)f( 14les.)150
- 5038 y Fk(4.4)68 b(Did)45 b(y)l(ou)g(get)h(the)f(righ)l(t)h(pac)l(k)-7
- b(age?)150 5230 y Fj(bzip2)34 b Fl(is)h(a)h(resource)g(hog.)56
- b(It)36 b(soaks)g(up)f(large)g(amoun)m(ts)h(of)g(CPU)f(cycles)h(and)f
- (memory)-8 b(.)57 b(Also,)36 b(it)150 5340 y(giv)m(es)26
- b(v)m(ery)h(large)f(latencies.)39 b(In)25 b(the)h(w)m(orst)g(case,)i(y)
- m(ou)f(can)f(feed)g(man)m(y)g(megab)m(ytes)h(of)f(uncompressed)p
- eop
- %%Page: 34 35
- 34 34 bop 150 -116 a Fl(Chapter)30 b(4:)41 b(Miscellanea)2586
- b(34)150 366 y(data)45 b(in)m(to)e(the)i(library)c(b)s(efore)j(getting)
- g(an)m(y)g(compressed)g(output,)j(so)d(this)f(probably)f(rules)h(out)
- 150 476 y(applications)29 b(requiring)e(in)m(teractiv)m(e)32
- b(b)s(eha)m(viour.)150 633 y(These)38 b(aren't)h(faults)e(of)h(m)m(y)g
- (implemen)m(tation,)h(I)f(hop)s(e,)i(but)d(more)h(an)g(in)m(trinsic)e
- (prop)s(ert)m(y)h(of)i(the)150 742 y(Burro)m(ws-Wheeler)30
- b(transform)g((unfortunately).)40 b(Ma)m(yb)s(e)31
- b(this)e(isn't)h(what)g(y)m(ou)h(w)m(an)m(t.)150 899
- y(If)h(y)m(ou)h(w)m(an)m(t)g(a)g(compressor)g(and/or)f(library)e(whic)m
- (h)h(is)h(faster,)i(uses)e(less)g(memory)g(but)g(gets)h(prett)m(y)150
- 1009 y(go)s(o)s(d)e(compression,)g(and)g(has)h(minimal)c(latency)-8
- b(,)33 b(consider)e(Jean-loup)f(Gailly's)g(and)h(Mark)h(Adler's)150
- 1119 y(w)m(ork,)23 b Fj(zlib-1.1.2)17 b Fl(and)j Fj(gzip-1.2.4)p
- Fl(.)34 b(Lo)s(ok)21 b(for)f(them)g(at)h Fj(http://www.cdrom.com/pub)o
- (/inf)o(ozip)o(/zl)o(ib)p 4036 1139 42 84 v 150 1228
- a Fl(and)30 b Fj(http://www.gzip.org)25 b Fl(resp)s(ectiv)m(ely)-8
- b(.)150 1385 y(F)g(or)32 b(something)f(faster)i(and)e(ligh)m(ter)f
- (still,)h(y)m(ou)g(migh)m(t)h(try)f(Markus)h(F)g(X)f(J)h(Ob)s(erh)m
- (umer's)d Fj(LZO)i Fl(real-)150 1495 y(time)f
- (compression/decompression)f(library)-8 b(,)28 b(at)150
- 1604 y Fj(http://wildsau.idv.uni-l)o(inz.)o(ac.a)o(t/m)o(fx/l)o(zo.h)o
- (tml)o Fl(.)150 1761 y(If)38 b(y)m(ou)h(w)m(an)m(t)g(to)h(use)e(the)g
- Fj(bzip2)g Fl(algorithms)f(to)i(compress)f(small)g(blo)s(c)m(ks)f(of)i
- (data,)j(64k)d(b)m(ytes)g(or)150 1871 y(smaller,)i(for)e(example)g(on)h
- (an)f(on-the- 15y)h(disk)e(compressor,)k(y)m(ou'd)e(b)s(e)f(w)m(ell)g
- (advised)f(not)i(to)g(use)150 1980 y(this)i(library)-8
- b(.)77 b(Instead,)47 b(I'v)m(e)d(made)f(a)h(sp)s(ecial)e(library)f
- (tuned)h(for)h(that)h(kind)d(of)j(use.)79 b(It's)43 b(part)150
- 2090 y(of)d Fj(e2compr-0.40)p Fl(,)f(an)g(on-the- 15y)h(disk)e
- (compressor)h(for)h(the)f(Lin)m(ux)f Fj(ext2)h Fl( 14lesystem.)67
- b(Lo)s(ok)40 b(at)150 2199 y Fj(http://www.netspace.net.)o(au/~)o(reit)
- o(er/)o(e2co)o(mpr)p Fl(.)150 2490 y Fk(4.5)68 b(T)-11
- b(esting)150 2683 y Fl(A)30 b(record)h(of)f(the)h(tests)g(I'v)m(e)g
- (done.)150 2840 y(First,)f(some)h(data)g(sets:)225 2996
- y Fi( 17)60 b Fl(B:)27 b(a)g(directory)f(con)m(taining)g(a)h(6001)h
- ( 14les,)e(one)h(for)f(ev)m(ery)h(length)f(in)f(the)i(range)g(0)g(to)g
- (6000)h(b)m(ytes.)330 3106 y(The)i( 14les)f(con)m(tain)i(random)e(lo)m
- (w)m(ercase)j(letters.)41 b(18.7)32 b(megab)m(ytes.)225
- 3244 y Fi( 17)60 b Fl(H:)36 b(m)m(y)f(home)h(directory)f(tree.)56
- b(Do)s(cumen)m(ts,)38 b(source)d(co)s(de,)i(mail)d( 14les,)i
- (compressed)f(data.)57 b(H)330 3354 y(con)m(tains)39
- b(B,)h(and)f(also)g(a)g(directory)g(of)g( 14les)f(designed)g(as)i(b)s
- (oundary)d(cases)j(for)f(the)g(sorting;)330 3463 y(mostly)30
- b(v)m(ery)h(rep)s(etitiv)m(e,)f(nast)m(y)h( 14les.)39
- b(445)32 b(megab)m(ytes.)225 3602 y Fi( 17)60 b Fl(A:)41
- b(directory)f(tree)i(holding)d(v)-5 b(arious)39 b(applications)g(built)
- g(from)h(source:)62 b Fj(egcs-1.0.2)p Fl(,)41 b Fj(gcc-)330
- 3711 y(2.8.1)p Fl(,)29 b(KDE)i(Beta)g(4,)g(GTK,)g(Octa)m(v)m(e,)i(etc.)
- 41 b(827)32 b(megab)m(ytes.)225 3850 y Fi( 17)60 b Fl(P:)33
- b(directory)f(tree)h(holding)e(large)i(amoun)m(ts)g(of)f(source)h(co)s
- (de)g(()p Fj(.tar)f Fl( 14les))g(of)h(the)g(en)m(tire)f(GNU)330
- 3959 y(distribution,)27 b(plus)h(a)j(couple)f(of)h(Lin)m(ux)d
- (distributions.)37 b(2400)32 b(megab)m(ytes.)150 4145
- y(The)j(tests)g(conducted)g(are)h(as)f(follo)m(ws.)54
- b(Eac)m(h)36 b(test)g(means)f(compressing)f((a)h(cop)m(y)h(of)7
- b())36 b(eac)m(h)g( 14le)e(in)150 4254 y(the)d(data)g(set,)g
- (decompressing)e(it)h(and)g(comparing)f(it)h(against)h(the)g(original.)
- 150 4411 y(First,)44 b(a)e(bunc)m(h)e(of)h(tests)h(with)f(blo)s(c)m(k)f
- (sizes,)45 b(in)m(ternal)40 b(bu 13er)g(sizes)h(and)g(randomisation)f
- (lengths)150 4521 y(set)45 b(v)m(ery)g(small,)h(to)f(detect)h(an)m(y)f
- (problems)e(with)g(the)h(blo)s(c)m(king,)j(bu 13ering)c(and)h
- (randomisation)150 4630 y(mec)m(hanisms.)c(This)28 b(required)h(mo)s
- (difying)f(the)i(source)h(co)s(de)f(so)h(as)g(to)g(try)f(to)h(break)f
- (it.)199 4787 y(1.)61 b(Data)32 b(set)f(H,)g(with)e(bu 13er)g(size)h
- (of)h(1)g(b)m(yte,)g(and)f(blo)s(c)m(k)g(size)g(of)g(23)i(b)m(ytes.)199
- 4925 y(2.)61 b(Data)32 b(set)f(B,)g(bu 13er)e(sizes)h(1)h(b)m(yte,)g
- (blo)s(c)m(k)f(size)g(1)h(b)m(yte.)199 5064 y(3.)61 b(As)30
- b((2))i(but)d(small-mo)s(de)g(decompression)h(( 14rst)g(1700)i
- ( 14les).)199 5202 y(4.)61 b(As)30 b((2))i(with)d(blo)s(c)m(k)h
- (size)g(2)h(b)m(ytes.)199 5340 y(5.)61 b(As)30 b((2))i(with)d(blo)s
- (c)m(k)h(size)g(3)h(b)m(ytes.)p eop
- %%Page: 35 36
- 35 35 bop 150 -116 a Fl(Chapter)30 b(4:)41 b(Miscellanea)2586
- b(35)199 366 y(6.)61 b(As)30 b((2))i(with)d(blo)s(c)m(k)h(size)g(4)h
- (b)m(ytes.)199 502 y(7.)61 b(As)30 b((2))i(with)d(blo)s(c)m(k)h(size)
- g(5)h(b)m(ytes.)199 638 y(8.)61 b(As)30 b((2))i(with)d(blo)s(c)m(k)h
- (size)g(6)h(b)m(ytes)g(and)e(small-mo)s(de)g(decompression.)199
- 774 y(9.)61 b(H)34 b(with)f(normal)g(bu 13er)h(sizes)f((5000)k(b)m
- (ytes),)f(normal)d(blo)s(c)m(k)h(size)g((up)g(to)g(900000)j(b)m
- (ytes),)g(but)330 883 y(with)i(randomisation)g(mec)m(hanism)h(running)
- e(in)m(tensely)h((randomising)f(appro)m(ximately)i(ev)m(ery)330
- 993 y(third)29 b(b)m(yte).)154 1128 y(10.)61 b(As)30
- b((9))i(with)d(small-mo)s(de)g(decompression.)150 1311
- y(Then)g(some)i(tests)g(with)e(unmo)s(di 14ed)f(source)i(co)s(de.)199
- 1468 y(1.)61 b(H,)31 b(all)e(settings)h(normal.)199 1604
- y(2.)61 b(As)30 b((1),)i(with)d(small-mo)s(de)g(decompress.)199
- 1740 y(3.)61 b(H,)31 b(compress)f(with)f( 15ag)i Fj(-1)p
- Fl(.)199 1875 y(4.)61 b(H,)31 b(compress)f(with)f( 15ag)i
- Fj(-s)p Fl(,)f(decompress)g(with)f( 15ag)i Fj(-s)p Fl(.)199
- 2011 y(5.)61 b(F)-8 b(orw)m(ards)33 b(compatibilit)m(y:)45
- b(H,)33 b Fj(bzip2-0.1pl2)d Fl(compressing,)j Fj(bzip2-0.9.0)d
- Fl(decompressing,)330 2121 y(all)f(settings)i(normal.)199
- 2256 y(6.)61 b(Bac)m(kw)m(ards)23 b(compatibilit)m(y:)35
- b(H,)23 b Fj(bzip2-0.9.0)c Fl(compressing,)k Fj(bzip2-0.1pl2)c
- Fl(decompressing,)330 2366 y(all)29 b(settings)i(normal.)199
- 2502 y(7.)61 b(Bigger)31 b(tests:)41 b(A,)31 b(all)e(settings)i
- (normal.)199 2637 y(8.)61 b(P)-8 b(,)31 b(all)e(settings)h(normal.)199
- 2773 y(9.)61 b(Misc)30 b(test:)42 b(ab)s(out)30 b(100)i(megab)m(ytes)f
- (of)g Fj(.tar)e Fl( 14les)h(with)f Fj(bzip2)g Fl(compiled)f(with)h
- (Purify)-8 b(.)154 2909 y(10.)61 b(Misc)30 b(tests)h(to)g(mak)m(e)h
- (sure)d(it)h(builds)e(and)h(runs)g(ok)i(on)f(non-Lin)m(ux/x86)g
- (platforms.)150 3092 y(These)j(tests)g(w)m(ere)h(conducted)f(on)f(a)i
- (205)g(MHz)f(Cyrix)f(6x86MX)i(mac)m(hine,)g(running)c(Lin)m(ux)h
- (2.0.32.)150 3201 y(They)f(represen)m(t)g(nearly)g(a)h(w)m(eek)g(of)f
- (con)m(tin)m(uous)g(computation.)41 b(All)29 b(tests)i(completed)f
- (successfully)-8 b(.)150 3485 y Fk(4.6)68 b(F)-11 b(urther)44
- b(reading)150 3677 y Fj(bzip2)28 b Fl(is)h(not)h(researc)m(h)g(w)m
- (ork,)g(in)e(the)i(sense)g(that)g(it)f(do)s(esn't)g(presen)m(t)h(an)m
- (y)g(new)f(ideas.)40 b(Rather,)30 b(it's)150 3787 y(an)g(engineering)f
- (exercise)i(based)f(on)g(existing)g(ideas.)150 3944 y(F)-8
- b(our)31 b(do)s(cumen)m(ts)f(describ)s(e)e(essen)m(tially)i(all)f(the)i
- (ideas)e(b)s(ehind)f Fj(bzip2)p Fl(:)390 4095 y Fj(Michael)46
- b(Burrows)g(and)h(D.)g(J.)g(Wheeler:)485 4198 y("A)h(block-sorting)c
- (lossless)h(data)i(compression)e(algorithm")533 4302
- y(10th)i(May)g(1994.)533 4406 y(Digital)f(SRC)h(Research)e(Report)i
- (124.)533 4510 y(ftp://ftp.digital.com/pub)o(/DEC)o(/SR)o(C/re)o(sear)o
- (ch-)o(repo)o(rts/)o(SRC)o(-124)o(.ps.)o(gz)533 4614
- y(If)g(you)g(have)g(trouble)f(finding)g(it,)g(try)h(searching)f(at)h
- (the)533 4717 y(New)g(Zealand)f(Digital)g(Library,)f
- (http://www.nzdl.org.)390 4925 y(Daniel)h(S.)h(Hirschberg)e(and)i
- (Debra)g(A.)g(LeLewer)485 5029 y("Efficient)e(Decoding)h(of)h(Prefix)f
- (Codes")533 5132 y(Communications)e(of)j(the)g(ACM,)g(April)f(1990,)h
- (Vol)f(33,)h(Number)f(4.)533 5236 y(You)h(might)f(be)i(able)e(to)h(get)
- g(an)h(electronic)d(copy)h(of)h(this)676 5340 y(from)g(the)g(ACM)g
- (Digital)f(Library.)p eop
- %%Page: 36 37
- 36 36 bop 150 -116 a Fl(Chapter)30 b(4:)41 b(Miscellanea)2586
- b(36)390 470 y Fj(David)46 b(J.)i(Wheeler)533 574 y(Program)e(bred3.c)g
- (and)h(accompanying)d(document)i(bred3.ps.)533 678 y(This)h(contains)e
- (the)i(idea)g(behind)f(the)h(multi-table)e(Huffman)533
- 782 y(coding)h(scheme.)533 885 y(ftp://ftp.cl.cam.ac.uk/pu)o(b/us)o
- (er/)o(djw3)o(/)390 1093 y(Jon)h(L.)g(Bentley)f(and)h(Robert)f
- (Sedgewick)485 1197 y("Fast)h(Algorithms)e(for)i(Sorting)f(and)g
- (Searching)g(Strings")533 1300 y(Available)f(from)i(Sedgewick's)e(web)i
- (page,)533 1404 y(www.cs.princeton.edu/~rs)150 1561 y
- Fl(The)29 b(follo)m(wing)f(pap)s(er)g(giv)m(es)h(v)-5
- b(aluable)28 b(additional)g(insigh)m(ts)f(in)m(to)j(the)f(algorithm,)g
- (but)g(is)f(not)i(imme-)150 1671 y(diately)g(the)g(basis)f(of)i(an)m(y)
- g(co)s(de)f(used)g(in)f(bzip2.)390 1822 y Fj(Peter)46
- b(Fenwick:)533 1925 y(Block)h(Sorting)e(Text)i(Compression)533
- 2029 y(Proceedings)e(of)i(the)g(19th)g(Australasian)d(Computer)i
- (Science)f(Conference,)629 2133 y(Melbourne,)g(Australia.)92
- b(Jan)47 b(31)g(-)h(Feb)f(2,)g(1996.)533 2237 y
- (ftp://ftp.cs.auckland.ac.)o(nz/p)o(ub/)o(pete)o(r-f/)o(ACS)o(C96p)o
- (aper)o(.ps)150 2394 y Fl(Kunihik)m(o)28 b(Sadak)-5 b(ane's)31
- b(sorting)e(algorithm,)h(men)m(tioned)g(ab)s(o)m(v)m(e,)i(is)d(a)m(v)-5
- b(ailable)30 b(from:)390 2545 y Fj(http://naomi.is.s.u-toky)o(o.ac)o
- (.jp/)o(~sa)o(da/p)o(aper)o(s/S)o(ada9)o(8b.p)o(s.g)o(z)150
- 2702 y Fl(The)41 b(Man)m(b)s(er-My)m(ers)g(su 16x)g(arra)m(y)g
- (construction)g(algorithm)f(is)g(describ)s(ed)f(in)h(a)i(pap)s(er)e(a)m
- (v)-5 b(ailable)150 2811 y(from:)390 2962 y Fj
- (http://www.cs.arizona.ed)o(u/pe)o(ople)o(/ge)o(ne/P)o(APER)o(S/s)o
- (uffi)o(x.ps)p eop
- %%Page: -1 38
- -1 37 bop 3725 -116 a Fl(i)150 366 y Fh(T)-13 b(able)54
- b(of)g(Con)l(ten)l(ts)150 684 y Fk(1)135 b(In)l(tro)t(duction)15
- b Fb(.)20 b(.)f(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)h(.)f
- (.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)60
- b Fk(2)150 942 y(2)135 b(Ho)l(w)45 b(to)h(use)f Fd(bzip2)31
- b Fb(.)19 b(.)g(.)h(.)f(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)h(.)f(.)g
- (.)h(.)f(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)78 b Fk(3)150
- 1201 y(3)135 b(Programming)46 b(with)f Fd(libbzip2)27
- b Fb(.)16 b(.)j(.)g(.)h(.)f(.)h(.)f(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)72
- b Fk(11)449 1338 y Fl(3.1)92 b(T)-8 b(op-lev)m(el)30
- b(structure)23 b Fa(.)15 b(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g
- (.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)g(.)
- g(.)g(.)g(.)g(.)g(.)g(.)g(.)52 b Fl(11)748 1447 y(3.1.1)93
- b(Lo)m(w-lev)m(el)30 b(summary)22 b Fa(.)15 b(.)g(.)g(.)g(.)g(.)g(.)g
- (.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)
- g(.)g(.)g(.)52 b Fl(11)748 1557 y(3.1.2)93 b(High-lev)m(el)29
- b(summary)10 b Fa(.)15 b(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)
- g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)40
- b Fl(11)748 1666 y(3.1.3)93 b(Utilit)m(y)29 b(functions)g(summary)12
- b Fa(.)h(.)j(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)
- g(.)g(.)g(.)g(.)g(.)41 b Fl(12)449 1776 y(3.2)92 b(Error)29
- b(handling)18 b Fa(.)13 b(.)i(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f
- (.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)
- g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)48 b Fl(12)449
- 1886 y(3.3)92 b(Lo)m(w-lev)m(el)31 b(in)m(terface)d Fa(.)15
- b(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g
- (.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)
- g(.)57 b Fl(14)748 1995 y(3.3.1)93 b Fj(bzCompressInit)9
- b Fa(.)h(.)15 b(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g
- (.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)38
- b Fl(14)748 2105 y(3.3.2)93 b Fj(bzCompress)18 b Fa(.)12
- b(.)j(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g
- (.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)47
- b Fl(15)748 2214 y(3.3.3)93 b Fj(bzCompressEnd)11 b Fa(.)g(.)k(.)g(.)g
- (.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)
- g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)40 b Fl(18)748
- 2324 y(3.3.4)93 b Fj(bzDecompressInit)21 b Fa(.)15 b(.)g(.)g(.)g(.)g(.)
- g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g
- (.)g(.)g(.)g(.)g(.)55 b Fl(18)748 2434 y(3.3.5)93 b Fj(bzDecompress)13
- b Fa(.)f(.)j(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)
- g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)43
- b Fl(19)748 2543 y(3.3.6)93 b Fj(bzDecompressEnd)23 b
- Fa(.)15 b(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g
- (.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)57
- b Fl(20)449 2653 y(3.4)92 b(High-lev)m(el)30 b(in)m(terface)16
- b Fa(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)
- h(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g
- (.)g(.)g(.)45 b Fl(20)748 2762 y(3.4.1)93 b Fj(bzReadOpen)18
- b Fa(.)12 b(.)j(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g
- (.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)
- g(.)47 b Fl(21)748 2872 y(3.4.2)93 b Fj(bzRead)25 b Fa(.)15
- b(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g
- (.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)
- g(.)g(.)g(.)57 b Fl(22)748 2982 y(3.4.3)93 b Fj(bzReadGetUnused)23
- b Fa(.)15 b(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g
- (.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)57
- b Fl(23)748 3091 y(3.4.4)93 b Fj(bzReadClose)16 b Fa(.)11
- b(.)k(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)g
- (.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)45
- b Fl(23)748 3201 y(3.4.5)93 b Fj(bzWriteOpen)16 b Fa(.)11
- b(.)k(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)g
- (.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)45
- b Fl(24)748 3310 y(3.4.6)93 b Fj(bzWrite)23 b Fa(.)15
- b(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g
- (.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)g(.)
- g(.)g(.)54 b Fl(24)748 3420 y(3.4.7)93 b Fj(bzWriteClose)13
- b Fa(.)f(.)j(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)
- g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)43
- b Fl(25)748 3530 y(3.4.8)93 b(Handling)28 b(em)m(b)s(edded)h
- (compressed)h(data)h(streams)17 b Fa(.)f(.)f(.)g(.)46
- b Fl(25)748 3639 y(3.4.9)93 b(Standard)29 b( 14le-reading/writing)e
- (co)s(de)22 b Fa(.)16 b(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g
- (.)52 b Fl(26)449 3749 y(3.5)92 b(Utilit)m(y)29 b(functions)f
- Fa(.)15 b(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g
- (.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)
- g(.)g(.)g(.)g(.)g(.)59 b Fl(27)748 3858 y(3.5.1)93 b
- Fj(bzBuffToBuffCompress)16 b Fa(.)9 b(.)15 b(.)g(.)g(.)g(.)g(.)g(.)g(.)
- g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)45
- b Fl(27)748 3968 y(3.5.2)93 b Fj(bzBuffToBuffDecompress)10
- b Fa(.)g(.)15 b(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g
- (.)g(.)g(.)g(.)g(.)g(.)41 b Fl(28)449 4077 y(3.6)92 b(Using)30
- b(the)g(library)e(in)h(a)i Fj(stdio)p Fl(-free)e(en)m(vironmen)m(t)23
- b Fa(.)15 b(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)52
- b Fl(29)748 4187 y(3.6.1)93 b(Getting)31 b(rid)d(of)j
- Fj(stdio)20 b Fa(.)13 b(.)i(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f
- (.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)49
- b Fl(29)748 4297 y(3.6.2)93 b(Critical)28 b(error)i(handling)22
- b Fa(.)15 b(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g
- (.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)54 b Fl(29)449 4406
- y(3.7)92 b(Making)30 b(a)h(Windo)m(ws)e(DLL)15 b Fa(.)h(.)f(.)g(.)g(.)g
- (.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)
- g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)44 b Fl(30)150 4637
- y Fk(4)135 b(Miscellanea)11 b Fb(.)21 b(.)f(.)f(.)h(.)f(.)g(.)h(.)f(.)h
- (.)f(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)h(.)f(.)
- h(.)f(.)g(.)h(.)56 b Fk(31)449 4774 y Fl(4.1)92 b(Limitations)29
- b(of)h(the)h(compressed)f( 14le)f(format)9 b Fa(.)15
- b(.)h(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)38
- b Fl(31)449 4884 y(4.2)92 b(P)m(ortabilit)m(y)30 b(issues)14
- b Fa(.)f(.)j(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)
- g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g
- (.)g(.)h(.)f(.)g(.)43 b Fl(32)449 4994 y(4.3)92 b(Rep)s(orting)29
- b(bugs)f Fa(.)15 b(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g
- (.)h(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)
- g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)58 b Fl(32)449 5103 y(4.4)92
- b(Did)29 b(y)m(ou)i(get)h(the)e(righ)m(t)g(pac)m(k)-5
- b(age?)22 b Fa(.)17 b(.)e(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h
- (.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)51
- b Fl(33)449 5213 y(4.5)92 b(T)-8 b(esting)16 b Fa(.)f(.)g(.)g(.)g(.)g
- (.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)
- g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g
- (.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)45 b Fl(34)449 5322 y(4.6)92
- b(F)-8 b(urther)30 b(reading)22 b Fa(.)14 b(.)h(.)g(.)h(.)f(.)g(.)g(.)g
- (.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)
- g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)51
- b Fl(35)p eop
- %%Trailer
- end
- userdict /end-hook known{end-hook}if
- %%EOF