aboutsummaryrefslogtreecommitdiff
path: root/examples/libsshpp.cpp
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2010-02-11 23:08:07 +0100
committerAris Adamantiadis <aris@0xbadc0de.be>2010-02-11 23:08:07 +0100
commit92ca76721aa06eb12d68489e48947db177667fd2 (patch)
treec09301508a0515703dcada2b628f5f9ce526fc21 /examples/libsshpp.cpp
parent6af2e3fc1088f2766715e824d926a8bb10d8e586 (diff)
downloadlibssh-92ca76721aa06eb12d68489e48947db177667fd2.tar.gz
libssh-92ca76721aa06eb12d68489e48947db177667fd2.tar.xz
libssh-92ca76721aa06eb12d68489e48947db177667fd2.zip
More C++ wrapper work.
Wrote stubs of functions needed in the wrapper Created an Exception class which greatly simplifies the use of libssh in C++
Diffstat (limited to 'examples/libsshpp.cpp')
-rw-r--r--examples/libsshpp.cpp27
1 files changed, 24 insertions, 3 deletions
diff --git a/examples/libsshpp.cpp b/examples/libsshpp.cpp
index eb415d8c..f9bfe63d 100644
--- a/examples/libsshpp.cpp
+++ b/examples/libsshpp.cpp
@@ -1,10 +1,31 @@
+/*
+Copyright 2010 Aris Adamantiadis
+This file is part of the SSH Library
+
+You are free to copy this file, modify it in any way, consider it being public
+domain. This does not apply to the rest of the library though, but it is
+allowed to cut-and-paste working code from this file to any license of
+program.
+*/
+
+/* This file demonstrates the use of the C++ wrapper to libssh */
+
+#include <iostream>
#include <libssh/libsshpp.hpp>
int main(int argc, const char **argv){
ssh::Session session;
- session.setOption(SSH_OPTIONS_HOST,"localhost");
- session.connect();
- session.userauthAutopubkey();
+ try {
+ if(argc>1)
+ session.setOption(SSH_OPTIONS_HOST,argv[1]);
+ else
+ session.setOption(SSH_OPTIONS_HOST,"localhost");
+ session.connect();
+ session.userauthAutopubkey();
+ } catch (ssh::SshException e){
+ std::cout << "Error during connection : ";
+ std::cout << e.getError() << std::endl;
+ }
return 0;
}