├── .DS_Store ├── .gitignore ├── LICENSE ├── README.md ├── serverpatch ├── .DS_Store ├── bsdiff-4.3.tar.gz ├── bsdiff-4.3 │ ├── .DS_Store │ ├── Makefile │ ├── bsdiff.1 │ ├── bsdiff.c │ ├── bspatch.1 │ ├── bspatch.c │ └── install.sh ├── bzip2-1.0.6.tar.gz └── bzip2-1.0.6 │ ├── .DS_Store │ ├── CHANGES │ ├── LICENSE │ ├── Makefile │ ├── Makefile-libbz2_so │ ├── README │ ├── README.COMPILATION.PROBLEMS │ ├── README.XML.STUFF │ ├── blocksort.c │ ├── blocksort.o │ ├── bz-common.xsl │ ├── bz-fo.xsl │ ├── bz-html.xsl │ ├── bzdiff │ ├── bzdiff.1 │ ├── bzgrep │ ├── bzgrep.1 │ ├── bzip.css │ ├── bzip2 │ ├── bzip2.1 │ ├── bzip2.1.preformatted │ ├── bzip2.c │ ├── bzip2.o │ ├── bzip2.txt │ ├── bzip2recover │ ├── bzip2recover.c │ ├── bzip2recover.o │ ├── bzlib.c │ ├── bzlib.h │ ├── bzlib.o │ ├── bzlib_private.h │ ├── bzmore │ ├── bzmore.1 │ ├── compress.c │ ├── compress.o │ ├── crctable.c │ ├── crctable.o │ ├── decompress.c │ ├── decompress.o │ ├── dlltest.c │ ├── dlltest.dsp │ ├── entities.xml │ ├── format.pl │ ├── huffman.c │ ├── huffman.o │ ├── libbz2.a │ ├── libbz2.def │ ├── libbz2.dsp │ ├── makefile.msc │ ├── manual.html │ ├── manual.pdf │ ├── manual.ps │ ├── manual.xml │ ├── mk251.c │ ├── randtable.c │ ├── randtable.o │ ├── sample1.bz2 │ ├── sample1.rb2 │ ├── sample1.ref │ ├── sample1.tst │ ├── sample2.bz2 │ ├── sample2.rb2 │ ├── sample2.ref │ ├── sample2.tst │ ├── sample3.bz2 │ ├── sample3.rb2 │ ├── sample3.ref │ ├── sample3.tst │ ├── spewG.c │ ├── unzcrash.c │ ├── words0 │ ├── words1 │ ├── words2 │ ├── words3 │ └── xmlproc.sh └── ypatchcore ├── .DS_Store ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src ├── androidTest └── java │ └── com │ └── chan │ └── ypatchcore │ └── ApplicationTest.java ├── main ├── AndroidManifest.xml ├── java │ └── com │ │ └── chan │ │ └── ypatchcore │ │ └── YPatch.java ├── jni │ ├── bzip │ │ ├── blocksort.c │ │ ├── bzlib.c │ │ ├── bzlib.h │ │ ├── bzlib_private.h │ │ ├── compress.c │ │ ├── crctable.c │ │ ├── decompress.c │ │ ├── huffman.c │ │ └── randtable.c │ ├── com_chan_ypatchcore_YPatch.cpp │ ├── com_chan_ypatchcore_YPatch.h │ └── patch │ │ ├── bspatch.c │ │ └── bspatch.h └── res │ └── values │ └── strings.xml └── test └── java └── com └── chan └── ypatchcore └── ExampleUnitTest.java /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChanJLee/android-patch/85678d935494f8a7dc1919f7b20469de81d9c465/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Android Studio Navigation editor temp files 30 | .navigation/ 31 | 32 | # Android Studio captures folder 33 | captures/ 34 | 35 | # Intellij 36 | *.iml 37 | .idea/workspace.xml 38 | 39 | # Keystore files 40 | *.jks 41 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 版权所有(c)<年份><版权持有人> 2 | 3 | 反996许可证版本1.0 4 | 5 | 在符合下列条件的情况下,特此免费向任何得到本授权作品的副本(包括源代码、文件和/或相关内容,以下 6 | 统称为“授权作品”)的个人和法人实体授权:被授权个人或法人实体有权以任何目的处置授权作品,包括但 7 | 不限于使用、复制,修改,衍生利用、散布,发布和再许可: 8 | 9 | 1. 个人或法人实体必须在许可作品的每个再散布或衍生副本上包含以上版权声明和本许可证,不得自行修 10 | 改。 11 | 2. 个人或法人实体必须严格遵守与个人实际所在地或个人出生地或归化地、或法人实体注册地或经营地 12 | (以较严格者为准)的司法管辖区所有适用的与劳动和就业相关法律、法规、规则和标准。如果该司法管辖 13 | 区没有此类法律、法规、规章和标准或其法律、法规、规章和标准不可执行,则个人或法人实体必须遵守国 14 | 际劳工标准的核心公约。 15 | 3. 个人或法人不得以任何方式诱导或强迫其全职或兼职员工或其独立承包人以口头或书面形式同意直接或 16 | 间接限制、削弱或放弃其所拥有的,受相关与劳动和就业有关的法律、法规、规则和标准保护的权利或补救 17 | 措施,无论该等书面或口头协议是否被该司法管辖区的法律所承认,该等个人或法人实体也不得以任何方法 18 | 限制其雇员或独立承包人向版权持有人或监督许可证合规情况的有关当局报告或投诉上述违反许可证的行为 19 | 的权利。 20 | 21 | 该授权作品是"按原样"提供,不做任何明示或暗示的保证,包括但不限于对适销性、特定用途适用性和非侵 22 | 权性的保证。在任何情况下,无论是在合同诉讼、侵权诉讼或其他诉讼中,版权持有人均不承担因本软件或 23 | 本软件的使用或其他交易而产生、引起或与之相关的任何索赔、损害或其他责任。 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AndroidPatch 2 | 用于实现Android端的增量升级 3 | 4 | # 目录结构 5 | - ypatchcore 是Android Studio工程,用于编译生成Android客户端的patch工具。 6 | - serverpatch 是用于生成服务器版本的diff,patch源代码 7 | 8 | # 安装 9 | 1:对于ypatchcore直接导入到Android Studio中就可以 10 | 2:对于serverpatch,首先先安装bzip2库,解压bzip2-1.0.6.tar.gz,执行make就行。然后再编译bsdiff,解压bsdiff-4.3.tar.gz,运行make程序就行 11 | 12 | 使用: 13 | 服务器端运行bsdiff old_file new_file patch_file生成差异文件,Android加入如下代码: 14 | 15 | ``` 16 | YPatch.patch(oldFilePath, newFilePath, patchFilePatch) 17 | ``` 18 | 19 | 将合成后的文件保存到newFilePath下 20 | -------------------------------------------------------------------------------- /serverpatch/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChanJLee/android-patch/85678d935494f8a7dc1919f7b20469de81d9c465/serverpatch/.DS_Store -------------------------------------------------------------------------------- /serverpatch/bsdiff-4.3.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChanJLee/android-patch/85678d935494f8a7dc1919f7b20469de81d9c465/serverpatch/bsdiff-4.3.tar.gz -------------------------------------------------------------------------------- /serverpatch/bsdiff-4.3/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChanJLee/android-patch/85678d935494f8a7dc1919f7b20469de81d9c465/serverpatch/bsdiff-4.3/.DS_Store -------------------------------------------------------------------------------- /serverpatch/bsdiff-4.3/Makefile: -------------------------------------------------------------------------------- 1 | CFLAGS += -O3 -lbz2 2 | 3 | PREFIX ?= /usr/local 4 | INSTALL_PROGRAM ?= ${INSTALL} -c -s -m 555 5 | INSTALL_MAN ?= ${INSTALL} -c -m 444 6 | 7 | all: bsdiff bspatch 8 | bsdiff: bsdiff.c 9 | bspatch: bspatch.c 10 | -------------------------------------------------------------------------------- /serverpatch/bsdiff-4.3/bsdiff.1: -------------------------------------------------------------------------------- 1 | .\"- 2 | .\" Copyright 2003-2005 Colin Percival 3 | .\" All rights reserved 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted providing that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 14 | .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 | .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 22 | .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 23 | .\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | .\" POSSIBILITY OF SUCH DAMAGE. 25 | .\" 26 | .\" $FreeBSD: src/usr.bin/bsdiff/bsdiff/bsdiff.1,v 1.1 2005/08/06 01:59:05 cperciva Exp $ 27 | .\" 28 | .Dd May 18, 2003 29 | .Dt BSDIFF 1 30 | .Os FreeBSD 31 | .Sh NAME 32 | .Nm bsdiff 33 | .Nd generate a patch between two binary files 34 | .Sh SYNOPSIS 35 | .Nm 36 | .Ao Ar oldfile Ac Ao Ar newfile Ac Ao Ar patchfile Ac 37 | .Sh DESCRIPTION 38 | .Nm 39 | compares 40 | .Ao Ar oldfile Ac 41 | to 42 | .Ao Ar newfile Ac 43 | and writes to 44 | .Ao Ar patchfile Ac 45 | a binary patch suitable for use by bspatch(1). 46 | When 47 | .Ao Ar oldfile Ac 48 | and 49 | .Ao Ar newfile Ac 50 | are two versions of an executable program, the 51 | patches produced are on average a factor of five smaller 52 | than those produced by any other binary patch tool known 53 | to the author. 54 | .Pp 55 | .Nm 56 | uses memory equal to 17 times the size of 57 | .Ao Ar oldfile Ac , 58 | and requires 59 | an absolute minimum working set size of 8 times the size of oldfile. 60 | .Sh SEE ALSO 61 | .Xr bspatch 1 62 | .Sh AUTHORS 63 | .An Colin Percival Aq cperciva@freebsd.org 64 | -------------------------------------------------------------------------------- /serverpatch/bsdiff-4.3/bsdiff.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright 2003-2005 Colin Percival 3 | * All rights reserved 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted providing that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 22 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 23 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | * POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #if 0 28 | __FBSDID("$FreeBSD: src/usr.bin/bsdiff/bsdiff/bsdiff.c,v 1.1 2005/08/06 01:59:05 cperciva Exp $"); 29 | #endif 30 | 31 | #include 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | 41 | #define MIN(x,y) (((x)<(y)) ? (x) : (y)) 42 | 43 | static void split(off_t *I,off_t *V,off_t start,off_t len,off_t h) 44 | { 45 | off_t i,j,k,x,tmp,jj,kk; 46 | 47 | if(len<16) { 48 | for(k=start;kstart) split(I,V,start,jj-start,h); 97 | 98 | for(i=0;ikk) split(I,V,kk,start+len-kk,h); 102 | } 103 | 104 | static void qsufsort(off_t *I,off_t *V,u_char *old,off_t oldsize) 105 | { 106 | off_t buckets[256]; 107 | off_t i,h,len; 108 | 109 | for(i=0;i<256;i++) buckets[i]=0; 110 | for(i=0;i0;i--) buckets[i]=buckets[i-1]; 113 | buckets[0]=0; 114 | 115 | for(i=0;iy) { 162 | *pos=I[st]; 163 | return x; 164 | } else { 165 | *pos=I[en]; 166 | return y; 167 | } 168 | }; 169 | 170 | x=st+(en-st)/2; 171 | if(memcmp(old+I[x],new,MIN(oldsize-I[x],newsize))<0) { 172 | return search(I,old,oldsize,new,newsize,x,en,pos); 173 | } else { 174 | return search(I,old,oldsize,new,newsize,st,x,pos); 175 | }; 176 | } 177 | 178 | static void offtout(off_t x,u_char *buf) 179 | { 180 | off_t y; 181 | 182 | if(x<0) y=-x; else y=x; 183 | 184 | buf[0]=y%256;y-=buf[0]; 185 | y=y/256;buf[1]=y%256;y-=buf[1]; 186 | y=y/256;buf[2]=y%256;y-=buf[2]; 187 | y=y/256;buf[3]=y%256;y-=buf[3]; 188 | y=y/256;buf[4]=y%256;y-=buf[4]; 189 | y=y/256;buf[5]=y%256;y-=buf[5]; 190 | y=y/256;buf[6]=y%256;y-=buf[6]; 191 | y=y/256;buf[7]=y%256; 192 | 193 | if(x<0) buf[7]|=0x80; 194 | } 195 | 196 | int main(int argc,char *argv[]) 197 | { 198 | int fd; 199 | u_char *old,*new; 200 | off_t oldsize,newsize; 201 | off_t *I,*V; 202 | off_t scan,pos,len; 203 | off_t lastscan,lastpos,lastoffset; 204 | off_t oldscore,scsc; 205 | off_t s,Sf,lenf,Sb,lenb; 206 | off_t overlap,Ss,lens; 207 | off_t i; 208 | off_t dblen,eblen; 209 | u_char *db,*eb; 210 | u_char buf[8]; 211 | u_char header[32]; 212 | FILE * pf; 213 | BZFILE * pfbz2; 214 | int bz2err; 215 | 216 | if(argc!=4) errx(1,"usage: %s oldfile newfile patchfile\n",argv[0]); 217 | 218 | /* Allocate oldsize+1 bytes instead of oldsize bytes to ensure 219 | that we never try to malloc(0) and get a NULL pointer */ 220 | if(((fd=open(argv[1],O_RDONLY,0))<0) || 221 | ((oldsize=lseek(fd,0,SEEK_END))==-1) || 222 | ((old=malloc(oldsize+1))==NULL) || 223 | (lseek(fd,0,SEEK_SET)!=0) || 224 | (read(fd,old,oldsize)!=oldsize) || 225 | (close(fd)==-1)) err(1,"%s",argv[1]); 226 | 227 | if(((I=malloc((oldsize+1)*sizeof(off_t)))==NULL) || 228 | ((V=malloc((oldsize+1)*sizeof(off_t)))==NULL)) err(1,NULL); 229 | 230 | qsufsort(I,V,old,oldsize); 231 | 232 | free(V); 233 | 234 | /* Allocate newsize+1 bytes instead of newsize bytes to ensure 235 | that we never try to malloc(0) and get a NULL pointer */ 236 | if(((fd=open(argv[2],O_RDONLY,0))<0) || 237 | ((newsize=lseek(fd,0,SEEK_END))==-1) || 238 | ((new=malloc(newsize+1))==NULL) || 239 | (lseek(fd,0,SEEK_SET)!=0) || 240 | (read(fd,new,newsize)!=newsize) || 241 | (close(fd)==-1)) err(1,"%s",argv[2]); 242 | 243 | if(((db=malloc(newsize+1))==NULL) || 244 | ((eb=malloc(newsize+1))==NULL)) err(1,NULL); 245 | dblen=0; 246 | eblen=0; 247 | 248 | /* Create the patch file */ 249 | if ((pf = fopen(argv[3], "w")) == NULL) 250 | err(1, "%s", argv[3]); 251 | 252 | /* Header is 253 | 0 8 "BSDIFF40" 254 | 8 8 length of bzip2ed ctrl block 255 | 16 8 length of bzip2ed diff block 256 | 24 8 length of new file */ 257 | /* File is 258 | 0 32 Header 259 | 32 ?? Bzip2ed ctrl block 260 | ?? ?? Bzip2ed diff block 261 | ?? ?? Bzip2ed extra block */ 262 | memcpy(header,"BSDIFF40",8); 263 | offtout(0, header + 8); 264 | offtout(0, header + 16); 265 | offtout(newsize, header + 24); 266 | if (fwrite(header, 32, 1, pf) != 1) 267 | err(1, "fwrite(%s)", argv[3]); 268 | 269 | /* Compute the differences, writing ctrl as we go */ 270 | if ((pfbz2 = BZ2_bzWriteOpen(&bz2err, pf, 9, 0, 0)) == NULL) 271 | errx(1, "BZ2_bzWriteOpen, bz2err = %d", bz2err); 272 | scan=0;len=0; 273 | lastscan=0;lastpos=0;lastoffset=0; 274 | while(scanoldscore+8)) break; 288 | 289 | if((scan+lastoffsetSf*2-lenf) { Sf=s; lenf=i; }; 300 | }; 301 | 302 | lenb=0; 303 | if(scan=lastscan+i)&&(pos>=i);i++) { 306 | if(old[pos-i]==new[scan-i]) s++; 307 | if(s*2-i>Sb*2-lenb) { Sb=s; lenb=i; }; 308 | }; 309 | }; 310 | 311 | if(lastscan+lenf>scan-lenb) { 312 | overlap=(lastscan+lenf)-(scan-lenb); 313 | s=0;Ss=0;lens=0; 314 | for(i=0;iSs) { Ss=s; lens=i+1; }; 320 | }; 321 | 322 | lenf+=lens-overlap; 323 | lenb-=lens; 324 | }; 325 | 326 | for(i=0;i 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | typedef unsigned char u_char; 40 | 41 | static off_t offtin(u_char *buf) 42 | { 43 | off_t y; 44 | 45 | y=buf[7]&0x7F; 46 | y=y*256;y+=buf[6]; 47 | y=y*256;y+=buf[5]; 48 | y=y*256;y+=buf[4]; 49 | y=y*256;y+=buf[3]; 50 | y=y*256;y+=buf[2]; 51 | y=y*256;y+=buf[1]; 52 | y=y*256;y+=buf[0]; 53 | 54 | if(buf[7]&0x80) y=-y; 55 | 56 | return y; 57 | } 58 | 59 | int main(int argc,char * argv[]) 60 | { 61 | FILE * f, * cpf, * dpf, * epf; 62 | BZFILE * cpfbz2, * dpfbz2, * epfbz2; 63 | int cbz2err, dbz2err, ebz2err; 64 | int fd; 65 | ssize_t oldsize,newsize; 66 | ssize_t bzctrllen,bzdatalen; 67 | u_char header[32],buf[8]; 68 | u_char *old, *new; 69 | off_t oldpos,newpos; 70 | off_t ctrl[3]; 71 | off_t lenread; 72 | off_t i; 73 | 74 | if(argc!=4) errx(1,"usage: %s oldfile newfile patchfile\n",argv[0]); 75 | 76 | /* Open patch file */ 77 | if ((f = fopen(argv[3], "r")) == NULL) 78 | err(1, "fopen(%s)", argv[3]); 79 | 80 | /* 81 | File format: 82 | 0 8 "BSDIFF40" 83 | 8 8 X 84 | 16 8 Y 85 | 24 8 sizeof(newfile) 86 | 32 X bzip2(control block) 87 | 32+X Y bzip2(diff block) 88 | 32+X+Y ??? bzip2(extra block) 89 | with control block a set of triples (x,y,z) meaning "add x bytes 90 | from oldfile to x bytes from the diff block; copy y bytes from the 91 | extra block; seek forwards in oldfile by z bytes". 92 | */ 93 | 94 | /* Read header */ 95 | if (fread(header, 1, 32, f) < 32) { 96 | if (feof(f)) 97 | errx(1, "Corrupt patch\n"); 98 | err(1, "fread(%s)", argv[3]); 99 | } 100 | 101 | /* Check for appropriate magic */ 102 | if (memcmp(header, "BSDIFF40", 8) != 0) 103 | errx(1, "Corrupt patch\n"); 104 | 105 | /* Read lengths from header */ 106 | bzctrllen=offtin(header+8); 107 | bzdatalen=offtin(header+16); 108 | newsize=offtin(header+24); 109 | if((bzctrllen<0) || (bzdatalen<0) || (newsize<0)) 110 | errx(1,"Corrupt patch\n"); 111 | 112 | /* Close patch file and re-open it via libbzip2 at the right places */ 113 | if (fclose(f)) 114 | err(1, "fclose(%s)", argv[3]); 115 | if ((cpf = fopen(argv[3], "r")) == NULL) 116 | err(1, "fopen(%s)", argv[3]); 117 | if (fseeko(cpf, 32, SEEK_SET)) 118 | err(1, "fseeko(%s, %lld)", argv[3], 119 | (long long)32); 120 | if ((cpfbz2 = BZ2_bzReadOpen(&cbz2err, cpf, 0, 0, NULL, 0)) == NULL) 121 | errx(1, "BZ2_bzReadOpen, bz2err = %d", cbz2err); 122 | if ((dpf = fopen(argv[3], "r")) == NULL) 123 | err(1, "fopen(%s)", argv[3]); 124 | if (fseeko(dpf, 32 + bzctrllen, SEEK_SET)) 125 | err(1, "fseeko(%s, %lld)", argv[3], 126 | (long long)(32 + bzctrllen)); 127 | if ((dpfbz2 = BZ2_bzReadOpen(&dbz2err, dpf, 0, 0, NULL, 0)) == NULL) 128 | errx(1, "BZ2_bzReadOpen, bz2err = %d", dbz2err); 129 | if ((epf = fopen(argv[3], "r")) == NULL) 130 | err(1, "fopen(%s)", argv[3]); 131 | if (fseeko(epf, 32 + bzctrllen + bzdatalen, SEEK_SET)) 132 | err(1, "fseeko(%s, %lld)", argv[3], 133 | (long long)(32 + bzctrllen + bzdatalen)); 134 | if ((epfbz2 = BZ2_bzReadOpen(&ebz2err, epf, 0, 0, NULL, 0)) == NULL) 135 | errx(1, "BZ2_bzReadOpen, bz2err = %d", ebz2err); 136 | 137 | if(((fd=open(argv[1],O_RDONLY,0))<0) || 138 | ((oldsize=lseek(fd,0,SEEK_END))==-1) || 139 | ((old=malloc(oldsize+1))==NULL) || 140 | (lseek(fd,0,SEEK_SET)!=0) || 141 | (read(fd,old,oldsize)!=oldsize) || 142 | (close(fd)==-1)) err(1,"%s",argv[1]); 143 | if((new=malloc(newsize+1))==NULL) err(1,NULL); 144 | 145 | oldpos=0;newpos=0; 146 | while(newposnewsize) 158 | errx(1,"Corrupt patch\n"); 159 | 160 | /* Read diff string */ 161 | lenread = BZ2_bzRead(&dbz2err, dpfbz2, new + newpos, ctrl[0]); 162 | if ((lenread < ctrl[0]) || 163 | ((dbz2err != BZ_OK) && (dbz2err != BZ_STREAM_END))) 164 | errx(1, "Corrupt patch\n"); 165 | 166 | /* Add old data to diff string */ 167 | for(i=0;i=0) && (oldpos+inewsize) 177 | errx(1,"Corrupt patch\n"); 178 | 179 | /* Read extra string */ 180 | lenread = BZ2_bzRead(&ebz2err, epfbz2, new + newpos, ctrl[1]); 181 | if ((lenread < ctrl[1]) || 182 | ((ebz2err != BZ_OK) && (ebz2err != BZ_STREAM_END))) 183 | errx(1, "Corrupt patch\n"); 184 | 185 | /* Adjust pointers */ 186 | newpos+=ctrl[1]; 187 | oldpos+=ctrl[2]; 188 | }; 189 | 190 | /* Clean up the bzip2 reads */ 191 | BZ2_bzReadClose(&cbz2err, cpfbz2); 192 | BZ2_bzReadClose(&dbz2err, dpfbz2); 193 | BZ2_bzReadClose(&ebz2err, epfbz2); 194 | if (fclose(cpf) || fclose(dpf) || fclose(epf)) 195 | err(1, "fclose(%s)", argv[3]); 196 | 197 | /* Write the new file */ 198 | if(((fd=open(argv[2],O_CREAT|O_TRUNC|O_WRONLY,0666))<0) || 199 | (write(fd,new,newsize)!=newsize) || (close(fd)==-1)) 200 | err(1,"%s",argv[2]); 201 | 202 | free(new); 203 | free(old); 204 | 205 | return 0; 206 | } 207 | -------------------------------------------------------------------------------- /serverpatch/bsdiff-4.3/install.sh: -------------------------------------------------------------------------------- 1 | make 2 | sudo mv ./bsdiff /usr/local/bin 3 | sudo mv ./bspatch /usr/local/bin 4 | -------------------------------------------------------------------------------- /serverpatch/bzip2-1.0.6.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChanJLee/android-patch/85678d935494f8a7dc1919f7b20469de81d9c465/serverpatch/bzip2-1.0.6.tar.gz -------------------------------------------------------------------------------- /serverpatch/bzip2-1.0.6/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChanJLee/android-patch/85678d935494f8a7dc1919f7b20469de81d9c465/serverpatch/bzip2-1.0.6/.DS_Store -------------------------------------------------------------------------------- /serverpatch/bzip2-1.0.6/CHANGES: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------ 2 | This file is part of bzip2/libbzip2, a program and library for 3 | lossless, block-sorting data compression. 4 | 5 | bzip2/libbzip2 version 1.0.6 of 6 September 2010 6 | Copyright (C) 1996-2010 Julian Seward 7 | 8 | Please read the WARNING, DISCLAIMER and PATENTS sections in the 9 | README file. 10 | 11 | This program is released under the terms of the license contained 12 | in the file LICENSE. 13 | ------------------------------------------------------------------ 14 | 15 | 16 | 0.9.0 17 | ~~~~~ 18 | First version. 19 | 20 | 21 | 0.9.0a 22 | ~~~~~~ 23 | Removed 'ranlib' from Makefile, since most modern Unix-es 24 | don't need it, or even know about it. 25 | 26 | 27 | 0.9.0b 28 | ~~~~~~ 29 | Fixed a problem with error reporting in bzip2.c. This does not effect 30 | the library in any way. Problem is: versions 0.9.0 and 0.9.0a (of the 31 | program proper) compress and decompress correctly, but give misleading 32 | error messages (internal panics) when an I/O error occurs, instead of 33 | reporting the problem correctly. This shouldn't give any data loss 34 | (as far as I can see), but is confusing. 35 | 36 | Made the inline declarations disappear for non-GCC compilers. 37 | 38 | 39 | 0.9.0c 40 | ~~~~~~ 41 | Fixed some problems in the library pertaining to some boundary cases. 42 | This makes the library behave more correctly in those situations. The 43 | fixes apply only to features (calls and parameters) not used by 44 | bzip2.c, so the non-fixedness of them in previous versions has no 45 | effect on reliability of bzip2.c. 46 | 47 | In bzlib.c: 48 | * made zero-length BZ_FLUSH work correctly in bzCompress(). 49 | * fixed bzWrite/bzRead to ignore zero-length requests. 50 | * fixed bzread to correctly handle read requests after EOF. 51 | * wrong parameter order in call to bzDecompressInit in 52 | bzBuffToBuffDecompress. Fixed. 53 | 54 | In compress.c: 55 | * changed setting of nGroups in sendMTFValues() so as to 56 | do a bit better on small files. This _does_ effect 57 | bzip2.c. 58 | 59 | 60 | 0.9.5a 61 | ~~~~~~ 62 | Major change: add a fallback sorting algorithm (blocksort.c) 63 | to give reasonable behaviour even for very repetitive inputs. 64 | Nuked --repetitive-best and --repetitive-fast since they are 65 | no longer useful. 66 | 67 | Minor changes: mostly a whole bunch of small changes/ 68 | bugfixes in the driver (bzip2.c). Changes pertaining to the 69 | user interface are: 70 | 71 | allow decompression of symlink'd files to stdout 72 | decompress/test files even without .bz2 extension 73 | give more accurate error messages for I/O errors 74 | when compressing/decompressing to stdout, don't catch control-C 75 | read flags from BZIP2 and BZIP environment variables 76 | decline to break hard links to a file unless forced with -f 77 | allow -c flag even with no filenames 78 | preserve file ownerships as far as possible 79 | make -s -1 give the expected block size (100k) 80 | add a flag -q --quiet to suppress nonessential warnings 81 | stop decoding flags after --, so files beginning in - can be handled 82 | resolved inconsistent naming: bzcat or bz2cat ? 83 | bzip2 --help now returns 0 84 | 85 | Programming-level changes are: 86 | 87 | fixed syntax error in GET_LL4 for Borland C++ 5.02 88 | let bzBuffToBuffDecompress return BZ_DATA_ERROR{_MAGIC} 89 | fix overshoot of mode-string end in bzopen_or_bzdopen 90 | wrapped bzlib.h in #ifdef __cplusplus ... extern "C" { ... } 91 | close file handles under all error conditions 92 | added minor mods so it compiles with DJGPP out of the box 93 | fixed Makefile so it doesn't give problems with BSD make 94 | fix uninitialised memory reads in dlltest.c 95 | 96 | 0.9.5b 97 | ~~~~~~ 98 | Open stdin/stdout in binary mode for DJGPP. 99 | 100 | 0.9.5c 101 | ~~~~~~ 102 | Changed BZ_N_OVERSHOOT to be ... + 2 instead of ... + 1. The + 1 103 | version could cause the sorted order to be wrong in some extremely 104 | obscure cases. Also changed setting of quadrant in blocksort.c. 105 | 106 | 0.9.5d 107 | ~~~~~~ 108 | The only functional change is to make bzlibVersion() in the library 109 | return the correct string. This has no effect whatsoever on the 110 | functioning of the bzip2 program or library. Added a couple of casts 111 | so the library compiles without warnings at level 3 in MS Visual 112 | Studio 6.0. Included a Y2K statement in the file Y2K_INFO. All other 113 | changes are minor documentation changes. 114 | 115 | 1.0 116 | ~~~ 117 | Several minor bugfixes and enhancements: 118 | 119 | * Large file support. The library uses 64-bit counters to 120 | count the volume of data passing through it. bzip2.c 121 | is now compiled with -D_FILE_OFFSET_BITS=64 to get large 122 | file support from the C library. -v correctly prints out 123 | file sizes greater than 4 gigabytes. All these changes have 124 | been made without assuming a 64-bit platform or a C compiler 125 | which supports 64-bit ints, so, except for the C library 126 | aspect, they are fully portable. 127 | 128 | * Decompression robustness. The library/program should be 129 | robust to any corruption of compressed data, detecting and 130 | handling _all_ corruption, instead of merely relying on 131 | the CRCs. What this means is that the program should 132 | never crash, given corrupted data, and the library should 133 | always return BZ_DATA_ERROR. 134 | 135 | * Fixed an obscure race-condition bug only ever observed on 136 | Solaris, in which, if you were very unlucky and issued 137 | control-C at exactly the wrong time, both input and output 138 | files would be deleted. 139 | 140 | * Don't run out of file handles on test/decompression when 141 | large numbers of files have invalid magic numbers. 142 | 143 | * Avoid library namespace pollution. Prefix all exported 144 | symbols with BZ2_. 145 | 146 | * Minor sorting enhancements from my DCC2000 paper. 147 | 148 | * Advance the version number to 1.0, so as to counteract the 149 | (false-in-this-case) impression some people have that programs 150 | with version numbers less than 1.0 are in some way, experimental, 151 | pre-release versions. 152 | 153 | * Create an initial Makefile-libbz2_so to build a shared library. 154 | Yes, I know I should really use libtool et al ... 155 | 156 | * Make the program exit with 2 instead of 0 when decompression 157 | fails due to a bad magic number (ie, an invalid bzip2 header). 158 | Also exit with 1 (as the manual claims :-) whenever a diagnostic 159 | message would have been printed AND the corresponding operation 160 | is aborted, for example 161 | bzip2: Output file xx already exists. 162 | When a diagnostic message is printed but the operation is not 163 | aborted, for example 164 | bzip2: Can't guess original name for wurble -- using wurble.out 165 | then the exit value 0 is returned, unless some other problem is 166 | also detected. 167 | 168 | I think it corresponds more closely to what the manual claims now. 169 | 170 | 171 | 1.0.1 172 | ~~~~~ 173 | * Modified dlltest.c so it uses the new BZ2_ naming scheme. 174 | * Modified makefile-msc to fix minor build probs on Win2k. 175 | * Updated README.COMPILATION.PROBLEMS. 176 | 177 | There are no functionality changes or bug fixes relative to version 178 | 1.0.0. This is just a documentation update + a fix for minor Win32 179 | build problems. For almost everyone, upgrading from 1.0.0 to 1.0.1 is 180 | utterly pointless. Don't bother. 181 | 182 | 183 | 1.0.2 184 | ~~~~~ 185 | A bug fix release, addressing various minor issues which have appeared 186 | in the 18 or so months since 1.0.1 was released. Most of the fixes 187 | are to do with file-handling or documentation bugs. To the best of my 188 | knowledge, there have been no data-loss-causing bugs reported in the 189 | compression/decompression engine of 1.0.0 or 1.0.1. 190 | 191 | Note that this release does not improve the rather crude build system 192 | for Unix platforms. The general plan here is to autoconfiscate/ 193 | libtoolise 1.0.2 soon after release, and release the result as 1.1.0 194 | or perhaps 1.2.0. That, however, is still just a plan at this point. 195 | 196 | Here are the changes in 1.0.2. Bug-reporters and/or patch-senders in 197 | parentheses. 198 | 199 | * Fix an infinite segfault loop in 1.0.1 when a directory is 200 | encountered in -f (force) mode. 201 | (Trond Eivind Glomsrod, Nicholas Nethercote, Volker Schmidt) 202 | 203 | * Avoid double fclose() of output file on certain I/O error paths. 204 | (Solar Designer) 205 | 206 | * Don't fail with internal error 1007 when fed a long stream (> 48MB) 207 | of byte 251. Also print useful message suggesting that 1007s may be 208 | caused by bad memory. 209 | (noticed by Juan Pedro Vallejo, fixed by me) 210 | 211 | * Fix uninitialised variable silly bug in demo prog dlltest.c. 212 | (Jorj Bauer) 213 | 214 | * Remove 512-MB limitation on recovered file size for bzip2recover 215 | on selected platforms which support 64-bit ints. At the moment 216 | all GCC supported platforms, and Win32. 217 | (me, Alson van der Meulen) 218 | 219 | * Hard-code header byte values, to give correct operation on platforms 220 | using EBCDIC as their native character set (IBM's OS/390). 221 | (Leland Lucius) 222 | 223 | * Copy file access times correctly. 224 | (Marty Leisner) 225 | 226 | * Add distclean and check targets to Makefile. 227 | (Michael Carmack) 228 | 229 | * Parameterise use of ar and ranlib in Makefile. Also add $(LDFLAGS). 230 | (Rich Ireland, Bo Thorsen) 231 | 232 | * Pass -p (create parent dirs as needed) to mkdir during make install. 233 | (Jeremy Fusco) 234 | 235 | * Dereference symlinks when copying file permissions in -f mode. 236 | (Volker Schmidt) 237 | 238 | * Majorly simplify implementation of uInt64_qrm10. 239 | (Bo Lindbergh) 240 | 241 | * Check the input file still exists before deleting the output one, 242 | when aborting in cleanUpAndFail(). 243 | (Joerg Prante, Robert Linden, Matthias Krings) 244 | 245 | Also a bunch of patches courtesy of Philippe Troin, the Debian maintainer 246 | of bzip2: 247 | 248 | * Wrapper scripts (with manpages): bzdiff, bzgrep, bzmore. 249 | 250 | * Spelling changes and minor enhancements in bzip2.1. 251 | 252 | * Avoid race condition between creating the output file and setting its 253 | interim permissions safely, by using fopen_output_safely(). 254 | No changes to bzip2recover since there is no issue with file 255 | permissions there. 256 | 257 | * do not print senseless report with -v when compressing an empty 258 | file. 259 | 260 | * bzcat -f works on non-bzip2 files. 261 | 262 | * do not try to escape shell meta-characters on unix (the shell takes 263 | care of these). 264 | 265 | * added --fast and --best aliases for -1 -9 for gzip compatibility. 266 | 267 | 268 | 1.0.3 (15 Feb 05) 269 | ~~~~~~~~~~~~~~~~~ 270 | Fixes some minor bugs since the last version, 1.0.2. 271 | 272 | * Further robustification against corrupted compressed data. 273 | There are currently no known bitstreams which can cause the 274 | decompressor to crash, loop or access memory which does not 275 | belong to it. If you are using bzip2 or the library to 276 | decompress bitstreams from untrusted sources, an upgrade 277 | to 1.0.3 is recommended. This fixes CAN-2005-1260. 278 | 279 | * The documentation has been converted to XML, from which html 280 | and pdf can be derived. 281 | 282 | * Various minor bugs in the documentation have been fixed. 283 | 284 | * Fixes for various compilation warnings with newer versions of 285 | gcc, and on 64-bit platforms. 286 | 287 | * The BZ_NO_STDIO cpp symbol was not properly observed in 1.0.2. 288 | This has been fixed. 289 | 290 | 291 | 1.0.4 (20 Dec 06) 292 | ~~~~~~~~~~~~~~~~~ 293 | Fixes some minor bugs since the last version, 1.0.3. 294 | 295 | * Fix file permissions race problem (CAN-2005-0953). 296 | 297 | * Avoid possible segfault in BZ2_bzclose. From Coverity's NetBSD 298 | scan. 299 | 300 | * 'const'/prototype cleanups in the C code. 301 | 302 | * Change default install location to /usr/local, and handle multiple 303 | 'make install's without error. 304 | 305 | * Sanitise file names more carefully in bzgrep. Fixes CAN-2005-0758 306 | to the extent that applies to bzgrep. 307 | 308 | * Use 'mktemp' rather than 'tempfile' in bzdiff. 309 | 310 | * Tighten up a couple of assertions in blocksort.c following automated 311 | analysis. 312 | 313 | * Fix minor doc/comment bugs. 314 | 315 | 316 | 1.0.5 (10 Dec 07) 317 | ~~~~~~~~~~~~~~~~~ 318 | Security fix only. Fixes CERT-FI 20469 as it applies to bzip2. 319 | 320 | 321 | 1.0.6 (6 Sept 10) 322 | ~~~~~~~~~~~~~~~~~ 323 | 324 | * Security fix for CVE-2010-0405. This was reported by Mikolaj 325 | Izdebski. 326 | 327 | * Make the documentation build on Ubuntu 10.04 328 | -------------------------------------------------------------------------------- /serverpatch/bzip2-1.0.6/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------- 3 | 4 | This program, "bzip2", the associated library "libbzip2", and all 5 | documentation, are copyright (C) 1996-2010 Julian R Seward. All 6 | rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions 10 | are met: 11 | 12 | 1. Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | 2. The origin of this software must not be misrepresented; you must 16 | not claim that you wrote the original software. If you use this 17 | software in a product, an acknowledgment in the product 18 | documentation would be appreciated but is not required. 19 | 20 | 3. Altered source versions must be plainly marked as such, and must 21 | not be misrepresented as being the original software. 22 | 23 | 4. The name of the author may not be used to endorse or promote 24 | products derived from this software without specific prior written 25 | permission. 26 | 27 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 28 | OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 29 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 30 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 31 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 33 | GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 34 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 35 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 36 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 37 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 | 39 | Julian Seward, jseward@bzip.org 40 | bzip2/libbzip2 version 1.0.6 of 6 September 2010 41 | 42 | -------------------------------------------------------------------------- 43 | -------------------------------------------------------------------------------- /serverpatch/bzip2-1.0.6/Makefile: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------ 2 | # This file is part of bzip2/libbzip2, a program and library for 3 | # lossless, block-sorting data compression. 4 | # 5 | # bzip2/libbzip2 version 1.0.6 of 6 September 2010 6 | # Copyright (C) 1996-2010 Julian Seward 7 | # 8 | # Please read the WARNING, DISCLAIMER and PATENTS sections in the 9 | # README file. 10 | # 11 | # This program is released under the terms of the license contained 12 | # in the file LICENSE. 13 | # ------------------------------------------------------------------ 14 | 15 | SHELL=/bin/sh 16 | 17 | # To assist in cross-compiling 18 | CC=gcc 19 | AR=ar 20 | RANLIB=ranlib 21 | LDFLAGS= 22 | 23 | BIGFILES=-D_FILE_OFFSET_BITS=64 24 | CFLAGS=-Wall -Winline -O2 -g $(BIGFILES) 25 | 26 | # Where you want it installed when you do 'make install' 27 | PREFIX=/usr/local 28 | 29 | 30 | OBJS= blocksort.o \ 31 | huffman.o \ 32 | crctable.o \ 33 | randtable.o \ 34 | compress.o \ 35 | decompress.o \ 36 | bzlib.o 37 | 38 | all: libbz2.a bzip2 bzip2recover test 39 | 40 | bzip2: libbz2.a bzip2.o 41 | $(CC) $(CFLAGS) $(LDFLAGS) -o bzip2 bzip2.o -L. -lbz2 42 | 43 | bzip2recover: bzip2recover.o 44 | $(CC) $(CFLAGS) $(LDFLAGS) -o bzip2recover bzip2recover.o 45 | 46 | libbz2.a: $(OBJS) 47 | rm -f libbz2.a 48 | $(AR) cq libbz2.a $(OBJS) 49 | @if ( test -f $(RANLIB) -o -f /usr/bin/ranlib -o \ 50 | -f /bin/ranlib -o -f /usr/ccs/bin/ranlib ) ; then \ 51 | echo $(RANLIB) libbz2.a ; \ 52 | $(RANLIB) libbz2.a ; \ 53 | fi 54 | 55 | check: test 56 | test: bzip2 57 | @cat words1 58 | ./bzip2 -1 < sample1.ref > sample1.rb2 59 | ./bzip2 -2 < sample2.ref > sample2.rb2 60 | ./bzip2 -3 < sample3.ref > sample3.rb2 61 | ./bzip2 -d < sample1.bz2 > sample1.tst 62 | ./bzip2 -d < sample2.bz2 > sample2.tst 63 | ./bzip2 -ds < sample3.bz2 > sample3.tst 64 | cmp sample1.bz2 sample1.rb2 65 | cmp sample2.bz2 sample2.rb2 66 | cmp sample3.bz2 sample3.rb2 67 | cmp sample1.tst sample1.ref 68 | cmp sample2.tst sample2.ref 69 | cmp sample3.tst sample3.ref 70 | @cat words3 71 | 72 | install: bzip2 bzip2recover 73 | if ( test ! -d $(PREFIX)/bin ) ; then mkdir -p $(PREFIX)/bin ; fi 74 | if ( test ! -d $(PREFIX)/lib ) ; then mkdir -p $(PREFIX)/lib ; fi 75 | if ( test ! -d $(PREFIX)/man ) ; then mkdir -p $(PREFIX)/man ; fi 76 | if ( test ! -d $(PREFIX)/man/man1 ) ; then mkdir -p $(PREFIX)/man/man1 ; fi 77 | if ( test ! -d $(PREFIX)/include ) ; then mkdir -p $(PREFIX)/include ; fi 78 | cp -f bzip2 $(PREFIX)/bin/bzip2 79 | cp -f bzip2 $(PREFIX)/bin/bunzip2 80 | cp -f bzip2 $(PREFIX)/bin/bzcat 81 | cp -f bzip2recover $(PREFIX)/bin/bzip2recover 82 | chmod a+x $(PREFIX)/bin/bzip2 83 | chmod a+x $(PREFIX)/bin/bunzip2 84 | chmod a+x $(PREFIX)/bin/bzcat 85 | chmod a+x $(PREFIX)/bin/bzip2recover 86 | cp -f bzip2.1 $(PREFIX)/man/man1 87 | chmod a+r $(PREFIX)/man/man1/bzip2.1 88 | cp -f bzlib.h $(PREFIX)/include 89 | chmod a+r $(PREFIX)/include/bzlib.h 90 | cp -f libbz2.a $(PREFIX)/lib 91 | chmod a+r $(PREFIX)/lib/libbz2.a 92 | cp -f bzgrep $(PREFIX)/bin/bzgrep 93 | ln -s -f $(PREFIX)/bin/bzgrep $(PREFIX)/bin/bzegrep 94 | ln -s -f $(PREFIX)/bin/bzgrep $(PREFIX)/bin/bzfgrep 95 | chmod a+x $(PREFIX)/bin/bzgrep 96 | cp -f bzmore $(PREFIX)/bin/bzmore 97 | ln -s -f $(PREFIX)/bin/bzmore $(PREFIX)/bin/bzless 98 | chmod a+x $(PREFIX)/bin/bzmore 99 | cp -f bzdiff $(PREFIX)/bin/bzdiff 100 | ln -s -f $(PREFIX)/bin/bzdiff $(PREFIX)/bin/bzcmp 101 | chmod a+x $(PREFIX)/bin/bzdiff 102 | cp -f bzgrep.1 bzmore.1 bzdiff.1 $(PREFIX)/man/man1 103 | chmod a+r $(PREFIX)/man/man1/bzgrep.1 104 | chmod a+r $(PREFIX)/man/man1/bzmore.1 105 | chmod a+r $(PREFIX)/man/man1/bzdiff.1 106 | echo ".so man1/bzgrep.1" > $(PREFIX)/man/man1/bzegrep.1 107 | echo ".so man1/bzgrep.1" > $(PREFIX)/man/man1/bzfgrep.1 108 | echo ".so man1/bzmore.1" > $(PREFIX)/man/man1/bzless.1 109 | echo ".so man1/bzdiff.1" > $(PREFIX)/man/man1/bzcmp.1 110 | 111 | clean: 112 | rm -f *.o libbz2.a bzip2 bzip2recover \ 113 | sample1.rb2 sample2.rb2 sample3.rb2 \ 114 | sample1.tst sample2.tst sample3.tst 115 | 116 | blocksort.o: blocksort.c 117 | @cat words0 118 | $(CC) $(CFLAGS) -c blocksort.c 119 | huffman.o: huffman.c 120 | $(CC) $(CFLAGS) -c huffman.c 121 | crctable.o: crctable.c 122 | $(CC) $(CFLAGS) -c crctable.c 123 | randtable.o: randtable.c 124 | $(CC) $(CFLAGS) -c randtable.c 125 | compress.o: compress.c 126 | $(CC) $(CFLAGS) -c compress.c 127 | decompress.o: decompress.c 128 | $(CC) $(CFLAGS) -c decompress.c 129 | bzlib.o: bzlib.c 130 | $(CC) $(CFLAGS) -c bzlib.c 131 | bzip2.o: bzip2.c 132 | $(CC) $(CFLAGS) -c bzip2.c 133 | bzip2recover.o: bzip2recover.c 134 | $(CC) $(CFLAGS) -c bzip2recover.c 135 | 136 | 137 | distclean: clean 138 | rm -f manual.ps manual.html manual.pdf 139 | 140 | DISTNAME=bzip2-1.0.6 141 | dist: check manual 142 | rm -f $(DISTNAME) 143 | ln -s -f . $(DISTNAME) 144 | tar cvf $(DISTNAME).tar \ 145 | $(DISTNAME)/blocksort.c \ 146 | $(DISTNAME)/huffman.c \ 147 | $(DISTNAME)/crctable.c \ 148 | $(DISTNAME)/randtable.c \ 149 | $(DISTNAME)/compress.c \ 150 | $(DISTNAME)/decompress.c \ 151 | $(DISTNAME)/bzlib.c \ 152 | $(DISTNAME)/bzip2.c \ 153 | $(DISTNAME)/bzip2recover.c \ 154 | $(DISTNAME)/bzlib.h \ 155 | $(DISTNAME)/bzlib_private.h \ 156 | $(DISTNAME)/Makefile \ 157 | $(DISTNAME)/LICENSE \ 158 | $(DISTNAME)/bzip2.1 \ 159 | $(DISTNAME)/bzip2.1.preformatted \ 160 | $(DISTNAME)/bzip2.txt \ 161 | $(DISTNAME)/words0 \ 162 | $(DISTNAME)/words1 \ 163 | $(DISTNAME)/words2 \ 164 | $(DISTNAME)/words3 \ 165 | $(DISTNAME)/sample1.ref \ 166 | $(DISTNAME)/sample2.ref \ 167 | $(DISTNAME)/sample3.ref \ 168 | $(DISTNAME)/sample1.bz2 \ 169 | $(DISTNAME)/sample2.bz2 \ 170 | $(DISTNAME)/sample3.bz2 \ 171 | $(DISTNAME)/dlltest.c \ 172 | $(DISTNAME)/manual.html \ 173 | $(DISTNAME)/manual.pdf \ 174 | $(DISTNAME)/manual.ps \ 175 | $(DISTNAME)/README \ 176 | $(DISTNAME)/README.COMPILATION.PROBLEMS \ 177 | $(DISTNAME)/README.XML.STUFF \ 178 | $(DISTNAME)/CHANGES \ 179 | $(DISTNAME)/libbz2.def \ 180 | $(DISTNAME)/libbz2.dsp \ 181 | $(DISTNAME)/dlltest.dsp \ 182 | $(DISTNAME)/makefile.msc \ 183 | $(DISTNAME)/unzcrash.c \ 184 | $(DISTNAME)/spewG.c \ 185 | $(DISTNAME)/mk251.c \ 186 | $(DISTNAME)/bzdiff \ 187 | $(DISTNAME)/bzdiff.1 \ 188 | $(DISTNAME)/bzmore \ 189 | $(DISTNAME)/bzmore.1 \ 190 | $(DISTNAME)/bzgrep \ 191 | $(DISTNAME)/bzgrep.1 \ 192 | $(DISTNAME)/Makefile-libbz2_so \ 193 | $(DISTNAME)/bz-common.xsl \ 194 | $(DISTNAME)/bz-fo.xsl \ 195 | $(DISTNAME)/bz-html.xsl \ 196 | $(DISTNAME)/bzip.css \ 197 | $(DISTNAME)/entities.xml \ 198 | $(DISTNAME)/manual.xml \ 199 | $(DISTNAME)/format.pl \ 200 | $(DISTNAME)/xmlproc.sh 201 | gzip -v $(DISTNAME).tar 202 | 203 | # For rebuilding the manual from sources on my SuSE 9.1 box 204 | 205 | MANUAL_SRCS= bz-common.xsl bz-fo.xsl bz-html.xsl bzip.css \ 206 | entities.xml manual.xml 207 | 208 | manual: manual.html manual.ps manual.pdf 209 | 210 | manual.ps: $(MANUAL_SRCS) 211 | ./xmlproc.sh -ps manual.xml 212 | 213 | manual.pdf: $(MANUAL_SRCS) 214 | ./xmlproc.sh -pdf manual.xml 215 | 216 | manual.html: $(MANUAL_SRCS) 217 | ./xmlproc.sh -html manual.xml 218 | -------------------------------------------------------------------------------- /serverpatch/bzip2-1.0.6/Makefile-libbz2_so: -------------------------------------------------------------------------------- 1 | 2 | # This Makefile builds a shared version of the library, 3 | # libbz2.so.1.0.6, with soname libbz2.so.1.0, 4 | # at least on x86-Linux (RedHat 7.2), 5 | # with gcc-2.96 20000731 (Red Hat Linux 7.1 2.96-98). 6 | # Please see the README file for some important info 7 | # about building the library like this. 8 | 9 | # ------------------------------------------------------------------ 10 | # This file is part of bzip2/libbzip2, a program and library for 11 | # lossless, block-sorting data compression. 12 | # 13 | # bzip2/libbzip2 version 1.0.6 of 6 September 2010 14 | # Copyright (C) 1996-2010 Julian Seward 15 | # 16 | # Please read the WARNING, DISCLAIMER and PATENTS sections in the 17 | # README file. 18 | # 19 | # This program is released under the terms of the license contained 20 | # in the file LICENSE. 21 | # ------------------------------------------------------------------ 22 | 23 | 24 | SHELL=/bin/sh 25 | CC=gcc 26 | BIGFILES=-D_FILE_OFFSET_BITS=64 27 | CFLAGS=-fpic -fPIC -Wall -Winline -O2 -g $(BIGFILES) 28 | 29 | OBJS= blocksort.o \ 30 | huffman.o \ 31 | crctable.o \ 32 | randtable.o \ 33 | compress.o \ 34 | decompress.o \ 35 | bzlib.o 36 | 37 | all: $(OBJS) 38 | $(CC) -shared -Wl,-soname -Wl,libbz2.so.1.0 -o libbz2.so.1.0.6 $(OBJS) 39 | $(CC) $(CFLAGS) -o bzip2-shared bzip2.c libbz2.so.1.0.6 40 | rm -f libbz2.so.1.0 41 | ln -s libbz2.so.1.0.6 libbz2.so.1.0 42 | 43 | clean: 44 | rm -f $(OBJS) bzip2.o libbz2.so.1.0.6 libbz2.so.1.0 bzip2-shared 45 | 46 | blocksort.o: blocksort.c 47 | $(CC) $(CFLAGS) -c blocksort.c 48 | huffman.o: huffman.c 49 | $(CC) $(CFLAGS) -c huffman.c 50 | crctable.o: crctable.c 51 | $(CC) $(CFLAGS) -c crctable.c 52 | randtable.o: randtable.c 53 | $(CC) $(CFLAGS) -c randtable.c 54 | compress.o: compress.c 55 | $(CC) $(CFLAGS) -c compress.c 56 | decompress.o: decompress.c 57 | $(CC) $(CFLAGS) -c decompress.c 58 | bzlib.o: bzlib.c 59 | $(CC) $(CFLAGS) -c bzlib.c 60 | -------------------------------------------------------------------------------- /serverpatch/bzip2-1.0.6/README: -------------------------------------------------------------------------------- 1 | 2 | This is the README for bzip2/libzip2. 3 | This version is fully compatible with the previous public releases. 4 | 5 | ------------------------------------------------------------------ 6 | This file is part of bzip2/libbzip2, a program and library for 7 | lossless, block-sorting data compression. 8 | 9 | bzip2/libbzip2 version 1.0.6 of 6 September 2010 10 | Copyright (C) 1996-2010 Julian Seward 11 | 12 | Please read the WARNING, DISCLAIMER and PATENTS sections in this file. 13 | 14 | This program is released under the terms of the license contained 15 | in the file LICENSE. 16 | ------------------------------------------------------------------ 17 | 18 | Complete documentation is available in Postscript form (manual.ps), 19 | PDF (manual.pdf) or html (manual.html). A plain-text version of the 20 | manual page is available as bzip2.txt. 21 | 22 | 23 | HOW TO BUILD -- UNIX 24 | 25 | Type 'make'. This builds the library libbz2.a and then the programs 26 | bzip2 and bzip2recover. Six self-tests are run. If the self-tests 27 | complete ok, carry on to installation: 28 | 29 | To install in /usr/local/bin, /usr/local/lib, /usr/local/man and 30 | /usr/local/include, type 31 | 32 | make install 33 | 34 | To install somewhere else, eg, /xxx/yyy/{bin,lib,man,include}, type 35 | 36 | make install PREFIX=/xxx/yyy 37 | 38 | If you are (justifiably) paranoid and want to see what 'make install' 39 | is going to do, you can first do 40 | 41 | make -n install or 42 | make -n install PREFIX=/xxx/yyy respectively. 43 | 44 | The -n instructs make to show the commands it would execute, but not 45 | actually execute them. 46 | 47 | 48 | HOW TO BUILD -- UNIX, shared library libbz2.so. 49 | 50 | Do 'make -f Makefile-libbz2_so'. This Makefile seems to work for 51 | Linux-ELF (RedHat 7.2 on an x86 box), with gcc. I make no claims 52 | that it works for any other platform, though I suspect it probably 53 | will work for most platforms employing both ELF and gcc. 54 | 55 | bzip2-shared, a client of the shared library, is also built, but not 56 | self-tested. So I suggest you also build using the normal Makefile, 57 | since that conducts a self-test. A second reason to prefer the 58 | version statically linked to the library is that, on x86 platforms, 59 | building shared objects makes a valuable register (%ebx) unavailable 60 | to gcc, resulting in a slowdown of 10%-20%, at least for bzip2. 61 | 62 | Important note for people upgrading .so's from 0.9.0/0.9.5 to version 63 | 1.0.X. All the functions in the library have been renamed, from (eg) 64 | bzCompress to BZ2_bzCompress, to avoid namespace pollution. 65 | Unfortunately this means that the libbz2.so created by 66 | Makefile-libbz2_so will not work with any program which used an older 67 | version of the library. I do encourage library clients to make the 68 | effort to upgrade to use version 1.0, since it is both faster and more 69 | robust than previous versions. 70 | 71 | 72 | HOW TO BUILD -- Windows 95, NT, DOS, Mac, etc. 73 | 74 | It's difficult for me to support compilation on all these platforms. 75 | My approach is to collect binaries for these platforms, and put them 76 | on the master web site (http://www.bzip.org). Look there. However 77 | (FWIW), bzip2-1.0.X is very standard ANSI C and should compile 78 | unmodified with MS Visual C. If you have difficulties building, you 79 | might want to read README.COMPILATION.PROBLEMS. 80 | 81 | At least using MS Visual C++ 6, you can build from the unmodified 82 | sources by issuing, in a command shell: 83 | 84 | nmake -f makefile.msc 85 | 86 | (you may need to first run the MSVC-provided script VCVARS32.BAT 87 | so as to set up paths to the MSVC tools correctly). 88 | 89 | 90 | VALIDATION 91 | 92 | Correct operation, in the sense that a compressed file can always be 93 | decompressed to reproduce the original, is obviously of paramount 94 | importance. To validate bzip2, I used a modified version of Mark 95 | Nelson's churn program. Churn is an automated test driver which 96 | recursively traverses a directory structure, using bzip2 to compress 97 | and then decompress each file it encounters, and checking that the 98 | decompressed data is the same as the original. 99 | 100 | 101 | 102 | Please read and be aware of the following: 103 | 104 | WARNING: 105 | 106 | This program and library (attempts to) compress data by 107 | performing several non-trivial transformations on it. 108 | Unless you are 100% familiar with *all* the algorithms 109 | contained herein, and with the consequences of modifying them, 110 | you should NOT meddle with the compression or decompression 111 | machinery. Incorrect changes can and very likely *will* 112 | lead to disastrous loss of data. 113 | 114 | 115 | DISCLAIMER: 116 | 117 | I TAKE NO RESPONSIBILITY FOR ANY LOSS OF DATA ARISING FROM THE 118 | USE OF THIS PROGRAM/LIBRARY, HOWSOEVER CAUSED. 119 | 120 | Every compression of a file implies an assumption that the 121 | compressed file can be decompressed to reproduce the original. 122 | Great efforts in design, coding and testing have been made to 123 | ensure that this program works correctly. However, the complexity 124 | of the algorithms, and, in particular, the presence of various 125 | special cases in the code which occur with very low but non-zero 126 | probability make it impossible to rule out the possibility of bugs 127 | remaining in the program. DO NOT COMPRESS ANY DATA WITH THIS 128 | PROGRAM UNLESS YOU ARE PREPARED TO ACCEPT THE POSSIBILITY, HOWEVER 129 | SMALL, THAT THE DATA WILL NOT BE RECOVERABLE. 130 | 131 | That is not to say this program is inherently unreliable. 132 | Indeed, I very much hope the opposite is true. bzip2/libbzip2 133 | has been carefully constructed and extensively tested. 134 | 135 | 136 | PATENTS: 137 | 138 | To the best of my knowledge, bzip2/libbzip2 does not use any 139 | patented algorithms. However, I do not have the resources 140 | to carry out a patent search. Therefore I cannot give any 141 | guarantee of the above statement. 142 | 143 | 144 | 145 | WHAT'S NEW IN 0.9.0 (as compared to 0.1pl2) ? 146 | 147 | * Approx 10% faster compression, 30% faster decompression 148 | * -t (test mode) is a lot quicker 149 | * Can decompress concatenated compressed files 150 | * Programming interface, so programs can directly read/write .bz2 files 151 | * Less restrictive (BSD-style) licensing 152 | * Flag handling more compatible with GNU gzip 153 | * Much more documentation, i.e., a proper user manual 154 | * Hopefully, improved portability (at least of the library) 155 | 156 | WHAT'S NEW IN 0.9.5 ? 157 | 158 | * Compression speed is much less sensitive to the input 159 | data than in previous versions. Specifically, the very 160 | slow performance caused by repetitive data is fixed. 161 | * Many small improvements in file and flag handling. 162 | * A Y2K statement. 163 | 164 | WHAT'S NEW IN 1.0.0 ? 165 | 166 | See the CHANGES file. 167 | 168 | WHAT'S NEW IN 1.0.2 ? 169 | 170 | See the CHANGES file. 171 | 172 | WHAT'S NEW IN 1.0.3 ? 173 | 174 | See the CHANGES file. 175 | 176 | WHAT'S NEW IN 1.0.4 ? 177 | 178 | See the CHANGES file. 179 | 180 | WHAT'S NEW IN 1.0.5 ? 181 | 182 | See the CHANGES file. 183 | 184 | WHAT'S NEW IN 1.0.6 ? 185 | 186 | See the CHANGES file. 187 | 188 | 189 | I hope you find bzip2 useful. Feel free to contact me at 190 | jseward@bzip.org 191 | if you have any suggestions or queries. Many people mailed me with 192 | comments, suggestions and patches after the releases of bzip-0.15, 193 | bzip-0.21, and bzip2 versions 0.1pl2, 0.9.0, 0.9.5, 1.0.0, 1.0.1, 194 | 1.0.2 and 1.0.3, and the changes in bzip2 are largely a result of this 195 | feedback. I thank you for your comments. 196 | 197 | bzip2's "home" is http://www.bzip.org/ 198 | 199 | Julian Seward 200 | jseward@bzip.org 201 | Cambridge, UK. 202 | 203 | 18 July 1996 (version 0.15) 204 | 25 August 1996 (version 0.21) 205 | 7 August 1997 (bzip2, version 0.1) 206 | 29 August 1997 (bzip2, version 0.1pl2) 207 | 23 August 1998 (bzip2, version 0.9.0) 208 | 8 June 1999 (bzip2, version 0.9.5) 209 | 4 Sept 1999 (bzip2, version 0.9.5d) 210 | 5 May 2000 (bzip2, version 1.0pre8) 211 | 30 December 2001 (bzip2, version 1.0.2pre1) 212 | 15 February 2005 (bzip2, version 1.0.3) 213 | 20 December 2006 (bzip2, version 1.0.4) 214 | 10 December 2007 (bzip2, version 1.0.5) 215 | 6 Sept 2010 (bzip2, version 1.0.6) 216 | -------------------------------------------------------------------------------- /serverpatch/bzip2-1.0.6/README.COMPILATION.PROBLEMS: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------ 2 | This file is part of bzip2/libbzip2, a program and library for 3 | lossless, block-sorting data compression. 4 | 5 | bzip2/libbzip2 version 1.0.6 of 6 September 2010 6 | Copyright (C) 1996-2010 Julian Seward 7 | 8 | Please read the WARNING, DISCLAIMER and PATENTS sections in the 9 | README file. 10 | 11 | This program is released under the terms of the license contained 12 | in the file LICENSE. 13 | ------------------------------------------------------------------ 14 | 15 | bzip2-1.0.6 should compile without problems on the vast majority of 16 | platforms. Using the supplied Makefile, I've built and tested it 17 | myself for x86-linux and amd64-linux. With makefile.msc, Visual C++ 18 | 6.0 and nmake, you can build a native Win32 version too. Large file 19 | support seems to work correctly on at least on amd64-linux. 20 | 21 | When I say "large file" I mean a file of size 2,147,483,648 (2^31) 22 | bytes or above. Many older OSs can't handle files above this size, 23 | but many newer ones can. Large files are pretty huge -- most files 24 | you'll encounter are not Large Files. 25 | 26 | Early versions of bzip2 (0.1, 0.9.0, 0.9.5) compiled on a wide variety 27 | of platforms without difficulty, and I hope this version will continue 28 | in that tradition. However, in order to support large files, I've had 29 | to include the define -D_FILE_OFFSET_BITS=64 in the Makefile. This 30 | can cause problems. 31 | 32 | The technique of adding -D_FILE_OFFSET_BITS=64 to get large file 33 | support is, as far as I know, the Recommended Way to get correct large 34 | file support. For more details, see the Large File Support 35 | Specification, published by the Large File Summit, at 36 | 37 | http://ftp.sas.com/standards/large.file 38 | 39 | As a general comment, if you get compilation errors which you think 40 | are related to large file support, try removing the above define from 41 | the Makefile, ie, delete the line 42 | 43 | BIGFILES=-D_FILE_OFFSET_BITS=64 44 | 45 | from the Makefile, and do 'make clean ; make'. This will give you a 46 | version of bzip2 without large file support, which, for most 47 | applications, is probably not a problem. 48 | 49 | Alternatively, try some of the platform-specific hints listed below. 50 | 51 | You can use the spewG.c program to generate huge files to test bzip2's 52 | large file support, if you are feeling paranoid. Be aware though that 53 | any compilation problems which affect bzip2 will also affect spewG.c, 54 | alas. 55 | 56 | AIX: I have reports that for large file support, you need to specify 57 | -D_LARGE_FILES rather than -D_FILE_OFFSET_BITS=64. I have not tested 58 | this myself. 59 | -------------------------------------------------------------------------------- /serverpatch/bzip2-1.0.6/README.XML.STUFF: -------------------------------------------------------------------------------- 1 | ---------------------------------------------------------------- 2 | This file is part of bzip2/libbzip2, a program and library for 3 | lossless, block-sorting data compression. 4 | 5 | bzip2/libbzip2 version 1.0.6 of 6 September 2010 6 | Copyright (C) 1996-2010 Julian Seward 7 | 8 | Please read the WARNING, DISCLAIMER and PATENTS sections in the 9 | README file. 10 | 11 | This program is released under the terms of the license contained 12 | in the file LICENSE. 13 | ---------------------------------------------------------------- 14 | 15 | The script xmlproc.sh takes an xml file as input, 16 | and processes it to create .pdf, .html or .ps output. 17 | It uses format.pl, a perl script to format
 blocks nicely,
18 |  and add CDATA tags so writers do not have to use eg. < 
19 | 
20 | The file "entities.xml" must be edited to reflect current
21 | version, year, etc.
22 | 
23 | 
24 | Usage:
25 | 
26 |   ./xmlproc.sh -v manual.xml
27 |   Validates an xml file to ensure no dtd-compliance errors
28 | 
29 |   ./xmlproc.sh -html manual.xml
30 |   Output: manual.html
31 | 
32 |   ./xmlproc.sh -pdf manual.xml
33 |   Output: manual.pdf
34 | 
35 |   ./xmlproc.sh -ps manual.xml
36 |   Output: manual.ps
37 | 
38 | 
39 | Notum bene: 
40 | - pdfxmltex barfs if given a filename with an underscore in it
41 | 
42 | - xmltex won't work yet - there's a bug in passivetex
43 |     which we are all waiting for Sebastian to fix.
44 |   So we are going the xml -> pdf -> ps route for the time being,
45 |     using pdfxmltex.
46 | 


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/blocksort.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ChanJLee/android-patch/85678d935494f8a7dc1919f7b20469de81d9c465/serverpatch/bzip2-1.0.6/blocksort.o


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/bz-common.xsl:
--------------------------------------------------------------------------------
 1 |  
 2 | 
 4 | 
 5 | 
 6 |  
 7 | 
 8 | 
 9 | 
10 |  
11 |  
12 |    
13 |     
14 |       
15 |      
16 |   
17 | 
18 | 
19 | 
20 | 
21 | set       toc,title
22 | book      toc,title,figure,table,example,equation
23 | chapter   toc,title
24 | section   toc
25 | sect1     toc
26 | sect2     toc
27 | sect3     toc
28 | sect4     nop
29 | sect5     nop
30 | qandaset  toc
31 | qandadiv  nop
32 | appendix  toc,title
33 | article/appendix  nop
34 | article   toc,title
35 | preface   toc,title
36 | reference toc,title
37 | 
38 | 
39 | 
40 | 


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/bz-fo.xsl:
--------------------------------------------------------------------------------
  1 |  
  2 | 
  4 | 
  5 | 
  6 | 
  7 | 
  8 | 
  9 | 
 10 | 
 11 | 
 12 | 
 13 | 
 14 | 
 15 |       
 16 |      
 17 |    
 18 | 
 19 | 
 20 | 
 21 | 
 22 |  
 23 | 
 24 | 
 25 | 
 26 | 
 27 | 
 28 | 
 29 |   
 30 | 
 31 | 
 32 | 
 33 | 
 34 |   blue
 35 | 
 36 | 
 37 | 
 38 | 
 39 |   
 44 |     
 45 |   
 46 | 
 47 | 
 48 | 
 49 |   
 54 |     
 55 |   
 56 | 
 57 | 
 58 | 
 59 | 
 60 |   
 61 |   
 62 |   
 63 |     
 64 |       
 65 |     
 66 |   
 67 |   
 68 |     
 69 |       
 70 |         
 71 |           
 72 |           
 73 |           
 74 |         
 75 |       
 76 |     
 77 |     
 78 |           
 79 |     
 80 |   
 81 |   
 82 |     
 83 |       
 85 |         
 86 |       
 87 |     
 88 |     
 89 |       
 90 |         
 91 |       
 92 |     
 93 |   
 94 | 
 95 | 
 96 | 
 97 | 
 98 |   
 99 |   
100 |   
101 |     
102 |       
103 |         
104 |       
105 |     
106 |     
107 |           
108 |     
109 |   
110 |   
111 |     
112 |       
114 |         
115 |       
116 |     
117 |     
118 |       
119 |         
120 |       
121 |     
122 |   
123 | 
124 | 
125 | 
126 | 
127 | 
128 |   
129 |     
130 |   
133 |     
134 |   
135 |   
139 |     
140 |       
141 |     
142 |   
143 | 
144 | 
145 | 
146 | 
147 | 
148 |   
149 |   
150 |   
151 |   
152 |     
153 |       0pt
154 |     
155 |   
156 |   
157 |     
158 |       
159 |       
160 |       
161 |         
162 |           
163 |             baseline
164 |              
165 |                
166 |             
167 |           
168 |           
169 |             baseline
170 |             
171 |               
172 |                 
173 |                 
174 |                 
175 |                 
176 |               
177 |             
178 |           
179 |         
180 |       
181 |     
182 |   
183 |   
184 |   
185 |     
187 |       
188 |     
189 |     
190 |       
191 |     
192 |     
193 |       
194 |     
195 |   
196 | 
197 | 
198 | 
199 | 
200 | 
201 |   
202 |   
203 |   
204 |   
205 |     
206 |       0pt
207 |     
208 |   
209 |   
210 |     
211 |       
212 |         
213 |         
214 |         
215 |       
216 |       
217 |       
218 |       
219 |         
220 |           
221 |             baseline
222 |             
223 |                
224 |             
225 |           
226 |           
227 |             baseline
228 |             
229 |               
230 |                 
231 |                 
232 |                 
233 |                 
234 |               
235 |             
236 |           
237 |         
238 |       
239 |     
240 |   
241 |   
242 |   
243 |     
245 |       
246 |     
247 |     
248 |       
249 |     
250 |     
251 |       
252 |     
253 |   
254 | 
255 | 
256 | 
257 | 
258 | 
259 | 
260 |   always
261 |   
262 |     
263 |   
264 |   
265 |     
266 |     pt
267 |   
268 |   
269 |     
270 |     pt
271 |   
272 |   false
273 | 
274 | 
275 | 
276 | 
277 | 


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/bz-html.xsl:
--------------------------------------------------------------------------------
 1 |  
 2 |  ]>
 3 | 
 4 | 
 6 | 
 7 | 
 8 | 
 9 | 
10 | 
11 | 
12 | 
13 | 
14 |   
15 |   
18 | 
19 | 
20 | 
21 | 


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/bzdiff:
--------------------------------------------------------------------------------
 1 | #!/bin/sh
 2 | # sh is buggy on RS/6000 AIX 3.2. Replace above line with #!/bin/ksh
 3 | 
 4 | # Bzcmp/diff wrapped for bzip2, 
 5 | # adapted from zdiff by Philippe Troin  for Debian GNU/Linux.
 6 | 
 7 | # Bzcmp and bzdiff are used to invoke the cmp or the  diff  pro-
 8 | # gram  on compressed files.  All options specified are passed
 9 | # directly to cmp or diff.  If only 1 file is specified,  then
10 | # the  files  compared  are file1 and an uncompressed file1.gz.
11 | # If two files are specified, then they are  uncompressed  (if
12 | # necessary) and fed to cmp or diff.  The exit status from cmp
13 | # or diff is preserved.
14 | 
15 | PATH="/usr/bin:/bin:$PATH"; export PATH
16 | prog=`echo $0 | sed 's|.*/||'`
17 | case "$prog" in
18 |   *cmp) comp=${CMP-cmp}   ;;
19 |   *)    comp=${DIFF-diff} ;;
20 | esac
21 | 
22 | OPTIONS=
23 | FILES=
24 | for ARG
25 | do
26 |     case "$ARG" in
27 |     -*)	OPTIONS="$OPTIONS $ARG";;
28 |      *)	if test -f "$ARG"; then
29 |             FILES="$FILES $ARG"
30 |         else
31 |             echo "${prog}: $ARG not found or not a regular file"
32 | 	    exit 1
33 |         fi ;;
34 |     esac
35 | done
36 | if test -z "$FILES"; then
37 | 	echo "Usage: $prog [${comp}_options] file [file]"
38 | 	exit 1
39 | fi
40 | tmp=`mktemp ${TMPDIR:-/tmp}/bzdiff.XXXXXXXXXX` || {
41 |       echo 'cannot create a temporary file' >&2
42 |       exit 1
43 | }
44 | set $FILES
45 | if test $# -eq 1; then
46 | 	FILE=`echo "$1" | sed 's/.bz2$//'`
47 | 	bzip2 -cd "$FILE.bz2" | $comp $OPTIONS - "$FILE"
48 | 	STAT="$?"
49 | 
50 | elif test $# -eq 2; then
51 | 	case "$1" in
52 |         *.bz2)
53 |                 case "$2" in
54 | 	        *.bz2)
55 | 			F=`echo "$2" | sed 's|.*/||;s|.bz2$||'`
56 |                         bzip2 -cdfq "$2" > $tmp
57 |                         bzip2 -cdfq "$1" | $comp $OPTIONS - $tmp
58 |                         STAT="$?"
59 | 			/bin/rm -f $tmp;;
60 | 
61 |                 *)      bzip2 -cdfq "$1" | $comp $OPTIONS - "$2"
62 |                         STAT="$?";;
63 |                 esac;;
64 |         *)      case "$2" in
65 | 	        *.bz2)
66 |                         bzip2 -cdfq "$2" | $comp $OPTIONS "$1" -
67 |                         STAT="$?";;
68 |                 *)      $comp $OPTIONS "$1" "$2"
69 |                         STAT="$?";;
70 |                 esac;;
71 | 	esac
72 |         exit "$STAT"
73 | else
74 | 	echo "Usage: $prog [${comp}_options] file [file]"
75 | 	exit 1
76 | fi
77 | 


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/bzdiff.1:
--------------------------------------------------------------------------------
 1 | \"Shamelessly copied from zmore.1 by Philippe Troin 
 2 | \"for Debian GNU/Linux
 3 | .TH BZDIFF 1
 4 | .SH NAME
 5 | bzcmp, bzdiff \- compare bzip2 compressed files
 6 | .SH SYNOPSIS
 7 | .B bzcmp
 8 | [ cmp_options ] file1
 9 | [ file2 ]
10 | .br
11 | .B bzdiff
12 | [ diff_options ] file1
13 | [ file2 ]
14 | .SH DESCRIPTION
15 | .I  Bzcmp
16 | and 
17 | .I bzdiff
18 | are used to invoke the
19 | .I cmp
20 | or the
21 | .I diff
22 | program on bzip2 compressed files.  All options specified are passed
23 | directly to
24 | .I cmp
25 | or
26 | .IR diff "."
27 | If only 1 file is specified, then the files compared are
28 | .I file1
29 | and an uncompressed
30 | .IR file1 ".bz2."
31 | If two files are specified, then they are uncompressed if necessary and fed to
32 | .I cmp
33 | or
34 | .IR diff "."
35 | The exit status from 
36 | .I cmp
37 | or
38 | .I diff
39 | is preserved.
40 | .SH "SEE ALSO"
41 | cmp(1), diff(1), bzmore(1), bzless(1), bzgrep(1), bzip2(1)
42 | .SH BUGS
43 | Messages from the
44 | .I cmp
45 | or
46 | .I diff
47 | programs refer to temporary filenames instead of those specified.
48 | 


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/bzgrep:
--------------------------------------------------------------------------------
 1 | #!/bin/sh
 2 | 
 3 | # Bzgrep wrapped for bzip2, 
 4 | # adapted from zgrep by Philippe Troin  for Debian GNU/Linux.
 5 | ## zgrep notice:
 6 | ## zgrep -- a wrapper around a grep program that decompresses files as needed
 7 | ## Adapted from a version sent by Charles Levert 
 8 | 
 9 | PATH="/usr/bin:$PATH"; export PATH
10 | 
11 | prog=`echo $0 | sed 's|.*/||'`
12 | case "$prog" in
13 | 	*egrep)	grep=${EGREP-egrep}	;;
14 | 	*fgrep)	grep=${FGREP-fgrep}	;;
15 | 	*)	grep=${GREP-grep}	;;
16 | esac
17 | pat=""
18 | while test $# -ne 0; do
19 |   case "$1" in
20 |   -e | -f) opt="$opt $1"; shift; pat="$1"
21 |            if test "$grep" = grep; then  # grep is buggy with -e on SVR4
22 |              grep=egrep
23 |            fi;;
24 |   -A | -B) opt="$opt $1 $2"; shift;;
25 |   -*)	   opt="$opt $1";;
26 |    *)      if test -z "$pat"; then
27 | 	     pat="$1"
28 | 	   else
29 | 	     break;
30 |            fi;;
31 |   esac
32 |   shift
33 | done
34 | 
35 | if test -z "$pat"; then
36 |   echo "grep through bzip2 files"
37 |   echo "usage: $prog [grep_options] pattern [files]"
38 |   exit 1
39 | fi
40 | 
41 | list=0
42 | silent=0
43 | op=`echo "$opt" | sed -e 's/ //g' -e 's/-//g'`
44 | case "$op" in
45 |   *l*) list=1
46 | esac
47 | case "$op" in
48 |   *h*) silent=1
49 | esac
50 | 
51 | if test $# -eq 0; then
52 |   bzip2 -cdfq | $grep $opt "$pat"
53 |   exit $?
54 | fi
55 | 
56 | res=0
57 | for i do
58 |   if test -f "$i"; then :; else if test -f "$i.bz2"; then i="$i.bz2"; fi; fi
59 |   if test $list -eq 1; then
60 |     bzip2 -cdfq "$i" | $grep $opt "$pat" 2>&1 > /dev/null && echo $i
61 |     r=$?
62 |   elif test $# -eq 1 -o $silent -eq 1; then
63 |     bzip2 -cdfq "$i" | $grep $opt "$pat"
64 |     r=$?
65 |   else
66 |     j=${i//\\/\\\\}
67 |     j=${j//|/\\|}
68 |     j=${j//&/\\&}
69 |     j=`printf "%s" "$j" | tr '\n' ' '`
70 |     bzip2 -cdfq "$i" | $grep $opt "$pat" | sed "s|^|${j}:|"
71 |     r=$?
72 |   fi
73 |   test "$r" -ne 0 && res="$r"
74 | done
75 | exit $res
76 | 


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/bzgrep.1:
--------------------------------------------------------------------------------
 1 | \"Shamelessly copied from zmore.1 by Philippe Troin 
 2 | \"for Debian GNU/Linux
 3 | .TH BZGREP 1
 4 | .SH NAME
 5 | bzgrep, bzfgrep, bzegrep \- search possibly bzip2 compressed files for a regular expression
 6 | .SH SYNOPSIS
 7 | .B bzgrep
 8 | [ grep_options ]
 9 | .BI  [\ -e\ ] " pattern"
10 | .IR filename ".\|.\|."
11 | .br
12 | .B bzegrep
13 | [ egrep_options ]
14 | .BI  [\ -e\ ] " pattern"
15 | .IR filename ".\|.\|."
16 | .br
17 | .B bzfgrep
18 | [ fgrep_options ]
19 | .BI  [\ -e\ ] " pattern"
20 | .IR filename ".\|.\|."
21 | .SH DESCRIPTION
22 | .IR  Bzgrep
23 | is used to invoke the
24 | .I grep
25 | on bzip2-compressed files. All options specified are passed directly to
26 | .I grep.
27 | If no file is specified, then the standard input is decompressed
28 | if necessary and fed to grep.
29 | Otherwise the given files are uncompressed if necessary and fed to
30 | .I grep.
31 | .PP
32 | If
33 | .I bzgrep
34 | is invoked as
35 | .I bzegrep
36 | or
37 | .I bzfgrep
38 | then
39 | .I egrep
40 | or
41 | .I fgrep
42 | is used instead of
43 | .I grep.
44 | If the GREP environment variable is set,
45 | .I bzgrep
46 | uses it as the
47 | .I grep
48 | program to be invoked. For example:
49 | 
50 |     for sh:  GREP=fgrep  bzgrep string files
51 |     for csh: (setenv GREP fgrep; bzgrep string files)
52 | .SH AUTHOR
53 | Charles Levert (charles@comm.polymtl.ca). Adapted to bzip2 by Philippe
54 | Troin  for Debian GNU/Linux.
55 | .SH "SEE ALSO"
56 | grep(1), egrep(1), fgrep(1), bzdiff(1), bzmore(1), bzless(1), bzip2(1)
57 | 


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/bzip.css:
--------------------------------------------------------------------------------
 1 | /* Colours:
 2 | #74240f  dark brown      h1, h2, h3, h4
 3 | #336699  medium blue     links
 4 | #339999  turquoise       link hover colour
 5 | #202020  almost black    general text
 6 | #761596  purple          md5sum text
 7 | #626262  dark gray       pre border
 8 | #eeeeee  very light gray pre background
 9 | #f2f2f9  very light blue nav table background
10 | #3366cc  medium blue     nav table border
11 | */
12 | 
13 | a, a:link, a:visited, a:active { color: #336699; }
14 | a:hover { color: #339999; }
15 | 
16 | body { font: 80%/126% sans-serif; }
17 | h1, h2, h3, h4 { color: #74240f; }
18 | 
19 | dt { color: #336699; font-weight: bold }
20 | dd { 
21 |  margin-left: 1.5em; 
22 |  padding-bottom: 0.8em;
23 | }
24 | 
25 | /* -- ruler -- */
26 | div.hr_blue { 
27 |   height:  3px; 
28 |   background:#ffffff url("/images/hr_blue.png") repeat-x; }
29 | div.hr_blue hr { display:none; }
30 | 
31 | /* release styles */
32 | #release p { margin-top: 0.4em; }
33 | #release .md5sum { color: #761596; }
34 | 
35 | 
36 | /* ------ styles for docs|manuals|howto ------ */
37 | /* -- lists -- */
38 | ul  { 
39 |  margin:     0px 4px 16px 16px;
40 |  padding:    0px;
41 |  list-style: url("/images/li-blue.png"); 
42 | }
43 | ul li { 
44 |  margin-bottom: 10px;
45 | }
46 | ul ul	{ 
47 |  list-style-type:  none; 
48 |  list-style-image: none; 
49 |  margin-left:      0px; 
50 | }
51 | 
52 | /* header / footer nav tables */
53 | table.nav {
54 |  border:     solid 1px #3366cc;
55 |  background: #f2f2f9;
56 |  background-color: #f2f2f9;
57 |  margin-bottom: 0.5em;
58 | }
59 | /* don't have underlined links in chunked nav menus */
60 | table.nav a { text-decoration: none; }
61 | table.nav a:hover { text-decoration: underline; }
62 | table.nav td { font-size: 85%; }
63 | 
64 | code, tt, pre { font-size: 120%; }
65 | code, tt { color: #761596; }
66 | 
67 | div.literallayout, pre.programlisting, pre.screen {
68 |  color:      #000000;
69 |  padding:    0.5em;
70 |  background: #eeeeee;
71 |  border:     1px solid #626262;
72 |  background-color: #eeeeee;
73 |  margin: 4px 0px 4px 0px; 
74 | }
75 | 


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/bzip2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ChanJLee/android-patch/85678d935494f8a7dc1919f7b20469de81d9c465/serverpatch/bzip2-1.0.6/bzip2


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/bzip2.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ChanJLee/android-patch/85678d935494f8a7dc1919f7b20469de81d9c465/serverpatch/bzip2-1.0.6/bzip2.o


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/bzip2recover:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ChanJLee/android-patch/85678d935494f8a7dc1919f7b20469de81d9c465/serverpatch/bzip2-1.0.6/bzip2recover


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/bzip2recover.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ChanJLee/android-patch/85678d935494f8a7dc1919f7b20469de81d9c465/serverpatch/bzip2-1.0.6/bzip2recover.o


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/bzlib.h:
--------------------------------------------------------------------------------
  1 | 
  2 | /*-------------------------------------------------------------*/
  3 | /*--- Public header file for the library.                   ---*/
  4 | /*---                                               bzlib.h ---*/
  5 | /*-------------------------------------------------------------*/
  6 | 
  7 | /* ------------------------------------------------------------------
  8 |    This file is part of bzip2/libbzip2, a program and library for
  9 |    lossless, block-sorting data compression.
 10 | 
 11 |    bzip2/libbzip2 version 1.0.6 of 6 September 2010
 12 |    Copyright (C) 1996-2010 Julian Seward 
 13 | 
 14 |    Please read the WARNING, DISCLAIMER and PATENTS sections in the 
 15 |    README file.
 16 | 
 17 |    This program is released under the terms of the license contained
 18 |    in the file LICENSE.
 19 |    ------------------------------------------------------------------ */
 20 | 
 21 | 
 22 | #ifndef _BZLIB_H
 23 | #define _BZLIB_H
 24 | 
 25 | #ifdef __cplusplus
 26 | extern "C" {
 27 | #endif
 28 | 
 29 | #define BZ_RUN               0
 30 | #define BZ_FLUSH             1
 31 | #define BZ_FINISH            2
 32 | 
 33 | #define BZ_OK                0
 34 | #define BZ_RUN_OK            1
 35 | #define BZ_FLUSH_OK          2
 36 | #define BZ_FINISH_OK         3
 37 | #define BZ_STREAM_END        4
 38 | #define BZ_SEQUENCE_ERROR    (-1)
 39 | #define BZ_PARAM_ERROR       (-2)
 40 | #define BZ_MEM_ERROR         (-3)
 41 | #define BZ_DATA_ERROR        (-4)
 42 | #define BZ_DATA_ERROR_MAGIC  (-5)
 43 | #define BZ_IO_ERROR          (-6)
 44 | #define BZ_UNEXPECTED_EOF    (-7)
 45 | #define BZ_OUTBUFF_FULL      (-8)
 46 | #define BZ_CONFIG_ERROR      (-9)
 47 | 
 48 | typedef 
 49 |    struct {
 50 |       char *next_in;
 51 |       unsigned int avail_in;
 52 |       unsigned int total_in_lo32;
 53 |       unsigned int total_in_hi32;
 54 | 
 55 |       char *next_out;
 56 |       unsigned int avail_out;
 57 |       unsigned int total_out_lo32;
 58 |       unsigned int total_out_hi32;
 59 | 
 60 |       void *state;
 61 | 
 62 |       void *(*bzalloc)(void *,int,int);
 63 |       void (*bzfree)(void *,void *);
 64 |       void *opaque;
 65 |    } 
 66 |    bz_stream;
 67 | 
 68 | 
 69 | #ifndef BZ_IMPORT
 70 | #define BZ_EXPORT
 71 | #endif
 72 | 
 73 | #ifndef BZ_NO_STDIO
 74 | /* Need a definitition for FILE */
 75 | #include 
 76 | #endif
 77 | 
 78 | #ifdef _WIN32
 79 | #   include 
 80 | #   ifdef small
 81 |       /* windows.h define small to char */
 82 | #      undef small
 83 | #   endif
 84 | #   ifdef BZ_EXPORT
 85 | #   define BZ_API(func) WINAPI func
 86 | #   define BZ_EXTERN extern
 87 | #   else
 88 |    /* import windows dll dynamically */
 89 | #   define BZ_API(func) (WINAPI * func)
 90 | #   define BZ_EXTERN
 91 | #   endif
 92 | #else
 93 | #   define BZ_API(func) func
 94 | #   define BZ_EXTERN extern
 95 | #endif
 96 | 
 97 | 
 98 | /*-- Core (low-level) library functions --*/
 99 | 
100 | BZ_EXTERN int BZ_API(BZ2_bzCompressInit) ( 
101 |       bz_stream* strm, 
102 |       int        blockSize100k, 
103 |       int        verbosity, 
104 |       int        workFactor 
105 |    );
106 | 
107 | BZ_EXTERN int BZ_API(BZ2_bzCompress) ( 
108 |       bz_stream* strm, 
109 |       int action 
110 |    );
111 | 
112 | BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) ( 
113 |       bz_stream* strm 
114 |    );
115 | 
116 | BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) ( 
117 |       bz_stream *strm, 
118 |       int       verbosity, 
119 |       int       small
120 |    );
121 | 
122 | BZ_EXTERN int BZ_API(BZ2_bzDecompress) ( 
123 |       bz_stream* strm 
124 |    );
125 | 
126 | BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) ( 
127 |       bz_stream *strm 
128 |    );
129 | 
130 | 
131 | 
132 | /*-- High(er) level library functions --*/
133 | 
134 | #ifndef BZ_NO_STDIO
135 | #define BZ_MAX_UNUSED 5000
136 | 
137 | typedef void BZFILE;
138 | 
139 | BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) ( 
140 |       int*  bzerror,   
141 |       FILE* f, 
142 |       int   verbosity, 
143 |       int   small,
144 |       void* unused,    
145 |       int   nUnused 
146 |    );
147 | 
148 | BZ_EXTERN void BZ_API(BZ2_bzReadClose) ( 
149 |       int*    bzerror, 
150 |       BZFILE* b 
151 |    );
152 | 
153 | BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) ( 
154 |       int*    bzerror, 
155 |       BZFILE* b, 
156 |       void**  unused,  
157 |       int*    nUnused 
158 |    );
159 | 
160 | BZ_EXTERN int BZ_API(BZ2_bzRead) ( 
161 |       int*    bzerror, 
162 |       BZFILE* b, 
163 |       void*   buf, 
164 |       int     len 
165 |    );
166 | 
167 | BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) ( 
168 |       int*  bzerror,      
169 |       FILE* f, 
170 |       int   blockSize100k, 
171 |       int   verbosity, 
172 |       int   workFactor 
173 |    );
174 | 
175 | BZ_EXTERN void BZ_API(BZ2_bzWrite) ( 
176 |       int*    bzerror, 
177 |       BZFILE* b, 
178 |       void*   buf, 
179 |       int     len 
180 |    );
181 | 
182 | BZ_EXTERN void BZ_API(BZ2_bzWriteClose) ( 
183 |       int*          bzerror, 
184 |       BZFILE*       b, 
185 |       int           abandon, 
186 |       unsigned int* nbytes_in, 
187 |       unsigned int* nbytes_out 
188 |    );
189 | 
190 | BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) ( 
191 |       int*          bzerror, 
192 |       BZFILE*       b, 
193 |       int           abandon, 
194 |       unsigned int* nbytes_in_lo32, 
195 |       unsigned int* nbytes_in_hi32, 
196 |       unsigned int* nbytes_out_lo32, 
197 |       unsigned int* nbytes_out_hi32
198 |    );
199 | #endif
200 | 
201 | 
202 | /*-- Utility functions --*/
203 | 
204 | BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) ( 
205 |       char*         dest, 
206 |       unsigned int* destLen,
207 |       char*         source, 
208 |       unsigned int  sourceLen,
209 |       int           blockSize100k, 
210 |       int           verbosity, 
211 |       int           workFactor 
212 |    );
213 | 
214 | BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) ( 
215 |       char*         dest, 
216 |       unsigned int* destLen,
217 |       char*         source, 
218 |       unsigned int  sourceLen,
219 |       int           small, 
220 |       int           verbosity 
221 |    );
222 | 
223 | 
224 | /*--
225 |    Code contributed by Yoshioka Tsuneo (tsuneo@rr.iij4u.or.jp)
226 |    to support better zlib compatibility.
227 |    This code is not _officially_ part of libbzip2 (yet);
228 |    I haven't tested it, documented it, or considered the
229 |    threading-safeness of it.
230 |    If this code breaks, please contact both Yoshioka and me.
231 | --*/
232 | 
233 | BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) (
234 |       void
235 |    );
236 | 
237 | #ifndef BZ_NO_STDIO
238 | BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) (
239 |       const char *path,
240 |       const char *mode
241 |    );
242 | 
243 | BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) (
244 |       int        fd,
245 |       const char *mode
246 |    );
247 |          
248 | BZ_EXTERN int BZ_API(BZ2_bzread) (
249 |       BZFILE* b, 
250 |       void* buf, 
251 |       int len 
252 |    );
253 | 
254 | BZ_EXTERN int BZ_API(BZ2_bzwrite) (
255 |       BZFILE* b, 
256 |       void*   buf, 
257 |       int     len 
258 |    );
259 | 
260 | BZ_EXTERN int BZ_API(BZ2_bzflush) (
261 |       BZFILE* b
262 |    );
263 | 
264 | BZ_EXTERN void BZ_API(BZ2_bzclose) (
265 |       BZFILE* b
266 |    );
267 | 
268 | BZ_EXTERN const char * BZ_API(BZ2_bzerror) (
269 |       BZFILE *b, 
270 |       int    *errnum
271 |    );
272 | #endif
273 | 
274 | #ifdef __cplusplus
275 | }
276 | #endif
277 | 
278 | #endif
279 | 
280 | /*-------------------------------------------------------------*/
281 | /*--- end                                           bzlib.h ---*/
282 | /*-------------------------------------------------------------*/
283 | 


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/bzlib.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ChanJLee/android-patch/85678d935494f8a7dc1919f7b20469de81d9c465/serverpatch/bzip2-1.0.6/bzlib.o


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/bzlib_private.h:
--------------------------------------------------------------------------------
  1 | 
  2 | /*-------------------------------------------------------------*/
  3 | /*--- Private header file for the library.                  ---*/
  4 | /*---                                       bzlib_private.h ---*/
  5 | /*-------------------------------------------------------------*/
  6 | 
  7 | /* ------------------------------------------------------------------
  8 |    This file is part of bzip2/libbzip2, a program and library for
  9 |    lossless, block-sorting data compression.
 10 | 
 11 |    bzip2/libbzip2 version 1.0.6 of 6 September 2010
 12 |    Copyright (C) 1996-2010 Julian Seward 
 13 | 
 14 |    Please read the WARNING, DISCLAIMER and PATENTS sections in the 
 15 |    README file.
 16 | 
 17 |    This program is released under the terms of the license contained
 18 |    in the file LICENSE.
 19 |    ------------------------------------------------------------------ */
 20 | 
 21 | 
 22 | #ifndef _BZLIB_PRIVATE_H
 23 | #define _BZLIB_PRIVATE_H
 24 | 
 25 | #include 
 26 | 
 27 | #ifndef BZ_NO_STDIO
 28 | #include 
 29 | #include 
 30 | #include 
 31 | #endif
 32 | 
 33 | #include "bzlib.h"
 34 | 
 35 | 
 36 | 
 37 | /*-- General stuff. --*/
 38 | 
 39 | #define BZ_VERSION  "1.0.6, 6-Sept-2010"
 40 | 
 41 | typedef char            Char;
 42 | typedef unsigned char   Bool;
 43 | typedef unsigned char   UChar;
 44 | typedef int             Int32;
 45 | typedef unsigned int    UInt32;
 46 | typedef short           Int16;
 47 | typedef unsigned short  UInt16;
 48 | 
 49 | #define True  ((Bool)1)
 50 | #define False ((Bool)0)
 51 | 
 52 | #ifndef __GNUC__
 53 | #define __inline__  /* */
 54 | #endif 
 55 | 
 56 | #ifndef BZ_NO_STDIO
 57 | 
 58 | extern void BZ2_bz__AssertH__fail ( int errcode );
 59 | #define AssertH(cond,errcode) \
 60 |    { if (!(cond)) BZ2_bz__AssertH__fail ( errcode ); }
 61 | 
 62 | #if BZ_DEBUG
 63 | #define AssertD(cond,msg) \
 64 |    { if (!(cond)) {       \
 65 |       fprintf ( stderr,   \
 66 |         "\n\nlibbzip2(debug build): internal error\n\t%s\n", msg );\
 67 |       exit(1); \
 68 |    }}
 69 | #else
 70 | #define AssertD(cond,msg) /* */
 71 | #endif
 72 | 
 73 | #define VPrintf0(zf) \
 74 |    fprintf(stderr,zf)
 75 | #define VPrintf1(zf,za1) \
 76 |    fprintf(stderr,zf,za1)
 77 | #define VPrintf2(zf,za1,za2) \
 78 |    fprintf(stderr,zf,za1,za2)
 79 | #define VPrintf3(zf,za1,za2,za3) \
 80 |    fprintf(stderr,zf,za1,za2,za3)
 81 | #define VPrintf4(zf,za1,za2,za3,za4) \
 82 |    fprintf(stderr,zf,za1,za2,za3,za4)
 83 | #define VPrintf5(zf,za1,za2,za3,za4,za5) \
 84 |    fprintf(stderr,zf,za1,za2,za3,za4,za5)
 85 | 
 86 | #else
 87 | 
 88 | extern void bz_internal_error ( int errcode );
 89 | #define AssertH(cond,errcode) \
 90 |    { if (!(cond)) bz_internal_error ( errcode ); }
 91 | #define AssertD(cond,msg)                do { } while (0)
 92 | #define VPrintf0(zf)                     do { } while (0)
 93 | #define VPrintf1(zf,za1)                 do { } while (0)
 94 | #define VPrintf2(zf,za1,za2)             do { } while (0)
 95 | #define VPrintf3(zf,za1,za2,za3)         do { } while (0)
 96 | #define VPrintf4(zf,za1,za2,za3,za4)     do { } while (0)
 97 | #define VPrintf5(zf,za1,za2,za3,za4,za5) do { } while (0)
 98 | 
 99 | #endif
100 | 
101 | 
102 | #define BZALLOC(nnn) (strm->bzalloc)(strm->opaque,(nnn),1)
103 | #define BZFREE(ppp)  (strm->bzfree)(strm->opaque,(ppp))
104 | 
105 | 
106 | /*-- Header bytes. --*/
107 | 
108 | #define BZ_HDR_B 0x42   /* 'B' */
109 | #define BZ_HDR_Z 0x5a   /* 'Z' */
110 | #define BZ_HDR_h 0x68   /* 'h' */
111 | #define BZ_HDR_0 0x30   /* '0' */
112 |   
113 | /*-- Constants for the back end. --*/
114 | 
115 | #define BZ_MAX_ALPHA_SIZE 258
116 | #define BZ_MAX_CODE_LEN    23
117 | 
118 | #define BZ_RUNA 0
119 | #define BZ_RUNB 1
120 | 
121 | #define BZ_N_GROUPS 6
122 | #define BZ_G_SIZE   50
123 | #define BZ_N_ITERS  4
124 | 
125 | #define BZ_MAX_SELECTORS (2 + (900000 / BZ_G_SIZE))
126 | 
127 | 
128 | 
129 | /*-- Stuff for randomising repetitive blocks. --*/
130 | 
131 | extern Int32 BZ2_rNums[512];
132 | 
133 | #define BZ_RAND_DECLS                          \
134 |    Int32 rNToGo;                               \
135 |    Int32 rTPos                                 \
136 | 
137 | #define BZ_RAND_INIT_MASK                      \
138 |    s->rNToGo = 0;                              \
139 |    s->rTPos  = 0                               \
140 | 
141 | #define BZ_RAND_MASK ((s->rNToGo == 1) ? 1 : 0)
142 | 
143 | #define BZ_RAND_UPD_MASK                       \
144 |    if (s->rNToGo == 0) {                       \
145 |       s->rNToGo = BZ2_rNums[s->rTPos];         \
146 |       s->rTPos++;                              \
147 |       if (s->rTPos == 512) s->rTPos = 0;       \
148 |    }                                           \
149 |    s->rNToGo--;
150 | 
151 | 
152 | 
153 | /*-- Stuff for doing CRCs. --*/
154 | 
155 | extern UInt32 BZ2_crc32Table[256];
156 | 
157 | #define BZ_INITIALISE_CRC(crcVar)              \
158 | {                                              \
159 |    crcVar = 0xffffffffL;                       \
160 | }
161 | 
162 | #define BZ_FINALISE_CRC(crcVar)                \
163 | {                                              \
164 |    crcVar = ~(crcVar);                         \
165 | }
166 | 
167 | #define BZ_UPDATE_CRC(crcVar,cha)              \
168 | {                                              \
169 |    crcVar = (crcVar << 8) ^                    \
170 |             BZ2_crc32Table[(crcVar >> 24) ^    \
171 |                            ((UChar)cha)];      \
172 | }
173 | 
174 | 
175 | 
176 | /*-- States and modes for compression. --*/
177 | 
178 | #define BZ_M_IDLE      1
179 | #define BZ_M_RUNNING   2
180 | #define BZ_M_FLUSHING  3
181 | #define BZ_M_FINISHING 4
182 | 
183 | #define BZ_S_OUTPUT    1
184 | #define BZ_S_INPUT     2
185 | 
186 | #define BZ_N_RADIX 2
187 | #define BZ_N_QSORT 12
188 | #define BZ_N_SHELL 18
189 | #define BZ_N_OVERSHOOT (BZ_N_RADIX + BZ_N_QSORT + BZ_N_SHELL + 2)
190 | 
191 | 
192 | 
193 | 
194 | /*-- Structure holding all the compression-side stuff. --*/
195 | 
196 | typedef
197 |    struct {
198 |       /* pointer back to the struct bz_stream */
199 |       bz_stream* strm;
200 | 
201 |       /* mode this stream is in, and whether inputting */
202 |       /* or outputting data */
203 |       Int32    mode;
204 |       Int32    state;
205 | 
206 |       /* remembers avail_in when flush/finish requested */
207 |       UInt32   avail_in_expect;
208 | 
209 |       /* for doing the block sorting */
210 |       UInt32*  arr1;
211 |       UInt32*  arr2;
212 |       UInt32*  ftab;
213 |       Int32    origPtr;
214 | 
215 |       /* aliases for arr1 and arr2 */
216 |       UInt32*  ptr;
217 |       UChar*   block;
218 |       UInt16*  mtfv;
219 |       UChar*   zbits;
220 | 
221 |       /* for deciding when to use the fallback sorting algorithm */
222 |       Int32    workFactor;
223 | 
224 |       /* run-length-encoding of the input */
225 |       UInt32   state_in_ch;
226 |       Int32    state_in_len;
227 |       BZ_RAND_DECLS;
228 | 
229 |       /* input and output limits and current posns */
230 |       Int32    nblock;
231 |       Int32    nblockMAX;
232 |       Int32    numZ;
233 |       Int32    state_out_pos;
234 | 
235 |       /* map of bytes used in block */
236 |       Int32    nInUse;
237 |       Bool     inUse[256];
238 |       UChar    unseqToSeq[256];
239 | 
240 |       /* the buffer for bit stream creation */
241 |       UInt32   bsBuff;
242 |       Int32    bsLive;
243 | 
244 |       /* block and combined CRCs */
245 |       UInt32   blockCRC;
246 |       UInt32   combinedCRC;
247 | 
248 |       /* misc administratium */
249 |       Int32    verbosity;
250 |       Int32    blockNo;
251 |       Int32    blockSize100k;
252 | 
253 |       /* stuff for coding the MTF values */
254 |       Int32    nMTF;
255 |       Int32    mtfFreq    [BZ_MAX_ALPHA_SIZE];
256 |       UChar    selector   [BZ_MAX_SELECTORS];
257 |       UChar    selectorMtf[BZ_MAX_SELECTORS];
258 | 
259 |       UChar    len     [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
260 |       Int32    code    [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
261 |       Int32    rfreq   [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
262 |       /* second dimension: only 3 needed; 4 makes index calculations faster */
263 |       UInt32   len_pack[BZ_MAX_ALPHA_SIZE][4];
264 | 
265 |    }
266 |    EState;
267 | 
268 | 
269 | 
270 | /*-- externs for compression. --*/
271 | 
272 | extern void 
273 | BZ2_blockSort ( EState* );
274 | 
275 | extern void 
276 | BZ2_compressBlock ( EState*, Bool );
277 | 
278 | extern void 
279 | BZ2_bsInitWrite ( EState* );
280 | 
281 | extern void 
282 | BZ2_hbAssignCodes ( Int32*, UChar*, Int32, Int32, Int32 );
283 | 
284 | extern void 
285 | BZ2_hbMakeCodeLengths ( UChar*, Int32*, Int32, Int32 );
286 | 
287 | 
288 | 
289 | /*-- states for decompression. --*/
290 | 
291 | #define BZ_X_IDLE        1
292 | #define BZ_X_OUTPUT      2
293 | 
294 | #define BZ_X_MAGIC_1     10
295 | #define BZ_X_MAGIC_2     11
296 | #define BZ_X_MAGIC_3     12
297 | #define BZ_X_MAGIC_4     13
298 | #define BZ_X_BLKHDR_1    14
299 | #define BZ_X_BLKHDR_2    15
300 | #define BZ_X_BLKHDR_3    16
301 | #define BZ_X_BLKHDR_4    17
302 | #define BZ_X_BLKHDR_5    18
303 | #define BZ_X_BLKHDR_6    19
304 | #define BZ_X_BCRC_1      20
305 | #define BZ_X_BCRC_2      21
306 | #define BZ_X_BCRC_3      22
307 | #define BZ_X_BCRC_4      23
308 | #define BZ_X_RANDBIT     24
309 | #define BZ_X_ORIGPTR_1   25
310 | #define BZ_X_ORIGPTR_2   26
311 | #define BZ_X_ORIGPTR_3   27
312 | #define BZ_X_MAPPING_1   28
313 | #define BZ_X_MAPPING_2   29
314 | #define BZ_X_SELECTOR_1  30
315 | #define BZ_X_SELECTOR_2  31
316 | #define BZ_X_SELECTOR_3  32
317 | #define BZ_X_CODING_1    33
318 | #define BZ_X_CODING_2    34
319 | #define BZ_X_CODING_3    35
320 | #define BZ_X_MTF_1       36
321 | #define BZ_X_MTF_2       37
322 | #define BZ_X_MTF_3       38
323 | #define BZ_X_MTF_4       39
324 | #define BZ_X_MTF_5       40
325 | #define BZ_X_MTF_6       41
326 | #define BZ_X_ENDHDR_2    42
327 | #define BZ_X_ENDHDR_3    43
328 | #define BZ_X_ENDHDR_4    44
329 | #define BZ_X_ENDHDR_5    45
330 | #define BZ_X_ENDHDR_6    46
331 | #define BZ_X_CCRC_1      47
332 | #define BZ_X_CCRC_2      48
333 | #define BZ_X_CCRC_3      49
334 | #define BZ_X_CCRC_4      50
335 | 
336 | 
337 | 
338 | /*-- Constants for the fast MTF decoder. --*/
339 | 
340 | #define MTFA_SIZE 4096
341 | #define MTFL_SIZE 16
342 | 
343 | 
344 | 
345 | /*-- Structure holding all the decompression-side stuff. --*/
346 | 
347 | typedef
348 |    struct {
349 |       /* pointer back to the struct bz_stream */
350 |       bz_stream* strm;
351 | 
352 |       /* state indicator for this stream */
353 |       Int32    state;
354 | 
355 |       /* for doing the final run-length decoding */
356 |       UChar    state_out_ch;
357 |       Int32    state_out_len;
358 |       Bool     blockRandomised;
359 |       BZ_RAND_DECLS;
360 | 
361 |       /* the buffer for bit stream reading */
362 |       UInt32   bsBuff;
363 |       Int32    bsLive;
364 | 
365 |       /* misc administratium */
366 |       Int32    blockSize100k;
367 |       Bool     smallDecompress;
368 |       Int32    currBlockNo;
369 |       Int32    verbosity;
370 | 
371 |       /* for undoing the Burrows-Wheeler transform */
372 |       Int32    origPtr;
373 |       UInt32   tPos;
374 |       Int32    k0;
375 |       Int32    unzftab[256];
376 |       Int32    nblock_used;
377 |       Int32    cftab[257];
378 |       Int32    cftabCopy[257];
379 | 
380 |       /* for undoing the Burrows-Wheeler transform (FAST) */
381 |       UInt32   *tt;
382 | 
383 |       /* for undoing the Burrows-Wheeler transform (SMALL) */
384 |       UInt16   *ll16;
385 |       UChar    *ll4;
386 | 
387 |       /* stored and calculated CRCs */
388 |       UInt32   storedBlockCRC;
389 |       UInt32   storedCombinedCRC;
390 |       UInt32   calculatedBlockCRC;
391 |       UInt32   calculatedCombinedCRC;
392 | 
393 |       /* map of bytes used in block */
394 |       Int32    nInUse;
395 |       Bool     inUse[256];
396 |       Bool     inUse16[16];
397 |       UChar    seqToUnseq[256];
398 | 
399 |       /* for decoding the MTF values */
400 |       UChar    mtfa   [MTFA_SIZE];
401 |       Int32    mtfbase[256 / MTFL_SIZE];
402 |       UChar    selector   [BZ_MAX_SELECTORS];
403 |       UChar    selectorMtf[BZ_MAX_SELECTORS];
404 |       UChar    len  [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
405 | 
406 |       Int32    limit  [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
407 |       Int32    base   [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
408 |       Int32    perm   [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
409 |       Int32    minLens[BZ_N_GROUPS];
410 | 
411 |       /* save area for scalars in the main decompress code */
412 |       Int32    save_i;
413 |       Int32    save_j;
414 |       Int32    save_t;
415 |       Int32    save_alphaSize;
416 |       Int32    save_nGroups;
417 |       Int32    save_nSelectors;
418 |       Int32    save_EOB;
419 |       Int32    save_groupNo;
420 |       Int32    save_groupPos;
421 |       Int32    save_nextSym;
422 |       Int32    save_nblockMAX;
423 |       Int32    save_nblock;
424 |       Int32    save_es;
425 |       Int32    save_N;
426 |       Int32    save_curr;
427 |       Int32    save_zt;
428 |       Int32    save_zn; 
429 |       Int32    save_zvec;
430 |       Int32    save_zj;
431 |       Int32    save_gSel;
432 |       Int32    save_gMinlen;
433 |       Int32*   save_gLimit;
434 |       Int32*   save_gBase;
435 |       Int32*   save_gPerm;
436 | 
437 |    }
438 |    DState;
439 | 
440 | 
441 | 
442 | /*-- Macros for decompression. --*/
443 | 
444 | #define BZ_GET_FAST(cccc)                     \
445 |     /* c_tPos is unsigned, hence test < 0 is pointless. */ \
446 |     if (s->tPos >= (UInt32)100000 * (UInt32)s->blockSize100k) return True; \
447 |     s->tPos = s->tt[s->tPos];                 \
448 |     cccc = (UChar)(s->tPos & 0xff);           \
449 |     s->tPos >>= 8;
450 | 
451 | #define BZ_GET_FAST_C(cccc)                   \
452 |     /* c_tPos is unsigned, hence test < 0 is pointless. */ \
453 |     if (c_tPos >= (UInt32)100000 * (UInt32)ro_blockSize100k) return True; \
454 |     c_tPos = c_tt[c_tPos];                    \
455 |     cccc = (UChar)(c_tPos & 0xff);            \
456 |     c_tPos >>= 8;
457 | 
458 | #define SET_LL4(i,n)                                          \
459 |    { if (((i) & 0x1) == 0)                                    \
460 |         s->ll4[(i) >> 1] = (s->ll4[(i) >> 1] & 0xf0) | (n); else    \
461 |         s->ll4[(i) >> 1] = (s->ll4[(i) >> 1] & 0x0f) | ((n) << 4);  \
462 |    }
463 | 
464 | #define GET_LL4(i)                             \
465 |    ((((UInt32)(s->ll4[(i) >> 1])) >> (((i) << 2) & 0x4)) & 0xF)
466 | 
467 | #define SET_LL(i,n)                          \
468 |    { s->ll16[i] = (UInt16)(n & 0x0000ffff);  \
469 |      SET_LL4(i, n >> 16);                    \
470 |    }
471 | 
472 | #define GET_LL(i) \
473 |    (((UInt32)s->ll16[i]) | (GET_LL4(i) << 16))
474 | 
475 | #define BZ_GET_SMALL(cccc)                            \
476 |     /* c_tPos is unsigned, hence test < 0 is pointless. */ \
477 |     if (s->tPos >= (UInt32)100000 * (UInt32)s->blockSize100k) return True; \
478 |     cccc = BZ2_indexIntoF ( s->tPos, s->cftab );    \
479 |     s->tPos = GET_LL(s->tPos);
480 | 
481 | 
482 | /*-- externs for decompression. --*/
483 | 
484 | extern Int32 
485 | BZ2_indexIntoF ( Int32, Int32* );
486 | 
487 | extern Int32 
488 | BZ2_decompress ( DState* );
489 | 
490 | extern void 
491 | BZ2_hbCreateDecodeTables ( Int32*, Int32*, Int32*, UChar*,
492 |                            Int32,  Int32, Int32 );
493 | 
494 | 
495 | #endif
496 | 
497 | 
498 | /*-- BZ_NO_STDIO seems to make NULL disappear on some platforms. --*/
499 | 
500 | #ifdef BZ_NO_STDIO
501 | #ifndef NULL
502 | #define NULL 0
503 | #endif
504 | #endif
505 | 
506 | 
507 | /*-------------------------------------------------------------*/
508 | /*--- end                                   bzlib_private.h ---*/
509 | /*-------------------------------------------------------------*/
510 | 


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/bzmore:
--------------------------------------------------------------------------------
 1 | #!/bin/sh
 2 | 
 3 | # Bzmore wrapped for bzip2, 
 4 | # adapted from zmore by Philippe Troin  for Debian GNU/Linux.
 5 | 
 6 | PATH="/usr/bin:$PATH"; export PATH
 7 | 
 8 | prog=`echo $0 | sed 's|.*/||'`
 9 | case "$prog" in
10 | 	*less)	more=less	;;
11 | 	*)	more=more       ;;
12 | esac
13 | 
14 | if test "`echo -n a`" = "-n a"; then
15 |   # looks like a SysV system:
16 |   n1=''; n2='\c'
17 | else
18 |   n1='-n'; n2=''
19 | fi
20 | oldtty=`stty -g 2>/dev/null`
21 | if stty -cbreak 2>/dev/null; then
22 |   cb='cbreak'; ncb='-cbreak'
23 | else
24 |   # 'stty min 1' resets eof to ^a on both SunOS and SysV!
25 |   cb='min 1 -icanon'; ncb='icanon eof ^d'
26 | fi
27 | if test $? -eq 0 -a -n "$oldtty"; then
28 |    trap 'stty $oldtty 2>/dev/null; exit' 0 2 3 5 10 13 15
29 | else
30 |    trap 'stty $ncb echo 2>/dev/null; exit' 0 2 3 5 10 13 15
31 | fi
32 | 
33 | if test $# = 0; then
34 |     if test -t 0; then
35 | 	echo usage: $prog files...
36 |     else
37 | 	bzip2 -cdfq | eval $more
38 |     fi
39 | else
40 |     FIRST=1
41 |     for FILE
42 |     do
43 | 	if test $FIRST -eq 0; then
44 | 		echo $n1 "--More--(Next file: $FILE)$n2"
45 | 		stty $cb -echo 2>/dev/null
46 | 		ANS=`dd bs=1 count=1 2>/dev/null` 
47 | 		stty $ncb echo 2>/dev/null
48 | 		echo " "
49 | 		if test "$ANS" = 'e' -o "$ANS" = 'q'; then
50 | 			exit
51 | 		fi
52 | 	fi
53 | 	if test "$ANS" != 's'; then
54 | 		echo "------> $FILE <------"
55 | 		bzip2 -cdfq "$FILE" | eval $more
56 | 	fi
57 | 	if test -t; then
58 | 		FIRST=0
59 | 	fi
60 |     done
61 | fi
62 | 


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/bzmore.1:
--------------------------------------------------------------------------------
  1 | .\"Shamelessly copied from zmore.1 by Philippe Troin 
  2 | .\"for Debian GNU/Linux
  3 | .TH BZMORE 1
  4 | .SH NAME
  5 | bzmore, bzless \- file perusal filter for crt viewing of bzip2 compressed text
  6 | .SH SYNOPSIS
  7 | .B bzmore
  8 | [ name ...  ]
  9 | .br
 10 | .B bzless
 11 | [ name ...  ]
 12 | .SH NOTE
 13 | In the following description,
 14 | .I bzless
 15 | and
 16 | .I less
 17 | can be used interchangeably with
 18 | .I bzmore
 19 | and
 20 | .I more.
 21 | .SH DESCRIPTION
 22 | .I  Bzmore
 23 | is a filter which allows examination of compressed or plain text files
 24 | one screenful at a time on a soft-copy terminal.
 25 | .I bzmore
 26 | works on files compressed with
 27 | .I bzip2
 28 | and also on uncompressed files.
 29 | If a file does not exist,
 30 | .I bzmore
 31 | looks for a file of the same name with the addition of a .bz2 suffix.
 32 | .PP
 33 | .I Bzmore
 34 | normally pauses after each screenful, printing --More--
 35 | at the bottom of the screen.
 36 | If the user then types a carriage return, one more line is displayed.
 37 | If the user hits a space,
 38 | another screenful is displayed.  Other possibilities are enumerated later.
 39 | .PP
 40 | .I Bzmore
 41 | looks in the file
 42 | .I /etc/termcap
 43 | to determine terminal characteristics,
 44 | and to determine the default window size.
 45 | On a terminal capable of displaying 24 lines,
 46 | the default window size is 22 lines.
 47 | Other sequences which may be typed when
 48 | .I bzmore
 49 | pauses, and their effects, are as follows (\fIi\fP is an optional integer
 50 | argument, defaulting to 1) :
 51 | .PP
 52 | .IP \fIi\|\fP
 53 | display
 54 | .I i
 55 | more lines, (or another screenful if no argument is given)
 56 | .PP
 57 | .IP ^D
 58 | display 11 more lines (a ``scroll'').
 59 | If
 60 | .I i
 61 | is given, then the scroll size is set to \fIi\|\fP.
 62 | .PP
 63 | .IP d
 64 | same as ^D (control-D)
 65 | .PP
 66 | .IP \fIi\|\fPz
 67 | same as typing a space except that \fIi\|\fP, if present, becomes the new
 68 | window size.  Note that the window size reverts back to the default at the
 69 | end of the current file.
 70 | .PP
 71 | .IP \fIi\|\fPs
 72 | skip \fIi\|\fP lines and print a screenful of lines
 73 | .PP
 74 | .IP \fIi\|\fPf
 75 | skip \fIi\fP screenfuls and print a screenful of lines
 76 | .PP
 77 | .IP "q or Q"
 78 | quit reading the current file; go on to the next (if any)
 79 | .PP
 80 | .IP "e or q"
 81 | When the prompt --More--(Next file: 
 82 | .IR file )
 83 | is printed, this command causes bzmore to exit.
 84 | .PP
 85 | .IP s
 86 | When the prompt --More--(Next file: 
 87 | .IR file )
 88 | is printed, this command causes bzmore to skip the next file and continue.
 89 | .PP 
 90 | .IP =
 91 | Display the current line number.
 92 | .PP
 93 | .IP \fIi\|\fP/expr
 94 | search for the \fIi\|\fP-th occurrence of the regular expression \fIexpr.\fP
 95 | If the pattern is not found,
 96 | .I bzmore
 97 | goes on to the next file (if any).
 98 | Otherwise, a screenful is displayed, starting two lines before the place
 99 | where the expression was found.
100 | The user's erase and kill characters may be used to edit the regular
101 | expression.
102 | Erasing back past the first column cancels the search command.
103 | .PP
104 | .IP \fIi\|\fPn
105 | search for the \fIi\|\fP-th occurrence of the last regular expression entered.
106 | .PP
107 | .IP !command
108 | invoke a shell with \fIcommand\|\fP. 
109 | The character `!' in "command" are replaced with the
110 | previous shell command.  The sequence "\\!" is replaced by "!".
111 | .PP
112 | .IP ":q or :Q"
113 | quit reading the current file; go on to the next (if any)
114 | (same as q or Q).
115 | .PP
116 | .IP .
117 | (dot) repeat the previous command.
118 | .PP
119 | The commands take effect immediately, i.e., it is not necessary to
120 | type a carriage return.
121 | Up to the time when the command character itself is given,
122 | the user may hit the line kill character to cancel the numerical
123 | argument being formed.
124 | In addition, the user may hit the erase character to redisplay the
125 | --More-- message.
126 | .PP
127 | At any time when output is being sent to the terminal, the user can
128 | hit the quit key (normally control\-\\).
129 | .I Bzmore
130 | will stop sending output, and will display the usual --More--
131 | prompt.
132 | The user may then enter one of the above commands in the normal manner.
133 | Unfortunately, some output is lost when this is done, due to the
134 | fact that any characters waiting in the terminal's output queue
135 | are flushed when the quit signal occurs.
136 | .PP
137 | The terminal is set to
138 | .I noecho
139 | mode by this program so that the output can be continuous.
140 | What you type will thus not show on your terminal, except for the / and !
141 | commands.
142 | .PP
143 | If the standard output is not a teletype, then
144 | .I bzmore
145 | acts just like
146 | .I bzcat,
147 | except that a header is printed before each file.
148 | .SH FILES
149 | .DT
150 | /etc/termcap		Terminal data base
151 | .SH "SEE ALSO"
152 | more(1), less(1), bzip2(1), bzdiff(1), bzgrep(1)
153 | 


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/compress.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ChanJLee/android-patch/85678d935494f8a7dc1919f7b20469de81d9c465/serverpatch/bzip2-1.0.6/compress.o


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/crctable.c:
--------------------------------------------------------------------------------
  1 | 
  2 | /*-------------------------------------------------------------*/
  3 | /*--- Table for doing CRCs                                  ---*/
  4 | /*---                                            crctable.c ---*/
  5 | /*-------------------------------------------------------------*/
  6 | 
  7 | /* ------------------------------------------------------------------
  8 |    This file is part of bzip2/libbzip2, a program and library for
  9 |    lossless, block-sorting data compression.
 10 | 
 11 |    bzip2/libbzip2 version 1.0.6 of 6 September 2010
 12 |    Copyright (C) 1996-2010 Julian Seward 
 13 | 
 14 |    Please read the WARNING, DISCLAIMER and PATENTS sections in the 
 15 |    README file.
 16 | 
 17 |    This program is released under the terms of the license contained
 18 |    in the file LICENSE.
 19 |    ------------------------------------------------------------------ */
 20 | 
 21 | 
 22 | #include "bzlib_private.h"
 23 | 
 24 | /*--
 25 |   I think this is an implementation of the AUTODIN-II,
 26 |   Ethernet & FDDI 32-bit CRC standard.  Vaguely derived
 27 |   from code by Rob Warnock, in Section 51 of the
 28 |   comp.compression FAQ.
 29 | --*/
 30 | 
 31 | UInt32 BZ2_crc32Table[256] = {
 32 | 
 33 |    /*-- Ugly, innit? --*/
 34 | 
 35 |    0x00000000L, 0x04c11db7L, 0x09823b6eL, 0x0d4326d9L,
 36 |    0x130476dcL, 0x17c56b6bL, 0x1a864db2L, 0x1e475005L,
 37 |    0x2608edb8L, 0x22c9f00fL, 0x2f8ad6d6L, 0x2b4bcb61L,
 38 |    0x350c9b64L, 0x31cd86d3L, 0x3c8ea00aL, 0x384fbdbdL,
 39 |    0x4c11db70L, 0x48d0c6c7L, 0x4593e01eL, 0x4152fda9L,
 40 |    0x5f15adacL, 0x5bd4b01bL, 0x569796c2L, 0x52568b75L,
 41 |    0x6a1936c8L, 0x6ed82b7fL, 0x639b0da6L, 0x675a1011L,
 42 |    0x791d4014L, 0x7ddc5da3L, 0x709f7b7aL, 0x745e66cdL,
 43 |    0x9823b6e0L, 0x9ce2ab57L, 0x91a18d8eL, 0x95609039L,
 44 |    0x8b27c03cL, 0x8fe6dd8bL, 0x82a5fb52L, 0x8664e6e5L,
 45 |    0xbe2b5b58L, 0xbaea46efL, 0xb7a96036L, 0xb3687d81L,
 46 |    0xad2f2d84L, 0xa9ee3033L, 0xa4ad16eaL, 0xa06c0b5dL,
 47 |    0xd4326d90L, 0xd0f37027L, 0xddb056feL, 0xd9714b49L,
 48 |    0xc7361b4cL, 0xc3f706fbL, 0xceb42022L, 0xca753d95L,
 49 |    0xf23a8028L, 0xf6fb9d9fL, 0xfbb8bb46L, 0xff79a6f1L,
 50 |    0xe13ef6f4L, 0xe5ffeb43L, 0xe8bccd9aL, 0xec7dd02dL,
 51 |    0x34867077L, 0x30476dc0L, 0x3d044b19L, 0x39c556aeL,
 52 |    0x278206abL, 0x23431b1cL, 0x2e003dc5L, 0x2ac12072L,
 53 |    0x128e9dcfL, 0x164f8078L, 0x1b0ca6a1L, 0x1fcdbb16L,
 54 |    0x018aeb13L, 0x054bf6a4L, 0x0808d07dL, 0x0cc9cdcaL,
 55 |    0x7897ab07L, 0x7c56b6b0L, 0x71159069L, 0x75d48ddeL,
 56 |    0x6b93dddbL, 0x6f52c06cL, 0x6211e6b5L, 0x66d0fb02L,
 57 |    0x5e9f46bfL, 0x5a5e5b08L, 0x571d7dd1L, 0x53dc6066L,
 58 |    0x4d9b3063L, 0x495a2dd4L, 0x44190b0dL, 0x40d816baL,
 59 |    0xaca5c697L, 0xa864db20L, 0xa527fdf9L, 0xa1e6e04eL,
 60 |    0xbfa1b04bL, 0xbb60adfcL, 0xb6238b25L, 0xb2e29692L,
 61 |    0x8aad2b2fL, 0x8e6c3698L, 0x832f1041L, 0x87ee0df6L,
 62 |    0x99a95df3L, 0x9d684044L, 0x902b669dL, 0x94ea7b2aL,
 63 |    0xe0b41de7L, 0xe4750050L, 0xe9362689L, 0xedf73b3eL,
 64 |    0xf3b06b3bL, 0xf771768cL, 0xfa325055L, 0xfef34de2L,
 65 |    0xc6bcf05fL, 0xc27dede8L, 0xcf3ecb31L, 0xcbffd686L,
 66 |    0xd5b88683L, 0xd1799b34L, 0xdc3abdedL, 0xd8fba05aL,
 67 |    0x690ce0eeL, 0x6dcdfd59L, 0x608edb80L, 0x644fc637L,
 68 |    0x7a089632L, 0x7ec98b85L, 0x738aad5cL, 0x774bb0ebL,
 69 |    0x4f040d56L, 0x4bc510e1L, 0x46863638L, 0x42472b8fL,
 70 |    0x5c007b8aL, 0x58c1663dL, 0x558240e4L, 0x51435d53L,
 71 |    0x251d3b9eL, 0x21dc2629L, 0x2c9f00f0L, 0x285e1d47L,
 72 |    0x36194d42L, 0x32d850f5L, 0x3f9b762cL, 0x3b5a6b9bL,
 73 |    0x0315d626L, 0x07d4cb91L, 0x0a97ed48L, 0x0e56f0ffL,
 74 |    0x1011a0faL, 0x14d0bd4dL, 0x19939b94L, 0x1d528623L,
 75 |    0xf12f560eL, 0xf5ee4bb9L, 0xf8ad6d60L, 0xfc6c70d7L,
 76 |    0xe22b20d2L, 0xe6ea3d65L, 0xeba91bbcL, 0xef68060bL,
 77 |    0xd727bbb6L, 0xd3e6a601L, 0xdea580d8L, 0xda649d6fL,
 78 |    0xc423cd6aL, 0xc0e2d0ddL, 0xcda1f604L, 0xc960ebb3L,
 79 |    0xbd3e8d7eL, 0xb9ff90c9L, 0xb4bcb610L, 0xb07daba7L,
 80 |    0xae3afba2L, 0xaafbe615L, 0xa7b8c0ccL, 0xa379dd7bL,
 81 |    0x9b3660c6L, 0x9ff77d71L, 0x92b45ba8L, 0x9675461fL,
 82 |    0x8832161aL, 0x8cf30badL, 0x81b02d74L, 0x857130c3L,
 83 |    0x5d8a9099L, 0x594b8d2eL, 0x5408abf7L, 0x50c9b640L,
 84 |    0x4e8ee645L, 0x4a4ffbf2L, 0x470cdd2bL, 0x43cdc09cL,
 85 |    0x7b827d21L, 0x7f436096L, 0x7200464fL, 0x76c15bf8L,
 86 |    0x68860bfdL, 0x6c47164aL, 0x61043093L, 0x65c52d24L,
 87 |    0x119b4be9L, 0x155a565eL, 0x18197087L, 0x1cd86d30L,
 88 |    0x029f3d35L, 0x065e2082L, 0x0b1d065bL, 0x0fdc1becL,
 89 |    0x3793a651L, 0x3352bbe6L, 0x3e119d3fL, 0x3ad08088L,
 90 |    0x2497d08dL, 0x2056cd3aL, 0x2d15ebe3L, 0x29d4f654L,
 91 |    0xc5a92679L, 0xc1683bceL, 0xcc2b1d17L, 0xc8ea00a0L,
 92 |    0xd6ad50a5L, 0xd26c4d12L, 0xdf2f6bcbL, 0xdbee767cL,
 93 |    0xe3a1cbc1L, 0xe760d676L, 0xea23f0afL, 0xeee2ed18L,
 94 |    0xf0a5bd1dL, 0xf464a0aaL, 0xf9278673L, 0xfde69bc4L,
 95 |    0x89b8fd09L, 0x8d79e0beL, 0x803ac667L, 0x84fbdbd0L,
 96 |    0x9abc8bd5L, 0x9e7d9662L, 0x933eb0bbL, 0x97ffad0cL,
 97 |    0xafb010b1L, 0xab710d06L, 0xa6322bdfL, 0xa2f33668L,
 98 |    0xbcb4666dL, 0xb8757bdaL, 0xb5365d03L, 0xb1f740b4L
 99 | };
100 | 
101 | 
102 | /*-------------------------------------------------------------*/
103 | /*--- end                                        crctable.c ---*/
104 | /*-------------------------------------------------------------*/
105 | 


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/crctable.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ChanJLee/android-patch/85678d935494f8a7dc1919f7b20469de81d9c465/serverpatch/bzip2-1.0.6/crctable.o


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/decompress.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ChanJLee/android-patch/85678d935494f8a7dc1919f7b20469de81d9c465/serverpatch/bzip2-1.0.6/decompress.o


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/dlltest.c:
--------------------------------------------------------------------------------
  1 | /*
  2 |    minibz2
  3 |       libbz2.dll test program.
  4 |       by Yoshioka Tsuneo (tsuneo@rr.iij4u.or.jp)
  5 |       This file is Public Domain.  Welcome any email to me.
  6 | 
  7 |    usage: minibz2 [-d] [-{1,2,..9}] [[srcfilename] destfilename]
  8 | */
  9 | 
 10 | #define BZ_IMPORT
 11 | #include 
 12 | #include 
 13 | #include "bzlib.h"
 14 | #ifdef _WIN32
 15 | #include 
 16 | #endif
 17 | 
 18 | 
 19 | #ifdef _WIN32
 20 | 
 21 | #define BZ2_LIBNAME "libbz2-1.0.2.DLL" 
 22 | 
 23 | #include 
 24 | static int BZ2DLLLoaded = 0;
 25 | static HINSTANCE BZ2DLLhLib;
 26 | int BZ2DLLLoadLibrary(void)
 27 | {
 28 |    HINSTANCE hLib;
 29 | 
 30 |    if(BZ2DLLLoaded==1){return 0;}
 31 |    hLib=LoadLibrary(BZ2_LIBNAME);
 32 |    if(hLib == NULL){
 33 |       fprintf(stderr,"Can't load %s\n",BZ2_LIBNAME);
 34 |       return -1;
 35 |    }
 36 |    BZ2_bzlibVersion=GetProcAddress(hLib,"BZ2_bzlibVersion");
 37 |    BZ2_bzopen=GetProcAddress(hLib,"BZ2_bzopen");
 38 |    BZ2_bzdopen=GetProcAddress(hLib,"BZ2_bzdopen");
 39 |    BZ2_bzread=GetProcAddress(hLib,"BZ2_bzread");
 40 |    BZ2_bzwrite=GetProcAddress(hLib,"BZ2_bzwrite");
 41 |    BZ2_bzflush=GetProcAddress(hLib,"BZ2_bzflush");
 42 |    BZ2_bzclose=GetProcAddress(hLib,"BZ2_bzclose");
 43 |    BZ2_bzerror=GetProcAddress(hLib,"BZ2_bzerror");
 44 | 
 45 |    if (!BZ2_bzlibVersion || !BZ2_bzopen || !BZ2_bzdopen
 46 |        || !BZ2_bzread || !BZ2_bzwrite || !BZ2_bzflush
 47 |        || !BZ2_bzclose || !BZ2_bzerror) {
 48 |       fprintf(stderr,"GetProcAddress failed.\n");
 49 |       return -1;
 50 |    }
 51 |    BZ2DLLLoaded=1;
 52 |    BZ2DLLhLib=hLib;
 53 |    return 0;
 54 | 
 55 | }
 56 | int BZ2DLLFreeLibrary(void)
 57 | {
 58 |    if(BZ2DLLLoaded==0){return 0;}
 59 |    FreeLibrary(BZ2DLLhLib);
 60 |    BZ2DLLLoaded=0;
 61 | }
 62 | #endif /* WIN32 */
 63 | 
 64 | void usage(void)
 65 | {
 66 |    puts("usage: minibz2 [-d] [-{1,2,..9}] [[srcfilename] destfilename]");
 67 | }
 68 | 
 69 | int main(int argc,char *argv[])
 70 | {
 71 |    int decompress = 0;
 72 |    int level = 9;
 73 |    char *fn_r = NULL;
 74 |    char *fn_w = NULL;
 75 | 
 76 | #ifdef _WIN32
 77 |    if(BZ2DLLLoadLibrary()<0){
 78 |       fprintf(stderr,"Loading of %s failed.  Giving up.\n", BZ2_LIBNAME);
 79 |       exit(1);
 80 |    }
 81 |    printf("Loading of %s succeeded.  Library version is %s.\n",
 82 |           BZ2_LIBNAME, BZ2_bzlibVersion() );
 83 | #endif
 84 |    while(++argv,--argc){
 85 |       if(**argv =='-' || **argv=='/'){
 86 |          char *p;
 87 | 
 88 |          for(p=*argv+1;*p;p++){
 89 |             if(*p=='d'){
 90 |                decompress = 1;
 91 |             }else if('1'<=*p && *p<='9'){
 92 |                level = *p - '0';
 93 |             }else{
 94 |                usage();
 95 |                exit(1);
 96 |             }
 97 |          }
 98 |       }else{
 99 |          break;
100 |       }
101 |    }
102 |    if(argc>=1){
103 |       fn_r = *argv;
104 |       argc--;argv++;
105 |    }else{
106 |       fn_r = NULL;
107 |    }
108 |    if(argc>=1){
109 |       fn_w = *argv;
110 |       argc--;argv++;
111 |    }else{
112 |       fn_w = NULL;
113 |    }
114 |    {
115 |       int len;
116 |       char buff[0x1000];
117 |       char mode[10];
118 | 
119 |       if(decompress){
120 |          BZFILE *BZ2fp_r = NULL;
121 |          FILE *fp_w = NULL;
122 | 
123 |          if(fn_w){
124 |             if((fp_w = fopen(fn_w,"wb"))==NULL){
125 |                printf("can't open [%s]\n",fn_w);
126 |                perror("reason:");
127 |                exit(1);
128 |             }
129 |          }else{
130 |             fp_w = stdout;
131 |          }
132 |          if((fn_r == NULL && (BZ2fp_r = BZ2_bzdopen(fileno(stdin),"rb"))==NULL)
133 |             || (fn_r != NULL && (BZ2fp_r = BZ2_bzopen(fn_r,"rb"))==NULL)){
134 |             printf("can't bz2openstream\n");
135 |             exit(1);
136 |          }
137 |          while((len=BZ2_bzread(BZ2fp_r,buff,0x1000))>0){
138 |             fwrite(buff,1,len,fp_w);
139 |          }
140 |          BZ2_bzclose(BZ2fp_r);
141 |          if(fp_w != stdout) fclose(fp_w);
142 |       }else{
143 |          BZFILE *BZ2fp_w = NULL;
144 |          FILE *fp_r = NULL;
145 | 
146 |          if(fn_r){
147 |             if((fp_r = fopen(fn_r,"rb"))==NULL){
148 |                printf("can't open [%s]\n",fn_r);
149 |                perror("reason:");
150 |                exit(1);
151 |             }
152 |          }else{
153 |             fp_r = stdin;
154 |          }
155 |          mode[0]='w';
156 |          mode[1] = '0' + level;
157 |          mode[2] = '\0';
158 | 
159 |          if((fn_w == NULL && (BZ2fp_w = BZ2_bzdopen(fileno(stdout),mode))==NULL)
160 |             || (fn_w !=NULL && (BZ2fp_w = BZ2_bzopen(fn_w,mode))==NULL)){
161 |             printf("can't bz2openstream\n");
162 |             exit(1);
163 |          }
164 |          while((len=fread(buff,1,0x1000,fp_r))>0){
165 |             BZ2_bzwrite(BZ2fp_w,buff,len);
166 |          }
167 |          BZ2_bzclose(BZ2fp_w);
168 |          if(fp_r!=stdin)fclose(fp_r);
169 |       }
170 |    }
171 | #ifdef _WIN32
172 |    BZ2DLLFreeLibrary();
173 | #endif
174 |    return 0;
175 | }
176 | 


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/dlltest.dsp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ChanJLee/android-patch/85678d935494f8a7dc1919f7b20469de81d9c465/serverpatch/bzip2-1.0.6/dlltest.dsp


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/entities.xml:
--------------------------------------------------------------------------------
 1 | 
 2 | 
 3 | 
 4 | 
 5 | 
 6 | 
 7 | 
 8 | 
 9 | 
10 | 


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/format.pl:
--------------------------------------------------------------------------------
 1 | #!/usr/bin/perl -w
 2 | #
 3 | # ------------------------------------------------------------------
 4 | # This file is part of bzip2/libbzip2, a program and library for
 5 | # lossless, block-sorting data compression.
 6 | #
 7 | # bzip2/libbzip2 version 1.0.6 of 6 September 2010
 8 | # Copyright (C) 1996-2010 Julian Seward 
 9 | #
10 | # Please read the WARNING, DISCLAIMER and PATENTS sections in the 
11 | # README file.
12 | #
13 | # This program is released under the terms of the license contained
14 | # in the file LICENSE.
15 | # ------------------------------------------------------------------
16 | #
17 | use strict;
18 | 
19 | # get command line values:
20 | if ( $#ARGV !=1 ) {
21 |     die "Usage:  $0 xml_infile xml_outfile\n";
22 | }
23 | 
24 | my $infile = shift;
25 | # check infile exists
26 | die "Can't find file \"$infile\""
27 |   unless -f $infile;
28 | # check we can read infile
29 | if (! -r $infile) {
30 |     die "Can't read input $infile\n";
31 | }
32 | # check we can open infile
33 | open( INFILE,"<$infile" ) or 
34 |     die "Can't input $infile $!";
35 | 
36 | #my $outfile = 'fmt-manual.xml';
37 | my $outfile = shift;
38 | #print "Infile: $infile, Outfile: $outfile\n";
39 | # check we can write to outfile
40 | open( OUTFILE,">$outfile" ) or 
41 |     die "Can't output $outfile $! for writing";
42 | 
43 | my ($prev, $curr, $str);
44 | $prev = ''; $curr = '';
45 | while (  ) {
46 | 
47 | 		print OUTFILE $prev;
48 |     $prev = $curr;
49 |     $curr = $_;
50 |     $str = '';
51 | 
52 |     if ( $prev =~ /$|$/ ) {
53 |         chomp $prev;
54 |         $curr = join( '', $prev, "|<\/screen>/ ) {
59 |         chomp $prev;
60 |         $curr = join( '', $prev, "]]>", $curr );
61 | 				$prev = '';
62 |         next;
63 |     }
64 | }
65 | print OUTFILE $curr;
66 | close INFILE;
67 | close OUTFILE;
68 | exit;
69 | 


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/huffman.c:
--------------------------------------------------------------------------------
  1 | 
  2 | /*-------------------------------------------------------------*/
  3 | /*--- Huffman coding low-level stuff                        ---*/
  4 | /*---                                             huffman.c ---*/
  5 | /*-------------------------------------------------------------*/
  6 | 
  7 | /* ------------------------------------------------------------------
  8 |    This file is part of bzip2/libbzip2, a program and library for
  9 |    lossless, block-sorting data compression.
 10 | 
 11 |    bzip2/libbzip2 version 1.0.6 of 6 September 2010
 12 |    Copyright (C) 1996-2010 Julian Seward 
 13 | 
 14 |    Please read the WARNING, DISCLAIMER and PATENTS sections in the 
 15 |    README file.
 16 | 
 17 |    This program is released under the terms of the license contained
 18 |    in the file LICENSE.
 19 |    ------------------------------------------------------------------ */
 20 | 
 21 | 
 22 | #include "bzlib_private.h"
 23 | 
 24 | /*---------------------------------------------------*/
 25 | #define WEIGHTOF(zz0)  ((zz0) & 0xffffff00)
 26 | #define DEPTHOF(zz1)   ((zz1) & 0x000000ff)
 27 | #define MYMAX(zz2,zz3) ((zz2) > (zz3) ? (zz2) : (zz3))
 28 | 
 29 | #define ADDWEIGHTS(zw1,zw2)                           \
 30 |    (WEIGHTOF(zw1)+WEIGHTOF(zw2)) |                    \
 31 |    (1 + MYMAX(DEPTHOF(zw1),DEPTHOF(zw2)))
 32 | 
 33 | #define UPHEAP(z)                                     \
 34 | {                                                     \
 35 |    Int32 zz, tmp;                                     \
 36 |    zz = z; tmp = heap[zz];                            \
 37 |    while (weight[tmp] < weight[heap[zz >> 1]]) {      \
 38 |       heap[zz] = heap[zz >> 1];                       \
 39 |       zz >>= 1;                                       \
 40 |    }                                                  \
 41 |    heap[zz] = tmp;                                    \
 42 | }
 43 | 
 44 | #define DOWNHEAP(z)                                   \
 45 | {                                                     \
 46 |    Int32 zz, yy, tmp;                                 \
 47 |    zz = z; tmp = heap[zz];                            \
 48 |    while (True) {                                     \
 49 |       yy = zz << 1;                                   \
 50 |       if (yy > nHeap) break;                          \
 51 |       if (yy < nHeap &&                               \
 52 |           weight[heap[yy+1]] < weight[heap[yy]])      \
 53 |          yy++;                                        \
 54 |       if (weight[tmp] < weight[heap[yy]]) break;      \
 55 |       heap[zz] = heap[yy];                            \
 56 |       zz = yy;                                        \
 57 |    }                                                  \
 58 |    heap[zz] = tmp;                                    \
 59 | }
 60 | 
 61 | 
 62 | /*---------------------------------------------------*/
 63 | void BZ2_hbMakeCodeLengths ( UChar *len, 
 64 |                              Int32 *freq,
 65 |                              Int32 alphaSize,
 66 |                              Int32 maxLen )
 67 | {
 68 |    /*--
 69 |       Nodes and heap entries run from 1.  Entry 0
 70 |       for both the heap and nodes is a sentinel.
 71 |    --*/
 72 |    Int32 nNodes, nHeap, n1, n2, i, j, k;
 73 |    Bool  tooLong;
 74 | 
 75 |    Int32 heap   [ BZ_MAX_ALPHA_SIZE + 2 ];
 76 |    Int32 weight [ BZ_MAX_ALPHA_SIZE * 2 ];
 77 |    Int32 parent [ BZ_MAX_ALPHA_SIZE * 2 ]; 
 78 | 
 79 |    for (i = 0; i < alphaSize; i++)
 80 |       weight[i+1] = (freq[i] == 0 ? 1 : freq[i]) << 8;
 81 | 
 82 |    while (True) {
 83 | 
 84 |       nNodes = alphaSize;
 85 |       nHeap = 0;
 86 | 
 87 |       heap[0] = 0;
 88 |       weight[0] = 0;
 89 |       parent[0] = -2;
 90 | 
 91 |       for (i = 1; i <= alphaSize; i++) {
 92 |          parent[i] = -1;
 93 |          nHeap++;
 94 |          heap[nHeap] = i;
 95 |          UPHEAP(nHeap);
 96 |       }
 97 | 
 98 |       AssertH( nHeap < (BZ_MAX_ALPHA_SIZE+2), 2001 );
 99 |    
100 |       while (nHeap > 1) {
101 |          n1 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1);
102 |          n2 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1);
103 |          nNodes++;
104 |          parent[n1] = parent[n2] = nNodes;
105 |          weight[nNodes] = ADDWEIGHTS(weight[n1], weight[n2]);
106 |          parent[nNodes] = -1;
107 |          nHeap++;
108 |          heap[nHeap] = nNodes;
109 |          UPHEAP(nHeap);
110 |       }
111 | 
112 |       AssertH( nNodes < (BZ_MAX_ALPHA_SIZE * 2), 2002 );
113 | 
114 |       tooLong = False;
115 |       for (i = 1; i <= alphaSize; i++) {
116 |          j = 0;
117 |          k = i;
118 |          while (parent[k] >= 0) { k = parent[k]; j++; }
119 |          len[i-1] = j;
120 |          if (j > maxLen) tooLong = True;
121 |       }
122 |       
123 |       if (! tooLong) break;
124 | 
125 |       /* 17 Oct 04: keep-going condition for the following loop used
126 |          to be 'i < alphaSize', which missed the last element,
127 |          theoretically leading to the possibility of the compressor
128 |          looping.  However, this count-scaling step is only needed if
129 |          one of the generated Huffman code words is longer than
130 |          maxLen, which up to and including version 1.0.2 was 20 bits,
131 |          which is extremely unlikely.  In version 1.0.3 maxLen was
132 |          changed to 17 bits, which has minimal effect on compression
133 |          ratio, but does mean this scaling step is used from time to
134 |          time, enough to verify that it works.
135 | 
136 |          This means that bzip2-1.0.3 and later will only produce
137 |          Huffman codes with a maximum length of 17 bits.  However, in
138 |          order to preserve backwards compatibility with bitstreams
139 |          produced by versions pre-1.0.3, the decompressor must still
140 |          handle lengths of up to 20. */
141 | 
142 |       for (i = 1; i <= alphaSize; i++) {
143 |          j = weight[i] >> 8;
144 |          j = 1 + (j / 2);
145 |          weight[i] = j << 8;
146 |       }
147 |    }
148 | }
149 | 
150 | 
151 | /*---------------------------------------------------*/
152 | void BZ2_hbAssignCodes ( Int32 *code,
153 |                          UChar *length,
154 |                          Int32 minLen,
155 |                          Int32 maxLen,
156 |                          Int32 alphaSize )
157 | {
158 |    Int32 n, vec, i;
159 | 
160 |    vec = 0;
161 |    for (n = minLen; n <= maxLen; n++) {
162 |       for (i = 0; i < alphaSize; i++)
163 |          if (length[i] == n) { code[i] = vec; vec++; };
164 |       vec <<= 1;
165 |    }
166 | }
167 | 
168 | 
169 | /*---------------------------------------------------*/
170 | void BZ2_hbCreateDecodeTables ( Int32 *limit,
171 |                                 Int32 *base,
172 |                                 Int32 *perm,
173 |                                 UChar *length,
174 |                                 Int32 minLen,
175 |                                 Int32 maxLen,
176 |                                 Int32 alphaSize )
177 | {
178 |    Int32 pp, i, j, vec;
179 | 
180 |    pp = 0;
181 |    for (i = minLen; i <= maxLen; i++)
182 |       for (j = 0; j < alphaSize; j++)
183 |          if (length[j] == i) { perm[pp] = j; pp++; };
184 | 
185 |    for (i = 0; i < BZ_MAX_CODE_LEN; i++) base[i] = 0;
186 |    for (i = 0; i < alphaSize; i++) base[length[i]+1]++;
187 | 
188 |    for (i = 1; i < BZ_MAX_CODE_LEN; i++) base[i] += base[i-1];
189 | 
190 |    for (i = 0; i < BZ_MAX_CODE_LEN; i++) limit[i] = 0;
191 |    vec = 0;
192 | 
193 |    for (i = minLen; i <= maxLen; i++) {
194 |       vec += (base[i+1] - base[i]);
195 |       limit[i] = vec-1;
196 |       vec <<= 1;
197 |    }
198 |    for (i = minLen + 1; i <= maxLen; i++)
199 |       base[i] = ((limit[i-1] + 1) << 1) - base[i];
200 | }
201 | 
202 | 
203 | /*-------------------------------------------------------------*/
204 | /*--- end                                         huffman.c ---*/
205 | /*-------------------------------------------------------------*/
206 | 


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/huffman.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ChanJLee/android-patch/85678d935494f8a7dc1919f7b20469de81d9c465/serverpatch/bzip2-1.0.6/huffman.o


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/libbz2.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ChanJLee/android-patch/85678d935494f8a7dc1919f7b20469de81d9c465/serverpatch/bzip2-1.0.6/libbz2.a


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/libbz2.def:
--------------------------------------------------------------------------------
 1 | LIBRARY			LIBBZ2
 2 | DESCRIPTION		"libbzip2: library for data compression"
 3 | EXPORTS
 4 | 	BZ2_bzCompressInit
 5 | 	BZ2_bzCompress
 6 | 	BZ2_bzCompressEnd
 7 | 	BZ2_bzDecompressInit
 8 | 	BZ2_bzDecompress
 9 | 	BZ2_bzDecompressEnd
10 | 	BZ2_bzReadOpen
11 | 	BZ2_bzReadClose
12 | 	BZ2_bzReadGetUnused
13 | 	BZ2_bzRead
14 | 	BZ2_bzWriteOpen
15 | 	BZ2_bzWrite
16 | 	BZ2_bzWriteClose
17 | 	BZ2_bzWriteClose64
18 | 	BZ2_bzBuffToBuffCompress
19 | 	BZ2_bzBuffToBuffDecompress
20 | 	BZ2_bzlibVersion
21 | 	BZ2_bzopen
22 | 	BZ2_bzdopen
23 | 	BZ2_bzread
24 | 	BZ2_bzwrite
25 | 	BZ2_bzflush
26 | 	BZ2_bzclose
27 | 	BZ2_bzerror
28 | 


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/libbz2.dsp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ChanJLee/android-patch/85678d935494f8a7dc1919f7b20469de81d9c465/serverpatch/bzip2-1.0.6/libbz2.dsp


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/makefile.msc:
--------------------------------------------------------------------------------
 1 | # Makefile for Microsoft Visual C++ 6.0
 2 | # usage: nmake -f makefile.msc
 3 | # K.M. Syring (syring@gsf.de)
 4 | # Fixed up by JRS for bzip2-0.9.5d release.
 5 | 
 6 | CC=cl
 7 | CFLAGS= -DWIN32 -MD -Ox -D_FILE_OFFSET_BITS=64 -nologo
 8 | 
 9 | OBJS= blocksort.obj  \
10 |       huffman.obj    \
11 |       crctable.obj   \
12 |       randtable.obj  \
13 |       compress.obj   \
14 |       decompress.obj \
15 |       bzlib.obj
16 | 
17 | all: lib bzip2 test
18 | 
19 | bzip2: lib
20 | 	$(CC) $(CFLAGS) -o bzip2 bzip2.c libbz2.lib setargv.obj
21 | 	$(CC) $(CFLAGS) -o bzip2recover bzip2recover.c
22 | 
23 | lib: $(OBJS)
24 | 	lib /out:libbz2.lib $(OBJS)
25 | 
26 | test: bzip2
27 | 	type words1
28 | 	.\\bzip2 -1  < sample1.ref > sample1.rb2
29 | 	.\\bzip2 -2  < sample2.ref > sample2.rb2
30 | 	.\\bzip2 -3  < sample3.ref > sample3.rb2
31 | 	.\\bzip2 -d  < sample1.bz2 > sample1.tst
32 | 	.\\bzip2 -d  < sample2.bz2 > sample2.tst
33 | 	.\\bzip2 -ds < sample3.bz2 > sample3.tst
34 | 	@echo All six of the fc's should find no differences.
35 | 	@echo If fc finds an error on sample3.bz2, this could be
36 | 	@echo because WinZip's 'TAR file smart CR/LF conversion'
37 | 	@echo is too clever for its own good.  Disable this option.
38 | 	@echo The correct size for sample3.ref is 120,244.  If it
39 | 	@echo is 150,251, WinZip has messed it up.
40 | 	fc sample1.bz2 sample1.rb2 
41 | 	fc sample2.bz2 sample2.rb2
42 | 	fc sample3.bz2 sample3.rb2
43 | 	fc sample1.tst sample1.ref
44 | 	fc sample2.tst sample2.ref
45 | 	fc sample3.tst sample3.ref
46 | 
47 | 
48 | 
49 | clean: 
50 | 	del *.obj
51 | 	del libbz2.lib 
52 | 	del bzip2.exe
53 | 	del bzip2recover.exe
54 | 	del sample1.rb2 
55 | 	del sample2.rb2 
56 | 	del sample3.rb2
57 | 	del sample1.tst 
58 | 	del sample2.tst
59 | 	del sample3.tst
60 | 
61 | .c.obj: 
62 | 	$(CC) $(CFLAGS) -c $*.c -o $*.obj
63 | 
64 | 


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/manual.html:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ChanJLee/android-patch/85678d935494f8a7dc1919f7b20469de81d9c465/serverpatch/bzip2-1.0.6/manual.html


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/manual.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ChanJLee/android-patch/85678d935494f8a7dc1919f7b20469de81d9c465/serverpatch/bzip2-1.0.6/manual.pdf


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/mk251.c:
--------------------------------------------------------------------------------
 1 | 
 2 | /* Spew out a long sequence of the byte 251.  When fed to bzip2
 3 |    versions 1.0.0 or 1.0.1, causes it to die with internal error
 4 |    1007 in blocksort.c.  This assertion misses an extremely rare
 5 |    case, which is fixed in this version (1.0.2) and above.
 6 | */
 7 | 
 8 | /* ------------------------------------------------------------------
 9 |    This file is part of bzip2/libbzip2, a program and library for
10 |    lossless, block-sorting data compression.
11 | 
12 |    bzip2/libbzip2 version 1.0.6 of 6 September 2010
13 |    Copyright (C) 1996-2010 Julian Seward 
14 | 
15 |    Please read the WARNING, DISCLAIMER and PATENTS sections in the 
16 |    README file.
17 | 
18 |    This program is released under the terms of the license contained
19 |    in the file LICENSE.
20 |    ------------------------------------------------------------------ */
21 | 
22 | 
23 | #include 
24 | 
25 | int main ()
26 | {
27 |    int i;
28 |    for (i = 0; i < 48500000 ; i++)
29 |      putchar(251);
30 |    return 0;
31 | }
32 | 


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/randtable.c:
--------------------------------------------------------------------------------
 1 | 
 2 | /*-------------------------------------------------------------*/
 3 | /*--- Table for randomising repetitive blocks               ---*/
 4 | /*---                                           randtable.c ---*/
 5 | /*-------------------------------------------------------------*/
 6 | 
 7 | /* ------------------------------------------------------------------
 8 |    This file is part of bzip2/libbzip2, a program and library for
 9 |    lossless, block-sorting data compression.
10 | 
11 |    bzip2/libbzip2 version 1.0.6 of 6 September 2010
12 |    Copyright (C) 1996-2010 Julian Seward 
13 | 
14 |    Please read the WARNING, DISCLAIMER and PATENTS sections in the 
15 |    README file.
16 | 
17 |    This program is released under the terms of the license contained
18 |    in the file LICENSE.
19 |    ------------------------------------------------------------------ */
20 | 
21 | 
22 | #include "bzlib_private.h"
23 | 
24 | 
25 | /*---------------------------------------------*/
26 | Int32 BZ2_rNums[512] = { 
27 |    619, 720, 127, 481, 931, 816, 813, 233, 566, 247, 
28 |    985, 724, 205, 454, 863, 491, 741, 242, 949, 214, 
29 |    733, 859, 335, 708, 621, 574, 73, 654, 730, 472, 
30 |    419, 436, 278, 496, 867, 210, 399, 680, 480, 51, 
31 |    878, 465, 811, 169, 869, 675, 611, 697, 867, 561, 
32 |    862, 687, 507, 283, 482, 129, 807, 591, 733, 623, 
33 |    150, 238, 59, 379, 684, 877, 625, 169, 643, 105, 
34 |    170, 607, 520, 932, 727, 476, 693, 425, 174, 647, 
35 |    73, 122, 335, 530, 442, 853, 695, 249, 445, 515, 
36 |    909, 545, 703, 919, 874, 474, 882, 500, 594, 612, 
37 |    641, 801, 220, 162, 819, 984, 589, 513, 495, 799, 
38 |    161, 604, 958, 533, 221, 400, 386, 867, 600, 782, 
39 |    382, 596, 414, 171, 516, 375, 682, 485, 911, 276, 
40 |    98, 553, 163, 354, 666, 933, 424, 341, 533, 870, 
41 |    227, 730, 475, 186, 263, 647, 537, 686, 600, 224, 
42 |    469, 68, 770, 919, 190, 373, 294, 822, 808, 206, 
43 |    184, 943, 795, 384, 383, 461, 404, 758, 839, 887, 
44 |    715, 67, 618, 276, 204, 918, 873, 777, 604, 560, 
45 |    951, 160, 578, 722, 79, 804, 96, 409, 713, 940, 
46 |    652, 934, 970, 447, 318, 353, 859, 672, 112, 785, 
47 |    645, 863, 803, 350, 139, 93, 354, 99, 820, 908, 
48 |    609, 772, 154, 274, 580, 184, 79, 626, 630, 742, 
49 |    653, 282, 762, 623, 680, 81, 927, 626, 789, 125, 
50 |    411, 521, 938, 300, 821, 78, 343, 175, 128, 250, 
51 |    170, 774, 972, 275, 999, 639, 495, 78, 352, 126, 
52 |    857, 956, 358, 619, 580, 124, 737, 594, 701, 612, 
53 |    669, 112, 134, 694, 363, 992, 809, 743, 168, 974, 
54 |    944, 375, 748, 52, 600, 747, 642, 182, 862, 81, 
55 |    344, 805, 988, 739, 511, 655, 814, 334, 249, 515, 
56 |    897, 955, 664, 981, 649, 113, 974, 459, 893, 228, 
57 |    433, 837, 553, 268, 926, 240, 102, 654, 459, 51, 
58 |    686, 754, 806, 760, 493, 403, 415, 394, 687, 700, 
59 |    946, 670, 656, 610, 738, 392, 760, 799, 887, 653, 
60 |    978, 321, 576, 617, 626, 502, 894, 679, 243, 440, 
61 |    680, 879, 194, 572, 640, 724, 926, 56, 204, 700, 
62 |    707, 151, 457, 449, 797, 195, 791, 558, 945, 679, 
63 |    297, 59, 87, 824, 713, 663, 412, 693, 342, 606, 
64 |    134, 108, 571, 364, 631, 212, 174, 643, 304, 329, 
65 |    343, 97, 430, 751, 497, 314, 983, 374, 822, 928, 
66 |    140, 206, 73, 263, 980, 736, 876, 478, 430, 305, 
67 |    170, 514, 364, 692, 829, 82, 855, 953, 676, 246, 
68 |    369, 970, 294, 750, 807, 827, 150, 790, 288, 923, 
69 |    804, 378, 215, 828, 592, 281, 565, 555, 710, 82, 
70 |    896, 831, 547, 261, 524, 462, 293, 465, 502, 56, 
71 |    661, 821, 976, 991, 658, 869, 905, 758, 745, 193, 
72 |    768, 550, 608, 933, 378, 286, 215, 979, 792, 961, 
73 |    61, 688, 793, 644, 986, 403, 106, 366, 905, 644, 
74 |    372, 567, 466, 434, 645, 210, 389, 550, 919, 135, 
75 |    780, 773, 635, 389, 707, 100, 626, 958, 165, 504, 
76 |    920, 176, 193, 713, 857, 265, 203, 50, 668, 108, 
77 |    645, 990, 626, 197, 510, 357, 358, 850, 858, 364, 
78 |    936, 638
79 | };
80 | 
81 | 
82 | /*-------------------------------------------------------------*/
83 | /*--- end                                       randtable.c ---*/
84 | /*-------------------------------------------------------------*/
85 | 


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/randtable.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ChanJLee/android-patch/85678d935494f8a7dc1919f7b20469de81d9c465/serverpatch/bzip2-1.0.6/randtable.o


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/sample1.bz2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ChanJLee/android-patch/85678d935494f8a7dc1919f7b20469de81d9c465/serverpatch/bzip2-1.0.6/sample1.bz2


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/sample1.rb2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ChanJLee/android-patch/85678d935494f8a7dc1919f7b20469de81d9c465/serverpatch/bzip2-1.0.6/sample1.rb2


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/sample1.ref:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ChanJLee/android-patch/85678d935494f8a7dc1919f7b20469de81d9c465/serverpatch/bzip2-1.0.6/sample1.ref


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/sample1.tst:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ChanJLee/android-patch/85678d935494f8a7dc1919f7b20469de81d9c465/serverpatch/bzip2-1.0.6/sample1.tst


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/sample2.bz2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ChanJLee/android-patch/85678d935494f8a7dc1919f7b20469de81d9c465/serverpatch/bzip2-1.0.6/sample2.bz2


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/sample2.rb2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ChanJLee/android-patch/85678d935494f8a7dc1919f7b20469de81d9c465/serverpatch/bzip2-1.0.6/sample2.rb2


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/sample2.ref:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ChanJLee/android-patch/85678d935494f8a7dc1919f7b20469de81d9c465/serverpatch/bzip2-1.0.6/sample2.ref


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/sample2.tst:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ChanJLee/android-patch/85678d935494f8a7dc1919f7b20469de81d9c465/serverpatch/bzip2-1.0.6/sample2.tst


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/sample3.bz2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ChanJLee/android-patch/85678d935494f8a7dc1919f7b20469de81d9c465/serverpatch/bzip2-1.0.6/sample3.bz2


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/sample3.rb2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ChanJLee/android-patch/85678d935494f8a7dc1919f7b20469de81d9c465/serverpatch/bzip2-1.0.6/sample3.rb2


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/spewG.c:
--------------------------------------------------------------------------------
 1 | 
 2 | /* spew out a thoroughly gigantic file designed so that bzip2
 3 |    can compress it reasonably rapidly.  This is to help test
 4 |    support for large files (> 2GB) in a reasonable amount of time.
 5 |    I suggest you use the undocumented --exponential option to
 6 |    bzip2 when compressing the resulting file; this saves a bit of
 7 |    time.  Note: *don't* bother with --exponential when compressing 
 8 |    Real Files; it'll just waste a lot of CPU time :-)
 9 |    (but is otherwise harmless).
10 | */
11 | 
12 | /* ------------------------------------------------------------------
13 |    This file is part of bzip2/libbzip2, a program and library for
14 |    lossless, block-sorting data compression.
15 | 
16 |    bzip2/libbzip2 version 1.0.6 of 6 September 2010
17 |    Copyright (C) 1996-2010 Julian Seward 
18 | 
19 |    Please read the WARNING, DISCLAIMER and PATENTS sections in the 
20 |    README file.
21 | 
22 |    This program is released under the terms of the license contained
23 |    in the file LICENSE.
24 | 	 ------------------------------------------------------------------ */
25 | 
26 | 
27 | #define _FILE_OFFSET_BITS 64
28 | 
29 | #include 
30 | #include 
31 | 
32 | /* The number of megabytes of junk to spew out (roughly) */
33 | #define MEGABYTES 5000
34 | 
35 | #define N_BUF 1000000
36 | char buf[N_BUF];
37 | 
38 | int main ( int argc, char** argv )
39 | {
40 |    int ii, kk, p;
41 |    srandom(1);
42 |    setbuffer ( stdout, buf, N_BUF );
43 |    for (kk = 0; kk < MEGABYTES * 515; kk+=3) {
44 |       p = 25+random()%50;
45 |       for (ii = 0; ii < p; ii++)
46 |          printf ( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" );
47 |       for (ii = 0; ii < p-1; ii++)
48 |          printf ( "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" );
49 |       for (ii = 0; ii < p+1; ii++)
50 |          printf ( "ccccccccccccccccccccccccccccccccccccc" );
51 |    }
52 |    fflush(stdout);
53 |    return 0;
54 | }
55 | 


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/unzcrash.c:
--------------------------------------------------------------------------------
  1 | 
  2 | /* A test program written to test robustness to decompression of
  3 |    corrupted data.  Usage is 
  4 |        unzcrash filename
  5 |    and the program will read the specified file, compress it (in memory),
  6 |    and then repeatedly decompress it, each time with a different bit of
  7 |    the compressed data inverted, so as to test all possible one-bit errors.
  8 |    This should not cause any invalid memory accesses.  If it does, 
  9 |    I want to know about it!
 10 | 
 11 |    PS.  As you can see from the above description, the process is
 12 |    incredibly slow.  A file of size eg 5KB will cause it to run for
 13 |    many hours.
 14 | */
 15 | 
 16 | /* ------------------------------------------------------------------
 17 |    This file is part of bzip2/libbzip2, a program and library for
 18 |    lossless, block-sorting data compression.
 19 | 
 20 |    bzip2/libbzip2 version 1.0.6 of 6 September 2010
 21 |    Copyright (C) 1996-2010 Julian Seward 
 22 | 
 23 |    Please read the WARNING, DISCLAIMER and PATENTS sections in the 
 24 |    README file.
 25 | 
 26 |    This program is released under the terms of the license contained
 27 |    in the file LICENSE.
 28 |    ------------------------------------------------------------------ */
 29 | 
 30 | 
 31 | #include 
 32 | #include 
 33 | #include "bzlib.h"
 34 | 
 35 | #define M_BLOCK 1000000
 36 | 
 37 | typedef unsigned char uchar;
 38 | 
 39 | #define M_BLOCK_OUT (M_BLOCK + 1000000)
 40 | uchar inbuf[M_BLOCK];
 41 | uchar outbuf[M_BLOCK_OUT];
 42 | uchar zbuf[M_BLOCK + 600 + (M_BLOCK / 100)];
 43 | 
 44 | int nIn, nOut, nZ;
 45 | 
 46 | static char *bzerrorstrings[] = {
 47 |        "OK"
 48 |       ,"SEQUENCE_ERROR"
 49 |       ,"PARAM_ERROR"
 50 |       ,"MEM_ERROR"
 51 |       ,"DATA_ERROR"
 52 |       ,"DATA_ERROR_MAGIC"
 53 |       ,"IO_ERROR"
 54 |       ,"UNEXPECTED_EOF"
 55 |       ,"OUTBUFF_FULL"
 56 |       ,"???"   /* for future */
 57 |       ,"???"   /* for future */
 58 |       ,"???"   /* for future */
 59 |       ,"???"   /* for future */
 60 |       ,"???"   /* for future */
 61 |       ,"???"   /* for future */
 62 | };
 63 | 
 64 | void flip_bit ( int bit )
 65 | {
 66 |    int byteno = bit / 8;
 67 |    int bitno  = bit % 8;
 68 |    uchar mask = 1 << bitno;
 69 |    //fprintf ( stderr, "(byte %d  bit %d  mask %d)",
 70 |    //          byteno, bitno, (int)mask );
 71 |    zbuf[byteno] ^= mask;
 72 | }
 73 | 
 74 | int main ( int argc, char** argv )
 75 | {
 76 |    FILE* f;
 77 |    int   r;
 78 |    int   bit;
 79 |    int   i;
 80 | 
 81 |    if (argc != 2) {
 82 |       fprintf ( stderr, "usage: unzcrash filename\n" );
 83 |       return 1;
 84 |    }
 85 | 
 86 |    f = fopen ( argv[1], "r" );
 87 |    if (!f) {
 88 |       fprintf ( stderr, "unzcrash: can't open %s\n", argv[1] );
 89 |       return 1;
 90 |    }
 91 | 
 92 |    nIn = fread ( inbuf, 1, M_BLOCK, f );
 93 |    fprintf ( stderr, "%d bytes read\n", nIn );
 94 | 
 95 |    nZ = M_BLOCK;
 96 |    r = BZ2_bzBuffToBuffCompress (
 97 |          zbuf, &nZ, inbuf, nIn, 9, 0, 30 );
 98 | 
 99 |    assert (r == BZ_OK);
100 |    fprintf ( stderr, "%d after compression\n", nZ );
101 | 
102 |    for (bit = 0; bit < nZ*8; bit++) {
103 |       fprintf ( stderr, "bit %d  ", bit );
104 |       flip_bit ( bit );
105 |       nOut = M_BLOCK_OUT;
106 |       r = BZ2_bzBuffToBuffDecompress (
107 |             outbuf, &nOut, zbuf, nZ, 0, 0 );
108 |       fprintf ( stderr, " %d  %s ", r, bzerrorstrings[-r] );
109 | 
110 |       if (r != BZ_OK) {
111 |          fprintf ( stderr, "\n" );
112 |       } else {
113 |          if (nOut != nIn) {
114 |            fprintf(stderr, "nIn/nOut mismatch %d %d\n", nIn, nOut );
115 |            return 1;
116 |          } else {
117 |            for (i = 0; i < nOut; i++)
118 |              if (inbuf[i] != outbuf[i]) { 
119 |                 fprintf(stderr, "mismatch at %d\n", i ); 
120 |                 return 1; 
121 |            }
122 |            if (i == nOut) fprintf(stderr, "really ok!\n" );
123 |          }
124 |       }
125 | 
126 |       flip_bit ( bit );
127 |    }
128 | 
129 | #if 0
130 |    assert (nOut == nIn);
131 |    for (i = 0; i < nOut; i++) {
132 |      if (inbuf[i] != outbuf[i]) {
133 |         fprintf ( stderr, "difference at %d !\n", i );
134 |         return 1;
135 |      }
136 |    }
137 | #endif
138 | 
139 |    fprintf ( stderr, "all ok\n" );
140 |    return 0;
141 | }
142 | 


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/words0:
--------------------------------------------------------------------------------
 1 | 
 2 | If compilation produces errors, or a large number of warnings,
 3 | please read README.COMPILATION.PROBLEMS -- you might be able to
 4 | adjust the flags in this Makefile to improve matters.
 5 | 
 6 | Also in README.COMPILATION.PROBLEMS are some hints that may help
 7 | if your build produces an executable which is unable to correctly
 8 | handle so-called 'large files' -- files of size 2GB or more.
 9 | 
10 | 


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/words1:
--------------------------------------------------------------------------------
1 | 
2 | Doing 6 tests (3 compress, 3 uncompress) ...
3 | If there's a problem, things might stop at this point.
4 |  
5 | 


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/words2:
--------------------------------------------------------------------------------
1 | 
2 | Checking test results.  If any of the four "cmp"s which follow
3 | report any differences, something is wrong.  If you can't easily
4 | figure out what, please let me know (jseward@bzip.org).
5 | 
6 | 


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/words3:
--------------------------------------------------------------------------------
 1 | 
 2 | If you got this far and the 'cmp's didn't complain, it looks
 3 | like you're in business.  
 4 | 
 5 | To install in /usr/local/bin, /usr/local/lib, /usr/local/man and 
 6 | /usr/local/include, type
 7 | 
 8 |    make install
 9 | 
10 | To install somewhere else, eg, /xxx/yyy/{bin,lib,man,include}, type 
11 | 
12 |    make install PREFIX=/xxx/yyy
13 | 
14 | If you are (justifiably) paranoid and want to see what 'make install'
15 | is going to do, you can first do
16 | 
17 |    make -n install                      or
18 |    make -n install PREFIX=/xxx/yyy      respectively.
19 | 
20 | The -n instructs make to show the commands it would execute, but
21 | not actually execute them.
22 | 
23 | Instructions for use are in the preformatted manual page, in the file
24 | bzip2.txt.  For more detailed documentation, read the full manual.  
25 | It is available in Postscript form (manual.ps), PDF form (manual.pdf),
26 | and HTML form (manual.html).
27 | 
28 | You can also do "bzip2 --help" to see some helpful information. 
29 | "bzip2 -L" displays the software license.
30 | 
31 | 


--------------------------------------------------------------------------------
/serverpatch/bzip2-1.0.6/xmlproc.sh:
--------------------------------------------------------------------------------
  1 | #!/bin/bash
  2 | # see the README file for usage etc.
  3 | #
  4 | # ------------------------------------------------------------------
  5 | #  This file is part of bzip2/libbzip2, a program and library for
  6 | #  lossless, block-sorting data compression.
  7 | #
  8 | #  bzip2/libbzip2 version 1.0.6 of 6 September 2010
  9 | #  Copyright (C) 1996-2010 Julian Seward 
 10 | #
 11 | #  Please read the WARNING, DISCLAIMER and PATENTS sections in the 
 12 | #  README file.
 13 | #
 14 | #  This program is released under the terms of the license contained
 15 | #  in the file LICENSE.
 16 | # ----------------------------------------------------------------
 17 | 
 18 | 
 19 | usage() {
 20 |   echo '';
 21 |   echo 'Usage: xmlproc.sh -[option] ';
 22 |   echo 'Specify a target from:';
 23 |   echo '-v      verify xml file conforms to dtd';
 24 |   echo '-html   output in html format (single file)';
 25 |   echo '-ps     output in postscript format';
 26 |   echo '-pdf    output in pdf format';
 27 |   exit;
 28 | }
 29 | 
 30 | if test $# -ne 2; then
 31 |   usage
 32 | fi
 33 | # assign the variable for the output type
 34 | action=$1; shift
 35 | # assign the output filename
 36 | xmlfile=$1; shift
 37 | # and check user input it correct
 38 | if !(test -f $xmlfile); then
 39 |   echo "No such file: $xmlfile";
 40 |   exit;
 41 | fi
 42 | # some other stuff we will use
 43 | OUT=output
 44 | xsl_fo=bz-fo.xsl
 45 | xsl_html=bz-html.xsl
 46 | 
 47 | basename=$xmlfile
 48 | basename=${basename//'.xml'/''}
 49 | 
 50 | fofile="${basename}.fo"
 51 | htmlfile="${basename}.html"
 52 | pdffile="${basename}.pdf"
 53 | psfile="${basename}.ps"
 54 | xmlfmtfile="${basename}.fmt"
 55 | 
 56 | # first process the xmlfile with CDATA tags
 57 | ./format.pl $xmlfile $xmlfmtfile
 58 | # so the shell knows where the catalogs live
 59 | export XML_CATALOG_FILES=/etc/xml/catalog
 60 | 
 61 | # post-processing tidy up
 62 | cleanup() {
 63 |   echo "Cleaning up: $@" 
 64 |   while [ $# != 0 ]
 65 |   do
 66 |     arg=$1; shift;
 67 |     echo "  deleting $arg";
 68 |     rm $arg
 69 |   done
 70 | }
 71 | 
 72 | case $action in
 73 |   -v)
 74 |    flags='--noout --xinclude --noblanks --postvalid'
 75 |    dtd='--dtdvalid http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd'
 76 |    xmllint $flags $dtd $xmlfmtfile 2> $OUT 
 77 |    egrep 'error' $OUT 
 78 |    rm $OUT
 79 |   ;;
 80 | 
 81 |   -html)
 82 |    echo "Creating $htmlfile ..."
 83 |    xsltproc --nonet --xinclude  -o $htmlfile $xsl_html $xmlfmtfile
 84 |    cleanup $xmlfmtfile
 85 |   ;;
 86 | 
 87 |   -pdf)
 88 |    echo "Creating $pdffile ..."
 89 |    xsltproc --nonet --xinclude -o $fofile $xsl_fo $xmlfmtfile
 90 |    pdfxmltex $fofile >$OUT $OUT $OUT $OUT $OUT $OUT $OUT $OUT $OUT Testing Fundamentals
 8 |  */
 9 | public class ApplicationTest extends ApplicationTestCase {
10 |     public ApplicationTest() {
11 |         super(Application.class);
12 |     }
13 | }


--------------------------------------------------------------------------------
/ypatchcore/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
 1 | 
 3 | 
 4 |     
 9 | 
10 |     
11 | 
12 | 
13 | 


--------------------------------------------------------------------------------
/ypatchcore/src/main/java/com/chan/ypatchcore/YPatch.java:
--------------------------------------------------------------------------------
 1 | package com.chan.ypatchcore;
 2 | 
 3 | /**
 4 |  * Created by chan on 16/8/18.
 5 |  */
 6 | public class YPatch {
 7 | 
 8 |     static {
 9 |         System.loadLibrary("y-patch-jni");
10 |     }
11 | 
12 |     public static native void patch(String oldFilePath, String newFilePath, String patchFilePatch);
13 | }
14 | 


--------------------------------------------------------------------------------
/ypatchcore/src/main/jni/bzip/bzlib.h:
--------------------------------------------------------------------------------
  1 | 
  2 | /*-------------------------------------------------------------*/
  3 | /*--- Public header file for the library.                   ---*/
  4 | /*---                                               bzlib.h ---*/
  5 | /*-------------------------------------------------------------*/
  6 | 
  7 | /* ------------------------------------------------------------------
  8 |    This file is part of bzip2/libbzip2, a program and library for
  9 |    lossless, block-sorting data compression.
 10 | 
 11 |    bzip2/libbzip2 version 1.0.6 of 6 September 2010
 12 |    Copyright (C) 1996-2010 Julian Seward 
 13 | 
 14 |    Please read the WARNING, DISCLAIMER and PATENTS sections in the 
 15 |    README file.
 16 | 
 17 |    This program is released under the terms of the license contained
 18 |    in the file LICENSE.
 19 |    ------------------------------------------------------------------ */
 20 | 
 21 | 
 22 | #ifndef _BZLIB_H
 23 | #define _BZLIB_H
 24 | 
 25 | #ifdef __cplusplus
 26 | extern "C" {
 27 | #endif
 28 | 
 29 | #define BZ_RUN               0
 30 | #define BZ_FLUSH             1
 31 | #define BZ_FINISH            2
 32 | 
 33 | #define BZ_OK                0
 34 | #define BZ_RUN_OK            1
 35 | #define BZ_FLUSH_OK          2
 36 | #define BZ_FINISH_OK         3
 37 | #define BZ_STREAM_END        4
 38 | #define BZ_SEQUENCE_ERROR    (-1)
 39 | #define BZ_PARAM_ERROR       (-2)
 40 | #define BZ_MEM_ERROR         (-3)
 41 | #define BZ_DATA_ERROR        (-4)
 42 | #define BZ_DATA_ERROR_MAGIC  (-5)
 43 | #define BZ_IO_ERROR          (-6)
 44 | #define BZ_UNEXPECTED_EOF    (-7)
 45 | #define BZ_OUTBUFF_FULL      (-8)
 46 | #define BZ_CONFIG_ERROR      (-9)
 47 | 
 48 | typedef 
 49 |    struct {
 50 |       char *next_in;
 51 |       unsigned int avail_in;
 52 |       unsigned int total_in_lo32;
 53 |       unsigned int total_in_hi32;
 54 | 
 55 |       char *next_out;
 56 |       unsigned int avail_out;
 57 |       unsigned int total_out_lo32;
 58 |       unsigned int total_out_hi32;
 59 | 
 60 |       void *state;
 61 | 
 62 |       void *(*bzalloc)(void *,int,int);
 63 |       void (*bzfree)(void *,void *);
 64 |       void *opaque;
 65 |    } 
 66 |    bz_stream;
 67 | 
 68 | 
 69 | #ifndef BZ_IMPORT
 70 | #define BZ_EXPORT
 71 | #endif
 72 | 
 73 | #ifndef BZ_NO_STDIO
 74 | /* Need a definitition for FILE */
 75 | #include 
 76 | #endif
 77 | 
 78 | #ifdef _WIN32
 79 | #   include 
 80 | #   ifdef small
 81 |       /* windows.h define small to char */
 82 | #      undef small
 83 | #   endif
 84 | #   ifdef BZ_EXPORT
 85 | #   define BZ_API(func) WINAPI func
 86 | #   define BZ_EXTERN extern
 87 | #   else
 88 |    /* import windows dll dynamically */
 89 | #   define BZ_API(func) (WINAPI * func)
 90 | #   define BZ_EXTERN
 91 | #   endif
 92 | #else
 93 | #   define BZ_API(func) func
 94 | #   define BZ_EXTERN extern
 95 | #endif
 96 | 
 97 | #include "bzlib_private.h"
 98 | 
 99 | /*-- Core (low-level) library functions --*/
100 | 
101 | BZ_EXTERN int BZ_API(BZ2_bzCompressInit) ( 
102 |       bz_stream* strm, 
103 |       int        blockSize100k, 
104 |       int        verbosity, 
105 |       int        workFactor 
106 |    );
107 | 
108 | BZ_EXTERN int BZ_API(BZ2_bzCompress) ( 
109 |       bz_stream* strm, 
110 |       int action 
111 |    );
112 | 
113 | BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) ( 
114 |       bz_stream* strm 
115 |    );
116 | 
117 | BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) ( 
118 |       bz_stream *strm, 
119 |       int       verbosity, 
120 |       int       small
121 |    );
122 | 
123 | BZ_EXTERN int BZ_API(BZ2_bzDecompress) ( 
124 |       bz_stream* strm 
125 |    );
126 | 
127 | BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) ( 
128 |       bz_stream *strm 
129 |    );
130 | 
131 | 
132 | 
133 | /*-- High(er) level library functions --*/
134 | 
135 | #ifndef BZ_NO_STDIO
136 | #define BZ_MAX_UNUSED 5000
137 | 
138 | typedef void BZFILE;
139 | 
140 | BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) ( 
141 |       int*  bzerror,   
142 |       FILE* f, 
143 |       int   verbosity, 
144 |       int   small,
145 |       void* unused,    
146 |       int   nUnused 
147 |    );
148 | 
149 | BZ_EXTERN void BZ_API(BZ2_bzReadClose) ( 
150 |       int*    bzerror, 
151 |       BZFILE* b 
152 |    );
153 | 
154 | BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) ( 
155 |       int*    bzerror, 
156 |       BZFILE* b, 
157 |       void**  unused,  
158 |       int*    nUnused 
159 |    );
160 | 
161 | BZ_EXTERN int BZ_API(BZ2_bzRead) ( 
162 |       int*    bzerror, 
163 |       BZFILE* b, 
164 |       void*   buf, 
165 |       int     len 
166 |    );
167 | 
168 | BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) ( 
169 |       int*  bzerror,      
170 |       FILE* f, 
171 |       int   blockSize100k, 
172 |       int   verbosity, 
173 |       int   workFactor 
174 |    );
175 | 
176 | BZ_EXTERN void BZ_API(BZ2_bzWrite) ( 
177 |       int*    bzerror, 
178 |       BZFILE* b, 
179 |       void*   buf, 
180 |       int     len 
181 |    );
182 | 
183 | BZ_EXTERN void BZ_API(BZ2_bzWriteClose) ( 
184 |       int*          bzerror, 
185 |       BZFILE*       b, 
186 |       int           abandon, 
187 |       unsigned int* nbytes_in, 
188 |       unsigned int* nbytes_out 
189 |    );
190 | 
191 | BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) ( 
192 |       int*          bzerror, 
193 |       BZFILE*       b, 
194 |       int           abandon, 
195 |       unsigned int* nbytes_in_lo32, 
196 |       unsigned int* nbytes_in_hi32, 
197 |       unsigned int* nbytes_out_lo32, 
198 |       unsigned int* nbytes_out_hi32
199 |    );
200 | #endif
201 | 
202 | 
203 | /*-- Utility functions --*/
204 | 
205 | BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) ( 
206 |       char*         dest, 
207 |       unsigned int* destLen,
208 |       char*         source, 
209 |       unsigned int  sourceLen,
210 |       int           blockSize100k, 
211 |       int           verbosity, 
212 |       int           workFactor 
213 |    );
214 | 
215 | BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) ( 
216 |       char*         dest, 
217 |       unsigned int* destLen,
218 |       char*         source, 
219 |       unsigned int  sourceLen,
220 |       int           small, 
221 |       int           verbosity 
222 |    );
223 | 
224 | 
225 | /*--
226 |    Code contributed by Yoshioka Tsuneo (tsuneo@rr.iij4u.or.jp)
227 |    to support better zlib compatibility.
228 |    This code is not _officially_ part of libbzip2 (yet);
229 |    I haven't tested it, documented it, or considered the
230 |    threading-safeness of it.
231 |    If this code breaks, please contact both Yoshioka and me.
232 | --*/
233 | 
234 | BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) (
235 |       void
236 |    );
237 | 
238 | #ifndef BZ_NO_STDIO
239 | BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) (
240 |       const char *path,
241 |       const char *mode
242 |    );
243 | 
244 | BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) (
245 |       int        fd,
246 |       const char *mode
247 |    );
248 |          
249 | BZ_EXTERN int BZ_API(BZ2_bzread) (
250 |       BZFILE* b, 
251 |       void* buf, 
252 |       int len 
253 |    );
254 | 
255 | BZ_EXTERN int BZ_API(BZ2_bzwrite) (
256 |       BZFILE* b, 
257 |       void*   buf, 
258 |       int     len 
259 |    );
260 | 
261 | BZ_EXTERN int BZ_API(BZ2_bzflush) (
262 |       BZFILE* b
263 |    );
264 | 
265 | BZ_EXTERN void BZ_API(BZ2_bzclose) (
266 |       BZFILE* b
267 |    );
268 | 
269 | BZ_EXTERN const char * BZ_API(BZ2_bzerror) (
270 |       BZFILE *b, 
271 |       int    *errnum
272 |    );
273 | #endif
274 | 
275 | #ifdef __cplusplus
276 | }
277 | #endif
278 | 
279 | #endif
280 | 
281 | /*-------------------------------------------------------------*/
282 | /*--- end                                           bzlib.h ---*/
283 | /*-------------------------------------------------------------*/
284 | 


--------------------------------------------------------------------------------
/ypatchcore/src/main/jni/bzip/bzlib_private.h:
--------------------------------------------------------------------------------
  1 | 
  2 | /*-------------------------------------------------------------*/
  3 | /*--- Private header file for the library.                  ---*/
  4 | /*---                                       bzlib_private.h ---*/
  5 | /*-------------------------------------------------------------*/
  6 | 
  7 | /* ------------------------------------------------------------------
  8 |    This file is part of bzip2/libbzip2, a program and library for
  9 |    lossless, block-sorting data compression.
 10 | 
 11 |    bzip2/libbzip2 version 1.0.6 of 6 September 2010
 12 |    Copyright (C) 1996-2010 Julian Seward 
 13 | 
 14 |    Please read the WARNING, DISCLAIMER and PATENTS sections in the 
 15 |    README file.
 16 | 
 17 |    This program is released under the terms of the license contained
 18 |    in the file LICENSE.
 19 |    ------------------------------------------------------------------ */
 20 | 
 21 | 
 22 | #ifndef _BZLIB_PRIVATE_H
 23 | #define _BZLIB_PRIVATE_H
 24 | 
 25 | #include 
 26 | 
 27 | #ifndef BZ_NO_STDIO
 28 | #include 
 29 | #include 
 30 | #include 
 31 | #endif
 32 | 
 33 | #include "bzlib.h"
 34 | 
 35 | 
 36 | 
 37 | /*-- General stuff. --*/
 38 | 
 39 | #define BZ_VERSION  "1.0.6, 6-Sept-2010"
 40 | 
 41 | typedef char            Char;
 42 | typedef unsigned char   Bool;
 43 | typedef unsigned char   UChar;
 44 | typedef int             Int32;
 45 | typedef unsigned int    UInt32;
 46 | typedef short           Int16;
 47 | typedef unsigned short  UInt16;
 48 | 
 49 | #define True  ((Bool)1)
 50 | #define False ((Bool)0)
 51 | 
 52 | #ifndef __GNUC__
 53 | #define __inline__  /* */
 54 | #endif 
 55 | 
 56 | #ifndef BZ_NO_STDIO
 57 | 
 58 | extern void BZ2_bz__AssertH__fail ( int errcode );
 59 | #define AssertH(cond,errcode) \
 60 |    { if (!(cond)) BZ2_bz__AssertH__fail ( errcode ); }
 61 | 
 62 | #if BZ_DEBUG
 63 | #define AssertD(cond,msg) \
 64 |    { if (!(cond)) {       \
 65 |       fprintf ( stderr,   \
 66 |         "\n\nlibbzip2(debug build): internal error\n\t%s\n", msg );\
 67 |       exit(1); \
 68 |    }}
 69 | #else
 70 | #define AssertD(cond,msg) /* */
 71 | #endif
 72 | 
 73 | #define VPrintf0(zf) \
 74 |    fprintf(stderr,zf)
 75 | #define VPrintf1(zf,za1) \
 76 |    fprintf(stderr,zf,za1)
 77 | #define VPrintf2(zf,za1,za2) \
 78 |    fprintf(stderr,zf,za1,za2)
 79 | #define VPrintf3(zf,za1,za2,za3) \
 80 |    fprintf(stderr,zf,za1,za2,za3)
 81 | #define VPrintf4(zf,za1,za2,za3,za4) \
 82 |    fprintf(stderr,zf,za1,za2,za3,za4)
 83 | #define VPrintf5(zf,za1,za2,za3,za4,za5) \
 84 |    fprintf(stderr,zf,za1,za2,za3,za4,za5)
 85 | 
 86 | #else
 87 | 
 88 | extern void bz_internal_error ( int errcode );
 89 | #define AssertH(cond,errcode) \
 90 |    { if (!(cond)) bz_internal_error ( errcode ); }
 91 | #define AssertD(cond,msg)                do { } while (0)
 92 | #define VPrintf0(zf)                     do { } while (0)
 93 | #define VPrintf1(zf,za1)                 do { } while (0)
 94 | #define VPrintf2(zf,za1,za2)             do { } while (0)
 95 | #define VPrintf3(zf,za1,za2,za3)         do { } while (0)
 96 | #define VPrintf4(zf,za1,za2,za3,za4)     do { } while (0)
 97 | #define VPrintf5(zf,za1,za2,za3,za4,za5) do { } while (0)
 98 | 
 99 | #endif
100 | 
101 | 
102 | #define BZALLOC(nnn) (strm->bzalloc)(strm->opaque,(nnn),1)
103 | #define BZFREE(ppp)  (strm->bzfree)(strm->opaque,(ppp))
104 | 
105 | 
106 | /*-- Header bytes. --*/
107 | 
108 | #define BZ_HDR_B 0x42   /* 'B' */
109 | #define BZ_HDR_Z 0x5a   /* 'Z' */
110 | #define BZ_HDR_h 0x68   /* 'h' */
111 | #define BZ_HDR_0 0x30   /* '0' */
112 |   
113 | /*-- Constants for the back end. --*/
114 | 
115 | #define BZ_MAX_ALPHA_SIZE 258
116 | #define BZ_MAX_CODE_LEN    23
117 | 
118 | #define BZ_RUNA 0
119 | #define BZ_RUNB 1
120 | 
121 | #define BZ_N_GROUPS 6
122 | #define BZ_G_SIZE   50
123 | #define BZ_N_ITERS  4
124 | 
125 | #define BZ_MAX_SELECTORS (2 + (900000 / BZ_G_SIZE))
126 | 
127 | 
128 | 
129 | /*-- Stuff for randomising repetitive blocks. --*/
130 | 
131 | extern Int32 BZ2_rNums[512];
132 | 
133 | #define BZ_RAND_DECLS                          \
134 |    Int32 rNToGo;                               \
135 |    Int32 rTPos                                 \
136 | 
137 | #define BZ_RAND_INIT_MASK                      \
138 |    s->rNToGo = 0;                              \
139 |    s->rTPos  = 0                               \
140 | 
141 | #define BZ_RAND_MASK ((s->rNToGo == 1) ? 1 : 0)
142 | 
143 | #define BZ_RAND_UPD_MASK                       \
144 |    if (s->rNToGo == 0) {                       \
145 |       s->rNToGo = BZ2_rNums[s->rTPos];         \
146 |       s->rTPos++;                              \
147 |       if (s->rTPos == 512) s->rTPos = 0;       \
148 |    }                                           \
149 |    s->rNToGo--;
150 | 
151 | 
152 | 
153 | /*-- Stuff for doing CRCs. --*/
154 | 
155 | extern UInt32 BZ2_crc32Table[256];
156 | 
157 | #define BZ_INITIALISE_CRC(crcVar)              \
158 | {                                              \
159 |    crcVar = 0xffffffffL;                       \
160 | }
161 | 
162 | #define BZ_FINALISE_CRC(crcVar)                \
163 | {                                              \
164 |    crcVar = ~(crcVar);                         \
165 | }
166 | 
167 | #define BZ_UPDATE_CRC(crcVar,cha)              \
168 | {                                              \
169 |    crcVar = (crcVar << 8) ^                    \
170 |             BZ2_crc32Table[(crcVar >> 24) ^    \
171 |                            ((UChar)cha)];      \
172 | }
173 | 
174 | 
175 | 
176 | /*-- States and modes for compression. --*/
177 | 
178 | #define BZ_M_IDLE      1
179 | #define BZ_M_RUNNING   2
180 | #define BZ_M_FLUSHING  3
181 | #define BZ_M_FINISHING 4
182 | 
183 | #define BZ_S_OUTPUT    1
184 | #define BZ_S_INPUT     2
185 | 
186 | #define BZ_N_RADIX 2
187 | #define BZ_N_QSORT 12
188 | #define BZ_N_SHELL 18
189 | #define BZ_N_OVERSHOOT (BZ_N_RADIX + BZ_N_QSORT + BZ_N_SHELL + 2)
190 | 
191 | 
192 | 
193 | 
194 | /*-- Structure holding all the compression-side stuff. --*/
195 | 
196 | typedef
197 |    struct {
198 |       /* pointer back to the struct bz_stream */
199 |       bz_stream* strm;
200 | 
201 |       /* mode this stream is in, and whether inputting */
202 |       /* or outputting data */
203 |       Int32    mode;
204 |       Int32    state;
205 | 
206 |       /* remembers avail_in when flush/finish requested */
207 |       UInt32   avail_in_expect;
208 | 
209 |       /* for doing the block sorting */
210 |       UInt32*  arr1;
211 |       UInt32*  arr2;
212 |       UInt32*  ftab;
213 |       Int32    origPtr;
214 | 
215 |       /* aliases for arr1 and arr2 */
216 |       UInt32*  ptr;
217 |       UChar*   block;
218 |       UInt16*  mtfv;
219 |       UChar*   zbits;
220 | 
221 |       /* for deciding when to use the fallback sorting algorithm */
222 |       Int32    workFactor;
223 | 
224 |       /* run-length-encoding of the input */
225 |       UInt32   state_in_ch;
226 |       Int32    state_in_len;
227 |       BZ_RAND_DECLS;
228 | 
229 |       /* input and output limits and current posns */
230 |       Int32    nblock;
231 |       Int32    nblockMAX;
232 |       Int32    numZ;
233 |       Int32    state_out_pos;
234 | 
235 |       /* map of bytes used in block */
236 |       Int32    nInUse;
237 |       Bool     inUse[256];
238 |       UChar    unseqToSeq[256];
239 | 
240 |       /* the buffer for bit stream creation */
241 |       UInt32   bsBuff;
242 |       Int32    bsLive;
243 | 
244 |       /* block and combined CRCs */
245 |       UInt32   blockCRC;
246 |       UInt32   combinedCRC;
247 | 
248 |       /* misc administratium */
249 |       Int32    verbosity;
250 |       Int32    blockNo;
251 |       Int32    blockSize100k;
252 | 
253 |       /* stuff for coding the MTF values */
254 |       Int32    nMTF;
255 |       Int32    mtfFreq    [BZ_MAX_ALPHA_SIZE];
256 |       UChar    selector   [BZ_MAX_SELECTORS];
257 |       UChar    selectorMtf[BZ_MAX_SELECTORS];
258 | 
259 |       UChar    len     [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
260 |       Int32    code    [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
261 |       Int32    rfreq   [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
262 |       /* second dimension: only 3 needed; 4 makes index calculations faster */
263 |       UInt32   len_pack[BZ_MAX_ALPHA_SIZE][4];
264 | 
265 |    }
266 |    EState;
267 | 
268 | 
269 | 
270 | /*-- externs for compression. --*/
271 | 
272 | extern void 
273 | BZ2_blockSort ( EState* );
274 | 
275 | extern void 
276 | BZ2_compressBlock ( EState*, Bool );
277 | 
278 | extern void 
279 | BZ2_bsInitWrite ( EState* );
280 | 
281 | extern void 
282 | BZ2_hbAssignCodes ( Int32*, UChar*, Int32, Int32, Int32 );
283 | 
284 | extern void 
285 | BZ2_hbMakeCodeLengths ( UChar*, Int32*, Int32, Int32 );
286 | 
287 | 
288 | 
289 | /*-- states for decompression. --*/
290 | 
291 | #define BZ_X_IDLE        1
292 | #define BZ_X_OUTPUT      2
293 | 
294 | #define BZ_X_MAGIC_1     10
295 | #define BZ_X_MAGIC_2     11
296 | #define BZ_X_MAGIC_3     12
297 | #define BZ_X_MAGIC_4     13
298 | #define BZ_X_BLKHDR_1    14
299 | #define BZ_X_BLKHDR_2    15
300 | #define BZ_X_BLKHDR_3    16
301 | #define BZ_X_BLKHDR_4    17
302 | #define BZ_X_BLKHDR_5    18
303 | #define BZ_X_BLKHDR_6    19
304 | #define BZ_X_BCRC_1      20
305 | #define BZ_X_BCRC_2      21
306 | #define BZ_X_BCRC_3      22
307 | #define BZ_X_BCRC_4      23
308 | #define BZ_X_RANDBIT     24
309 | #define BZ_X_ORIGPTR_1   25
310 | #define BZ_X_ORIGPTR_2   26
311 | #define BZ_X_ORIGPTR_3   27
312 | #define BZ_X_MAPPING_1   28
313 | #define BZ_X_MAPPING_2   29
314 | #define BZ_X_SELECTOR_1  30
315 | #define BZ_X_SELECTOR_2  31
316 | #define BZ_X_SELECTOR_3  32
317 | #define BZ_X_CODING_1    33
318 | #define BZ_X_CODING_2    34
319 | #define BZ_X_CODING_3    35
320 | #define BZ_X_MTF_1       36
321 | #define BZ_X_MTF_2       37
322 | #define BZ_X_MTF_3       38
323 | #define BZ_X_MTF_4       39
324 | #define BZ_X_MTF_5       40
325 | #define BZ_X_MTF_6       41
326 | #define BZ_X_ENDHDR_2    42
327 | #define BZ_X_ENDHDR_3    43
328 | #define BZ_X_ENDHDR_4    44
329 | #define BZ_X_ENDHDR_5    45
330 | #define BZ_X_ENDHDR_6    46
331 | #define BZ_X_CCRC_1      47
332 | #define BZ_X_CCRC_2      48
333 | #define BZ_X_CCRC_3      49
334 | #define BZ_X_CCRC_4      50
335 | 
336 | 
337 | 
338 | /*-- Constants for the fast MTF decoder. --*/
339 | 
340 | #define MTFA_SIZE 4096
341 | #define MTFL_SIZE 16
342 | 
343 | 
344 | 
345 | /*-- Structure holding all the decompression-side stuff. --*/
346 | 
347 | typedef
348 |    struct {
349 |       /* pointer back to the struct bz_stream */
350 |       bz_stream* strm;
351 | 
352 |       /* state indicator for this stream */
353 |       Int32    state;
354 | 
355 |       /* for doing the final run-length decoding */
356 |       UChar    state_out_ch;
357 |       Int32    state_out_len;
358 |       Bool     blockRandomised;
359 |       BZ_RAND_DECLS;
360 | 
361 |       /* the buffer for bit stream reading */
362 |       UInt32   bsBuff;
363 |       Int32    bsLive;
364 | 
365 |       /* misc administratium */
366 |       Int32    blockSize100k;
367 |       Bool     smallDecompress;
368 |       Int32    currBlockNo;
369 |       Int32    verbosity;
370 | 
371 |       /* for undoing the Burrows-Wheeler transform */
372 |       Int32    origPtr;
373 |       UInt32   tPos;
374 |       Int32    k0;
375 |       Int32    unzftab[256];
376 |       Int32    nblock_used;
377 |       Int32    cftab[257];
378 |       Int32    cftabCopy[257];
379 | 
380 |       /* for undoing the Burrows-Wheeler transform (FAST) */
381 |       UInt32   *tt;
382 | 
383 |       /* for undoing the Burrows-Wheeler transform (SMALL) */
384 |       UInt16   *ll16;
385 |       UChar    *ll4;
386 | 
387 |       /* stored and calculated CRCs */
388 |       UInt32   storedBlockCRC;
389 |       UInt32   storedCombinedCRC;
390 |       UInt32   calculatedBlockCRC;
391 |       UInt32   calculatedCombinedCRC;
392 | 
393 |       /* map of bytes used in block */
394 |       Int32    nInUse;
395 |       Bool     inUse[256];
396 |       Bool     inUse16[16];
397 |       UChar    seqToUnseq[256];
398 | 
399 |       /* for decoding the MTF values */
400 |       UChar    mtfa   [MTFA_SIZE];
401 |       Int32    mtfbase[256 / MTFL_SIZE];
402 |       UChar    selector   [BZ_MAX_SELECTORS];
403 |       UChar    selectorMtf[BZ_MAX_SELECTORS];
404 |       UChar    len  [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
405 | 
406 |       Int32    limit  [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
407 |       Int32    base   [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
408 |       Int32    perm   [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
409 |       Int32    minLens[BZ_N_GROUPS];
410 | 
411 |       /* save area for scalars in the main decompress code */
412 |       Int32    save_i;
413 |       Int32    save_j;
414 |       Int32    save_t;
415 |       Int32    save_alphaSize;
416 |       Int32    save_nGroups;
417 |       Int32    save_nSelectors;
418 |       Int32    save_EOB;
419 |       Int32    save_groupNo;
420 |       Int32    save_groupPos;
421 |       Int32    save_nextSym;
422 |       Int32    save_nblockMAX;
423 |       Int32    save_nblock;
424 |       Int32    save_es;
425 |       Int32    save_N;
426 |       Int32    save_curr;
427 |       Int32    save_zt;
428 |       Int32    save_zn; 
429 |       Int32    save_zvec;
430 |       Int32    save_zj;
431 |       Int32    save_gSel;
432 |       Int32    save_gMinlen;
433 |       Int32*   save_gLimit;
434 |       Int32*   save_gBase;
435 |       Int32*   save_gPerm;
436 | 
437 |    }
438 |    DState;
439 | 
440 | 
441 | 
442 | /*-- Macros for decompression. --*/
443 | 
444 | #define BZ_GET_FAST(cccc)                     \
445 |     /* c_tPos is unsigned, hence test < 0 is pointless. */ \
446 |     if (s->tPos >= (UInt32)100000 * (UInt32)s->blockSize100k) return True; \
447 |     s->tPos = s->tt[s->tPos];                 \
448 |     cccc = (UChar)(s->tPos & 0xff);           \
449 |     s->tPos >>= 8;
450 | 
451 | #define BZ_GET_FAST_C(cccc)                   \
452 |     /* c_tPos is unsigned, hence test < 0 is pointless. */ \
453 |     if (c_tPos >= (UInt32)100000 * (UInt32)ro_blockSize100k) return True; \
454 |     c_tPos = c_tt[c_tPos];                    \
455 |     cccc = (UChar)(c_tPos & 0xff);            \
456 |     c_tPos >>= 8;
457 | 
458 | #define SET_LL4(i,n)                                          \
459 |    { if (((i) & 0x1) == 0)                                    \
460 |         s->ll4[(i) >> 1] = (s->ll4[(i) >> 1] & 0xf0) | (n); else    \
461 |         s->ll4[(i) >> 1] = (s->ll4[(i) >> 1] & 0x0f) | ((n) << 4);  \
462 |    }
463 | 
464 | #define GET_LL4(i)                             \
465 |    ((((UInt32)(s->ll4[(i) >> 1])) >> (((i) << 2) & 0x4)) & 0xF)
466 | 
467 | #define SET_LL(i,n)                          \
468 |    { s->ll16[i] = (UInt16)(n & 0x0000ffff);  \
469 |      SET_LL4(i, n >> 16);                    \
470 |    }
471 | 
472 | #define GET_LL(i) \
473 |    (((UInt32)s->ll16[i]) | (GET_LL4(i) << 16))
474 | 
475 | #define BZ_GET_SMALL(cccc)                            \
476 |     /* c_tPos is unsigned, hence test < 0 is pointless. */ \
477 |     if (s->tPos >= (UInt32)100000 * (UInt32)s->blockSize100k) return True; \
478 |     cccc = BZ2_indexIntoF ( s->tPos, s->cftab );    \
479 |     s->tPos = GET_LL(s->tPos);
480 | 
481 | 
482 | /*-- externs for decompression. --*/
483 | 
484 | extern Int32 
485 | BZ2_indexIntoF ( Int32, Int32* );
486 | 
487 | extern Int32 
488 | BZ2_decompress ( DState* );
489 | 
490 | extern void 
491 | BZ2_hbCreateDecodeTables ( Int32*, Int32*, Int32*, UChar*,
492 |                            Int32,  Int32, Int32 );
493 | 
494 | 
495 | #endif
496 | 
497 | 
498 | /*-- BZ_NO_STDIO seems to make NULL disappear on some platforms. --*/
499 | 
500 | #ifdef BZ_NO_STDIO
501 | #ifndef NULL
502 | #define NULL 0
503 | #endif
504 | #endif
505 | 
506 | 
507 | /*-------------------------------------------------------------*/
508 | /*--- end                                   bzlib_private.h ---*/
509 | /*-------------------------------------------------------------*/
510 | 


--------------------------------------------------------------------------------
/ypatchcore/src/main/jni/bzip/crctable.c:
--------------------------------------------------------------------------------
  1 | 
  2 | /*-------------------------------------------------------------*/
  3 | /*--- Table for doing CRCs                                  ---*/
  4 | /*---                                            crctable.c ---*/
  5 | /*-------------------------------------------------------------*/
  6 | 
  7 | /* ------------------------------------------------------------------
  8 |    This file is part of bzip2/libbzip2, a program and library for
  9 |    lossless, block-sorting data compression.
 10 | 
 11 |    bzip2/libbzip2 version 1.0.6 of 6 September 2010
 12 |    Copyright (C) 1996-2010 Julian Seward 
 13 | 
 14 |    Please read the WARNING, DISCLAIMER and PATENTS sections in the 
 15 |    README file.
 16 | 
 17 |    This program is released under the terms of the license contained
 18 |    in the file LICENSE.
 19 |    ------------------------------------------------------------------ */
 20 | 
 21 | 
 22 | #include "bzlib_private.h"
 23 | 
 24 | /*--
 25 |   I think this is an implementation of the AUTODIN-II,
 26 |   Ethernet & FDDI 32-bit CRC standard.  Vaguely derived
 27 |   from code by Rob Warnock, in Section 51 of the
 28 |   comp.compression FAQ.
 29 | --*/
 30 | 
 31 | UInt32 BZ2_crc32Table[256] = {
 32 | 
 33 |    /*-- Ugly, innit? --*/
 34 | 
 35 |    0x00000000L, 0x04c11db7L, 0x09823b6eL, 0x0d4326d9L,
 36 |    0x130476dcL, 0x17c56b6bL, 0x1a864db2L, 0x1e475005L,
 37 |    0x2608edb8L, 0x22c9f00fL, 0x2f8ad6d6L, 0x2b4bcb61L,
 38 |    0x350c9b64L, 0x31cd86d3L, 0x3c8ea00aL, 0x384fbdbdL,
 39 |    0x4c11db70L, 0x48d0c6c7L, 0x4593e01eL, 0x4152fda9L,
 40 |    0x5f15adacL, 0x5bd4b01bL, 0x569796c2L, 0x52568b75L,
 41 |    0x6a1936c8L, 0x6ed82b7fL, 0x639b0da6L, 0x675a1011L,
 42 |    0x791d4014L, 0x7ddc5da3L, 0x709f7b7aL, 0x745e66cdL,
 43 |    0x9823b6e0L, 0x9ce2ab57L, 0x91a18d8eL, 0x95609039L,
 44 |    0x8b27c03cL, 0x8fe6dd8bL, 0x82a5fb52L, 0x8664e6e5L,
 45 |    0xbe2b5b58L, 0xbaea46efL, 0xb7a96036L, 0xb3687d81L,
 46 |    0xad2f2d84L, 0xa9ee3033L, 0xa4ad16eaL, 0xa06c0b5dL,
 47 |    0xd4326d90L, 0xd0f37027L, 0xddb056feL, 0xd9714b49L,
 48 |    0xc7361b4cL, 0xc3f706fbL, 0xceb42022L, 0xca753d95L,
 49 |    0xf23a8028L, 0xf6fb9d9fL, 0xfbb8bb46L, 0xff79a6f1L,
 50 |    0xe13ef6f4L, 0xe5ffeb43L, 0xe8bccd9aL, 0xec7dd02dL,
 51 |    0x34867077L, 0x30476dc0L, 0x3d044b19L, 0x39c556aeL,
 52 |    0x278206abL, 0x23431b1cL, 0x2e003dc5L, 0x2ac12072L,
 53 |    0x128e9dcfL, 0x164f8078L, 0x1b0ca6a1L, 0x1fcdbb16L,
 54 |    0x018aeb13L, 0x054bf6a4L, 0x0808d07dL, 0x0cc9cdcaL,
 55 |    0x7897ab07L, 0x7c56b6b0L, 0x71159069L, 0x75d48ddeL,
 56 |    0x6b93dddbL, 0x6f52c06cL, 0x6211e6b5L, 0x66d0fb02L,
 57 |    0x5e9f46bfL, 0x5a5e5b08L, 0x571d7dd1L, 0x53dc6066L,
 58 |    0x4d9b3063L, 0x495a2dd4L, 0x44190b0dL, 0x40d816baL,
 59 |    0xaca5c697L, 0xa864db20L, 0xa527fdf9L, 0xa1e6e04eL,
 60 |    0xbfa1b04bL, 0xbb60adfcL, 0xb6238b25L, 0xb2e29692L,
 61 |    0x8aad2b2fL, 0x8e6c3698L, 0x832f1041L, 0x87ee0df6L,
 62 |    0x99a95df3L, 0x9d684044L, 0x902b669dL, 0x94ea7b2aL,
 63 |    0xe0b41de7L, 0xe4750050L, 0xe9362689L, 0xedf73b3eL,
 64 |    0xf3b06b3bL, 0xf771768cL, 0xfa325055L, 0xfef34de2L,
 65 |    0xc6bcf05fL, 0xc27dede8L, 0xcf3ecb31L, 0xcbffd686L,
 66 |    0xd5b88683L, 0xd1799b34L, 0xdc3abdedL, 0xd8fba05aL,
 67 |    0x690ce0eeL, 0x6dcdfd59L, 0x608edb80L, 0x644fc637L,
 68 |    0x7a089632L, 0x7ec98b85L, 0x738aad5cL, 0x774bb0ebL,
 69 |    0x4f040d56L, 0x4bc510e1L, 0x46863638L, 0x42472b8fL,
 70 |    0x5c007b8aL, 0x58c1663dL, 0x558240e4L, 0x51435d53L,
 71 |    0x251d3b9eL, 0x21dc2629L, 0x2c9f00f0L, 0x285e1d47L,
 72 |    0x36194d42L, 0x32d850f5L, 0x3f9b762cL, 0x3b5a6b9bL,
 73 |    0x0315d626L, 0x07d4cb91L, 0x0a97ed48L, 0x0e56f0ffL,
 74 |    0x1011a0faL, 0x14d0bd4dL, 0x19939b94L, 0x1d528623L,
 75 |    0xf12f560eL, 0xf5ee4bb9L, 0xf8ad6d60L, 0xfc6c70d7L,
 76 |    0xe22b20d2L, 0xe6ea3d65L, 0xeba91bbcL, 0xef68060bL,
 77 |    0xd727bbb6L, 0xd3e6a601L, 0xdea580d8L, 0xda649d6fL,
 78 |    0xc423cd6aL, 0xc0e2d0ddL, 0xcda1f604L, 0xc960ebb3L,
 79 |    0xbd3e8d7eL, 0xb9ff90c9L, 0xb4bcb610L, 0xb07daba7L,
 80 |    0xae3afba2L, 0xaafbe615L, 0xa7b8c0ccL, 0xa379dd7bL,
 81 |    0x9b3660c6L, 0x9ff77d71L, 0x92b45ba8L, 0x9675461fL,
 82 |    0x8832161aL, 0x8cf30badL, 0x81b02d74L, 0x857130c3L,
 83 |    0x5d8a9099L, 0x594b8d2eL, 0x5408abf7L, 0x50c9b640L,
 84 |    0x4e8ee645L, 0x4a4ffbf2L, 0x470cdd2bL, 0x43cdc09cL,
 85 |    0x7b827d21L, 0x7f436096L, 0x7200464fL, 0x76c15bf8L,
 86 |    0x68860bfdL, 0x6c47164aL, 0x61043093L, 0x65c52d24L,
 87 |    0x119b4be9L, 0x155a565eL, 0x18197087L, 0x1cd86d30L,
 88 |    0x029f3d35L, 0x065e2082L, 0x0b1d065bL, 0x0fdc1becL,
 89 |    0x3793a651L, 0x3352bbe6L, 0x3e119d3fL, 0x3ad08088L,
 90 |    0x2497d08dL, 0x2056cd3aL, 0x2d15ebe3L, 0x29d4f654L,
 91 |    0xc5a92679L, 0xc1683bceL, 0xcc2b1d17L, 0xc8ea00a0L,
 92 |    0xd6ad50a5L, 0xd26c4d12L, 0xdf2f6bcbL, 0xdbee767cL,
 93 |    0xe3a1cbc1L, 0xe760d676L, 0xea23f0afL, 0xeee2ed18L,
 94 |    0xf0a5bd1dL, 0xf464a0aaL, 0xf9278673L, 0xfde69bc4L,
 95 |    0x89b8fd09L, 0x8d79e0beL, 0x803ac667L, 0x84fbdbd0L,
 96 |    0x9abc8bd5L, 0x9e7d9662L, 0x933eb0bbL, 0x97ffad0cL,
 97 |    0xafb010b1L, 0xab710d06L, 0xa6322bdfL, 0xa2f33668L,
 98 |    0xbcb4666dL, 0xb8757bdaL, 0xb5365d03L, 0xb1f740b4L
 99 | };
100 | 
101 | 
102 | /*-------------------------------------------------------------*/
103 | /*--- end                                        crctable.c ---*/
104 | /*-------------------------------------------------------------*/
105 | 


--------------------------------------------------------------------------------
/ypatchcore/src/main/jni/bzip/huffman.c:
--------------------------------------------------------------------------------
  1 | 
  2 | /*-------------------------------------------------------------*/
  3 | /*--- Huffman coding low-level stuff                        ---*/
  4 | /*---                                             huffman.c ---*/
  5 | /*-------------------------------------------------------------*/
  6 | 
  7 | /* ------------------------------------------------------------------
  8 |    This file is part of bzip2/libbzip2, a program and library for
  9 |    lossless, block-sorting data compression.
 10 | 
 11 |    bzip2/libbzip2 version 1.0.6 of 6 September 2010
 12 |    Copyright (C) 1996-2010 Julian Seward 
 13 | 
 14 |    Please read the WARNING, DISCLAIMER and PATENTS sections in the 
 15 |    README file.
 16 | 
 17 |    This program is released under the terms of the license contained
 18 |    in the file LICENSE.
 19 |    ------------------------------------------------------------------ */
 20 | 
 21 | 
 22 | #include "bzlib_private.h"
 23 | 
 24 | /*---------------------------------------------------*/
 25 | #define WEIGHTOF(zz0)  ((zz0) & 0xffffff00)
 26 | #define DEPTHOF(zz1)   ((zz1) & 0x000000ff)
 27 | #define MYMAX(zz2,zz3) ((zz2) > (zz3) ? (zz2) : (zz3))
 28 | 
 29 | #define ADDWEIGHTS(zw1,zw2)                           \
 30 |    (WEIGHTOF(zw1)+WEIGHTOF(zw2)) |                    \
 31 |    (1 + MYMAX(DEPTHOF(zw1),DEPTHOF(zw2)))
 32 | 
 33 | #define UPHEAP(z)                                     \
 34 | {                                                     \
 35 |    Int32 zz, tmp;                                     \
 36 |    zz = z; tmp = heap[zz];                            \
 37 |    while (weight[tmp] < weight[heap[zz >> 1]]) {      \
 38 |       heap[zz] = heap[zz >> 1];                       \
 39 |       zz >>= 1;                                       \
 40 |    }                                                  \
 41 |    heap[zz] = tmp;                                    \
 42 | }
 43 | 
 44 | #define DOWNHEAP(z)                                   \
 45 | {                                                     \
 46 |    Int32 zz, yy, tmp;                                 \
 47 |    zz = z; tmp = heap[zz];                            \
 48 |    while (True) {                                     \
 49 |       yy = zz << 1;                                   \
 50 |       if (yy > nHeap) break;                          \
 51 |       if (yy < nHeap &&                               \
 52 |           weight[heap[yy+1]] < weight[heap[yy]])      \
 53 |          yy++;                                        \
 54 |       if (weight[tmp] < weight[heap[yy]]) break;      \
 55 |       heap[zz] = heap[yy];                            \
 56 |       zz = yy;                                        \
 57 |    }                                                  \
 58 |    heap[zz] = tmp;                                    \
 59 | }
 60 | 
 61 | 
 62 | /*---------------------------------------------------*/
 63 | void BZ2_hbMakeCodeLengths ( UChar *len, 
 64 |                              Int32 *freq,
 65 |                              Int32 alphaSize,
 66 |                              Int32 maxLen )
 67 | {
 68 |    /*--
 69 |       Nodes and heap entries run from 1.  Entry 0
 70 |       for both the heap and nodes is a sentinel.
 71 |    --*/
 72 |    Int32 nNodes, nHeap, n1, n2, i, j, k;
 73 |    Bool  tooLong;
 74 | 
 75 |    Int32 heap   [ BZ_MAX_ALPHA_SIZE + 2 ];
 76 |    Int32 weight [ BZ_MAX_ALPHA_SIZE * 2 ];
 77 |    Int32 parent [ BZ_MAX_ALPHA_SIZE * 2 ]; 
 78 | 
 79 |    for (i = 0; i < alphaSize; i++)
 80 |       weight[i+1] = (freq[i] == 0 ? 1 : freq[i]) << 8;
 81 | 
 82 |    while (True) {
 83 | 
 84 |       nNodes = alphaSize;
 85 |       nHeap = 0;
 86 | 
 87 |       heap[0] = 0;
 88 |       weight[0] = 0;
 89 |       parent[0] = -2;
 90 | 
 91 |       for (i = 1; i <= alphaSize; i++) {
 92 |          parent[i] = -1;
 93 |          nHeap++;
 94 |          heap[nHeap] = i;
 95 |          UPHEAP(nHeap);
 96 |       }
 97 | 
 98 |       AssertH( nHeap < (BZ_MAX_ALPHA_SIZE+2), 2001 );
 99 |    
100 |       while (nHeap > 1) {
101 |          n1 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1);
102 |          n2 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1);
103 |          nNodes++;
104 |          parent[n1] = parent[n2] = nNodes;
105 |          weight[nNodes] = ADDWEIGHTS(weight[n1], weight[n2]);
106 |          parent[nNodes] = -1;
107 |          nHeap++;
108 |          heap[nHeap] = nNodes;
109 |          UPHEAP(nHeap);
110 |       }
111 | 
112 |       AssertH( nNodes < (BZ_MAX_ALPHA_SIZE * 2), 2002 );
113 | 
114 |       tooLong = False;
115 |       for (i = 1; i <= alphaSize; i++) {
116 |          j = 0;
117 |          k = i;
118 |          while (parent[k] >= 0) { k = parent[k]; j++; }
119 |          len[i-1] = j;
120 |          if (j > maxLen) tooLong = True;
121 |       }
122 |       
123 |       if (! tooLong) break;
124 | 
125 |       /* 17 Oct 04: keep-going condition for the following loop used
126 |          to be 'i < alphaSize', which missed the last element,
127 |          theoretically leading to the possibility of the compressor
128 |          looping.  However, this count-scaling step is only needed if
129 |          one of the generated Huffman code words is longer than
130 |          maxLen, which up to and including version 1.0.2 was 20 bits,
131 |          which is extremely unlikely.  In version 1.0.3 maxLen was
132 |          changed to 17 bits, which has minimal effect on compression
133 |          ratio, but does mean this scaling step is used from time to
134 |          time, enough to verify that it works.
135 | 
136 |          This means that bzip2-1.0.3 and later will only produce
137 |          Huffman codes with a maximum length of 17 bits.  However, in
138 |          order to preserve backwards compatibility with bitstreams
139 |          produced by versions pre-1.0.3, the decompressor must still
140 |          handle lengths of up to 20. */
141 | 
142 |       for (i = 1; i <= alphaSize; i++) {
143 |          j = weight[i] >> 8;
144 |          j = 1 + (j / 2);
145 |          weight[i] = j << 8;
146 |       }
147 |    }
148 | }
149 | 
150 | 
151 | /*---------------------------------------------------*/
152 | void BZ2_hbAssignCodes ( Int32 *code,
153 |                          UChar *length,
154 |                          Int32 minLen,
155 |                          Int32 maxLen,
156 |                          Int32 alphaSize )
157 | {
158 |    Int32 n, vec, i;
159 | 
160 |    vec = 0;
161 |    for (n = minLen; n <= maxLen; n++) {
162 |       for (i = 0; i < alphaSize; i++)
163 |          if (length[i] == n) { code[i] = vec; vec++; };
164 |       vec <<= 1;
165 |    }
166 | }
167 | 
168 | 
169 | /*---------------------------------------------------*/
170 | void BZ2_hbCreateDecodeTables ( Int32 *limit,
171 |                                 Int32 *base,
172 |                                 Int32 *perm,
173 |                                 UChar *length,
174 |                                 Int32 minLen,
175 |                                 Int32 maxLen,
176 |                                 Int32 alphaSize )
177 | {
178 |    Int32 pp, i, j, vec;
179 | 
180 |    pp = 0;
181 |    for (i = minLen; i <= maxLen; i++)
182 |       for (j = 0; j < alphaSize; j++)
183 |          if (length[j] == i) { perm[pp] = j; pp++; };
184 | 
185 |    for (i = 0; i < BZ_MAX_CODE_LEN; i++) base[i] = 0;
186 |    for (i = 0; i < alphaSize; i++) base[length[i]+1]++;
187 | 
188 |    for (i = 1; i < BZ_MAX_CODE_LEN; i++) base[i] += base[i-1];
189 | 
190 |    for (i = 0; i < BZ_MAX_CODE_LEN; i++) limit[i] = 0;
191 |    vec = 0;
192 | 
193 |    for (i = minLen; i <= maxLen; i++) {
194 |       vec += (base[i+1] - base[i]);
195 |       limit[i] = vec-1;
196 |       vec <<= 1;
197 |    }
198 |    for (i = minLen + 1; i <= maxLen; i++)
199 |       base[i] = ((limit[i-1] + 1) << 1) - base[i];
200 | }
201 | 
202 | 
203 | /*-------------------------------------------------------------*/
204 | /*--- end                                         huffman.c ---*/
205 | /*-------------------------------------------------------------*/
206 | 


--------------------------------------------------------------------------------
/ypatchcore/src/main/jni/bzip/randtable.c:
--------------------------------------------------------------------------------
 1 | 
 2 | /*-------------------------------------------------------------*/
 3 | /*--- Table for randomising repetitive blocks               ---*/
 4 | /*---                                           randtable.c ---*/
 5 | /*-------------------------------------------------------------*/
 6 | 
 7 | /* ------------------------------------------------------------------
 8 |    This file is part of bzip2/libbzip2, a program and library for
 9 |    lossless, block-sorting data compression.
10 | 
11 |    bzip2/libbzip2 version 1.0.6 of 6 September 2010
12 |    Copyright (C) 1996-2010 Julian Seward 
13 | 
14 |    Please read the WARNING, DISCLAIMER and PATENTS sections in the 
15 |    README file.
16 | 
17 |    This program is released under the terms of the license contained
18 |    in the file LICENSE.
19 |    ------------------------------------------------------------------ */
20 | 
21 | 
22 | #include "bzlib_private.h"
23 | 
24 | 
25 | /*---------------------------------------------*/
26 | Int32 BZ2_rNums[512] = { 
27 |    619, 720, 127, 481, 931, 816, 813, 233, 566, 247, 
28 |    985, 724, 205, 454, 863, 491, 741, 242, 949, 214, 
29 |    733, 859, 335, 708, 621, 574, 73, 654, 730, 472, 
30 |    419, 436, 278, 496, 867, 210, 399, 680, 480, 51, 
31 |    878, 465, 811, 169, 869, 675, 611, 697, 867, 561, 
32 |    862, 687, 507, 283, 482, 129, 807, 591, 733, 623, 
33 |    150, 238, 59, 379, 684, 877, 625, 169, 643, 105, 
34 |    170, 607, 520, 932, 727, 476, 693, 425, 174, 647, 
35 |    73, 122, 335, 530, 442, 853, 695, 249, 445, 515, 
36 |    909, 545, 703, 919, 874, 474, 882, 500, 594, 612, 
37 |    641, 801, 220, 162, 819, 984, 589, 513, 495, 799, 
38 |    161, 604, 958, 533, 221, 400, 386, 867, 600, 782, 
39 |    382, 596, 414, 171, 516, 375, 682, 485, 911, 276, 
40 |    98, 553, 163, 354, 666, 933, 424, 341, 533, 870, 
41 |    227, 730, 475, 186, 263, 647, 537, 686, 600, 224, 
42 |    469, 68, 770, 919, 190, 373, 294, 822, 808, 206, 
43 |    184, 943, 795, 384, 383, 461, 404, 758, 839, 887, 
44 |    715, 67, 618, 276, 204, 918, 873, 777, 604, 560, 
45 |    951, 160, 578, 722, 79, 804, 96, 409, 713, 940, 
46 |    652, 934, 970, 447, 318, 353, 859, 672, 112, 785, 
47 |    645, 863, 803, 350, 139, 93, 354, 99, 820, 908, 
48 |    609, 772, 154, 274, 580, 184, 79, 626, 630, 742, 
49 |    653, 282, 762, 623, 680, 81, 927, 626, 789, 125, 
50 |    411, 521, 938, 300, 821, 78, 343, 175, 128, 250, 
51 |    170, 774, 972, 275, 999, 639, 495, 78, 352, 126, 
52 |    857, 956, 358, 619, 580, 124, 737, 594, 701, 612, 
53 |    669, 112, 134, 694, 363, 992, 809, 743, 168, 974, 
54 |    944, 375, 748, 52, 600, 747, 642, 182, 862, 81, 
55 |    344, 805, 988, 739, 511, 655, 814, 334, 249, 515, 
56 |    897, 955, 664, 981, 649, 113, 974, 459, 893, 228, 
57 |    433, 837, 553, 268, 926, 240, 102, 654, 459, 51, 
58 |    686, 754, 806, 760, 493, 403, 415, 394, 687, 700, 
59 |    946, 670, 656, 610, 738, 392, 760, 799, 887, 653, 
60 |    978, 321, 576, 617, 626, 502, 894, 679, 243, 440, 
61 |    680, 879, 194, 572, 640, 724, 926, 56, 204, 700, 
62 |    707, 151, 457, 449, 797, 195, 791, 558, 945, 679, 
63 |    297, 59, 87, 824, 713, 663, 412, 693, 342, 606, 
64 |    134, 108, 571, 364, 631, 212, 174, 643, 304, 329, 
65 |    343, 97, 430, 751, 497, 314, 983, 374, 822, 928, 
66 |    140, 206, 73, 263, 980, 736, 876, 478, 430, 305, 
67 |    170, 514, 364, 692, 829, 82, 855, 953, 676, 246, 
68 |    369, 970, 294, 750, 807, 827, 150, 790, 288, 923, 
69 |    804, 378, 215, 828, 592, 281, 565, 555, 710, 82, 
70 |    896, 831, 547, 261, 524, 462, 293, 465, 502, 56, 
71 |    661, 821, 976, 991, 658, 869, 905, 758, 745, 193, 
72 |    768, 550, 608, 933, 378, 286, 215, 979, 792, 961, 
73 |    61, 688, 793, 644, 986, 403, 106, 366, 905, 644, 
74 |    372, 567, 466, 434, 645, 210, 389, 550, 919, 135, 
75 |    780, 773, 635, 389, 707, 100, 626, 958, 165, 504, 
76 |    920, 176, 193, 713, 857, 265, 203, 50, 668, 108, 
77 |    645, 990, 626, 197, 510, 357, 358, 850, 858, 364, 
78 |    936, 638
79 | };
80 | 
81 | 
82 | /*-------------------------------------------------------------*/
83 | /*--- end                                       randtable.c ---*/
84 | /*-------------------------------------------------------------*/
85 | 


--------------------------------------------------------------------------------
/ypatchcore/src/main/jni/com_chan_ypatchcore_YPatch.cpp:
--------------------------------------------------------------------------------
 1 | //
 2 | // Created by chan on 16/8/18.
 3 | //
 4 | #include 
 5 | #include 
 6 | #include 
 7 | #include "com_chan_ypatchcore_YPatch.h"
 8 | #include "patch/bspatch.h"
 9 | 
10 | char* jstringTostring(JNIEnv* env, jstring jstr)
11 | {
12 |     char* rtn = NULL;
13 |     jclass clsstring = env->FindClass("java/lang/String");
14 |     jstring strencode = env->NewStringUTF("utf-8");
15 |     jmethodID mid = env->GetMethodID(clsstring, "getBytes", "(Ljava/lang/String;)[B");
16 |     jbyteArray barr= (jbyteArray)env->CallObjectMethod(jstr, mid, strencode);
17 |     jsize alen = env->GetArrayLength(barr);
18 |     jbyte* ba = env->GetByteArrayElements(barr, JNI_FALSE);
19 |     if (alen > 0)
20 |     {
21 |         rtn = (char*)malloc(alen + 1);
22 | 
23 |         memcpy(rtn, ba, alen);
24 |         rtn[alen] = 0;
25 |     }
26 |     env->ReleaseByteArrayElements(barr, ba, 0);
27 |     return rtn;
28 | }
29 | 
30 | JNIEXPORT void JNICALL Java_com_chan_ypatchcore_YPatch_patch
31 |         (JNIEnv * env, jclass clazz, jstring oldFile, jstring newFile, jstring patchFile) {
32 | 
33 |     char* old_file = jstringTostring(env, oldFile);
34 |     char* new_file = jstringTostring(env, newFile);
35 |     char* patch_file = jstringTostring(env, patchFile);
36 | 
37 |     run_patch(old_file, new_file, patch_file);
38 | 
39 |     free(old_file);
40 |     free(new_file);
41 |     free(patch_file);
42 | }


--------------------------------------------------------------------------------
/ypatchcore/src/main/jni/com_chan_ypatchcore_YPatch.h:
--------------------------------------------------------------------------------
 1 | /* DO NOT EDIT THIS FILE - it is machine generated */
 2 | #include 
 3 | /* Header for class com_chan_ypatchcore_YPatch */
 4 | 
 5 | #ifndef _Included_com_chan_ypatchcore_YPatch
 6 | #define _Included_com_chan_ypatchcore_YPatch
 7 | #ifdef __cplusplus
 8 | extern "C" {
 9 | #endif
10 | /*
11 |  * Class:     com_chan_ypatchcore_YPatch
12 |  * Method:    patch
13 |  * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
14 |  */
15 | JNIEXPORT void JNICALL Java_com_chan_ypatchcore_YPatch_patch
16 |   (JNIEnv *, jclass, jstring, jstring, jstring);
17 | 
18 | #ifdef __cplusplus
19 | }
20 | #endif
21 | #endif
22 | 


--------------------------------------------------------------------------------
/ypatchcore/src/main/jni/patch/bspatch.c:
--------------------------------------------------------------------------------
  1 | /*-
  2 |  * Copyright 2003-2005 Colin Percival
  3 |  * All rights reserved
  4 |  *
  5 |  * Redistribution and use in source and binary forms, with or without
  6 |  * modification, are permitted providing that the following conditions 
  7 |  * are met:
  8 |  * 1. Redistributions of source code must retain the above copyright
  9 |  *    notice, this list of conditions and the following disclaimer.
 10 |  * 2. Redistributions in binary form must reproduce the above copyright
 11 |  *    notice, this list of conditions and the following disclaimer in the
 12 |  *    documentation and/or other materials provided with the distribution.
 13 |  *
 14 |  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 15 |  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 16 |  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 17 |  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
 18 |  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 19 |  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 20 |  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 21 |  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 22 |  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
 23 |  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 24 |  * POSSIBILITY OF SUCH DAMAGE.
 25 |  */
 26 | 
 27 | #if 0
 28 | __FBSDID("$FreeBSD: src/usr.bin/bsdiff/bspatch/bspatch.c,v 1.1 2005/08/06 01:59:06 cperciva Exp $");
 29 | #endif
 30 | 
 31 | #include "../bzip/bzlib.h"
 32 | #include 
 33 | #include 
 34 | #include 
 35 | #include "bspatch.h"
 36 | 
 37 | typedef unsigned char u_char;
 38 | 
 39 | static off_t offtin(u_char *buf)
 40 | {
 41 | 	off_t y;
 42 | 
 43 | 	y=buf[7]&0x7F;
 44 | 	y=y*256;y+=buf[6];
 45 | 	y=y*256;y+=buf[5];
 46 | 	y=y*256;y+=buf[4];
 47 | 	y=y*256;y+=buf[3];
 48 | 	y=y*256;y+=buf[2];
 49 | 	y=y*256;y+=buf[1];
 50 | 	y=y*256;y+=buf[0];
 51 | 
 52 | 	if(buf[7]&0x80) y=-y;
 53 | 
 54 | 	return y;
 55 | }
 56 | 
 57 | int main_patch(int argc, const char * argv[])
 58 | {
 59 | 	FILE * f, * cpf, * dpf, * epf;
 60 | 	BZFILE * cpfbz2, * dpfbz2, * epfbz2;
 61 | 	int cbz2err, dbz2err, ebz2err;
 62 | 	int fd;
 63 | 	ssize_t oldsize,newsize;
 64 | 	ssize_t bzctrllen,bzdatalen;
 65 | 	u_char header[32],buf[8];
 66 | 	u_char *old, *new;
 67 | 	off_t oldpos,newpos;
 68 | 	off_t ctrl[3];
 69 | 	off_t lenread;
 70 | 	off_t i;
 71 | 
 72 | 	if(argc!=4) errx(1,"usage: %s oldfile newfile patchfile\n",argv[0]);
 73 | 
 74 | 	/* Open patch file */
 75 | 	if ((f = fopen(argv[3], "r")) == NULL)
 76 | 		err(1, "fopen(%s)", argv[3]);
 77 | 
 78 | 	/*
 79 | 	File format:
 80 | 		0	8	"BSDIFF40"
 81 | 		8	8	X
 82 | 		16	8	Y
 83 | 		24	8	sizeof(newfile)
 84 | 		32	X	bzip2(control block)
 85 | 		32+X	Y	bzip2(diff block)
 86 | 		32+X+Y	???	bzip2(extra block)
 87 | 	with control block a set of triples (x,y,z) meaning "add x bytes
 88 | 	from oldfile to x bytes from the diff block; copy y bytes from the
 89 | 	extra block; seek forwards in oldfile by z bytes".
 90 | 	*/
 91 | 
 92 | 	/* Read header */
 93 | 	if (fread(header, 1, 32, f) < 32) {
 94 | 		if (feof(f))
 95 | 			errx(1, "Corrupt patch\n");
 96 | 		err(1, "fread(%s)", argv[3]);
 97 | 	}
 98 | 
 99 | 	/* Check for appropriate magic */
100 | 	if (memcmp(header, "BSDIFF40", 8) != 0)
101 | 		errx(1, "Corrupt patch\n");
102 | 
103 | 	/* Read lengths from header */
104 | 	bzctrllen=offtin(header+8);
105 | 	bzdatalen=offtin(header+16);
106 | 	newsize=offtin(header+24);
107 | 	if((bzctrllen<0) || (bzdatalen<0) || (newsize<0))
108 | 		errx(1,"Corrupt patch\n");
109 | 
110 | 	/* Close patch file and re-open it via libbzip2 at the right places */
111 | 	if (fclose(f))
112 | 		err(1, "fclose(%s)", argv[3]);
113 | 	if ((cpf = fopen(argv[3], "r")) == NULL)
114 | 		err(1, "fopen(%s)", argv[3]);
115 | 	if (fseeko(cpf, 32, SEEK_SET))
116 | 		err(1, "fseeko(%s, %lld)", argv[3],
117 | 		    (long long)32);
118 | 	if ((cpfbz2 = BZ2_bzReadOpen(&cbz2err, cpf, 0, 0, NULL, 0)) == NULL)
119 | 		errx(1, "BZ2_bzReadOpen, bz2err = %d", cbz2err);
120 | 	if ((dpf = fopen(argv[3], "r")) == NULL)
121 | 		err(1, "fopen(%s)", argv[3]);
122 | 	if (fseeko(dpf, 32 + bzctrllen, SEEK_SET))
123 | 		err(1, "fseeko(%s, %lld)", argv[3],
124 | 		    (long long)(32 + bzctrllen));
125 | 	if ((dpfbz2 = BZ2_bzReadOpen(&dbz2err, dpf, 0, 0, NULL, 0)) == NULL)
126 | 		errx(1, "BZ2_bzReadOpen, bz2err = %d", dbz2err);
127 | 	if ((epf = fopen(argv[3], "r")) == NULL)
128 | 		err(1, "fopen(%s)", argv[3]);
129 | 	if (fseeko(epf, 32 + bzctrllen + bzdatalen, SEEK_SET))
130 | 		err(1, "fseeko(%s, %lld)", argv[3],
131 | 		    (long long)(32 + bzctrllen + bzdatalen));
132 | 	if ((epfbz2 = BZ2_bzReadOpen(&ebz2err, epf, 0, 0, NULL, 0)) == NULL)
133 | 		errx(1, "BZ2_bzReadOpen, bz2err = %d", ebz2err);
134 | 
135 | 	if(((fd=open(argv[1],O_RDONLY,0))<0) ||
136 | 		((oldsize=lseek(fd,0,SEEK_END))==-1) ||
137 | 		((old=malloc(oldsize+1))==NULL) ||
138 | 		(lseek(fd,0,SEEK_SET)!=0) ||
139 | 		(read(fd,old,oldsize)!=oldsize) ||
140 | 		(close(fd)==-1)) err(1,"%s",argv[1]);
141 | 	if((new=malloc(newsize+1))==NULL) err(1,NULL);
142 | 
143 | 	oldpos=0;newpos=0;
144 | 	while(newposnewsize)
156 | 			errx(1,"Corrupt patch\n");
157 | 
158 | 		/* Read diff string */
159 | 		lenread = BZ2_bzRead(&dbz2err, dpfbz2, new + newpos, ctrl[0]);
160 | 		if ((lenread < ctrl[0]) ||
161 | 		    ((dbz2err != BZ_OK) && (dbz2err != BZ_STREAM_END)))
162 | 			errx(1, "Corrupt patch\n");
163 | 
164 | 		/* Add old data to diff string */
165 | 		for(i=0;i=0) && (oldpos+inewsize)
175 | 			errx(1,"Corrupt patch\n");
176 | 
177 | 		/* Read extra string */
178 | 		lenread = BZ2_bzRead(&ebz2err, epfbz2, new + newpos, ctrl[1]);
179 | 		if ((lenread < ctrl[1]) ||
180 | 		    ((ebz2err != BZ_OK) && (ebz2err != BZ_STREAM_END)))
181 | 			errx(1, "Corrupt patch\n");
182 | 
183 | 		/* Adjust pointers */
184 | 		newpos+=ctrl[1];
185 | 		oldpos+=ctrl[2];
186 | 	};
187 | 
188 | 	/* Clean up the bzip2 reads */
189 | 	BZ2_bzReadClose(&cbz2err, cpfbz2);
190 | 	BZ2_bzReadClose(&dbz2err, dpfbz2);
191 | 	BZ2_bzReadClose(&ebz2err, epfbz2);
192 | 	if (fclose(cpf) || fclose(dpf) || fclose(epf))
193 | 		err(1, "fclose(%s)", argv[3]);
194 | 
195 | 	/* Write the new file */
196 | 	if(((fd=open(argv[2],O_CREAT|O_TRUNC|O_WRONLY,0666))<0) ||
197 | 		(write(fd,new,newsize)!=newsize) || (close(fd)==-1))
198 | 		err(1,"%s",argv[2]);
199 | 
200 | 	free(new);
201 | 	free(old);
202 | 
203 | 	return 0;
204 | }
205 | 
206 | void run_patch(const char* old_file, const char* new_file, const char* patch_file) {
207 | 	const int argc = 4;
208 | 
209 | 	const char* args[argc];
210 | 
211 | 	args[1] = old_file;
212 | 	args[2] = new_file;
213 | 	args[3] = patch_file;
214 | 
215 | 	main_patch(argc, args);
216 | }


--------------------------------------------------------------------------------
/ypatchcore/src/main/jni/patch/bspatch.h:
--------------------------------------------------------------------------------
 1 | //
 2 | // Created by chan on 16/8/18.
 3 | //
 4 | 
 5 | #ifndef YPATCH_BSPATCH_H
 6 | #define YPATCH_BSPATCH_H
 7 | 
 8 | #ifdef __cplusplus
 9 | extern "C" {
10 | #endif
11 | 
12 | void run_patch(const char* old_file, const char* new_file, const char* patch_file);
13 | 
14 | #ifdef __cplusplus
15 | }
16 | #endif
17 | 
18 | #endif //YPATCH_BSPATCH_H
19 | 


--------------------------------------------------------------------------------
/ypatchcore/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 | 
2 |     YPatchCore
3 | 
4 | 


--------------------------------------------------------------------------------
/ypatchcore/src/test/java/com/chan/ypatchcore/ExampleUnitTest.java:
--------------------------------------------------------------------------------
 1 | package com.chan.ypatchcore;
 2 | 
 3 | import org.junit.Test;
 4 | 
 5 | import static org.junit.Assert.*;
 6 | 
 7 | /**
 8 |  * To work on unit tests, switch the Test Artifact in the Build Variants view.
 9 |  */
10 | public class ExampleUnitTest {
11 |     @Test
12 |     public void addition_isCorrect() throws Exception {
13 |         assertEquals(4, 2 + 2);
14 |     }
15 | }


--------------------------------------------------------------------------------