Skip to content

Commit cc0b184

Browse files
Remove zlib compiler vars and wrappers
1 parent 514038c commit cc0b184

File tree

1 file changed

+19
-57
lines changed

1 file changed

+19
-57
lines changed

lib/pkg_editor/src/pkg_editor.c

Lines changed: 19 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@
3939
#endif
4040

4141
#include "pkg_editor/pkg_editor.h"
42-
#if USE_ZLIB
4342
#include "zlib.h"
44-
#endif
4543

4644
typedef struct acl_pkg_file {
4745
const char *fname;
@@ -1160,23 +1158,6 @@ void acl_pkg_set_show_mode(acl_pkg_file *pkg, int show_mode) {
11601158
}
11611159
}
11621160

1163-
#if USE_ZLIB
1164-
1165-
int zlib_deflateInit(z_streamp strm, int level) {
1166-
return deflateInit_(strm, level, ZLIB_VERSION, (int)sizeof(z_stream));
1167-
}
1168-
1169-
int zlib_deflate(z_streamp strm, int flush) { return deflate(strm, flush); }
1170-
1171-
int zlib_deflateEnd(z_streamp strm) { return deflateEnd(strm); }
1172-
1173-
int zlib_inflateInit(z_streamp strm) {
1174-
return inflateInit_(strm, ZLIB_VERSION, (int)sizeof(z_stream));
1175-
}
1176-
1177-
int zlib_inflate(z_streamp strm, int flush) { return inflate(strm, flush); }
1178-
int zlib_inflateEnd(z_streamp strm) { return inflateEnd(strm); }
1179-
11801161
typedef struct ZInfo {
11811162
z_stream strm;
11821163
unsigned char buffer[32 * 1024];
@@ -1209,7 +1190,7 @@ static int append_data(const void *data, size_t size, ZInfo *z_info, FILE *of,
12091190
int ret;
12101191
z_info->strm.avail_out = sizeof(z_info->buffer);
12111192
z_info->strm.next_out = z_info->buffer;
1212-
ret = zlib_deflate(&z_info->strm, Z_FINISH);
1193+
ret = deflate(&z_info->strm, Z_FINISH);
12131194
assert(ret != Z_STREAM_ERROR);
12141195
output_size = sizeof(z_info->buffer) - z_info->strm.avail_out;
12151196
if (output_size > 0) {
@@ -1221,7 +1202,7 @@ static int append_data(const void *data, size_t size, ZInfo *z_info, FILE *of,
12211202
} else {
12221203
// Only dump the output buffer when it is full.
12231204
do {
1224-
int ret = zlib_deflate(&z_info->strm, Z_NO_FLUSH);
1205+
int ret = deflate(&z_info->strm, Z_NO_FLUSH);
12251206
assert(ret != Z_STREAM_ERROR);
12261207
if (z_info->strm.avail_out == 0) {
12271208
if (fwrite(z_info->buffer, sizeof(z_info->buffer), 1, of) != 1) {
@@ -1491,7 +1472,8 @@ int acl_pkg_pack(const char *out_file, const char **input_files_dirs) {
14911472
z_info.strm.opaque = Z_NULL;
14921473
z_info.strm.avail_out = sizeof(z_info.buffer);
14931474
z_info.strm.next_out = z_info.buffer;
1494-
ret = zlib_deflateInit(&z_info.strm, Z_BEST_COMPRESSION);
1475+
deflateInit_(&z_info.strm, Z_BEST_COMPRESSION, ZLIB_VERSION,
1476+
(int)sizeof(z_stream));
14951477
if (ret != Z_OK) {
14961478
fprintf(stderr, "acl_pkg_pack: Unable to initialize zlib for writing %s\n",
14971479
out_file);
@@ -1506,7 +1488,7 @@ int acl_pkg_pack(const char *out_file, const char **input_files_dirs) {
15061488
if (result == PACK_END) {
15071489
// We had a failure; stop here.
15081490
fclose(of);
1509-
zlib_deflateEnd(&z_info.strm);
1491+
deflateEnd(&z_info.strm);
15101492
return 0;
15111493
}
15121494
input_files_dirs++;
@@ -1520,10 +1502,10 @@ int acl_pkg_pack(const char *out_file, const char **input_files_dirs) {
15201502
if (fclose(of) != 0) {
15211503
fprintf(stderr, "acl_pkg_pack: Write of %s failed: %s\n", out_file,
15221504
strerror(errno));
1523-
zlib_deflateEnd(&z_info.strm);
1505+
deflateEnd(&z_info.strm);
15241506
return 0;
15251507
}
1526-
zlib_deflateEnd(&z_info.strm);
1508+
deflateEnd(&z_info.strm);
15271509
return 1 /* success */;
15281510
}
15291511

@@ -1549,7 +1531,7 @@ static int read_data(void *data, size_t size, ZInfo *z_info, FILE *in_fd) {
15491531
z_info->strm.next_in = z_info->buffer;
15501532
}
15511533
// Grab the next chunk of data from the input buffer.
1552-
ret = zlib_inflate(&z_info->strm, Z_NO_FLUSH);
1534+
ret = inflate(&z_info->strm, Z_NO_FLUSH);
15531535
assert(ret != Z_STREAM_ERROR);
15541536
if (ret == Z_STREAM_END) {
15551537
// Last bit of data.
@@ -1605,7 +1587,7 @@ static int acl_pkg_unpack_buffer_or_file(const char *buffer, size_t buffer_size,
16051587
z_info.strm.avail_in = 0;
16061588
z_info.strm.next_in = NULL;
16071589
}
1608-
ret = zlib_inflateInit(&z_info.strm);
1590+
ret = inflateInit_(&z_info.strm, ZLIB_VERSION, (int)sizeof(z_stream));
16091591
if (ret != Z_OK) {
16101592
fprintf(stderr, "%s: Unable to initialize zlib for reading from buffer\n",
16111593
routine_name);
@@ -1626,13 +1608,13 @@ static int acl_pkg_unpack_buffer_or_file(const char *buffer, size_t buffer_size,
16261608
acl_pkg_pack_info info;
16271609
if (!read_data(&info, sizeof(info), &z_info, input)) {
16281610
fprintf(stderr, "%s: Error reading from buffer\n", routine_name);
1629-
zlib_inflateEnd(&z_info.strm);
1611+
inflateEnd(&z_info.strm);
16301612
return 0;
16311613
}
16321614
if (info.magic != PACK_MAGIC) {
16331615
fprintf(stderr, "%s: Incorrect magic number read from buffer\n",
16341616
routine_name);
1635-
zlib_inflateEnd(&z_info.strm);
1617+
inflateEnd(&z_info.strm);
16361618
return 0;
16371619
}
16381620

@@ -1645,7 +1627,7 @@ static int acl_pkg_unpack_buffer_or_file(const char *buffer, size_t buffer_size,
16451627
if (!read_data(name, info.name_length, &z_info, input)) {
16461628
fprintf(stderr, "%s: Error reading file name from buffer\n",
16471629
routine_name);
1648-
zlib_inflateEnd(&z_info.strm);
1630+
inflateEnd(&z_info.strm);
16491631
return 0;
16501632
}
16511633

@@ -1671,7 +1653,7 @@ static int acl_pkg_unpack_buffer_or_file(const char *buffer, size_t buffer_size,
16711653
if (out_file == NULL) {
16721654
fprintf(stderr, "%s: Unable to open %s for writing: %s\n", routine_name,
16731655
full_name, strerror(errno));
1674-
zlib_inflateEnd(&z_info.strm);
1656+
inflateEnd(&z_info.strm);
16751657
return 0;
16761658
}
16771659
if (info.file_length > 0) {
@@ -1681,14 +1663,14 @@ static int acl_pkg_unpack_buffer_or_file(const char *buffer, size_t buffer_size,
16811663
fprintf(stderr, "%s: Error reading file data for %s from buffer\n",
16821664
routine_name, full_name);
16831665
fclose(out_file);
1684-
zlib_inflateEnd(&z_info.strm);
1666+
inflateEnd(&z_info.strm);
16851667
return 0;
16861668
}
16871669
if (fwrite(buf, info.file_length, 1, out_file) != 1) {
16881670
fprintf(stderr, "%s: Failed to write to %s: %s\n", routine_name,
16891671
full_name, strerror(errno));
16901672
fclose(out_file);
1691-
zlib_inflateEnd(&z_info.strm);
1673+
inflateEnd(&z_info.strm);
16921674
return 0;
16931675
}
16941676
} else {
@@ -1698,23 +1680,23 @@ static int acl_pkg_unpack_buffer_or_file(const char *buffer, size_t buffer_size,
16981680
routine_name, full_name, strerror(errno));
16991681
fclose(out_file);
17001682
free(buf2);
1701-
zlib_inflateEnd(&z_info.strm);
1683+
inflateEnd(&z_info.strm);
17021684
return PACK_END;
17031685
}
17041686
if (!read_data(buf2, info.file_length, &z_info, input)) {
17051687
fprintf(stderr, "%s: Error reading file data for %s from buffer\n",
17061688
routine_name, full_name);
17071689
fclose(out_file);
17081690
free(buf2);
1709-
zlib_inflateEnd(&z_info.strm);
1691+
inflateEnd(&z_info.strm);
17101692
return 0;
17111693
}
17121694
if (fwrite(buf2, info.file_length, 1, out_file) != 1) {
17131695
fprintf(stderr, "%s: Failed to write to %s: %s\n", routine_name,
17141696
full_name, strerror(errno));
17151697
fclose(out_file);
17161698
free(buf2);
1717-
zlib_inflateEnd(&z_info.strm);
1699+
inflateEnd(&z_info.strm);
17181700
return 0;
17191701
}
17201702
free(buf2);
@@ -1724,7 +1706,7 @@ static int acl_pkg_unpack_buffer_or_file(const char *buffer, size_t buffer_size,
17241706
}
17251707
}
17261708

1727-
zlib_inflateEnd(&z_info.strm);
1709+
inflateEnd(&z_info.strm);
17281710
return 1;
17291711
}
17301712

@@ -1758,23 +1740,3 @@ int acl_pkg_unpack(const char *in_file, const char *out_dir) {
17581740
}
17591741
return ret;
17601742
}
1761-
1762-
#else // USE_ZLIB
1763-
1764-
int acl_pkg_pack(const char *out_file, const char **input_files_dirs) {
1765-
// Not implemented if no ZLIB
1766-
return 0;
1767-
}
1768-
1769-
int acl_pkg_unpack(const char *in_file, const char *out_dir) {
1770-
// Not implemented if no ZLIB
1771-
return 0;
1772-
}
1773-
1774-
int acl_pkg_unpack_buffer(const char *buffer, size_t buffer_size,
1775-
const char *out_dir) {
1776-
// Not implemented if no ZLIB
1777-
return 0;
1778-
}
1779-
1780-
#endif // USE_ZLIB

0 commit comments

Comments
 (0)