Skip to content

Commit 6b03bc4

Browse files
committed
igzip: fix coding style of inflate example
Signed-off-by: Pablo de Lara <[email protected]>
1 parent 4fe61d3 commit 6b03bc4

File tree

1 file changed

+48
-47
lines changed

1 file changed

+48
-47
lines changed

igzip/igzip_inflate_example.c

Lines changed: 48 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -36,61 +36,62 @@
3636

3737
struct inflate_state stream;
3838

39-
int main(int argc, char *argv[])
39+
int
40+
main(int argc, char *argv[])
4041
{
41-
uint8_t inbuf[BUF_SIZE], outbuf[BUF_SIZE];
42-
FILE *in, *out;
43-
int ret;
44-
int eof;
45-
46-
if (argc != 3) {
47-
fprintf(stderr, "Usage: igzip_inflate_example infile outfile\n");
48-
exit(0);
49-
}
50-
51-
in = fopen(argv[1], "rb");
52-
if (!in) {
53-
fprintf(stderr, "Can't open %s for reading\n", argv[1]);
54-
exit(0);
55-
}
56-
57-
out = fopen(argv[2], "wb");
58-
if (!out) {
59-
fprintf(stderr, "Can't open %s for writing\n", argv[2]);
60-
fclose(in);
61-
exit(0);
62-
}
63-
64-
printf("igzip_inflate_example\n");
65-
fflush(0);
42+
uint8_t inbuf[BUF_SIZE], outbuf[BUF_SIZE];
43+
FILE *in, *out;
44+
int ret;
45+
int eof;
46+
47+
if (argc != 3) {
48+
fprintf(stderr, "Usage: igzip_inflate_example infile outfile\n");
49+
exit(0);
50+
}
51+
52+
in = fopen(argv[1], "rb");
53+
if (!in) {
54+
fprintf(stderr, "Can't open %s for reading\n", argv[1]);
55+
exit(0);
56+
}
57+
58+
out = fopen(argv[2], "wb");
59+
if (!out) {
60+
fprintf(stderr, "Can't open %s for writing\n", argv[2]);
61+
fclose(in);
62+
exit(0);
63+
}
6664

67-
isal_inflate_init(&stream);
65+
printf("igzip_inflate_example\n");
66+
fflush(0);
6867

69-
do {
70-
stream.avail_in = (uint32_t)fread(inbuf, 1, BUF_SIZE, in);
71-
eof = feof(in);
72-
stream.next_in = inbuf;
68+
isal_inflate_init(&stream);
7369

7470
do {
75-
stream.avail_out = BUF_SIZE;
76-
stream.next_out = outbuf;
71+
stream.avail_in = (uint32_t) fread(inbuf, 1, BUF_SIZE, in);
72+
eof = feof(in);
73+
stream.next_in = inbuf;
7774

78-
ret = isal_inflate(&stream);
75+
do {
76+
stream.avail_out = BUF_SIZE;
77+
stream.next_out = outbuf;
7978

80-
if (ret != ISAL_DECOMP_OK && ret != ISAL_END_INPUT) {
81-
fprintf(stderr, "Decompression error: %d\n", ret);
82-
fclose(out);
83-
fclose(in);
84-
return 1;
85-
}
79+
ret = isal_inflate(&stream);
80+
81+
if (ret != ISAL_DECOMP_OK && ret != ISAL_END_INPUT) {
82+
fprintf(stderr, "Decompression error: %d\n", ret);
83+
fclose(out);
84+
fclose(in);
85+
return 1;
86+
}
8687

87-
fwrite(outbuf, 1, BUF_SIZE - stream.avail_out, out);
88-
} while (stream.avail_out == 0);
89-
} while (eof == 0);
88+
fwrite(outbuf, 1, BUF_SIZE - stream.avail_out, out);
89+
} while (stream.avail_out == 0);
90+
} while (eof == 0);
9091

91-
fclose(out);
92-
fclose(in);
92+
fclose(out);
93+
fclose(in);
9394

94-
printf("End of igzip_inflate_example\n\n");
95-
return 0;
95+
printf("End of igzip_inflate_example\n\n");
96+
return 0;
9697
}

0 commit comments

Comments
 (0)