Skip to content

Commit 85e7ad0

Browse files
Add emiso files and align cpp code with gcc-12 version
1 parent 74a7db4 commit 85e7ad0

31 files changed

Lines changed: 2784 additions & 25 deletions

buildroot/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dl
2+

linux/rootfs/configs/virt64_defconfig

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -441,15 +441,10 @@ BR2_PACKAGE_FFMPEG_ARCH_SUPPORTS=y
441441
# BR2_PACKAGE_FLUID_SOUNDFONT is not set
442442
# BR2_PACKAGE_FLUIDSYNTH is not set
443443
# BR2_PACKAGE_GMRENDER_RESURRECT is not set
444-
BR2_PACKAGE_GSTREAMER1=y
445-
BR2_PACKAGE_GSTREAMER1_CHECK=y
446-
BR2_PACKAGE_GSTREAMER1_PARSE=y
447-
BR2_PACKAGE_GSTREAMER1_TRACE=y
448-
BR2_PACKAGE_GSTREAMER1_GST_DEBUG=y
449-
BR2_PACKAGE_GSTREAMER1_PLUGIN_REGISTRY=y
450-
BR2_PACKAGE_GSTREAMER1_INSTALL_TOOLS=y
451-
BR2_PACKAGE_GST1_PLUGINS_BASE=y
452-
# BR2_PACKAGE_GST1_PLUGINS_BASE_INSTALL_TOOLS is not set
444+
# BR2_PACKAGE_GSTREAMER1 is not set
445+
# BR2_PACKAGE_JACK1 is not set
446+
# BR2_PACKAGE_JACK2 is not set
447+
BR2_PACKAGE_KODI_ARCH_SUPPORTS=y
453448

454449
#
455450
# dependency-less plugins
@@ -1852,7 +1847,7 @@ BR2_PACKAGE_EXPAT=y
18521847
BR2_PACKAGE_JSON_C=y
18531848
# BR2_PACKAGE_JSON_FOR_MODERN_CPP is not set
18541849
# BR2_PACKAGE_JSON_GLIB is not set
1855-
# BR2_PACKAGE_JSONCPP is not set
1850+
BR2_PACKAGE_JSONCPP=y
18561851
# BR2_PACKAGE_LIBBSON is not set
18571852
# BR2_PACKAGE_LIBFASTJSON is not set
18581853
# BR2_PACKAGE_LIBJSON is not set
@@ -2003,7 +1998,7 @@ BR2_PACKAGE_LIBCURL_TLS_NONE=y
20031998
# BR2_PACKAGE_LIBGSASL is not set
20041999
# BR2_PACKAGE_LIBHTP is not set
20052000
# BR2_PACKAGE_LIBHTTPPARSER is not set
2006-
# BR2_PACKAGE_LIBHTTPSERVER is not set
2001+
BR2_PACKAGE_LIBHTTPSERVER=y
20072002
# BR2_PACKAGE_LIBIDN is not set
20082003
# BR2_PACKAGE_LIBIDN2 is not set
20092004
# BR2_PACKAGE_LIBISCSI is not set
@@ -2012,7 +2007,8 @@ BR2_PACKAGE_LIBCURL_TLS_NONE=y
20122007
# BR2_PACKAGE_LIBMAXMINDDB is not set
20132008
# BR2_PACKAGE_LIBMBUS is not set
20142009
# BR2_PACKAGE_LIBMEMCACHED is not set
2015-
# BR2_PACKAGE_LIBMICROHTTPD is not set
2010+
BR2_PACKAGE_LIBMICROHTTPD=y
2011+
BR2_PACKAGE_LIBMICROHTTPD_SSL=y
20162012
# BR2_PACKAGE_LIBMINIUPNPC is not set
20172013
# BR2_PACKAGE_LIBMNL is not set
20182014
# BR2_PACKAGE_LIBMODBUS is not set
@@ -2088,8 +2084,8 @@ BR2_PACKAGE_LIBZENOH_C_ARCH_SUPPORTS=y
20882084
# BR2_PACKAGE_OPENPGM is not set
20892085
# BR2_PACKAGE_OPENZWAVE is not set
20902086
# BR2_PACKAGE_ORTP is not set
2091-
# BR2_PACKAGE_PAHO_MQTT_C is not set
2092-
# BR2_PACKAGE_PAHO_MQTT_CPP is not set
2087+
BR2_PACKAGE_PAHO_MQTT_C=y
2088+
BR2_PACKAGE_PAHO_MQTT_CPP=y
20932089
# BR2_PACKAGE_PISTACHE is not set
20942090
# BR2_PACKAGE_QDECODER is not set
20952091
# BR2_PACKAGE_QPID_PROTON is not set
@@ -2320,7 +2316,7 @@ BR2_PACKAGE_FMT=y
23202316
# BR2_PACKAGE_LIBENCA is not set
23212317
# BR2_PACKAGE_LIBESTR is not set
23222318
BR2_PACKAGE_LIBFRIBIDI=y
2323-
# BR2_PACKAGE_LIBUNIBREAK is not set
2319+
BR2_PACKAGE_LIBUNISTRING=y
23242320
# BR2_PACKAGE_LIBUNISTRING is not set
23252321
# BR2_PACKAGE_LINENOISE is not set
23262322
BR2_PACKAGE_NCURSES=y
@@ -2508,6 +2504,7 @@ BR2_PACKAGE_HAPROXY_ARCH_SUPPORTS=y
25082504
# BR2_PACKAGE_IFPLUGD is not set
25092505
# BR2_PACKAGE_IFTOP is not set
25102506
# BR2_PACKAGE_IFUPDOWN is not set
2507+
BR2_PACKAGE_IFUPDOWN_SCRIPTS=y
25112508
# BR2_PACKAGE_IGD2_FOR_LINUX is not set
25122509

25132510
#
@@ -2581,8 +2578,11 @@ BR2_PACKAGE_NETCAT=y
25812578
# BR2_PACKAGE_NETPLUG is not set
25822579
# BR2_PACKAGE_NETSNMP is not set
25832580
# BR2_PACKAGE_NETSTAT_NAT is not set
2584-
# BR2_PACKAGE_NETWORK_MANAGER is not set
2585-
# BR2_PACKAGE_NETWORKD_DISPATCHER is not set
2581+
BR2_PACKAGE_NETWORK_MANAGER=y
2582+
# BR2_PACKAGE_NETWORK_MANAGER_TUI is not set
2583+
# BR2_PACKAGE_NETWORK_MANAGER_MODEM_MANAGER is not set
2584+
# BR2_PACKAGE_NETWORK_MANAGER_PPPD is not set
2585+
# BR2_PACKAGE_NETWORK_MANAGER_OVS is not set
25862586
# BR2_PACKAGE_NFACCT is not set
25872587
# BR2_PACKAGE_NFTABLES is not set
25882588
# BR2_PACKAGE_NGINX is not set
@@ -2891,8 +2891,8 @@ BR2_PACKAGE_AUDIT_ARCH_SUPPORTS=y
28912891
#
28922892
# BR2_PACKAGE_CONMON is not set
28932893
# BR2_PACKAGE_CONTAINERD is not set
2894-
# BR2_PACKAGE_COREUTILS is not set
2895-
# BR2_PACKAGE_CPULIMIT is not set
2894+
BR2_PACKAGE_COREUTILS=y
2895+
# BR2_PACKAGE_COREUTILS_INDIVIDUAL_BINARIES is not set
28962896
# BR2_PACKAGE_CPULOAD is not set
28972897
BR2_PACKAGE_CRIU_ARCH_SUPPORTS=y
28982898
# BR2_PACKAGE_CRIU is not set
@@ -2924,10 +2924,8 @@ BR2_PACKAGE_EFIVAR_ARCH_SUPPORTS=y
29242924
# BR2_PACKAGE_GKRELLM is not set
29252925
# BR2_PACKAGE_HTOP is not set
29262926
# BR2_PACKAGE_IBM_SW_TPM2 is not set
2927-
2928-
#
2929-
# iotop depends on python3
2930-
#
2927+
BR2_PACKAGE_INITSCRIPTS=y
2928+
# BR2_PACKAGE_IOTOP is not set
29312929
# BR2_PACKAGE_IPRUTILS is not set
29322930
# BR2_PACKAGE_IRQBALANCE is not set
29332931

@@ -3009,7 +3007,7 @@ BR2_PACKAGE_SEATD_DAEMON=y
30093007
#
30103008
# BR2_PACKAGE_SWUPDATE is not set
30113009
# BR2_PACKAGE_SYSKLOGD is not set
3012-
# BR2_PACKAGE_SYSLOG_NG is not set
3010+
BR2_PACKAGE_SYSLOG_NG=y
30133011
BR2_PACKAGE_SYSTEMD_ARCH_SUPPORTS=y
30143012
BR2_PACKAGE_SYSTEMD=y
30153013
# BR2_PACKAGE_SYSTEMD_INITRD is not set
@@ -3246,6 +3244,7 @@ BR2_PACKAGE_HOST_DEPOT_TOOLS=y
32463244
# BR2_PACKAGE_HOST_E2TOOLS is not set
32473245
# BR2_PACKAGE_HOST_ENVIRONMENT_SETUP is not set
32483246
# BR2_PACKAGE_HOST_EROFS_UTILS is not set
3247+
BR2_PACKAGE_HOST_EUDEV=y
32493248
# BR2_PACKAGE_HOST_EXFATPROGS is not set
32503249
# BR2_PACKAGE_HOST_F2FS_TOOLS is not set
32513250
# BR2_PACKAGE_HOST_FAKETIME is not set

linux/usr/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
cmake_minimum_required(VERSION 3.10)
66

7-
project(agency-usr LANGUAGES C)
7+
project(agency-usr LANGUAGES C CXX)
88

99
option(WITH_LED_ACTIVITIES "LED activities during migration" OFF)
1010

@@ -26,3 +26,5 @@ add_subdirectory(lib)
2626

2727
#add_subdirectory(wago_client)
2828

29+
# EMISO
30+
add_subdirectory(emiso_engine)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
project(emiso_engine LANGUAGES C CXX)
2+
3+
set(CMAKE_CXX_STANDARD 17)
4+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
5+
6+
add_executable(${PROJECT_NAME} emiso_engine.cpp
7+
utils.cpp
8+
webserver/webserver.cpp
9+
webserver/system/system.cpp
10+
webserver/container/container.cpp
11+
webserver/image/image.cpp
12+
webserver/network/network.cpp
13+
webserver/volume/volume.cpp
14+
daemon/image.cpp
15+
daemon/container.cpp
16+
daemon/daemon.cpp
17+
#cli/cli.cpp
18+
)
19+
20+
target_include_directories(${PROJECT_NAME} PRIVATE include)
21+
22+
target_link_libraries(${PROJECT_NAME} httpserver jsoncpp readline)
23+
24+
install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_BINARY_DIR}/bin)

linux/usr/emiso_engine/cli/cli.cpp

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
/*
2+
* Copyright (C) 2023 Jean-Pierre Miceli <jean-pierre.miceli@heig-vd.ch>
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License version 2 as
6+
* published by the Free Software Foundation.
7+
*
8+
* This program is distributed in the hope that it will be useful,
9+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
* GNU General Public License for more details.
12+
*
13+
* You should have received a copy of the GNU General Public License
14+
* along with this program; if not, write to the Free Software
15+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16+
*
17+
*/
18+
19+
#include <vector>
20+
#include <sstream>
21+
22+
#include "cli.hpp"
23+
24+
#define EMISO_CLI_PROMPT "(emiso)>> "
25+
26+
namespace emiso {
27+
28+
Cli::Cli() {}
29+
30+
Cli::~Cli() {}
31+
32+
void Cli::splitCmd(std::string const &str, const char delim, std::vector<std::string> &out)
33+
{
34+
// create a stream from the string
35+
std::stringstream s(str);
36+
37+
std::string s2;
38+
while (std::getline (s, s2, delim)) {
39+
out.push_back(s2); // store the string in s2
40+
}
41+
}
42+
43+
44+
// Function to handle the "hello" command
45+
void Cli::handleHelloCommand() {
46+
std::cout << "Hello, World!" << std::endl;
47+
}
48+
49+
// Function to handle the "help" command
50+
void Cli::handleHelpCommand() {
51+
std::cout << "Available commands:" << std::endl;
52+
std::cout << " hello - Print a greeting" << std::endl;
53+
std::cout << " help - Show available commands" << std::endl;
54+
std::cout << " exit - Exit the program" << std::endl;
55+
}
56+
57+
58+
void Cli::handleImagesCommand(std::vector<std::string> &tokens)
59+
{
60+
std::map<std::string, daemon::ImageInfo> info;
61+
62+
// TODO - Add checks on 'tokens'
63+
if (tokens[1] == "info") {
64+
_image.info(info);
65+
66+
for (auto it = info.begin(); it != info.end(); ++it) {
67+
std::string name = it->second.name;
68+
size_t size = it->second.size;
69+
std::string id = it->second.id;
70+
auto date = it->second.date;
71+
72+
std::cout << name << std::endl;
73+
std::cout << " Size: " << size << std::endl;
74+
std::cout << " ID: " << id << std::endl;
75+
std::cout << " date: " << date << std::endl;
76+
}
77+
} else if (tokens[1] == "rm") {
78+
// TODO - Add checks on 'tokens[2]'
79+
_image.remove(tokens[2]);
80+
} else {
81+
std::cout << "[ERROR] image cmd '" << tokens[1] << "' is not supported" << std::endl;
82+
}
83+
}
84+
85+
void Cli::start()
86+
{
87+
std::cout << "Starting interactive mode" << std::endl;
88+
while (true) {
89+
char* input = readline(EMISO_CLI_PROMPT);
90+
if (!input) {
91+
break; // User pressed Ctrl+D (EOF)
92+
}
93+
94+
std::string command(input);
95+
free(input);
96+
97+
// Add the command to readline's history
98+
if (!command.empty()) {
99+
add_history(command.c_str());
100+
}
101+
102+
std::vector<std::string> tokens;
103+
Cli::splitCmd(command, ' ', tokens);
104+
105+
106+
if (tokens[0] == "hello") {
107+
Cli::handleHelloCommand();
108+
} else if (tokens[0] == "help") {
109+
Cli::handleHelpCommand();
110+
} else if (tokens[0] == "image") {
111+
Cli::handleImagesCommand(tokens);
112+
} else if (tokens[0] == "exit") {
113+
break; // Exit the program
114+
} else {
115+
std::cout << "Unknown command. Type 'help' for a list of available commands." << std::endl;
116+
}
117+
}
118+
119+
std::cout << "Stopping interactive mode" << std::endl;
120+
121+
}
122+
123+
} // emiso

linux/usr/emiso_engine/cli/cli.hpp

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright (C) 2023 Jean-Pierre Miceli <jean-pierre.miceli@heig-vd.ch>
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License version 2 as
6+
* published by the Free Software Foundation.
7+
*
8+
* This program is distributed in the hope that it will be useful,
9+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
* GNU General Public License for more details.
12+
*
13+
* You should have received a copy of the GNU General Public License
14+
* along with this program; if not, write to the Free Software
15+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16+
*
17+
*/
18+
19+
#ifndef EMISO_CLI_H
20+
#define EMISO_CLI_H
21+
22+
#include <iostream>
23+
#include <readline/readline.h>
24+
#include <readline/history.h>
25+
26+
#include "../daemon/image.hpp"
27+
28+
namespace emiso {
29+
30+
class Cli {
31+
public:
32+
Cli();
33+
34+
// Destructor
35+
~Cli();
36+
37+
void start();
38+
39+
private:
40+
daemon::Image _image;
41+
42+
void splitCmd(std::string const &str, const char delim, std::vector<std::string> &out);
43+
44+
void handleHelloCommand();
45+
void handleHelpCommand();
46+
void handleImagesCommand(std::vector<std::string> &tockens);
47+
};
48+
}
49+
50+
#endif // EMISO_CLI_H

0 commit comments

Comments
 (0)