Skip to content

Commit 8f788bb

Browse files
author
Pan
committed
Added scp and sftp definitions.
1 parent 9756dff commit 8f788bb

File tree

4 files changed

+187
-3
lines changed

4 files changed

+187
-3
lines changed

ssh/c_scp.pxd

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# This file is part of ssh-python.
2+
# Copyright (C) 2018 Panos Kittenis
3+
#
4+
# This library is free software; you can redistribute it and/or
5+
# modify it under the terms of the GNU Lesser General Public
6+
# License as published by the Free Software Foundation, version 2.1.
7+
#
8+
# This library is distributed in the hope that it will be useful,
9+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11+
# Lesser General Public License for more details.
12+
#
13+
# You should have received a copy of the GNU Lesser General Public
14+
# License along with this library; if not, write to the Free Software
15+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130
16+
17+
from c_ssh cimport ssh_scp, ssh_scp_request_types, ssh_channel, uint64_t, \
18+
ssh_session
19+
20+
cdef extern from "libssh/include/scp.h" nogil:
21+
enum ssh_scp_states:
22+
SSH_SCP_NEW,
23+
SSH_SCP_WRITE_INITED,
24+
SSH_SCP_WRITE_WRITING,
25+
SSH_SCP_READ_INITED,
26+
SSH_SCP_READ_REQUESTED,
27+
SSH_SCP_READ_READING,
28+
SSH_SCP_ERROR,
29+
SSH_SCP_TERMINATED
30+
31+
struct ssh_scp_struct:
32+
ssh_session session
33+
int mode
34+
int recursive
35+
ssh_channel channel
36+
char *location
37+
ssh_scp_states state
38+
uint64_t filelen
39+
uint64_t processed
40+
ssh_scp_request_types request_type
41+
char *request_name
42+
char *warning
43+
int request_mode
44+
int ssh_scp_read_string(ssh_scp scp, char *buffer, size_t len)
45+
int ssh_scp_integer_mode(const char *mode)
46+
char *ssh_scp_string_mode(int mode)
47+
int ssh_scp_response(ssh_scp scp, char **response)

ssh/c_sftp.pxd

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
# This file is part of ssh-python.
2+
# Copyright (C) 2018 Panos Kittenis
3+
#
4+
# This library is free software; you can redistribute it and/or
5+
# modify it under the terms of the GNU Lesser General Public
6+
# License as published by the Free Software Foundation, version 2.1.
7+
#
8+
# This library is distributed in the hope that it will be useful,
9+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11+
# Lesser General Public License for more details.
12+
#
13+
# You should have received a copy of the GNU Lesser General Public
14+
# License along with this library; if not, write to the Free Software
15+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130
16+
17+
from c_ssh cimport uint64_t, uint32_t, uint8_t, ssh_string, ssh_buffer, \
18+
ssh_channel, ssh_session
19+
20+
cdef extern from "libssh/include/sftp.h" nogil:
21+
ctypedef sftp_attributes_struct* sftp_attributes
22+
ctypedef sftp_client_message_struct* sftp_client_message
23+
ctypedef sftp_dir_struct* sftp_dir
24+
# ctypedef sftp_ext_struct *sftp_ext
25+
ctypedef sftp_file_struct* sftp_file
26+
ctypedef sftp_message_struct* sftp_message
27+
ctypedef sftp_packet_struct* sftp_packet
28+
ctypedef sftp_request_queue_struct* sftp_request_queue
29+
ctypedef sftp_session_struct* sftp_session
30+
ctypedef sftp_status_message_struct* sftp_status_message
31+
ctypedef sftp_statvfs_struct* sftp_statvfs_t
32+
33+
struct sftp_session_struct:
34+
ssh_session session
35+
ssh_channel channel
36+
int server_version
37+
int client_version
38+
int version
39+
sftp_request_queue queue
40+
uint32_t id_counter
41+
int errnum
42+
void **handles
43+
# sftp_ext ext
44+
45+
struct sftp_packet_struct:
46+
sftp_session sftp
47+
uint8_t type
48+
ssh_buffer payload
49+
50+
struct sftp_file_struct:
51+
sftp_session sftp
52+
char *name
53+
uint64_t offset
54+
ssh_string handle
55+
int eof
56+
int nonblocking
57+
58+
struct sftp_dir_struct:
59+
sftp_session sftp
60+
char *name
61+
ssh_string handle
62+
ssh_buffer buffer
63+
uint32_t count
64+
int eof
65+
66+
struct sftp_message_struct:
67+
sftp_session sftp
68+
uint8_t packet_type
69+
ssh_buffer payload
70+
uint32_t id
71+
72+
struct sftp_client_message_struct:
73+
sftp_session sftp
74+
uint8_t type
75+
uint32_t id
76+
char *filename
77+
uint32_t flags
78+
sftp_attributes attr
79+
ssh_string handle
80+
uint64_t offset
81+
uint32_t len
82+
int attr_num
83+
ssh_buffer attrbuf
84+
ssh_string data
85+
ssh_buffer complete_message
86+
char *str_data
87+
88+
struct sftp_request_queue_struct:
89+
sftp_request_queue _next "next"
90+
sftp_message message
91+
92+
struct sftp_status_message_struct:
93+
uint32_t _id "id"
94+
uint32_t status
95+
ssh_string error_unused
96+
ssh_string lang_unused
97+
char *errormsg;
98+
char *langmsg;
99+
100+
struct sftp_attributes_struct:
101+
char *name
102+
char *longname
103+
uint32_t flags
104+
uint8_t type
105+
uint64_t size
106+
uint32_t uid
107+
uint32_t gid
108+
char *owner
109+
char *group
110+
uint32_t permissions
111+
uint64_t atime64
112+
uint32_t atime
113+
uint32_t atime_nseconds
114+
uint64_t createtime
115+
uint32_t createtime_nseconds
116+
uint64_t mtime64
117+
uint32_t mtime
118+
uint32_t mtime_nseconds
119+
ssh_string acl
120+
uint32_t extended_count
121+
ssh_string extended_type
122+
ssh_string extended_data
123+
124+
struct sftp_statvfs_struct:
125+
uint64_t f_bsize
126+
uint64_t f_frsize
127+
uint64_t f_blocks
128+
uint64_t f_bfree
129+
uint64_t f_bavail
130+
uint64_t f_files
131+
uint64_t f_ffree
132+
uint64_t f_favail
133+
uint64_t f_fsid
134+
uint64_t f_flag
135+
uint64_t f_namemax

ssh/c_ssh.pxd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# This file is part of ssh-python.
22
# Copyright (C) 2018 Panos Kittenis
3-
3+
#
44
# This library is free software; you can redistribute it and/or
55
# modify it under the terms of the GNU Lesser General Public
66
# License as published by the Free Software Foundation, version 2.1.
7-
7+
#
88
# This library is distributed in the hope that it will be useful,
99
# but WITHOUT ANY WARRANTY; without even the implied warranty of
1010
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1111
# Lesser General Public License for more details.
12-
12+
#
1313
# You should have received a copy of the GNU Lesser General Public
1414
# License along with this library; if not, write to the Free Software
1515
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130

ssh/ssh.pyx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,5 @@ cimport c_socket
3838
cimport c_priv
3939
cimport c_session
4040
cimport c_pki_priv
41+
cimport c_scp
42+
cimport c_sftp

0 commit comments

Comments
 (0)