BsDiPa
view release on metacpan or search on metacpan
c-lib/s-bsdipa-lib.h view on Meta::CPAN
/*@ s-bsdipa-lib: port of Colin Percival's BSDiff(/bspatch) to a library.
*@ BSDiff: create or apply binary difference patch.
*@
*@ Remarks:
*@ - If s_BSDIPA_32 is defined, 31-bit instead of 63-bit limits.
*@ - Note: the real limit is maximally
*@ MIN(s_BSDIPA_OFF_MAX, SIZE_MAX) / sizeof(s_bsdipa_off_t)
*@ (with 32-bit size_t this can be restrictive)!
*@ - Algorithm requires a lot of memory, multiple times the input size!
*@ With s_BSDIPA_32 the overhead can almost be halved.
*@ - If s_BSDIPA_SMALL is defined, libdivsufsort is not actually used,
*@ but only the original BSDiff algorithm of Colin Percival.
*@ - If s_BSDIPA_TEXT is defined, alternatively selectable text (linewise)
*@ differential approach (nothing special, but produces same patch format.)
*@ - Code requires an ISO STD C99 environment.
*@
*@ Changes to original bsdiff / libdivsufsort:
*@ - Optional (s_BSDIPA_32) 31-bit limits, thus smaller header/control data,
*@ as well as smaller (about halved) memory overhead.
*@ - The s_BSDIPA_MAGIC_WINDOW is configurable: the original is bound to
*@ (32- and) 64-bit binary diffs (8), but eg 16 or 32 are better (for text).
*@ - Data serialization is in big endian/network byte order.
*@ - No file I/O, everything is stored on the heap.
*@ - No bzip2 compression: callee should compress result.
*@ NOTE: compression is necessary since data is stored in full, meaning
*@ that identical bytes are stored as NUL.
*@ -- The s-bsdipa-io.h header is a readily available I/O layer.
*@ NOTE: I/O layers may impose further size limit restrictions!
*@ - Internally diff- and extra data share heap to reduce memory overhead.
*@ -- As a result diff data is stored in reverse order, last byte first.
*@ - Memory allocation is solely done via user provided allocator.
*@ - The header includes the extra data length, so that all information
*@ is available through it.
*@ - "Data-less" control blocks cannot occur (but for the first):
*@ BSDiff may generate control blocks which contain no data, but only seek.
*@ Such fragments are instead collapsed to the former control block,
*@ tightening testable constraints on the header and control chunks.
*@
*@ Informational: original bsdiff file format:
*@ 0 8 "BSDIFF40"
*@ 8 8 X
*@ 16 8 Y
*@ 24 8 sizeof(result[file])
*@ 32 X bzip2(control block)
*@ 32+X Y bzip2(diff block)
*@ 32+X+Y ??? bzip2(extra block)
*@ With control block being a set of triples (x,y,z) meaning "read x bytes of
*@ diff data into NEW, then add x bytes from OLD to these x bytes in NEW;
*@ copy y bytes from the extra block onto NEW; seek forwards in OLD by z".
*/
#define s_BSDIPA_COPYRIGHT \
"S-bsdipa is\n" \
" Copyright (c) 2024 - 2026 Steffen Nurpmeso\n" \
" SPDX-License-Identifier: ISC\n" \
"The used BSDiff algorithm is\n" \
" Copyright 2003-2005 Colin Percival\n" \
" SPDX-License-Identifier: BSD-2-Clause\n" \
"and it optionally (!s_BSDIPA_SMALL) uses libdivsufsort that is\n" \
" Copyright (c) 2003 Yuta Mori All rights reserved.\n" \
" SPDX-License-Identifier: MIT\n"
/* L5E> */
/*@ S-bsdipa copyright:
*
* Copyright (c) 2024 - 2026 Steffen Nurpmeso <steffen@sdaoden.eu>.
* SPDX-License-Identifier: ISC
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*@ The algorithm as is used inside the library (s-bsdiff.c) is:
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright 2003-2005 Colin Percival
* All rights reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted providing that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
( run in 0.796 second using v1.01-cache-2.11-cpan-b16cb0d3907 )