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 *sftpfs_class;
  66 
  67 /*** declarations of public functions ************************************************************/
  68 
  69 void sftpfs_init_class (void);
  70 void sftpfs_init_subclass (void);
  71 void sftpfs_init_config_variables_patterns (void);
  72 void sftpfs_deinit_config_variables_patterns (void);
  73 
  74 gboolean sftpfs_is_sftp_error (LIBSSH2_SFTP * sftp_session, int sftp_res, int sftp_error);
  75 void sftpfs_ssherror_to_gliberror (sftpfs_super_t * super, int libssh_errno, GError ** mcerror);
  76 gboolean sftpfs_waitsocket (sftpfs_super_t * super, int sftp_res, GError ** mcerror);
  77 
  78 const GString *sftpfs_fix_filename (const char *file_name);
  79 void sftpfs_attr_to_stat (const LIBSSH2_SFTP_ATTRIBUTES * attrs, struct stat *s);
  80 int sftpfs_lstat (const vfs_path_t * vpath, struct stat *buf, GError ** mcerror);
  81 int sftpfs_stat (const vfs_path_t * vpath, struct stat *buf, GError ** mcerror);
  82 int sftpfs_readlink (const vfs_path_t * vpath, char *buf, size_t size, GError ** mcerror);
  83 int sftpfs_symlink (const vfs_path_t * vpath1, const vfs_path_t * vpath2, GError ** mcerror);
  84 int sftpfs_utime (const vfs_path_t * vpath, time_t atime, time_t mtime, GError ** mcerror);
  85 int sftpfs_chmod (const vfs_path_t * vpath, mode_t mode, GError ** mcerror);
  86 int sftpfs_unlink (const vfs_path_t * vpath, GError ** mcerror);
  87 int sftpfs_rename (const vfs_path_t * vpath1, const vfs_path_t * vpath2, GError ** mcerror);
  88 
  89 void sftpfs_fill_connection_data_from_config (struct vfs_s_super *super, GError ** mcerror);
  90 int sftpfs_open_connection (struct vfs_s_super *super, GError ** mcerror);
  91 void sftpfs_close_connection (struct vfs_s_super *super, const char *shutdown_message,
  92                               GError ** mcerror);
  93 
  94 vfs_file_handler_t *sftpfs_fh_new (struct vfs_s_inode *ino, gboolean changed);
  95 
  96 void *sftpfs_opendir (const vfs_path_t * vpath, GError ** mcerror);
  97 struct vfs_dirent *sftpfs_readdir (void *data, GError ** mcerror);
  98 int sftpfs_closedir (void *data, GError ** mcerror);
  99 int sftpfs_mkdir (const vfs_path_t * vpath, mode_t mode, GError ** mcerror);
 100 int sftpfs_rmdir (const vfs_path_t * vpath, GError ** mcerror);
 101 
 102 gboolean sftpfs_open_file (vfs_file_handler_t * fh, int flags, mode_t mode, GError ** mcerror);
 103 ssize_t sftpfs_read_file (vfs_file_handler_t * fh, char *buffer, size_t count, GError ** mcerror);
 104 ssize_t sftpfs_write_file (vfs_file_handler_t * fh, const char *buffer, size_t count,
 105                            GError ** mcerror);
 106 int sftpfs_close_file (vfs_file_handler_t * fh, GError ** mcerror);
 107 int sftpfs_fstat (void *data, struct stat *buf, GError ** mcerror);
 108 off_t sftpfs_lseek (vfs_file_handler_t * fh, off_t offset, int whence, GError ** mcerror);
 109 
 110 /*** inline functions ****************************************************************************/
 111 
 112 #endif /* MC__VFS_SFTPFS_INTERNAL_H */

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