mirror of
https://github.com/intel/isa-l.git
synced 2025-10-30 21:50:45 +01:00
igzip: fix coding style of inflate example
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
This commit is contained in:
@@ -36,61 +36,62 @@
|
||||
|
||||
struct inflate_state stream;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
uint8_t inbuf[BUF_SIZE], outbuf[BUF_SIZE];
|
||||
FILE *in, *out;
|
||||
int ret;
|
||||
int eof;
|
||||
uint8_t inbuf[BUF_SIZE], outbuf[BUF_SIZE];
|
||||
FILE *in, *out;
|
||||
int ret;
|
||||
int eof;
|
||||
|
||||
if (argc != 3) {
|
||||
fprintf(stderr, "Usage: igzip_inflate_example infile outfile\n");
|
||||
exit(0);
|
||||
}
|
||||
if (argc != 3) {
|
||||
fprintf(stderr, "Usage: igzip_inflate_example infile outfile\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
in = fopen(argv[1], "rb");
|
||||
if (!in) {
|
||||
fprintf(stderr, "Can't open %s for reading\n", argv[1]);
|
||||
exit(0);
|
||||
}
|
||||
in = fopen(argv[1], "rb");
|
||||
if (!in) {
|
||||
fprintf(stderr, "Can't open %s for reading\n", argv[1]);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
out = fopen(argv[2], "wb");
|
||||
if (!out) {
|
||||
fprintf(stderr, "Can't open %s for writing\n", argv[2]);
|
||||
fclose(in);
|
||||
exit(0);
|
||||
}
|
||||
out = fopen(argv[2], "wb");
|
||||
if (!out) {
|
||||
fprintf(stderr, "Can't open %s for writing\n", argv[2]);
|
||||
fclose(in);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
printf("igzip_inflate_example\n");
|
||||
fflush(0);
|
||||
printf("igzip_inflate_example\n");
|
||||
fflush(0);
|
||||
|
||||
isal_inflate_init(&stream);
|
||||
|
||||
do {
|
||||
stream.avail_in = (uint32_t)fread(inbuf, 1, BUF_SIZE, in);
|
||||
eof = feof(in);
|
||||
stream.next_in = inbuf;
|
||||
isal_inflate_init(&stream);
|
||||
|
||||
do {
|
||||
stream.avail_out = BUF_SIZE;
|
||||
stream.next_out = outbuf;
|
||||
stream.avail_in = (uint32_t) fread(inbuf, 1, BUF_SIZE, in);
|
||||
eof = feof(in);
|
||||
stream.next_in = inbuf;
|
||||
|
||||
ret = isal_inflate(&stream);
|
||||
do {
|
||||
stream.avail_out = BUF_SIZE;
|
||||
stream.next_out = outbuf;
|
||||
|
||||
if (ret != ISAL_DECOMP_OK && ret != ISAL_END_INPUT) {
|
||||
fprintf(stderr, "Decompression error: %d\n", ret);
|
||||
fclose(out);
|
||||
fclose(in);
|
||||
return 1;
|
||||
}
|
||||
ret = isal_inflate(&stream);
|
||||
|
||||
fwrite(outbuf, 1, BUF_SIZE - stream.avail_out, out);
|
||||
} while (stream.avail_out == 0);
|
||||
} while (eof == 0);
|
||||
if (ret != ISAL_DECOMP_OK && ret != ISAL_END_INPUT) {
|
||||
fprintf(stderr, "Decompression error: %d\n", ret);
|
||||
fclose(out);
|
||||
fclose(in);
|
||||
return 1;
|
||||
}
|
||||
|
||||
fclose(out);
|
||||
fclose(in);
|
||||
fwrite(outbuf, 1, BUF_SIZE - stream.avail_out, out);
|
||||
} while (stream.avail_out == 0);
|
||||
} while (eof == 0);
|
||||
|
||||
printf("End of igzip_inflate_example\n\n");
|
||||
return 0;
|
||||
fclose(out);
|
||||
fclose(in);
|
||||
|
||||
printf("End of igzip_inflate_example\n\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user