Rizin
unix-like reverse engineering framework and cli tools
decompress-partial.c
Go to the documentation of this file.
1 #include "stdio.h"
2 #include "string.h"
3 #include "lz4.h"
4 
5 const char source[] =
6  "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod\n"
7  "tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim\n"
8  "veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea\n"
9  "commodo consequat. Duis aute irure dolor in reprehenderit in voluptate\n"
10  "velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat\n"
11  "cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id\n"
12  "est laborum.\n"
13  "\n"
14  "Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium\n"
15  "doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore\n"
16  "veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim\n"
17  "ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia\n"
18  "consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque\n"
19  "porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur,\n"
20  "adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore\n"
21  "et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis\n"
22  "nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid\n"
23  "ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea\n"
24  "voluptate velit esse quam nihil molestiae consequatur, vel illum qui\n"
25  "dolorem eum fugiat quo voluptas nulla pariatur?\n";
26 
27 #define BUFFER_SIZE 2048
28 
29 int main(void)
30 {
31  int srcLen = (int)strlen(source);
32  char cmpBuffer[BUFFER_SIZE];
33  char outBuffer[BUFFER_SIZE];
34  int cmpSize;
35  int i;
36 
37  cmpSize = LZ4_compress_default(source, cmpBuffer, srcLen, BUFFER_SIZE);
38 
39  for (i = cmpSize; i < cmpSize + 10; ++i) {
40  int result = LZ4_decompress_safe_partial(cmpBuffer, outBuffer, i, srcLen, BUFFER_SIZE);
41  if ((result < 0) || (result != srcLen) || memcmp(source, outBuffer, srcLen)) {
42  printf("test decompress-partial error \n");
43  return -1;
44  }
45  }
46 
47  printf("test decompress-partial OK \n");
48  return 0;
49 }
lzma_index ** i
Definition: index.h:629
_Use_decl_annotations_ int __cdecl printf(const char *const _Format,...)
Definition: cs_driver.c:93
const char source[]
#define BUFFER_SIZE
int main(void)
int LZ4_compress_default(const char *src, char *dst, int srcSize, int maxOutputSize)
Definition: lz4.c:1373
LZ4_FORCE_O2 int LZ4_decompress_safe_partial(const char *src, char *dst, int compressedSize, int targetOutputSize, int dstCapacity)
Definition: lz4.c:2179
static int
Definition: sfsocketcall.h:114