summaryrefslogtreecommitdiff
path: root/xdelta3
diff options
context:
space:
mode:
Diffstat (limited to 'xdelta3')
-rw-r--r--xdelta3/Makefile.mingw303
-rw-r--r--xdelta3/xdelta3-main.h21
-rw-r--r--xdelta3/xdelta3.h28
3 files changed, 347 insertions, 5 deletions
diff --git a/xdelta3/Makefile.mingw b/xdelta3/Makefile.mingw
new file mode 100644
index 0000000..b91c4e7
--- /dev/null
+++ b/xdelta3/Makefile.mingw
@@ -0,0 +1,303 @@
1# xdelta 3 - delta compression tools and library
2# Copyright (C) 2001, 2003, 2004, 2005, 2006, 2007. Joshua P. MacDonald
3
4UNAME = $(shell uname)
5CYGWIN = $(findstring CYGWIN, $(UNAME))
6PYVER = 2.5
7
8ifeq ("$(CYGWIN)", "")
9SWIGTGT = xdelta3module.so
10PYTGT = build/lib.linux-i686-$(PYVER)/xdelta3main.so
11else
12SWIGTGT = xdelta3module.dll
13PYTGT = build/lib.cygwin-1.5.24-i686-$(PYVER)/xdelta3main.dll
14endif
15
16SOURCES = xdelta3-cfgs.h \
17 xdelta3-decode.h \
18 xdelta3-djw.h \
19 xdelta3-fgk.h \
20 xdelta3-hash.h \
21 xdelta3-list.h \
22 xdelta3-main.h \
23 xdelta3-python.h \
24 xdelta3-second.h \
25 xdelta3-test.h \
26 xdelta3.c \
27 xdelta3.h
28
29TARGETS = xdelta3-debug \
30 xdelta3 \
31 xdelta3-debug2 \
32 xdelta3-debug3 \
33 xdelta3.o \
34 xdelta3_wrap.o \
35 xdelta3-32 \
36 xdelta3-64 \
37 xdelta3-everything \
38 xdelta3-Opg \
39 xdelta3-64-O \
40 xdelta3-Op \
41 xdelta3-decoder xdelta3-decoder-nomain.o \
42 xdelta3-nosec.o xdelta3-all.o xdelta3-fgk.o \
43 xdelta3-noext xdelta3-tools \
44 xdelta3-notools \
45 xdelta3_wrap.c xdelta3.py \
46 $(PYTGT) $(SWIGTGT)
47
48PYTHON = python
49
50WIXDIR = "/cygdrive/c/Program Files/wix2.0.4820"
51
52CFLAGS= -Wall -Wshadow -fno-builtin
53
54# $Format: "REL=$Xdelta3Version$" $
55REL=3.0t
56
57RELDIR = xdelta$(REL)
58
59EXTRA = Makefile COPYING linkxd3lib.c badcopy.c xdelta3.swig \
60 draft-korn-vcdiff.txt xdelta3.vcproj badcopy.vcproj \
61 xdelta3-regtest.py xdelta3-test.py setup.py \
62 examples/Makefile examples/small_page_test.c \
63 examples/README examples/encode_decode_test.c \
64 examples/compare_test.c examples/speed_test.c \
65 examples/test.h examples/checksum_test.cc \
66 xdelta3.py xdelta3_wrap.c xdelta3.wxs xdelta3.wxi \
67 README readme.txt
68
69SWIG_FLAGS = -DXD3_DEBUG=0 \
70 -DEXTERNAL_COMPRESSION=0 \
71 -DXD3_USE_LARGEFILE64=1 \
72 -DGENERIC_ENCODE_TABLES=1 \
73 -DSECONDARY_DJW=1 \
74 -DVCDIFF_TOOLS=1 \
75 -DSWIG_MODULE=1
76
77all: xdelta3-debug xdelta3
78
79all-py: all $(PYTGT) $(SWIGTGT)
80
81all-targets: $(TARGETS)
82
83all-targets-test: all-targets test
84
85pytgt: $(PYTGT)
86swigtgt: $(SWIGTGT)
87
88test:
89 ./xdelta3-debug test
90
91tar:
92 tar --exclude ".svn" -czf /tmp/$(RELDIR)-tmp.tar.gz $(SOURCES) $(EXTRA)
93 rm -rf /tmp/$(RELDIR)
94 mkdir /tmp/$(RELDIR)
95 (cd /tmp/$(RELDIR) && tar -xzf ../$(RELDIR)-tmp.tar.gz)
96 tar -czf ./$(RELDIR).tar.gz -C /tmp $(RELDIR)
97 +tar -tzf ./$(RELDIR).tar.gz
98 rm -rf /tmp/$(RELDIR)
99
100zip:
101 tar --exclude ".svn" -czf /tmp/$(RELDIR)-tmp.tar.gz $(SOURCES) $(EXTRA)
102 rm -rf /tmp/$(RELDIR)
103 mkdir /tmp/$(RELDIR)
104 (cd /tmp/$(RELDIR) && tar -xzf ../$(RELDIR)-tmp.tar.gz)
105 tar -czf ./$(RELDIR).tar.gz -C /tmp $(RELDIR)
106 +zip -r $(RELDIR).zip /tmp/$(RELDIR)
107 rm -rf /tmp/$(RELDIR)
108
109clean:
110 rm -f $(TARGETS)
111 rm -rf build Debug Release core cifs* *.stackdump *.exe \
112 xdelta3.ncb xdelta3.suo xdelta3.sln xdelta3.wixobj xdelta3.msi
113
114wix: xdelta3.wxs xdelta3.wxi readme.txt Release\xdelta3.exe
115 $(WIXDIR)/candle.exe xdelta3.wxs -out xdelta3.wixobj
116 $(WIXDIR)/light.exe xdelta3.wixobj -out xdelta3.msi
117
118xdelta3: $(SOURCES)
119 $(CC) $(CFLAGS) -O3 xdelta3.c -lm -o xdelta3 \
120 -DGENERIC_ENCODE_TABLES=0 \
121 -DREGRESSION_TEST=1 \
122 -DEXTERNAL_COMPRESSION=0 \
123 -DSECONDARY_DJW=1 \
124 -DSECONDARY_FGK=1 \
125 -DXD3_DEBUG=0 \
126 -DXD3_MAIN=1 \
127 -DXD3_STDIO=0 -DXD3_POSIX=0 -DXD3_WIN32=1 \
128 -DXD3_USE_LARGEFILE64=1
129
130xdelta3-debug: $(SOURCES)
131 $(CC) -g $(CFLAGS) xdelta3.c -lm -o xdelta3-debug \
132 -DGENERIC_ENCODE_TABLES=1 \
133 -DREGRESSION_TEST=1 \
134 -DEXTERNAL_COMPRESSION=0 \
135 -DSECONDARY_DJW=1 \
136 -DSECONDARY_FGK=1 \
137 -DXD3_DEBUG=1 \
138 -DXD3_MAIN=1 \
139 -DXD3_STDIO=0 -DXD3_POSIX=0 -DXD3_WIN32=1 \
140 -DXD3_USE_LARGEFILE64=1
141
142xdelta3-32: $(SOURCES)
143 $(CC) -O3 $(CFLAGS) xdelta3.c -lm -o xdelta3-32 \
144 -DXD3_DEBUG=1 \
145 -DXD3_USE_LARGEFILE64=0 \
146 -DREGRESSION_TEST=1 \
147 -DEXTERNAL_COMPRESSION=0 \
148 -DSECONDARY_DJW=1 \
149 -DSECONDARY_FGK=1 \
150 -DXD3_MAIN=1 \
151 -DXD3_STDIO=0 -DXD3_POSIX=0 -DXD3_WIN32=1
152
153xdelta3-debug2: $(SOURCES)
154 $(CC) -g $(CFLAGS) \
155 xdelta3.c -o xdelta3-debug2 \
156 -DXD3_DEBUG=2 \
157 -DXD3_MAIN=1 \
158 -DXD3_STDIO=0 -DXD3_POSIX=0 -DXD3_WIN32=1 \
159 -DXD3_USE_LARGEFILE64=1 \
160 -DGENERIC_ENCODE_TABLES=1 \
161 -DREGRESSION_TEST=1 \
162 -DEXTERNAL_COMPRESSION=0 \
163 -DSECONDARY_DJW=1 \
164 -DSECONDARY_FGK=1 \
165 -lm
166
167xdelta3-debug3: $(SOURCES)
168 $(CC) -g $(CFLAGS) xdelta3.c -o xdelta3-debug3 \
169 -DXD3_MAIN=1 \
170 -DGENERIC_ENCODE_TABLES=1 \
171 -DXD3_USE_LARGEFILE64=1 \
172 -DXD3_STDIO=0 -DXD3_POSIX=0 -DXD3_WIN32=1 \
173 -DREGRESSION_TEST=1 \
174 -DXD3_DEBUG=3 \
175 -DEXTERNAL_COMPRESSION=0 \
176 -DSECONDARY_DJW=1 \
177 -DSECONDARY_FGK=1 \
178 -lm
179
180$(PYTGT): $(SOURCES) setup.py
181 $(PYTHON) setup.py install --verbose --compile --force
182
183xdelta3_wrap.c xdelta3.py: xdelta3.swig
184 swig -python xdelta3.swig
185
186xdelta3.o: $(SOURCES)
187 $(CC) -O3 $(CFLAGS) -c xdelta3.c $(SWIG_FLAGS) -o xdelta3.o
188
189xdelta3_wrap.o: xdelta3_wrap.c
190 $(CC) -O3 $(CFLAGS) $(SWIG_FLAGS) \
191 -DHAVE_CONFIG_H \
192 -I/usr/include/python$(PYVER) \
193 -I/usr/lib/python$(PYVER)/config \
194 -fpic \
195 -c xdelta3_wrap.c
196
197xdelta3module.dll: xdelta3_wrap.o xdelta3.o
198 gcc -shared -Wl,--enable-auto-image-base \
199 xdelta3.o \
200 xdelta3_wrap.o \
201 -L/usr/lib/python$(PYVER)/config \
202 -lpython$(PYVER) \
203 -o xdelta3module.dll
204 cp $(SWIGTGT) /usr/lib/python$(PYVER)/site-packages
205
206xdelta3module.so: xdelta3_wrap.o xdelta3.o
207 ld -shared xdelta3.o xdelta3_wrap.o \
208 -o xdelta3module.so \
209 /usr/lib/libpython$(PYVER).so \
210 -lc
211
212xdelta3-decoder: $(SOURCES)
213 $(CC) -O3 -Wall -Wshadow xdelta3.c \
214 -DXD3_ENCODER=0 -DXD3_MAIN=1 -DSECONDARY_FGK=0 -DSECONDARY_DJW=0 \
215 -DXD3_STDIO=0 -DXD3_POSIX=0 -DXD3_WIN32=1 -DEXTERNAL_COMPRESSION=0 -DVCDIFF_TOOLS=0 \
216 -o xdelta3-decoder
217
218xdelta3-decoder-nomain.o: $(SOURCES) linkxd3lib.c
219 $(CC) -O3 -Wall -Wshadow xdelta3.c linkxd3lib.c \
220 -DXD3_ENCODER=0 -DSECONDARY_FGK=0 -DSECONDARY_DJW=0 \
221 -o xdelta3-decoder-nomain.o
222 strip xdelta3-decoder-nomain.o
223
224xdelta3-O++: $(SOURCES)
225 $(CXX) -g -O3 $(CFLAGS) xdelta3.c \
226 -o xdelta3-O++ \
227 -DXD3_MAIN=1 \
228 -DSECONDARY_DJW=1 \
229 -DREGRESSION_TEST=1 \
230 -lm
231
232xdelta3-Op: $(SOURCES)
233 $(CC) -g -O3 $(CFLAGS) xdelta3.c \
234 -o xdelta3-Op \
235 -DXD3_POSIX=1 \
236 -DXD3_MAIN=1 \
237 -DREGRESSION_TEST=1 \
238 -lm
239
240xdelta3-64: $(SOURCES)
241 $(CC) -g $(CFLAGS) \
242 xdelta3.c \
243 -o xdelta3-64 \
244 -DXD3_POSIX=1 \
245 -DXD3_MAIN=1 \
246 -DREGRESSION_TEST=1 \
247 -DXD3_DEBUG=0 \
248 -DXD3_USE_LARGEFILE64=1 \
249 -lm
250
251xdelta3-64-O: $(SOURCES)
252 $(CC) -O3 $(CFLAGS) \
253 xdelta3.c \
254 -o xdelta3-64-O \
255 -DXD3_POSIX=1 \
256 -DXD3_MAIN=1 \
257 -DXD3_USE_LARGEFILE64=1 \
258 -lm
259
260xdelta3-everything: $(SOURCES)
261 $(CC) -g $(CFLAGS) \
262 xdelta3.c \
263 -o xdelta3-everything \
264 -DXD3_MAIN=1 \
265 -DVCDIFF_TOOLS=1 \
266 -DREGRESSION_TEST=1 \
267 -DSECONDARY_FGK=1 \
268 -DSECONDARY_DJW=1 \
269 -DGENERIC_ENCODE_TABLES=1 \
270 -DGENERIC_ENCODE_TABLES_COMPUTE=1 \
271 -DXD3_POSIX=1 \
272 -DEXTERNAL_COMPRESSION=1 \
273 -DXD3_DEBUG=1 \
274 -lm
275
276xdelta3-Opg: $(SOURCES)
277 $(CC) -pg -g -O3 $(CFLAGS) \
278 xdelta3.c \
279 -o xdelta3-Opg \
280 -DXD3_MAIN=1 \
281 -DSECONDARY_DJW=1 \
282 -DSECONDARY_FGK=1 \
283 -DXD3_POSIX=1 \
284 -DXD3_USE_LARGEFILE64=1 \
285 -DREGRESSION_TEST=1
286
287xdelta3-nosec.o: $(SOURCES)
288 $(CC) -O3 $(CFLAGS) -c xdelta3.c -DSECONDARY_FGK=0 -DSECONDARY_DJW=0 -o xdelta3-nosec.o
289
290xdelta3-all.o: $(SOURCES)
291 $(CC) -O3 $(CFLAGS) -c xdelta3.c -DSECONDARY_FGK=1 -DSECONDARY_DJW=1 -o xdelta3-all.o
292
293xdelta3-fgk.o: $(SOURCES)
294 $(CC) -O3 $(CFLAGS) -c xdelta3.c -DSECONDARY_FGK=1 -DSECONDARY_DJW=0 -o xdelta3-fgk.o
295
296xdelta3-noext: $(SOURCES)
297 $(CC) -O3 $(CFLAGS) xdelta3.c -DXD3_MAIN=1 -DEXTERNAL_COMPRESSION=0 -o xdelta3-noext
298
299xdelta3-tools: $(SOURCES)
300 $(CC) -O3 $(CFLAGS) xdelta3.c -DXD3_MAIN=1 -o xdelta3-tools
301
302xdelta3-notools: $(SOURCES)
303 $(CC) -O3 $(CFLAGS) xdelta3.c -DXD3_MAIN=1 -DVCDIFF_TOOLS=0 -o xdelta3-notools
diff --git a/xdelta3/xdelta3-main.h b/xdelta3/xdelta3-main.h
index cfff0fc..d0f90fe 100644
--- a/xdelta3/xdelta3-main.h
+++ b/xdelta3/xdelta3-main.h
@@ -106,7 +106,9 @@ const char* xd3_mainerror(int err_num);
106#include <sys/time.h> /* gettimeofday() */ 106#include <sys/time.h> /* gettimeofday() */
107#include <sys/stat.h> /* stat() and fstat() */ 107#include <sys/stat.h> /* stat() and fstat() */
108#else 108#else
109#if defined(_MSC_VER)
109#define strtoll _strtoi64 110#define strtoll _strtoi64
111#endif
110#include <sys/types.h> 112#include <sys/types.h>
111#include <sys/stat.h> 113#include <sys/stat.h>
112#ifndef WIFEXITED 114#ifndef WIFEXITED
@@ -841,6 +843,7 @@ main_file_stat (main_file *xfile, xoff_t *size, int err_ifnoseek)
841{ 843{
842 int ret = 0; 844 int ret = 0;
843#if XD3_WIN32 845#if XD3_WIN32
846# if (_WIN32_WINNT >= 0x0500)
844 LARGE_INTEGER li; 847 LARGE_INTEGER li;
845 if (GetFileSizeEx(xfile->file, &li) == 0) 848 if (GetFileSizeEx(xfile->file, &li) == 0)
846 { 849 {
@@ -850,6 +853,16 @@ main_file_stat (main_file *xfile, xoff_t *size, int err_ifnoseek)
850 { 853 {
851 *size = li.QuadPart; 854 *size = li.QuadPart;
852 } 855 }
856# else
857 DWORD filesize = GetFileSize(xfile->file, NULL);
858 if (filesize == INVALID_FILE_SIZE)
859 {
860 ret = GetLastError();
861 if (ret != NO_ERROR)
862 return ret;
863 }
864 *size = filesize;
865# endif
853#else 866#else
854 struct stat sbuf; 867 struct stat sbuf;
855 if (fstat (XFNO (xfile), & sbuf) < 0) 868 if (fstat (XFNO (xfile), & sbuf) < 0)
@@ -1024,11 +1037,19 @@ main_file_seek (main_file *xfile, xoff_t pos)
1024 { ret = get_errno (); } 1037 { ret = get_errno (); }
1025 1038
1026#elif XD3_WIN32 1039#elif XD3_WIN32
1040# if (_WIN32_WINNT >= 0x0500)
1027 LARGE_INTEGER move, out; 1041 LARGE_INTEGER move, out;
1028 move.QuadPart = pos; 1042 move.QuadPart = pos;
1029 if (SetFilePointerEx(xfile->file, move, &out, FILE_BEGIN) == 0) { 1043 if (SetFilePointerEx(xfile->file, move, &out, FILE_BEGIN) == 0) {
1030 ret = get_errno (); 1044 ret = get_errno ();
1031 } 1045 }
1046# else
1047 if (SetFilePointer(xfile->file, (LONG)pos, NULL, FILE_BEGIN) ==
1048 INVALID_SET_FILE_POINTER)
1049 {
1050 ret = get_errno ();
1051 }
1052# endif
1032#endif 1053#endif
1033 1054
1034 if (ret) 1055 if (ret)
diff --git a/xdelta3/xdelta3.h b/xdelta3/xdelta3.h
index adc78c9..0cf6d6b 100644
--- a/xdelta3/xdelta3.h
+++ b/xdelta3/xdelta3.h
@@ -84,6 +84,10 @@
84#define XD3_DEFAULT_SECONDARY_LEVEL 6 84#define XD3_DEFAULT_SECONDARY_LEVEL 6
85#endif 85#endif
86 86
87#ifndef XD3_USE_LARGEFILE64
88#define XD3_USE_LARGEFILE64 1
89#endif
90
87/* Sizes and addresses within VCDIFF windows are represented as usize_t 91/* Sizes and addresses within VCDIFF windows are represented as usize_t
88 * 92 *
89 * For source-file offsets and total file sizes, total input and 93 * For source-file offsets and total file sizes, total input and
@@ -96,19 +100,33 @@
96typedef unsigned int usize_t; 100typedef unsigned int usize_t;
97#else 101#else
98#define WIN32_LEAN_AND_MEAN 102#define WIN32_LEAN_AND_MEAN
103#if XD3_USE_LARGEFILE64
104/* 64 bit file offsets: uses GetFileSizeEx and
105 * SetFilePointerEx. requires WinME, or Win2000
106 * and or newer version of WinNT */
107#define WINVER 0x0500
108#define _WIN32_WINNT 0x0500
109#else
110/* 32 bit (DWORD) file offsets: uses GetFileSize
111 * and SetFilePointer. compatible with win95-98
112 * and WinNT4 */
113#define WINVER 0x0400
114#define _WIN32_WINNT 0x0400
115#endif
99#include <windows.h> 116#include <windows.h>
117typedef unsigned int usize_t;
118#ifdef _MSC_VER
100#define inline 119#define inline
101typedef unsigned int uint;
102typedef signed int ssize_t; 120typedef signed int ssize_t;
103typedef unsigned int usize_t;
104typedef unsigned char uint8_t; 121typedef unsigned char uint8_t;
105typedef unsigned short uint16_t; 122typedef unsigned short uint16_t;
106typedef unsigned long uint32_t; 123typedef unsigned long uint32_t;
107typedef ULONGLONG uint64_t; 124typedef ULONGLONG uint64_t;
125#else
126/* mingw32, lcc and watcom
127 * provide a proper header */
128#include <stdint.h>
108#endif 129#endif
109
110#ifndef XD3_USE_LARGEFILE64
111#define XD3_USE_LARGEFILE64 1
112#endif 130#endif
113 131
114/* TODO: note that SIZEOF_USIZE_T is never set to 8, although it should be for 132/* TODO: note that SIZEOF_USIZE_T is never set to 8, although it should be for