bsdiff-portable

A more portable version of Colin Percival's bsdiff
git clone git://git.sgregoratto.me/bsdiff-portable
Log | Files | Refs | README | LICENSE

bsdiff.h (2146B)


      1 #ifndef BSDIFF_H
      2 #define BSDIFF_H
      3 /*-
      4  * Copyright 2003-2005	Colin Percival
      5  * Copyright 2020	Stephen Gregoratto
      6  * All rights reserved
      7  *
      8  * Redistribution and use in source and binary forms, with or without
      9  * modification, are permitted providing that the following conditions
     10  * are met:
     11  * 1. Redistributions of source code must retain the above copyright
     12  *    notice, this list of conditions and the following disclaimer.
     13  * 2. Redistributions in binary form must reproduce the above copyright
     14  *    notice, this list of conditions and the following disclaimer in the
     15  *    documentation and/or other materials provided with the distribution.
     16  *
     17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
     21  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     25  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     26  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     27  * POSSIBILITY OF SUCH DAMAGE.
     28  */
     29 
     30 #ifdef __GNUC__
     31 #define DEAD __attribute__ ((noreturn))
     32 #else
     33 #define DEAD
     34 #endif
     35 
     36 #define MIN(x, y) (((x) < (y)) ? (x) : (y))
     37 
     38 struct bsdiff_header {
     39 	uint8_t magic[8];
     40 	off_t	ctrl_block_len;
     41 	off_t	diff_block_len;
     42 	off_t	new_file_len;
     43 };
     44 
     45 void		split(off_t *, off_t *, off_t, off_t, off_t);
     46 void		qsufsort(off_t *, off_t *, uint8_t *, off_t);
     47 off_t		matchlen(uint8_t *, off_t, uint8_t *, off_t);
     48 off_t		search(off_t *, uint8_t *, off_t, uint8_t *, off_t, off_t,
     49 		       off_t, off_t *);
     50 void		offtout(off_t, uint8_t *);
     51 off_t		offtin(uint8_t *buf);
     52 uint8_t *	readfile(char *, off_t *, struct stat *);
     53 
     54 DEAD void	usage(void);
     55 DEAD void	cleanup_newfile(void);
     56 void		err_rm(const char *, ...);
     57 void		errx_rm(const char *, ...);
     58 #endif /* BSDIFF_H */