root/src/vfs/sftpfs/internal.h

/* [previous][next][first][last][top][bottom][index][help]  */

INCLUDED FROM


   1 /**
   2  * \file
   3  * \brief Header: SFTP FS
   4  */
   5 
   6 #ifndef MC__VFS_SFTPFS_INTERNAL_H
   7 #define MC__VFS_SFTPFS_INTERNAL_H
   8 
   9 #include <libssh2.h>
  10 #include <libssh2_sftp.h>
  11 
  12 #include "lib/vfs/vfs.h"
  13 #include "lib/vfs/xdirentry.h"
  14 
  15 /*** typedefs(not structures) and defined constants **********************************************/
  16 
  17 #define SFTP_DEFAULT_PORT 22
  18 
  19 /* LIBSSH2_INVALID_SOCKET is defined in libssh2 >= 1.4.1 */
  20 #ifndef LIBSSH2_INVALID_SOCKET
  21 #define LIBSSH2_INVALID_SOCKET -1
  22 #endif
  23 
  24 #define SFTP_SUPER(super) ((sftpfs_super_t *) (super))
  25 
  26 /*** enums ***************************************************************************************/
  27 
  28 typedef enum
  29 {
  30     NONE = 0,
  31     PUBKEY = (1 << 0),
  32     PASSWORD = (1 << 1),
  33     AGENT = (1 << 2)
  34 } sftpfs_auth_type_t;
  35 
  36 /*** structures declarations (and typedefs of structures)*****************************************/
  37 
  38 typedef struct
  39 {
  40     struct vfs_s_super base;
  41 
  42     sftpfs_auth_type_t auth_type;
  43     sftpfs_auth_type_t config_auth_type;
  44 
  45     LIBSSH2_KNOWNHOSTS *known_hosts;
  46     char *known_hosts_file;
  47 
  48     LIBSSH2_SESSION *session;
  49     LIBSSH2_SFTP *sftp_session;
  50 
  51     LIBSSH2_AGENT *agent;
  52 
  53     char *pubkey;
  54     char *privkey;
  55 
  56     int socket_handle;
  57     const char *ip_address;
  58     vfs_path_element_t *original_connection_info;
  59 } sftpfs_super_t;
  60 
  61 /*** global variables defined in .c file *********************************************************/
  62 
  63 extern GString *sftpfs_filename_buffer;
  64 extern struct vfs_s_subclass sftpfs_subclass;
  65 extern struct vfs_class *vfs_sftpfs_ops;
  66 
  67 /*** declarations of public functions ************************************************************/
  68 
  69 void sftpfs_init_config_variables_patterns (void);
  70 void sftpfs_deinit_config_variables_patterns (void);
  71 
  72 gboolean sftpfs_is_sftp_error (LIBSSH2_SFTP * sftp_session, int sftp_res, int sftp_error);
  73 void sftpfs_ssherror_to_gliberror (sftpfs_super_t * super, int libssh_errno, GError ** mcerror);
  74 gboolean sftpfs_waitsocket (sftpfs_super_t * super, int sftp_res, GError ** mcerror);
  75 
  76 const GString *sftpfs_fix_filename (const char *file_name);
  77 
  78 gboolean sftpfs_op_init (sftpfs_super_t ** super, const vfs_path_element_t ** path_element,
  79                          const vfs_path_t * vpath, GError ** mcerror);
  80 
  81 void sftpfs_attr_to_stat (const LIBSSH2_SFTP_ATTRIBUTES * attrs, struct stat *s);
  82 int sftpfs_lstat (const vfs_path_t * vpath, struct stat *buf, GError ** mcerror);
  83 int sftpfs_stat (const vfs_path_t * vpath, struct stat *buf, GError ** mcerror);
  84 int sftpfs_readlink (const vfs_path_t * vpath, char *buf, size_t size, GError ** mcerror);
  85 int sftpfs_symlink (const vfs_path_t * vpath1, const vfs_path_t * vpath2, GError ** mcerror);
  86 int sftpfs_utime (const vfs_path_t * vpath, time_t atime, time_t mtime, GError ** mcerror);
  87 int sftpfs_chmod (const vfs_path_t * vpath, mode_t mode, GError ** mcerror);
  88 int sftpfs_unlink (const vfs_path_t * vpath, GError ** mcerror);
  89 int sftpfs_rename (const vfs_path_t * vpath1, const vfs_path_t * vpath2, GError ** mcerror);
  90 
  91 void sftpfs_fill_connection_data_from_config (struct vfs_s_super *super, GError ** mcerror);
  92 int sftpfs_open_connection (struct vfs_s_super *super, GError ** mcerror);
  93 void sftpfs_close_connection (struct vfs_s_super *super, const char *shutdown_message,
  94                               GError ** mcerror);
  95 
  96 vfs_file_handler_t *sftpfs_fh_new (struct vfs_s_inode *ino, gboolean changed);
  97 
  98 void *sftpfs_opendir (const vfs_path_t * vpath, GError ** mcerror);
  99 struct vfs_dirent *sftpfs_readdir (void *data, GError ** mcerror);
 100 int sftpfs_closedir (void *data, GError ** mcerror);
 101 int sftpfs_mkdir (const vfs_path_t * vpath, mode_t mode, GError ** mcerror);
 102 int sftpfs_rmdir (const vfs_path_t * vpath, GError ** mcerror);
 103 
 104 gboolean sftpfs_open_file (vfs_file_handler_t * fh, int flags, mode_t mode, GError ** mcerror);
 105 ssize_t sftpfs_read_file (vfs_file_handler_t * fh, char *buffer, size_t count, GError ** mcerror);
 106 ssize_t sftpfs_write_file (vfs_file_handler_t * fh, const char *buffer, size_t count,
 107                            GError ** mcerror);
 108 int sftpfs_close_file (vfs_file_handler_t * fh, GError ** mcerror);
 109 int sftpfs_fstat (void *data, struct stat *buf, GError ** mcerror);
 110 off_t sftpfs_lseek (vfs_file_handler_t * fh, off_t offset, int whence, GError ** mcerror);
 111 
 112 /*** inline functions ****************************************************************************/
 113 
 114 #endif /* MC__VFS_SFTPFS_INTERNAL_H */

/* [previous][next][first][last][top][bottom][index][help]  */