-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsftp.h
More file actions
executable file
·107 lines (92 loc) · 3.14 KB
/
Copy pathsftp.h
File metadata and controls
executable file
·107 lines (92 loc) · 3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/**
* @package node-ssh
* @copyright Copyright(c) 2011 Ajax.org B.V. <info AT ajax.org>
* @author Gabor Krizsanits <gabor AT ajax DOT org>
* @license http://github.com/ajaxorg/node-ssh/blob/master/LICENSE MIT License
*/
#ifndef NODE_SFTP_SFTP_H
#define NODE_SFTP_SFTP_H
#include <node.h>
#include <node_object_wrap.h>
#include <node_events.h>
#include <v8.h>
#include <libssh/libssh.h>
#include <libssh/sftp.h>
#include <libssh/callbacks.h>
#include "sshBase.h"
//#include <cerrno>
using namespace v8;
using namespace node;
struct ListNode {
ListNode();
~ListNode();
char* data;
sftp_attributes attr;
ListNode* next;
void add(const char* data, sftp_attributes attr=NULL );
};
class SFTP : public SSHBase {
private:
sftp_session m_sftp_session;
sftp_file m_sftp_file;
ssh_channel m_ssh_channel;
ev_timer* m_timer;
ListNode* m_list;
sftp_attributes m_stat;
char* m_buf;
char* m_buf2;
size_t m_size;
size_t m_size2;
size_t m_pos;
int m_int;
int m_int2;
int m_killed;
static Persistent<FunctionTemplate> constructor_template;
static Persistent<ObjectTemplate> data_template;
static int startConnect(eio_req *req);
static int startMkdir(eio_req *req);
static int startWriteFile(eio_req *req);
static int continueWriteFile(eio_req *req);
static int cbWriteFile(eio_req *req);
static int startReadFile(eio_req *req);
static int continueReadFile(eio_req *req);
static int cbReadFile(eio_req *req);
static int startSpawn(eio_req *req);
static int continueSpawn(eio_req *req);
static int cbSpawn(eio_req *req);
static int startListDir(eio_req *req);
static int startRename(eio_req *req);
static int startChmod(eio_req *req);
static int startChown(eio_req *req);
static int startStat(eio_req *req);
static int startUnlink(eio_req *req);
static int startRmdir(eio_req *req);
static int onStat(eio_req *req);
static int onList(eio_req *req);
static int onExit(eio_req *req);
static void timerSpawn (ev_timer *w, int revents);
virtual void freeSessions();
virtual void resetData();
protected:
static Handle<Value> New(const Arguments &args);
public:
SFTP(const Arguments &);
virtual ~SFTP();
static void Initialize(Handle<Object> &);
static Handle<Value> init(const Arguments &args);
static Handle<Value> connect(const Arguments &args);
static Handle<Value> mkdir(const Arguments &args);
static Handle<Value> writeFile(const Arguments &args);
static Handle<Value> readFile(const Arguments &args);
static Handle<Value> listDir(const Arguments &args);
static Handle<Value> rename(const Arguments &args);
static Handle<Value> chmod(const Arguments &args);
static Handle<Value> chown(const Arguments &args);
static Handle<Value> stat(const Arguments &args);
static Handle<Value> unlink(const Arguments &args);
static Handle<Value> rmdir(const Arguments &args);
static Handle<Value> spawn(const Arguments &args);
static Handle<Value> isConnected(const Arguments &args);
static Handle<Value> kill(const Arguments &args);
};
#endif