Ignore:
Timestamp:
Jan 1, 2014, 12:47:38 AM (7 years ago)
Author:
Bruno Cornec
Message:
  • Update mindi-busybox to 1.21.1
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2/mindi-busybox/archival/bbunzip.c

    r2725 r3232  
    66 */
    77#include "libbb.h"
    8 #include "archive.h"
     8#include "bb_archive.h"
    99
    1010enum {
     
    3434
    3535int FAST_FUNC bbunpack(char **argv,
    36     IF_DESKTOP(long long) int FAST_FUNC (*unpacker)(unpack_info_t *info),
     36    IF_DESKTOP(long long) int FAST_FUNC (*unpacker)(transformer_aux_data_t *aux),
    3737    char* FAST_FUNC (*make_new_name)(char *filename, const char *expected_ext),
    3838    const char *expected_ext
     
    4343    char *filename, *new_name;
    4444    smallint exitcode = 0;
    45     unpack_info_t info;
     45    transformer_aux_data_t aux;
    4646
    4747    do {
     
    9999        }
    100100
    101         /* memset(&info, 0, sizeof(info)); */
    102         info.mtime = 0; /* so far it has one member only */
    103         status = unpacker(&info);
     101        init_transformer_aux_data(&aux);
     102        aux.check_signature = 1;
     103        status = unpacker(&aux);
    104104        if (status < 0)
    105105            exitcode = 1;
    106         xclose(STDOUT_FILENO); /* with error check! */
     106
     107        if (!(option_mask32 & OPT_STDOUT))
     108            xclose(STDOUT_FILENO); /* with error check! */
    107109
    108110        if (filename) {
     
    110112            if (status >= 0) {
    111113                /* TODO: restore other things? */
    112                 if (info.mtime) {
     114                if (aux.mtime != 0) {
    113115                    struct timeval times[2];
    114116
    115                     times[1].tv_sec = times[0].tv_sec = info.mtime;
     117                    times[1].tv_sec = times[0].tv_sec = aux.mtime;
    116118                    times[1].tv_usec = times[0].tv_usec = 0;
    117119                    /* Note: we closed it first.
     
    143145        }
    144146    } while (*argv && *++argv);
     147
     148    if (option_mask32 & OPT_STDOUT)
     149        xclose(STDOUT_FILENO); /* with error check! */
    145150
    146151    return exitcode;
     
    168173 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
    169174 */
     175
     176//usage:#define uncompress_trivial_usage
     177//usage:       "[-cf] [FILE]..."
     178//usage:#define uncompress_full_usage "\n\n"
     179//usage:       "Decompress .Z file[s]\n"
     180//usage:     "\n    -c  Write to stdout"
     181//usage:     "\n    -f  Overwrite"
     182
    170183#if ENABLE_UNCOMPRESS
    171184static
    172 IF_DESKTOP(long long) int FAST_FUNC unpack_uncompress(unpack_info_t *info UNUSED_PARAM)
    173 {
    174     IF_DESKTOP(long long) int status = -1;
    175 
    176     if ((xread_char(STDIN_FILENO) != 0x1f) || (xread_char(STDIN_FILENO) != 0x9d)) {
    177         bb_error_msg("invalid magic");
    178     } else {
    179         status = unpack_Z_stream(STDIN_FILENO, STDOUT_FILENO);
    180     }
    181     return status;
     185IF_DESKTOP(long long) int FAST_FUNC unpack_uncompress(transformer_aux_data_t *aux)
     186{
     187    return unpack_Z_stream(aux, STDIN_FILENO, STDOUT_FILENO);
    182188}
    183189int uncompress_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
     
    219225 * See the file algorithm.doc for the compression algorithms and file formats.
    220226 */
     227
     228//usage:#define gunzip_trivial_usage
     229//usage:       "[-cft] [FILE]..."
     230//usage:#define gunzip_full_usage "\n\n"
     231//usage:       "Decompress FILEs (or stdin)\n"
     232//usage:     "\n    -c  Write to stdout"
     233//usage:     "\n    -f  Force"
     234//usage:     "\n    -t  Test file integrity"
     235//usage:
     236//usage:#define gunzip_example_usage
     237//usage:       "$ ls -la /tmp/BusyBox*\n"
     238//usage:       "-rw-rw-r--    1 andersen andersen   557009 Apr 11 10:55 /tmp/BusyBox-0.43.tar.gz\n"
     239//usage:       "$ gunzip /tmp/BusyBox-0.43.tar.gz\n"
     240//usage:       "$ ls -la /tmp/BusyBox*\n"
     241//usage:       "-rw-rw-r--    1 andersen andersen  1761280 Apr 14 17:47 /tmp/BusyBox-0.43.tar\n"
     242//usage:
     243//usage:#define zcat_trivial_usage
     244//usage:       "FILE"
     245//usage:#define zcat_full_usage "\n\n"
     246//usage:       "Decompress to stdout"
     247
    221248#if ENABLE_GUNZIP
    222249static
     
    246273}
    247274static
    248 IF_DESKTOP(long long) int FAST_FUNC unpack_gunzip(unpack_info_t *info)
    249 {
    250     IF_DESKTOP(long long) int status = -1;
    251 
    252     /* do the decompression, and cleanup */
    253     if (xread_char(STDIN_FILENO) == 0x1f) {
    254         unsigned char magic2;
    255 
    256         magic2 = xread_char(STDIN_FILENO);
    257         if (ENABLE_FEATURE_SEAMLESS_Z && magic2 == 0x9d) {
    258             status = unpack_Z_stream(STDIN_FILENO, STDOUT_FILENO);
    259         } else if (magic2 == 0x8b) {
    260             status = unpack_gz_stream_with_info(STDIN_FILENO, STDOUT_FILENO, info);
    261         } else {
    262             goto bad_magic;
    263         }
    264         if (status < 0) {
    265             bb_error_msg("error inflating");
    266         }
    267     } else {
    268  bad_magic:
    269         bb_error_msg("invalid magic");
    270         /* status is still == -1 */
    271     }
    272     return status;
     275IF_DESKTOP(long long) int FAST_FUNC unpack_gunzip(transformer_aux_data_t *aux)
     276{
     277    return unpack_gz_stream(aux, STDIN_FILENO, STDOUT_FILENO);
    273278}
    274279/*
     
    309314//usage:#define bunzip2_full_usage "\n\n"
    310315//usage:       "Decompress FILEs (or stdin)\n"
    311 //usage:     "\nOptions:"
    312316//usage:     "\n    -c  Write to stdout"
    313317//usage:     "\n    -f  Force"
     
    316320//usage:#define bzcat_full_usage "\n\n"
    317321//usage:       "Decompress to stdout"
    318 //applet:IF_BUNZIP2(APPLET(bunzip2, _BB_DIR_USR_BIN, _BB_SUID_DROP))
    319 //applet:IF_BUNZIP2(APPLET_ODDNAME(bzcat, bunzip2, _BB_DIR_USR_BIN, _BB_SUID_DROP, bzcat))
     322//applet:IF_BUNZIP2(APPLET(bunzip2, BB_DIR_USR_BIN, BB_SUID_DROP))
     323//applet:IF_BUNZIP2(APPLET_ODDNAME(bzcat, bunzip2, BB_DIR_USR_BIN, BB_SUID_DROP, bzcat))
    320324#if ENABLE_BUNZIP2
    321325static
    322 IF_DESKTOP(long long) int FAST_FUNC unpack_bunzip2(unpack_info_t *info UNUSED_PARAM)
    323 {
    324     return unpack_bz2_stream_prime(STDIN_FILENO, STDOUT_FILENO);
     326IF_DESKTOP(long long) int FAST_FUNC unpack_bunzip2(transformer_aux_data_t *aux)
     327{
     328    return unpack_bz2_stream(aux, STDIN_FILENO, STDOUT_FILENO);
    325329}
    326330int bunzip2_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
     
    345349 * Licensed under GPLv2, see file LICENSE in this source tree.
    346350 */
     351
     352//usage:#define unlzma_trivial_usage
     353//usage:       "[-cf] [FILE]..."
     354//usage:#define unlzma_full_usage "\n\n"
     355//usage:       "Decompress FILE (or stdin)\n"
     356//usage:     "\n    -c  Write to stdout"
     357//usage:     "\n    -f  Force"
     358//usage:
     359//usage:#define lzma_trivial_usage
     360//usage:       "-d [-cf] [FILE]..."
     361//usage:#define lzma_full_usage "\n\n"
     362//usage:       "Decompress FILE (or stdin)\n"
     363//usage:     "\n    -d  Decompress"
     364//usage:     "\n    -c  Write to stdout"
     365//usage:     "\n    -f  Force"
     366//usage:
     367//usage:#define lzcat_trivial_usage
     368//usage:       "FILE"
     369//usage:#define lzcat_full_usage "\n\n"
     370//usage:       "Decompress to stdout"
     371//usage:
     372//usage:#define unxz_trivial_usage
     373//usage:       "[-cf] [FILE]..."
     374//usage:#define unxz_full_usage "\n\n"
     375//usage:       "Decompress FILE (or stdin)\n"
     376//usage:     "\n    -c  Write to stdout"
     377//usage:     "\n    -f  Force"
     378//usage:
     379//usage:#define xz_trivial_usage
     380//usage:       "-d [-cf] [FILE]..."
     381//usage:#define xz_full_usage "\n\n"
     382//usage:       "Decompress FILE (or stdin)\n"
     383//usage:     "\n    -d  Decompress"
     384//usage:     "\n    -c  Write to stdout"
     385//usage:     "\n    -f  Force"
     386//usage:
     387//usage:#define xzcat_trivial_usage
     388//usage:       "FILE"
     389//usage:#define xzcat_full_usage "\n\n"
     390//usage:       "Decompress to stdout"
     391
    347392#if ENABLE_UNLZMA
    348393static
    349 IF_DESKTOP(long long) int FAST_FUNC unpack_unlzma(unpack_info_t *info UNUSED_PARAM)
    350 {
    351     return unpack_lzma_stream(STDIN_FILENO, STDOUT_FILENO);
     394IF_DESKTOP(long long) int FAST_FUNC unpack_unlzma(transformer_aux_data_t *aux)
     395{
     396    return unpack_lzma_stream(aux, STDIN_FILENO, STDOUT_FILENO);
    352397}
    353398int unlzma_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
     
    372417#if ENABLE_UNXZ
    373418static
    374 IF_DESKTOP(long long) int FAST_FUNC unpack_unxz(unpack_info_t *info UNUSED_PARAM)
    375 {
    376     struct {
    377         uint32_t v1;
    378         uint16_t v2;
    379     } magic;
    380     xread(STDIN_FILENO, &magic, 6);
    381     if (magic.v1 != XZ_MAGIC1a || magic.v2 != XZ_MAGIC2a) {
    382         bb_error_msg("invalid magic");
    383         return -1;
    384     }
    385     return unpack_xz_stream(STDIN_FILENO, STDOUT_FILENO);
     419IF_DESKTOP(long long) int FAST_FUNC unpack_unxz(transformer_aux_data_t *aux)
     420{
     421    return unpack_xz_stream(aux, STDIN_FILENO, STDOUT_FILENO);
    386422}
    387423int unxz_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
Note: See TracChangeset for help on using the changeset viewer.