Ticket #1535: SFTP support
[midnight-commander.git] / src / vfs / sftpfs / internal.h
blob7c0f457a06adaa2d4c9a4d82e159247f17753ae5
1 /**
2 * \file
3 * \brief Header: SFTP FS
4 */
6 #ifndef MC__VFS_SFTPFS_INTERNAL_H
7 #define MC__VFS_SFTPFS_INTERNAL_H
9 #include <libssh2.h>
10 #include <libssh2_sftp.h>
12 #include "lib/vfs/vfs.h"
13 #include "lib/vfs/xdirentry.h"
15 /*** typedefs(not structures) and defined constants **********************************************/
17 #define SFTP_DEFAULT_PORT 22
19 /*** enums ***************************************************************************************/
21 typedef enum
23 NONE = 0,
24 PUBKEY = (1 << 0),
25 PASSWORD = (1 << 1),
26 AGENT = (1 << 2)
27 } sftpfs_auth_type_t;
29 /*** structures declarations (and typedefs of structures)*****************************************/
31 typedef struct
33 sftpfs_auth_type_t auth_type;
34 sftpfs_auth_type_t config_auth_type;
36 LIBSSH2_SESSION *session;
37 LIBSSH2_SFTP *sftp_session;
39 LIBSSH2_AGENT *agent;
41 char *pubkey;
42 char *privkey;
44 int socket_handle;
45 const char *fingerprint;
46 } sftpfs_super_data_t;
48 /*** global variables defined in .c file *********************************************************/
50 extern GString *sftpfs_filename_buffer;
51 extern struct vfs_class sftpfs_class;
52 extern struct vfs_s_subclass sftpfs_subclass;
54 /*** declarations of public functions ************************************************************/
56 void sftpfs_init_class (void);
57 void sftpfs_init_subclass (void);
58 void sftpfs_init_class_callbacks (void);
59 void sftpfs_init_subclass_callbacks (void);
60 void sftpfs_init_config_variables_patterns (void);
61 void sftpfs_deinit_config_variables_patterns (void);
63 gboolean sftpfs_show_error (GError ** error);
64 void sftpfs_ssherror_to_gliberror (sftpfs_super_data_t * super_data, int libssh_errno,
65 GError ** error);
66 int sftpfs_waitsocket (sftpfs_super_data_t * super_data, GError ** error);
68 const char *sftpfs_fix_filename (const char *file_name);
69 int sftpfs_lstat (const vfs_path_t * vpath, struct stat *buf, GError ** error);
70 int sftpfs_stat (const vfs_path_t * vpath, struct stat *buf, GError ** error);
71 int sftpfs_readlink (const vfs_path_t * vpath, char *buf, size_t size, GError ** error);
72 int sftpfs_symlink (const vfs_path_t * vpath1, const vfs_path_t * vpath2, GError ** error);
73 int sftpfs_chmod (const vfs_path_t * vpath, mode_t mode, GError ** error);
74 int sftpfs_unlink (const vfs_path_t * vpath, GError ** error);
75 int sftpfs_rename (const vfs_path_t * vpath1, const vfs_path_t * vpath2, GError ** error);
77 void sftpfs_fill_connection_data_from_config (struct vfs_s_super *super, GError ** error);
78 int sftpfs_open_connection (struct vfs_s_super *super, GError ** error);
79 void sftpfs_close_connection (struct vfs_s_super *super, const char *shutdown_message,
80 GError ** error);
82 void *sftpfs_opendir (const vfs_path_t * vpath, GError ** error);
83 void *sftpfs_readdir (void *data, GError ** error);
84 int sftpfs_closedir (void *data, GError ** error);
85 int sftpfs_mkdir (const vfs_path_t * vpath, mode_t mode, GError ** error);
86 int sftpfs_rmdir (const vfs_path_t * vpath, GError ** error);
88 gboolean sftpfs_open_file (vfs_file_handler_t * file_handler, int flags, mode_t mode,
89 GError ** error);
90 ssize_t sftpfs_read_file (vfs_file_handler_t * file_handler, char *buffer, size_t count,
91 GError ** error);
92 ssize_t sftpfs_write_file (vfs_file_handler_t * file_handler, const char *buffer, size_t count,
93 GError ** error);
94 int sftpfs_close_file (vfs_file_handler_t * file_handler, GError ** error);
95 int sftpfs_fstat (void *data, struct stat *buf, GError ** error);
96 off_t sftpfs_lseek (vfs_file_handler_t * file_handler, off_t offset, int whence, GError ** error);
98 /*** inline functions ****************************************************************************/
100 #endif /* MC__VFS_SFTPFS_INTERNAL_H */