🏗 Add xdelta3 dependency
This commit is contained in:
parent
80f2439239
commit
ae59ce2256
97 changed files with 45332 additions and 1 deletions
32
lib/xdelta3/examples/Makefile
Normal file
32
lib/xdelta3/examples/Makefile
Normal file
|
@ -0,0 +1,32 @@
|
|||
CFLAGS = -g -Wall -I.. -DXD3_DEBUG=1 -DNDEBUG=0 -DSIZEOF_SIZE_T=8 -DSIZEOF_UNSIGNED_LONG_LONG=8
|
||||
#CFLAGS = -O3 -Wall -I.. -DXD3_DEBUG=0 -fno-builtin -DNDEBUG=1
|
||||
# -pg
|
||||
|
||||
SOURCES = small_page_test.c encode_decode_test.c speed_test.c
|
||||
|
||||
DEPS = ../*.h ../*.c *.h
|
||||
|
||||
TARGETS = small_page_test encode_decode_test speed_test32 speed_test64 compare_test checksum_test
|
||||
|
||||
all: $(TARGETS)
|
||||
|
||||
small_page_test: small_page_test.c $(DEPS)
|
||||
$(CC) $(CFLAGS) small_page_test.c -o small_page_test -DXD3_USE_LARGEFILE64=0 -DSECONDARY_DJW=1
|
||||
|
||||
encode_decode_test: encode_decode_test.c $(DEPS)
|
||||
$(CC) $(CFLAGS) encode_decode_test.c -o encode_decode_test
|
||||
|
||||
speed_test32: speed_test.c $(DEPS)
|
||||
$(CC) $(CFLAGS) -DXD3_USE_LARGEFILE64=0 speed_test.c -o speed_test32
|
||||
|
||||
speed_test64: speed_test.c $(DEPS)
|
||||
$(CC) $(CFLAGS) -DXD3_USE_LARGEFILE64=1 speed_test.c -o speed_test64
|
||||
|
||||
compare_test: compare_test.c
|
||||
$(CC) $(CFLAGS) compare_test.c -o compare_test
|
||||
|
||||
checksum_test: checksum_test.cc
|
||||
$(CXX) $(CFLAGS) checksum_test.cc -o checksum_test
|
||||
|
||||
clean:
|
||||
rm -r -f *.exe *.stackdump $(TARGETS) *.dSYM *~
|
8
lib/xdelta3/examples/README.md
Normal file
8
lib/xdelta3/examples/README.md
Normal file
|
@ -0,0 +1,8 @@
|
|||
Files in this directory demonstrate how to use the Xdelta3 API. Copyrights
|
||||
are held by the respective authors.
|
||||
|
||||
small_page_test.c -- how to use xdelta3 in an environment such as the kernel
|
||||
for small pages with little memory
|
||||
|
||||
encode_decode_test.c -- how to use xdelta3 to process (encode/decode) data in
|
||||
multiple windows with the non-blocking API
|
138
lib/xdelta3/examples/compare_test.c
Normal file
138
lib/xdelta3/examples/compare_test.c
Normal file
|
@ -0,0 +1,138 @@
|
|||
/* xdelta3 - delta compression tools and library
|
||||
Copyright 2016 Joshua MacDonald
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "xdelta3.h"
|
||||
|
||||
#define NUM (1<<20)
|
||||
#define ITERS 100
|
||||
|
||||
/* From wikipedia on RDTSC */
|
||||
inline uint64_t rdtsc() {
|
||||
uint32_t lo, hi;
|
||||
asm volatile ("rdtsc" : "=a" (lo), "=d" (hi));
|
||||
return (uint64_t)hi << 32 | lo;
|
||||
}
|
||||
|
||||
typedef int (*test_func)(const char *s1, const char *s2, int n);
|
||||
|
||||
void run_test(const char *buf1, const char *buf2,
|
||||
const char *name, test_func func) {
|
||||
uint64_t start, end;
|
||||
uint64_t accum = 0;
|
||||
int i, x;
|
||||
|
||||
for (i = 0; i < ITERS; i++) {
|
||||
start = rdtsc();
|
||||
x = func(buf1, buf2, NUM);
|
||||
end = rdtsc();
|
||||
accum += end - start;
|
||||
assert(x == NUM - 1);
|
||||
}
|
||||
|
||||
accum /= ITERS;
|
||||
|
||||
printf("%s : %qu cycles\n", name, accum);
|
||||
}
|
||||
|
||||
/* Build w/ -fno-builtin for this to be fast, this assumes that there
|
||||
* is a difference at s1[n-1] */
|
||||
int memcmp_fake(const char *s1, const char *s2, int n) {
|
||||
int x = memcmp(s1, s2, n);
|
||||
return x < 0 ? n - 1 : n + 1;
|
||||
}
|
||||
|
||||
#define UNALIGNED_OK 1
|
||||
static inline int
|
||||
test2(const char *s1c, const char *s2c, int n)
|
||||
{
|
||||
int i = 0;
|
||||
#if UNALIGNED_OK
|
||||
int nint = n / sizeof(int);
|
||||
|
||||
if (nint >> 3)
|
||||
{
|
||||
int j = 0;
|
||||
const int *s1 = (const int*)s1c;
|
||||
const int *s2 = (const int*)s2c;
|
||||
int nint_8 = nint - 8;
|
||||
|
||||
while (i <= nint_8 &&
|
||||
s1[i++] == s2[j++] &&
|
||||
s1[i++] == s2[j++] &&
|
||||
s1[i++] == s2[j++] &&
|
||||
s1[i++] == s2[j++] &&
|
||||
s1[i++] == s2[j++] &&
|
||||
s1[i++] == s2[j++] &&
|
||||
s1[i++] == s2[j++] &&
|
||||
s1[i++] == s2[j++]) { }
|
||||
|
||||
i = (i - 1) * sizeof(int);
|
||||
}
|
||||
#endif
|
||||
|
||||
while (i < n && s1c[i] == s2c[i])
|
||||
{
|
||||
i++;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
static inline int
|
||||
test1(const char *s1c, const char *s2c, int n) {
|
||||
int i = 0;
|
||||
while (i < n && s1c[i] == s2c[i])
|
||||
{
|
||||
i++;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
int main(/*int argc, char **argv*/) {
|
||||
char *buf1 = malloc(NUM+1);
|
||||
char *buf2 = malloc(NUM+1);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NUM; i++) {
|
||||
buf1[i] = buf2[i] = rand();
|
||||
}
|
||||
|
||||
buf2[NUM-1]++;
|
||||
|
||||
printf ("ALIGNED\n");
|
||||
|
||||
run_test(buf1, buf2, "memcmp", &memcmp_fake);
|
||||
run_test(buf1, buf2, "test1", &test1);
|
||||
run_test(buf1, buf2, "test2", &test2);
|
||||
|
||||
for (i = 0; i < NUM; i++) {
|
||||
buf1[i] = buf2[i+1] = rand();
|
||||
}
|
||||
|
||||
buf2[NUM]++;
|
||||
|
||||
printf ("UNALIGNED\n");
|
||||
|
||||
run_test(buf1, buf2+1, "memcmp", &memcmp_fake);
|
||||
run_test(buf1, buf2+1, "test1", &test1);
|
||||
run_test(buf1, buf2+1, "test2", &test2);
|
||||
|
||||
return 0;
|
||||
}
|
203
lib/xdelta3/examples/encode_decode_test.c
Normal file
203
lib/xdelta3/examples/encode_decode_test.c
Normal file
|
@ -0,0 +1,203 @@
|
|||
// Permission to distribute this example by
|
||||
// Copyright (C) 2007 Ralf Junker
|
||||
// Ralf Junker <delphi@yunqa.de>
|
||||
// http://www.yunqa.de/delphi/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
#include "xdelta3.h"
|
||||
#include "xdelta3.c"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
int code (
|
||||
int encode,
|
||||
FILE* InFile,
|
||||
FILE* SrcFile ,
|
||||
FILE* OutFile,
|
||||
int BufSize )
|
||||
{
|
||||
int r, ret;
|
||||
struct stat statbuf;
|
||||
xd3_stream stream;
|
||||
xd3_config config;
|
||||
xd3_source source;
|
||||
void* Input_Buf;
|
||||
int Input_Buf_Read;
|
||||
|
||||
if (BufSize < XD3_ALLOCSIZE)
|
||||
BufSize = XD3_ALLOCSIZE;
|
||||
|
||||
memset (&stream, 0, sizeof (stream));
|
||||
memset (&source, 0, sizeof (source));
|
||||
|
||||
xd3_init_config(&config, XD3_ADLER32);
|
||||
config.winsize = BufSize;
|
||||
xd3_config_stream(&stream, &config);
|
||||
|
||||
if (SrcFile)
|
||||
{
|
||||
r = fstat(fileno(SrcFile), &statbuf);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
source.blksize = BufSize;
|
||||
source.curblk = malloc(source.blksize);
|
||||
|
||||
/* Load 1st block of stream. */
|
||||
r = fseek(SrcFile, 0, SEEK_SET);
|
||||
if (r)
|
||||
return r;
|
||||
source.onblk = fread((void*)source.curblk, 1, source.blksize, SrcFile);
|
||||
source.curblkno = 0;
|
||||
/* Set the stream. */
|
||||
xd3_set_source(&stream, &source);
|
||||
}
|
||||
|
||||
Input_Buf = malloc(BufSize);
|
||||
|
||||
fseek(InFile, 0, SEEK_SET);
|
||||
do
|
||||
{
|
||||
Input_Buf_Read = fread(Input_Buf, 1, BufSize, InFile);
|
||||
if (Input_Buf_Read < BufSize)
|
||||
{
|
||||
xd3_set_flags(&stream, XD3_FLUSH | stream.flags);
|
||||
}
|
||||
xd3_avail_input(&stream, Input_Buf, Input_Buf_Read);
|
||||
|
||||
process:
|
||||
if (encode)
|
||||
ret = xd3_encode_input(&stream);
|
||||
else
|
||||
ret = xd3_decode_input(&stream);
|
||||
|
||||
switch (ret)
|
||||
{
|
||||
case XD3_INPUT:
|
||||
{
|
||||
fprintf (stderr,"XD3_INPUT\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
case XD3_OUTPUT:
|
||||
{
|
||||
fprintf (stderr,"XD3_OUTPUT\n");
|
||||
r = fwrite(stream.next_out, 1, stream.avail_out, OutFile);
|
||||
if (r != (int)stream.avail_out)
|
||||
return r;
|
||||
xd3_consume_output(&stream);
|
||||
goto process;
|
||||
}
|
||||
|
||||
case XD3_GETSRCBLK:
|
||||
{
|
||||
fprintf (stderr,"XD3_GETSRCBLK %qd\n", source.getblkno);
|
||||
if (SrcFile)
|
||||
{
|
||||
r = fseek(SrcFile, source.blksize * source.getblkno, SEEK_SET);
|
||||
if (r)
|
||||
return r;
|
||||
source.onblk = fread((void*)source.curblk, 1,
|
||||
source.blksize, SrcFile);
|
||||
source.curblkno = source.getblkno;
|
||||
}
|
||||
goto process;
|
||||
}
|
||||
|
||||
case XD3_GOTHEADER:
|
||||
{
|
||||
fprintf (stderr,"XD3_GOTHEADER\n");
|
||||
goto process;
|
||||
}
|
||||
|
||||
case XD3_WINSTART:
|
||||
{
|
||||
fprintf (stderr,"XD3_WINSTART\n");
|
||||
goto process;
|
||||
}
|
||||
|
||||
case XD3_WINFINISH:
|
||||
{
|
||||
fprintf (stderr,"XD3_WINFINISH\n");
|
||||
goto process;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
fprintf (stderr,"!!! INVALID %s %d !!!\n",
|
||||
stream.msg, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
while (Input_Buf_Read == BufSize);
|
||||
|
||||
free(Input_Buf);
|
||||
|
||||
free((void*)source.curblk);
|
||||
xd3_close_stream(&stream);
|
||||
xd3_free_stream(&stream);
|
||||
|
||||
return 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
FILE* InFile;
|
||||
FILE* SrcFile;
|
||||
FILE* OutFile;
|
||||
int r;
|
||||
|
||||
if (argc != 3) {
|
||||
fprintf (stderr, "usage: %s source input\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
char *input = argv[2];
|
||||
char *source = argv[1];
|
||||
const char *output = "encoded.testdata";
|
||||
const char *decoded = "decoded.testdata";
|
||||
|
||||
/* Encode */
|
||||
|
||||
InFile = fopen(input, "rb");
|
||||
SrcFile = fopen(source, "rb");
|
||||
OutFile = fopen(output, "wb");
|
||||
|
||||
r = code (1, InFile, SrcFile, OutFile, 0x1000);
|
||||
|
||||
fclose(OutFile);
|
||||
fclose(SrcFile);
|
||||
fclose(InFile);
|
||||
|
||||
if (r) {
|
||||
fprintf (stderr, "Encode error: %d\n", r);
|
||||
return r;
|
||||
}
|
||||
|
||||
/* Decode */
|
||||
|
||||
InFile = fopen(output, "rb");
|
||||
SrcFile = fopen(source, "rb");
|
||||
OutFile = fopen(decoded, "wb");
|
||||
|
||||
r = code (0, InFile, SrcFile, OutFile, 0x1000);
|
||||
|
||||
fclose(OutFile);
|
||||
fclose(SrcFile);
|
||||
fclose(InFile);
|
||||
|
||||
if (r) {
|
||||
fprintf (stderr, "Decode error: %d\n", r);
|
||||
return r;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,389 @@
|
|||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 46;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
B9001B65158D008900B9E855 /* xdelta3.c in Sources */ = {isa = PBXBuildFile; fileRef = B9001B63158D008900B9E855 /* xdelta3.c */; };
|
||||
B9313C3C158D11BA001C1F28 /* file_v1_to_v2.bin in Resources */ = {isa = PBXBuildFile; fileRef = B9313C39158D11BA001C1F28 /* file_v1_to_v2.bin */; };
|
||||
B9313C3D158D11BA001C1F28 /* file_v1.bin in Resources */ = {isa = PBXBuildFile; fileRef = B9313C3A158D11BA001C1F28 /* file_v1.bin */; };
|
||||
B9313C3E158D11BA001C1F28 /* file_v2.bin in Resources */ = {isa = PBXBuildFile; fileRef = B9313C3B158D11BA001C1F28 /* file_v2.bin */; };
|
||||
B9ADC6BF158CFD36007EF999 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B9ADC6BE158CFD36007EF999 /* UIKit.framework */; };
|
||||
B9ADC6C1158CFD36007EF999 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B9ADC6C0158CFD36007EF999 /* Foundation.framework */; };
|
||||
B9ADC6C3158CFD36007EF999 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B9ADC6C2158CFD36007EF999 /* CoreGraphics.framework */; };
|
||||
B9ADC6C9158CFD36007EF999 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = B9ADC6C7158CFD36007EF999 /* InfoPlist.strings */; };
|
||||
B9ADC6CB158CFD36007EF999 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = B9ADC6CA158CFD36007EF999 /* main.m */; };
|
||||
B9ADC6CF158CFD36007EF999 /* Xd3iOSAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = B9ADC6CE158CFD36007EF999 /* Xd3iOSAppDelegate.m */; };
|
||||
B9ADC6D2158CFD36007EF999 /* MainStoryboard_iPhone.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B9ADC6D0158CFD36007EF999 /* MainStoryboard_iPhone.storyboard */; };
|
||||
B9ADC6D5158CFD36007EF999 /* MainStoryboard_iPad.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B9ADC6D3158CFD36007EF999 /* MainStoryboard_iPad.storyboard */; };
|
||||
B9ADC6D8158CFD36007EF999 /* Xd3iOSViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B9ADC6D7158CFD36007EF999 /* Xd3iOSViewController.m */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
B9001B56158D008900B9E855 /* xdelta3-blkcache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "xdelta3-blkcache.h"; path = "../../../../xdelta3-blkcache.h"; sourceTree = "<group>"; };
|
||||
B9001B57158D008900B9E855 /* xdelta3-cfgs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "xdelta3-cfgs.h"; path = "../../../../xdelta3-cfgs.h"; sourceTree = "<group>"; };
|
||||
B9001B58158D008900B9E855 /* xdelta3-decode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "xdelta3-decode.h"; path = "../../../../xdelta3-decode.h"; sourceTree = "<group>"; };
|
||||
B9001B59158D008900B9E855 /* xdelta3-djw.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "xdelta3-djw.h"; path = "../../../../xdelta3-djw.h"; sourceTree = "<group>"; };
|
||||
B9001B5A158D008900B9E855 /* xdelta3-fgk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "xdelta3-fgk.h"; path = "../../../../xdelta3-fgk.h"; sourceTree = "<group>"; };
|
||||
B9001B5B158D008900B9E855 /* xdelta3-hash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "xdelta3-hash.h"; path = "../../../../xdelta3-hash.h"; sourceTree = "<group>"; };
|
||||
B9001B5C158D008900B9E855 /* xdelta3-internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "xdelta3-internal.h"; path = "../../../../xdelta3-internal.h"; sourceTree = "<group>"; };
|
||||
B9001B5D158D008900B9E855 /* xdelta3-list.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "xdelta3-list.h"; path = "../../../../xdelta3-list.h"; sourceTree = "<group>"; };
|
||||
B9001B5E158D008900B9E855 /* xdelta3-main.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "xdelta3-main.h"; path = "../../../../xdelta3-main.h"; sourceTree = "<group>"; };
|
||||
B9001B5F158D008900B9E855 /* xdelta3-merge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "xdelta3-merge.h"; path = "../../../../xdelta3-merge.h"; sourceTree = "<group>"; };
|
||||
B9001B60158D008900B9E855 /* xdelta3-python.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "xdelta3-python.h"; path = "../../../../xdelta3-python.h"; sourceTree = "<group>"; };
|
||||
B9001B61158D008900B9E855 /* xdelta3-second.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "xdelta3-second.h"; path = "../../../../xdelta3-second.h"; sourceTree = "<group>"; };
|
||||
B9001B62158D008900B9E855 /* xdelta3-test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "xdelta3-test.h"; path = "../../../../xdelta3-test.h"; sourceTree = "<group>"; };
|
||||
B9001B63158D008900B9E855 /* xdelta3.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = xdelta3.c; path = ../../../../xdelta3.c; sourceTree = "<group>"; };
|
||||
B9001B64158D008900B9E855 /* xdelta3.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = xdelta3.h; path = ../../../../xdelta3.h; sourceTree = "<group>"; };
|
||||
B9313C39158D11BA001C1F28 /* file_v1_to_v2.bin */ = {isa = PBXFileReference; lastKnownFileType = archive.macbinary; path = file_v1_to_v2.bin; sourceTree = "<group>"; };
|
||||
B9313C3A158D11BA001C1F28 /* file_v1.bin */ = {isa = PBXFileReference; lastKnownFileType = archive.macbinary; path = file_v1.bin; sourceTree = "<group>"; };
|
||||
B9313C3B158D11BA001C1F28 /* file_v2.bin */ = {isa = PBXFileReference; lastKnownFileType = archive.macbinary; path = file_v2.bin; sourceTree = "<group>"; };
|
||||
B9ADC6BA158CFD36007EF999 /* xdelta3-ios-test.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "xdelta3-ios-test.app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
B9ADC6BE158CFD36007EF999 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
|
||||
B9ADC6C0158CFD36007EF999 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
|
||||
B9ADC6C2158CFD36007EF999 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
|
||||
B9ADC6C6158CFD36007EF999 /* xdelta3-ios-test-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "xdelta3-ios-test-Info.plist"; sourceTree = "<group>"; };
|
||||
B9ADC6C8158CFD36007EF999 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
||||
B9ADC6CA158CFD36007EF999 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
||||
B9ADC6CC158CFD36007EF999 /* xdelta3-ios-test-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "xdelta3-ios-test-Prefix.pch"; sourceTree = "<group>"; };
|
||||
B9ADC6CD158CFD36007EF999 /* Xd3iOSAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Xd3iOSAppDelegate.h; sourceTree = "<group>"; };
|
||||
B9ADC6CE158CFD36007EF999 /* Xd3iOSAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Xd3iOSAppDelegate.m; sourceTree = "<group>"; };
|
||||
B9ADC6D1158CFD36007EF999 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = en; path = en.lproj/MainStoryboard_iPhone.storyboard; sourceTree = "<group>"; };
|
||||
B9ADC6D4158CFD36007EF999 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = en; path = en.lproj/MainStoryboard_iPad.storyboard; sourceTree = "<group>"; };
|
||||
B9ADC6D6158CFD36007EF999 /* Xd3iOSViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Xd3iOSViewController.h; sourceTree = "<group>"; };
|
||||
B9ADC6D7158CFD36007EF999 /* Xd3iOSViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Xd3iOSViewController.m; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
B9ADC6B7158CFD36007EF999 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
B9ADC6BF158CFD36007EF999 /* UIKit.framework in Frameworks */,
|
||||
B9ADC6C1158CFD36007EF999 /* Foundation.framework in Frameworks */,
|
||||
B9ADC6C3158CFD36007EF999 /* CoreGraphics.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
B9ADC6AF158CFD36007EF999 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
B9ADC6C4158CFD36007EF999 /* xdelta3-ios-test */,
|
||||
B9ADC6BD158CFD36007EF999 /* Frameworks */,
|
||||
B9ADC6BB158CFD36007EF999 /* Products */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
B9ADC6BB158CFD36007EF999 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
B9ADC6BA158CFD36007EF999 /* xdelta3-ios-test.app */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
B9ADC6BD158CFD36007EF999 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
B9ADC6BE158CFD36007EF999 /* UIKit.framework */,
|
||||
B9ADC6C0158CFD36007EF999 /* Foundation.framework */,
|
||||
B9ADC6C2158CFD36007EF999 /* CoreGraphics.framework */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
B9ADC6C4158CFD36007EF999 /* xdelta3-ios-test */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
B9001B56158D008900B9E855 /* xdelta3-blkcache.h */,
|
||||
B9001B57158D008900B9E855 /* xdelta3-cfgs.h */,
|
||||
B9001B58158D008900B9E855 /* xdelta3-decode.h */,
|
||||
B9001B59158D008900B9E855 /* xdelta3-djw.h */,
|
||||
B9001B5A158D008900B9E855 /* xdelta3-fgk.h */,
|
||||
B9001B5B158D008900B9E855 /* xdelta3-hash.h */,
|
||||
B9001B5C158D008900B9E855 /* xdelta3-internal.h */,
|
||||
B9001B5D158D008900B9E855 /* xdelta3-list.h */,
|
||||
B9001B5E158D008900B9E855 /* xdelta3-main.h */,
|
||||
B9001B5F158D008900B9E855 /* xdelta3-merge.h */,
|
||||
B9001B60158D008900B9E855 /* xdelta3-python.h */,
|
||||
B9001B61158D008900B9E855 /* xdelta3-second.h */,
|
||||
B9001B62158D008900B9E855 /* xdelta3-test.h */,
|
||||
B9001B63158D008900B9E855 /* xdelta3.c */,
|
||||
B9001B64158D008900B9E855 /* xdelta3.h */,
|
||||
B9ADC6CD158CFD36007EF999 /* Xd3iOSAppDelegate.h */,
|
||||
B9ADC6CE158CFD36007EF999 /* Xd3iOSAppDelegate.m */,
|
||||
B9ADC6D0158CFD36007EF999 /* MainStoryboard_iPhone.storyboard */,
|
||||
B9ADC6D3158CFD36007EF999 /* MainStoryboard_iPad.storyboard */,
|
||||
B9ADC6D6158CFD36007EF999 /* Xd3iOSViewController.h */,
|
||||
B9ADC6D7158CFD36007EF999 /* Xd3iOSViewController.m */,
|
||||
B9ADC6C5158CFD36007EF999 /* Supporting Files */,
|
||||
);
|
||||
path = "xdelta3-ios-test";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
B9ADC6C5158CFD36007EF999 /* Supporting Files */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
B9313C39158D11BA001C1F28 /* file_v1_to_v2.bin */,
|
||||
B9313C3A158D11BA001C1F28 /* file_v1.bin */,
|
||||
B9313C3B158D11BA001C1F28 /* file_v2.bin */,
|
||||
B9ADC6C6158CFD36007EF999 /* xdelta3-ios-test-Info.plist */,
|
||||
B9ADC6C7158CFD36007EF999 /* InfoPlist.strings */,
|
||||
B9ADC6CA158CFD36007EF999 /* main.m */,
|
||||
B9ADC6CC158CFD36007EF999 /* xdelta3-ios-test-Prefix.pch */,
|
||||
);
|
||||
name = "Supporting Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
B9ADC6B9158CFD36007EF999 /* xdelta3-ios-test */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = B9ADC6DB158CFD36007EF999 /* Build configuration list for PBXNativeTarget "xdelta3-ios-test" */;
|
||||
buildPhases = (
|
||||
B9ADC6B6158CFD36007EF999 /* Sources */,
|
||||
B9ADC6B7158CFD36007EF999 /* Frameworks */,
|
||||
B9ADC6B8158CFD36007EF999 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = "xdelta3-ios-test";
|
||||
productName = "xdelta3-ios-test";
|
||||
productReference = B9ADC6BA158CFD36007EF999 /* xdelta3-ios-test.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
B9ADC6B1158CFD36007EF999 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 0420;
|
||||
};
|
||||
buildConfigurationList = B9ADC6B4158CFD36007EF999 /* Build configuration list for PBXProject "xdelta3-ios-test" */;
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
);
|
||||
mainGroup = B9ADC6AF158CFD36007EF999;
|
||||
productRefGroup = B9ADC6BB158CFD36007EF999 /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
B9ADC6B9158CFD36007EF999 /* xdelta3-ios-test */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
B9ADC6B8158CFD36007EF999 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
B9ADC6C9158CFD36007EF999 /* InfoPlist.strings in Resources */,
|
||||
B9ADC6D2158CFD36007EF999 /* MainStoryboard_iPhone.storyboard in Resources */,
|
||||
B9ADC6D5158CFD36007EF999 /* MainStoryboard_iPad.storyboard in Resources */,
|
||||
B9313C3C158D11BA001C1F28 /* file_v1_to_v2.bin in Resources */,
|
||||
B9313C3D158D11BA001C1F28 /* file_v1.bin in Resources */,
|
||||
B9313C3E158D11BA001C1F28 /* file_v2.bin in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
B9ADC6B6158CFD36007EF999 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
B9ADC6CB158CFD36007EF999 /* main.m in Sources */,
|
||||
B9ADC6CF158CFD36007EF999 /* Xd3iOSAppDelegate.m in Sources */,
|
||||
B9ADC6D8158CFD36007EF999 /* Xd3iOSViewController.m in Sources */,
|
||||
B9001B65158D008900B9E855 /* xdelta3.c in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXVariantGroup section */
|
||||
B9ADC6C7158CFD36007EF999 /* InfoPlist.strings */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
B9ADC6C8158CFD36007EF999 /* en */,
|
||||
);
|
||||
name = InfoPlist.strings;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
B9ADC6D0158CFD36007EF999 /* MainStoryboard_iPhone.storyboard */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
B9ADC6D1158CFD36007EF999 /* en */,
|
||||
);
|
||||
name = MainStoryboard_iPhone.storyboard;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
B9ADC6D3158CFD36007EF999 /* MainStoryboard_iPad.storyboard */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
B9ADC6D4158CFD36007EF999 /* en */,
|
||||
);
|
||||
name = MainStoryboard_iPad.storyboard;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXVariantGroup section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
B9ADC6D9158CFD36007EF999 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_INPUT_FILETYPE = sourcecode.c.objc;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"XD3_USE_LARGEFILE64=0",
|
||||
"XD3_POSIX=1",
|
||||
"EXTERNAL_COMPRESSION=0",
|
||||
"NOT_MAIN=1",
|
||||
"XD3_MAIN=1",
|
||||
"SECONDARY_DJW=1",
|
||||
"XD3_DEBUG=1",
|
||||
"REGRESSION_TEST=1",
|
||||
"SHELL_TESTS=0",
|
||||
"SECONDARY_FGK=1",
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
|
||||
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
|
||||
OTHER_CFLAGS = (
|
||||
"-DXD3_USE_LARGEFILE64=0",
|
||||
"-DXD3_POSIX=1",
|
||||
"-DEXTERNAL_COMPRESSION=0",
|
||||
"-DNOT_MAIN=1",
|
||||
"-DXD3_MAIN=1",
|
||||
"-DSECONDARY_DJW=1",
|
||||
"-DXD3_DEBUG=1",
|
||||
"-DREGRESSION_TEST=1",
|
||||
"-DSHELL_TESTS=0",
|
||||
"-DSECONDARY_FGK=1",
|
||||
);
|
||||
SDKROOT = iphoneos;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
B9ADC6DA158CFD36007EF999 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_INPUT_FILETYPE = sourcecode.c.objc;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"XD3_USE_LARGEFILE64=0",
|
||||
"XD3_POSIX=1",
|
||||
"EXTERNAL_COMPRESSION=0",
|
||||
"NOT_MAIN=1",
|
||||
"XD3_MAIN=1",
|
||||
"SECONDARY_DJW=1",
|
||||
"XD3_DEBUG=1",
|
||||
"REGRESSION_TEST=1",
|
||||
"SHELL_TESTS=0",
|
||||
"SECONDARY_FGK=1",
|
||||
);
|
||||
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
|
||||
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
|
||||
OTHER_CFLAGS = (
|
||||
"-DXD3_USE_LARGEFILE64=0",
|
||||
"-DXD3_POSIX=1",
|
||||
"-DEXTERNAL_COMPRESSION=0",
|
||||
"-DNOT_MAIN=1",
|
||||
"-DXD3_MAIN=1",
|
||||
"-DSECONDARY_DJW=1",
|
||||
"-DXD3_DEBUG=1",
|
||||
"-DREGRESSION_TEST=1",
|
||||
"-DSHELL_TESTS=0",
|
||||
"-DSECONDARY_FGK=1",
|
||||
);
|
||||
SDKROOT = iphoneos;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
B9ADC6DC158CFD36007EF999 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = "xdelta3-ios-test/xdelta3-ios-test-Prefix.pch";
|
||||
INFOPLIST_FILE = "xdelta3-ios-test/xdelta3-ios-test-Info.plist";
|
||||
OTHER_CFLAGS = "";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
WRAPPER_EXTENSION = app;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
B9ADC6DD158CFD36007EF999 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = "xdelta3-ios-test/xdelta3-ios-test-Prefix.pch";
|
||||
INFOPLIST_FILE = "xdelta3-ios-test/xdelta3-ios-test-Info.plist";
|
||||
OTHER_CFLAGS = "";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
WRAPPER_EXTENSION = app;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
B9ADC6B4158CFD36007EF999 /* Build configuration list for PBXProject "xdelta3-ios-test" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
B9ADC6D9158CFD36007EF999 /* Debug */,
|
||||
B9ADC6DA158CFD36007EF999 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
B9ADC6DB158CFD36007EF999 /* Build configuration list for PBXNativeTarget "xdelta3-ios-test" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
B9ADC6DC158CFD36007EF999 /* Debug */,
|
||||
B9ADC6DD158CFD36007EF999 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = B9ADC6B1158CFD36007EF999 /* Project object */;
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
/* xdelta3 - delta compression tools and library -*- Mode: objc *-*
|
||||
Copyright 2016 Joshua MacDonald
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface Xd3iOSAppDelegate : UIResponder <UIApplicationDelegate>
|
||||
|
||||
@property (strong, nonatomic) UIWindow *window;
|
||||
|
||||
@end
|
|
@ -0,0 +1,68 @@
|
|||
/* xdelta3 - delta compression tools and library -*- Mode: objc *-*
|
||||
Copyright 2016 Joshua MacDonald
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "Xd3iOSAppDelegate.h"
|
||||
|
||||
@implementation Xd3iOSAppDelegate
|
||||
|
||||
@synthesize window = _window;
|
||||
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
||||
{
|
||||
// Override point for customization after application launch.
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)applicationWillResignActive:(UIApplication *)application
|
||||
{
|
||||
/*
|
||||
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
|
||||
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
|
||||
*/
|
||||
}
|
||||
|
||||
- (void)applicationDidEnterBackground:(UIApplication *)application
|
||||
{
|
||||
/*
|
||||
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
|
||||
If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
|
||||
*/
|
||||
}
|
||||
|
||||
- (void)applicationWillEnterForeground:(UIApplication *)application
|
||||
{
|
||||
/*
|
||||
Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
|
||||
*/
|
||||
}
|
||||
|
||||
- (void)applicationDidBecomeActive:(UIApplication *)application
|
||||
{
|
||||
/*
|
||||
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
|
||||
*/
|
||||
}
|
||||
|
||||
- (void)applicationWillTerminate:(UIApplication *)application
|
||||
{
|
||||
/*
|
||||
Called when the application is about to terminate.
|
||||
Save data if appropriate.
|
||||
See also applicationDidEnterBackground:.
|
||||
*/
|
||||
}
|
||||
|
||||
@end
|
|
@ -0,0 +1,28 @@
|
|||
/* xdelta3 - delta compression tools and library -*- Mode: objc *-*
|
||||
Copyright 2016 Joshua MacDonald
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface Xd3iOSViewController : UIViewController <UITextViewDelegate> {
|
||||
NSString *inputSeed;
|
||||
}
|
||||
- (IBAction)startTest:(id)sender;
|
||||
@property (weak, nonatomic) IBOutlet UITextField *theSeed;
|
||||
@property (weak, nonatomic) IBOutlet UITextView *theView;
|
||||
@property (atomic, retain) NSMutableString *theOutput;
|
||||
@property (nonatomic) BOOL inTest;
|
||||
|
||||
@end
|
|
@ -0,0 +1,177 @@
|
|||
/* xdelta3 - delta compression tools and library -*- Mode: objc *-*
|
||||
Copyright 2016 Joshua MacDonald
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "Xd3iOSViewController.h"
|
||||
#include "xdelta3.h"
|
||||
#include "dispatch/queue.h"
|
||||
#include "Foundation/NSBundle.h"
|
||||
|
||||
extern void (*xprintf_message_func)(const char* msg);
|
||||
void print_to_view(const char* buf);
|
||||
int xd3_main_cmdline(int argc, char **argv);
|
||||
void do_localfile_test(void);
|
||||
int compare_files(const char* file1, const char* file2);
|
||||
Xd3iOSViewController *static_ptr;
|
||||
|
||||
@implementation Xd3iOSViewController
|
||||
@synthesize theSeed = _theSeed;
|
||||
@synthesize theView = _theView;
|
||||
@synthesize theOutput = _theOutput;
|
||||
@synthesize inTest = _inTest;
|
||||
|
||||
- (void)didReceiveMemoryWarning
|
||||
{
|
||||
[super didReceiveMemoryWarning];
|
||||
}
|
||||
|
||||
#pragma mark - View lifecycle
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
}
|
||||
|
||||
- (void)viewDidUnload
|
||||
{
|
||||
[self setTheSeed:nil];
|
||||
[self setTheView:nil];
|
||||
[self setTheView:nil];
|
||||
[super viewDidUnload];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
}
|
||||
|
||||
- (void)viewDidAppear:(BOOL)animated
|
||||
{
|
||||
[super viewDidAppear:animated];
|
||||
}
|
||||
|
||||
- (void)viewWillDisappear:(BOOL)animated
|
||||
{
|
||||
[super viewWillDisappear:animated];
|
||||
}
|
||||
|
||||
- (void)viewDidDisappear:(BOOL)animated
|
||||
{
|
||||
[super viewDidDisappear:animated];
|
||||
}
|
||||
|
||||
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
|
||||
{
|
||||
switch (interfaceOrientation) {
|
||||
case UIInterfaceOrientationPortrait:
|
||||
case UIInterfaceOrientationPortraitUpsideDown:
|
||||
return YES;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
- (BOOL)textFieldShouldReturn:(UITextField*)theTextField {
|
||||
if (theTextField == self.theSeed) {
|
||||
[theTextField resignFirstResponder];
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
- (IBAction)startTest:(id)sender {
|
||||
if (self.inTest) {
|
||||
return;
|
||||
}
|
||||
self.inTest = YES;
|
||||
NSString *seedString = self.theSeed.text;
|
||||
if ([seedString length] == 0) {
|
||||
seedString = @"RFC3284";
|
||||
}
|
||||
static_ptr = self;
|
||||
xprintf_message_func = &print_to_view;
|
||||
self.theOutput = [[NSMutableString alloc] initWithFormat:@"Starting test (seed=%@)\n", seedString];
|
||||
self.theView.text = self.theOutput;
|
||||
dispatch_queue_t mq = dispatch_get_main_queue();
|
||||
dispatch_queue_t dq = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
|
||||
dispatch_async(dq, ^{
|
||||
do_localfile_test();
|
||||
char *argv[] = { "xdelta3", "test", NULL };
|
||||
xd3_main_cmdline(2, argv);
|
||||
print_to_view("Finished unittest: success");
|
||||
dispatch_async(mq, ^{
|
||||
self.inTest = NO;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
void printns_to_view(NSString* ns);
|
||||
void printns_to_view(NSString* ns) {
|
||||
dispatch_queue_t mq = dispatch_get_main_queue();
|
||||
dispatch_async(mq, ^{
|
||||
if ([static_ptr.theOutput length] < 25000) {
|
||||
[static_ptr.theOutput appendString:ns];
|
||||
} else {
|
||||
static_ptr.theOutput = [[NSMutableString alloc] initWithString:ns];
|
||||
}
|
||||
static_ptr.theView.text = static_ptr.theOutput;
|
||||
CGSize size = static_ptr.theView.contentSize;
|
||||
[static_ptr.theView scrollRectToVisible:CGRectMake(0, size.height - 1, 1, 1) animated:NO];
|
||||
});
|
||||
}
|
||||
|
||||
void print_to_view(const char* buf) {
|
||||
NSString *ns = [NSString stringWithCString:buf encoding:NSASCIIStringEncoding];
|
||||
printns_to_view(ns);
|
||||
}
|
||||
|
||||
void do_localfile_test(void) {
|
||||
NSBundle *bundle;
|
||||
bundle = [NSBundle mainBundle];
|
||||
NSString *localfile1 = [bundle pathForResource:@"file_v1" ofType:@"bin"];
|
||||
NSString *localfile2 = [bundle pathForResource:@"file_v2" ofType:@"bin"];
|
||||
NSString *localfiled = [bundle pathForResource:@"file_v1_to_v2" ofType:@"bin"];
|
||||
printns_to_view([localfile1 stringByAppendingString:@"\n"]);
|
||||
printns_to_view([localfile2 stringByAppendingString:@"\n"]);
|
||||
printns_to_view([localfiled stringByAppendingString:@"\n"]);
|
||||
NSString *tmpdir = NSTemporaryDirectory();
|
||||
NSString *tmpfile = [tmpdir stringByAppendingPathComponent:@"delta.tmp"];
|
||||
printns_to_view([tmpfile stringByAppendingString:@"\n"]);
|
||||
char *argv[] = {
|
||||
"xdelta3", "-dfvv", "-s",
|
||||
(char*)[localfile1 UTF8String],
|
||||
(char*)[localfiled UTF8String],
|
||||
(char*)[tmpfile UTF8String] };
|
||||
xd3_main_cmdline(6, argv);
|
||||
|
||||
NSFileManager *filemgr;
|
||||
|
||||
filemgr = [NSFileManager defaultManager];
|
||||
|
||||
if ([filemgr contentsEqualAtPath: localfile2 andPath: tmpfile] == YES) {
|
||||
printns_to_view(@"File contents match\n");
|
||||
} else {
|
||||
NSError *err1 = NULL;
|
||||
NSDictionary *d1 = [filemgr attributesOfItemAtPath: tmpfile error: &err1];
|
||||
if (err1 != NULL) {
|
||||
printns_to_view([@"File localfile2 could not stat %s\n" stringByAppendingString: tmpfile]);
|
||||
} else {
|
||||
printns_to_view([@"File contents do not match!!!! tmpfile size=" stringByAppendingString:
|
||||
[[NSMutableString alloc] initWithFormat:@"%llu\n", [d1 fileSize]]]);
|
||||
}
|
||||
compare_files([localfile2 UTF8String], [tmpfile UTF8String]);
|
||||
}
|
||||
print_to_view("Finished localfile test.\n");
|
||||
}
|
||||
|
||||
@end
|
|
@ -0,0 +1,2 @@
|
|||
/* Localized versions of Info.plist keys */
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="1.0" toolsVersion="1938" systemVersion="11C74" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none" initialViewController="2">
|
||||
<dependencies>
|
||||
<development defaultVersion="4200" identifier="xcode"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="933"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<scene sceneID="4">
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="3" sceneMemberID="firstResponder"/>
|
||||
<viewController id="2" customClass="Xd3iOSViewController" sceneMemberID="viewController">
|
||||
<view key="view" contentMode="scaleToFill" id="5">
|
||||
<rect key="frame" x="0.0" y="20" width="768" height="1004"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="d7Y-KS-zOa">
|
||||
<rect key="frame" x="258" y="28" width="197" height="37"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
|
||||
<state key="normal" title="Start test">
|
||||
<color key="titleColor" red="0.19607843459999999" green="0.30980393290000002" blue="0.52156865600000002" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</state>
|
||||
<state key="highlighted">
|
||||
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</state>
|
||||
<connections>
|
||||
<action selector="startTest:" destination="2" eventType="touchUpInside" id="f4X-jg-ZsU"/>
|
||||
</connections>
|
||||
</button>
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Random seed" minimumFontSize="17" id="TZ8-OW-wjf">
|
||||
<rect key="frame" x="27" y="28" width="197" height="31"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits" autocorrectionType="no"/>
|
||||
<connections>
|
||||
<outlet property="delegate" destination="2" id="hjY-Ym-Fcw"/>
|
||||
</connections>
|
||||
</textField>
|
||||
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" showsHorizontalScrollIndicator="NO" editable="NO" id="LHz-h6-ZBC">
|
||||
<rect key="frame" x="27" y="88" width="721" height="887"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
|
||||
<connections>
|
||||
<outlet property="delegate" destination="2" id="fwY-fT-bCV"/>
|
||||
</connections>
|
||||
</textView>
|
||||
</subviews>
|
||||
<color key="backgroundColor" red="0.13337372065218178" green="0.1801924475036723" blue="0.21739130434782605" alpha="1" colorSpace="calibratedRGB"/>
|
||||
</view>
|
||||
<connections>
|
||||
<outlet property="theSeed" destination="TZ8-OW-wjf" id="QuA-uT-5IR"/>
|
||||
<outlet property="theView" destination="LHz-h6-ZBC" id="s64-32-fBA"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-601" y="-1021"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
<classes>
|
||||
<class className="Xd3iOSViewController" superclassName="UIViewController">
|
||||
<source key="sourceIdentifier" type="project" relativePath="./Classes/Xd3iOSViewController.h"/>
|
||||
<relationships>
|
||||
<relationship kind="action" name="startTest:"/>
|
||||
<relationship kind="outlet" name="theSeed" candidateClass="UITextField"/>
|
||||
<relationship kind="outlet" name="theView" candidateClass="UITextView"/>
|
||||
</relationships>
|
||||
</class>
|
||||
</classes>
|
||||
<simulatedMetricsContainer key="defaultSimulatedMetrics">
|
||||
<simulatedStatusBarMetrics key="statusBar" statusBarStyle="blackTranslucent"/>
|
||||
<simulatedOrientationMetrics key="orientation"/>
|
||||
<simulatedScreenMetrics key="destination"/>
|
||||
</simulatedMetricsContainer>
|
||||
</document>
|
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="1.0" toolsVersion="1906" systemVersion="11A511" targetRuntime="iOS.CocoaTouch" nextObjectID="6" propertyAccessControl="none" initialViewController="2">
|
||||
<dependencies>
|
||||
<development defaultVersion="4200" identifier="xcode"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="902"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<scene sceneID="5">
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="4" sceneMemberID="firstResponder"/>
|
||||
<viewController id="2" customClass="Xd3iOSViewController" sceneMemberID="viewController">
|
||||
<view key="view" contentMode="scaleToFill" id="3">
|
||||
<rect key="frame" x="0.0" y="20" width="320" height="460"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<subviews/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
</viewController>
|
||||
</objects>
|
||||
</scene>
|
||||
</scenes>
|
||||
<simulatedMetricsContainer key="defaultSimulatedMetrics">
|
||||
<simulatedStatusBarMetrics key="statusBar"/>
|
||||
<simulatedOrientationMetrics key="orientation"/>
|
||||
<simulatedScreenMetrics key="destination"/>
|
||||
</simulatedMetricsContainer>
|
||||
</document>
|
File diff suppressed because it is too large
Load diff
Binary file not shown.
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,25 @@
|
|||
/* xdelta3 - delta compression tools and library -*- Mode: objc *-*
|
||||
Copyright 2016 Joshua MacDonald
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import "Xd3iOSAppDelegate.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@autoreleasepool {
|
||||
return UIApplicationMain(argc, argv, nil, NSStringFromClass([Xd3iOSAppDelegate class]));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIconFiles</key>
|
||||
<array/>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>Joshua-MacDonald.${PRODUCT_NAME:rfc1034identifier}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>UIMainStoryboardFile</key>
|
||||
<string>MainStoryboard_iPhone</string>
|
||||
<key>UIMainStoryboardFile~ipad</key>
|
||||
<string>MainStoryboard_iPad</string>
|
||||
<key>UIRequiredDeviceCapabilities</key>
|
||||
<array>
|
||||
<string>armv7</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
|
@ -0,0 +1,14 @@
|
|||
//
|
||||
// Prefix header for all source files of the 'xdelta3-ios-test' target in the 'xdelta3-ios-test' project
|
||||
//
|
||||
|
||||
#import <Availability.h>
|
||||
|
||||
#ifndef __IPHONE_5_0
|
||||
#warning "This project uses features only available in iOS SDK 5.0 and later."
|
||||
#endif
|
||||
|
||||
#ifdef __OBJC__
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
215
lib/xdelta3/examples/small_page_test.c
Normal file
215
lib/xdelta3/examples/small_page_test.c
Normal file
|
@ -0,0 +1,215 @@
|
|||
/* xdelta3 - delta compression tools and library
|
||||
Copyright 2016 Joshua MacDonald
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define PAGE_SIZE 4096
|
||||
|
||||
#define SPACE_MAX 131072 // how much memory per process
|
||||
#define OUTPUT_MAX 1024 // max size for output
|
||||
#define XD3_ALLOCSIZE 256 // internal size for various buffers
|
||||
#define IOPT_SIZE 128 // instruction buffer
|
||||
|
||||
// SPACE_MAX of 32K is sufficient for most inputs with XD3_COMPLEVEL_1
|
||||
// XD3_COMPLEVEL_9 requires about 4x more space than XD3_COMPLEVEL_1
|
||||
|
||||
#include "xdelta3.h"
|
||||
#include "xdelta3.c"
|
||||
|
||||
typedef struct _context {
|
||||
uint8_t *buffer;
|
||||
int allocated;
|
||||
} context_t;
|
||||
|
||||
static int max_allocated = 0;
|
||||
|
||||
void*
|
||||
process_alloc (void* opaque, usize_t items, usize_t size)
|
||||
{
|
||||
context_t *ctx = (context_t*) opaque;
|
||||
usize_t t = items * size;
|
||||
void *ret;
|
||||
|
||||
if (ctx->allocated + t > SPACE_MAX)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = ctx->buffer + ctx->allocated;
|
||||
ctx->allocated += t;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
process_free (void* opaque, void *ptr)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
process_page (int is_encode,
|
||||
int (*func) (xd3_stream *),
|
||||
const uint8_t *input,
|
||||
usize_t input_size,
|
||||
const uint8_t *source,
|
||||
uint8_t *output,
|
||||
usize_t *output_size,
|
||||
usize_t output_size_max,
|
||||
int flags) {
|
||||
|
||||
/* On my x86 this is 1072 of objects on the stack */
|
||||
xd3_stream stream;
|
||||
xd3_config config;
|
||||
xd3_source src;
|
||||
context_t *ctx = calloc(SPACE_MAX, 1);
|
||||
int ret;
|
||||
|
||||
memset (&config, 0, sizeof(config));
|
||||
|
||||
if (ctx == NULL)
|
||||
{
|
||||
printf("calloc failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ctx->buffer = (uint8_t*)ctx;
|
||||
ctx->allocated = sizeof(*ctx);
|
||||
|
||||
config.flags = flags;
|
||||
config.winsize = PAGE_SIZE;
|
||||
config.sprevsz = PAGE_SIZE;
|
||||
config.srcwin_maxsz = PAGE_SIZE;
|
||||
config.iopt_size = IOPT_SIZE;
|
||||
config.alloc = &process_alloc;
|
||||
config.freef = &process_free;
|
||||
config.opaque = (void*) ctx;
|
||||
|
||||
src.blksize = PAGE_SIZE;
|
||||
src.onblk = PAGE_SIZE;
|
||||
src.curblk = source;
|
||||
src.curblkno = 0;
|
||||
|
||||
if ((ret = xd3_config_stream (&stream, &config)) != 0 ||
|
||||
(ret = xd3_set_source_and_size (&stream, &src, PAGE_SIZE)) != 0 ||
|
||||
(ret = xd3_process_stream (is_encode,
|
||||
&stream,
|
||||
func, 1,
|
||||
input, input_size,
|
||||
output, output_size,
|
||||
output_size_max)) != 0)
|
||||
{
|
||||
if (stream.msg != NULL)
|
||||
{
|
||||
fprintf(stderr, "stream message: %s\n", stream.msg);
|
||||
}
|
||||
}
|
||||
|
||||
xd3_free_stream (&stream);
|
||||
if (max_allocated < ctx->allocated)
|
||||
{
|
||||
max_allocated = ctx->allocated;
|
||||
fprintf(stderr, "max allocated %d\n", max_allocated);
|
||||
}
|
||||
|
||||
free(ctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int test(int stride, int encode_flags)
|
||||
{
|
||||
uint8_t frompg[PAGE_SIZE];
|
||||
uint8_t topg[PAGE_SIZE];
|
||||
uint8_t output[OUTPUT_MAX];
|
||||
uint8_t reout[PAGE_SIZE];
|
||||
usize_t output_size;
|
||||
usize_t re_size;
|
||||
int i, j, ret;
|
||||
|
||||
for (i = 0; i < PAGE_SIZE; i++)
|
||||
{
|
||||
topg[i] = frompg[i] = (rand() >> 3 ^ rand() >> 6 ^ rand() >> 9);
|
||||
}
|
||||
|
||||
// change 1 byte every stride
|
||||
if (stride > 0)
|
||||
{
|
||||
for (j = stride; j <= PAGE_SIZE; j += stride)
|
||||
{
|
||||
topg[j - 1] ^= 0xff;
|
||||
}
|
||||
}
|
||||
|
||||
if ((ret = process_page (1, xd3_encode_input,
|
||||
topg, PAGE_SIZE,
|
||||
frompg, output,
|
||||
&output_size, OUTPUT_MAX,
|
||||
encode_flags)) != 0)
|
||||
{
|
||||
fprintf (stderr, "encode failed: stride %u flags 0x%x\n",
|
||||
stride, encode_flags);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if ((ret = process_page (0, xd3_decode_input,
|
||||
output, output_size,
|
||||
frompg, reout,
|
||||
&re_size, PAGE_SIZE,
|
||||
0)) != 0)
|
||||
{
|
||||
fprintf (stderr, "decode failed: stride %u output_size %u flags 0x%x\n",
|
||||
stride, output_size, encode_flags);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (output_size > OUTPUT_MAX || re_size != PAGE_SIZE)
|
||||
{
|
||||
fprintf (stderr, "internal error: %u != %u\n", output_size, re_size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < PAGE_SIZE; i++)
|
||||
{
|
||||
if (reout[i] != topg[i])
|
||||
{
|
||||
fprintf (stderr, "encode-decode error: position %d\n", i);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr, "stride %d flags 0x%x size %u ",
|
||||
stride, encode_flags, output_size);
|
||||
fprintf(stderr, "%s\n", (ret == 0) ? "OK" : "FAIL");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int stride;
|
||||
int level;
|
||||
|
||||
for (level = 1; level < 10; level = (level == 1 ? 3 : level + 3))
|
||||
{
|
||||
int lflag = level << XD3_COMPLEVEL_SHIFT;
|
||||
|
||||
for (stride = 2; stride <= PAGE_SIZE; stride += 2)
|
||||
{
|
||||
test(stride, lflag);
|
||||
test(stride, lflag | XD3_SEC_DJW);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
87
lib/xdelta3/examples/speed_test.c
Normal file
87
lib/xdelta3/examples/speed_test.c
Normal file
|
@ -0,0 +1,87 @@
|
|||
/* xdelta3 - delta compression tools and library
|
||||
Copyright 2016 Joshua MacDonald
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#include "test.h"
|
||||
|
||||
usize_t bench_speed(const uint8_t *from_buf, const size_t from_len,
|
||||
const uint8_t *to_buf, const size_t to_len,
|
||||
uint8_t *delta_buf, const size_t delta_alloc,
|
||||
int flags) {
|
||||
usize_t delta_size;
|
||||
int ret = xd3_encode_memory(to_buf, to_len, from_buf, from_len,
|
||||
delta_buf, &delta_size, delta_alloc, flags);
|
||||
if (ret != 0) {
|
||||
fprintf(stderr, "encode failure: %d: %s\n", ret, xd3_strerror(ret));
|
||||
abort();
|
||||
}
|
||||
return delta_size;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int repeat, level;
|
||||
char *from, *to;
|
||||
uint8_t *from_buf = NULL, *to_buf = NULL, *delta_buf = NULL;
|
||||
size_t from_len = 0, to_len, delta_alloc, delta_size = 0;
|
||||
long start, finish;
|
||||
int i, ret;
|
||||
int flags;
|
||||
|
||||
if (argc != 5) {
|
||||
fprintf(stderr, "usage: speed_test LEVEL COUNT FROM TO\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
level = atoi(argv[1]);
|
||||
repeat = atoi(argv[2]);
|
||||
from = argv[3];
|
||||
to = argv[4];
|
||||
flags = (level << XD3_COMPLEVEL_SHIFT) & XD3_COMPLEVEL_MASK;
|
||||
|
||||
if ((strcmp(from, "null") != 0 &&
|
||||
(ret = read_whole_file(from, &from_buf, &from_len))) ||
|
||||
(ret = read_whole_file(to, &to_buf, &to_len))) {
|
||||
fprintf(stderr, "read_whole_file error\n");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
delta_alloc = to_len * 11 / 10;
|
||||
delta_buf = main_malloc(delta_alloc);
|
||||
|
||||
start = get_millisecs_now();
|
||||
|
||||
for (i = 0; i < repeat; ++i) {
|
||||
delta_size = bench_speed(from_buf, from_len,
|
||||
to_buf, to_len, delta_buf, delta_alloc, flags);
|
||||
}
|
||||
|
||||
finish = get_millisecs_now();
|
||||
|
||||
fprintf(stderr,
|
||||
"STAT: encode %3.2f ms from %s to %s repeat %d %zdbit delta %zd\n",
|
||||
(double)(finish - start) / repeat, from, to, repeat, sizeof (xoff_t) * 8, delta_size);
|
||||
|
||||
ret = 0;
|
||||
|
||||
if (0) {
|
||||
exit:
|
||||
ret = 1;
|
||||
}
|
||||
|
||||
main_free(to_buf);
|
||||
main_free(from_buf);
|
||||
main_free(delta_buf);
|
||||
return ret;
|
||||
}
|
56
lib/xdelta3/examples/test.h
Normal file
56
lib/xdelta3/examples/test.h
Normal file
|
@ -0,0 +1,56 @@
|
|||
/* xdelta3 - delta compression tools and library
|
||||
Copyright 2016 Joshua MacDonald
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#define NOT_MAIN 1
|
||||
|
||||
#include "xdelta3.h"
|
||||
#include "xdelta3.c"
|
||||
|
||||
static int read_whole_file(const char *name,
|
||||
uint8_t **buf_ptr,
|
||||
size_t *buf_len) {
|
||||
main_file file;
|
||||
int ret;
|
||||
xoff_t len;
|
||||
usize_t nread;
|
||||
main_file_init(&file);
|
||||
file.filename = name;
|
||||
ret = main_file_open(&file, name, XO_READ);
|
||||
if (ret != 0) {
|
||||
fprintf(stderr, "open failed\n");
|
||||
goto exit;
|
||||
}
|
||||
ret = main_file_stat(&file, &len);
|
||||
if (ret != 0) {
|
||||
fprintf(stderr, "stat failed\n");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
(*buf_len) = (size_t)len;
|
||||
(*buf_ptr) = (uint8_t*) main_malloc(*buf_len);
|
||||
ret = main_file_read(&file, *buf_ptr, *buf_len, &nread,
|
||||
"read failed");
|
||||
if (ret == 0 && *buf_len == nread) {
|
||||
ret = 0;
|
||||
} else {
|
||||
fprintf(stderr, "invalid read\n");
|
||||
ret = XD3_INTERNAL;
|
||||
}
|
||||
exit:
|
||||
main_file_cleanup(&file);
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue