+ write and read text in shared memory
~ initialize library
This commit is contained in:
parent
f89d2ef5b6
commit
3671c2c3e1
@ -5,19 +5,23 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <SharedMemoryAccess.h>
|
#include <SharedMemoryAccess.h>
|
||||||
|
#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;
|
||||||
@ -34,19 +38,28 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
//Test for write and read
|
//Test for write and read
|
||||||
if(eingabe == "write") {
|
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
|
//write a bitMap for example 2 (width) * 2 (high) * 3 (color) in Schared Memory
|
||||||
|
/*
|
||||||
char bitMap[12] = {0};
|
char bitMap[12] = {0};
|
||||||
for(int i = 0; i < sizeof(bitMap); i++)
|
for(int i = 0; i < sizeof(bitMap); i++)
|
||||||
bitMap[i] = 'y';
|
bitMap[i] = 'y';
|
||||||
writeSharedMemory(bitMap, sizeof(bitMap),1);
|
writeSharedMemory(bitMap, sizeof(bitMap),1);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
if(eingabe == "read") {
|
if(eingabe == "read") {
|
||||||
|
auto str = getText();
|
||||||
|
std::cout << str << std::endl;
|
||||||
|
/*
|
||||||
char content[12] = {0};
|
char content[12] = {0};
|
||||||
std::cout << "key "<< impl.sharedMemoryKey << std::endl;
|
std::cout << "key "<< impl.sharedMemoryKey << std::endl;
|
||||||
getSharedMemory(content, sizeof(content), 1);
|
getSharedMemory(content, sizeof(content), 1);
|
||||||
|
|
||||||
std::cout << content << std::endl;
|
std::cout << content << std::endl;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user