37 #define LZ4F_STATIC_LINKING_ONLY
41 #define XXH_STATIC_LINKING_ONLY
56 #define DISPLAY(...) fprintf(stderr, __VA_ARGS__)
57 #define DISPLAYLEVEL(l, ...) if (displayLevel>=l) { DISPLAY(__VA_ARGS__); }
65 #define DEBUGOUTPUT(...) if (DEBUG) DISPLAY(__VA_ARGS__);
66 #define EXM_THROW(error, ...) \
68 DEBUGOUTPUT("Error defined at %s, line %i : \n", __FILE__, __LINE__); \
69 DISPLAYLEVEL(1, "Error %i : ", error); \
70 DISPLAYLEVEL(1, __VA_ARGS__); \
71 DISPLAYLEVEL(1, " \n"); \
88 #define MIN(a,b) ( (a) < (b) ? (a) : (b) )
89 #define MAX(a,b) ( (a) > (b) ? (a) : (b) )
109 EXM_THROW(20,
"Allocation error : not enough memory");
115 EXM_THROW(21,
"Unable to create decompression context");
131 size_t curblocksize = 0;
132 int partialBlock = 0;
144 if (!readSize)
break;
146 while (
pos < readSize) {
151 remaining = readSize -
pos;
154 EXM_THROW(22,
"Error getting frame info: %s",
157 EXM_THROW(23,
"Block size ID %u != expected %u",
161 remaining = nextToLoad;
169 if (nextToLoad > (readSize -
pos)) {
172 remaining = readSize -
pos;
177 remaining = nextToLoad;
181 curblocksize += decodedBytes;
185 if ((curblocksize != 0) && (nextToLoad > 4)) {
186 if (curblocksize != blockSize)
187 EXM_THROW(25,
"Block size %u != expected %u, pos %u\n",
188 (
unsigned)curblocksize, (
unsigned)blockSize, (
unsigned)
pos);
195 if (ferror(srcFile))
EXM_THROW(26,
"Read error");
197 if (nextToLoad!=0)
EXM_THROW(27,
"Unfinished stream");
205 DISPLAY(
" %s [args] filename\n", programName);
208 DISPLAY(
" -b# : expected blocksizeID [4-7] (required)\n");
209 DISPLAY(
" -B# : expected blocksize [32-4194304] (required)\n");
211 DISPLAY(
" -h : display help and exit\n");
221 const char*
const programName =
argv[0];
224 for (argNb=1; argNb<argc; argNb++) {
225 const char* argument =
argv[argNb];
227 if(!argument)
continue;
230 if (argument[0]==
'-') {
231 if (!strcmp(argument,
"--no-prompt")) {
238 while (*argument!=0) {
259 while ((*argument>=
'0') && (*argument<=
'9')) {
261 bsid += (
unsigned)(*argument -
'0');
269 while ((*argument>=
'0') && (*argument<=
'9')) {
271 blockSize += (
size_t)(*argument -
'0');
285 if (bsid == 0 || blockSize == 0)
290 srcFile = fopen(argument,
"rb");
291 if ( srcFile==
NULL ) {
293 EXM_THROW(1,
"%s: %s \n", argument, strerror(errno));
int main(int argc, const char **argv)
#define EXM_THROW(error,...)
int frameCheck(cRess_t ress, FILE *const srcFile, unsigned bsid, size_t blockSize)
static void freeCResources(cRess_t ress)
static int createCResources(cRess_t *ress)
int FUZ_usage(const char *programName)
RZ_API void Ht_() free(HtName_(Ht) *ht)
void * malloc(size_t size)
static static fork const void static count static fd const char const char static newpath char char argv
static void struct sockaddr socklen_t static fromlen static backlog static fork char char char static envp int struct rusage static rusage struct utsname static buf struct sembuf unsigned
#define LZ4_VERSION_STRING
LZ4F_errorCode_t LZ4F_freeDecompressionContext(LZ4F_dctx *dctx)
size_t LZ4F_decompress(LZ4F_dctx *dctx, void *dstBuffer, size_t *dstSizePtr, const void *srcBuffer, size_t *srcSizePtr, const LZ4F_decompressOptions_t *decompressOptionsPtr)
unsigned LZ4F_isError(LZ4F_errorCode_t code)
LZ4F_errorCode_t LZ4F_getFrameInfo(LZ4F_dctx *dctx, LZ4F_frameInfo_t *frameInfoPtr, const void *srcBuffer, size_t *srcSizePtr)
LZ4F_errorCode_t LZ4F_createDecompressionContext(LZ4F_dctx **LZ4F_decompressionContextPtr, unsigned versionNumber)
const char * LZ4F_getErrorName(LZ4F_errorCode_t code)
assert(limit<=UINT32_MAX/2)
LZ4F_blockSizeID_t blockSizeID
LZ4F_compressionContext_t ctx
LZ4F_decompressionContext_t ctx