"Fossies" - the Fresh Open Source Software Archive

Member "zsync-0.6.2/libzsync/zsync.h" (16 Sep 2010, 4197 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 "zsync.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2  *   zsync - client side rsync over http
    3  *   Copyright (C) 2004,2005,2009 Colin Phipps <cph@moria.org.uk>
    4  *
    5  *   This program is free software; you can redistribute it and/or modify
    6  *   it under the terms of the Artistic License v2 (see the accompanying 
    7  *   file COPYING for the full license terms), or, at your option, any later 
    8  *   version of the same license.
    9  *
   10  *   This program is distributed in the hope that it will be useful,
   11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
   12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   13  *   COPYING file for details.
   14  */
   15 
   16 struct zsync_state;
   17 
   18 /* zsync_begin - load a zsync file and return data structure to use for the rest of the process.
   19  */
   20 struct zsync_state* zsync_begin(FILE* cf);
   21 
   22 /* zsync_hint_decompress - if it returns non-zero, this suggests that 
   23  *  compressed seed files should be decompressed */
   24 int zsync_hint_decompress(const struct zsync_state*);
   25 
   26 /* zsync_filename - return the suggested filename from the .zsync file */
   27 char* zsync_filename(const struct zsync_state*);
   28 /* zsync_mtime - return the suggested mtime from the .zsync file */
   29 time_t zsync_mtime(const struct zsync_state*);
   30 
   31 /* zsync_rename_file - renames the temporary file used by zsync to the given name.
   32  * You don't "own" the filename until you zsync_end, but you can use this to give zsync a more 
   33  * appropriate intermediate filename (in case the user ctrl-c's). 
   34  * This is purely a hint; zsync could ignore it. Returns 0 if successful. */
   35 int zsync_rename_file(struct zsync_state* zs, const char* f);
   36 
   37 /* zsync_status - returns the current state:
   38  * 0 - no relevant local data found yet.
   39  * 1 - some data present
   40  * 2+ - all data downloaded (higher values may be added later to indicate completion
   41  *      of checksumming and file handle states)
   42  */
   43 
   44 int zsync_status(const struct zsync_state* zs);
   45 
   46 /* zsync_progress - returns bytes of the file known so far in *got,
   47  * and the total (roughly, the file length) in *total */
   48 void zsync_progress(const struct zsync_state* zs, long long* got, long long* total);
   49 
   50 /* zsync_submit_source_file - submit local file data to zsync
   51  */
   52 int zsync_submit_source_file(struct zsync_state* zs, FILE* f, int progress);
   53 
   54 /* zsync_get_url - returns a URL from which to get needed data.
   55  * Returns NULL on failure, or a array of pointers to URLs.
   56  * Returns the size of the array in *n,
   57  * and the url type (to pass to needed_byte_ranges & begin_receive)
   58  * (the URL pointers are still referenced by the library, and are valid only until zsync_end).
   59  */
   60 
   61 const char * const * zsync_get_urls(struct zsync_state* zs, int* n, int* t);
   62 
   63 /* zsync_needed_byte_ranges - get the byte ranges needed from a URL.
   64  * Returns the number of ranges in *num, and a malloc'd array (to be freed 
   65  * by the caller) of 2*(*num) off_t's which are the starts and ends 
   66  * of byte ranges.
   67  */
   68 
   69 off_t* zsync_needed_byte_ranges(struct zsync_state* zs, int* num, int type);
   70 
   71 /* zsync_complete - set file length and verify checksum if available
   72  * Returns -1 for failure, 1 for success, 0 for unable to verify (e.g. no checksum in the .zsync) */
   73 int zsync_complete(struct zsync_state* zs);
   74 
   75 /* Clean up and free all resources. The pointer is freed by this call.
   76  * Returns a strdup()d pointer to the name of the file resulting from the process. */
   77 char* zsync_end(struct zsync_state* zs);
   78 
   79 /* And functions for receiving data on the network */
   80 struct zsync_receiver;
   81 
   82 /* Begin and end receiving from a particular URL.
   83  * Note that the zsync_receiver stores a reference to the zsync_state, 
   84  *  and libzsync does not do reference counting, so it is the caller's 
   85  *  responsibility not to do a zsync_end without doing a zsync_end_receive 
   86  *  first.
   87  * The url_type is as in the value returned by zsync_get_url.
   88  */
   89 struct zsync_receiver* zsync_begin_receive(struct zsync_state*zs, int url_type);
   90 void zsync_end_receive(struct zsync_receiver* zr);
   91 
   92 /* Supply data buf of length len received corresponding to offset offset from the URL.
   93  * Returns 0 for success; if not, you should not submit more data. */
   94 int zsync_receive_data(struct zsync_receiver* zr, const unsigned char* buf, off_t offset, size_t len);
   95