summaryrefslogtreecommitdiff
path: root/modules/io-ssh/c++
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2025-11-05 09:44:04 +0100
committerClaudius "keldu" Holeksa <mail@keldu.de>2025-11-05 09:44:04 +0100
commitc1d73cbe17650c834faee5a0098a9499b39a2835 (patch)
treeac9c1180f5f8603dd887b7360597db8c53b6e99e /modules/io-ssh/c++
parent5c1d7018ba867a73c160cc044b939e35a2c07243 (diff)
downloadforstio-forstio-c1d73cbe17650c834faee5a0098a9499b39a2835.tar.gz
Dangling changes from the weekend. Added io/ssh setup
Diffstat (limited to 'modules/io-ssh/c++')
-rw-r--r--modules/io-ssh/c++/SConscript38
-rw-r--r--modules/io-ssh/c++/ssh.hpp43
2 files changed, 81 insertions, 0 deletions
diff --git a/modules/io-ssh/c++/SConscript b/modules/io-ssh/c++/SConscript
new file mode 100644
index 0000000..4af4ea3
--- /dev/null
+++ b/modules/io-ssh/c++/SConscript
@@ -0,0 +1,38 @@
+#!/bin/false
+
+import os
+import os.path
+import glob
+
+
+Import('env')
+
+dir_path = Dir('.').abspath
+
+# Environment for base library
+io_ssh_env = env.Clone();
+
+io_ssh_env.sources = sorted(glob.glob(dir_path + "/*.cpp"))
+io_ssh_env.headers = sorted(glob.glob(dir_path + "/*.hpp"))
+
+env.sources += io_ssh_env.sources;
+env.headers += io_ssh_env.headers;
+
+## Shared lib
+objects_shared = []
+io_ssh_env.add_source_files(objects_shared, io_ssh_env.sources, shared=True);
+env.library_shared = io_ssh_env.SharedLibrary('#build/forstio-io-ssh', [objects_shared]);
+
+## Static lib
+objects_static = []
+io_ssh_env.add_source_files(objects_static, io_ssh_env.sources, shared=False);
+env.library_static = io_ssh_env.StaticLibrary('#build/forstio-io-ssh', [objects_static]);
+
+# Set Alias
+env.Alias('library_io_ssh', [env.library_shared, env.library_static]);
+
+env.targets += ['library_io_ssh'];
+
+# Install
+env.Install('$prefix/lib/', [env.library_shared, env.library_static]);
+env.Install('$prefix/include/forstio/io/ssh/', [io_ssh_env.headers]);
diff --git a/modules/io-ssh/c++/ssh.hpp b/modules/io-ssh/c++/ssh.hpp
new file mode 100644
index 0000000..93c4ac0
--- /dev/null
+++ b/modules/io-ssh/c++/ssh.hpp
@@ -0,0 +1,43 @@
+#pragma once
+
+#include <forstio/io/io.hpp>
+
+namespace saw {
+namespace net {
+struct Ssh {};
+}
+
+template<>
+class network_address<net::Ssh> final {
+private:
+ std::string address_;
+public:
+ network_address(const std::string& address__):
+ address_{address__}
+ {}
+};
+
+template<>
+class network<net::Ssh> final {
+private:
+public:
+ conveyor<own<network_address<net::Ssh>>> resolve_address(const std::string& addr){
+ return make_error<err::not_implemented>("SSH resolve address not implemented");
+ }
+
+ error_or<own<network_address<net::Ssh>>> parse_address(const std::string& addr){
+ return heap<network_address<net::Ssh>>(addr);
+ }
+};
+
+error_or<own<network<net::Ssh>>> setup_ssh_network(){
+ own<network<net::Ssh>> ssh_net;
+ try{
+ ssh_net = heap<network<net::Ssh>>();
+ }catch(const std::exception& e){
+ (void)e;
+ return make_error<err::critical>("Couldn't allocate ssh memory");
+ }
+ return ssh_net;
+}
+}