"Fossies" - the Fresh Open Source Software Archive

Member "zsync-0.6.2/librcksum/rcksum.h" (16 Sep 2010, 2931 Bytes) of package /linux/privat/old/zsync-0.6.2.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. For more information about "rcksum.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2  *   rcksum/lib - library for using the rsync algorithm to determine
    3  *               which parts of a file you have and which you need.
    4  *   Copyright (C) 2004,2005,2009 Colin Phipps <cph@moria.org.uk>
    5  *
    6  *   This program is free software; you can redistribute it and/or modify
    7  *   it under the terms of the Artistic License v2 (see the accompanying 
    8  *   file COPYING for the full license terms), or, at your option, any later 
    9  *   version of the same license.
   10  *
   11  *   This program is distributed in the hope that it will be useful,
   12  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
   14  *   COPYING file for details.
   15  */
   17 /* This is the library interface. Very changeable at this stage. */
   19 #include <stdio.h>
   21 struct rcksum_state;
   23 typedef int zs_blockid;
   25 struct rsum {
   26     unsigned short  a;
   27     unsigned short  b;
   28 } __attribute__((packed));
   30 #define CHECKSUM_SIZE 16
   32 struct rcksum_state* rcksum_init(zs_blockid nblocks, size_t blocksize, int rsum_butes, int checksum_bytes, int require_consecutive_matches);
   33 void rcksum_end(struct rcksum_state* z);
   35 /* These transfer out the filename and handle of the file backing the data retrieved.
   36  * Once you have transferred out the file handle, you can no longer read and write data through librcksum - it has handed it over to you, and can use it no more itself.
   37  * If you transfer out the filename, you are responsible for renaming it to something useful. If you don't transfer out the filename, librcksum will unlink it at rcksum_end.
   38  */
   39 char* rcksum_filename(struct rcksum_state* z);
   40 int rcksum_filehandle(struct rcksum_state* z);
   42 void rcksum_add_target_block(struct rcksum_state* z, zs_blockid b, struct rsum r, void* checksum);
   44 int rcksum_submit_blocks(struct rcksum_state* z, const unsigned char* data, zs_blockid bfrom, zs_blockid bto);
   45 int rcksum_submit_source_data(struct rcksum_state* z, unsigned char* data, size_t len, off_t offset);
   46 int rcksum_submit_source_file(struct rcksum_state* z, FILE* f, int progress);
   48 /* This reads back in data which is already known. */
   49 int rcksum_read_known_data(struct rcksum_state* z, unsigned char* buf, off_t offset, size_t len);
   51 /* rcksum_needed_block_ranges tells you what blocks, within the given range,
   52  * are still unknown. It returns a list of block ranges in r[]
   53  * (at most max ranges, so spece for 2*max elements must be there)
   54  * these are half-open ranges, so r[0] <= x < r[1], r[2] <= x < r[3] etc are needed */
   55 zs_blockid* rcksum_needed_block_ranges(const struct rcksum_state* z, int* num, zs_blockid from, zs_blockid to);
   56 int rcksum_blocks_todo(const struct rcksum_state*);
   58 /* For preparing rcksum control files - in both cases len is the block size. */
   59 struct rsum __attribute__((pure)) rcksum_calc_rsum_block(const unsigned char* data, size_t len);
   60 void rcksum_calc_checksum(unsigned char *c, const unsigned char* data, size_t len);