Cygwin version 2.5.2


window下模拟linux系统,版本2.5.2,带vi组件
资源截图
代码片段和文件信息
///////////////////////////////////////////////////////////////////////////////
//
/// file       01_compress_easy.c
/// rief      Compress from stdin to stdout in multi-call mode
///
/// Usage:      ./01_compress_easy PRESET < INFILE > OUTFILE
///
/// Example:    ./01_compress_easy 6 < foo > foo.xz
//
//  Author:     Lasse Collin
//
//  This file has been put into the public domain.
//  You can do whatever you want with this file.
//
///////////////////////////////////////////////////////////////////////////////

#include 
#include 
#include 
#include 
#include 
#include 


static void
show_usage_and_exit(const char *argv0)
{
fprintf(stderr “Usage: %s PRESET < INFILE > OUTFILE

“PRESET is a number 0-9 and can optionally be “
“followed by ‘e‘ to indicate extreme preset

argv0);
exit(EXIT_FAILURE);
}


static uint32_t
get_preset(int argc char **argv)
{
// One argument whose first char must be 0-9.
if (argc != 2 || argv[1][0] < ‘0‘ || argv[1][0] > ‘9‘)
show_usage_and_exit(argv[0]);

// Calculate the preste level 0-9.
uint32_t preset = argv[1][0] - ‘0‘;

// If there is a second char it must be ‘e‘. It will set
// the LZMA_PRESET_EXTREME flag.
if (argv[1][1] != ‘‘) {
if (argv[1][1] != ‘e‘ || argv[1][2] != ‘‘)
show_usage_and_exit(argv[0]);

preset |= LZMA_PRESET_EXTREME;
}

return preset;
}


static bool
init_encoder(lzma_stream *strm uint32_t preset)
{
// Initialize the encoder using a preset. Set the integrity to check
// to CRC64 which is the default in the xz command line tool. If
// the .xz file needs to be decompressed with XZ embedded use
// LZMA_CHECK_CRC32 instead.
lzma_ret ret = lzma_easy_encoder(strm preset LZMA_CHECK_CRC64);

// Return successfully if the initialization went fine.
if (ret == LZMA_OK)
return true;

// Something went wrong. The possible errors are documented in
// lzma/container.h (src/liblzma/api/lzma/container.h in the source
// package or e.g. /usr/include/lzma/container.h depending on the
// install prefix).
const char *msg;
switch (ret) {
case LZMA_MEM_ERROR:
msg = “Memory allocation failed“;
break;

case LZMA_OPTIONS_ERROR:
msg = “Specified preset is not supported“;
break;

case LZMA_UNSUPPORTED_CHECK:
msg = “Specified integrity check is not supported“;
break;

default:
// This is most likely LZMA_PROG_ERROR indicating a bug in
// this program or in liblzma. It is inconvenient to have a
// separate error message for errors that should be impossible
// to occur but knowing the error code is important for
// debugging. That‘s why it is good to print the error code
// at least when there is no good error message to show.
msg = “Unknown error possibly a bug“;
break;
}

fprintf(stderr “Error initializing the encoder: %s (error code %u)

msg ret);
return false;
}


static bool
compress(lzma_stream *strm FILE *infile FILE *outfile)
{
// This will be LZMA_RUN u

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      24595  2015-02-19 00:53  cygwin64inaddftinfo.exe

    ....S..        21  2016-07-07 07:40  cygwin64inapropos

     文件      28179  2016-04-13 02:58  cygwin64inarch.exe

     文件      99869  2014-10-28 06:18  cygwin64inash.exe

    ....S..        19  2016-07-07 07:40  cygwin64inawk

     文件      36371  2016-04-13 02:58  cygwin64inase32.exe

     文件      36371  2016-04-13 02:58  cygwin64inase64.exe

     文件      28179  2016-04-13 02:58  cygwin64inasename.exe

     文件     701459  2015-09-25 04:58  cygwin64inash.exe

     文件       7186  2015-09-25 04:57  cygwin64inashbug

     文件      30739  2013-03-07 10:54  cygwin64inunzip2.exe

     文件      30739  2013-03-07 10:54  cygwin64inzcat.exe

    ....S..        17  2016-07-07 07:40  cygwin64inzcmp

     文件       2128  2013-03-07 10:54  cygwin64inzdiff

    ....S..        17  2016-07-07 07:40  cygwin64inzegrep

    ....S..        17  2016-07-07 07:40  cygwin64inzfgrep

     文件       1677  2013-03-07 10:54  cygwin64inzgrep

     文件      30739  2013-03-07 10:54  cygwin64inzip2.exe

     文件      12307  2013-03-07 10:54  cygwin64inzip2recover.exe

    ....S..        17  2016-07-07 07:40  cygwin64inzless

     文件       1259  2013-03-07 10:54  cygwin64inzmore

     文件       1644  2016-04-10 14:48  cygwin64inca-legacy

     文件      33811  2015-03-23 16:47  cygwin64incal.exe

    ....S..        18  2016-07-07 07:40  cygwin64incaptoinfo

     文件      49683  2016-04-13 02:58  cygwin64incat.exe

     文件      32787  2015-10-09 10:22  cygwin64incatman.exe

     文件      52243  2016-04-13 02:58  cygwin64inchcon.exe

     文件      58899  2016-04-13 02:58  cygwin64inchgrp.exe

     文件      51219  2016-04-13 02:58  cygwin64inchmod.exe

     文件      61459  2016-04-13 02:58  cygwin64inchown.exe

............此处省略5441个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)