Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,8 @@ else(CMAKE_SIZEOF_VOID_P EQUAL 8)
endif(CMAKE_SIZEOF_VOID_P EQUAL 8)

if (WIN32)
if (EXISTS "C:/Proton/qpid-proton-winsdk/2015")
set(Boost_INCLUDE_DIRS "C:/Boost2015" CACHE String "Boost include directory")
set(Boost_LIBRARY_DIRS "C:/Boost2015/lib64-msvc-14.0" CACHE String "Boost library directory")
else()
set(Boost_INCLUDE_DIRS "C:/Boost" CACHE String "Boost include directory")
set(Boost_LIBRARY_DIRS "C:/Boost/lib64-msvc-12.0" CACHE String "Boost library directory")
endif()

set(PROTON_INCLUDE_DIR "C:/Proton/qpid-proton-winsdk/include" CACHE String "Proton include directory")
set(PROTON_LIBRARY_DIR "C:/Proton/qpid-proton-winsdk/lib" CACHE String "Proton library directory")
else (WIN32)
include(FindBoost)
find_package(Boost
1.41.0 # CentOS/RHEL 6
REQUIRED
COMPONENTS filesystem regex system
)
endif (WIN32)

set(ENABLE_QPID_PROTON ON CACHE BOOL "Enable qpid proton clients")
Expand All @@ -77,18 +62,6 @@ if (NOT WIN32)
)
endif (NOT WIN32)

if (EXISTS "${Boost_INCLUDE_DIRS}")
include_directories(${Boost_INCLUDE_DIRS})
else (EXISTS "${Boost_INCLUDE_DIRS}")
message(FATAL_ERROR "Boost ${BOOST_VERSION} headers were not found in ${Boost_INCLUDE_DIRS}")
endif (EXISTS "${Boost_INCLUDE_DIRS}")

if (EXISTS "${Boost_LIBRARY_DIRS}")
link_directories(${Boost_LIBRARY_DIRS})
else (EXISTS "${Boost_LIBRARY_DIRS}")
message(FATAL_ERROR "Boost ${BOOST_VERSION} libraries were not found in ${Boost_LIBRARY_DIRS}")
endif (EXISTS "${Boost_LIBRARY_DIRS}")

if (WIN32)
if (EXISTS "${PROTON_INCLUDE_DIR}")
include_directories(${PROTON_INCLUDE_DIR})
Expand Down
1 change: 0 additions & 1 deletion src/api/qpid-proton/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ else (WIN32)
target_link_libraries(
dtests-proton-common

boost_regex
dtests-cpp-contrib
dtests-cpp-common
dtests-cpp-common-options
Expand Down
2 changes: 0 additions & 2 deletions src/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ if (WIN32)
target_link_libraries(dtests-cpp-common)
else (WIN32)
target_link_libraries(dtests-cpp-common
boost_filesystem
boost_system
pthread
)
endif (WIN32)
Expand Down
30 changes: 14 additions & 16 deletions src/common/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@
#include <unistd.h>
#endif

#include <boost/regex.hpp>
#include <boost/format.hpp>
#include <string>
#include <cstdio>

#include "Utils.h"

//MAX_INT is 2^64 so the number can take a maximum of 20 characters
//INT_CONSTANT is 32 just to be sure
#define INT_CONSTANT 32

// get_time ()
// get current time downto miliseconds (as double) since epoch
Expand Down Expand Up @@ -106,23 +109,18 @@ void set_stdx_unbuffered()
*/
std::string str_fmt(const std::string& in_str, int in_indx)
{
std::string str_int(in_str);

if (!in_str.empty()) {
// string not empty
boost::regex regex("%[ 0-9]*[ds]"); // boost regexp

if (boost::regex_search(in_str, regex)) {
// formating *printf substring found
std::ostringstream stm;
stm << boost::format(in_str) % in_indx;

str_int = stm.str();
}
std::string outputString;
char *str_int = new char[sizeof(*str_int) *
(in_str.size() + INT_CONSTANT)];
if (sprintf(str_int, in_str.c_str(), in_indx) > 0) {

Check failure

Code scanning / Flawfinder (reported by Codacy)

Potential format string problem (CWE-134). Make format string constant.

Potential format string problem (CWE-134). Make format string constant.
outputString = str_int;
} else {
outputString = in_str;
}
delete [] str_int;

// return the string value
return (str_int);
return (outputString);
}


Expand Down
15 changes: 8 additions & 7 deletions src/common/options/OptionsHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@
* Author: opiske
*/

#include <fstream>
#include "OptionsHelper.h"
#include "logger/LoggerWrapper.h"


namespace fs = boost::filesystem;

using namespace dtests::common;
using namespace dtests::common::log;


static bool fileExists(const std::string& name)
{
std::ifstream f(name);
return f.is_open();
}

OptionsSetter::OptionsSetter(const optparse::Values &options)
: options(options)
Expand All @@ -34,15 +37,13 @@ string OptionsSetter::getContent() const
} else if(options.is_set("msg-content-from-file")) {
const string contentFile = options["msg-content-from-file"];

fs::path file(contentFile);

if (!exists(file)) {
if (!fileExists(contentFile)) {
logger(error) << "The file " << contentFile << " does"
<< " not exist";
throw IOException("The file " + contentFile + " does not exist");
}

fs::ifstream inputStream(file);
std::ifstream inputStream(contentFile);

string content;

Expand Down
5 changes: 0 additions & 5 deletions src/common/options/OptionsHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@
#ifndef DTESTS_COMMON_OPTIONSHELPER_H_
#define DTESTS_COMMON_OPTIONSHELPER_H_

#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>

#include <optparse/OptionParser.h>

#include <vector>
Expand Down