shared-memory/main/main.cpp

54 lines
1.8 KiB
C++

#include "../src/SharedMemory.h"
#include "vkvm.hpp"
#include <cstdlib>
#include <iostream>
#include <sys/shm.h>
int main() {
vkvm::initialize(0);
initSharedMemory();
vkvm::setDefaultValues();
std::atexit(deleteSharedMemory);
std::string eingabe;
getConfig();
while(eingabe != "exit") {
std::cout << "cmd# ";
std::cin >> eingabe;
//if verschieden information ausgaben
if(eingabe == "info")
{
std::cout << "OUTPUT ------------------------ OUTPUT\n" << std::endl;
std::cout << "memory ID: " << shmget(vkvm::impl.sharedMemoryKey, 0, 0) << std::endl;
std::cout << "Max memory Size: " << Max_Memory_Size << std::endl;
std::cout << "OUTPUT ------------------------ OUTPUT\n" << std::endl;
//Memory that is used now
//outprint of all memory
} else if(eingabe == "write") {
std::cout << "text: ";
std::cin >> eingabe;
vkvm::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 = vkvm::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;
}