"Fossies" - the Fresh Open Source Software Archive

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

    1 /*
    2  *   zsync - client side rsync over http
    3  *   Copyright (C) 2004,2005,2007,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 #include "zsglobal.h"
   17 
   18 struct gzblock {
   19   uint16_t inbitoffset;
   20   uint16_t outbyteoffset;
   21 } __attribute__((packed));
   22 
   23 #define GZB_NOTBLOCKSTART 0x8000
   24 
   25 struct zmap;
   26 struct z_stream_s;
   27 
   28 struct zmap* zmap_make(const struct gzblock* zb, int n);
   29 void zmap_free(struct zmap*);
   30 
   31 off_t* zmap_to_compressed_ranges(const struct zmap* zm, off_t* byterange, int nrange, int* num);
   32 void configure_zstream_for_zdata(const struct zmap* zm, struct z_stream_s* zs, long zoffset, long long* poutoffset);
   33 
   34 /* gzip flag byte */
   35 #define GZ_ASCII_FLAG   0x01 /* bit 0 set: file probably ascii text */
   36 #define GZ_HEAD_CRC     0x02 /* bit 1 set: header CRC present */
   37 #define GZ_EXTRA_FIELD  0x04 /* bit 2 set: extra field present */
   38 #define GZ_ORIG_NAME    0x08 /* bit 3 set: original file name present */
   39 #define GZ_COMMENT      0x10 /* bit 4 set: file comment present */
   40 #define GZ_RESERVED     0xE0 /* bits 5..7: reserved */
   41 
   42 /* mtime is in bytes 4..7 of the gzip header */
   43 static inline int zhead_has_mtime(const char* p) {
   44     return !!(p[4] || p[5] || p[6] || p[7]);
   45 }
   46 
   47 static inline int zhead_has_fname(const char* p) {
   48     return !!(p[3] & GZ_ORIG_NAME);
   49 }
   50 
   51 static inline const char* skip_zhead(const char* p)
   52 {
   53     const char* q = p + 10;
   54     if (zhead_has_fname(p)) {
   55         q += strlen(q)+1;
   56     }
   57 
   58     return q;
   59 }
   60