Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix up line endings, add libxpwn.c that was necessary, made Makefile …

…generate DOS readmes for Windows, fixed up some includes
  • Loading branch information...
commit 6bf5301c167cebdb88557a8028804c07dde081f9 1 parent d42404a
@planetbeing authored
Showing with 10,787 additions and 10,786 deletions.
  1. +3 −2 Makefile
  2. +28 −28 hdutil/Makefile
  3. +290 −290 hdutil/hdutil.c
  4. +9 −9 hdutil/win32test.c
  5. +5 −5 ide/eclipse/Makefile
  6. +47 −47 ipsw-patch/8900.h
  7. +40 −40 ipsw-patch/Makefile
  8. +215 −215 ipsw-patch/bspatch.c
  9. +59 −59 ipsw-patch/bzip2-1.0.5/Makefile-libbz2_so
  10. +210 −210 ipsw-patch/bzip2-1.0.5/README
  11. +58 −58 ipsw-patch/bzip2-1.0.5/README.COMPILATION.PROBLEMS
  12. +45 −45 ipsw-patch/bzip2-1.0.5/README.XML.STUFF
  13. +1,094 −1,094 ipsw-patch/bzip2-1.0.5/blocksort.c
  14. +514 −514 ipsw-patch/bzip2-1.0.5/bzip2recover.c
  15. +1,572 −1,572 ipsw-patch/bzip2-1.0.5/bzlib.c
  16. +282 −282 ipsw-patch/bzip2-1.0.5/bzlib.h
  17. +509 −509 ipsw-patch/bzip2-1.0.5/bzlib_private.h
  18. +672 −672 ipsw-patch/bzip2-1.0.5/compress.c
  19. +104 −104 ipsw-patch/bzip2-1.0.5/crctable.c
  20. +626 −626 ipsw-patch/bzip2-1.0.5/decompress.c
  21. +175 −175 ipsw-patch/bzip2-1.0.5/dlltest.c
  22. +205 −205 ipsw-patch/bzip2-1.0.5/huffman.c
  23. +31 −31 ipsw-patch/bzip2-1.0.5/mk251.c
  24. +84 −84 ipsw-patch/bzip2-1.0.5/randtable.c
  25. +54 −54 ipsw-patch/bzip2-1.0.5/spewG.c
  26. +141 −141 ipsw-patch/bzip2-1.0.5/unzcrash.c
  27. +313 −313 ipsw-patch/ibootim.c
  28. +34 −34 ipsw-patch/img2.h
  29. +28 −28 ipsw-patch/libpng-1.2.28/projects/cbuilder5/libpng.cpp
  30. +344 −344 ipsw-patch/lzss.c
  31. +5 −5 ipsw-patch/lzss.h
  32. +162 −162 ipsw-patch/lzssfile.c
  33. +27 −27 ipsw-patch/lzssfile.h
  34. +59 −59 ipsw-patch/nor_files.c
  35. +7 −7 ipsw-patch/nor_files.h
  36. +7 −7 ipsw-patch/outputstate.h
  37. +494 −494 ipsw-patch/patch.c
  38. +489 −489 ipsw-patch/plist.c
  39. +51 −51 ipsw-patch/plist.h
  40. +9 −9 ipsw-patch/win32test.c
  41. +1 −1  xpwn/Makefile
  42. +263 −263 xpwn/libusb-win32/Makefile
  43. +165 −165 xpwn/libusb-win32/src/driver/driver_api.h
  44. +1,248 −1,248 xpwn/libusb-win32/src/windows.c
  45. +9 −9 xpwn/win32test.c
View
5 Makefile
@@ -37,8 +37,8 @@ install-win: ipsw-patch/pch xpwn/xpwn
cp xpwn/ramdisk.dmg xpwn-build/ramdisk.dmg
cp -R ipsw-patch/FirmwareBundles xpwn-build/FirmwareBundles
cp -R ipsw-patch/bundles xpwn-build/bundles
- cp README.markdown xpwn-build/README.txt
- cp LICENSE xpwn-build/LICENSE.txt
+ sed "`echo s/$$/\\\r`/" README.markdown > xpwn-build/README.txt
+ sed "`echo s/$$/\\\r`/" LICENSE > xpwn-build/LICENSE.txt
cd xpwn-build; zip -r ../xpwn-windows.zip *
clean:
@@ -73,3 +73,4 @@ dist-clean: clean
-rm dmg/zlib-1.2.3/contrib/minizip/*.o
-rm ipsw-patch/bzip2-1.0.5/*.exe
-rm -rf xpwn-build
+
View
56 hdutil/Makefile
@@ -1,29 +1,29 @@
-UTILOBJS=hdutil.o
-DMGOBJS=../dmg/base64.o ../dmg/resources.o ../dmg/checksum.o ../dmg/udif.o ../dmg/partition.o ../dmg/io.o ../dmg/filevault.o ../dmg/dmgfile.o ../dmg/zlib-1.2.3/libz.a ../dmg/openssl-0.9.8g/libcrypto.a
-HFSOBJS=../hfs/volume.o ../hfs/btree.o ../hfs/extents.o ../hfs/rawfile.o ../hfs/catalog.o ../hfs/flatfile.o ../hfs/utility.o ../hfs/fastunicodecompare.o ../hfs/abstractfile.o ../hfs/hfslib.o
-CFLAGS=-D_FILE_OFFSET_BITS=64 -DHAVE_CRYPT
-LIBRARIES=`if $(CC) win32test.c -o /dev/null 2>/dev/null ; then echo ""; else echo "-lgdi32"; fi`
-
-all: util
-
-util: $(DMGOBJS) $(HFSOBJS) $(UTILOBJS)
- $(CC) $(CFLAGS) $(DMGOBJS) $(HFSOBJS) $(UTILOBJS) $(LIBRARIES) -o hdutil
-
-%.o: %.c
- $(CC) $(CFLAGS) -I../dmg/zlib-1.2.3 -I../dmg/openssl-0.9.8g/include -c $< -o $@
-
-../dmg/zlib-1.2.3/Makefile:
- cd ../dmg/zlib-1.2.3; ./configure
-
-../dmg/zlib-1.2.3/libz.a: ../dmg/zlib-1.2.3/Makefile
- cd ../dmg/zlib-1.2.3; make
-
+UTILOBJS=hdutil.o
+DMGOBJS=../dmg/base64.o ../dmg/resources.o ../dmg/checksum.o ../dmg/udif.o ../dmg/partition.o ../dmg/io.o ../dmg/filevault.o ../dmg/dmgfile.o ../dmg/zlib-1.2.3/libz.a ../dmg/openssl-0.9.8g/libcrypto.a
+HFSOBJS=../hfs/volume.o ../hfs/btree.o ../hfs/extents.o ../hfs/rawfile.o ../hfs/catalog.o ../hfs/flatfile.o ../hfs/utility.o ../hfs/fastunicodecompare.o ../hfs/abstractfile.o ../hfs/hfslib.o
+CFLAGS=-D_FILE_OFFSET_BITS=64 -DHAVE_CRYPT
+LIBRARIES=`if $(CC) win32test.c -o /dev/null 2>/dev/null ; then echo ""; else echo "-lgdi32"; fi`
+
+all: util
+
+util: $(DMGOBJS) $(HFSOBJS) $(UTILOBJS)
+ $(CC) $(CFLAGS) $(DMGOBJS) $(HFSOBJS) $(UTILOBJS) $(LIBRARIES) -o hdutil
+
+%.o: %.c
+ $(CC) $(CFLAGS) -I../dmg/zlib-1.2.3 -I../dmg/openssl-0.9.8g/include -c $< -o $@
+
+../dmg/zlib-1.2.3/Makefile:
+ cd ../dmg/zlib-1.2.3; ./configure
+
+../dmg/zlib-1.2.3/libz.a: ../dmg/zlib-1.2.3/Makefile
+ cd ../dmg/zlib-1.2.3; make
+
../dmg/openssl-0.9.8g/libcrypto.a:
- touch ../dmg/openssl-0.9.8g/Makefile
- cd ../dmg/openssl-0.9.8g/crypto; make
-
-
-clean:
- -rm *.o
- -rm hdutil
- -rm hdutil.exe
+ touch ../dmg/openssl-0.9.8g/Makefile
+ cd ../dmg/openssl-0.9.8g/crypto; make
+
+
+clean:
+ -rm *.o
+ -rm hdutil
+ -rm hdutil.exe
View
580 hdutil/hdutil.c
@@ -1,308 +1,308 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <time.h>
-#include <string.h>
-#include <unistd.h>
-#include "../hfs/hfsplus.h"
-#include "../dmg/dmgfile.h"
-#include "../dmg/filevault.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <dirent.h>
-
-char endianness;
-
-void cmd_ls(Volume* volume, int argc, const char *argv[]) {
- HFSPlusCatalogRecord* record;
- char* name;
-
- if(argc > 1)
- hfs_ls(volume, argv[1]);
- else
- hfs_ls(volume, "/");
-}
-
-void cmd_cat(Volume* volume, int argc, const char *argv[]) {
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <time.h>
+#include <string.h>
+#include <unistd.h>
+#include "../hfs/hfsplus.h"
+#include "../dmg/dmgfile.h"
+#include "../dmg/filevault.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <dirent.h>
+
+char endianness;
+
+void cmd_ls(Volume* volume, int argc, const char *argv[]) {
+ HFSPlusCatalogRecord* record;
+ char* name;
+
+ if(argc > 1)
+ hfs_ls(volume, argv[1]);
+ else
+ hfs_ls(volume, "/");
+}
+
+void cmd_cat(Volume* volume, int argc, const char *argv[]) {
HFSPlusCatalogRecord* record;
- AbstractFile* stdoutFile;
-
+ AbstractFile* stdoutFile;
+
record = getRecordFromPath(argv[1], volume, NULL, NULL);
- stdoutFile = createAbstractFileFromFile(stdout);
-
- if(record != NULL) {
- if(record->recordType == kHFSPlusFileRecord)
- writeToFile((HFSPlusCatalogFile*)record, stdoutFile, volume);
- else
- printf("Not a file\n");
- } else {
- printf("No such file or directory\n");
- }
+ stdoutFile = createAbstractFileFromFile(stdout);
+
+ if(record != NULL) {
+ if(record->recordType == kHFSPlusFileRecord)
+ writeToFile((HFSPlusCatalogFile*)record, stdoutFile, volume);
+ else
+ printf("Not a file\n");
+ } else {
+ printf("No such file or directory\n");
+ }
+
+ free(record);
+ free(stdoutFile);
+}
+
+void cmd_extract(Volume* volume, int argc, const char *argv[]) {
+ HFSPlusCatalogRecord* record;
+ AbstractFile *outFile;
+
+ if(argc < 3) {
+ printf("Not enough arguments");
+ return;
+ }
+
+ outFile = createAbstractFileFromFile(fopen(argv[2], "wb"));
+
+ if(outFile == NULL) {
+ printf("cannot create file");
+ }
+
+ record = getRecordFromPath(argv[1], volume, NULL, NULL);
+
+ if(record != NULL) {
+ if(record->recordType == kHFSPlusFileRecord)
+ writeToFile((HFSPlusCatalogFile*)record, outFile, volume);
+ else
+ printf("Not a file\n");
+ } else {
+ printf("No such file or directory\n");
+ }
+
outFile->close(outFile);
- free(record);
- free(stdoutFile);
-}
-
-void cmd_extract(Volume* volume, int argc, const char *argv[]) {
- HFSPlusCatalogRecord* record;
- AbstractFile *outFile;
-
- if(argc < 3) {
- printf("Not enough arguments");
- return;
- }
-
- outFile = createAbstractFileFromFile(fopen(argv[2], "wb"));
-
- if(outFile == NULL) {
- printf("cannot create file");
- }
-
- record = getRecordFromPath(argv[1], volume, NULL, NULL);
-
- if(record != NULL) {
- if(record->recordType == kHFSPlusFileRecord)
- writeToFile((HFSPlusCatalogFile*)record, outFile, volume);
- else
- printf("Not a file\n");
- } else {
- printf("No such file or directory\n");
- }
-
- outFile->close(outFile);
- free(record);
-}
-
-void cmd_mv(Volume* volume, int argc, const char *argv[]) {
- if(argc > 2) {
- move(argv[1], argv[2], volume);
- } else {
- printf("Not enough arguments");
free(record);
}
-
-void cmd_symlink(Volume* volume, int argc, const char *argv[]) {
- if(argc > 2) {
- makeSymlink(argv[1], argv[2], volume);
- } else {
- printf("Not enough arguments");
- }
-}
-
-void cmd_mkdir(Volume* volume, int argc, const char *argv[]) {
- if(argc > 1) {
- newFolder(argv[1], volume);
- } else {
- printf("Not enough arguments");
- }
-}
-
-void cmd_add(Volume* volume, int argc, const char *argv[]) {
- AbstractFile *inFile;
-
- if(argc < 3) {
- printf("Not enough arguments");
- return;
- }
-
- inFile = createAbstractFileFromFile(fopen(argv[1], "rb"));
-
- if(inFile == NULL) {
+
+void cmd_mv(Volume* volume, int argc, const char *argv[]) {
+ if(argc > 2) {
+ move(argv[1], argv[2], volume);
+ } else {
+ printf("Not enough arguments");
+ }
+}
+
+void cmd_symlink(Volume* volume, int argc, const char *argv[]) {
+ if(argc > 2) {
+ makeSymlink(argv[1], argv[2], volume);
+ } else {
+ printf("Not enough arguments");
+ }
+}
+
+void cmd_mkdir(Volume* volume, int argc, const char *argv[]) {
+ if(argc > 1) {
+ newFolder(argv[1], volume);
+ } else {
+ printf("Not enough arguments");
+ }
+}
+
+void cmd_add(Volume* volume, int argc, const char *argv[]) {
+ AbstractFile *inFile;
+
+ if(argc < 3) {
+ printf("Not enough arguments");
+ return;
+ }
+
+ inFile = createAbstractFileFromFile(fopen(argv[1], "rb"));
+
+ if(inFile == NULL) {
printf("file to add not found");
}
-
- add_hfs(volume, inFile, argv[2]);
-}
-
-void cmd_rm(Volume* volume, int argc, const char *argv[]) {
- if(argc > 1) {
- removeFile(argv[1], volume);
- } else {
- printf("Not enough arguments");
- }
-}
-
-void cmd_chmod(Volume* volume, int argc, const char *argv[]) {
- int mode;
-
- if(argc > 2) {
- sscanf(argv[1], "%o", &mode);
- chmodFile(argv[2], mode, volume);
- } else {
- printf("Not enough arguments");
- }
-}
-
-void cmd_extractall(Volume* volume, int argc, const char *argv[]) {
- HFSPlusCatalogRecord* record;
- char cwd[1024];
- char* name;
-
- ASSERT(getcwd(cwd, 1024) != NULL, "cannot get current working directory");
-
- if(argc > 1)
- record = getRecordFromPath(argv[1], volume, &name, NULL);
- else
- record = getRecordFromPath("/", volume, &name, NULL);
-
- if(argc > 2) {
- ASSERT(chdir(argv[2]) == 0, "chdir");
- }
-
- if(record != NULL) {
- if(record->recordType == kHFSPlusFolderRecord)
- extractAllInFolder(((HFSPlusCatalogFolder*)record)->folderID, volume);
- else
- printf("Not a folder\n");
- } else {
- printf("No such file or directory\n");
- }
- free(record);
-
- ASSERT(chdir(cwd) == 0, "chdir");
-}
-
-
-void cmd_rmall(Volume* volume, int argc, const char *argv[]) {
- HFSPlusCatalogRecord* record;
- char* name;
- char initPath[1024];
- int lastCharOfPath;
-
- if(argc > 1) {
- record = getRecordFromPath(argv[1], volume, &name, NULL);
- strcpy(initPath, argv[1]);
- lastCharOfPath = strlen(argv[1]) - 1;
- if(argv[1][lastCharOfPath] != '/') {
- initPath[lastCharOfPath + 1] = '/';
- initPath[lastCharOfPath + 2] = '\0';
- }
- } else {
- record = getRecordFromPath("/", volume, &name, NULL);
- initPath[0] = '/';
- initPath[1] = '\0';
- }
-
- if(record != NULL) {
- if(record->recordType == kHFSPlusFolderRecord) {
- removeAllInFolder(((HFSPlusCatalogFolder*)record)->folderID, volume, initPath);
- } else {
- printf("Not a folder\n");
- }
- } else {
- printf("No such file or directory\n");
- }
- free(record);
-}
-
-void cmd_addall(Volume* volume, int argc, const char *argv[]) {
- if(argc < 2) {
- printf("Not enough arguments");
+
+ add_hfs(volume, inFile, argv[2]);
+}
+
+void cmd_rm(Volume* volume, int argc, const char *argv[]) {
+ if(argc > 1) {
+ removeFile(argv[1], volume);
+ } else {
printf("Not enough arguments");
+ }
}
-
- if(argc > 2) {
- addall_hfs(volume, argv[1], argv[2]);
- } else {
- addall_hfs(volume, argv[1], "/");
- }
-}
-
-void cmd_grow(Volume* volume, int argc, const char *argv[]) {
- uint64_t newSize;
-
- if(argc < 2) {
- printf("Not enough arguments\n");
- return;
- }
-
+
+void cmd_chmod(Volume* volume, int argc, const char *argv[]) {
+ int mode;
+
+ if(argc > 2) {
+ sscanf(argv[1], "%o", &mode);
+ chmodFile(argv[2], mode, volume);
+ } else {
+ printf("Not enough arguments");
+ }
+}
+
+void cmd_extractall(Volume* volume, int argc, const char *argv[]) {
+ HFSPlusCatalogRecord* record;
+ char cwd[1024];
+ char* name;
+
+ ASSERT(getcwd(cwd, 1024) != NULL, "cannot get current working directory");
+
+ if(argc > 1)
+ record = getRecordFromPath(argv[1], volume, &name, NULL);
+ else
+ record = getRecordFromPath("/", volume, &name, NULL);
+
+ if(argc > 2) {
+ ASSERT(chdir(argv[2]) == 0, "chdir");
+ }
+
+ if(record != NULL) {
+ if(record->recordType == kHFSPlusFolderRecord)
+ extractAllInFolder(((HFSPlusCatalogFolder*)record)->folderID, volume);
+ else
+ printf("Not a folder\n");
+ } else {
+ printf("No such file or directory\n");
+ }
+ free(record);
+
+ ASSERT(chdir(cwd) == 0, "chdir");
+}
+
+
+void cmd_rmall(Volume* volume, int argc, const char *argv[]) {
+ HFSPlusCatalogRecord* record;
+ char* name;
+ char initPath[1024];
+ int lastCharOfPath;
+
+ if(argc > 1) {
+ record = getRecordFromPath(argv[1], volume, &name, NULL);
+ strcpy(initPath, argv[1]);
+ lastCharOfPath = strlen(argv[1]) - 1;
+ if(argv[1][lastCharOfPath] != '/') {
+ initPath[lastCharOfPath + 1] = '/';
+ initPath[lastCharOfPath + 2] = '\0';
+ }
+ } else {
+ record = getRecordFromPath("/", volume, &name, NULL);
+ initPath[0] = '/';
+ initPath[1] = '\0';
+ }
+
+ if(record != NULL) {
+ if(record->recordType == kHFSPlusFolderRecord) {
+ removeAllInFolder(((HFSPlusCatalogFolder*)record)->folderID, volume, initPath);
+ } else {
+ printf("Not a folder\n");
+ }
+ } else {
+ printf("No such file or directory\n");
+ }
+ free(record);
+}
+
+void cmd_addall(Volume* volume, int argc, const char *argv[]) {
+ if(argc < 2) {
+ printf("Not enough arguments");
+ return;
+ }
+
+ if(argc > 2) {
+ addall_hfs(volume, argv[1], argv[2]);
+ } else {
+ addall_hfs(volume, argv[1], "/");
+ }
+}
+
+void cmd_grow(Volume* volume, int argc, const char *argv[]) {
+ uint64_t newSize;
+
+ if(argc < 2) {
+ printf("Not enough arguments\n");
+ return;
+ }
+
newSize = 0;
sscanf(argv[1], "%lld", &newSize);
grow_hfs(volume, newSize);
-
+
printf("grew volume: %lld\n", newSize);
}
-
-void TestByteOrder()
-{
- short int word = 0x0001;
- char *byte = (char *) &word;
+
+void TestByteOrder()
+{
+ short int word = 0x0001;
+ char *byte = (char *) &word;
endianness = byte[0] ? IS_LITTLE_ENDIAN : IS_BIG_ENDIAN;
-}
-
-int main(int argc, const char *argv[]) {
- io_func* io;
- Volume* volume;
- AbstractFile* image;
- int argOff;
-
- TestByteOrder();
-
- if(argc < 3) {
- printf("usage: %s <image-file> (-k <key>) <ls|cat|mv|mkdir|add|rm|chmod|extract|extractall|rmall|addall> <arguments>\n", argv[0]);
- return 0;
- }
-
- argOff = 2;
-
- if(strstr(argv[1], ".dmg")) {
- image = createAbstractFileFromFile(fopen(argv[1], "rb"));
- if(argc > 3) {
- if(strcmp(argv[2], "-k") == 0) {
- image = createAbstractFileFromFileVault(image, argv[3]);
- argOff = 4;
- }
- }
- io = openDmgFilePartition(image, -1);
- } else {
- io = openFlatFile(argv[1]);
- }
-
- if(io == NULL) {
- fprintf(stderr, "error: Cannot open image-file.\n");
- return 1;
- }
-
- volume = openVolume(io);
- if(volume == NULL) {
- fprintf(stderr, "error: Cannot open volume.\n");
- CLOSE(io);
- return 1;
- }
-
- if(argc > argOff) {
- if(strcmp(argv[argOff], "ls") == 0) {
- cmd_ls(volume, argc - argOff, argv + argOff);
- } else if(strcmp(argv[argOff], "cat") == 0) {
- cmd_cat(volume, argc - argOff, argv + argOff);
+}
+
+int main(int argc, const char *argv[]) {
+ io_func* io;
+ Volume* volume;
+ AbstractFile* image;
+ int argOff;
+
+ TestByteOrder();
+
+ if(argc < 3) {
+ printf("usage: %s <image-file> (-k <key>) <ls|cat|mv|mkdir|add|rm|chmod|extract|extractall|rmall|addall> <arguments>\n", argv[0]);
+ return 0;
+ }
+
+ argOff = 2;
+
+ if(strstr(argv[1], ".dmg")) {
+ image = createAbstractFileFromFile(fopen(argv[1], "rb"));
+ if(argc > 3) {
+ if(strcmp(argv[2], "-k") == 0) {
+ image = createAbstractFileFromFileVault(image, argv[3]);
+ argOff = 4;
+ }
+ }
+ io = openDmgFilePartition(image, -1);
+ } else {
+ io = openFlatFile(argv[1]);
+ }
+
+ if(io == NULL) {
+ fprintf(stderr, "error: Cannot open image-file.\n");
+ return 1;
+ }
+
+ volume = openVolume(io);
+ if(volume == NULL) {
+ fprintf(stderr, "error: Cannot open volume.\n");
+ CLOSE(io);
+ return 1;
+ }
+
+ if(argc > argOff) {
+ if(strcmp(argv[argOff], "ls") == 0) {
+ cmd_ls(volume, argc - argOff, argv + argOff);
+ } else if(strcmp(argv[argOff], "cat") == 0) {
+ cmd_cat(volume, argc - argOff, argv + argOff);
} else if(strcmp(argv[argOff], "mv") == 0) {
- cmd_mv(volume, argc - argOff, argv + argOff);
- } else if(strcmp(argv[2], "symlink") == 0) {
- cmd_symlink(volume, argc - 2, argv + 2);
- } else if(strcmp(argv[argOff], "mkdir") == 0) {
- cmd_mkdir(volume, argc - argOff, argv + argOff);
- } else if(strcmp(argv[argOff], "add") == 0) {
- cmd_add(volume, argc - argOff, argv + argOff);
- } else if(strcmp(argv[argOff], "rm") == 0) {
- cmd_rm(volume, argc - argOff, argv + argOff);
- } else if(strcmp(argv[argOff], "chmod") == 0) {
- cmd_chmod(volume, argc - argOff, argv + argOff);
- } else if(strcmp(argv[argOff], "extract") == 0) {
- cmd_extract(volume, argc - argOff, argv + argOff);
- } else if(strcmp(argv[argOff], "extractall") == 0) {
- cmd_extractall(volume, argc - argOff, argv + argOff);
- } else if(strcmp(argv[argOff], "rmall") == 0) {
- cmd_rmall(volume, argc - argOff, argv + argOff);
- } else if(strcmp(argv[argOff], "addall") == 0) {
- cmd_addall(volume, argc - argOff, argv + argOff);
- } else if(strcmp(argv[argOff], "grow") == 0) {
- cmd_grow(volume, argc - argOff, argv + argOff);
- }
- }
-
- closeVolume(volume);
- CLOSE(io);
-
- return 0;
+ cmd_mv(volume, argc - argOff, argv + argOff);
+ } else if(strcmp(argv[2], "symlink") == 0) {
+ cmd_symlink(volume, argc - 2, argv + 2);
+ } else if(strcmp(argv[argOff], "mkdir") == 0) {
+ cmd_mkdir(volume, argc - argOff, argv + argOff);
+ } else if(strcmp(argv[argOff], "add") == 0) {
+ cmd_add(volume, argc - argOff, argv + argOff);
+ } else if(strcmp(argv[argOff], "rm") == 0) {
+ cmd_rm(volume, argc - argOff, argv + argOff);
+ } else if(strcmp(argv[argOff], "chmod") == 0) {
+ cmd_chmod(volume, argc - argOff, argv + argOff);
+ } else if(strcmp(argv[argOff], "extract") == 0) {
+ cmd_extract(volume, argc - argOff, argv + argOff);
+ } else if(strcmp(argv[argOff], "extractall") == 0) {
+ cmd_extractall(volume, argc - argOff, argv + argOff);
+ } else if(strcmp(argv[argOff], "rmall") == 0) {
+ cmd_rmall(volume, argc - argOff, argv + argOff);
+ } else if(strcmp(argv[argOff], "addall") == 0) {
+ cmd_addall(volume, argc - argOff, argv + argOff);
+ } else if(strcmp(argv[argOff], "grow") == 0) {
+ cmd_grow(volume, argc - argOff, argv + argOff);
+ }
+ }
+
+ closeVolume(volume);
+ CLOSE(io);
+
+ return 0;
View
18 hdutil/win32test.c
@@ -1,9 +1,9 @@
-#include <stdlib.h>
-
-#ifdef WIN32
-blahfs-o_f-0-(){ {}A
-#else
-int main(int argc, char* argv[]) {
- return 0;
-}
-#endif
+#include <stdlib.h>
+
+#ifdef WIN32
+blahfs-o_f-0-(){ {}A
+#else
+int main(int argc, char* argv[]) {
+ return 0;
+}
+#endif
View
10 ide/eclipse/Makefile
@@ -1,5 +1,5 @@
-all:
- cd ../../; make
-
-clean:
- cd ../../; make clean
+all:
+ cd ../../; make
+
+clean:
+ cd ../../; make clean
View
94 ipsw-patch/8900.h
@@ -1,47 +1,47 @@
-#include <stdint.h>
-#include <openssl/aes.h>
-#include "abstractfile.h"
-
-#ifndef INC_8900_H
-#define INC_8900_H
-
-typedef struct {
- uint32_t magic; /* string "8900" */
- unsigned char version[3]; /* string "1.0" */
- uint8_t format; /* plaintext format is 0x4, encrypted format is 0x3 */
- uint32_t unknown1;
- uint32_t sizeOfData; /* size of data (ie, filesize - header(0x800) - footer signature(0x80) - footer certificate(0xC0A)) */
- uint32_t footerSignatureOffset; /* offset to footer signature */
- uint32_t footerCertOffset; /* offset to footer certificate, from end of header (0x800) */
- uint32_t footerCertLen;
- unsigned char salt[0x20]; /* a seemingly random salt (an awfully big one though... needs more attention) */
- uint16_t unknown2;
- uint16_t epoch; /* the security epoch of the file */
- unsigned char headerSignature[0x10]; /* encrypt(sha1(header[0:0x40])[0:0x10], key_0x837, zero_iv) */
- unsigned char padding[0x7B0];
-} __attribute__((__packed__)) Apple8900Header;
-
-#define SIGNATURE_8900 0x38393030
-
-static uint8_t key_0x837[] = {0x18, 0x84, 0x58, 0xA6, 0xD1, 0x50, 0x34, 0xDF, 0xE3, 0x86, 0xF2, 0x3B, 0x61, 0xD4, 0x37, 0x74};
-
-typedef struct Info8900 {
- AbstractFile* file;
-
- Apple8900Header header;
- size_t offset;
- void* buffer;
-
- unsigned char footerSignature[0x80];
- unsigned char* footerCertificate;
-
- AES_KEY encryptKey;
- AES_KEY decryptKey;
-
- char dirty;
-} Info8900;
-
-AbstractFile* createAbstractFileFrom8900(AbstractFile* file);
-AbstractFile* duplicate8900File(AbstractFile* file, AbstractFile* backing);
-
-#endif
+#include <stdint.h>
+#include <openssl/aes.h>
+#include "abstractfile.h"
+
+#ifndef INC_8900_H
+#define INC_8900_H
+
+typedef struct {
+ uint32_t magic; /* string "8900" */
+ unsigned char version[3]; /* string "1.0" */
+ uint8_t format; /* plaintext format is 0x4, encrypted format is 0x3 */
+ uint32_t unknown1;
+ uint32_t sizeOfData; /* size of data (ie, filesize - header(0x800) - footer signature(0x80) - footer certificate(0xC0A)) */
+ uint32_t footerSignatureOffset; /* offset to footer signature */
+ uint32_t footerCertOffset; /* offset to footer certificate, from end of header (0x800) */
+ uint32_t footerCertLen;
+ unsigned char salt[0x20]; /* a seemingly random salt (an awfully big one though... needs more attention) */
+ uint16_t unknown2;
+ uint16_t epoch; /* the security epoch of the file */
+ unsigned char headerSignature[0x10]; /* encrypt(sha1(header[0:0x40])[0:0x10], key_0x837, zero_iv) */
+ unsigned char padding[0x7B0];
+} __attribute__((__packed__)) Apple8900Header;
+
+#define SIGNATURE_8900 0x38393030
+
+static uint8_t key_0x837[] = {0x18, 0x84, 0x58, 0xA6, 0xD1, 0x50, 0x34, 0xDF, 0xE3, 0x86, 0xF2, 0x3B, 0x61, 0xD4, 0x37, 0x74};
+
+typedef struct Info8900 {
+ AbstractFile* file;
+
+ Apple8900Header header;
+ size_t offset;
+ void* buffer;
+
+ unsigned char footerSignature[0x80];
+ unsigned char* footerCertificate;
+
+ AES_KEY encryptKey;
+ AES_KEY decryptKey;
+
+ char dirty;
+} Info8900;
+
+AbstractFile* createAbstractFileFrom8900(AbstractFile* file);
+AbstractFile* duplicate8900File(AbstractFile* file, AbstractFile* backing);
+
+#endif
View
80 ipsw-patch/Makefile
@@ -1,44 +1,44 @@
-RANLIB ?= ranlib
-PCHOBJS=patch.o
-XPWNOBJS=plist.o pwnutil.o outputstate.o nor_files.o 8900.o img2.o bspatch.o ibootim.o lzss.o lzssfile.o ../dmg/zlib-1.2.3/contrib/minizip/ioapi.o ../dmg/zlib-1.2.3/contrib/minizip/unzip.o ../dmg/zlib-1.2.3/contrib/minizip/zip.o
-DMGOBJS=../dmg/base64.o ../dmg/resources.o ../dmg/checksum.o ../dmg/udif.o ../dmg/partition.o ../dmg/io.o ../dmg/filevault.o ../dmg/dmgfile.o ../dmg/dmglib.o
-HFSOBJS=../hfs/volume.o ../hfs/btree.o ../hfs/extents.o ../hfs/rawfile.o ../hfs/catalog.o ../hfs/flatfile.o ../hfs/utility.o ../hfs/fastunicodecompare.o ../hfs/abstractfile.o ../hfs/hfslib.o
+RANLIB ?= ranlib
+PCHOBJS=patch.o
+XPWNOBJS=plist.o pwnutil.o outputstate.o nor_files.o 8900.o img2.o bspatch.o ibootim.o lzss.o lzssfile.o ../dmg/zlib-1.2.3/contrib/minizip/ioapi.o ../dmg/zlib-1.2.3/contrib/minizip/unzip.o ../dmg/zlib-1.2.3/contrib/minizip/zip.o
+DMGOBJS=../dmg/base64.o ../dmg/resources.o ../dmg/checksum.o ../dmg/udif.o ../dmg/partition.o ../dmg/io.o ../dmg/filevault.o ../dmg/dmgfile.o ../dmg/dmglib.o
+HFSOBJS=../hfs/volume.o ../hfs/btree.o ../hfs/extents.o ../hfs/rawfile.o ../hfs/catalog.o ../hfs/flatfile.o ../hfs/utility.o ../hfs/fastunicodecompare.o ../hfs/abstractfile.o ../hfs/hfslib.o
CFLAGS=-D_FILE_OFFSET_BITS=64 -DHAVE_CRYPT -O3
-STATIC_LIBRARIES=../dmg/zlib-1.2.3/libz.a ../dmg/openssl-0.9.8g/libcrypto.a ../dmg/openssl-0.9.8g/libcrypto.a bzip2-1.0.5/libbz2.a libpng-1.2.28/libpng.a
-LIBRARIES=`if $(CC) win32test.c -o /dev/null 2>/dev/null ; then echo ""; else echo "-lgdi32"; fi` -lm
+STATIC_LIBRARIES=../dmg/zlib-1.2.3/libz.a ../dmg/openssl-0.9.8g/libcrypto.a ../dmg/openssl-0.9.8g/libcrypto.a bzip2-1.0.5/libbz2.a libpng-1.2.28/libpng.a
+LIBRARIES=`if $(CC) win32test.c -o /dev/null 2>/dev/null ; then echo ""; else echo "-lgdi32"; fi` -lm
INCLUDES=-I../hfs -I../dmg -Ilibpng-1.2.28 -I../dmg/zlib-1.2.3 -I../dmg/openssl-0.9.8g/include -Ibzip2-1.0.5
-
-all: pch
-
-pch: $(DMGOBJS) $(HFSOBJS) $(XPWNOBJS) $(PCHOBJS) $(STATIC_LIBRARIES)
- $(CC) $(CFLAGS) $(DMGOBJS) $(HFSOBJS) $(XPWNOBJS) $(PCHOBJS) $(STATIC_LIBRARIES) $(LIBRARIES) -o pch
-
-libxpwn.a: libxpwn.o $(DMGOBJS) $(HFSOBJS) $(XPWNOBJS) $(STATIC_LIBRARIES)
+
+all: pch
+
+pch: $(DMGOBJS) $(HFSOBJS) $(XPWNOBJS) $(PCHOBJS) $(STATIC_LIBRARIES)
+ $(CC) $(CFLAGS) $(DMGOBJS) $(HFSOBJS) $(XPWNOBJS) $(PCHOBJS) $(STATIC_LIBRARIES) $(LIBRARIES) -o pch
+
+libxpwn.a: libxpwn.o $(DMGOBJS) $(HFSOBJS) $(XPWNOBJS) $(STATIC_LIBRARIES)
$(LD) libxpwn.o $(DMGOBJS) $(HFSOBJS) $(XPWNOBJS) $(STATIC_LIBRARIES) -r -o libxpwnbuild.o
ar rc libxpwn.a libxpwnbuild.o
- ranlib libxpwn.a
-
-%.o: %.c
- $(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
-
-../dmg/zlib-1.2.3/Makefile:
- cd ../dmg/zlib-1.2.3; ./configure
-
-../dmg/zlib-1.2.3/libz.a: ../dmg/zlib-1.2.3/Makefile
- cd ../dmg/zlib-1.2.3; make
-
-../dmg/openssl-0.9.8g/libcrypto.a:
- touch ../dmg/openssl-0.9.8g/Makefile
- cd ../dmg/openssl-0.9.8g/crypto; make
-
-bzip2-1.0.5/libbz2.a:
- cd bzip2-1.0.5; make
-
-libpng-1.2.28/libpng.a:
- cd libpng-1.2.28; make
-
-clean:
- -rm *.o
- -rm pch
- -rm pch.exe
- -rm libxpwn.a
+ ranlib libxpwn.a
+
+%.o: %.c
+ $(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
+
+../dmg/zlib-1.2.3/Makefile:
+ cd ../dmg/zlib-1.2.3; ./configure
+
+../dmg/zlib-1.2.3/libz.a: ../dmg/zlib-1.2.3/Makefile
+ cd ../dmg/zlib-1.2.3; make
+
+../dmg/openssl-0.9.8g/libcrypto.a:
+ touch ../dmg/openssl-0.9.8g/Makefile
+ cd ../dmg/openssl-0.9.8g/crypto; make
+
+bzip2-1.0.5/libbz2.a:
+ cd bzip2-1.0.5; make
+
+libpng-1.2.28/libpng.a:
+ cd libpng-1.2.28; make
+
+clean:
+ -rm *.o
+ -rm pch
+ -rm pch.exe
+ -rm libxpwn.a
View
430 ipsw-patch/bspatch.c
@@ -1,218 +1,218 @@
-#include <stdlib.h>
+#include <stdlib.h>
#include <stdio.h>
-#include <string.h>
-#include <bzlib.h>
-#include "abstractfile.h"
-
-static off_t offtin(unsigned char *buf)
-{
- off_t y;
-
- y = buf[7] & 0x7F;
- y <<= 8; y += buf[6];
- y <<= 8; y += buf[5];
- y <<= 8; y += buf[4];
- y <<= 8; y += buf[3];
- y <<= 8; y += buf[2];
- y <<= 8; y += buf[1];
- y <<= 8; y += buf[0];
-
- if(buf[7] & 0x80) y = -y;
-
- return y;
-}
-
-typedef struct {
- bz_stream bz2;
- AbstractFile* file;
- off_t offset;
- unsigned char* inBuffer;
- unsigned char* outBuffer;
- size_t bufferLen;
- char ended;
-} BZStream;
-
-size_t bzRead(int *bzerr, BZStream* stream, unsigned char* out, size_t len) {
- size_t toRead;
- size_t haveRead;
- size_t total;
-
- total = len;
-
- *bzerr = BZ_OK;
-
- while(total > 0) {
- if(!stream->ended) {
- memmove(stream->inBuffer, stream->bz2.next_in, stream->bz2.avail_in);
- stream->file->seek(stream->file, stream->offset);
- haveRead = stream->file->read(stream->file, stream->inBuffer + stream->bz2.avail_in, stream->bufferLen - stream->bz2.avail_in);
- stream->offset += haveRead;
- stream->bz2.avail_in += haveRead;
- stream->bz2.next_in = stream->inBuffer;
-
- *bzerr = BZ2_bzDecompress(&(stream->bz2));
-
- if(*bzerr == BZ_STREAM_END) {
- stream->ended = TRUE;
- } else {
- if(*bzerr != BZ_OK) {
- return 0;
- }
- }
- }
-
- if(total > (stream->bufferLen - stream->bz2.avail_out)) {
- toRead = stream->bufferLen - stream->bz2.avail_out;
- } else {
- toRead = total;
- }
-
- memcpy(out, stream->outBuffer, toRead);
- memmove(stream->outBuffer, stream->outBuffer + toRead, stream->bufferLen - toRead);
- stream->bz2.next_out -= toRead;
- stream->bz2.avail_out += toRead;
- out += toRead;
- total -= toRead;
-
- if(total > 0 && stream->ended) {
- return (len - total);
- }
- }
-
- return len;
-}
-
-void closeBZStream(BZStream* stream) {
- free(stream->inBuffer);
- free(stream->outBuffer);
- BZ2_bzDecompressEnd(&(stream->bz2));
- free(stream);
-}
-
-BZStream* openBZStream(AbstractFile* file, off_t offset, size_t bufferLen) {
- BZStream* stream;
- stream = (BZStream*) malloc(sizeof(BZStream));
- stream->file = file;
- stream->offset = offset;
- stream->bufferLen = bufferLen;
- stream->inBuffer = (unsigned char*) malloc(bufferLen);
- stream->outBuffer = (unsigned char*) malloc(bufferLen);
- memset(&(stream->bz2), 0, sizeof(bz_stream));
- BZ2_bzDecompressInit(&(stream->bz2), 0, FALSE);
-
- stream->bz2.next_in = stream->inBuffer;
- stream->bz2.avail_in = 0;
- stream->bz2.next_out = stream->outBuffer;
- stream->bz2.avail_out = bufferLen;
-
- stream->ended = FALSE;
- return stream;
-}
-
-int patch(AbstractFile* in, AbstractFile* out, AbstractFile* patch) {
- unsigned char header[32], buf[8];
- off_t oldsize, newsize;
- off_t bzctrllen, bzdatalen;
- off_t oldpos, newpos;
- unsigned char *old, *newBuffer;
- int i;
- int cbz2err, dbz2err, ebz2err;
- off_t ctrl[3];
- size_t lenread;
-
- BZStream* cpfbz2;
- BZStream* dpfbz2;
- BZStream* epfbz2;
-
- /* Read header */
- if (patch->read(patch, header, 32) < 32) {
- return -1;
- }
-
- /* Check for appropriate magic */
- if (memcmp(header, "BSDIFF40", 8) != 0)
- return -2;
-
- /* Read lengths from header */
- bzctrllen = offtin(header + 8);
- bzdatalen = offtin(header + 16);
- newsize = offtin(header + 24);
-
- if((bzctrllen < 0) || (bzdatalen < 0) || (newsize < 0))
- return -3;
-
- cpfbz2 = openBZStream(patch, 32, 1024);
- dpfbz2 = openBZStream(patch, 32 + bzctrllen, 1024);
- epfbz2 = openBZStream(patch, 32 + bzctrllen + bzdatalen, 1024);
-
- oldsize = in->getLength(in);
- old = malloc(oldsize + 1);
- in->seek(in, 0);
- in->read(in, old, oldsize);
- in->close(in);
-
- newBuffer = malloc(newsize + 1);
-
- oldpos = 0;
- newpos = 0;
- while(newpos < newsize) {
- /* Read control data */
- for(i=0;i<=2;i++) {
- lenread = bzRead(&cbz2err, cpfbz2, buf, 8);
- if ((lenread < 8) || ((cbz2err != BZ_OK) &&
- (cbz2err != BZ_STREAM_END)))
- return -4;
- ctrl[i] = offtin(buf);
- };
-
- /* Sanity-check */
- if((newpos + ctrl[0]) > newsize)
- return -5;
-
- /* Read diff string */
- memset(newBuffer + newpos, 0, ctrl[0]);
- lenread = bzRead(&dbz2err, dpfbz2, newBuffer + newpos, ctrl[0]);
- if ((lenread < ctrl[0]) ||
- ((dbz2err != BZ_OK) && (dbz2err != BZ_STREAM_END)))
- return -6;
-
- /* Add old data to diff string */
- for(i = 0; i < ctrl[0]; i++) {
- if(((oldpos + i)>=0) && ((oldpos + i)<oldsize)) {
- newBuffer[newpos + i] += old[oldpos + i];
- }
- }
-
- /* Adjust pointers */
- newpos += ctrl[0];
- oldpos += ctrl[0];
-
- /* Sanity-check */
- if((newpos + ctrl[1]) > newsize)
- return -7;
-
- /* Read extra string */
- lenread = bzRead(&ebz2err, epfbz2, newBuffer + newpos, ctrl[1]);
- if ((lenread < ctrl[1]) ||
- ((ebz2err != BZ_OK) && (ebz2err != BZ_STREAM_END)))
- return -8;
-
- /* Adjust pointers */
- newpos += ctrl[1];
- oldpos += ctrl[2];
- };
-
- closeBZStream(cpfbz2);
- closeBZStream(dpfbz2);
- closeBZStream(epfbz2);
- out->seek(out, 0);
-
- if(out->write(out, newBuffer, newsize) != newsize)
- return -9;
- out->close(out);
- free(newBuffer);
+#include <string.h>
+#include <bzlib.h>
+#include "abstractfile.h"
+
+static off_t offtin(unsigned char *buf)
+{
+ off_t y;
+
+ y = buf[7] & 0x7F;
+ y <<= 8; y += buf[6];
+ y <<= 8; y += buf[5];
+ y <<= 8; y += buf[4];
+ y <<= 8; y += buf[3];
+ y <<= 8; y += buf[2];
+ y <<= 8; y += buf[1];
+ y <<= 8; y += buf[0];
+
+ if(buf[7] & 0x80) y = -y;
+
+ return y;
+}
+
+typedef struct {
+ bz_stream bz2;
+ AbstractFile* file;
+ off_t offset;
+ unsigned char* inBuffer;
+ unsigned char* outBuffer;
+ size_t bufferLen;
+ char ended;
+} BZStream;
+
+size_t bzRead(int *bzerr, BZStream* stream, unsigned char* out, size_t len) {
+ size_t toRead;
+ size_t haveRead;
+ size_t total;
+
+ total = len;
+
+ *bzerr = BZ_OK;
+
+ while(total > 0) {
+ if(!stream->ended) {
+ memmove(stream->inBuffer, stream->bz2.next_in, stream->bz2.avail_in);
+ stream->file->seek(stream->file, stream->offset);
+ haveRead = stream->file->read(stream->file, stream->inBuffer + stream->bz2.avail_in, stream->bufferLen - stream->bz2.avail_in);
+ stream->offset += haveRead;
+ stream->bz2.avail_in += haveRead;
+ stream->bz2.next_in = stream->inBuffer;
+
+ *bzerr = BZ2_bzDecompress(&(stream->bz2));
+
+ if(*bzerr == BZ_STREAM_END) {
+ stream->ended = TRUE;
+ } else {
+ if(*bzerr != BZ_OK) {
+ return 0;
+ }
+ }
+ }
+
+ if(total > (stream->bufferLen - stream->bz2.avail_out)) {
+ toRead = stream->bufferLen - stream->bz2.avail_out;
+ } else {
+ toRead = total;
+ }
+
+ memcpy(out, stream->outBuffer, toRead);
+ memmove(stream->outBuffer, stream->outBuffer + toRead, stream->bufferLen - toRead);
+ stream->bz2.next_out -= toRead;
+ stream->bz2.avail_out += toRead;
+ out += toRead;
+ total -= toRead;
+
+ if(total > 0 && stream->ended) {
+ return (len - total);
+ }
+ }
+
+ return len;
+}
+
+void closeBZStream(BZStream* stream) {
+ free(stream->inBuffer);
+ free(stream->outBuffer);
+ BZ2_bzDecompressEnd(&(stream->bz2));
+ free(stream);
+}
+
+BZStream* openBZStream(AbstractFile* file, off_t offset, size_t bufferLen) {
+ BZStream* stream;
+ stream = (BZStream*) malloc(sizeof(BZStream));
+ stream->file = file;
+ stream->offset = offset;
+ stream->bufferLen = bufferLen;
+ stream->inBuffer = (unsigned char*) malloc(bufferLen);
+ stream->outBuffer = (unsigned char*) malloc(bufferLen);
+ memset(&(stream->bz2), 0, sizeof(bz_stream));
+ BZ2_bzDecompressInit(&(stream->bz2), 0, FALSE);
+
+ stream->bz2.next_in = stream->inBuffer;
+ stream->bz2.avail_in = 0;
+ stream->bz2.next_out = stream->outBuffer;
+ stream->bz2.avail_out = bufferLen;
+
+ stream->ended = FALSE;
+ return stream;
+}
+
+int patch(AbstractFile* in, AbstractFile* out, AbstractFile* patch) {
+ unsigned char header[32], buf[8];
+ off_t oldsize, newsize;
+ off_t bzctrllen, bzdatalen;
+ off_t oldpos, newpos;
+ unsigned char *old, *newBuffer;
+ int i;
+ int cbz2err, dbz2err, ebz2err;
+ off_t ctrl[3];
+ size_t lenread;
+
+ BZStream* cpfbz2;
+ BZStream* dpfbz2;
+ BZStream* epfbz2;
+
+ /* Read header */
+ if (patch->read(patch, header, 32) < 32) {
+ return -1;
+ }
+
+ /* Check for appropriate magic */
+ if (memcmp(header, "BSDIFF40", 8) != 0)
+ return -2;
+
+ /* Read lengths from header */
+ bzctrllen = offtin(header + 8);
+ bzdatalen = offtin(header + 16);
+ newsize = offtin(header + 24);
+
+ if((bzctrllen < 0) || (bzdatalen < 0) || (newsize < 0))
+ return -3;
+
+ cpfbz2 = openBZStream(patch, 32, 1024);
+ dpfbz2 = openBZStream(patch, 32 + bzctrllen, 1024);
+ epfbz2 = openBZStream(patch, 32 + bzctrllen + bzdatalen, 1024);
+
+ oldsize = in->getLength(in);
+ old = malloc(oldsize + 1);
+ in->seek(in, 0);
+ in->read(in, old, oldsize);
+ in->close(in);
+
+ newBuffer = malloc(newsize + 1);
+
+ oldpos = 0;
+ newpos = 0;
+ while(newpos < newsize) {
+ /* Read control data */
+ for(i=0;i<=2;i++) {
+ lenread = bzRead(&cbz2err, cpfbz2, buf, 8);
+ if ((lenread < 8) || ((cbz2err != BZ_OK) &&
+ (cbz2err != BZ_STREAM_END)))
+ return -4;
+ ctrl[i] = offtin(buf);
+ };
+
+ /* Sanity-check */
+ if((newpos + ctrl[0]) > newsize)
+ return -5;
+
+ /* Read diff string */
+ memset(newBuffer + newpos, 0, ctrl[0]);
+ lenread = bzRead(&dbz2err, dpfbz2, newBuffer + newpos, ctrl[0]);
+ if ((lenread < ctrl[0]) ||
+ ((dbz2err != BZ_OK) && (dbz2err != BZ_STREAM_END)))
+ return -6;
+
+ /* Add old data to diff string */
+ for(i = 0; i < ctrl[0]; i++) {
+ if(((oldpos + i)>=0) && ((oldpos + i)<oldsize)) {
+ newBuffer[newpos + i] += old[oldpos + i];
+ }
+ }
+
+ /* Adjust pointers */
+ newpos += ctrl[0];
+ oldpos += ctrl[0];
+
+ /* Sanity-check */
+ if((newpos + ctrl[1]) > newsize)
+ return -7;
+
+ /* Read extra string */
+ lenread = bzRead(&ebz2err, epfbz2, newBuffer + newpos, ctrl[1]);
+ if ((lenread < ctrl[1]) ||
+ ((ebz2err != BZ_OK) && (ebz2err != BZ_STREAM_END)))
+ return -8;
+
+ /* Adjust pointers */
+ newpos += ctrl[1];
+ oldpos += ctrl[2];
+ };
+
+ closeBZStream(cpfbz2);
+ closeBZStream(dpfbz2);
+ closeBZStream(epfbz2);
+ out->seek(out, 0);
+
+ if(out->write(out, newBuffer, newsize) != newsize)
+ return -9;
+ out->close(out);
+ free(newBuffer);
free(old);
- patch->close(patch);
- return 0;
-}
+ patch->close(patch);
+ return 0;
+}
View
118 ipsw-patch/bzip2-1.0.5/Makefile-libbz2_so
@@ -1,59 +1,59 @@
-
-# This Makefile builds a shared version of the library,
-# libbz2.so.1.0.4, with soname libbz2.so.1.0,
-# at least on x86-Linux (RedHat 7.2),
-# with gcc-2.96 20000731 (Red Hat Linux 7.1 2.96-98).
-# Please see the README file for some important info
-# about building the library like this.
-
-# ------------------------------------------------------------------
-# This file is part of bzip2/libbzip2, a program and library for
-# lossless, block-sorting data compression.
-#
-# bzip2/libbzip2 version 1.0.5 of 10 December 2007
-# Copyright (C) 1996-2007 Julian Seward <jseward@bzip.org>
-#
-# Please read the WARNING, DISCLAIMER and PATENTS sections in the
-# README file.
-#
-# This program is released under the terms of the license contained
-# in the file LICENSE.
-# ------------------------------------------------------------------
-
-
-SHELL=/bin/sh
-CC=gcc
-BIGFILES=-D_FILE_OFFSET_BITS=64
-CFLAGS=-fpic -fPIC -Wall -Winline -O2 -g $(BIGFILES)
-
-OBJS= blocksort.o \
- huffman.o \
- crctable.o \
- randtable.o \
- compress.o \
- decompress.o \
- bzlib.o
-
-all: $(OBJS)
- $(CC) -shared -Wl,-soname -Wl,libbz2.so.1.0 -o libbz2.so.1.0.4 $(OBJS)
- $(CC) $(CFLAGS) -o bzip2-shared bzip2.c libbz2.so.1.0.4
- rm -f libbz2.so.1.0
- ln -s libbz2.so.1.0.4 libbz2.so.1.0
-
-clean:
- rm -f $(OBJS) bzip2.o libbz2.so.1.0.4 libbz2.so.1.0 bzip2-shared
-
-blocksort.o: blocksort.c
- $(CC) $(CFLAGS) -c blocksort.c
-huffman.o: huffman.c
- $(CC) $(CFLAGS) -c huffman.c
-crctable.o: crctable.c
- $(CC) $(CFLAGS) -c crctable.c
-randtable.o: randtable.c
- $(CC) $(CFLAGS) -c randtable.c
-compress.o: compress.c
- $(CC) $(CFLAGS) -c compress.c
-decompress.o: decompress.c
- $(CC) $(CFLAGS) -c decompress.c
-bzlib.o: bzlib.c
- $(CC) $(CFLAGS) -c bzlib.c
+
+# This Makefile builds a shared version of the library,
+# libbz2.so.1.0.4, with soname libbz2.so.1.0,
+# at least on x86-Linux (RedHat 7.2),
+# with gcc-2.96 20000731 (Red Hat Linux 7.1 2.96-98).
+# Please see the README file for some important info
+# about building the library like this.
+
+# ------------------------------------------------------------------
+# This file is part of bzip2/libbzip2, a program and library for
+# lossless, block-sorting data compression.
+#
+# bzip2/libbzip2 version 1.0.5 of 10 December 2007
+# Copyright (C) 1996-2007 Julian Seward <jseward@bzip.org>
+#
+# Please read the WARNING, DISCLAIMER and PATENTS sections in the
+# README file.
+#
+# This program is released under the terms of the license contained
+# in the file LICENSE.
+# ------------------------------------------------------------------
+
+
+SHELL=/bin/sh
+CC=gcc
+BIGFILES=-D_FILE_OFFSET_BITS=64
+CFLAGS=-fpic -fPIC -Wall -Winline -O2 -g $(BIGFILES)
+
+OBJS= blocksort.o \
+ huffman.o \
+ crctable.o \
+ randtable.o \
+ compress.o \
+ decompress.o \
+ bzlib.o
+
+all: $(OBJS)
+ $(CC) -shared -Wl,-soname -Wl,libbz2.so.1.0 -o libbz2.so.1.0.4 $(OBJS)
+ $(CC) $(CFLAGS) -o bzip2-shared bzip2.c libbz2.so.1.0.4
+ rm -f libbz2.so.1.0
+ ln -s libbz2.so.1.0.4 libbz2.so.1.0
+
+clean:
+ rm -f $(OBJS) bzip2.o libbz2.so.1.0.4 libbz2.so.1.0 bzip2-shared
+
+blocksort.o: blocksort.c
+ $(CC) $(CFLAGS) -c blocksort.c
+huffman.o: huffman.c
+ $(CC) $(CFLAGS) -c huffman.c
+crctable.o: crctable.c
+ $(CC) $(CFLAGS) -c crctable.c
+randtable.o: randtable.c
+ $(CC) $(CFLAGS) -c randtable.c
+compress.o: compress.c
+ $(CC) $(CFLAGS) -c compress.c
+decompress.o: decompress.c
+ $(CC) $(CFLAGS) -c decompress.c
+bzlib.o: bzlib.c
+ $(CC) $(CFLAGS) -c bzlib.c
View
420 ipsw-patch/bzip2-1.0.5/README
@@ -1,210 +1,210 @@
-
-This is the README for bzip2/libzip2.
-This version is fully compatible with the previous public releases.
-
-------------------------------------------------------------------
-This file is part of bzip2/libbzip2, a program and library for
-lossless, block-sorting data compression.
-
-bzip2/libbzip2 version 1.0.5 of 10 December 2007
-Copyright (C) 1996-2007 Julian Seward <jseward@bzip.org>
-
-Please read the WARNING, DISCLAIMER and PATENTS sections in this file.
-
-This program is released under the terms of the license contained
-in the file LICENSE.
-------------------------------------------------------------------
-
-Complete documentation is available in Postscript form (manual.ps),
-PDF (manual.pdf) or html (manual.html). A plain-text version of the
-manual page is available as bzip2.txt.
-
-
-HOW TO BUILD -- UNIX
-
-Type 'make'. This builds the library libbz2.a and then the programs
-bzip2 and bzip2recover. Six self-tests are run. If the self-tests
-complete ok, carry on to installation:
-
-To install in /usr/local/bin, /usr/local/lib, /usr/local/man and
-/usr/local/include, type
-
- make install
-
-To install somewhere else, eg, /xxx/yyy/{bin,lib,man,include}, type
-
- make install PREFIX=/xxx/yyy
-
-If you are (justifiably) paranoid and want to see what 'make install'
-is going to do, you can first do
-
- make -n install or
- make -n install PREFIX=/xxx/yyy respectively.
-
-The -n instructs make to show the commands it would execute, but not
-actually execute them.
-
-
-HOW TO BUILD -- UNIX, shared library libbz2.so.
-
-Do 'make -f Makefile-libbz2_so'. This Makefile seems to work for
-Linux-ELF (RedHat 7.2 on an x86 box), with gcc. I make no claims
-that it works for any other platform, though I suspect it probably
-will work for most platforms employing both ELF and gcc.
-
-bzip2-shared, a client of the shared library, is also built, but not
-self-tested. So I suggest you also build using the normal Makefile,
-since that conducts a self-test. A second reason to prefer the
-version statically linked to the library is that, on x86 platforms,
-building shared objects makes a valuable register (%ebx) unavailable
-to gcc, resulting in a slowdown of 10%-20%, at least for bzip2.
-
-Important note for people upgrading .so's from 0.9.0/0.9.5 to version
-1.0.X. All the functions in the library have been renamed, from (eg)
-bzCompress to BZ2_bzCompress, to avoid namespace pollution.
-Unfortunately this means that the libbz2.so created by
-Makefile-libbz2_so will not work with any program which used an older
-version of the library. I do encourage library clients to make the
-effort to upgrade to use version 1.0, since it is both faster and more
-robust than previous versions.
-
-
-HOW TO BUILD -- Windows 95, NT, DOS, Mac, etc.
-
-It's difficult for me to support compilation on all these platforms.
-My approach is to collect binaries for these platforms, and put them
-on the master web site (http://www.bzip.org). Look there. However
-(FWIW), bzip2-1.0.X is very standard ANSI C and should compile
-unmodified with MS Visual C. If you have difficulties building, you
-might want to read README.COMPILATION.PROBLEMS.
-
-At least using MS Visual C++ 6, you can build from the unmodified
-sources by issuing, in a command shell:
-
- nmake -f makefile.msc
-
-(you may need to first run the MSVC-provided script VCVARS32.BAT
- so as to set up paths to the MSVC tools correctly).
-
-
-VALIDATION
-
-Correct operation, in the sense that a compressed file can always be
-decompressed to reproduce the original, is obviously of paramount
-importance. To validate bzip2, I used a modified version of Mark
-Nelson's churn program. Churn is an automated test driver which
-recursively traverses a directory structure, using bzip2 to compress
-and then decompress each file it encounters, and checking that the
-decompressed data is the same as the original.
-
-
-
-Please read and be aware of the following:
-
-WARNING:
-
- This program and library (attempts to) compress data by
- performing several non-trivial transformations on it.
- Unless you are 100% familiar with *all* the algorithms
- contained herein, and with the consequences of modifying them,
- you should NOT meddle with the compression or decompression
- machinery. Incorrect changes can and very likely *will*
- lead to disastrous loss of data.
-
-
-DISCLAIMER:
-
- I TAKE NO RESPONSIBILITY FOR ANY LOSS OF DATA ARISING FROM THE
- USE OF THIS PROGRAM/LIBRARY, HOWSOEVER CAUSED.
-
- Every compression of a file implies an assumption that the
- compressed file can be decompressed to reproduce the original.
- Great efforts in design, coding and testing have been made to
- ensure that this program works correctly. However, the complexity
- of the algorithms, and, in particular, the presence of various
- special cases in the code which occur with very low but non-zero
- probability make it impossible to rule out the possibility of bugs
- remaining in the program. DO NOT COMPRESS ANY DATA WITH THIS
- PROGRAM UNLESS YOU ARE PREPARED TO ACCEPT THE POSSIBILITY, HOWEVER
- SMALL, THAT THE DATA WILL NOT BE RECOVERABLE.
-
- That is not to say this program is inherently unreliable.
- Indeed, I very much hope the opposite is true. bzip2/libbzip2
- has been carefully constructed and extensively tested.
-
-
-PATENTS:
-
- To the best of my knowledge, bzip2/libbzip2 does not use any
- patented algorithms. However, I do not have the resources
- to carry out a patent search. Therefore I cannot give any
- guarantee of the above statement.
-
-
-
-WHAT'S NEW IN 0.9.0 (as compared to 0.1pl2) ?
-
- * Approx 10% faster compression, 30% faster decompression
- * -t (test mode) is a lot quicker
- * Can decompress concatenated compressed files
- * Programming interface, so programs can directly read/write .bz2 files
- * Less restrictive (BSD-style) licensing
- * Flag handling more compatible with GNU gzip
- * Much more documentation, i.e., a proper user manual
- * Hopefully, improved portability (at least of the library)
-
-WHAT'S NEW IN 0.9.5 ?
-
- * Compression speed is much less sensitive to the input
- data than in previous versions. Specifically, the very
- slow performance caused by repetitive data is fixed.
- * Many small improvements in file and flag handling.
- * A Y2K statement.
-
-WHAT'S NEW IN 1.0.0 ?
-
- See the CHANGES file.
-
-WHAT'S NEW IN 1.0.2 ?
-
- See the CHANGES file.
-
-WHAT'S NEW IN 1.0.3 ?
-
- See the CHANGES file.
-
-WHAT'S NEW IN 1.0.4 ?
-
- See the CHANGES file.
-
-WHAT'S NEW IN 1.0.5 ?
-
- See the CHANGES file.
-
-
-I hope you find bzip2 useful. Feel free to contact me at
- jseward@bzip.org
-if you have any suggestions or queries. Many people mailed me with
-comments, suggestions and patches after the releases of bzip-0.15,
-bzip-0.21, and bzip2 versions 0.1pl2, 0.9.0, 0.9.5, 1.0.0, 1.0.1,
-1.0.2 and 1.0.3, and the changes in bzip2 are largely a result of this
-feedback. I thank you for your comments.
-
-bzip2's "home" is http://www.bzip.org/
-
-Julian Seward
-jseward@bzip.org
-Cambridge, UK.
-
-18 July 1996 (version 0.15)
-25 August 1996 (version 0.21)
- 7 August 1997 (bzip2, version 0.1)
-29 August 1997 (bzip2, version 0.1pl2)
-23 August 1998 (bzip2, version 0.9.0)
- 8 June 1999 (bzip2, version 0.9.5)
- 4 Sept 1999 (bzip2, version 0.9.5d)
- 5 May 2000 (bzip2, version 1.0pre8)
-30 December 2001 (bzip2, version 1.0.2pre1)
-15 February 2005 (bzip2, version 1.0.3)
-20 December 2006 (bzip2, version 1.0.4)
-10 December 2007 (bzip2, version 1.0.5)
+
+This is the README for bzip2/libzip2.
+This version is fully compatible with the previous public releases.
+
+------------------------------------------------------------------
+This file is part of bzip2/libbzip2, a program and library for
+lossless, block-sorting data compression.
+
+bzip2/libbzip2 version 1.0.5 of 10 December 2007
+Copyright (C) 1996-2007 Julian Seward <jseward@bzip.org>
+
+Please read the WARNING, DISCLAIMER and PATENTS sections in this file.
+
+This program is released under the terms of the license contained
+in the file LICENSE.
+------------------------------------------------------------------
+
+Complete documentation is available in Postscript form (manual.ps),
+PDF (manual.pdf) or html (manual.html). A plain-text version of the
+manual page is available as bzip2.txt.
+
+
+HOW TO BUILD -- UNIX
+
+Type 'make'. This builds the library libbz2.a and then the programs
+bzip2 and bzip2recover. Six self-tests are run. If the self-tests
+complete ok, carry on to installation:
+
+To install in /usr/local/bin, /usr/local/lib, /usr/local/man and
+/usr/local/include, type
+
+ make install
+
+To install somewhere else, eg, /xxx/yyy/{bin,lib,man,include}, type
+
+ make install PREFIX=/xxx/yyy
+
+If you are (justifiably) paranoid and want to see what 'make install'
+is going to do, you can first do
+
+ make -n install or
+ make -n install PREFIX=/xxx/yyy respectively.
+
+The -n instructs make to show the commands it would execute, but not
+actually execute them.
+
+
+HOW TO BUILD -- UNIX, shared library libbz2.so.
+
+Do 'make -f Makefile-libbz2_so'. This Makefile seems to work for
+Linux-ELF (RedHat 7.2 on an x86 box), with gcc. I make no claims
+that it works for any other platform, though I suspect it probably
+will work for most platforms employing both ELF and gcc.
+
+bzip2-shared, a client of the shared library, is also built, but not
+self-tested. So I suggest you also build using the normal Makefile,
+since that conducts a self-test. A second reason to prefer the
+version statically linked to the library is that, on x86 platforms,
+building shared objects makes a valuable register (%ebx) unavailable
+to gcc, resulting in a slowdown of 10%-20%, at least for bzip2.
+
+Important note for people upgrading .so's from 0.9.0/0.9.5 to version
+1.0.X. All the functions in the library have been renamed, from (eg)
+bzCompress to BZ2_bzCompress, to avoid namespace pollution.
+Unfortunately this means that the libbz2.so created by
+Makefile-libbz2_so will not work with any program which used an older
+version of the library. I do encourage library clients to make the
+effort to upgrade to use version 1.0, since it is both faster and more
+robust than previous versions.
+
+
+HOW TO BUILD -- Windows 95, NT, DOS, Mac, etc.
+
+It's difficult for me to support compilation on all these platforms.
+My approach is to collect binaries for these platforms, and put them
+on the master web site (http://www.bzip.org). Look there. However
+(FWIW), bzip2-1.0.X is very standard ANSI C and should compile
+unmodified with MS Visual C. If you have difficulties building, you
+might want to read README.COMPILATION.PROBLEMS.
+
+At least using MS Visual C++ 6, you can build from the unmodified
+sources by issuing, in a command shell:
+
+ nmake -f makefile.msc
+
+(you may need to first run the MSVC-provided script VCVARS32.BAT
+ so as to set up paths to the MSVC tools correctly).
+
+
+VALIDATION
+
+Correct operation, in the sense that a compressed file can always be
+decompressed to reproduce the original, is obviously of paramount
+importance. To validate bzip2, I used a modified version of Mark
+Nelson's churn program. Churn is an automated test driver which
+recursively traverses a directory structure, using bzip2 to compress
+and then decompress each file it encounters, and checking that the
+decompressed data is the same as the original.
+
+
+
+Please read and be aware of the following:
+
+WARNING:
+
+ This program and library (attempts to) compress data by
+ performing several non-trivial transformations on it.
+ Unless you are 100% familiar with *all* the algorithms
+ contained herein, and with the consequences of modifying them,
+ you should NOT meddle with the compression or decompression
+ machinery. Incorrect changes can and very likely *will*
+ lead to disastrous loss of data.
+
+
+DISCLAIMER:
+
+ I TAKE NO RESPONSIBILITY FOR ANY LOSS OF DATA ARISING FROM THE
+ USE OF THIS PROGRAM/LIBRARY, HOWSOEVER CAUSED.
+
+ Every compression of a file implies an assumption that the
+ compressed file can be decompressed to reproduce the original.
+ Great efforts in design, coding and testing have been made to
+ ensure that this program works correctly. However, the complexity
+ of the algorithms, and, in particular, the presence of various
+ special cases in the code which occur with very low but non-zero
+ probability make it impossible to rule out the possibility of bugs
+ remaining in the program. DO NOT COMPRESS ANY DATA WITH THIS
+ PROGRAM UNLESS YOU ARE PREPARED TO ACCEPT THE POSSIBILITY, HOWEVER
+ SMALL, THAT THE DATA WILL NOT BE RECOVERABLE.
+
+ That is not to say this program is inherently unreliable.
+ Indeed, I very much hope the opposite is true. bzip2/libbzip2
+ has been carefully constructed and extensively tested.
+
+
+PATENTS:
+
+ To the best of my knowledge, bzip2/libbzip2 does not use any
+ patented algorithms. However, I do not have the resources
+ to carry out a patent search. Therefore I cannot give any
+ guarantee of the above statement.
+
+
+
+WHAT'S NEW IN 0.9.0 (as compared to 0.1pl2) ?
+
+ * Approx 10% faster compression, 30% faster decompression
+ * -t (test mode) is a lot quicker
+ * Can decompress concatenated compressed files
+ * Programming interface, so programs can directly read/write .bz2 files
+ * Less restrictive (BSD-style) licensing
+ * Flag handling more compatible with GNU gzip
+ * Much more documentation, i.e., a proper user manual
+ * Hopefully, improved portability (at least of the library)
+
+WHAT'S NEW IN 0.9.5 ?
+
+ * Compression speed is much less sensitive to the input
+ data than in previous versions. Specifically, the very
+ slow performance caused by repetitive data is fixed.
+ * Many small improvements in file and flag handling.
+ * A Y2K statement.
+
+WHAT'S NEW IN 1.0.0 ?
+
+ See the CHANGES file.
+
+WHAT'S NEW IN 1.0.2 ?
+
+ See the CHANGES file.
+
+WHAT'S NEW IN 1.0.3 ?
+
+ See the CHANGES file.
+
+WHAT'S NEW IN 1.0.4 ?
+
+ See the CHANGES file.
+
+WHAT'S NEW IN 1.0.5 ?
+
+ See the CHANGES file.
+
+
+I hope you find bzip2 useful. Feel free to contact me at
+ jseward@bzip.org
+if you have any suggestions or queries. Many people mailed me with
+comments, suggestions and patches after the releases of bzip-0.15,
+bzip-0.21, and bzip2 versions 0.1pl2, 0.9.0, 0.9.5, 1.0.0, 1.0.1,
+1.0.2 and 1.0.3, and the changes in bzip2 are largely a result of this
+feedback. I thank you for your comments.
+
+bzip2's "home" is http://www.bzip.org/
+
+Julian Seward
+jseward@bzip.org
+Cambridge, UK.
+
+18 July 1996 (version 0.15)
+25 August 1996 (version 0.21)
+ 7 August 1997 (bzip2, version 0.1)
+29 August 1997 (bzip2, version 0.1pl2)
+23 August 1998 (bzip2, version 0.9.0)
+ 8 June 1999 (bzip2, version 0.9.5)
+ 4 Sept 1999 (bzip2, version 0.9.5d)
+ 5 May 2000 (bzip2, version 1.0pre8)
+30 December 2001 (bzip2, version 1.0.2pre1)
+15 February 2005 (bzip2, version 1.0.3)
+20 December 2006 (bzip2, version 1.0.4)
+10 December 2007 (bzip2, version 1.0.5)
View
116 ipsw-patch/bzip2-1.0.5/README.COMPILATION.PROBLEMS
@@ -1,58 +1,58 @@
-------------------------------------------------------------------
-This file is part of bzip2/libbzip2, a program and library for
-lossless, block-sorting data compression.
-
-bzip2/libbzip2 version 1.0.5 of 10 December 2007
-Copyright (C) 1996-2007 Julian Seward <jseward@bzip.org>
-
-Please read the WARNING, DISCLAIMER and PATENTS sections in the
-README file.
-
-This program is released under the terms of the license contained
-in the file LICENSE.
-------------------------------------------------------------------
-
-bzip2-1.0.5 should compile without problems on the vast majority of
-platforms. Using the supplied Makefile, I've built and tested it
-myself for x86-linux and amd64-linux. With makefile.msc, Visual C++
-6.0 and nmake, you can build a native Win32 version too. Large file
-support seems to work correctly on at least on amd64-linux.
-
-When I say "large file" I mean a file of size 2,147,483,648 (2^31)
-bytes or above. Many older OSs can't handle files above this size,
-but many newer ones can. Large files are pretty huge -- most files
-you'll encounter are not Large Files.
-
-Early versions of bzip2 (0.1, 0.9.0, 0.9.5) compiled on a wide variety
-of platforms without difficulty, and I hope this version will continue
-in that tradition. However, in order to support large files, I've had
-to include the define -D_FILE_OFFSET_BITS=64 in the Makefile. This
-can cause problems.
-
-The technique of adding -D_FILE_OFFSET_BITS=64 to get large file
-support is, as far as I know, the Recommended Way to get correct large
-file support. For more details, see the Large File Support
-Specification, published by the Large File Summit, at
-
- http://ftp.sas.com/standards/large.file
-
-As a general comment, if you get compilation errors which you think
-are related to large file support, try removing the above define from
-the Makefile, ie, delete the line
-
- BIGFILES=-D_FILE_OFFSET_BITS=64
-
-from the Makefile, and do 'make clean ; make'. This will give you a
-version of bzip2 without large file support, which, for most
-applications, is probably not a problem.
-
-Alternatively, try some of the platform-specific hints listed below.
-
-You can use the spewG.c program to generate huge files to test bzip2's
-large file support, if you are feeling paranoid. Be aware though that
-any compilation problems which affect bzip2 will also affect spewG.c,
-alas.
-
-AIX: I have reports that for large file support, you need to specify
--D_LARGE_FILES rather than -D_FILE_OFFSET_BITS=64. I have not tested
-this myself.
+------------------------------------------------------------------
+This file is part of bzip2/libbzip2, a program and library for
+lossless, block-sorting data compression.
+
+bzip2/libbzip2 version 1.0.5 of 10 December 2007
+Copyright (C) 1996-2007 Julian Seward <jseward@bzip.org>
+
+Please read the WARNING, DISCLAIMER and PATENTS sections in the
+README file.
+
+This program is released under the terms of the license contained
+in the file LICENSE.
+------------------------------------------------------------------
+
+bzip2-1.0.5 should compile without problems on the vast majority of
+platforms. Using the supplied Makefile, I've built and tested it
+myself for x86-linux and amd64-linux. With makefile.msc, Visual C++
+6.0 and nmake, you can build a native Win32 version too. Large file
+support seems to work correctly on at least on amd64-linux.
+
+When I say "large file" I mean a file of size 2,147,483,648 (2^31)
+bytes or above. Many older OSs can't handle files above this size,
+but many newer ones can. Large files are pretty huge -- most files
+you'll encounter are not Large Files.
+
+Early versions of bzip2 (0.1, 0.9.0, 0.9.5) compiled on a wide variety
+of platforms without difficulty, and I hope this version will continue
+in that tradition. However, in order to support large files, I've had
+to include the define -D_FILE_OFFSET_BITS=64 in the Makefile. This
+can cause problems.
+
+The technique of adding -D_FILE_OFFSET_BITS=64 to get large file
+support is, as far as I know, the Recommended Way to get correct large
+file support. For more details, see the Large File Support
+Specification, published by the Large File Summit, at
+
+ http://ftp.sas.com/standards/large.file
+
+As a general comment, if you get compilation errors which you think
+are related to large file support, try removing the above define from
+the Makefile, ie, delete the line
+
+ BIGFILES=-D_FILE_OFFSET_BITS=64
+
+from the Makefile, and do 'make clean ; make'. This will give you a
+version of bzip2 without large file support, which, for most
+applications, is probably not a problem.
+
+Alternatively, try some of the platform-specific hints listed below.
+
+You can use the spewG.c program to generate huge files to test bzip2's
+large file support, if you are feeling paranoid. Be aware though that
+any compilation problems which affect bzip2 will also affect spewG.c,
+alas.
+
+AIX: I have reports that for large file support, you need to specify
+-D_LARGE_FILES rather than -D_FILE_OFFSET_BITS=64. I have not tested
+this myself.
View
90 ipsw-patch/bzip2-1.0.5/README.XML.STUFF
@@ -1,45 +1,45 @@
- ----------------------------------------------------------------
- This file is part of bzip2/libbzip2, a program and library for
- lossless, block-sorting data compression.
-
- bzip2/libbzip2 version 1.0.5 of 10 December 2007
- Copyright (C) 1996-2007 Julian Seward <jseward@bzip.org>
-
- Please read the WARNING, DISCLAIMER and PATENTS sections in the
- README file.
-
- This program is released under the terms of the license contained
- in the file LICENSE.
- ----------------------------------------------------------------
-
-The script xmlproc.sh takes an xml file as input,
-and processes it to create .pdf, .html or .ps output.
-It uses format.pl, a perl script to format <pre> blocks nicely,
- and add CDATA tags so writers do not have to use eg. &lt;
-
-The file "entities.xml" must be edited to reflect current
-version, year, etc.
-
-
-Usage:
-
- ./xmlproc.sh -v manual.xml
- Validates an xml file to ensure no dtd-compliance errors
-
- ./xmlproc.sh -html manual.xml
- Output: manual.html
-
- ./xmlproc.sh -pdf manual.xml
- Output: manual.pdf
-
- ./xmlproc.sh -ps manual.xml
- Output: manual.ps
-
-
-Notum bene:
-- pdfxmltex barfs if given a filename with an underscore in it
-
-- xmltex won't work yet - there's a bug in passivetex
- which we are all waiting for Sebastian to fix.
- So we are going the xml -> pdf -> ps route for the time being,
- using pdfxmltex.
+ ----------------------------------------------------------------
+ This file is part of bzip2/libbzip2, a program and library for
+ lossless, block-sorting data compression.
+
+ bzip2/libbzip2 version 1.0.5 of 10 December 2007
+ Copyright (C) 1996-2007 Julian Seward <jseward@bzip.org>
+
+ Please read the WARNING, DISCLAIMER and PATENTS sections in the
+ README file.
+
+ This program is released under the terms of the license contained
+ in the file LICENSE.
+ ----------------------------------------------------------------
+
+The script xmlproc.sh takes an xml file as input,
+and processes it to create .pdf, .html or .ps output.
+It uses format.pl, a perl script to format <pre> blocks nicely,
+ and add CDATA tags so writers do not have to use eg. &lt;
+
+The file "entities.xml" must be edited to reflect current
+version, year, etc.
+
+
+Usage:
+
+ ./xmlproc.sh -v manual.xml
+ Validates an xml file to ensure no dtd-compliance errors
+
+ ./xmlproc.sh -html manual.xml
+ Output: manual.html
+
+ ./xmlproc.sh -pdf manual.xml
+ Output: manual.pdf
+
+ ./xmlproc.sh -ps manual.xml
+ Output: manual.ps
+
+
+Notum bene:
+- pdfxmltex barfs if given a filename with an underscore in it
+
+- xmltex won't work yet - there's a bug in passivetex
+ which we are all waiting for Sebastian to fix.
+ So we are going the xml -> pdf -> ps route for the time being,
+ using pdfxmltex.
View
2,188 ipsw-patch/bzip2-1.0.5/blocksort.c
@@ -1,1094 +1,1094 @@
-
-/*-------------------------------------------------------------*/
-/*--- Block sorting machinery ---*/
-/*--- blocksort.c ---*/
-/*-------------------------------------------------------------*/
-
-/* ------------------------------------------------------------------
- This file is part of bzip2/libbzip2, a program and library for
- lossless, block-sorting data compression.
-
- bzip2/libbzip2 version 1.0.5 of 10 December 2007
- Copyright (C) 1996-2007 Julian Seward <jseward@bzip.org>
-
- Please read the WARNING, DISCLAIMER and PATENTS sections in the
- README file.
-
- This program is released under the terms of the license contained
- in the file LICENSE.
- ------------------------------------------------------------------ */
-
-
-#include "bzlib_private.h"
-
-/*---------------------------------------------*/
-/*--- Fallback O(N log(N)^2) sorting ---*/
-/*--- algorithm, for repetitive blocks ---*/
-/*---------------------------------------------*/
-
-/*---------------------------------------------*/
-static
-__inline__
-void fallbackSimpleSort ( UInt32* fmap,
- UInt32* eclass,
- Int32 lo,
- Int32 hi )
-{
- Int32 i, j, tmp;
- UInt32 ec_tmp;
-
- if (lo == hi) return;
-
- if (hi - lo > 3) {
- for ( i = hi-4; i >= lo; i-- ) {
- tmp = fmap[i];
- ec_tmp = eclass[tmp];
- for ( j = i+4; j <= hi && ec_tmp > eclass[fmap[j]]; j += 4 )
- fmap[j-4] = fmap[j];
- fmap[j-4] = tmp;
- }
- }
-
- for ( i = hi-1; i >= lo; i-- ) {
- tmp = fmap[i];
- ec_tmp = eclass[tmp];
- for ( j = i+1; j <= hi && ec_tmp > eclass[fmap[j]]; j++ )
- fmap[j-1] = fmap[j];
- fmap[j-1] = tmp;
- }
-}
-
-
-/*---------------------------------------------*/
-#define fswap(zz1, zz2) \
- { Int32 zztmp = zz1; zz1 = zz2; zz2 = zztmp; }
-
-#define fvswap(zzp1, zzp2, zzn) \
-{ \
- Int32 yyp1 = (zzp1); \
- Int32 yyp2 = (zzp2); \
- Int32 yyn = (zzn); \
- while (yyn > 0) { \
- fswap(fmap[yyp1], fmap[yyp2]); \
- yyp1++; yyp2++; yyn--; \
- } \
-}
-
-
-#define fmin(a,b) ((a) < (b)) ? (a) : (b)
-
-#define fpush(lz,hz) { stackLo[sp] = lz; \
- stackHi[sp] = hz; \
- sp++; }
-
-#define fpop(lz,hz) { sp--; \
- lz = stackLo[sp]; \
- hz = stackHi[sp]; }
-
-#define FALLBACK_QSORT_SMALL_THRESH 10
-#define FALLBACK_QSORT_STACK_SIZE 100
-
-
-static
-void fallbackQSort3 ( UInt32* fmap,
- UInt32* eclass,
- Int32 loSt,
- Int32 hiSt )
-{
- Int32 unLo, unHi, ltLo, gtHi, n, m;
- Int32 sp, lo, hi;
- UInt32 med, r, r3;
- Int32 stackLo[FALLBACK_QSORT_STACK_SIZE];
- Int32 stackHi[FALLBACK_QSORT_STACK_SIZE];
-
- r = 0;
-
- sp = 0;
- fpush ( loSt, hiSt );
-
- while (sp > 0) {
-
- AssertH ( sp < FALLBACK_QSORT_STACK_SIZE - 1, 1004 );
-
- fpop ( lo, hi );
- if (hi - lo < FALLBACK_QSORT_SMALL_THRESH) {
- fallbackSimpleSort ( fmap, eclass, lo, hi );
- continue;
- }
-
- /* Random partitioning. Median of 3 sometimes fails to
- avoid bad cases. Median of 9 seems to help but
- looks rather expensive. This too seems to work but
- is cheaper. Guidance for the magic constants
- 7621 and 32768 is taken from Sedgewick's algorithms
- book, chapter 35.
- */
- r = ((r * 7621) + 1) % 32768;
- r3 = r % 3;
- if (r3 == 0) med = eclass[fmap[lo]]; else
- if (r3 == 1) med = eclass[fmap[(lo+hi)>>1]]; else
- med = eclass[fmap[hi]];
-
- unLo = ltLo = lo;
- unHi = gtHi = hi;
-
- while (1) {
- while (1) {
- if (unLo > unHi) break;
- n = (Int32)eclass[fmap[unLo]] - (Int32)med;
- if (n == 0) {
- fswap(fmap[unLo], fmap[ltLo]);
- ltLo++; unLo++;
- continue;
- };
- if (n > 0) break;
- unLo++;
- }
- while (1) {
- if (unLo > unHi) break;
- n = (Int32)eclass[fmap[unHi]] - (Int32)med;
- if (n == 0) {
- fswap(fmap[unHi], fmap[gtHi]);
- gtHi--; unHi--;
- continue;
- };
- if (n < 0) break;
- unHi--;
- }
- if (unLo > unHi) break;
- fswap(fmap[unLo], fmap[unHi]); unLo++; unHi--;
- }
-
- AssertD ( unHi == unLo-1, "fallbackQSort3(2)" );
-
- if (gtHi < ltLo) continue;
-
- n = fmin(ltLo-lo, unLo-ltLo); fvswap(lo, unLo-n, n);
- m = fmin(hi-gtHi, gtHi-unHi); fvswap(unLo, hi-m+1, m);
-
- n = lo + unLo - ltLo - 1;
- m = hi - (gtHi - unHi) + 1;
-
- if (n - lo > hi - m) {
- fpush ( lo, n );
- fpush ( m, hi );
- } else {
- fpush ( m, hi );
- fpush ( lo, n );
- }
- }
-}
-
-#undef fmin
-#undef fpush
-#undef fpop
-#undef fswap
-#undef fvswap
-#undef FALLBACK_QSORT_SMALL_THRESH
-#undef FALLBACK_QSORT_STACK_SIZE
-
-
-/*---------------------------------------------*/
-/* Pre:
- nblock > 0
- eclass exists for [0 .. nblock-1]
- ((UChar*)eclass) [0 .. nblock-1] holds block
- ptr exists for [0 .. nblock-1]
-
- Post:
- ((UChar*)eclass) [0 .. nblock-1] holds block
- All other areas of eclass destroyed
- fmap [0 .. nblock-1] holds sorted order
- bhtab [ 0 .. 2+(nblock/32) ] destroyed
-*/
-
-#define SET_BH(zz) bhtab[(zz) >> 5] |= (1 << ((zz) & 31))
-#define CLEAR_BH(zz) bhtab[(zz) >> 5] &= ~(1 << ((zz) & 31))
-#define ISSET_BH(zz) (bhtab[(zz) >> 5] & (1 << ((zz) & 31)))
-#define WORD_BH(zz) bhtab[(zz) >> 5]
-#define UNALIGNED_BH(zz) ((zz) & 0x01f)
-
-static
-void fallbackSort ( UInt32* fmap,
- UInt32* eclass,
- UInt32* bhtab,
- Int32 nblock,
- Int32 verb )
-{
- Int32 ftab[257];
- Int32 ftabCopy[256];
- Int32 H, i, j, k, l, r, cc, cc1;
- Int32 nNotDone;
- Int32 nBhtab;
- UChar* eclass8 = (UChar*)eclass;
-
- /*--
- Initial 1-char radix sort to generate
- initial fmap and initial BH bits.
- --*/
- if (verb >= 4)
- VPrintf0 ( " bucket sorting ...\n" );
- for (i = 0; i < 257; i++) ftab[i] = 0;
- for (i = 0; i < nblock; i++) ftab[eclass8[i]]++;
- for (i = 0; i < 256; i++) ftabCopy[i] = ftab[i];
- for (i = 1; i < 257; i++) ftab[i] += ftab[i-1];
-
- for (i = 0; i < nblock; i++) {
- j = eclass8[i];
- k = ftab[j] - 1;
- ftab[j] = k;
- fmap[k] = i;
- }
-
- nBhtab = 2 + (nblock / 32);
- for (i = 0; i < nBhtab; i++) bhtab[i] = 0;
- for (i = 0; i < 256; i++) SET_BH(ftab[i]);
-
- /*--
- Inductively refine the buckets. Kind-of an
- "exponential radix sort" (!), inspired by the
- Manber-Myers suffix array construction algorithm.
- --*/
-
- /*-- set sentinel bits for block-end detection --*/
- for (i = 0; i < 32; i++) {
- SET_BH(nblock + 2*i);
- CLEAR_BH(nblock + 2*i + 1);
- }
-
- /*-- the log(N) loop --*/
- H = 1;
- while (1) {
-
- if (verb >= 4)
- VPrintf1 ( " depth %6d has ", H );
-
- j = 0;
- for (i = 0; i < nblock; i++) {
- if (ISSET_BH(i)) j = i;
- k = fmap[i] - H; if (k < 0) k += nblock;
- eclass[k] = j;
- }
-
- nNotDone = 0;
- r = -1;
- while (1) {
-
- /*-- find the next non-singleton bucket --*/
- k = r + 1;
- while (ISSET_BH(k) && UNALIGNED_BH(k)) k++;
- if (ISSET_BH(k)) {
- while (WORD_BH(k) == 0xffffffff) k += 32;
- while (ISSET_BH(k)) k++;
- }
- l = k - 1;
- if (l >= nblock) break;
- while (!ISSET_BH(k) && UNALIGNED_BH(k)) k++;
- if (!ISSET_BH(k)) {
- while (WORD_BH(k) == 0x00000000) k += 32;
- while (!ISSET_BH(k)) k++;
- }
- r = k - 1;
- if (r >= nblock) break;
-
- /*-- now [l, r] bracket current bucket --*/
- if (r > l) {
- nNotDone += (r - l + 1);
- fallbackQSort3 ( fmap, eclass, l, r );
-
- /*-- scan bucket and generate header bits-- */
- cc = -1;
- for (i = l; i <= r; i++) {
- cc1 = eclass[fmap[i]];
- if (cc != cc1) { SET_BH(i); cc = cc1; };
- }
- }
- }
-
- if (verb >= 4)
- VPrintf1 ( "%6d unresolved strings\n", nNotDone );
-
- H *= 2;
- if (H > nblock || nNotDone == 0) break;
- }
-
- /*--
- Reconstruct the original block in
- eclass8 [0 .. nblock-1], since the
- previous phase destroyed it.
- --*/
- if (verb >= 4)
- VPrintf0 ( " reconstructing block ...\n" );
- j = 0;
- for (i = 0; i < nblock; i++) {
- while (ftabCopy[j] == 0) j++;
- ftabCopy[j]--;
- eclass8[fmap[i]] = (UChar)j;
- }
- AssertH ( j < 256, 1005 );
-}
-
-#undef SET_BH
-#undef CLEAR_BH
-#undef ISSET_BH
-#undef WORD_BH
-#undef UNALIGNED_BH
-
-
-/*---------------------------------------------*/
-/*--- The main, O(N^2 log(N)) sorting ---*/
-/*--- algorithm. Faster for "normal" ---*/
-/*--- non-repetitive blocks. ---*/
-/*---------------------------------------------*/
-
-/*---------------------------------------------*/
-static
-__inline__
-Bool mainGtU ( UInt32 i1,
- UInt32 i2,
- UChar* block,
- UInt16* quadrant,
- UInt32 nblock,
- Int32* budget )
-{
- Int32 k;
- UChar c1, c2;
- UInt16 s1, s2;
-
- AssertD ( i1 != i2, "mainGtU" );
- /* 1 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- i1++; i2++;
- /* 2 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- i1++; i2++;
- /* 3 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- i1++; i2++;
- /* 4 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- i1++; i2++;
- /* 5 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- i1++; i2++;
- /* 6 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- i1++; i2++;
- /* 7 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- i1++; i2++;
- /* 8 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- i1++; i2++;
- /* 9 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- i1++; i2++;
- /* 10 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- i1++; i2++;
- /* 11 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- i1++; i2++;
- /* 12 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- i1++; i2++;
-
- k = nblock + 8;
-
- do {
- /* 1 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- s1 = quadrant[i1]; s2 = quadrant[i2];
- if (s1 != s2) return (s1 > s2);
- i1++; i2++;
- /* 2 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- s1 = quadrant[i1]; s2 = quadrant[i2];