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_SESSION *session;
  46     LIBSSH2_SFTP *sftp_session;
  47 
  48     LIBSSH2_AGENT *agent;
  49 
  50     char *pubkey;
  51     char *privkey;
  52 
  53     int socket_handle;
  54     const char *fingerprint;
  55     vfs_path_element_t *original_connection_info;
  56 } sftpfs_super_t;
  57 
  58 /*** global variables defined in .c file *********************************************************/
  59 
  60 extern GString *sftpfs_filename_buffer;
  61 extern struct vfs_s_subclass sftpfs_subclass;
  62 extern struct vfs_class *sftpfs_class;
  63 
  64 /*** declarations of public functions ************************************************************/
  65 
  66 void sftpfs_init_class (void);
  67 void sftpfs_init_subclass (void);
  68 void sftpfs_init_config_variables_patterns (void);
  69 void sftpfs_deinit_config_variables_patterns (void);
  70 
  71 gboolean sftpfs_is_sftp_error (LIBSSH2_SFTP * sftp_session, int sftp_res, int sftp_error);
  72 void sftpfs_ssherror_to_gliberror (sftpfs_super_t * super, int libssh_errno, GError ** mcerror);
  73 gboolean sftpfs_waitsocket (sftpfs_super_t * super, int sftp_res, GError ** mcerror);
  74 
  75 const char *sftpfs_fix_filename (const char *file_name, unsigned int *length);
  76 void sftpfs_attr_to_stat (const LIBSSH2_SFTP_ATTRIBUTES * attrs, struct stat *s);
  77 int sftpfs_lstat (const vfs_path_t * vpath, struct stat *buf, GError ** mcerror);
  78 int sftpfs_stat (const vfs_path_t * vpath, struct stat *buf, GError ** mcerror);
  79 int sftpfs_readlink (const vfs_path_t * vpath, char *buf, size_t size, GError ** mcerror);
  80 int sftpfs_symlink (const vfs_path_t * vpath1, const vfs_path_t * vpath2, GError ** mcerror);
  81 int sftpfs_utime (const vfs_path_t * vpath, time_t atime, time_t mtime, GError ** mcerror);
  82 int sftpfs_chmod (const vfs_path_t * vpath, mode_t mode, GError ** mcerror);
  83 int sftpfs_unlink (const vfs_path_t * vpath, GError ** mcerror);
  84 int sftpfs_rename (const vfs_path_t * vpath1, const vfs_path_t * vpath2, GError ** mcerror);
  85 
  86 void sftpfs_fill_connection_data_from_config (struct vfs_s_super *super, GError ** mcerror);
  87 int sftpfs_open_connection (struct vfs_s_super *super, GError ** mcerror);
  88 void sftpfs_close_connection (struct vfs_s_super *super, const char *shutdown_message,
  89                               GError ** mcerror);
  90 
  91 vfs_file_handler_t *sftpfs_fh_new (struct vfs_s_inode *ino, gboolean changed);
  92 
  93 void *sftpfs_opendir (const vfs_path_t * vpath, GError ** mcerror);
  94 void *sftpfs_readdir (void *data, GError ** mcerror);
  95 int sftpfs_closedir (void *data, GError ** mcerror);
  96 int sftpfs_mkdir (const vfs_path_t * vpath, mode_t mode, GError ** mcerror);
  97 int sftpfs_rmdir (const vfs_path_t * vpath, GError ** mcerror);
  98 
  99 gboolean sftpfs_open_file (vfs_file_handler_t * fh, int flags, mode_t mode, GError ** mcerror);
 100 ssize_t sftpfs_read_file (vfs_file_handler_t * fh, char *buffer, size_t count, GError ** mcerror);
 101 ssize_t sftpfs_write_file (vfs_file_handler_t * fh, const char *buffer, size_t count,
 102                            GError ** mcerror);
 103 int sftpfs_close_file (vfs_file_handler_t * fh, GError ** mcerror);
 104 int sftpfs_fstat (void *data, struct stat *buf, GError ** mcerror);
 105 off_t sftpfs_lseek (vfs_file_handler_t * fh, off_t offset, int whence, GError ** mcerror);
 106 
 107 /*** inline functions ****************************************************************************/
 108 
 109 #endif /* MC__VFS_SFTPFS_INTERNAL_H */

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