"Fossies" - the Fresh Open Source Software Archive 
Member "xdelta3-3.0.11/testing/delta.h" (24 Mar 2015, 1512 Bytes) of package /linux/misc/xdelta3-3.0.11.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
1 // Mode: -*- C++ -*-
2
3 class Delta {
4 public:
5 Delta(const Block &block) {
6 int ret;
7 xd3_config config;
8 memset(&stream_, 0, sizeof (stream_));
9 memset(&config, 0, sizeof (config));
10
11 xd3_init_config(&config, XD3_SKIP_EMIT | XD3_ADLER32_NOVER);
12
13 CHECK_EQ(0, xd3_config_stream (&stream_, &config));
14
15 xd3_avail_input (&stream_, block.Data(), block.Size());
16
17 bool done = false;
18 while (!done) {
19 ret = xd3_decode_input(&stream_);
20
21 switch (ret) {
22 case XD3_INPUT:
23 done = true;
24 break;
25 case XD3_OUTPUT:
26 CHECK_EQ(0, xd3_whole_append_window (&stream_));
27 break;
28 case XD3_GOTHEADER:
29 case XD3_WINSTART:
30 case XD3_WINFINISH:
31 break;
32 default:
33 DP(RINT "error code %s\n", xd3_strerror (ret));
34 abort();
35 }
36 }
37 }
38
39 ~Delta() {
40 xd3_free_stream(&stream_);
41 }
42
43 xoff_t AddedBytes() const {
44 return stream_.whole_target.addslen;
45 }
46
47 xoff_t Windows() const {
48 return stream_.whole_target.wininfolen;
49 }
50
51 void Print() const {
52 for (size_t i = 0; i < stream_.whole_target.instlen; i++) {
53 xd3_winst &winst = stream_.whole_target.inst[i];
54 switch (winst.type) {
55 case XD3_RUN:
56 DP(RINT "%"Q"u run %u\n", winst.position, winst.size);
57 break;
58 case XD3_ADD:
59 DP(RINT "%"Q"u add %u\n", winst.position, winst.size);
60 break;
61 default:
62 DP(RINT "%"Q"u copy %u @ %"Q"u (mode %u)\n",
63 winst.position, winst.size, winst.addr, winst.mode);
64 break;
65 }
66 }
67 }
68
69 private:
70 xd3_stream stream_;
71 };