1 // Copyright 2015 The Chromium OS Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef _BSDIFF_BSDIFF_H_ 6 #define _BSDIFF_BSDIFF_H_ 7 8 #include <stddef.h> 9 #include <stdint.h> 10 11 #include "bsdiff/common.h" 12 #include "bsdiff/patch_writer_interface.h" 13 #include "bsdiff/suffix_array_index_interface.h" 14 15 namespace bsdiff { 16 17 // Generate bsdiff patch from |old_buf| to |new_buf|, save the patch file to 18 // |patch_filename|. Returns 0 on success. 19 // |sai_cache| can be used to cache the suffix array if the same |old_buf| is 20 // used repeatedly, pass nullptr if not needed. 21 BSDIFF_EXPORT 22 int bsdiff(const uint8_t* old_buf, 23 size_t oldsize, 24 const uint8_t* new_buf, 25 size_t newsize, 26 const char* patch_filename, 27 SuffixArrayIndexInterface** sai_cache); 28 29 BSDIFF_EXPORT 30 int bsdiff(const uint8_t* old_buf, 31 size_t oldsize, 32 const uint8_t* new_buf, 33 size_t newsize, 34 PatchWriterInterface* patch, 35 SuffixArrayIndexInterface** sai_cache); 36 37 // The |min_length| parameter determines the required minimum length of a match 38 // to be considered instead of emitting mismatches. The minimum value is 9, 39 // since smaller matches are always ignored. If a smaller value is passed, the 40 // minimum value of 9 will be used instead. A very large value (past 30) will 41 // give increasingly bad results as you increase the minimum length since legit 42 // matches between the old and new data will be ignored. The exact best value 43 // depends on the data, but the sweet spot should be between 9 and 20 for the 44 // examples tested. 45 BSDIFF_EXPORT 46 int bsdiff(const uint8_t* old_buf, 47 size_t oldsize, 48 const uint8_t* new_buf, 49 size_t newsize, 50 size_t min_length, 51 PatchWriterInterface* patch, 52 SuffixArrayIndexInterface** sai_cache); 53 54 } // namespace bsdiff 55 56 #endif // _BSDIFF_BSDIFF_H_ 57