diff options
author | Aris Adamantiadis <aris@0xbadc0de.be> | 2010-08-27 11:52:09 +0200 |
---|---|---|
committer | Aris Adamantiadis <aris@0xbadc0de.be> | 2010-08-27 11:53:38 +0200 |
commit | 1834ca38200a46e4d1f539f2ec7c1bcd93564b9a (patch) | |
tree | 0b74e9da2c9a8f0968fea5d3f05b9864a7e7d9cd /examples/libsshpp_noexcept.cpp | |
parent | ad4a4120b7aa9b8d259f7caf1009e3ef6f386c4d (diff) | |
download | libssh-1834ca38200a46e4d1f539f2ec7c1bcd93564b9a.tar.gz libssh-1834ca38200a46e4d1f539f2ec7c1bcd93564b9a.tar.xz libssh-1834ca38200a46e4d1f539f2ec7c1bcd93564b9a.zip |
Added a SSH_NO_CPP_EXCEPTIONS mode to libsshpp.h
Diffstat (limited to 'examples/libsshpp_noexcept.cpp')
-rw-r--r-- | examples/libsshpp_noexcept.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/examples/libsshpp_noexcept.cpp b/examples/libsshpp_noexcept.cpp new file mode 100644 index 00000000..624cfe9f --- /dev/null +++ b/examples/libsshpp_noexcept.cpp @@ -0,0 +1,41 @@ +/* +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 + * specifically, without C++ exceptions + */ + +#include <iostream> +#define SSH_NO_CPP_EXCEPTIONS +#include <libssh/libsshpp.hpp> + +int main(int argc, const char **argv){ + ssh::Session session,s2; + int err; + if(argc>1) + err=session.setOption(SSH_OPTIONS_HOST,argv[1]); + else + err=session.setOption(SSH_OPTIONS_HOST,"localhost"); + if(err==SSH_ERROR) + goto error; + err=session.connect(); + if(err==SSH_ERROR) + goto error; + err=session.userauthAutopubkey(); + if(err==SSH_ERROR) + goto error; + + return 0; + error: + std::cout << "Error during connection : "; + std::cout << session.getError() << std::endl; + return 1; +} |