53 #define LIBSSH_LEGACY_0_4
55 #include <libssh/libssh.h>
56 #include <libssh/server.h>
68 #ifndef SSH_NO_CPP_EXCEPTIONS
82 description=e.description;
101 std::string description;
107 #define ssh_throw(x) if((x)==SSH_ERROR) throw SshException(getCSession())
108 #define ssh_throw_null(CSession,x) if((x)==NULL) throw SshException(CSession)
109 #define void_throwable void
110 #define return_throwable return
117 #define ssh_throw(x) if((x)==SSH_ERROR) return SSH_ERROR
118 #define ssh_throw_null(CSession,x) if((x)==NULL) return NULL
119 #define void_throwable int
120 #define return_throwable return SSH_OK
142 void_throwable
setOption(
enum ssh_options_e type,
const char *option){
152 void_throwable
setOption(
enum ssh_options_e type,
long int option){
162 void_throwable
setOption(
enum ssh_options_e type,
void *option){
238 int userauthPrivatekeyFile(
const char *filename,
239 const char *passphrase);
267 const char *getError(){
291 std::string ret= std::string(banner);
320 void log(
int priority,
const char *format, ...){
324 va_start(va, format);
325 vsnprintf(buffer,
sizeof(buffer), format, va);
327 ssh_log(c_session,priority,
"%s", buffer);
375 void_throwable cancelForward(
const char *address,
int port){
381 void_throwable listenForward(
const char *address,
int port,
389 ssh_session c_session;
390 ssh_session getCSession(){
394 Session(
const Session &);
395 Session& operator=(
const Session &);
407 this->session=&session;
424 ssh_throw_null(getCSession(),x11chan);
452 Session &getSession(){
473 int openForward(
const char *remotehost,
int remoteport,
474 const char *sourcehost=NULL,
int localport=0){
476 sourcehost, localport);
481 void_throwable openSession(){
486 int poll(
bool is_stderr=
false){
491 int read(
void *dest,
size_t count,
bool is_stderr=
false){
494 if(count > 0x7fffffff)
500 int readNonblocking(
void *dest,
size_t count,
bool is_stderr=
false){
503 if(count > 0x7fffffff)
509 void_throwable requestEnv(
const char *name,
const char *value){
515 void_throwable requestExec(
const char *cmd){
520 void_throwable requestPty(
const char *term=NULL,
int cols=0,
int rows=0){
522 if(term != NULL && cols != 0 && rows != 0)
530 void_throwable requestShell(){
535 void_throwable requestSendSignal(
const char *signum){
540 void_throwable requestSubsystem(
const char *subsystem){
545 int requestX11(
bool single_connection,
546 const char *protocol,
const char *cookie,
int screen_number){
548 protocol, cookie, screen_number);
552 void_throwable sendEof(){
566 int write(
const void *data,
size_t len,
bool is_stderr=
false){
569 ret=ssh_channel_write_stderr(channel,data,len);
577 ssh_session getCSession(){
578 return session->getCSession();
580 Channel (Session &session, ssh_channel c_channel){
581 this->channel=c_channel;
582 this->session=&session;
587 Channel(
const Channel &);
588 Channel &operator=(
const Channel &);
596 ssh_throw_null(c_session,forward);