40 #include <sys/types.h> 50 typedef uint32_t uid_t;
53 typedef uint32_t gid_t;
57 # ifndef _SSIZE_T_DEFINED 60 typedef _W64 SSIZE_T ssize_t;
61 # define _SSIZE_T_DEFINED 67 #define LIBSFTP_VERSION 3 72 typedef struct sftp_ext_struct *sftp_ext;
171 uint32_t permissions;
174 uint32_t atime_nseconds;
176 uint32_t createtime_nseconds;
179 uint32_t mtime_nseconds;
181 uint32_t extended_count;
857 #define SFTP_HANDLES 256 869 LIBSSH_API
void sftp_client_message_set_filename(
sftp_client_message msg,
const char *newname);
880 LIBSSH_API
int sftp_reply_status(
sftp_client_message msg, uint32_t status,
const char *message);
885 LIBSSH_API
void sftp_handle_remove(
sftp_session sftp,
void *handle);
888 #define SSH_FXP_INIT 1 889 #define SSH_FXP_VERSION 2 890 #define SSH_FXP_OPEN 3 891 #define SSH_FXP_CLOSE 4 892 #define SSH_FXP_READ 5 893 #define SSH_FXP_WRITE 6 894 #define SSH_FXP_LSTAT 7 895 #define SSH_FXP_FSTAT 8 896 #define SSH_FXP_SETSTAT 9 897 #define SSH_FXP_FSETSTAT 10 898 #define SSH_FXP_OPENDIR 11 899 #define SSH_FXP_READDIR 12 900 #define SSH_FXP_REMOVE 13 901 #define SSH_FXP_MKDIR 14 902 #define SSH_FXP_RMDIR 15 903 #define SSH_FXP_REALPATH 16 904 #define SSH_FXP_STAT 17 905 #define SSH_FXP_RENAME 18 906 #define SSH_FXP_READLINK 19 907 #define SSH_FXP_SYMLINK 20 909 #define SSH_FXP_STATUS 101 910 #define SSH_FXP_HANDLE 102 911 #define SSH_FXP_DATA 103 912 #define SSH_FXP_NAME 104 913 #define SSH_FXP_ATTRS 105 915 #define SSH_FXP_EXTENDED 200 916 #define SSH_FXP_EXTENDED_REPLY 201 923 #define SSH_FILEXFER_ATTR_SIZE 0x00000001 924 #define SSH_FILEXFER_ATTR_PERMISSIONS 0x00000004 925 #define SSH_FILEXFER_ATTR_ACCESSTIME 0x00000008 926 #define SSH_FILEXFER_ATTR_ACMODTIME 0x00000008 927 #define SSH_FILEXFER_ATTR_CREATETIME 0x00000010 928 #define SSH_FILEXFER_ATTR_MODIFYTIME 0x00000020 929 #define SSH_FILEXFER_ATTR_ACL 0x00000040 930 #define SSH_FILEXFER_ATTR_OWNERGROUP 0x00000080 931 #define SSH_FILEXFER_ATTR_SUBSECOND_TIMES 0x00000100 932 #define SSH_FILEXFER_ATTR_EXTENDED 0x80000000 933 #define SSH_FILEXFER_ATTR_UIDGID 0x00000002 936 #define SSH_FILEXFER_TYPE_REGULAR 1 937 #define SSH_FILEXFER_TYPE_DIRECTORY 2 938 #define SSH_FILEXFER_TYPE_SYMLINK 3 939 #define SSH_FILEXFER_TYPE_SPECIAL 4 940 #define SSH_FILEXFER_TYPE_UNKNOWN 5 954 #define SSH_FX_NO_SUCH_FILE 2 956 #define SSH_FX_PERMISSION_DENIED 3 958 #define SSH_FX_FAILURE 4 960 #define SSH_FX_BAD_MESSAGE 5 962 #define SSH_FX_NO_CONNECTION 6 964 #define SSH_FX_CONNECTION_LOST 7 966 #define SSH_FX_OP_UNSUPPORTED 8 968 #define SSH_FX_INVALID_HANDLE 9 970 #define SSH_FX_NO_SUCH_PATH 10 972 #define SSH_FX_FILE_ALREADY_EXISTS 11 974 #define SSH_FX_WRITE_PROTECT 12 976 #define SSH_FX_NO_MEDIA 13 981 #define SSH_FXF_READ 0x01 982 #define SSH_FXF_WRITE 0x02 983 #define SSH_FXF_APPEND 0x04 984 #define SSH_FXF_CREAT 0x08 985 #define SSH_FXF_TRUNC 0x10 986 #define SSH_FXF_EXCL 0x20 987 #define SSH_FXF_TEXT 0x40 990 #define SSH_S_IFMT 00170000 991 #define SSH_S_IFSOCK 0140000 992 #define SSH_S_IFLNK 0120000 993 #define SSH_S_IFREG 0100000 994 #define SSH_S_IFBLK 0060000 995 #define SSH_S_IFDIR 0040000 996 #define SSH_S_IFCHR 0020000 997 #define SSH_S_IFIFO 0010000 1000 #define SSH_FXF_RENAME_OVERWRITE 0x00000001 1001 #define SSH_FXF_RENAME_ATOMIC 0x00000002 1002 #define SSH_FXF_RENAME_NATIVE 0x00000004 1004 #define SFTP_OPEN SSH_FXP_OPEN 1005 #define SFTP_CLOSE SSH_FXP_CLOSE 1006 #define SFTP_READ SSH_FXP_READ 1007 #define SFTP_WRITE SSH_FXP_WRITE 1008 #define SFTP_LSTAT SSH_FXP_LSTAT 1009 #define SFTP_FSTAT SSH_FXP_FSTAT 1010 #define SFTP_SETSTAT SSH_FXP_SETSTAT 1011 #define SFTP_FSETSTAT SSH_FXP_FSETSTAT 1012 #define SFTP_OPENDIR SSH_FXP_OPENDIR 1013 #define SFTP_READDIR SSH_FXP_READDIR 1014 #define SFTP_REMOVE SSH_FXP_REMOVE 1015 #define SFTP_MKDIR SSH_FXP_MKDIR 1016 #define SFTP_RMDIR SSH_FXP_RMDIR 1017 #define SFTP_REALPATH SSH_FXP_REALPATH 1018 #define SFTP_STAT SSH_FXP_STAT 1019 #define SFTP_RENAME SSH_FXP_RENAME 1020 #define SFTP_READLINK SSH_FXP_READLINK 1021 #define SFTP_SYMLINK SSH_FXP_SYMLINK 1022 #define SFTP_EXTENDED SSH_FXP_EXTENDED 1025 #define SSH_FXE_STATVFS_ST_RDONLY 0x1 1026 #define SSH_FXE_STATVFS_ST_NOSUID 0x2
LIBSSH_API int sftp_unlink(sftp_session sftp, const char *file)
Unlink (delete) a file.
LIBSSH_API int sftp_dir_eof(sftp_dir dir)
Tell if the directory has reached EOF (End Of File).
LIBSSH_API int sftp_fsync(sftp_file file)
Synchronize a file's in-core state with storage device.
LIBSSH_API char * sftp_canonicalize_path(sftp_session sftp, const char *path)
Canonicalize a sftp path.
uint64_t f_bfree
Definition: sftp.h:193
LIBSSH_API sftp_dir sftp_opendir(sftp_session session, const char *path)
Open a directory used to obtain directory entries.
LIBSSH_API int sftp_rename(sftp_session sftp, const char *original, const char *newname)
Rename or move a file or directory.
LIBSSH_API int sftp_extension_supported(sftp_session sftp, const char *name, const char *data)
Check if the given extension is supported.
LIBSSH_API int sftp_async_read_begin(sftp_file file, uint32_t len)
Start an asynchronous read from a file using an opened sftp file handle.
LIBSSH_API int sftp_utimes(sftp_session sftp, const char *file, const struct timeval *times)
Change the last modification and access time of a file.
Definition: channels.h:57
LIBSSH_API void sftp_statvfs_free(sftp_statvfs_t statvfs_o)
Free the memory of an allocated statvfs.
LIBSSH_API int sftp_rmdir(sftp_session sftp, const char *directory)
Remove a directoy.
uint64_t f_favail
Definition: sftp.h:197
Definition: session.h:102
LIBSSH_API void sftp_file_set_blocking(sftp_file handle)
Make the sftp communication for this file handle blocking.
LIBSSH_API int sftp_server_version(sftp_session sftp)
Get the version of the SFTP protocol supported by the server.
uint64_t f_files
Definition: sftp.h:195
LIBSSH_API int sftp_chown(sftp_session sftp, const char *file, uid_t owner, gid_t group)
Change the file owner and group.
uint64_t f_ffree
Definition: sftp.h:196
LIBSSH_API const char * sftp_extensions_get_data(sftp_session sftp, unsigned int indexn)
Get the data of the extension provided by the server.
SFTP statvfs structure.
Definition: sftp.h:189
LIBSSH_API sftp_session sftp_new(ssh_session session)
Start a new sftp session.
LIBSSH_API int sftp_setstat(sftp_session sftp, const char *file, sftp_attributes attr)
Set file attributes on a file, directory or symbolic link.
LIBSSH_API sftp_attributes sftp_fstat(sftp_file file)
Get information about a file or directory from a file handle.
LIBSSH_API const char * sftp_extensions_get_name(sftp_session sftp, unsigned int indexn)
Get the name of the extension provided by the server.
LIBSSH_API unsigned long sftp_tell(sftp_file file)
Report current byte position in file.
uint64_t f_fsid
Definition: sftp.h:198
LIBSSH_API char * sftp_readlink(sftp_session sftp, const char *path)
Read the value of a symbolic link.
uint64_t f_namemax
Definition: sftp.h:200
LIBSSH_API int sftp_seek(sftp_file file, uint32_t new_offset)
Seek to a specific location in a file.
LIBSSH_API int sftp_close(sftp_file file)
Close an open file handle.
LIBSSH_API sftp_session sftp_new_channel(ssh_session session, ssh_channel channel)
Start a new sftp session with an existing channel.
LIBSSH_API unsigned int sftp_extensions_get_count(sftp_session sftp)
Get the count of extensions provided by the server.
LIBSSH_API sftp_attributes sftp_readdir(sftp_session session, sftp_dir dir)
Get a single file attributes structure of a directory.
LIBSSH_API void sftp_rewind(sftp_file file)
Rewinds the position of the file pointer to the beginning of the file.
LIBSSH_API int sftp_get_error(sftp_session sftp)
Get the last sftp error.
LIBSSH_API int sftp_seek64(sftp_file file, uint64_t new_offset)
Seek to a specific location in a file. This is the 64bit version.
uint64_t f_bavail
Definition: sftp.h:194
LIBSSH_API int sftp_async_read(sftp_file file, void *data, uint32_t len, uint32_t id)
Wait for an asynchronous read to complete and save the data.
uint64_t f_frsize
Definition: sftp.h:191
LIBSSH_API int sftp_init(sftp_session sftp)
Initialize the sftp session with the server.
LIBSSH_API int sftp_closedir(sftp_dir dir)
Close a directory handle opened by sftp_opendir().
LIBSSH_API int sftp_symlink(sftp_session sftp, const char *target, const char *dest)
Create a symbolic link.
LIBSSH_API sftp_statvfs_t sftp_statvfs(sftp_session sftp, const char *path)
Get information about a mounted file system.
uint64_t f_blocks
Definition: sftp.h:192
LIBSSH_API void sftp_file_set_nonblocking(sftp_file handle)
Make the sftp communication for this file handle non blocking.
LIBSSH_API ssize_t sftp_write(sftp_file file, const void *buf, size_t count)
Write to a file using an opened sftp file handle.
LIBSSH_API void sftp_attributes_free(sftp_attributes file)
Free a sftp attribute structure.
LIBSSH_API ssize_t sftp_read(sftp_file file, void *buf, size_t count)
Read from a file using an opened sftp file handle.
LIBSSH_API sftp_statvfs_t sftp_fstatvfs(sftp_file file)
Get information about a mounted file system.
LIBSSH_API int sftp_chmod(sftp_session sftp, const char *file, mode_t mode)
Change permissions of a file.
LIBSSH_API sftp_file sftp_open(sftp_session session, const char *file, int accesstype, mode_t mode)
Open a file on the server.
uint64_t f_flag
Definition: sftp.h:199
LIBSSH_API uint64_t sftp_tell64(sftp_file file)
Report current byte position in file.
LIBSSH_API void sftp_free(sftp_session sftp)
Close and deallocate a sftp session.
LIBSSH_API sftp_attributes sftp_stat(sftp_session session, const char *path)
Get information about a file or directory.
LIBSSH_API int sftp_mkdir(sftp_session sftp, const char *directory, mode_t mode)
Create a directory.
LIBSSH_API sftp_attributes sftp_lstat(sftp_session session, const char *path)
Get information about a file or directory.