summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xxdelta3/Makefile26
-rwxr-xr-xxdelta3/xdelta3-decode.h60
-rwxr-xr-xxdelta3/xdelta3-main.h2
-rwxr-xr-xxdelta3/xdelta3-regtest.py58
-rwxr-xr-xxdelta3/xdelta3-test.h15
-rwxr-xr-xxdelta3/xdelta3-test.py131
-rwxr-xr-xxdelta3/xdelta3.c65
-rwxr-xr-xxdelta3/xdelta3.h5
-rwxr-xr-xxdelta3/xdelta3.prj29
-rwxr-xr-xxdelta3/xdelta3.swig72
10 files changed, 354 insertions, 109 deletions
diff --git a/xdelta3/Makefile b/xdelta3/Makefile
index 4b25ab7..6137966 100755
--- a/xdelta3/Makefile
+++ b/xdelta3/Makefile
@@ -1,8 +1,6 @@
1# xdelta 3 - delta compression tools and library 1# xdelta 3 - delta compression tools and library
2# Copyright (C) 2001, 2003, 2004, 2005, 2006. Joshua P. MacDonald 2# Copyright (C) 2001, 2003, 2004, 2005, 2006. Joshua P. MacDonald
3 3
4CC=gcc-4.1.1
5
6SOURCES = xdelta3-cfgs.h \ 4SOURCES = xdelta3-cfgs.h \
7 xdelta3-decode.h \ 5 xdelta3-decode.h \
8 xdelta3-djw.h \ 6 xdelta3-djw.h \
@@ -20,6 +18,7 @@ TARGETS = xdelta3-debug \
20 xdelta3-debug2 \ 18 xdelta3-debug2 \
21 xdelta3-debug3 \ 19 xdelta3-debug3 \
22 xdelta3.o \ 20 xdelta3.o \
21 xdelta3_wrap.o \
23 xdelta3module.so \ 22 xdelta3module.so \
24 xdelta3-32 \ 23 xdelta3-32 \
25 xdelta3-64 \ 24 xdelta3-64 \
@@ -39,12 +38,20 @@ PYTGT = build/lib.linux-i686-2.4/xdelta3.so
39PYFILES = xdelta3-regtest.py setup.py 38PYFILES = xdelta3-regtest.py setup.py
40 39
41EXTRA = Makefile COPYING linkxd3lib.c badcopy.c xdelta3.swig \ 40EXTRA = Makefile COPYING linkxd3lib.c badcopy.c xdelta3.swig \
42 draft-korn-vcdiff.txt xdelta3.vcproj badcopy.vcproj 41 draft-korn-vcdiff.txt xdelta3.vcproj badcopy.vcproj \
42 xdelta3.py xdelta3_wrap.c
43 43
44# $Format: "REL=$Xdelta3Version$" $ 44# $Format: "REL=$Xdelta3Version$" $
45REL=0o 45REL=0o
46RELDIR = xdelta3$(REL) 46RELDIR = xdelta3$(REL)
47 47
48SWIG_FLAGS = -DXD3_DEBUG=0 \
49 -DXD3_USE_LARGEFILE64=1 \
50 -DSECONDARY_DJW=1 \
51 -DVCDIFF_TOOLS=1 \
52 -DSWIG_MODULE=1 \
53 -O3
54
48all: xdelta3-debug xdelta3 $(PYTGT) 55all: xdelta3-debug xdelta3 $(PYTGT)
49 56
50all-targets: $(TARGETS) 57all-targets: $(TARGETS)
@@ -98,21 +105,18 @@ xdelta3_wrap.c xdelta3.py: xdelta3.swig
98 swig -python xdelta3.swig 105 swig -python xdelta3.swig
99 106
100xdelta3.o: $(SOURCES) 107xdelta3.o: $(SOURCES)
101 $(CC) -O3 -Wall -Wshadow -c xdelta3.c -DSECONDARY_DJW=1 -o xdelta3.o 108 $(CC) -g -Wall -Wshadow -c xdelta3.c $(SWIG_FLAGS) -o xdelta3.o
102 109
103xdelta3_wrap.o: xdelta3_wrap.c 110xdelta3_wrap.o: xdelta3_wrap.c
104 $(CC) -DXD3_DEBUG=0 \ 111 $(CC) $(SWIG_FLAGS) \
105 -DXD3_USE_LARGEFILE64=1 \ 112 -DHAVE_CONFIG_H \
106 -DSECONDARY_DJW=1 \
107 -DXD3_MAIN=0 \
108 -DHAVE_CONFIG_H \
109 -I/usr/include/python2.4 \ 113 -I/usr/include/python2.4 \
110 -I/usr/lib/python2.4/config \ 114 -I/usr/lib/python2.4/config \
111 -fpic \ 115 -fpic \
112 -c xdelta3_wrap.c 116 -c -g xdelta3_wrap.c
113 117
114xdelta3module.so: xdelta3_wrap.o xdelta3.o 118xdelta3module.so: xdelta3_wrap.o xdelta3.o
115 ld -shared xdelta3.o xdelta3_wrap.o -o xdelta3module.so /usr/lib/libpython2.4.so 119 ld -shared xdelta3.o xdelta3_wrap.o -o xdelta3module.so /usr/lib/libpython2.4.so -lgcc_s -lc
116 120
117xdelta3-decoder: $(SOURCES) 121xdelta3-decoder: $(SOURCES)
118 $(CC) -O2 -Wall -Wshadow xdelta3.c \ 122 $(CC) -O2 -Wall -Wshadow xdelta3.c \
diff --git a/xdelta3/xdelta3-decode.h b/xdelta3/xdelta3-decode.h
index 7f62c23..b1b5b88 100755
--- a/xdelta3/xdelta3-decode.h
+++ b/xdelta3/xdelta3-decode.h
@@ -58,7 +58,7 @@ xd3_decode_setup_buffers (xd3_stream *stream)
58 if (stream->dec_cpyoff < stream->dec_laststart) 58 if (stream->dec_cpyoff < stream->dec_laststart)
59 { 59 {
60 stream->msg = "unsupported VCD_TARGET offset"; 60 stream->msg = "unsupported VCD_TARGET offset";
61 return XD3_INTERNAL; 61 return XD3_INVALID_INPUT;
62 } 62 }
63 63
64 /* See if the two windows are the same. This indicates the first time VCD_TARGET is 64 /* See if the two windows are the same. This indicates the first time VCD_TARGET is
@@ -210,7 +210,7 @@ xd3_decode_parse_halfinst (xd3_stream *stream, xd3_hinst *inst)
210 stream->inst_sect.buf_max, 210 stream->inst_sect.buf_max,
211 & inst->size))) 211 & inst->size)))
212 { 212 {
213 return XD3_INTERNAL; 213 return XD3_INVALID_INPUT;
214 } 214 }
215 215
216 /* For copy instructions, read address. */ 216 /* For copy instructions, read address. */
@@ -240,7 +240,7 @@ xd3_decode_parse_halfinst (xd3_stream *stream, xd3_hinst *inst)
240 if (inst->addr >= stream->dec_position) 240 if (inst->addr >= stream->dec_position)
241 { 241 {
242 stream->msg = "address too large"; 242 stream->msg = "address too large";
243 return XD3_INTERNAL; 243 return XD3_INVALID_INPUT;
244 } 244 }
245 245
246 /* Check: a VCD_TARGET or VCD_SOURCE copy cannot exceed the remaining buffer space 246 /* Check: a VCD_TARGET or VCD_SOURCE copy cannot exceed the remaining buffer space
@@ -248,7 +248,7 @@ xd3_decode_parse_halfinst (xd3_stream *stream, xd3_hinst *inst)
248 if (inst->addr < stream->dec_cpylen && inst->addr + inst->size > stream->dec_cpylen) 248 if (inst->addr < stream->dec_cpylen && inst->addr + inst->size > stream->dec_cpylen)
249 { 249 {
250 stream->msg = "size too large"; 250 stream->msg = "size too large";
251 return XD3_INTERNAL; 251 return XD3_INVALID_INPUT;
252 } 252 }
253 } 253 }
254 else 254 else
@@ -280,7 +280,7 @@ xd3_decode_parse_halfinst (xd3_stream *stream, xd3_hinst *inst)
280 if (stream->dec_position + inst->size > stream->dec_maxpos) 280 if (stream->dec_position + inst->size > stream->dec_maxpos)
281 { 281 {
282 stream->msg = "size too large"; 282 stream->msg = "size too large";
283 return XD3_INTERNAL; 283 return XD3_INVALID_INPUT;
284 } 284 }
285 285
286 stream->dec_position += inst->size; 286 stream->dec_position += inst->size;
@@ -297,7 +297,7 @@ xd3_decode_instruction (xd3_stream *stream)
297 if (stream->inst_sect.buf == stream->inst_sect.buf_max) 297 if (stream->inst_sect.buf == stream->inst_sect.buf_max)
298 { 298 {
299 stream->msg = "instruction underflow"; 299 stream->msg = "instruction underflow";
300 return XD3_INTERNAL; 300 return XD3_INVALID_INPUT;
301 } 301 }
302 302
303 inst = &stream->code_table[*stream->inst_sect.buf++]; 303 inst = &stream->code_table[*stream->inst_sect.buf++];
@@ -338,7 +338,7 @@ xd3_decode_output_halfinst (xd3_stream *stream, xd3_hinst *inst)
338 if (stream->data_sect.buf == stream->data_sect.buf_max) 338 if (stream->data_sect.buf == stream->data_sect.buf_max)
339 { 339 {
340 stream->msg = "data underflow"; 340 stream->msg = "data underflow";
341 return XD3_INTERNAL; 341 return XD3_INVALID_INPUT;
342 } 342 }
343 343
344 /* TUNE: Probably want to eliminate memset/memcpy here */ 344 /* TUNE: Probably want to eliminate memset/memcpy here */
@@ -357,7 +357,7 @@ xd3_decode_output_halfinst (xd3_stream *stream, xd3_hinst *inst)
357 if (stream->data_sect.buf + take > stream->data_sect.buf_max) 357 if (stream->data_sect.buf + take > stream->data_sect.buf_max)
358 { 358 {
359 stream->msg = "data underflow"; 359 stream->msg = "data underflow";
360 return XD3_INTERNAL; 360 return XD3_INVALID_INPUT;
361 } 361 }
362 362
363 memcpy (stream->next_out + stream->avail_out, 363 memcpy (stream->next_out + stream->avail_out,
@@ -426,7 +426,7 @@ xd3_decode_output_halfinst (xd3_stream *stream, xd3_hinst *inst)
426 if ((source->onblk != blksize) && (blkoff + take > source->onblk)) 426 if ((source->onblk != blksize) && (blkoff + take > source->onblk))
427 { 427 {
428 stream->msg = "source file too short"; 428 stream->msg = "source file too short";
429 return XD3_INTERNAL; 429 return XD3_INVALID_INPUT;
430 430
431 } 431 }
432 432
@@ -549,7 +549,7 @@ xd3_decode_sections (xd3_stream *stream)
549 { 549 {
550 default: 550 default:
551 stream->msg = "internal error"; 551 stream->msg = "internal error";
552 return XD3_INTERNAL; 552 return XD3_INVALID_INPUT;
553 553
554 case DEC_DATA: 554 case DEC_DATA:
555 if ((ret = xd3_decode_section (stream, & stream->data_sect, DEC_INST, copy))) { return ret; } 555 if ((ret = xd3_decode_section (stream, & stream->data_sect, DEC_INST, copy))) { return ret; }
@@ -625,19 +625,19 @@ xd3_decode_emit (xd3_stream *stream)
625 { 625 {
626 IF_DEBUG1 (P(RINT "AVAIL_OUT(%d) != DEC_TGTLEN(%d)\n", stream->avail_out, stream->dec_tgtlen)); 626 IF_DEBUG1 (P(RINT "AVAIL_OUT(%d) != DEC_TGTLEN(%d)\n", stream->avail_out, stream->dec_tgtlen));
627 stream->msg = "wrong window length"; 627 stream->msg = "wrong window length";
628 return XD3_INTERNAL; 628 return XD3_INVALID_INPUT;
629 } 629 }
630 630
631 if (stream->data_sect.buf != stream->data_sect.buf_max) 631 if (stream->data_sect.buf != stream->data_sect.buf_max)
632 { 632 {
633 stream->msg = "extra data section"; 633 stream->msg = "extra data section";
634 return XD3_INTERNAL; 634 return XD3_INVALID_INPUT;
635 } 635 }
636 636
637 if (stream->addr_sect.buf != stream->addr_sect.buf_max) 637 if (stream->addr_sect.buf != stream->addr_sect.buf_max)
638 { 638 {
639 stream->msg = "extra address section"; 639 stream->msg = "extra address section";
640 return XD3_INTERNAL; 640 return XD3_INVALID_INPUT;
641 } 641 }
642 642
643 /* OPT: Should cksum computation be combined with the above loop? */ 643 /* OPT: Should cksum computation be combined with the above loop? */
@@ -649,7 +649,7 @@ xd3_decode_emit (xd3_stream *stream)
649 if (a32 != stream->dec_adler32) 649 if (a32 != stream->dec_adler32)
650 { 650 {
651 stream->msg = "target window checksum mismatch"; 651 stream->msg = "target window checksum mismatch";
652 return XD3_INTERNAL; 652 return XD3_INVALID_INPUT;
653 } 653 }
654 } 654 }
655 655
@@ -665,7 +665,7 @@ xd3_decode_input (xd3_stream *stream)
665 if (stream->enc_state != 0) 665 if (stream->enc_state != 0)
666 { 666 {
667 stream->msg = "encoder/decoder transition"; 667 stream->msg = "encoder/decoder transition";
668 return XD3_INTERNAL; 668 return XD3_INVALID_INPUT;
669 } 669 }
670 670
671#define BYTE_CASE(expr,x,nstate) \ 671#define BYTE_CASE(expr,x,nstate) \
@@ -703,13 +703,13 @@ xd3_decode_input (xd3_stream *stream)
703 stream->dec_magic[2] != VCDIFF_MAGIC3) 703 stream->dec_magic[2] != VCDIFF_MAGIC3)
704 { 704 {
705 stream->msg = "not a VCDIFF input"; 705 stream->msg = "not a VCDIFF input";
706 return XD3_INTERNAL; 706 return XD3_INVALID_INPUT;
707 } 707 }
708 708
709 if (stream->dec_magic[3] != 0) 709 if (stream->dec_magic[3] != 0)
710 { 710 {
711 stream->msg = "VCDIFF input version > 0 is not supported"; 711 stream->msg = "VCDIFF input version > 0 is not supported";
712 return XD3_INTERNAL; 712 return XD3_INVALID_INPUT;
713 } 713 }
714 714
715 stream->dec_state = DEC_HDRIND; 715 stream->dec_state = DEC_HDRIND;
@@ -721,7 +721,7 @@ xd3_decode_input (xd3_stream *stream)
721 if ((stream->dec_hdr_ind & VCD_INVHDR) != 0) 721 if ((stream->dec_hdr_ind & VCD_INVHDR) != 0)
722 { 722 {
723 stream->msg = "unrecognized header indicator bits set"; 723 stream->msg = "unrecognized header indicator bits set";
724 return XD3_INTERNAL; 724 return XD3_INVALID_INPUT;
725 } 725 }
726 726
727 stream->dec_state = DEC_SECONDID; 727 stream->dec_state = DEC_SECONDID;
@@ -741,7 +741,7 @@ xd3_decode_input (xd3_stream *stream)
741 DJW_CASE (stream); 741 DJW_CASE (stream);
742 default: 742 default:
743 stream->msg = "unknown secondary compressor ID"; 743 stream->msg = "unknown secondary compressor ID";
744 return XD3_INTERNAL; 744 return XD3_INVALID_INPUT;
745 } 745 }
746 } 746 }
747 747
@@ -828,7 +828,7 @@ xd3_decode_input (xd3_stream *stream)
828 if (XOFF_T_OVERFLOW (stream->dec_winstart, stream->dec_tgtlen)) 828 if (XOFF_T_OVERFLOW (stream->dec_winstart, stream->dec_tgtlen))
829 { 829 {
830 stream->msg = "decoder file offset overflow"; 830 stream->msg = "decoder file offset overflow";
831 return XD3_INTERNAL; 831 return XD3_INVALID_INPUT;
832 } 832 }
833 833
834 stream->dec_winstart += stream->dec_tgtlen; 834 stream->dec_winstart += stream->dec_tgtlen;
@@ -836,7 +836,7 @@ xd3_decode_input (xd3_stream *stream)
836 if ((stream->dec_win_ind & VCD_INVWIN) != 0) 836 if ((stream->dec_win_ind & VCD_INVWIN) != 0)
837 { 837 {
838 stream->msg = "unrecognized window indicator bits set"; 838 stream->msg = "unrecognized window indicator bits set";
839 return XD3_INTERNAL; 839 return XD3_INVALID_INPUT;
840 } 840 }
841 841
842 if ((ret = xd3_decode_init_window (stream))) { return ret; } 842 if ((ret = xd3_decode_init_window (stream))) { return ret; }
@@ -863,7 +863,7 @@ xd3_decode_input (xd3_stream *stream)
863 if (XOFF_T_OVERFLOW (stream->dec_cpyoff, stream->dec_cpylen)) 863 if (XOFF_T_OVERFLOW (stream->dec_cpyoff, stream->dec_cpylen))
864 { 864 {
865 stream->msg = "decoder copy window overflows a file offset"; 865 stream->msg = "decoder copy window overflows a file offset";
866 return XD3_INTERNAL; 866 return XD3_INVALID_INPUT;
867 } 867 }
868 868
869 /* Check copy window bounds: VCD_TARGET window may not exceed current position. */ 869 /* Check copy window bounds: VCD_TARGET window may not exceed current position. */
@@ -871,7 +871,7 @@ xd3_decode_input (xd3_stream *stream)
871 (stream->dec_cpyoff + (xoff_t) stream->dec_cpylen > stream->dec_winstart)) 871 (stream->dec_cpyoff + (xoff_t) stream->dec_cpylen > stream->dec_winstart))
872 { 872 {
873 stream->msg = "VCD_TARGET window out of bounds"; 873 stream->msg = "VCD_TARGET window out of bounds";
874 return XD3_INTERNAL; 874 return XD3_INVALID_INPUT;
875 } 875 }
876 876
877 case DEC_ENCLEN: 877 case DEC_ENCLEN:
@@ -887,14 +887,14 @@ xd3_decode_input (xd3_stream *stream)
887 if (USIZE_T_OVERFLOW (stream->dec_cpylen, stream->dec_tgtlen)) 887 if (USIZE_T_OVERFLOW (stream->dec_cpylen, stream->dec_tgtlen))
888 { 888 {
889 stream->msg = "decoder target window overflows a usize_t"; 889 stream->msg = "decoder target window overflows a usize_t";
890 return XD3_INTERNAL; 890 return XD3_INVALID_INPUT;
891 } 891 }
892 892
893 /* Check for malicious files. */ 893 /* Check for malicious files. */
894 if (stream->dec_tgtlen > XD3_HARDMAXWINSIZE) 894 if (stream->dec_tgtlen > XD3_HARDMAXWINSIZE)
895 { 895 {
896 stream->msg = "hard window size exceeded"; 896 stream->msg = "hard window size exceeded";
897 return XD3_INTERNAL; 897 return XD3_INVALID_INPUT;
898 } 898 }
899 899
900 stream->dec_maxpos = stream->dec_cpylen + stream->dec_tgtlen; 900 stream->dec_maxpos = stream->dec_cpylen + stream->dec_tgtlen;
@@ -906,14 +906,14 @@ xd3_decode_input (xd3_stream *stream)
906 if ((stream->dec_del_ind & VCD_INVDEL) != 0) 906 if ((stream->dec_del_ind & VCD_INVDEL) != 0)
907 { 907 {
908 stream->msg = "unrecognized delta indicator bits set"; 908 stream->msg = "unrecognized delta indicator bits set";
909 return XD3_INTERNAL; 909 return XD3_INVALID_INPUT;
910 } 910 }
911 911
912 /* Delta indicator is only used with secondary compression. */ 912 /* Delta indicator is only used with secondary compression. */
913 if ((stream->dec_del_ind != 0) && (stream->sec_type == NULL)) 913 if ((stream->dec_del_ind != 0) && (stream->sec_type == NULL))
914 { 914 {
915 stream->msg = "invalid delta indicator bits set"; 915 stream->msg = "invalid delta indicator bits set";
916 return XD3_INTERNAL; 916 return XD3_INVALID_INPUT;
917 } 917 }
918 918
919 /* Section lengths */ 919 /* Section lengths */
@@ -954,7 +954,7 @@ xd3_decode_input (xd3_stream *stream)
954 if (stream->dec_enclen != enclen_check) 954 if (stream->dec_enclen != enclen_check)
955 { 955 {
956 stream->msg = "incorrect encoding length (redundent)"; 956 stream->msg = "incorrect encoding length (redundent)";
957 return XD3_INTERNAL; 957 return XD3_INVALID_INPUT;
958 } 958 }
959 } 959 }
960 960
@@ -980,7 +980,7 @@ xd3_decode_input (xd3_stream *stream)
980 if (src == NULL) 980 if (src == NULL)
981 { 981 {
982 stream->msg = "source input required"; 982 stream->msg = "source input required";
983 return XD3_INTERNAL; 983 return XD3_INVALID_INPUT;
984 } 984 }
985 985
986 src->cpyoff_blocks = stream->dec_cpyoff / src->blksize; 986 src->cpyoff_blocks = stream->dec_cpyoff / src->blksize;
@@ -1023,7 +1023,7 @@ xd3_decode_input (xd3_stream *stream)
1023 1023
1024 default: 1024 default:
1025 stream->msg = "invalid state"; 1025 stream->msg = "invalid state";
1026 return XD3_INTERNAL; 1026 return XD3_INVALID_INPUT;
1027 } 1027 }
1028} 1028}
1029 1029
diff --git a/xdelta3/xdelta3-main.h b/xdelta3/xdelta3-main.h
index 9e47d61..fd50c24 100755
--- a/xdelta3/xdelta3-main.h
+++ b/xdelta3/xdelta3-main.h
@@ -2811,7 +2811,7 @@ main_cleanup (void)
2811} 2811}
2812 2812
2813int 2813int
2814#if PYTHON_MODULE 2814#if PYTHON_MODULE || SWIG_MODULE
2815xd3_main_cmdline (int argc, char **argv) 2815xd3_main_cmdline (int argc, char **argv)
2816#else 2816#else
2817main (int argc, char **argv) 2817main (int argc, char **argv)
diff --git a/xdelta3/xdelta3-regtest.py b/xdelta3/xdelta3-regtest.py
index 1b84940..db6f06f 100755
--- a/xdelta3/xdelta3-regtest.py
+++ b/xdelta3/xdelta3-regtest.py
@@ -25,6 +25,7 @@
25 25
26import os, sys, math, re, time, types, array, random 26import os, sys, math, re, time, types, array, random
27import xdelta3main 27import xdelta3main
28import xdelta3
28 29
29HIST_SIZE = 10 # the number of buckets 30HIST_SIZE = 10 # the number of buckets
30MIN_SIZE = 0 31MIN_SIZE = 0
@@ -497,6 +498,7 @@ class GzipInfo:
497 498
498class Xdelta3Info: 499class Xdelta3Info:
499 def __init__(self,target,delta): 500 def __init__(self,target,delta):
501 # TODO: bug is fixed
500 self.extcomp = 0 # TODO: I removed some code that called printhdr 502 self.extcomp = 0 # TODO: I removed some code that called printhdr
501 self.hdrsize = 0 # to compute these, but printhdr uses stdout (now) 503 self.hdrsize = 0 # to compute these, but printhdr uses stdout (now)
502 self.tgtsize = os.stat(target).st_size 504 self.tgtsize = os.stat(target).st_size
@@ -506,6 +508,23 @@ class Xdelta3Info:
506 else: 508 else:
507 self.ideal = 0.0 509 self.ideal = 0.0
508 510
511class Xdelta3ModInfo:
512 def __init__(self,target,delta):
513 #tmp = open(DFILE, 'w')
514 #tmp.write(patch)
515 #tmp.close()
516 #r3 = xdelta3.xd3_main_cmdline(['xdelta3', 'printhdr', DFILE, RFILE])
517 #if r3 != 0:
518 # raise CommandError('memory', 'print failed: %s' % r3)
519 #hdr = open(RFILE, 'r').read()
520 #print hdr
521 self.tgtsize = len(target)
522 self.dsize = len(delta)
523 if self.tgtsize > 0:
524 self.ideal = 100.0 * self.dsize / self.tgtsize;
525 else:
526 self.ideal = 0.0
527
509class Xdelta3Pair: 528class Xdelta3Pair:
510 def __init__(self): 529 def __init__(self):
511 self.type = 'xdelta3' 530 self.type = 'xdelta3'
@@ -585,11 +604,27 @@ class Xdelta3Run1:
585 self.file = file 604 self.file = file
586 def Run(self,trial): 605 def Run(self,trial):
587 RunXdelta3(testwide_encode_args + 606 RunXdelta3(testwide_encode_args +
588 ['-efq', self.file, DFILE]) 607 ['-efqW', str(1<<20), self.file, DFILE])
589 if trial > 0: 608 if trial > 0:
590 return None 609 return None
591 return Xdelta3Info(self.file,DFILE) 610 return Xdelta3Info(self.file,DFILE)
592 611
612class Xdelta3Mod1:
613 def __init__(self,file):
614 self.data = open(file, 'r').read()
615 def Run(self,trial):
616 r1, patch = xdelta3.xd3_encode_memory(self.data, None, 1000000, 1<<10)
617 if r1 != 0:
618 raise CommandError('memory', 'encode failed: %s' % r1)
619 if trial > 0:
620 return None
621 r2, data1 = xdelta3.xd3_decode_memory(patch, None, len(self.data))
622 if r2 != 0:
623 raise CommandError('memory', 'decode failed: %s' % r1)
624 if self.data != data1:
625 raise CommandError('memory', 'bad output: %s' % self.data, data1)
626 return Xdelta3ModInfo(self.data,patch)
627
593class GzipRun1: 628class GzipRun1:
594 def __init__(self,file): 629 def __init__(self,file):
595 self.file = file 630 self.file = file
@@ -608,7 +643,8 @@ def SetFileSize(F,L):
608 643
609def ReportSpeed(L,tr,desc): 644def ReportSpeed(L,tr,desc):
610 print '%s 0-run length %u: dsize %u: time %.3f ms: encode %.0f B/sec: in %u trials' % \ 645 print '%s 0-run length %u: dsize %u: time %.3f ms: encode %.0f B/sec: in %u trials' % \
611 (desc, L, tr.r1.dsize, tr.time.mean * 1000.0, ((L+tr.r1.dsize) / tr.time.mean), tr.trials) 646 (desc, L, tr.r1.dsize, tr.time.mean * 1000.0,
647 ((L+tr.r1.dsize) / tr.time.mean), tr.trials)
612 648
613class RandomTestResult: 649class RandomTestResult:
614 def __init__(self, round, config, runtime, compsize): 650 def __init__(self, round, config, runtime, compsize):
@@ -870,10 +906,13 @@ class RandomTester:
870#end 906#end
871 907
872def RunSpeed(): 908def RunSpeed():
909 # TODO: Start testing window sizes
873 for L in Decimals(MAX_RUN): 910 for L in Decimals(MAX_RUN):
874 SetFileSize(RUNFILE, L) 911 SetFileSize(RUNFILE, L)
875 trx = TimeRun(Xdelta3Run1(RUNFILE)) 912 trx = TimeRun(Xdelta3Run1(RUNFILE))
876 ReportSpeed(L,trx,'xdelta3') 913 ReportSpeed(L,trx,'xdelta3')
914 trm = TimeRun(Xdelta3Mod1(RUNFILE))
915 ReportSpeed(L,trm,'module ')
877 trg = TimeRun(GzipRun1(RUNFILE)) 916 trg = TimeRun(GzipRun1(RUNFILE))
878 ReportSpeed(L,trg,'gzip ') 917 ReportSpeed(L,trg,'gzip ')
879 #end 918 #end
@@ -886,7 +925,14 @@ if __name__ == "__main__":
886 #rcsf = Test() 925 #rcsf = Test()
887 configs = [] 926 configs = []
888 927
889 while 1: 928 # This tests pairwise (date-ordered) performance
929 #rcsf.PairsByDate(Xdelta3Pair())
930
931 # This tests the raw speed of 0-byte inputs
932 RunSpeed()
933
934
935 while 0:
890 #f1 = '/tmp/big.1' 936 #f1 = '/tmp/big.1'
891 #f2 = '/tmp/big.2' 937 #f2 = '/tmp/big.2'
892 test = RandomTester(configs) 938 test = RandomTester(configs)
@@ -907,12 +953,6 @@ if __name__ == "__main__":
907 #end 953 #end
908 #end 954 #end
909 955
910 # This tests pairwise (date-ordered) performance
911 #rcsf.PairsByDate(Xdelta3Pair())
912
913 # This tests the raw speed of 0-byte inputs
914 #RunSpeed()
915
916 except CommandError: 956 except CommandError:
917 pass 957 pass
918 else: 958 else:
diff --git a/xdelta3/xdelta3-test.h b/xdelta3/xdelta3-test.h
index 3658488..f4d5972 100755
--- a/xdelta3/xdelta3-test.h
+++ b/xdelta3/xdelta3-test.h
@@ -380,7 +380,8 @@ test_read_integer_error (xd3_stream *stream, int trunto, const char *msg)
380 inp = buf->base; 380 inp = buf->base;
381 max = buf->base + buf->next - trunto; 381 max = buf->base + buf->next - trunto;
382 382
383 if ((ret = xd3_read_uint32_t (stream, & inp, max, & rval)) != XD3_INTERNAL || !MSG_IS (msg)) 383 if ((ret = xd3_read_uint32_t (stream, & inp, max, & rval)) != XD3_INVALID_INPUT ||
384 !MSG_IS (msg))
384 { 385 {
385 ret = XD3_INTERNAL; 386 ret = XD3_INTERNAL;
386 } 387 }
@@ -1387,17 +1388,17 @@ test_streaming (xd3_stream *in_stream, uint8_t *encbuf, uint8_t *decbuf, uint8_t
1387 1388
1388 if ((i % 200) == 199) { DOT (); } 1389 if ((i % 200) == 199) { DOT (); }
1389 1390
1390 if ((ret = xd3_process_stream (& estream, xd3_encode_input, 0, 1391 if ((ret = xd3_process_stream (1, & estream, xd3_encode_input, 0,
1391 encbuf, 1 << 20, 1392 encbuf, 1 << 20,
1392 delbuf, & delsize, 1 << 10))) 1393 delbuf, & delsize, 1 << 10)))
1393 { 1394 {
1394 in_stream->msg = estream.msg; 1395 in_stream->msg = estream.msg;
1395 goto fail; 1396 goto fail;
1396 } 1397 }
1397 1398
1398 if ((ret = xd3_process_stream (& dstream, xd3_decode_input, 0, 1399 if ((ret = xd3_process_stream (0, & dstream, xd3_decode_input, 0,
1399 delbuf, delsize, 1400 delbuf, delsize,
1400 decbuf, & decsize, 1 << 20))) 1401 decbuf, & decsize, 1 << 20)))
1401 { 1402 {
1402 in_stream->msg = dstream.msg; 1403 in_stream->msg = dstream.msg;
1403 goto fail; 1404 goto fail;
diff --git a/xdelta3/xdelta3-test.py b/xdelta3/xdelta3-test.py
new file mode 100755
index 0000000..7ad25dd
--- /dev/null
+++ b/xdelta3/xdelta3-test.py
@@ -0,0 +1,131 @@
1#!/usr/bin/python2.4
2# xdelta 3 - delta compression tools and library
3# Copyright (C) 2003, 2006, 2007. Joshua P. MacDonald
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, write to the Free Software
17# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19import xdelta3
20
21# the test data section is expected to be len('target')
22source = 'source source input0 source source'
23target = 'source source target source source'
24
25#
26#
27
28print 'encode: basic ...'
29result, patch = xdelta3.xd3_encode_memory(target, source, 50)
30
31assert result == 0
32assert len(patch) < len(source)
33
34print 'encode: adler32 ...'
35result, patch_adler32 = xdelta3.xd3_encode_memory(target, source, 50,
36 1<<10)
37
38assert result == 0
39assert len(patch_adler32) < len(source)
40assert len(patch_adler32) > len(patch)
41
42print 'encode: secondary ...'
43result, patch_djw = xdelta3.xd3_encode_memory(target, source, 50,
44 1<<5)
45
46assert result == 0
47# secondary compression doesn't help
48assert len(patch_djw) > len(patch)
49
50print 'encode: exact ...'
51result, ignore = xdelta3.xd3_encode_memory(target, source, len(patch))
52
53assert result == 0
54assert len(ignore) < len(source)
55
56print 'encode: out of space ...'
57result, ignore = xdelta3.xd3_encode_memory(target, source, len(patch) - 1)
58
59assert result == 28
60assert ignore == None
61
62print 'encode: zero space ...'
63result, ignore = xdelta3.xd3_encode_memory(target, source, 0)
64
65assert result == 28
66assert ignore == None
67
68print 'encode: no source ...'
69result, zdata = xdelta3.xd3_encode_memory(target, None, 50)
70
71assert result == 0
72assert len(zdata) > len(patch)
73
74print 'encode: no input ...'
75result, ignore = xdelta3.xd3_encode_memory(None, None, 50)
76
77assert result != 0
78
79print 'decode: basic ...'
80result, target1 = xdelta3.xd3_decode_memory(patch, source, len(target))
81
82assert result == 0
83assert len(target1) == len(target)
84assert target1 == target
85
86print 'decode: out of space ...'
87result, ignore = xdelta3.xd3_decode_memory(patch, source, len(target) - 1)
88
89assert result == 28
90assert ignore == None
91
92print 'decode: zero space ...'
93result, ignore = xdelta3.xd3_decode_memory(patch, source, 0)
94
95assert result == 28
96assert ignore == None
97
98print 'decode: single byte error ...'
99# a few expected single-byte errors, e.g., unused address cache bits, see
100# xdelta3-test.h's single-bit error tests
101extra_count = 4
102noverify_count = 0
103for corrupt_pos in range(len(patch_adler32)):
104 input = ''.join([j == corrupt_pos and '\xff' or patch_adler32[j]
105 for j in range(len(patch_adler32))])
106
107 result, ignore = xdelta3.xd3_decode_memory(input, source, len(target), 0)
108 assert result == -17712
109 assert ignore == None
110
111 # without adler32 verification, the error may be in the data section which
112 # in this case is 6 bytes 'target'
113 result, corrupt = xdelta3.xd3_decode_memory(input, source, len(target),
114 1<<11)
115 if result == 0:
116 noverify_count = noverify_count + 1
117 #print "got %s" % corrupt
118 #end
119#end
120assert noverify_count == len('target') + extra_count
121
122print 'decode: no source ...'
123result, target2 = xdelta3.xd3_decode_memory(zdata, None, len(target))
124
125assert result == 0
126assert target == target2
127
128#
129#
130
131print 'PASS'
diff --git a/xdelta3/xdelta3.c b/xdelta3/xdelta3.c
index 65e71f2..4e40ba4 100755
--- a/xdelta3/xdelta3.c
+++ b/xdelta3/xdelta3.c
@@ -740,7 +740,7 @@ static const xd3_sec_type djw_sec_type =
740#include "xdelta3-cfgs.h" 740#include "xdelta3-cfgs.h"
741#undef __XDELTA3_C_TEMPLATE_PASS__ 741#undef __XDELTA3_C_TEMPLATE_PASS__
742 742
743#if XD3_MAIN || PYTHON_MODULE 743#if XD3_MAIN || PYTHON_MODULE || SWIG_MODULE
744#include "xdelta3-main.h" 744#include "xdelta3-main.h"
745#endif 745#endif
746 746
@@ -1856,7 +1856,7 @@ xd3_emit_bytes (xd3_stream *stream,
1856 if (PART & OFLOW) \ 1856 if (PART & OFLOW) \
1857 { \ 1857 { \
1858 stream->msg = "overflow in decode_integer"; \ 1858 stream->msg = "overflow in decode_integer"; \
1859 return XD3_INTERNAL; \ 1859 return XD3_INVALID_INPUT; \
1860 } \ 1860 } \
1861 \ 1861 \
1862 PART = (PART << 7) | (next & 127); \ 1862 PART = (PART << 7) | (next & 127); \
@@ -1882,13 +1882,13 @@ xd3_emit_bytes (xd3_stream *stream,
1882 if (inp == max) \ 1882 if (inp == max) \
1883 { \ 1883 { \
1884 stream->msg = "end-of-input in read_integer"; \ 1884 stream->msg = "end-of-input in read_integer"; \
1885 return XD3_INTERNAL; \ 1885 return XD3_INVALID_INPUT; \
1886 } \ 1886 } \
1887 \ 1887 \
1888 if (val & OFLOW) \ 1888 if (val & OFLOW) \
1889 { \ 1889 { \
1890 stream->msg = "overflow in read_intger"; \ 1890 stream->msg = "overflow in read_intger"; \
1891 return XD3_INTERNAL; \ 1891 return XD3_INVALID_INPUT; \
1892 } \ 1892 } \
1893 \ 1893 \
1894 next = (*inp++); \ 1894 next = (*inp++); \
@@ -2126,7 +2126,7 @@ xd3_decode_address (xd3_stream *stream, usize_t here, uint mode, const uint8_t *
2126 if (*inpp == max) 2126 if (*inpp == max)
2127 { 2127 {
2128 stream->msg = "address underflow"; 2128 stream->msg = "address underflow";
2129 return XD3_INTERNAL; 2129 return XD3_INVALID_INPUT;
2130 } 2130 }
2131 2131
2132 mode -= same_start; 2132 mode -= same_start;
@@ -3829,7 +3829,8 @@ xd3_encode_input (xd3_stream *stream)
3829 ******************************************************************************************/ 3829 ******************************************************************************************/
3830 3830
3831static int 3831static int
3832xd3_process_stream (xd3_stream *stream, 3832xd3_process_stream (int is_encode,
3833 xd3_stream *stream,
3833 int (*func) (xd3_stream *), 3834 int (*func) (xd3_stream *),
3834 int close_stream, 3835 int close_stream,
3835 const uint8_t *input, 3836 const uint8_t *input,
@@ -3838,11 +3839,15 @@ xd3_process_stream (xd3_stream *stream,
3838 usize_t *output_size, 3839 usize_t *output_size,
3839 usize_t output_size_max) 3840 usize_t output_size_max)
3840{ 3841{
3842 usize_t ipos = 0;
3843 usize_t n = min(stream->winsize, input_size);
3844
3841 (*output_size) = 0; 3845 (*output_size) = 0;
3842 3846
3843 stream->flags |= XD3_FLUSH; 3847 stream->flags |= XD3_FLUSH;
3844 3848
3845 xd3_avail_input (stream, input, input_size); 3849 xd3_avail_input (stream, input + ipos, n);
3850 ipos += n;
3846 3851
3847 for (;;) 3852 for (;;)
3848 { 3853 {
@@ -3850,7 +3855,15 @@ xd3_process_stream (xd3_stream *stream,
3850 switch((ret = func (stream))) 3855 switch((ret = func (stream)))
3851 { 3856 {
3852 case XD3_OUTPUT: { /* memcpy below */ break; } 3857 case XD3_OUTPUT: { /* memcpy below */ break; }
3853 case XD3_INPUT: { /* this means EOF */ goto done; } 3858 case XD3_INPUT: {
3859 n = min(stream->winsize, input_size - ipos);
3860 if (n == 0) {
3861 goto done;
3862 }
3863 xd3_avail_input (stream, input + ipos, n);
3864 ipos += n;
3865 continue;
3866 }
3854 case XD3_GOTHEADER: { /* ignore */ continue; } 3867 case XD3_GOTHEADER: { /* ignore */ continue; }
3855 case XD3_WINSTART: { /* ignore */ continue; } 3868 case XD3_WINSTART: { /* ignore */ continue; }
3856 case XD3_WINFINISH: { /* ignore */ continue; } 3869 case XD3_WINFINISH: { /* ignore */ continue; }
@@ -3886,7 +3899,8 @@ xd3_process_stream (xd3_stream *stream,
3886} 3899}
3887 3900
3888static int 3901static int
3889xd3_process_memory (int (*func) (xd3_stream *), 3902xd3_process_memory (int is_encode,
3903 int (*func) (xd3_stream *),
3890 int close_stream, 3904 int close_stream,
3891 const uint8_t *input, 3905 const uint8_t *input,
3892 usize_t input_size, 3906 usize_t input_size,
@@ -3901,6 +3915,11 @@ xd3_process_memory (int (*func) (xd3_stream *),
3901 xd3_source src; 3915 xd3_source src;
3902 int ret; 3916 int ret;
3903 3917
3918 if (input == NULL || output == NULL) {
3919 stream.msg = "invalid input/output buffer";
3920 return XD3_INTERNAL;
3921 }
3922
3904 /* TODO: for small inputs, the xd3_stream could be configured to allocate MUCH less 3923 /* TODO: for small inputs, the xd3_stream could be configured to allocate MUCH less
3905 * memory. Most of the allocations sizes are defaulted (see xdelta3.h), and assume 3924 * memory. Most of the allocations sizes are defaulted (see xdelta3.h), and assume
3906 * large inputs. */ 3925 * large inputs. */
@@ -3908,8 +3927,13 @@ xd3_process_memory (int (*func) (xd3_stream *),
3908 memset (& config, 0, sizeof (config)); 3927 memset (& config, 0, sizeof (config));
3909 3928
3910 config.flags = flags; 3929 config.flags = flags;
3911 config.srcwin_maxsz = source_size; 3930
3912 config.winsize = input_size; 3931 if (is_encode)
3932 {
3933 /* TODO: for large inputs, limit window size ... */
3934 config.srcwin_maxsz = source_size;
3935 config.winsize = min(input_size, (usize_t) (1<<20));
3936 }
3913 3937
3914 if ((ret = xd3_config_stream (&stream, &config)) != 0) 3938 if ((ret = xd3_config_stream (&stream, &config)) != 0)
3915 { 3939 {
@@ -3931,7 +3955,8 @@ xd3_process_memory (int (*func) (xd3_stream *),
3931 } 3955 }
3932 } 3956 }
3933 3957
3934 if ((ret = xd3_process_stream (& stream, 3958 if ((ret = xd3_process_stream (is_encode,
3959 & stream,
3935 func, 1, 3960 func, 1,
3936 input, input_size, 3961 input, input_size,
3937 output, 3962 output,
@@ -3949,12 +3974,12 @@ xd3_process_memory (int (*func) (xd3_stream *),
3949int 3974int
3950xd3_decode_stream (xd3_stream *stream, 3975xd3_decode_stream (xd3_stream *stream,
3951 const uint8_t *input, 3976 const uint8_t *input,
3952 usize_t input_size, 3977 usize_t input_size,
3953 uint8_t *output, 3978 uint8_t *output,
3954 usize_t *output_size, 3979 usize_t *output_size,
3955 usize_t output_size_max) 3980 usize_t output_size_max)
3956{ 3981{
3957 return xd3_process_stream (stream, & xd3_decode_input, 1, 3982 return xd3_process_stream (0, stream, & xd3_decode_input, 1,
3958 input, input_size, 3983 input, input_size,
3959 output, output_size, output_size_max); 3984 output, output_size, output_size_max);
3960} 3985}
@@ -3968,7 +3993,7 @@ xd3_decode_memory (const uint8_t *input,
3968 usize_t *output_size, 3993 usize_t *output_size,
3969 usize_t output_size_max, 3994 usize_t output_size_max,
3970 int flags) { 3995 int flags) {
3971 return xd3_process_memory (& xd3_decode_input, 1, 3996 return xd3_process_memory (0, & xd3_decode_input, 1,
3972 input, input_size, 3997 input, input_size,
3973 source, source_size, 3998 source, source_size,
3974 output, output_size, output_size_max, 3999 output, output_size, output_size_max,
@@ -3985,7 +4010,7 @@ xd3_encode_stream (xd3_stream *stream,
3985 usize_t *output_size, 4010 usize_t *output_size,
3986 usize_t output_size_max) 4011 usize_t output_size_max)
3987{ 4012{
3988 return xd3_process_stream (stream, & xd3_encode_input, 1, 4013 return xd3_process_stream (1, stream, & xd3_encode_input, 1,
3989 input, input_size, 4014 input, input_size,
3990 output, output_size, output_size_max); 4015 output, output_size, output_size_max);
3991} 4016}
@@ -3999,7 +4024,7 @@ xd3_encode_memory (const uint8_t *input,
3999 usize_t *output_size, 4024 usize_t *output_size,
4000 usize_t output_size_max, 4025 usize_t output_size_max,
4001 int flags) { 4026 int flags) {
4002 return xd3_process_memory (& xd3_encode_input, 1, 4027 return xd3_process_memory (1, & xd3_encode_input, 1,
4003 input, input_size, 4028 input, input_size,
4004 source, source_size, 4029 source, source_size,
4005 output, output_size, output_size_max, 4030 output, output_size, output_size_max,
diff --git a/xdelta3/xdelta3.h b/xdelta3/xdelta3.h
index ca8d7c9..e6c9e20 100755
--- a/xdelta3/xdelta3.h
+++ b/xdelta3/xdelta3.h
@@ -171,6 +171,10 @@ typedef uint32_t xoff_t;
171#define PYTHON_MODULE 0 171#define PYTHON_MODULE 0
172#endif 172#endif
173 173
174#ifndef SWIG_MODULE
175#define SWIG_MODULE 0
176#endif
177
174/* There are three string matching functions supplied: one fast, one slow (default), and 178/* There are three string matching functions supplied: one fast, one slow (default), and
175 * one soft-configurable. To disable any of these, use the following definitions. */ 179 * one soft-configurable. To disable any of these, use the following definitions. */
176#ifndef XD3_BUILD_SLOW 180#ifndef XD3_BUILD_SLOW
@@ -303,6 +307,7 @@ typedef enum {
303 XD3_TOOFARBACK = -17709, /* (encoder only) may be returned by getblk() if the block is too old */ 307 XD3_TOOFARBACK = -17709, /* (encoder only) may be returned by getblk() if the block is too old */
304 XD3_INTERNAL = -17710, /* internal error */ 308 XD3_INTERNAL = -17710, /* internal error */
305 XD3_INVALID = -17711, /* invalid config */ 309 XD3_INVALID = -17711, /* invalid config */
310 XD3_INVALID_INPUT = -17712, /* invalid input/decoder error */
306 311
307} xd3_rvalues; 312} xd3_rvalues;
308 313
diff --git a/xdelta3/xdelta3.prj b/xdelta3/xdelta3.prj
index a1a3fb9..8eb4c3b 100755
--- a/xdelta3/xdelta3.prj
+++ b/xdelta3/xdelta3.prj
@@ -1,11 +1,11 @@
1;; -*- Prcs -*- 1;; -*- Prcs -*-
2(Created-By-Prcs-Version 1 3 4) 2(Created-By-Prcs-Version 1 3 4)
3(Project-Description "") 3(Project-Description "")
4(Project-Version xdelta3 0 14) 4(Project-Version xdelta3 0 17)
5(Parent-Version xdelta3 0 13) 5(Parent-Version xdelta3 0 16)
6(Version-Log "add FASTEST, update DEFAULT compression levels") 6(Version-Log "check None inputs")
7(New-Version-Log "") 7(New-Version-Log "")
8(Checkin-Time "Wed, 07 Feb 2007 03:07:16 -0800") 8(Checkin-Time "Wed, 07 Feb 2007 18:22:25 -0800")
9(Checkin-Login jmacd) 9(Checkin-Login jmacd)
10(Populate-Ignore ()) 10(Populate-Ignore ())
11(Project-Keywords 11(Project-Keywords
@@ -15,19 +15,19 @@
15 (COPYING (xdelta3/b/29_COPYING 1.1 644)) 15 (COPYING (xdelta3/b/29_COPYING 1.1 644))
16 16
17 (xdelta3-cfgs.h (xdelta3/9_xdelta3-cf 1.5 744)) 17 (xdelta3-cfgs.h (xdelta3/9_xdelta3-cf 1.5 744))
18 (xdelta3-decode.h (xdelta3/b/30_xdelta3-de 1.4 744)) 18 (xdelta3-decode.h (xdelta3/b/30_xdelta3-de 1.5 744))
19 (xdelta3-djw.h (xdelta3/8_xdelta3-dj 1.5 744)) 19 (xdelta3-djw.h (xdelta3/8_xdelta3-dj 1.5 744))
20 (xdelta3-fgk.h (xdelta3/7_xdelta3-fg 1.3 744)) 20 (xdelta3-fgk.h (xdelta3/7_xdelta3-fg 1.3 744))
21 (xdelta3-list.h (xdelta3/6_xdelta3-li 1.3 644)) 21 (xdelta3-list.h (xdelta3/6_xdelta3-li 1.3 644))
22 (xdelta3-main.h (xdelta3/5_xdelta3-ma 1.9 744)) 22 (xdelta3-main.h (xdelta3/5_xdelta3-ma 1.10 744))
23 (xdelta3-python.h (xdelta3/4_xdelta3-py 1.4 744)) 23 (xdelta3-python.h (xdelta3/4_xdelta3-py 1.4 744))
24 (xdelta3-regtest.py (xdelta3/10_xdelta3-re 1.8 744)) 24 (xdelta3-regtest.py (xdelta3/10_xdelta3-re 1.10 744))
25 (xdelta3-second.h (xdelta3/3_xdelta3-se 1.4 744)) 25 (xdelta3-second.h (xdelta3/3_xdelta3-se 1.4 744))
26 (xdelta3-test.h (xdelta3/2_xdelta3-te 1.8 744)) 26 (xdelta3-test.h (xdelta3/2_xdelta3-te 1.10 744))
27 (xdelta3.c (xdelta3/16_xdelta3.c 1.8 744)) 27 (xdelta3.c (xdelta3/16_xdelta3.c 1.10 744))
28 (xdelta3.h (xdelta3/1_xdelta3.h 1.7 744)) 28 (xdelta3.h (xdelta3/1_xdelta3.h 1.8 744))
29 29
30 (Makefile (xdelta3/0_Makefile 1.7 744)) 30 (Makefile (xdelta3/0_Makefile 1.8 744))
31 (setup.py (xdelta3/11_setup.py 1.4 744)) 31 (setup.py (xdelta3/11_setup.py 1.4 744))
32 32
33 (draft-korn-vcdiff.txt (xdelta3/b/22_draft-korn 1.1 644)) 33 (draft-korn-vcdiff.txt (xdelta3/b/22_draft-korn 1.1 644))
@@ -40,8 +40,13 @@
40 (badcopy.vcproj (xdelta3/b/32_badcopy.vc 1.1 744)) 40 (badcopy.vcproj (xdelta3/b/32_badcopy.vc 1.1 744))
41 (xdelta3.vcproj (xdelta3/b/33_xdelta3.vc 1.2 744)) 41 (xdelta3.vcproj (xdelta3/b/33_xdelta3.vc 1.2 744))
42 42
43 (xdelta3.swig (xdelta3/b/27_xdelta3.sw 1.1 744)) 43 (xdelta3.swig (xdelta3/b/27_xdelta3.sw 1.2 744))
44 44
45
46;; Files added by populate at Wed, 07 Feb 2007 13:33:45 -0800,
47;; to version 0.14(w), by jmacd:
48
49 (xdelta3-test.py (xdelta3/b/28_xdelta3-te 1.2 744))
45) 50)
46(Merge-Parents) 51(Merge-Parents)
47(New-Merge-Parents) 52(New-Merge-Parents)
diff --git a/xdelta3/xdelta3.swig b/xdelta3/xdelta3.swig
index 9546e42..696974f 100755
--- a/xdelta3/xdelta3.swig
+++ b/xdelta3/xdelta3.swig
@@ -1,8 +1,11 @@
1%module xdelta3 1%module xdelta3
2%import cstring.i 2%import cstring.i
3%import argcargv.i
3%{ 4%{
4#include "xdelta3.h" 5#include "xdelta3.h"
5 6
7int xd3_main_cmdline (int ARGC, char **ARGV);
8
6#undef SWIG_init 9#undef SWIG_init
7#undef SWIG_name 10#undef SWIG_name
8 11
@@ -13,23 +16,54 @@
13 16
14%cstring_input_binary(const char *input, unsigned int input_size); 17%cstring_input_binary(const char *input, unsigned int input_size);
15%cstring_input_binary(const char *source, unsigned int source_size); 18%cstring_input_binary(const char *source, unsigned int source_size);
16%cstring_output_withsize(char *output_buf, unsigned int avail_output);
17
18int xd3_encode_memory (const char *input,
19 unsigned int input_size,
20 const char *source,
21 unsigned int source_size,
22 char *output_buf,
23 unsigned int *OUTPUT,
24 unsigned int avail_output,
25 int flags);
26
27int xd3_decode_memory (const char *input,
28 unsigned int input_size,
29 const char *source,
30 unsigned int source_size,
31 char *output_buf,
32 unsigned int *OUTPUT,
33 unsigned int avail_output,
34 int flags);
35 19
20%define %max_output_withsize(TYPEMAP, SIZE, MAXSIZE)
21%typemap(in) MAXSIZE (unsigned int alloc_size) {
22 $1 = alloc_size = PyInt_AsLong(obj2);
23}
24%typemap(in,numinputs=0) (TYPEMAP, SIZE) {
25}
26%typemap(check) (TYPEMAP, SIZE) {
27 // alloc_size input is #7th position in xd3_xxcode_memory()
28 $1 = malloc(alloc_size7);
29 $2 = &alloc_size7;
30}
31%typemap(argout,fragment="t_output_helper") (TYPEMAP, SIZE) {
32 if (result == 0) {
33 PyObject *o;
34 // alloc_size7 now carries actual size
35 o = PyString_FromStringAndSize($1,alloc_size7);
36 $result = t_output_helper($result,o);
37 } else {
38 $result = t_output_helper($result,Py_None);
39 }
40 free($1);
41}
42%typemap(default) int flags {
43 $1 = 0;
44}
45%enddef
46
47%max_output_withsize(char *output_buf, unsigned int *output_size, unsigned int max_output);
48
49int xd3_encode_memory (const char *input,
50 unsigned int input_size,
51 const char *source,
52 unsigned int source_size,
53 char *output_buf,
54 unsigned int *output_size,
55 unsigned int max_output,
56 int flags);
57
58int xd3_decode_memory (const char *input,
59 unsigned int input_size,
60 const char *source,
61 unsigned int source_size,
62 char *output_buf,
63 unsigned int *output_size,
64 unsigned int max_output,
65 int flags);
66
67
68
69int xd3_main_cmdline (int ARGC, char **ARGV);