Skip to content
Open
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
29 changes: 18 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,28 +1,35 @@
cmake_minimum_required(VERSION 3.6)
project(OCB)

find_package(Boost COMPONENTS system filesystem thread date_time REQUIRED)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -pthread")

#Possible builds VALIDATOR_DEBUG & VALIDATOR_RELEASE or GENERATOR (include tests)

#Possible builds UTIL or GENERATOR (in future will include tests)
set(BUILD_CONFIGURATION "VALIDATOR_DEBUG")

set(BUILD_CONFIGURATION "GENERATOR")
IF(${BUILD_CONFIGURATION} MATCHES "VALIDATOR_DEBUG")
set(CMAKE_BUILD_TYPE "DEBUG")
#extends mode
add_definitions(-DVALIDATOR)
ENDIF(${BUILD_CONFIGURATION} MATCHES "VALIDATOR_DEBUG")

IF(${BUILD_CONFIGURATION} MATCHES "UTIL")
set(CMAKE_BUILD_TYPE "UTIL")
add_definitions(-DUTIL)
ENDIF(${BUILD_CONFIGURATION} MATCHES "UTIL")
IF(${BUILD_CONFIGURATION} MATCHES "VALIDATOR_RELEASE")
set(CMAKE_BUILD_TYPE "RELEASE")
#extends mode
add_definitions(-DVALIDATOR)
ENDIF(${BUILD_CONFIGURATION} MATCHES "VALIDATOR_RELEASE")

IF(${BUILD_CONFIGURATION} MATCHES "GENERATOR")
set(CMAKE_BUILD_TYPE "GENERATOR")
set(CMAKE_BUILD_TYPE "DEBUG")
add_definitions(-DGENERATOR)
ENDIF(${BUILD_CONFIGURATION} MATCHES "GENERATOR")

add_subdirectory(crypto)
add_subdirectory(source)
add_subdirectory(src)

set(SOURCE_FILES core.cpp)

add_executable(OCB ${SOURCE_FILES})

target_link_libraries(OCB lamport -lsodium)
target_link_libraries(OCB lamport Boost::thread -lsodium -lboost_system -lboost_filesystem)
9 changes: 9 additions & 0 deletions bin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
cmake_minimum_required(VERSION 3.13)
project(SCRIPT)
find_package(Boost COMPONENTS system filesystem thread date_time REQUIRED)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
set(CMAKE_CXX_STANDARD 14)

add_executable(SCRIPT script.cpp )
target_link_libraries(SCRIPT Boost::thread -lboost_system -lboost_filesystem)
61 changes: 61 additions & 0 deletions bin/script.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <iostream>
#include <boost/algorithm/string.hpp>
#include <boost/asio.hpp>
#include <boost/filesystem.hpp>
#include <boost/signals2.hpp>
#include <string>
#include <boost/bind.hpp>
#include <sys/types.h>
#include <sys/stat.h>

using namespace std;
namespace as = boost::asio;
namespace fs = boost::filesystem;
namespace signals = boost::signals2;

static const constexpr char kFileNameSepator = '\n';

std::string make_string(boost::asio::streambuf& streambuf)
{
return {boost::asio::buffers_begin(streambuf.data()),
boost::asio::buffers_end(streambuf.data())};
}

int main() {
int as;
as = open("fifo/requests.fifo", O_WRONLY | O_NONBLOCK);
int ad;
ad = open("fifo/answers.fifo", O_RDONLY | O_NONBLOCK);
as::io_service io_service1;

unique_ptr<as::posix::stream_descriptor> mWrite = unique_ptr<as::posix::stream_descriptor>(
new as::posix::stream_descriptor(io_service1, as));
unique_ptr<as::posix::stream_descriptor> mRead = unique_ptr<as::posix::stream_descriptor>(
new as::posix::stream_descriptor(io_service1, ad));
mRead->non_blocking(true);
mWrite->non_blocking(true);
io_service1.run();
for (;;) {

boost::asio::streambuf write_buffer;
std::ostream output(&write_buffer);
std::string d;
getline(std::cin, d);
output <<d + "\n";
std::cout << "Writing: " << make_string(write_buffer) << std::endl;
boost::asio::write(*mWrite, write_buffer);

sleep(1);

boost::asio::streambuf read_buffer;
boost::asio::read_until(*mRead, read_buffer, kFileNameSepator);
std::cout << "Read: " << make_string(read_buffer) << std::endl;

}
}
20 changes: 11 additions & 9 deletions core.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
#ifdef GENERATOR
#include "source/file_generator/file_generator.cpp"
#define CATCH_CONFIG_MAIN
#include "src/tests/catch.hpp"
#include "src/tests/TestValidator/TestValidator.cpp"
#endif

int main()
{
#ifdef GENERATOR
file_generator generator;
#ifdef VALIDATOR
#include "src/interface/initInterface/InitInterface.cpp"
#endif

#ifdef UTIL
//here comes main util
#endif
}
#ifndef GENERATOR
int main()
{
return InitInterface().run();
}
#endif
20 changes: 19 additions & 1 deletion include/includes.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,33 @@
#ifndef LAMPORT_INCLUDES_H
#define LAMPORT_INCLUDES_H

#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <ctime>

#include <boost/uuid/uuid.hpp>
#include <boost/uuid/string_generator.hpp>
#include <boost/uuid/uuid_generators.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/bind.hpp>
#include <boost/asio.hpp>
#include <boost/filesystem.hpp>
#include <boost/signals2.hpp>

#include <sodium.h>
#include "../crypto/src/lamportscheme.h"

using namespace std;
namespace as = boost::asio;
namespace fs = boost::filesystem;
namespace signals = boost::signals2;

typedef uint8_t byte;
static const constexpr char kFileNameSepator = '\n';
using namespace crypto::lamport;

#endif //LAMPORT_INCLUDES_H
35 changes: 35 additions & 0 deletions script.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <iostream>

int main()
{
int fd1;

char response[80], file_name[80];

uint16_t get;

while(1) {
// Now open in write mode and write
// string taken from u
// ser.
fd1 = open("fifo", O_WRONLY);
fgets(file_name, sizeof(file_name), stdin);
write(fd1, file_name, strlen(file_name) + 1);
close(fd1);

fd1 = open("fifo", O_RDONLY);
read(fd1, response, sizeof(response));
close(fd1);


std::cout<<response<<"\n";
}

}

6 changes: 0 additions & 6 deletions source/CMakeLists.txt

This file was deleted.

100 changes: 0 additions & 100 deletions source/file_generator/file_generator.cpp

This file was deleted.

22 changes: 0 additions & 22 deletions source/file_generator/file_generator.h

This file was deleted.

Loading