52 #define LIBSSH_LEGACY_0_4
54 #include <libssh/libssh.h>
55 #include <libssh/server.h>
67 #ifndef SSH_NO_CPP_EXCEPTIONS
81 description=e.description;
100 std::string description;
106 #define ssh_throw(x) if((x)==SSH_ERROR) throw SshException(getCSession())
107 #define ssh_throw_null(CSession,x) if((x)==NULL) throw SshException(CSession)
108 #define void_throwable void
109 #define return_throwable return
116 #define ssh_throw(x) if((x)==SSH_ERROR) return SSH_ERROR
117 #define ssh_throw_null(CSession,x) if((x)==NULL) return NULL
118 #define void_throwable int
119 #define return_throwable return SSH_OK
141 void_throwable
setOption(
enum ssh_options_e type,
const char *option){
151 void_throwable
setOption(
enum ssh_options_e type,
long int option){
161 void_throwable
setOption(
enum ssh_options_e type,
void *option){
230 int userauthPrivatekeyFile(
const char *filename,
231 const char *passphrase);
259 const char *getError(){
283 std::string ret= std::string(banner);
312 void log(
int priority,
const char *format, ...){
316 va_start(va, format);
317 vsnprintf(buffer,
sizeof(buffer), format, va);
319 _ssh_log(priority,
"libsshpp",
"%s", buffer);
367 void_throwable cancelForward(
const char *address,
int port){
373 void_throwable listenForward(
const char *address,
int port,
381 ssh_session c_session;
382 ssh_session getCSession(){
386 Session(
const Session &);
387 Session& operator=(
const Session &);
399 this->session=&session;
416 ssh_throw_null(getCSession(),x11chan);
444 Session &getSession(){
465 int openForward(
const char *remotehost,
int remoteport,
466 const char *sourcehost=NULL,
int localport=0){
468 sourcehost, localport);
473 void_throwable openSession(){
478 int poll(
bool is_stderr=
false){
483 int read(
void *dest,
size_t count,
bool is_stderr=
false){
486 if(count > 0x7fffffff)
492 int readNonblocking(
void *dest,
size_t count,
bool is_stderr=
false){
495 if(count > 0x7fffffff)
501 void_throwable requestEnv(
const char *name,
const char *value){
507 void_throwable requestExec(
const char *cmd){
512 void_throwable requestPty(
const char *term=NULL,
int cols=0,
int rows=0){
514 if(term != NULL && cols != 0 && rows != 0)
522 void_throwable requestShell(){
527 void_throwable requestSendSignal(
const char *signum){
532 void_throwable requestSubsystem(
const char *subsystem){
537 int requestX11(
bool single_connection,
538 const char *protocol,
const char *cookie,
int screen_number){
540 protocol, cookie, screen_number);
544 void_throwable sendEof(){
558 int write(
const void *data,
size_t len,
bool is_stderr=
false){
569 ssh_session getCSession(){
570 return session->getCSession();
572 Channel (Session &session, ssh_channel c_channel){
573 this->channel=c_channel;
574 this->session=&session;
579 Channel(
const Channel &);
580 Channel &operator=(
const Channel &);
588 ssh_throw_null(c_session,forward);