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