Home | History | Annotate | Download | only in puffin
      1 // Copyright 2017 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 SRC_INCLUDE_PUFFIN_PUFFPATCH_H_
      6 #define SRC_INCLUDE_PUFFIN_PUFFPATCH_H_
      7 
      8 #include "puffin/common.h"
      9 #include "puffin/stream.h"
     10 
     11 namespace puffin {
     12 
     13 extern const char kMagic[];
     14 extern const size_t kMagicLength;
     15 
     16 // Applies the puffin patch to deflate stream |src| to create deflate stream
     17 // |dst|. This function is used in the client and internally uses bspatch to
     18 // apply the patch. The input streams are of type |shared_ptr| because
     19 // |PuffPatch| needs to wrap these streams into another ones and we don't want
     20 // to loose the ownership of the input streams. Optionally one can cache the
     21 // puff buffers individually if non-zero value is passed |max_cache_size|.
     22 //
     23 // |src|           IN  Source deflate stream.
     24 // |dst|           IN  Destination deflate stream.
     25 // |patch|         IN  The input patch.
     26 // |patch_length|  IN  The length of the patch.
     27 // |max_cache_size|IN  The maximum amount of memory to cache puff buffers.
     28 PUFFIN_EXPORT
     29 bool PuffPatch(UniqueStreamPtr src,
     30                UniqueStreamPtr dst,
     31                const uint8_t* patch,
     32                size_t patch_length,
     33                size_t max_cache_size = 0);
     34 
     35 }  // namespace puffin
     36 
     37 #endif  // SRC_INCLUDE_PUFFIN_PUFFPATCH_H_
     38