From 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 20:24:20 +0200 Subject: Adding upstream version 14.2.21. Signed-off-by: Daniel Baumann --- src/boost/libs/crc/crc_example.cpp | 75 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 src/boost/libs/crc/crc_example.cpp (limited to 'src/boost/libs/crc/crc_example.cpp') diff --git a/src/boost/libs/crc/crc_example.cpp b/src/boost/libs/crc/crc_example.cpp new file mode 100644 index 00000000..a40e61d1 --- /dev/null +++ b/src/boost/libs/crc/crc_example.cpp @@ -0,0 +1,75 @@ +// Boost CRC example program file ------------------------------------------// + +// Copyright 2003 Daryle Walker. Use, modification, and distribution are +// subject to the Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or a copy at .) + +// See for the library's home page. + +// Revision History +// 17 Jun 2003 Initial version (Daryle Walker) + +#include // for boost::crc_32_type + +#include // for EXIT_SUCCESS, EXIT_FAILURE +#include // for std::exception +#include // for std::ifstream +#include // for std::ios_base, etc. +#include // for std::cerr, std::cout +#include // for std::endl + + +// Redefine this to change to processing buffer size +#ifndef PRIVATE_BUFFER_SIZE +#define PRIVATE_BUFFER_SIZE 1024 +#endif + +// Global objects +std::streamsize const buffer_size = PRIVATE_BUFFER_SIZE; + + +// Main program +int +main +( + int argc, + char const * argv[] +) +try +{ + boost::crc_32_type result; + + for ( int i = 1 ; i < argc ; ++i ) + { + std::ifstream ifs( argv[i], std::ios_base::binary ); + + if ( ifs ) + { + do + { + char buffer[ buffer_size ]; + + ifs.read( buffer, buffer_size ); + result.process_bytes( buffer, ifs.gcount() ); + } while ( ifs ); + } + else + { + std::cerr << "Failed to open file '" << argv[i] << "'." + << std::endl; + } + } + + std::cout << std::hex << std::uppercase << result.checksum() << std::endl; + return EXIT_SUCCESS; +} +catch ( std::exception &e ) +{ + std::cerr << "Found an exception with '" << e.what() << "'." << std::endl; + return EXIT_FAILURE; +} +catch ( ... ) +{ + std::cerr << "Found an unknown exception." << std::endl; + return EXIT_FAILURE; +} -- cgit v1.2.3