diff options
author | lloyd <[email protected]> | 2014-12-22 01:25:32 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2014-12-22 01:25:32 +0000 |
commit | e6af27a8be91db29b44c7a15eb762c6547275506 (patch) | |
tree | ebdfed7b5e90581a59f0728a175f18e7deac339e | |
parent | 66723650cab63f541e64145272821984a0f6117e (diff) |
Remove obsolete example
-rw-r--r-- | src/cmd/bzip.cpp | 103 |
1 files changed, 0 insertions, 103 deletions
diff --git a/src/cmd/bzip.cpp b/src/cmd/bzip.cpp deleted file mode 100644 index 15403ea88..000000000 --- a/src/cmd/bzip.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/* -* Bzip2 Compression/Decompression -* (C) 2009 Jack Lloyd -* -* Distributed under the terms of the Botan license -*/ - -#include "apps.h" - -#if defined(BOTAN_HAS_COMPRESSOR_BZIP2) - -#include <botan/bzip2.h> - -namespace { - -int bzip2(int argc, char* argv[]) - { - const std::string SUFFIX = ".bz2"; - - if(argc < 2) - { - std::cout << "Usage: " << argv[0] - << " [-s] [-d] [-1...9] <filenames>" << std::endl; - return 1; - } - - std::vector<std::string> files; - bool decompress = false, small = false; - int level = 9; - - for(int j = 1; argv[j] != 0; j++) - { - if(std::strcmp(argv[j], "-d") == 0) { decompress = true; continue; } - if(std::strcmp(argv[j], "-s") == 0) { small = true; continue; } - if(std::strcmp(argv[j], "-1") == 0) { level = 1; continue; } - if(std::strcmp(argv[j], "-2") == 0) { level = 2; continue; } - if(std::strcmp(argv[j], "-3") == 0) { level = 3; continue; } - if(std::strcmp(argv[j], "-4") == 0) { level = 4; continue; } - if(std::strcmp(argv[j], "-5") == 0) { level = 5; continue; } - if(std::strcmp(argv[j], "-6") == 0) { level = 6; continue; } - if(std::strcmp(argv[j], "-7") == 0) { level = 7; continue; } - if(std::strcmp(argv[j], "-8") == 0) { level = 8; continue; } - if(std::strcmp(argv[j], "-9") == 0) { level = 9; continue; } - files.push_back(argv[j]); - } - - try { - - Botan::Filter* bzip = 0; - if(decompress) - bzip = new Botan::Bzip_Decompression(small); - else - bzip = new Botan::Bzip_Compression(level); - - Botan::Pipe pipe(bzip); - - for(unsigned int j = 0; j != files.size(); j++) - { - std::string infile = files[j], outfile = files[j]; - if(!decompress) - outfile = outfile += SUFFIX; - else - outfile = outfile.replace(outfile.find(SUFFIX), - SUFFIX.length(), ""); - - std::ifstream in(infile.c_str(), std::ios::binary); - std::ofstream out(outfile.c_str(), std::ios::binary); - if(!in) - { - std::cout << "ERROR: could not read " << infile << std::endl; - continue; - } - if(!out) - { - std::cout << "ERROR: could not write " << outfile << std::endl; - continue; - } - - pipe.start_msg(); - in >> pipe; - pipe.end_msg(); - pipe.set_default_msg(j); - out << pipe; - - in.close(); - out.close(); - return 0; - } - } - catch(std::exception& e) - { - std::cout << "Exception caught: " << e.what() << std::endl; - return 2; - } - - return 1; - } - -REGISTER_APP(bzip2); - -} - -#endif |