Skip to content

Commit

Permalink
minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
nitram2342 committed Sep 23, 2016
1 parent 1f4414a commit a2673be
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ find_package(PkgConfig)
#set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)

find_package(Boost REQUIRED COMPONENTS program_options system regex thread unit_test_framework)
find_package(Boost REQUIRED COMPONENTS program_options system regex thread unit_test_framework filesystem)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
set(LIBS ${LIBS} ${Boost_LIBRARIES})
Expand Down
3 changes: 2 additions & 1 deletion README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ Dependencies
- boost_regex
- boost_thread
- boost_test
- boost_filesystem

To install these on a Linux, you may run:

$ sudo apt-get install cmake libboost-program-options-dev libboost-system-dev libboost-regex-dev \
libboost-thread-dev libboost-test-dev
libboost-thread-dev libboost-test-dev libboost-filesystem-dev


Compile
Expand Down
17 changes: 15 additions & 2 deletions bruteforce-crc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <boost/integer.hpp>
#include <boost/thread.hpp>
#include <boost/format.hpp>
#include <boost/filesystem.hpp>

#include "bruteforce-crc.hpp"

Expand Down Expand Up @@ -94,6 +95,9 @@ std::vector<bf_crc::test_vector_t> read_file(std::string const& file, int32_t of
tv.crc = crc;
test_vectors.push_back(tv);
}
if (verbose) {
printf("Extracted %ld messages and CRC values\n", test_vectors.size());
}

return test_vectors;
}
Expand Down Expand Up @@ -182,12 +186,21 @@ int main(int argc, char *argv[]) {
if(vm.count("probe-reflected-output")) reflected_output = vm["reflect-out"].as<bool>();

// Check parameters TODO: A lot more checking
if(crc_width > 16) { std::cout << "maximum value for width is: 16\n"; exit(1); } // Why 16?
if(crc_width > 16) {
std::cout << "Maximum value for width is 16. otherwise it would be to CPU consuming, but you are free to adjust this limit." << std::endl;
exit(1);
}

// Read messages from intput file
std::vector<bf_crc::test_vector_t> test_vectors;
if(vm.count("file")) {
test_vectors = read_file(vm["file"].as<std::string>(), start, end-start, offs_crc, crc_width, verbose);
std::string const & fname = vm["file"].as<std::string>();
if(!boost::filesystem::exists(fname)) {
std::cout << "Can't find file '" << fname << "'." << std::endl;
exit(1);
}
else
test_vectors = read_file(fname, start, end-start, offs_crc, crc_width, verbose);
}

// Set output file
Expand Down

0 comments on commit a2673be

Please sign in to comment.