-rw-r--r-- | rsync/sumset.c | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/rsync/sumset.c b/rsync/sumset.c new file mode 100644 index 0000000..c03aeb4 --- a/dev/null +++ b/rsync/sumset.c | |||
@@ -0,0 +1,83 @@ | |||
1 | /*= -*- c-basic-offset: 4; indent-tabs-mode: nil; -*- | ||
2 | * | ||
3 | * librsync -- library for network deltas | ||
4 | * $Id$ | ||
5 | * | ||
6 | * Copyright (C) 1999, 2000, 2001 by Martin Pool <mbp@samba.org> | ||
7 | * Copyright (C) 1999 by Andrew Tridgell | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU Lesser General Public License as published by | ||
11 | * the Free Software Foundation; either version 2.1 of the License, or | ||
12 | * (at your option) any later version. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | * GNU Lesser General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU Lesser General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
22 | */ | ||
23 | |||
24 | #include <config_rsync.h> | ||
25 | |||
26 | #include <assert.h> | ||
27 | #include <stdlib.h> | ||
28 | #include <stdio.h> | ||
29 | |||
30 | #include "rsync.h" | ||
31 | #include "sumset.h" | ||
32 | #include "util.h" | ||
33 | #include "trace.h" | ||
34 | |||
35 | |||
36 | /** | ||
37 | * Deep deallocation of checksums. | ||
38 | */ | ||
39 | void | ||
40 | rs_free_sumset(rs_signature_t * psums) | ||
41 | { | ||
42 | if (psums->block_sigs) | ||
43 | free(psums->block_sigs); | ||
44 | |||
45 | if (psums->tag_table) | ||
46 | free(psums->tag_table); | ||
47 | |||
48 | if (psums->targets) | ||
49 | free(psums->targets); | ||
50 | |||
51 | rs_bzero(psums, sizeof *psums); | ||
52 | free(psums); | ||
53 | } | ||
54 | |||
55 | |||
56 | |||
57 | /** | ||
58 | * Dump signatures to the log. | ||
59 | */ | ||
60 | void | ||
61 | rs_sumset_dump(rs_signature_t const *sums) | ||
62 | { | ||
63 | int i; | ||
64 | char strong_hex[RS_MD4_LENGTH * 3]; | ||
65 | |||
66 | rs_log(RS_LOG_INFO, | ||
67 | "sumset info: block_len=%d, file length=%lu, " | ||
68 | "number of chunks=%d, remainder=%d", | ||
69 | sums->block_len, | ||
70 | (unsigned long) sums->flength, sums->count, | ||
71 | sums->remainder); | ||
72 | |||
73 | for (i = 0; i < sums->count; i++) { | ||
74 | rs_hexify(strong_hex, sums->block_sigs[i].strong_sum, | ||
75 | sums->strong_sum_len); | ||
76 | rs_log(RS_LOG_INFO, | ||
77 | "sum %6d: weak=%08x, strong=%s", | ||
78 | i, sums->block_sigs[i].weak_sum, strong_hex); | ||
79 | } | ||
80 | } | ||
81 | |||
82 | |||
83 | |||