summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordotdotisdead <dotdotisdead@a3eca27d-f21b-0410-9b4a-6511e771f64e>2006-12-10 02:20:48 +0000
committerdotdotisdead <dotdotisdead@a3eca27d-f21b-0410-9b4a-6511e771f64e>2006-12-10 02:20:48 +0000
commit7fb75616337a50fb98c6c251f8d76825dfca9165 (patch)
tree5767f0e88ce9fe638d8112d35a4ae65337091415
parentad85653ca73c8126de516b9a4294e8f08577c00d (diff)
Preliminary WIN32 support.
-rwxr-xr-xxdelta3/Makefile21
-rwxr-xr-xxdelta3/xdelta3-main.h141
-rwxr-xr-xxdelta3/xdelta3.c9
-rwxr-xr-xxdelta3/xdelta3.h6
-rwxr-xr-xxdelta3/xdelta3.vcproj238
5 files changed, 328 insertions, 87 deletions
diff --git a/xdelta3/Makefile b/xdelta3/Makefile
index ef5468d..a23ce28 100755
--- a/xdelta3/Makefile
+++ b/xdelta3/Makefile
@@ -13,7 +13,7 @@ SOURCES = xdelta3-cfgs.h \
13 xdelta3.c \ 13 xdelta3.c \
14 xdelta3.h 14 xdelta3.h
15 15
16TARGETS = xdelta3 xdelta3-1 xdelta3-debug xdelta3-64 xdelta3-everything \ 16TARGETS = xdelta3 xdelta3-debug xdelta3-64 xdelta3-everything \
17 xdelta3-Opg xdelta3-64-O xdelta3-Op xdelta3-O \ 17 xdelta3-Opg xdelta3-64-O xdelta3-Op xdelta3-O \
18 xdelta3-decoder xdelta3-decoder-nomain.o \ 18 xdelta3-decoder xdelta3-decoder-nomain.o \
19 $(PYTGT) \ 19 $(PYTGT) \
@@ -32,7 +32,9 @@ EXTRA = Makefile COPYING linkxd3lib.c badcopy.c www
32REL=0h_pre0 32REL=0h_pre0
33RELDIR = xdelta3$(REL) 33RELDIR = xdelta3$(REL)
34 34
35all: xdelta3 xdelta3-debug $(PYTGT) 35XDELTA1 = ../xdelta11/xdelta
36
37all: xdelta3-debug xdelta3 $(PYTGT)
36 38
37all-targets: $(TARGETS) 39all-targets: $(TARGETS)
38 40
@@ -58,23 +60,18 @@ xdelta3: $(SOURCES)
58 -DXD3_MAIN=1 \ 60 -DXD3_MAIN=1 \
59 -DXD3_POSIX=1 61 -DXD3_POSIX=1
60 62
61$(PYTGT): $(SOURCES)
62 $(PYTHON) setup.py install --verbose --compile --force
63
64xdelta3-1: $(SOURCES)
65 $(CC) -g -Wall -Wshadow xdelta3.c -o xdelta3-1 -DXD3_MAIN=1 -DGENERIC_ENCODE_TABLES=1 \
66 -DXD3_USE_LARGEFILE64=1 -DREGRESSION_TEST=1 -DXD3_DEBUG=1 -DSECONDARY_DJW=1 -lm
67
68xdelta3-debug: $(SOURCES) 63xdelta3-debug: $(SOURCES)
69 $(CC) -g -Wall -Wshadow xdelta3.c -o xdelta3-debug -DXD3_MAIN=1 -DGENERIC_ENCODE_TABLES=1 \ 64 $(CC) -g -Wall -Wshadow xdelta3.c -o xdelta3-debug -DXD3_MAIN=1 -DGENERIC_ENCODE_TABLES=1 \
70 -DXD3_USE_LARGEFILE64=1 -DREGRESSION_TEST=1 -DXD3_DEBUG=2 -DSECONDARY_DJW=1 -lm 65 -DXD3_USE_LARGEFILE64=1 -DXD3_STDIO=1 -DREGRESSION_TEST=1 -DXD3_DEBUG=2 -DSECONDARY_DJW=1 -lm
66
67$(PYTGT): $(SOURCES)
68 $(PYTHON) setup.py install --verbose --compile --force
71 69
72xdelta3-decoder: $(SOURCES) 70xdelta3-decoder: $(SOURCES)
73 $(CC) -O2 -Wall -Wshadow xdelta3.c \ 71 $(CC) -O2 -Wall -Wshadow xdelta3.c \
74 -DXD3_ENCODER=0 -DXD3_MAIN=1 -DSECONDARY_FGK=0 -DSECONDARY_DJW=0 \ 72 -DXD3_ENCODER=0 -DXD3_MAIN=1 -DSECONDARY_FGK=0 -DSECONDARY_DJW=0 \
75 -DXD3_POSIX=0 -DEXTERNAL_COMPRESSION=0 -DVCDIFF_TOOLS=0 \ 73 -DXD3_STDIO=1 -DEXTERNAL_COMPRESSION=0 -DVCDIFF_TOOLS=0 \
76 -o xdelta3-decoder 74 -o xdelta3-decoder
77 strip xdelta3-decoder
78 75
79xdelta3-decoder-nomain.o: $(SOURCES) linkxd3lib.c 76xdelta3-decoder-nomain.o: $(SOURCES) linkxd3lib.c
80 $(CC) -O2 -Wall -Wshadow xdelta3.c linkxd3lib.c \ 77 $(CC) -O2 -Wall -Wshadow xdelta3.c linkxd3lib.c \
diff --git a/xdelta3/xdelta3-main.h b/xdelta3/xdelta3-main.h
index 6261156..79f9617 100755
--- a/xdelta3/xdelta3-main.h
+++ b/xdelta3/xdelta3-main.h
@@ -55,19 +55,16 @@
55#ifndef XD3_STDIO 55#ifndef XD3_STDIO
56#define XD3_STDIO 0 56#define XD3_STDIO 0
57#endif 57#endif
58#ifndef XD3_WIN32
59#define XD3_WIN32 0
60#endif
61 58
62/* XPRINTX (used by main) prefixes an "xdelta3: " to the output. */ 59/* XPRINTX (used by main) prefixes an "xdelta3: " to the output. */
63#define XPR fprintf 60#define XPR fprintf
64#define NT stderr, "xdelta3: " 61#define NT stderr, "xdelta3: "
65 62
66#define VC fprintf 63#define VC fprintf
67#define OUT vcout, 64#define UT vcout,
68 65
69/* If none are set, default to posix. */ 66/* If none are set, default to posix. */
70#if (XD3_POSIX + XD3_STDIO + XD3_WIN32) == 0 67#if (XD3_POSIX + XD3_STDIO) == 0
71#undef XD3_POSIX 68#undef XD3_POSIX
72#define XD3_POSIX 1 69#define XD3_POSIX 1
73#endif 70#endif
@@ -79,10 +76,6 @@
79 76
80#define PRINTHDR_SPECIAL -4378291 77#define PRINTHDR_SPECIAL -4378291
81 78
82#ifndef XDELTA1PATH
83#define XDELTA1PATH "xdelta1"
84#endif
85
86/* The number of soft-config variables. */ 79/* The number of soft-config variables. */
87#define XD3_SOFTCFG_VARCNT 1 80#define XD3_SOFTCFG_VARCNT 1
88 81
@@ -91,7 +84,6 @@
91#define XD3_LIB_ERRMSG(stream, ret) "%s: %s\n", xd3_errstring (stream), xd3_strerror (ret) 84#define XD3_LIB_ERRMSG(stream, ret) "%s: %s\n", xd3_errstring (stream), xd3_strerror (ret)
92 85
93#include <stdio.h> /* fprintf */ 86#include <stdio.h> /* fprintf */
94#include <unistd.h> /* lots */
95 87
96#if XD3_POSIX 88#if XD3_POSIX
97#include <unistd.h> /* close, read, write... */ 89#include <unistd.h> /* close, read, write... */
@@ -99,8 +91,12 @@
99#include <fcntl.h> 91#include <fcntl.h>
100#endif 92#endif
101 93
94#ifndef _WIN32
95#include <unistd.h> /* lots */
102#include <sys/time.h> /* gettimeofday() */ 96#include <sys/time.h> /* gettimeofday() */
103#include <sys/stat.h> /* stat() and fstat() */ 97#include <sys/stat.h> /* stat() and fstat() */
98#else
99#endif
104 100
105/****************************************************************************************** 101/******************************************************************************************
106 ENUMS and TYPES 102 ENUMS and TYPES
@@ -120,6 +116,7 @@ typedef enum
120{ 116{
121 RD_FIRST = (1 << 0), 117 RD_FIRST = (1 << 0),
122 RD_NONEXTERNAL = (1 << 1), 118 RD_NONEXTERNAL = (1 << 1),
119 RD_EXTERNAL_V1 = (1 << 2),
123} xd3_read_flags; 120} xd3_read_flags;
124 121
125/* main_file->mode values */ 122/* main_file->mode values */
@@ -175,7 +172,7 @@ struct _main_file
175 char *filename_copy; /* File name or /dev/stdin, /dev/stdout, /dev/stderr. */ 172 char *filename_copy; /* File name or /dev/stdin, /dev/stdout, /dev/stderr. */
176 const char *realname; /* File name or /dev/stdin, /dev/stdout, /dev/stderr. */ 173 const char *realname; /* File name or /dev/stdin, /dev/stdout, /dev/stderr. */
177 const main_extcomp *compressor; /* External compression struct. */ 174 const main_extcomp *compressor; /* External compression struct. */
178 int flags; /* RD_FIRST or RD_NONEXTERNAL */ 175 int flags; /* RD_FIRST, RD_NONEXTERNAL, ... */
179 xoff_t nread; /* for input position */ 176 xoff_t nread; /* for input position */
180 xoff_t nwrite; /* for output position */ 177 xoff_t nwrite; /* for output position */
181}; 178};
@@ -231,6 +228,7 @@ static char* option_smatch_config = NULL;
231static int option_no_compress = 0; 228static int option_no_compress = 0;
232static int option_no_output = 0; /* go through the motions, but do not open or write output */ 229static int option_no_output = 0; /* go through the motions, but do not open or write output */
233static const char *option_source_filename = NULL; 230static const char *option_source_filename = NULL;
231static const char *option_xdelta1 = "xdelta1";
234 232
235static usize_t option_winsize = XD3_DEFAULT_WINSIZE; 233static usize_t option_winsize = XD3_DEFAULT_WINSIZE;
236static usize_t option_srcwinsz = XD3_DEFAULT_SRCWINSZ; 234static usize_t option_srcwinsz = XD3_DEFAULT_SRCWINSZ;
@@ -277,9 +275,9 @@ static int allow_fake_source = 0;
277 * the program knows the mapping of IDENT->NAME. */ 275 * the program knows the mapping of IDENT->NAME. */
278static main_extcomp extcomp_types[] = 276static main_extcomp extcomp_types[] =
279{ 277{
280 /* The entry for xdelta must be first because the program_name is set here. */ 278 /* The entry for xdelta3/1 must be 0/1 because the program_names are set there. */
281 { "xdelta3", "-cfq", "xdelta3", "-dcfq", "X", "\xd6\xc3\xc4", 3, RD_NONEXTERNAL }, 279 { "xdelta3", "-cfq", "xdelta3", "-dcfq", "X", "\xd6\xc3\xc4", 3, RD_NONEXTERNAL },
282 { XDELTA1PATH,"delta", XDELTA1PATH, "patch", "1", "%XD", 3, 0 }, 280 { "xdelta1", "delta", "xdelta1", "patch", "1", "%XD", 3, RD_EXTERNAL_V1 },
283 { "bzip2", "-cf", "bzip2", "-dcf", "B", "BZh", 3, 0 }, 281 { "bzip2", "-cf", "bzip2", "-dcf", "B", "BZh", 3, 0 },
284 { "gzip", "-cf", "gzip", "-dcf", "G", "\037\213", 2, 0 }, 282 { "gzip", "-cf", "gzip", "-dcf", "G", "\037\213", 2, 0 },
285 { "compress", "-cf", "uncompress", "-cf", "Z", "\037\235", 2, 0 }, 283 { "compress", "-cf", "uncompress", "-cf", "Z", "\037\235", 2, 0 },
@@ -783,7 +781,7 @@ main_print_window (xd3_stream* stream, FILE *vcout)
783 int ret; 781 int ret;
784 usize_t size = 0; 782 usize_t size = 0;
785 783
786 VC(OUT " Offset Code Type1 Size1 @Addr1 + Type2 Size2 @Addr2\n"); 784 VC(UT " Offset Code Type1 Size1 @Addr1 + Type2 Size2 @Addr2\n");
787 785
788 while (stream->inst_sect.buf < stream->inst_sect.buf_max) 786 while (stream->inst_sect.buf < stream->inst_sect.buf_max)
789 { 787 {
@@ -791,7 +789,7 @@ main_print_window (xd3_stream* stream, FILE *vcout)
791 789
792 if ((ret = xd3_decode_instruction (stream))) { return ret; } 790 if ((ret = xd3_decode_instruction (stream))) { return ret; }
793 791
794 VC(OUT " %06"Q"u %03u %s %3u", stream->dec_winstart + size, code, 792 VC(UT " %06"Q"u %03u %s %3u", stream->dec_winstart + size, code,
795 xd3_rtype_to_string (stream->dec_current1.type, option_print_cpymode), 793 xd3_rtype_to_string (stream->dec_current1.type, option_print_cpymode),
796 stream->dec_current1.size); 794 stream->dec_current1.size);
797 795
@@ -800,28 +798,28 @@ main_print_window (xd3_stream* stream, FILE *vcout)
800 size += stream->dec_current1.size; 798 size += stream->dec_current1.size;
801 if (stream->dec_current1.type >= XD3_CPY) 799 if (stream->dec_current1.type >= XD3_CPY)
802 { 800 {
803 VC(OUT " @%-6u", stream->dec_current1.addr); 801 VC(UT " @%-6u", stream->dec_current1.addr);
804 } 802 }
805 else 803 else
806 { 804 {
807 VC(OUT " "); 805 VC(UT " ");
808 } 806 }
809 } 807 }
810 808
811 if (stream->dec_current2.type != XD3_NOOP) 809 if (stream->dec_current2.type != XD3_NOOP)
812 { 810 {
813 size += stream->dec_current2.size; 811 size += stream->dec_current2.size;
814 VC(OUT " %s %3u", 812 VC(UT " %s %3u",
815 xd3_rtype_to_string (stream->dec_current2.type, option_print_cpymode), 813 xd3_rtype_to_string (stream->dec_current2.type, option_print_cpymode),
816 stream->dec_current2.size); 814 stream->dec_current2.size);
817 815
818 if (stream->dec_current2.type >= XD3_CPY) 816 if (stream->dec_current2.type >= XD3_CPY)
819 { 817 {
820 VC(OUT " @%-6u", stream->dec_current2.addr); 818 VC(UT " @%-6u", stream->dec_current2.addr);
821 } 819 }
822 } 820 }
823 821
824 VC(OUT "\n"); 822 VC(UT "\n");
825 } 823 }
826 824
827 if (stream->dec_tgtlen != size && (stream->flags & XD3_SKIP_WINDOW) == 0) 825 if (stream->dec_tgtlen != size && (stream->flags & XD3_SKIP_WINDOW) == 0)
@@ -842,7 +840,7 @@ main_print_window (xd3_stream* stream, FILE *vcout)
842 return XD3_INTERNAL; 840 return XD3_INTERNAL;
843 } 841 }
844 842
845 IF_DEBUG (VC(OUT "SIZE=%u TGTLEN=%u\n", size, stream->dec_tgtlen)); 843 IF_DEBUG (VC(UT "SIZE=%u TGTLEN=%u\n", size, stream->dec_tgtlen));
846 844
847 return 0; 845 return 0;
848} 846}
@@ -850,8 +848,8 @@ main_print_window (xd3_stream* stream, FILE *vcout)
850static void 848static void
851main_print_vcdiff_file (main_file *file, const char *type, FILE *vcout) 849main_print_vcdiff_file (main_file *file, const char *type, FILE *vcout)
852{ 850{
853 if (file->filename) { VC(OUT "XDELTA filename (%s): %s\n", type, file->filename); } 851 if (file->filename) { VC(UT "XDELTA filename (%s): %s\n", type, file->filename); }
854 if (file->compressor) { VC(OUT "XDELTA ext comp (%s): %s\n", type, file->compressor->recomp_cmdname); } 852 if (file->compressor) { VC(UT "XDELTA ext comp (%s): %s\n", type, file->compressor->recomp_cmdname); }
855} 853}
856 854
857/* This function prints a VCDIFF input, mainly for debugging purposes. */ 855/* This function prints a VCDIFF input, mainly for debugging purposes. */
@@ -873,18 +871,18 @@ main_print_func (xd3_stream* stream, main_file *xfile)
873 XD3_ASSERT (vcout); 871 XD3_ASSERT (vcout);
874 if (stream->dec_winstart == 0) 872 if (stream->dec_winstart == 0)
875 { 873 {
876 VC(OUT "VCDIFF version: 0\n"); 874 VC(UT "VCDIFF version: 0\n");
877 875
878 VC(OUT "VCDIFF header size: %d\n", stream->dec_hdrsize); 876 VC(UT "VCDIFF header size: %d\n", stream->dec_hdrsize);
879 VC(OUT "VCDIFF header indicator: "); 877 VC(UT "VCDIFF header indicator: ");
880 if ((stream->dec_hdr_ind & VCD_SECONDARY) != 0) VC(OUT "VCD_SECONDARY "); 878 if ((stream->dec_hdr_ind & VCD_SECONDARY) != 0) VC(UT "VCD_SECONDARY ");
881 if ((stream->dec_hdr_ind & VCD_CODETABLE) != 0) VC(OUT "VCD_CODETABLE "); 879 if ((stream->dec_hdr_ind & VCD_CODETABLE) != 0) VC(UT "VCD_CODETABLE ");
882 if ((stream->dec_hdr_ind & VCD_APPHEADER) != 0) VC(OUT "VCD_APPHEADER "); 880 if ((stream->dec_hdr_ind & VCD_APPHEADER) != 0) VC(UT "VCD_APPHEADER ");
883 if (stream->dec_hdr_ind == 0) VC(OUT "none"); 881 if (stream->dec_hdr_ind == 0) VC(UT "none");
884 VC(OUT "\n"); 882 VC(UT "\n");
885 883
886 IF_SEC(VC(OUT "VCDIFF secondary compressor: %s\n", stream->sec_type ? stream->sec_type->name : "none")); 884 IF_SEC(VC(UT "VCDIFF secondary compressor: %s\n", stream->sec_type ? stream->sec_type->name : "none"));
887 IF_NSEC(VC(OUT "VCDIFF secondary compressor: unsupported\n")); 885 IF_NSEC(VC(UT "VCDIFF secondary compressor: unsupported\n"));
888 886
889 if (stream->dec_hdr_ind & VCD_APPHEADER) 887 if (stream->dec_hdr_ind & VCD_APPHEADER)
890 { 888 {
@@ -897,9 +895,9 @@ main_print_func (xd3_stream* stream, main_file *xfile)
897 int sq = option_quiet; 895 int sq = option_quiet;
898 main_file i, o, s; 896 main_file i, o, s;
899 XD3_ASSERT (apphead != NULL); 897 XD3_ASSERT (apphead != NULL);
900 VC(OUT "VCDIFF application header: "); 898 VC(UT "VCDIFF application header: ");
901 fwrite (apphead, 1, appheadsz, vcout); 899 fwrite (apphead, 1, appheadsz, vcout);
902 VC(OUT "\n"); 900 VC(UT "\n");
903 901
904 main_file_init (& i); 902 main_file_init (& i);
905 main_file_init (& o); 903 main_file_init (& o);
@@ -917,49 +915,49 @@ main_print_func (xd3_stream* stream, main_file *xfile)
917 } 915 }
918 else 916 else
919 { 917 {
920 VC(OUT "\n"); 918 VC(UT "\n");
921 } 919 }
922 920
923 VC(OUT "VCDIFF window number: %"Q"u\n", stream->current_window); 921 VC(UT "VCDIFF window number: %"Q"u\n", stream->current_window);
924 VC(OUT "VCDIFF window indicator: "); 922 VC(UT "VCDIFF window indicator: ");
925 if ((stream->dec_win_ind & VCD_SOURCE) != 0) VC(OUT "VCD_SOURCE "); 923 if ((stream->dec_win_ind & VCD_SOURCE) != 0) VC(UT "VCD_SOURCE ");
926 if ((stream->dec_win_ind & VCD_TARGET) != 0) VC(OUT "VCD_TARGET "); 924 if ((stream->dec_win_ind & VCD_TARGET) != 0) VC(UT "VCD_TARGET ");
927 if ((stream->dec_win_ind & VCD_ADLER32) != 0) VC(OUT "VCD_ADLER32 "); 925 if ((stream->dec_win_ind & VCD_ADLER32) != 0) VC(UT "VCD_ADLER32 ");
928 if (stream->dec_win_ind == 0) VC(OUT "none"); 926 if (stream->dec_win_ind == 0) VC(UT "none");
929 VC(OUT "\n"); 927 VC(UT "\n");
930 928
931 if ((stream->dec_win_ind & VCD_ADLER32) != 0) 929 if ((stream->dec_win_ind & VCD_ADLER32) != 0)
932 { 930 {
933 VC(OUT "VCDIFF adler32 checksum: %08X\n", stream->dec_adler32); 931 VC(UT "VCDIFF adler32 checksum: %08X\n", stream->dec_adler32);
934 } 932 }
935 933
936 if (stream->dec_del_ind != 0) 934 if (stream->dec_del_ind != 0)
937 { 935 {
938 VC(OUT "VCDIFF delta indicator: "); 936 VC(UT "VCDIFF delta indicator: ");
939 if ((stream->dec_del_ind & VCD_DATACOMP) != 0) VC(OUT "VCD_DATACOMP "); 937 if ((stream->dec_del_ind & VCD_DATACOMP) != 0) VC(UT "VCD_DATACOMP ");
940 if ((stream->dec_del_ind & VCD_INSTCOMP) != 0) VC(OUT "VCD_INSTCOMP "); 938 if ((stream->dec_del_ind & VCD_INSTCOMP) != 0) VC(UT "VCD_INSTCOMP ");
941 if ((stream->dec_del_ind & VCD_ADDRCOMP) != 0) VC(OUT "VCD_ADDRCOMP "); 939 if ((stream->dec_del_ind & VCD_ADDRCOMP) != 0) VC(UT "VCD_ADDRCOMP ");
942 if (stream->dec_del_ind == 0) VC(OUT "none"); 940 if (stream->dec_del_ind == 0) VC(UT "none");
943 VC(OUT "\n"); 941 VC(UT "\n");
944 } 942 }
945 943
946 if (stream->dec_winstart != 0) 944 if (stream->dec_winstart != 0)
947 { 945 {
948 VC(OUT "VCDIFF window at offset: %"Q"u\n", stream->dec_winstart); 946 VC(UT "VCDIFF window at offset: %"Q"u\n", stream->dec_winstart);
949 } 947 }
950 948
951 if (SRCORTGT (stream->dec_win_ind)) 949 if (SRCORTGT (stream->dec_win_ind))
952 { 950 {
953 VC(OUT "VCDIFF copy window length: %u\n", stream->dec_cpylen); 951 VC(UT "VCDIFF copy window length: %u\n", stream->dec_cpylen);
954 VC(OUT "VCDIFF copy window offset: %"Q"u\n", stream->dec_cpyoff); 952 VC(UT "VCDIFF copy window offset: %"Q"u\n", stream->dec_cpyoff);
955 } 953 }
956 954
957 VC(OUT "VCDIFF delta encoding length: %u\n", stream->dec_enclen); 955 VC(UT "VCDIFF delta encoding length: %u\n", stream->dec_enclen);
958 VC(OUT "VCDIFF target window length: %u\n", stream->dec_tgtlen); 956 VC(UT "VCDIFF target window length: %u\n", stream->dec_tgtlen);
959 957
960 VC(OUT "VCDIFF data section length: %u\n", stream->data_sect.size); 958 VC(UT "VCDIFF data section length: %u\n", stream->data_sect.size);
961 VC(OUT "VCDIFF inst section length: %u\n", stream->inst_sect.size); 959 VC(UT "VCDIFF inst section length: %u\n", stream->inst_sect.size);
962 VC(OUT "VCDIFF addr section length: %u\n", stream->addr_sect.size); 960 VC(UT "VCDIFF addr section length: %u\n", stream->addr_sect.size);
963 961
964 ret = 0; 962 ret = 0;
965 if ((stream->flags & XD3_JUST_HDR) != 0) 963 if ((stream->flags & XD3_JUST_HDR) != 0)
@@ -1278,7 +1276,9 @@ main_decompress_input_check (main_file *ifile,
1278 1276
1279 if (check_nread == XD3_ALLOCSIZE) 1277 if (check_nread == XD3_ALLOCSIZE)
1280 { 1278 {
1281 ret = main_file_read (ifile, input_buf + XD3_ALLOCSIZE, input_size - XD3_ALLOCSIZE, nread, "input read failed"); 1279 ret = main_file_read (ifile, input_buf + XD3_ALLOCSIZE,
1280 input_size - XD3_ALLOCSIZE, nread,
1281 "input read failed");
1282 } 1282 }
1283 1283
1284 memcpy (input_buf, check_buf, check_nread); 1284 memcpy (input_buf, check_buf, check_nread);
@@ -1878,7 +1878,7 @@ main_set_source (xd3_stream *stream, int cmd, main_file *sfile, xd3_source *sour
1878 { 1878 {
1879 XPR(NT "source file too large for external decompression: %s: %"Q"u\n", 1879 XPR(NT "source file too large for external decompression: %s: %"Q"u\n",
1880 sfile->filename, osize); 1880 sfile->filename, osize);
1881 return EFBIG; 1881 return XD3_INTERNAL;
1882 } 1882 }
1883 1883
1884 if ((ret = main_decompress_source (sfile, source))) 1884 if ((ret = main_decompress_source (sfile, source)))
@@ -2427,6 +2427,14 @@ done:
2427 main_file_close (ifile); 2427 main_file_close (ifile);
2428 main_file_close (sfile); 2428 main_file_close (sfile);
2429 2429
2430#if EXTERNAL_COMPRESSION
2431 if ((ret = main_external_compression_finish ()))
2432 {
2433 XPR(NT "external compression commands failed\n");
2434 return EXIT_FAILURE;
2435 }
2436#endif
2437
2430 /* If output file is not open yet because of delayed-open, it means we never encountered 2438 /* If output file is not open yet because of delayed-open, it means we never encountered
2431 * a window in the delta, but it could have had a VCDIFF header? TODO: solve this 2439 * a window in the delta, but it could have had a VCDIFF header? TODO: solve this
2432 * elsewhere. For now, it prints "nothing to output" below, but the check doesn't 2440 * elsewhere. For now, it prints "nothing to output" below, but the check doesn't
@@ -2452,10 +2460,6 @@ done:
2452 return EXIT_FAILURE; 2460 return EXIT_FAILURE;
2453 } 2461 }
2454 2462
2455#if EXTERNAL_COMPRESSION
2456 if ((ret = main_external_compression_finish ())) { return EXIT_FAILURE; }
2457#endif
2458
2459 xd3_free_stream (& stream); 2463 xd3_free_stream (& stream);
2460 2464
2461 if (option_verbose) 2465 if (option_verbose)
@@ -2463,9 +2467,6 @@ done:
2463 char tm[32]; 2467 char tm[32];
2464 long end_time = get_millisecs_now (); 2468 long end_time = get_millisecs_now ();
2465 XPR(NT "command finished in %s\n", main_format_millis (end_time - start_time, tm)); 2469 XPR(NT "command finished in %s\n", main_format_millis (end_time - start_time, tm));
2466 }
2467 if (option_verbose > 1)
2468 {
2469 XPR(NT "input bytes: %"Q"u\n", ifile->nread); 2470 XPR(NT "input bytes: %"Q"u\n", ifile->nread);
2470 XPR(NT "output bytes: %"Q"u\n", ofile->nwrite); 2471 XPR(NT "output bytes: %"Q"u\n", ofile->nwrite);
2471 } 2472 }
@@ -2513,7 +2514,7 @@ main (int argc, char **argv)
2513 main_file ifile; 2514 main_file ifile;
2514 main_file ofile; 2515 main_file ofile;
2515 main_file sfile; 2516 main_file sfile;
2516 static char *flags = "0123456789cdefhnqvDJNRTVs:B:C:E:F:L:O:P:M:W:A::S::"; 2517 static char *flags = "0123456789cdefhnqvDJNORTVs:B:C:E:F:L:O:P:M:W:A::S::";
2517 int my_optind; 2518 int my_optind;
2518 char *my_optarg; 2519 char *my_optarg;
2519 char *my_optstr; 2520 char *my_optstr;
@@ -2698,6 +2699,7 @@ main (int argc, char **argv)
2698 case 'T': option_use_altcodetable = 1; break; 2699 case 'T': option_use_altcodetable = 1; break;
2699 case 'C': option_smatch_config = my_optarg; break; 2700 case 'C': option_smatch_config = my_optarg; break;
2700 case 'J': option_no_output = 1; break; 2701 case 'J': option_no_output = 1; break;
2702 case 'O': option_xdelta1 = my_optarg; break;
2701 case 'S': if (my_optarg == NULL) { option_use_secondary = 0; } 2703 case 'S': if (my_optarg == NULL) { option_use_secondary = 0; }
2702 else { option_use_secondary = 1; option_secondary = my_optarg; } break; 2704 else { option_use_secondary = 1; option_secondary = my_optarg; } break;
2703 case 'A': if (my_optarg == NULL) { option_use_appheader = 0; } 2705 case 'A': if (my_optarg == NULL) { option_use_appheader = 0; }
@@ -2772,6 +2774,9 @@ main (int argc, char **argv)
2772 goto cleanup; 2774 goto cleanup;
2773 } 2775 }
2774 2776
2777 extcomp_types[1].recomp_cmdname = option_xdelta1;
2778 extcomp_types[1].decomp_cmdname = option_xdelta1;
2779
2775 if (option_verbose > 1) 2780 if (option_verbose > 1)
2776 { 2781 {
2777 int l = 1; 2782 int l = 1;
diff --git a/xdelta3/xdelta3.c b/xdelta3/xdelta3.c
index e2f4f28..828643a 100755
--- a/xdelta3/xdelta3.c
+++ b/xdelta3/xdelta3.c
@@ -637,7 +637,7 @@ const char* xd3_strerror (int ret)
637 case XD3_TOOFARBACK: return "XD3_TOOFARBACK"; 637 case XD3_TOOFARBACK: return "XD3_TOOFARBACK";
638 case XD3_INTERNAL: return "XD3_INTERNAL"; 638 case XD3_INTERNAL: return "XD3_INTERNAL";
639 } 639 }
640 return strerror (ret); 640 return strerror(ret);
641} 641}
642 642
643/******************************************************************************************/ 643/******************************************************************************************/
@@ -4007,6 +4007,7 @@ xd3_srcwin_move_point (xd3_stream *stream, usize_t *next_move_point)
4007 usize_t blkoff = stream->srcwin_cksum_pos % stream->src->blksize; 4007 usize_t blkoff = stream->srcwin_cksum_pos % stream->src->blksize;
4008 usize_t onblk = xd3_bytes_on_srcblk (stream->src, blkno); 4008 usize_t onblk = xd3_bytes_on_srcblk (stream->src, blkno);
4009 int ret; 4009 int ret;
4010 int diff;
4010 4011
4011 if (blkoff + stream->smatcher.large_look > onblk) 4012 if (blkoff + stream->smatcher.large_look > onblk)
4012 { 4013 {
@@ -4026,7 +4027,7 @@ xd3_srcwin_move_point (xd3_stream *stream, usize_t *next_move_point)
4026 } 4027 }
4027 4028
4028 onblk -= stream->smatcher.large_look; 4029 onblk -= stream->smatcher.large_look;
4029 int diff = logical_input_cksum_pos - stream->srcwin_cksum_pos; 4030 diff = logical_input_cksum_pos - stream->srcwin_cksum_pos;
4030 onblk = min(blkoff + diff, onblk); 4031 onblk = min(blkoff + diff, onblk);
4031 4032
4032 while (blkoff <= onblk) 4033 while (blkoff <= onblk)
@@ -4060,12 +4061,12 @@ xd3_source_cksum_offset(xd3_stream *stream, usize_t low)
4060 xoff_t scp = stream->srcwin_cksum_pos; 4061 xoff_t scp = stream->srcwin_cksum_pos;
4061 xoff_t s0 = scp >> 32; 4062 xoff_t s0 = scp >> 32;
4062 4063
4064 usize_t sr = (usize_t) scp;
4065
4063 if (s0 == 0) { 4066 if (s0 == 0) {
4064 return low; 4067 return low;
4065 } 4068 }
4066 4069
4067 usize_t sr = (usize_t) scp;
4068
4069 // This should not be >= because srcwin_cksum_pos is the next position to index 4070 // This should not be >= because srcwin_cksum_pos is the next position to index
4070 if (low > sr) { 4071 if (low > sr) {
4071 return (--s0 << 32) | low; 4072 return (--s0 << 32) | low;
diff --git a/xdelta3/xdelta3.h b/xdelta3/xdelta3.h
index 71fe681..1c1b7aa 100755
--- a/xdelta3/xdelta3.h
+++ b/xdelta3/xdelta3.h
@@ -104,9 +104,9 @@ typedef u_int32_t uint32_t;
104typedef u_int64_t uint64_t; 104typedef u_int64_t uint64_t;
105#else 105#else
106#include <windows.h> 106#include <windows.h>
107#define INLINE 107#define inline
108typedef unsigned int uint; 108typedef unsigned int uint;
109typedef unsigned int usize_t 109typedef unsigned int usize_t;
110typedef unsigned char uint8_t; 110typedef unsigned char uint8_t;
111typedef unsigned short uint16_t; 111typedef unsigned short uint16_t;
112typedef unsigned long uint32_t; 112typedef unsigned long uint32_t;
@@ -990,7 +990,7 @@ usize_t xd3_bytes_on_srcblk (xd3_source *source, xoff_t blkno)
990 return source->blksize; 990 return source->blksize;
991 } 991 }
992 992
993 return ((source->size - 1) % source->blksize) + 1; 993 return (usize_t)((source->size - 1) % source->blksize) + 1;
994} 994}
995 995
996#endif /* _XDELTA3_H_ */ 996#endif /* _XDELTA3_H_ */
diff --git a/xdelta3/xdelta3.vcproj b/xdelta3/xdelta3.vcproj
new file mode 100755
index 0000000..1a279e5
--- /dev/null
+++ b/xdelta3/xdelta3.vcproj
@@ -0,0 +1,238 @@
1<?xml version="1.0" encoding="Windows-1252"?>
2<VisualStudioProject
3 ProjectType="Visual C++"
4 Version="8.00"
5 Name="xdelta3"
6 ProjectGUID="{7F30EDF1-4493-4E47-8664-0661516BC9E4}"
7 Keyword="Win32Proj"
8 >
9 <Platforms>
10 <Platform
11 Name="Win32"
12 />
13 </Platforms>
14 <ToolFiles>
15 </ToolFiles>
16 <Configurations>
17 <Configuration
18 Name="Debug|Win32"
19 OutputDirectory="Debug"
20 IntermediateDirectory="Debug"
21 ConfigurationType="1"
22 >
23 <Tool
24 Name="VCPreBuildEventTool"
25 />
26 <Tool
27 Name="VCCustomBuildTool"
28 />
29 <Tool
30 Name="VCXMLDataGeneratorTool"
31 />
32 <Tool
33 Name="VCWebServiceProxyGeneratorTool"
34 />
35 <Tool
36 Name="VCMIDLTool"
37 />
38 <Tool
39 Name="VCCLCompilerTool"
40 AdditionalOptions="/DXD3_DEBUG=0 /DXD3_USE_LARGEFILE64=1 /DREGRESSION_TEST=1 /DSECONDARY_DJW=1 /DSECONDARY_FGK=1 /DXD3_MAIN=1 /DXD3_STDIO=1 /DEXTERNAL_COMPRESSION=0"
41 Optimization="0"
42 PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;"
43 MinimalRebuild="true"
44 BasicRuntimeChecks="3"
45 RuntimeLibrary="3"
46 UsePrecompiledHeader="0"
47 WarningLevel="3"
48 Detect64BitPortabilityProblems="true"
49 DebugInformationFormat="4"
50 />
51 <Tool
52 Name="VCManagedResourceCompilerTool"
53 />
54 <Tool
55 Name="VCResourceCompilerTool"
56 />
57 <Tool
58 Name="VCPreLinkEventTool"
59 />
60 <Tool
61 Name="VCLinkerTool"
62 LinkIncremental="2"
63 GenerateDebugInformation="true"
64 SubSystem="1"
65 TargetMachine="1"
66 />
67 <Tool
68 Name="VCALinkTool"
69 />
70 <Tool
71 Name="VCManifestTool"
72 />
73 <Tool
74 Name="VCXDCMakeTool"
75 />
76 <Tool
77 Name="VCBscMakeTool"
78 />
79 <Tool
80 Name="VCFxCopTool"
81 />
82 <Tool
83 Name="VCAppVerifierTool"
84 />
85 <Tool
86 Name="VCWebDeploymentTool"
87 />
88 <Tool
89 Name="VCPostBuildEventTool"
90 />
91 </Configuration>
92 <Configuration
93 Name="Release|Win32"
94 OutputDirectory="Release"
95 IntermediateDirectory="Release"
96 ConfigurationType="1"
97 >
98 <Tool
99 Name="VCPreBuildEventTool"
100 />
101 <Tool
102 Name="VCCustomBuildTool"
103 />
104 <Tool
105 Name="VCXMLDataGeneratorTool"
106 />
107 <Tool
108 Name="VCWebServiceProxyGeneratorTool"
109 />
110 <Tool
111 Name="VCMIDLTool"
112 />
113 <Tool
114 Name="VCCLCompilerTool"
115 PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;"
116 RuntimeLibrary="2"
117 UsePrecompiledHeader="0"
118 WarningLevel="3"
119 Detect64BitPortabilityProblems="true"
120 DebugInformationFormat="3"
121 />
122 <Tool
123 Name="VCManagedResourceCompilerTool"
124 />
125 <Tool
126 Name="VCResourceCompilerTool"
127 />
128 <Tool
129 Name="VCPreLinkEventTool"
130 />
131 <Tool
132 Name="VCLinkerTool"
133 LinkIncremental="2"
134 GenerateDebugInformation="true"
135 SubSystem="1"
136 OptimizeReferences="2"
137 EnableCOMDATFolding="2"
138 TargetMachine="1"
139 />
140 <Tool
141 Name="VCALinkTool"
142 />
143 <Tool
144 Name="VCManifestTool"
145 />
146 <Tool
147 Name="VCXDCMakeTool"
148 />
149 <Tool
150 Name="VCBscMakeTool"
151 />
152 <Tool
153 Name="VCFxCopTool"
154 />
155 <Tool
156 Name="VCAppVerifierTool"
157 />
158 <Tool
159 Name="VCWebDeploymentTool"
160 />
161 <Tool
162 Name="VCPostBuildEventTool"
163 />
164 </Configuration>
165 </Configurations>
166 <References>
167 </References>
168 <Files>
169 <Filter
170 Name="Header Files"
171 Filter="h;hpp;hxx;hm;inl;inc;xsd"
172 UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
173 >
174 <File
175 RelativePath=".\xdelta.h"
176 >
177 </File>
178 <File
179 RelativePath=".\xdelta3-cfgs.h"
180 >
181 </File>
182 <File
183 RelativePath=".\xdelta3-decode.h"
184 >
185 </File>
186 <File
187 RelativePath=".\xdelta3-djw.h"
188 >
189 </File>
190 <File
191 RelativePath=".\xdelta3-fgk.h"
192 >
193 </File>
194 <File
195 RelativePath=".\xdelta3-list.h"
196 >
197 </File>
198 <File
199 RelativePath=".\xdelta3-main.h"
200 >
201 </File>
202 <File
203 RelativePath=".\xdelta3-python.h"
204 >
205 </File>
206 <File
207 RelativePath=".\xdelta3-second.h"
208 >
209 </File>
210 <File
211 RelativePath=".\xdelta3-test.h"
212 >
213 </File>
214 <File
215 RelativePath=".\xdelta3.h"
216 >
217 </File>
218 </Filter>
219 <Filter
220 Name="Resource Files"
221 Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
222 UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
223 >
224 </Filter>
225 <Filter
226 Name="Source Files"
227 Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
228 UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
229 >
230 <File
231 RelativePath=".\xdelta3.c"
232 >
233 </File>
234 </Filter>
235 </Files>
236 <Globals>
237 </Globals>
238</VisualStudioProject>