bpak_bspatch — bspatch¶
The BPAK bspatch module, bspatch is used to apply a binary patch one some source data to produce target data.
Source code: include/bpak/bspatch.h, lib/bspatch.c
BPAK - Bit Packer
Copyright (C) 2022 Jonas Blixt jonpe960@gmail.com
SPDX-License-Identifier: BSD-3-Clause
Defines
-
BPAK_BSPATCH_CTRL_BUFFER_LENGTH¶
Enums
Functions
-
int bpak_bspatch_init(struct bpak_bspatch_context *ctx, uint8_t *buffer, size_t buffer_length, size_t input_length, bpak_io_t read_origin, off_t origin_offset, bpak_io_t write_output, off_t output_offset, enum bpak_compression compression, void *user_priv)¶
Initialize the BPAK bspatch context
- Parameters:
ctx – [in] Pointer to the context
buffer – [in] Work buffer for bspatch
buffer_length – [in] Size of bspatch internal buffers in bytes
read_origin – [in] Callback for reading origin data
write_output – [in] Callback for writing output data
user_priv – [in] User context sent to call backs
- Returns:
BPAK_OK on success or a negative number
-
int bpak_bspatch_write(struct bpak_bspatch_context *ctx, uint8_t *buffer, size_t length)¶
Feed bspatch with input data
- Parameters:
ctx – [in] Pointer to bspatch context
buffer – [in] Input buffer
length – [in] Bytes available in inputbuffer
- Returns:
BPAK_OK on success or a negative number
-
ssize_t bpak_bspatch_final(struct bpak_bspatch_context *ctx)¶
Call bpak_bsptach_final when there is no more input.
- Parameters:
ctx – [in] Pointer to bspatch context
- Returns:
the output patched size or a negative number on error
-
void bpak_bspatch_free(struct bpak_bspatch_context *ctx)¶
Free the bspatch context
- Parameters:
ctx – [in] bspatch context
-
struct bpak_bspatch_context¶
Public Members
-
off_t origin_position¶
Current position in origin data
-
off_t origin_offset¶
Origin stream offset
-
off_t output_position¶
Current position in output data
-
off_t output_offset¶
Output stream offset
-
enum bpak_bspatch_state state¶
Current state of bspatch
-
uint8_t *patch_buffer¶
Chunk of patch data input
-
size_t patch_buffer_length¶
Length of patch buffer
-
uint8_t *input_buffer¶
-
size_t input_buffer_length¶
-
size_t input_length¶
-
size_t input_position¶
-
uint8_t ctrl_buf[BPAK_BSPATCH_CTRL_BUFFER_LENGTH]¶
Hold the current control header
-
uint8_t ctrl_buf_count¶
Fill status of control buffer
-
int64_t diff_count¶
Current patch block: amount of diff bytes
-
int64_t extra_count¶
Current patch block: extra bytes
-
int64_t adjust¶
Current patch block: Origin offset adjustment
-
enum bpak_compression compression¶
-
heatshrink_decoder hsd¶
-
union bpak_bspatch_context::[anonymous] decompressor¶
-
void *user_priv¶
-
off_t origin_position¶