Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	README.md
This commit is contained in:
Zakarya 2019-11-13 12:47:21 +01:00
commit b220ee0bd1
8 changed files with 67 additions and 12 deletions

View File

@ -5,11 +5,11 @@ bool=false
# explicitly set IFS to contain only a line feed # explicitly set IFS to contain only a line feed
IFS=' IFS='
' '
filelist="$(find . -not \( -path './client/cpptoml/*' -prune \) -type f ! -name "$(printf "*\n*")")" filelist="$(find . -not \( -path './*build*' -prune \) -type f ! -name "$(printf "*\n*")")"
for file in $filelist; do for file in $filelist; do
if echo "$file" | grep -q -E ".*\.cpp$" ; then if echo "$file" | grep -q -E ".*(\.cpp|\.h|\.hpp)$" ; then
#Extra check missing dependencies due to clang-tidy doesn't toggle exit code. #Extra check missing dependencies due to clang-tidy doesn't toggle exit code.
clang_tidy_lib_check="$(clang-tidy -warnings-as-errors='*' -header-filter='.*,-cpptoml.hpp' -checks='*,-llvm-header-guard,-fuchsia-statically-constructed-objects,-fuchsia-default-arguments,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-bounds-constant-array-index,-bugprone-narrowing-conversions,-cppcoreguidelines-narrowing-conversions,-cppcoreguidelines-pro-type-const-cast,-cppcoreguidelines-pro-type-reinterpret-cast,-hicpp-signed-bitwise,-bugprone-exception-escape,-cppcoreguidelines-pro-type-member-init,-cppcoreguidelines-pro-type-cstyle-cast,-hicpp-member-init' "$file" -- -I. -std=c++14 2>&1)" clang_tidy_lib_check="$(clang-tidy -warnings-as-errors='*' -header-filter='.*,-cpptoml.hpp' -checks='*,-llvm-header-guard,-fuchsia-statically-constructed-objects,-fuchsia-default-arguments,-fuchsia-default-arguments-calls,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-bounds-constant-array-index,-bugprone-narrowing-conversions,-cppcoreguidelines-narrowing-conversions,-cppcoreguidelines-pro-type-const-cast,-cppcoreguidelines-pro-type-reinterpret-cast,-hicpp-signed-bitwise,-bugprone-exception-escape,-cppcoreguidelines-pro-type-member-init,-cppcoreguidelines-pro-type-cstyle-cast,-hicpp-member-init' "$file" -- -I. -std=c++14 2>&1)"
for tidy_line in $clang_tidy_lib_check; do for tidy_line in $clang_tidy_lib_check; do
echo "$tidy_line" | grep -q -v -E "^Error while processing*" echo "$tidy_line" | grep -q -v -E "^Error while processing*"
if [ $? -eq 1 ]; then if [ $? -eq 1 ]; then

View File

@ -9,7 +9,7 @@ stages:
clang_tidy: clang_tidy:
image: jhasse/clang-tidy image: joethei/clang_tidy
stage: style stage: style
tags: tags:
- docker-ci - docker-ci

View File

@ -20,6 +20,7 @@ set(LIB_PATH "${CMAKE_SOURCE_DIR}/../library")
include_directories(${LIB_PATH}/include) include_directories(${LIB_PATH}/include)
add_executable(SharedMemory ${SOURCES} ${HEADERS} main/main.cpp) add_executable(SharedMemory ${SOURCES} ${HEADERS} main/main.cpp)
target_link_libraries(SharedMemory ${LIB_PATH}/lib/liblibrary.a) target_link_libraries(SharedMemory ${LIB_PATH}/lib/liblibrary.a)

View File

@ -1,8 +1,31 @@
# vKVM Shared Memory # vKVM Shared Memory
Shared memory is a kernel-managed memory area that can be read and written by the graphical user interface , Text Renderer and the Library.
## Features
- set shared memory keys
- Manage the shared memory
## Installation ## Installation
Use the installation script provided in the Scripts repository Use the installation script provided in the Scripts repository
to install the full package. to install the full package.
Installing a single component is currently not supported. Installing a single component is currently not supported.
## Usage
mkdir build
cd build
cmake ..
make
## Description
changedKey(): create new Key for the Shared Memory.
getAnswerFromUser(): ask the User if he want to chgange the Key of Shared Memory.
initSharedMemory(): create Shared Memory and make it available t o use it
deleteSharedMemory(int s): delete the Shared memory.
deleteSharedMemory(): delete the Shared memory.

View File

@ -3,19 +3,20 @@
#include "../src/SharedMemory.h" #include "../src/SharedMemory.h"
#include <sys/shm.h> #include <sys/shm.h>
#include <iostream> #include <iostream>
#include "vkvm.h"
int main(int argc, char** argv) int main(int argc, char** argv) {
{ initialize(0);
initSharedMemory(); initSharedMemory();
struct sigaction sigIntHandler; struct sigaction sigIntHandler;
sigIntHandler.sa_handler = deleteSharedMemory; sigIntHandler.sa_handler = deleteSharedMemory;
sigemptyset(&sigIntHandler.sa_mask); sigemptyset(&sigIntHandler.sa_mask);
sigIntHandler.sa_flags = 0; sigIntHandler.sa_flags = 0;
sigaction(SIGINT, &sigIntHandler, NULL); sigaction(SIGINT, &sigIntHandler, nullptr);
setDefaultValues();
std::atexit(deleteSharedMemory); std::atexit(deleteSharedMemory);
std::string eingabe = ""; std::string eingabe;
while(eingabe != "exit") { while(eingabe != "exit") {
std::cout << "cmd# "; std::cout << "cmd# ";
std::cin >> eingabe; std::cin >> eingabe;
@ -28,6 +29,29 @@ int main(int argc, char** argv)
std::cout << "OUTPUT ------------------------ OUTPUT\n" << std::endl; std::cout << "OUTPUT ------------------------ OUTPUT\n" << std::endl;
//Memory that is used now //Memory that is used now
//outprint of all memory //outprint of all memory
} else if(eingabe == "write") {
std::cout << "text: ";
std::cin >> eingabe;
setText(eingabe);
//write a bitMap for example 2 (width) * 2 (high) * 3 (color) in Schared Memory
/*
char bitMap[12] = {0};
for(int i = 0; i < sizeof(bitMap); i++)
bitMap[i] = 'y';
writeSharedMemory(bitMap, sizeof(bitMap),1);
*/
} else if(eingabe == "read") {
auto str = getText();
std::cout << str << std::endl;
/*
char content[12] = {0};
std::cout << "key "<< impl.sharedMemoryKey << std::endl;
getSharedMemory(content, sizeof(content), 1);
std::cout << content << std::endl;
*/
} else if (eingabe != "exit"){
std::cout << eingabe << " <- is not a known command" << std::endl;
} }
} }
return 0; return 0;

View File

@ -1,14 +1,20 @@
#include <cstdlib> #include <cstdlib>
#include "SharedMemory.h" #include "SharedMemory.h"
#include <iostream> #include <iostream>
#include <fstream>
key_t changedKey() key_t changedKey()
{ {
std::ofstream keyFile;
keyFile.open("key.log", std::ofstream::out | std::ofstream::trunc);
keyFile.clear();
int newKey; int newKey;
std::cout << "Type in a new Key for the Shared Memory Segment" << std::endl; std::cout << "Type in a new Key for the Shared Memory Segment" << std::endl;
std::cout << "new Key#"; std::cout << "new Key#";
std::cin >> newKey; std::cin >> newKey;
std::cout <<"New Key is -> " << newKey << std::endl; std::cout <<"New Key is -> " << newKey << std::endl;
keyFile << newKey;
keyFile.close();
return key_t(newKey); return key_t(newKey);
} }
@ -36,9 +42,7 @@ void initSharedMemory(void) {
std::string answer = getAnswerFromUser(); std::string answer = getAnswerFromUser();
if(answer.compare("y") == 0) if(answer.compare("y") == 0)
{ {
std::cout << "Please type in a new Key:\n"; impl.sharedMemoryKey = changedKey();
std::cout << "#";
std::cin >> impl.sharedMemoryKey;
std::cout << "new Try with Key:c " << impl.sharedMemoryKey << std::endl; std::cout << "new Try with Key:c " << impl.sharedMemoryKey << std::endl;
initSharedMemory(); initSharedMemory();
} else if(answer.compare("n") == 0) { } else if(answer.compare("n") == 0) {

View File

@ -12,4 +12,6 @@
void deleteSharedMemory(int s); void deleteSharedMemory(int s);
void deleteSharedMemory(void); void deleteSharedMemory(void);
void initSharedMemory(void); void initSharedMemory(void);
key_t changedKey();
std::string getAnswerFromUser();
#endif //SHARED_MEMORY_H #endif //SHARED_MEMORY_H

1
src/key.log Normal file
View File

@ -0,0 +1 @@
12345