|
| 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 |
0 commit comments