Blame examples/libsshpp_noexcept.cpp

Packit Service 31306d
/*
Packit Service 31306d
Copyright 2010 Aris Adamantiadis
Packit Service 31306d
Packit Service 31306d
This file is part of the SSH Library
Packit Service 31306d
Packit Service 31306d
You are free to copy this file, modify it in any way, consider it being public
Packit Service 31306d
domain. This does not apply to the rest of the library though, but it is
Packit Service 31306d
allowed to cut-and-paste working code from this file to any license of
Packit Service 31306d
program.
Packit Service 31306d
*/
Packit Service 31306d
Packit Service 31306d
/* This file demonstrates the use of the C++ wrapper to libssh
Packit Service 31306d
 * specifically, without C++ exceptions
Packit Service 31306d
 */
Packit Service 31306d
Packit Service 31306d
#include <iostream>
Packit Service 31306d
#define SSH_NO_CPP_EXCEPTIONS
Packit Service 31306d
#include <libssh/libsshpp.hpp>
Packit Service 31306d
Packit Service 31306d
int main(int argc, const char **argv){
Packit Service 31306d
	ssh::Session session,s2;
Packit Service 31306d
	int err;
Packit Service 31306d
	if(argc>1)
Packit Service 31306d
		err=session.setOption(SSH_OPTIONS_HOST,argv[1]);
Packit Service 31306d
	else
Packit Service 31306d
		err=session.setOption(SSH_OPTIONS_HOST,"localhost");
Packit Service 31306d
	if(err==SSH_ERROR)
Packit Service 31306d
		goto error;
Packit Service 31306d
	err=session.connect();
Packit Service 31306d
	if(err==SSH_ERROR)
Packit Service 31306d
		goto error;
Packit Service 31306d
	err=session.userauthPublickeyAuto();
Packit Service 31306d
	if(err==SSH_ERROR)
Packit Service 31306d
		goto error;
Packit Service 31306d
Packit Service 31306d
	return 0;
Packit Service 31306d
	error:
Packit Service 31306d
	std::cout << "Error during connection : ";
Packit Service 31306d
	std::cout << session.getError() << std::endl;
Packit Service 31306d
	return 1;
Packit Service 31306d
}