Unify external API signatures across all buffer transforms

Every exported buffer transform now has the same shape:

    int32_t AARU_xxx(const uint8_t *src_buffer, size_t src_size,
                     uint8_t *dst_buffer, size_t *dst_size, ...extras);

On entry *dst_size is the capacity of dst_buffer; on success it holds the
number of bytes written. The return value is 0 (AARU_ERROR_NONE) on success
and non-zero on error, either an AARU_ERROR_* constant or the underlying
library's own error code when it is propagated.

Changes by category:

- Parameter reorder only: all AARU_zip_*, AARU_stuffit*, AARU_dd_*,
  AARU_cpt_*, AARU_lzo_*, AARU_xz_*, AARU_lzma2_*, AARU_kencode_*,
  AARU_apple_lzh_* and ace_decompress_*.
- Byte count return replaced by an out-parameter plus a status code:
  AARU_adc_*, AARU_apple_rle_*, AARU_lz4_*, AARU_lzip_*, AARU_lzfse_*,
  AARU_lzvn_*, AARU_zstd_* and AARU_flac_*. Their algorithm bodies are kept
  as static internals behind a thin exported wrapper.
- Type normalisation: bzip2 uint32_t* -> size_t*, zstd void* -> uint8_t*,
  ZIP PPMd size_t -> size_t*, and int/unsigned char -> int32_t/uint8_t
  throughout the header.
- AARU_lzma_decode_buffer no longer takes src_size as an in/out pointer; the
  consumed length is tracked internally.
- Already conforming decompressors (arc_*, pak_*, ha_*, lha_*, larc_*,
  pmarc_*, arj*, rar*, lh5_decompress) only had their declarations
  normalised.

The streaming LZD context API and AARU_get_acn_version are left alone, as
they are not buffer transforms.

Tests updated to the new call convention; all 78 pass.
This commit is contained in:
2026-08-31 12:26:05 +01:00
parent bbae748612
commit adecbc7c7f
26 changed files with 859 additions and 515 deletions

View File

@@ -59,7 +59,7 @@ TEST_F(StuffitCompressFixture, stuffit_compress)
size_t destLen = EXPECTED_ORIGSIZE;
auto *outBuf = (uint8_t *)malloc(EXPECTED_ORIGSIZE);
auto err = AARU_stuffit_compress_decode_buffer(outBuf, &destLen, compress_buffer, COMPRESS_SIZE);
auto err = AARU_stuffit_compress_decode_buffer(compress_buffer, COMPRESS_SIZE, outBuf, &destLen);
EXPECT_EQ(err, 0);
EXPECT_EQ(destLen, (size_t)EXPECTED_ORIGSIZE);
@@ -97,7 +97,7 @@ TEST_F(StuffitMethod13Fixture, stuffit_method13)
size_t destLen = EXPECTED_ORIGSIZE;
auto *outBuf = (uint8_t *)malloc(EXPECTED_ORIGSIZE);
auto err = AARU_stuffit_method13_decode_buffer(outBuf, &destLen, method13_buffer, METHOD13_SIZE);
auto err = AARU_stuffit_method13_decode_buffer(method13_buffer, METHOD13_SIZE, outBuf, &destLen);
EXPECT_EQ(err, 0);
EXPECT_EQ(destLen, (size_t)EXPECTED_ORIGSIZE);
@@ -135,7 +135,7 @@ TEST_F(StuffitMethod13V5Fixture, stuffit_method13_v5)
size_t destLen = EXPECTED_ORIGSIZE;
auto *outBuf = (uint8_t *)malloc(EXPECTED_ORIGSIZE);
auto err = AARU_stuffit_method13_decode_buffer(outBuf, &destLen, method13_v5_buffer, METHOD13_V5_SIZE);
auto err = AARU_stuffit_method13_decode_buffer(method13_v5_buffer, METHOD13_V5_SIZE, outBuf, &destLen);
EXPECT_EQ(err, 0);
EXPECT_EQ(destLen, (size_t)EXPECTED_ORIGSIZE);
@@ -173,7 +173,7 @@ TEST_F(StuffitArsenicFixture, stuffit_arsenic)
size_t destLen = EXPECTED_ORIGSIZE;
auto *outBuf = (uint8_t *)malloc(EXPECTED_ORIGSIZE);
auto err = AARU_stuffit_arsenic_decode_buffer(outBuf, &destLen, arsenic_buffer, ARSENIC_SIZE);
auto err = AARU_stuffit_arsenic_decode_buffer(arsenic_buffer, ARSENIC_SIZE, outBuf, &destLen);
EXPECT_EQ(err, 0);
EXPECT_EQ(destLen, (size_t)EXPECTED_ORIGSIZE);
@@ -224,7 +224,7 @@ TEST_F(StuffitxBrimstoneFixture, stuffitx_brimstone)
size_t midLen = EXPECTED_ORIGSIZE * 2;
auto *midBuf = (uint8_t *)malloc(midLen);
auto err = AARU_stuffitx_brimstone_decode_buffer(midBuf, &midLen, buf + 2, BRIMSTONE_SIZE - 2, order, allocsize);
auto err = AARU_stuffitx_brimstone_decode_buffer(buf + 2, BRIMSTONE_SIZE - 2, midBuf, &midLen, order, allocsize);
EXPECT_EQ(err, 0);
EXPECT_GT(midLen, (size_t)0);
@@ -232,7 +232,7 @@ TEST_F(StuffitxBrimstoneFixture, stuffitx_brimstone)
size_t destLen = EXPECTED_ORIGSIZE;
auto *outBuf = (uint8_t *)malloc(destLen);
err = AARU_stuffitx_english_decode_buffer(outBuf, &destLen, midBuf, midLen);
err = AARU_stuffitx_english_decode_buffer(midBuf, midLen, outBuf, &destLen);
free(midBuf);
EXPECT_EQ(err, 0);
EXPECT_EQ(destLen, (size_t)EXPECTED_ORIGSIZE);
@@ -262,14 +262,14 @@ TEST_F(StuffitxCyanideFixture, stuffitx_cyanide)
size_t midLen = EXPECTED_ORIGSIZE * 2;
auto *midBuf = (uint8_t *)malloc(midLen);
auto err = AARU_stuffitx_cyanide_decode_buffer(midBuf, &midLen, buf, CYANIDE_SIZE);
auto err = AARU_stuffitx_cyanide_decode_buffer(buf, CYANIDE_SIZE, midBuf, &midLen);
EXPECT_EQ(err, 0);
EXPECT_GT(midLen, (size_t)0);
size_t destLen = EXPECTED_ORIGSIZE;
auto *outBuf = (uint8_t *)malloc(destLen);
err = AARU_stuffitx_english_decode_buffer(outBuf, &destLen, midBuf, midLen);
err = AARU_stuffitx_english_decode_buffer(midBuf, midLen, outBuf, &destLen);
free(midBuf);
EXPECT_EQ(err, 0);
EXPECT_EQ(destLen, (size_t)EXPECTED_ORIGSIZE);
@@ -301,14 +301,14 @@ TEST_F(StuffitxDarkhorseFixture, stuffitx_darkhorse)
size_t midLen = EXPECTED_ORIGSIZE * 2;
auto *midBuf = (uint8_t *)malloc(midLen);
auto err = AARU_stuffitx_darkhorse_decode_buffer(midBuf, &midLen, buf + 1, DARKHORSE_SIZE - 1, window_bits);
auto err = AARU_stuffitx_darkhorse_decode_buffer(buf + 1, DARKHORSE_SIZE - 1, midBuf, &midLen, window_bits);
EXPECT_EQ(err, 0);
EXPECT_GT(midLen, (size_t)0);
size_t destLen = EXPECTED_ORIGSIZE;
auto *outBuf = (uint8_t *)malloc(destLen);
err = AARU_stuffitx_english_decode_buffer(outBuf, &destLen, midBuf, midLen);
err = AARU_stuffitx_english_decode_buffer(midBuf, midLen, outBuf, &destLen);
free(midBuf);
EXPECT_EQ(err, 0);
EXPECT_EQ(destLen, (size_t)EXPECTED_ORIGSIZE);
@@ -338,14 +338,14 @@ TEST_F(StuffitxDeflateFixture, stuffitx_deflate)
size_t midLen = EXPECTED_ORIGSIZE * 2;
auto *midBuf = (uint8_t *)malloc(midLen);
auto err = AARU_stuffitx_deflate_decode_buffer(midBuf, &midLen, buf + 1, SITX_DEFLATE_SIZE - 1);
auto err = AARU_stuffitx_deflate_decode_buffer(buf + 1, SITX_DEFLATE_SIZE - 1, midBuf, &midLen);
EXPECT_EQ(err, 0);
EXPECT_GT(midLen, (size_t)0);
size_t destLen = EXPECTED_ORIGSIZE;
auto *outBuf = (uint8_t *)malloc(destLen);
err = AARU_stuffitx_english_decode_buffer(outBuf, &destLen, midBuf, midLen);
err = AARU_stuffitx_english_decode_buffer(midBuf, midLen, outBuf, &destLen);
free(midBuf);
EXPECT_EQ(err, 0);
EXPECT_EQ(destLen, (size_t)EXPECTED_ORIGSIZE);
@@ -375,14 +375,14 @@ TEST_F(StuffitxBlendFixture, stuffitx_blend)
size_t midLen = EXPECTED_ORIGSIZE * 2;
auto *midBuf = (uint8_t *)malloc(midLen);
auto err = AARU_stuffitx_blend_decode_buffer(midBuf, &midLen, buf, BLEND_SIZE);
auto err = AARU_stuffitx_blend_decode_buffer(buf, BLEND_SIZE, midBuf, &midLen);
EXPECT_EQ(err, 0);
EXPECT_GT(midLen, (size_t)0);
size_t destLen = EXPECTED_ORIGSIZE;
auto *outBuf = (uint8_t *)malloc(destLen);
err = AARU_stuffitx_english_decode_buffer(outBuf, &destLen, midBuf, midLen);
err = AARU_stuffitx_english_decode_buffer(midBuf, midLen, outBuf, &destLen);
free(midBuf);
EXPECT_EQ(err, 0);
EXPECT_EQ(destLen, (size_t)EXPECTED_ORIGSIZE);
@@ -415,7 +415,7 @@ TEST_F(StuffitShrinkwrapFixture, stuffit_shrinkwrap)
size_t destLen = SHRINKWRAP_ORIGSIZE;
auto *outBuf = (uint8_t *)malloc(SHRINKWRAP_ORIGSIZE);
auto err = AARU_stuffit_shrinkwrap_decode_buffer(outBuf, &destLen, buf, SHRINKWRAP_SIZE);
auto err = AARU_stuffit_shrinkwrap_decode_buffer(buf, SHRINKWRAP_SIZE, outBuf, &destLen);
EXPECT_EQ(err, 0);
EXPECT_EQ(destLen, (size_t)SHRINKWRAP_ORIGSIZE);