aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/CMakeLists.txt4
-rw-r--r--examples/libsshpp.cpp10
-rw-r--r--include/libssh/libsshpp.hpp65
3 files changed, 78 insertions, 1 deletions
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 77eb4173..94d89499 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -1,4 +1,4 @@
-project(libssh-examples C)
+project(libssh-examples C CXX)
set(examples_SRCS
authentication.c
@@ -15,11 +15,13 @@ add_executable(libssh_scp libssh_scp.c ${examples_SRCS})
add_executable(scp_download scp_download.c ${examples_SRCS})
add_executable(samplessh sample.c ${examples_SRCS})
add_executable(exec exec.c ${examples_SRCS})
+add_executable(libsshpp libsshpp.cpp)
target_link_libraries(libssh_scp ${LIBSSH_SHARED_LIBRARY})
target_link_libraries(scp_download ${LIBSSH_SHARED_LIBRARY})
target_link_libraries(samplessh ${LIBSSH_SHARED_LIBRARY})
target_link_libraries(exec ${LIBSSH_SHARED_LIBRARY})
+target_link_libraries(libsshpp ${LIBSSH_SHARED_LIBRARY})
include_directories(
${LIBSSH_PUBLIC_INCLUDE_DIRS}
diff --git a/examples/libsshpp.cpp b/examples/libsshpp.cpp
new file mode 100644
index 00000000..eb415d8c
--- /dev/null
+++ b/examples/libsshpp.cpp
@@ -0,0 +1,10 @@
+
+#include <libssh/libsshpp.hpp>
+
+int main(int argc, const char **argv){
+ ssh::Session session;
+ session.setOption(SSH_OPTIONS_HOST,"localhost");
+ session.connect();
+ session.userauthAutopubkey();
+ return 0;
+}
diff --git a/include/libssh/libsshpp.hpp b/include/libssh/libsshpp.hpp
new file mode 100644
index 00000000..9be035e8
--- /dev/null
+++ b/include/libssh/libsshpp.hpp
@@ -0,0 +1,65 @@
+/*
+ * This file is part of the SSH Library
+ *
+ * Copyright (c) 2010 by Aris Adamantiadis
+ *
+ * The SSH Library is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or (at your
+ * option) any later version.
+ *
+ * The SSH Library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with the SSH Library; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ */
+
+#ifndef LIBSSHPP_HPP_
+#define LIBSSHPP_HPP_
+
+/** @defgroup ssh_cpp libssh C++ wrapper
+ * @addtogroup ssh_cpp
+ * @{
+ */
+
+#include <libssh/libssh.h>
+
+namespace ssh {
+class Session {
+public:
+ Session(){
+ session=ssh_new();
+ }
+ ~Session(){
+ ssh_free(session);
+ session=NULL;
+ }
+ void setOption(enum ssh_options_e type, const char *option){
+ ssh_options_set(session,type,option);
+ }
+ void setOption(enum ssh_options_e type, long int option){
+ ssh_options_set(session,type,&option);
+ }
+ void setOption(enum ssh_options_e type, void *option){
+ ssh_options_set(session,type,option);
+ }
+ int connect(){
+ return ssh_connect(session);
+ }
+ int userauthAutopubkey(){
+ return ssh_userauth_autopubkey(session,NULL);
+ }
+private:
+ ssh_session session;
+};
+}
+
+
+/** @}
+ */
+#endif /* LIBSSHPP_HPP_ */