mirror of
https://git.triforceproject.com/triforce/source
synced 2026-11-20 16:49:57 -04:00
Triforce v0.2.0
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
23
third_party/zbic/zbic_api.c
vendored
Normal file
23
third_party/zbic/zbic_api.c
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
/* A C entry point for ZBIC decompression (Atmosphere's zstd with ZSTD_ZBIC_SUPPORT), loaded by nx2/zbic.py with
|
||||
* ctypes. Returns the decompressed size, or -1 (bad data or the size is not in the frame header), or -2 (the
|
||||
* output buffer is too small or the data is corrupt). */
|
||||
#include <stddef.h>
|
||||
#include "zstd.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#define API __declspec(dllexport)
|
||||
#else
|
||||
#define API __attribute__((visibility("default")))
|
||||
#endif
|
||||
|
||||
API long long zbic_content_size(const void *src, size_t n) {
|
||||
unsigned long long s = ZSTD_getFrameContentSize(src, n);
|
||||
if (s == ZSTD_CONTENTSIZE_ERROR || s == ZSTD_CONTENTSIZE_UNKNOWN) return -1;
|
||||
return (long long)s;
|
||||
}
|
||||
|
||||
API long long zbic_decompress(void *dst, size_t cap, const void *src, size_t n) {
|
||||
size_t r = ZSTD_decompress(dst, cap, src, n);
|
||||
if (ZSTD_isError(r)) return -2;
|
||||
return (long long)r;
|
||||
}
|
||||
Reference in New Issue
Block a user