|
36 | 36 |
|
37 | 37 | struct inflate_state stream;
|
38 | 38 |
|
39 |
| -int main(int argc, char *argv[]) |
| 39 | +int |
| 40 | +main(int argc, char *argv[]) |
40 | 41 | {
|
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 | + } |
66 | 64 |
|
67 |
| - isal_inflate_init(&stream); |
| 65 | + printf("igzip_inflate_example\n"); |
| 66 | + fflush(0); |
68 | 67 |
|
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); |
73 | 69 |
|
74 | 70 | 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; |
77 | 74 |
|
78 |
| - ret = isal_inflate(&stream); |
| 75 | + do { |
| 76 | + stream.avail_out = BUF_SIZE; |
| 77 | + stream.next_out = outbuf; |
79 | 78 |
|
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 | + } |
86 | 87 |
|
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); |
90 | 91 |
|
91 |
| - fclose(out); |
92 |
| - fclose(in); |
| 92 | + fclose(out); |
| 93 | + fclose(in); |
93 | 94 |
|
94 |
| - printf("End of igzip_inflate_example\n\n"); |
95 |
| - return 0; |
| 95 | + printf("End of igzip_inflate_example\n\n"); |
| 96 | + return 0; |
96 | 97 | }
|
0 commit comments