aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDavid M. Syzdek <syzdek@bindlebinaries.com>2017-07-06 16:00:10 -0800
committerDavid M. Syzdek <syzdek@bindlebinaries.com>2017-07-06 16:00:10 -0800
commit0ad2aeaf60b4a74572d8eed7d587c13f7a6cc099 (patch)
treedc9f65f5941356a103d8e749aefd1414dc454102
parent6a12b9c6e0c7d459e8814cab72ea0ade6f0345a8 (diff)
downloadsecurecoreutils-0ad2aeaf60b4a74572d8eed7d587c13f7a6cc099.tar.gz
securecoreutils-0ad2aeaf60b4a74572d8eed7d587c13f7a6cc099.tar.bz2
securecoreutils-0ad2aeaf60b4a74572d8eed7d587c13f7a6cc099.tar.xz
securecoreutils-0ad2aeaf60b4a74572d8eed7d587c13f7a6cc099.zip
Adding ability to enable/disable compression support
-rw-r--r--acinclude.m481
-rw-r--r--configure.ac2
-rw-r--r--securecoreutilities.xcodeproj/project.pbxproj4
-rw-r--r--src/widget-zcat.c28
-rw-r--r--src/widget-zcat.h2
5 files changed, 77 insertions, 40 deletions
diff --git a/acinclude.m4 b/acinclude.m4
index bf07655..af7264a 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -38,35 +38,72 @@
38# ______________________________________________________________________________ 38# ______________________________________________________________________________
39AC_DEFUN([AC_SCU_ZCAT_DEPS],[dnl 39AC_DEFUN([AC_SCU_ZCAT_DEPS],[dnl
40 40
41 enableval=""
42 AC_ARG_ENABLE(
43 bzip2,
44 [AS_HELP_STRING([--disable-bzip2], [disable bzip2 support [auto]])],
45 [ EBZIP2=$enableval ],
46 [ EBZIP2=$enableval ]
47 )
48 enableval=""
49 AC_ARG_ENABLE(
50 lzma,
51 [AS_HELP_STRING([--disable-lzma], [disable lzma support [auto]])],
52 [ ELZMA=$enableval ],
53 [ ELZMA=$enableval ]
54 )
55 enableval=""
56 AC_ARG_ENABLE(
57 zlib,
58 [AS_HELP_STRING([--disable-zlib], [disable zlib support [auto]])],
59 [ EZLIB=$enableval ],
60 [ EZLIB=$enableval ]
61 )
62
41 # check zlib 63 # check zlib
42 USE_ZLIB=yes; 64 USE_ZLIB=no;
43 AC_CHECK_HEADERS([zlib.h], [], [USE_ZLIB=no]) 65 if test "x${EZLIB}" != "xno";then
44 AC_SEARCH_LIBS([gzclose], [z], [], [USE_ZLIB=no]) 66 USE_ZLIB=yes;
45 AC_SEARCH_LIBS([gzerror], [z], [], [USE_ZLIB=no]) 67 AC_CHECK_HEADERS([zlib.h], [], [USE_ZLIB=no])
46 AC_SEARCH_LIBS([gzopen], [z], [], [USE_ZLIB=no]) 68 AC_SEARCH_LIBS([gzclose], [z], [], [USE_ZLIB=no])
47 AC_SEARCH_LIBS([gzread], [z], [], [USE_ZLIB=no]) 69 AC_SEARCH_LIBS([gzerror], [z], [], [USE_ZLIB=no])
48 if test "x${USE_ZLIB}" = "xyes";then 70 AC_SEARCH_LIBS([gzopen], [z], [], [USE_ZLIB=no])
49 AC_DEFINE_UNQUOTED(USE_ZLIB, 1, [Use zlib]) 71 AC_SEARCH_LIBS([gzread], [z], [], [USE_ZLIB=no])
72 if test "x${USE_ZLIB}" = "xyes";then
73 AC_DEFINE_UNQUOTED(USE_ZLIB, 1, [Use zlib])
74 elif test "x${EZLIB}" == "xyes";then
75 AC_MSG_ERROR([unable to locate zlib library and headers])
76 fi
50 fi 77 fi
51 78
52 # check libbz2 79 # check libbz2
53 USE_BZIP2=yes; 80 USE_BZIP2=no
54 AC_CHECK_HEADERS([bzlib.h], [], [USE_BZIP2=no]) 81 if test "x${EBZIP2}" != "xno";then
55 AC_SEARCH_LIBS([BZ2_bzRead], [bz2], [], [USE_BZIP2=no]) 82 USE_BZIP2=yes;
56 AC_SEARCH_LIBS([BZ2_bzReadClose], [bz2], [], [USE_BZIP2=no]) 83 AC_CHECK_HEADERS([bzlib.h], [], [USE_BZIP2=no])
57 AC_SEARCH_LIBS([BZ2_bzReadGetUnused], [bz2], [], [USE_BZIP2=no]) 84 AC_SEARCH_LIBS([BZ2_bzRead], [bz2], [], [USE_BZIP2=no])
58 AC_SEARCH_LIBS([BZ2_bzReadOpen], [bz2], [], [USE_BZIP2=no]) 85 AC_SEARCH_LIBS([BZ2_bzReadClose], [bz2], [], [USE_BZIP2=no])
59 if test "x${USE_BZIP2}" = "xyes";then 86 AC_SEARCH_LIBS([BZ2_bzReadGetUnused], [bz2], [], [USE_BZIP2=no])
60 AC_DEFINE_UNQUOTED(USE_BZIP2, 1, [Use bzip2]) 87 AC_SEARCH_LIBS([BZ2_bzReadOpen], [bz2], [], [USE_BZIP2=no])
88 if test "x${USE_BZIP2}" = "xyes";then
89 AC_DEFINE_UNQUOTED(USE_BZIP2, 1, [Use bzip2])
90 elif test "x${EBZIP2}" == "xyes";then
91 AC_MSG_ERROR([unable to locate bzip2 library and headers])
92 fi
61 fi 93 fi
62 94
63 # check liblzma 95 # check liblzma
64 USE_XZ=yes; 96 USE_LZMA=no;
65 AC_CHECK_HEADERS([lzma.h], [], [USE_XZ=no]) 97 if test "x${ELZMA}" != "xno";then
66 AC_SEARCH_LIBS([lzma_stream_decoder], [lzma], [], [USE_XZ=no]) 98 USE_LZMA=yes;
67 AC_SEARCH_LIBS([lzma_code], [lzma], [], [USE_XZ=no]) 99 AC_CHECK_HEADERS([lzma.h], [], [USE_LZMA=no])
68 if test "x${USE_XZ}" = "xyes";then 100 AC_SEARCH_LIBS([lzma_stream_decoder], [lzma], [], [USE_LZMA=no])
69 AC_DEFINE_UNQUOTED(USE_XZ, 1, [Use liblzma]) 101 AC_SEARCH_LIBS([lzma_code], [lzma], [], [USE_LZMA=no])
102 if test "x${USE_LZMA}" = "xyes";then
103 AC_DEFINE_UNQUOTED(USE_LZMA, 1, [Use liblzma])
104 elif test "x${ELZMA}" == "xyes";then
105 AC_MSG_ERROR([unable to locate LZMA library and headers])
106 fi
70 fi 107 fi
71 108
72 AC_CHECK_PROG([USE_Z], [uncompress], [yes], [no]) 109 AC_CHECK_PROG([USE_Z], [uncompress], [yes], [no])
diff --git a/configure.ac b/configure.ac
index cd05ae0..4fbc532 100644
--- a/configure.ac
+++ b/configure.ac
@@ -167,7 +167,7 @@ AC_MSG_NOTICE([ ])
167AC_MSG_NOTICE([ Features:]) 167AC_MSG_NOTICE([ Features:])
168AC_MSG_NOTICE([ zlib support: $USE_ZLIB]) 168AC_MSG_NOTICE([ zlib support: $USE_ZLIB])
169AC_MSG_NOTICE([ bzip2 support: $USE_BZIP2]) 169AC_MSG_NOTICE([ bzip2 support: $USE_BZIP2])
170AC_MSG_NOTICE([ xz support: $USE_XZ]) 170AC_MSG_NOTICE([ lzma support: $USE_LZMA])
171AC_MSG_NOTICE([ Z support: $USE_Z]) 171AC_MSG_NOTICE([ Z support: $USE_Z])
172AC_MSG_NOTICE([ ]) 172AC_MSG_NOTICE([ ])
173AC_MSG_NOTICE([ Please send suggestions to: $PACKAGE_BUGREPORT]) 173AC_MSG_NOTICE([ Please send suggestions to: $PACKAGE_BUGREPORT])
diff --git a/securecoreutilities.xcodeproj/project.pbxproj b/securecoreutilities.xcodeproj/project.pbxproj
index 2d38e6a..5cbc1d6 100644
--- a/securecoreutilities.xcodeproj/project.pbxproj
+++ b/securecoreutilities.xcodeproj/project.pbxproj
@@ -308,7 +308,7 @@
308 GCC_PREPROCESSOR_DEFINITIONS = ( 308 GCC_PREPROCESSOR_DEFINITIONS = (
309 "USE_ZLIB=1", 309 "USE_ZLIB=1",
310 "USE_BZIP2=1", 310 "USE_BZIP2=1",
311 "USE_XZ=1", 311 "USE_LZMA=1",
312 ); 312 );
313 GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 313 GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
314 GCC_WARN_ABOUT_RETURN_TYPE = YES; 314 GCC_WARN_ABOUT_RETURN_TYPE = YES;
@@ -343,7 +343,7 @@
343 GCC_PREPROCESSOR_DEFINITIONS = ( 343 GCC_PREPROCESSOR_DEFINITIONS = (
344 "USE_ZLIB=1", 344 "USE_ZLIB=1",
345 "USE_BZIP2=1", 345 "USE_BZIP2=1",
346 "USE_XZ=1", 346 "USE_LZMA=1",
347 ); 347 );
348 GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 348 GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
349 GCC_WARN_ABOUT_RETURN_TYPE = YES; 349 GCC_WARN_ABOUT_RETURN_TYPE = YES;
diff --git a/src/widget-zcat.c b/src/widget-zcat.c
index dc36826..ec9a24a 100644
--- a/src/widget-zcat.c
+++ b/src/widget-zcat.c
@@ -63,7 +63,7 @@
63#include <bzlib.h> 63#include <bzlib.h>
64#endif 64#endif
65 65
66#ifdef USE_XZ 66#ifdef USE_LZMA
67#include <lzma.h> 67#include <lzma.h>
68#endif 68#endif
69 69
@@ -79,7 +79,7 @@ const uint8_t scm_magic_gz[2] = { 0x1f, 0x8b }; // ta
79const uint8_t scm_magic_lz4[4] = { 0x04, 0x22, 0x4d, 0x18 }; // tar.lz4 79const uint8_t scm_magic_lz4[4] = { 0x04, 0x22, 0x4d, 0x18 }; // tar.lz4
80const uint8_t scm_magic_z_lzw[2] = { 0x1f, 0x9d }; // tar.Z 80const uint8_t scm_magic_z_lzw[2] = { 0x1f, 0x9d }; // tar.Z
81const uint8_t scm_magic_z_lzh[2] = { 0x1f, 0xa0 }; // tar.Z 81const uint8_t scm_magic_z_lzh[2] = { 0x1f, 0xa0 }; // tar.Z
82const uint8_t scm_magic_xz[6] = { 0xfd, 0x37, 0x7a, 0x58, 0x5a, 0x00 }; // tar.xz 82const uint8_t scm_magic_lzma[6] = { 0xfd, 0x37, 0x7a, 0x58, 0x5a, 0x00 }; // tar.xz
83 83
84 84
85////////////////// 85//////////////////
@@ -91,8 +91,8 @@ const uint8_t scm_magic_xz[6] = { 0xfd, 0x37, 0x7a, 0x58, 0x5a, 0x00 }; // ta
91#pragma mark - 91#pragma mark -
92#endif 92#endif
93 93
94#ifdef USE_XZ 94#ifdef USE_LZMA
95int scu_widget_zcat_xz_perror(scu_config * cnf, lzma_ret ret); 95int scu_widget_zcat_lzma_perror(scu_config * cnf, lzma_ret ret);
96#endif 96#endif
97 97
98 98
@@ -226,9 +226,9 @@ int scu_widget_zcat(scu_config * cnf)
226 return(scu_widget_zcat_bz2(cnf)); 226 return(scu_widget_zcat_bz2(cnf));
227#endif 227#endif
228 228
229#ifdef USE_XZ 229#ifdef USE_LZMA
230 if (!( memcmp(magic, scm_magic_xz, sizeof(scm_magic_xz)) )) 230 if (!( memcmp(magic, scm_magic_lzma, sizeof(scm_magic_lzma)) ))
231 return(scu_widget_zcat_xz(cnf)); 231 return(scu_widget_zcat_lzma(cnf));
232#endif 232#endif
233 233
234#ifdef USE_Z 234#ifdef USE_Z
@@ -351,8 +351,8 @@ void scu_widget_zcat_usage(scu_config * cnf)
351} 351}
352 352
353 353
354#ifdef USE_XZ 354#ifdef USE_LZMA
355int scu_widget_zcat_xz(scu_config * cnf) 355int scu_widget_zcat_lzma(scu_config * cnf)
356{ 356{
357 int fd; 357 int fd;
358 lzma_ret ret; 358 lzma_ret ret;
@@ -377,7 +377,7 @@ int scu_widget_zcat_xz(scu_config * cnf)
377 377
378 if ((ret = lzma_stream_decoder(&strm, UINT64_MAX, LZMA_CONCATENATED)) != LZMA_OK) 378 if ((ret = lzma_stream_decoder(&strm, UINT64_MAX, LZMA_CONCATENATED)) != LZMA_OK)
379 { 379 {
380 scu_widget_zcat_xz_perror(cnf, ret); 380 scu_widget_zcat_lzma_perror(cnf, ret);
381 close(fd); 381 close(fd);
382 return(1); 382 return(1);
383 }; 383 };
@@ -406,7 +406,7 @@ int scu_widget_zcat_xz(scu_config * cnf)
406 { 406 {
407 if (ret != LZMA_STREAM_END) 407 if (ret != LZMA_STREAM_END)
408 { 408 {
409 scu_widget_zcat_xz_perror(cnf, ret); 409 scu_widget_zcat_lzma_perror(cnf, ret);
410 close(fd); 410 close(fd);
411 return(1); 411 return(1);
412 }; 412 };
@@ -434,7 +434,7 @@ int scu_widget_zcat_xz(scu_config * cnf)
434 { 434 {
435 if (ret != LZMA_STREAM_END) 435 if (ret != LZMA_STREAM_END)
436 { 436 {
437 scu_widget_zcat_xz_perror(cnf, ret); 437 scu_widget_zcat_lzma_perror(cnf, ret);
438 return(1); 438 return(1);
439 }; 439 };
440 }; 440 };
@@ -455,7 +455,7 @@ int scu_widget_zcat_xz(scu_config * cnf)
455} 455}
456 456
457 457
458int scu_widget_zcat_xz_perror(scu_config * cnf, lzma_ret ret) 458int scu_widget_zcat_lzma_perror(scu_config * cnf, lzma_ret ret)
459{ 459{
460 switch(ret) 460 switch(ret)
461 { 461 {
@@ -468,7 +468,7 @@ int scu_widget_zcat_xz_perror(scu_config * cnf, lzma_ret ret)
468 return(1); 468 return(1);
469 469
470 case LZMA_FORMAT_ERROR: 470 case LZMA_FORMAT_ERROR:
471 fprintf(stderr, "%s: %s: invalid .xz format\n", cnf->prog_name, cnf->widget->name); 471 fprintf(stderr, "%s: %s: invalid LZMA format\n", cnf->prog_name, cnf->widget->name);
472 return(1); 472 return(1);
473 473
474 case LZMA_MEM_ERROR: 474 case LZMA_MEM_ERROR:
diff --git a/src/widget-zcat.h b/src/widget-zcat.h
index 8228d94..198b362 100644
--- a/src/widget-zcat.h
+++ b/src/widget-zcat.h
@@ -64,7 +64,7 @@ int scu_widget_zcat(scu_config * cnf);
64int scu_widget_zcat_bz2(scu_config * cnf); 64int scu_widget_zcat_bz2(scu_config * cnf);
65int scu_widget_zcat_gz(scu_config * cnf); 65int scu_widget_zcat_gz(scu_config * cnf);
66int scu_widget_zcat_prog(scu_config * cnf, const char * prog); 66int scu_widget_zcat_prog(scu_config * cnf, const char * prog);
67int scu_widget_zcat_xz(scu_config * cnf); 67int scu_widget_zcat_lzma(scu_config * cnf);
68 68
69void scu_widget_zcat_usage(scu_config * cnf); 69void scu_widget_zcat_usage(scu_config * cnf);
70 70