Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

sftp.h

00001 /*
00002  * sftp.h: definitions for SFTP and the sftp.c routines.
00003  */
00004 
00005 #include "int64.h"
00006 
00007 #define SSH_FXP_INIT                              1     /* 0x1 */
00008 #define SSH_FXP_VERSION                           2     /* 0x2 */
00009 #define SSH_FXP_OPEN                              3     /* 0x3 */
00010 #define SSH_FXP_CLOSE                             4     /* 0x4 */
00011 #define SSH_FXP_READ                              5     /* 0x5 */
00012 #define SSH_FXP_WRITE                             6     /* 0x6 */
00013 #define SSH_FXP_LSTAT                             7     /* 0x7 */
00014 #define SSH_FXP_FSTAT                             8     /* 0x8 */
00015 #define SSH_FXP_SETSTAT                           9     /* 0x9 */
00016 #define SSH_FXP_FSETSTAT                          10    /* 0xa */
00017 #define SSH_FXP_OPENDIR                           11    /* 0xb */
00018 #define SSH_FXP_READDIR                           12    /* 0xc */
00019 #define SSH_FXP_REMOVE                            13    /* 0xd */
00020 #define SSH_FXP_MKDIR                             14    /* 0xe */
00021 #define SSH_FXP_RMDIR                             15    /* 0xf */
00022 #define SSH_FXP_REALPATH                          16    /* 0x10 */
00023 #define SSH_FXP_STAT                              17    /* 0x11 */
00024 #define SSH_FXP_RENAME                            18    /* 0x12 */
00025 #define SSH_FXP_STATUS                            101   /* 0x65 */
00026 #define SSH_FXP_HANDLE                            102   /* 0x66 */
00027 #define SSH_FXP_DATA                              103   /* 0x67 */
00028 #define SSH_FXP_NAME                              104   /* 0x68 */
00029 #define SSH_FXP_ATTRS                             105   /* 0x69 */
00030 #define SSH_FXP_EXTENDED                          200   /* 0xc8 */
00031 #define SSH_FXP_EXTENDED_REPLY                    201   /* 0xc9 */
00032 
00033 #define SSH_FX_OK                                 0
00034 #define SSH_FX_EOF                                1
00035 #define SSH_FX_NO_SUCH_FILE                       2
00036 #define SSH_FX_PERMISSION_DENIED                  3
00037 #define SSH_FX_FAILURE                            4
00038 #define SSH_FX_BAD_MESSAGE                        5
00039 #define SSH_FX_NO_CONNECTION                      6
00040 #define SSH_FX_CONNECTION_LOST                    7
00041 #define SSH_FX_OP_UNSUPPORTED                     8
00042 
00043 #define SSH_FILEXFER_ATTR_SIZE                    0x00000001
00044 #define SSH_FILEXFER_ATTR_UIDGID                  0x00000002
00045 #define SSH_FILEXFER_ATTR_PERMISSIONS             0x00000004
00046 #define SSH_FILEXFER_ATTR_ACMODTIME               0x00000008
00047 #define SSH_FILEXFER_ATTR_EXTENDED                0x80000000
00048 
00049 #define SSH_FXF_READ                              0x00000001
00050 #define SSH_FXF_WRITE                             0x00000002
00051 #define SSH_FXF_APPEND                            0x00000004
00052 #define SSH_FXF_CREAT                             0x00000008
00053 #define SSH_FXF_TRUNC                             0x00000010
00054 #define SSH_FXF_EXCL                              0x00000020
00055 
00056 #define SFTP_PROTO_VERSION 3
00057 
00058 /*
00059  * External references. The sftp client module sftp.c expects to be
00060  * able to get at these functions.
00061  * 
00062  * sftp_recvdata must never return less than len. It either blocks
00063  * until len is available, or it returns failure.
00064  * 
00065  * Both functions return 1 on success, 0 on failure.
00066  */
00067 int sftp_senddata(char *data, int len);
00068 int sftp_recvdata(char *data, int len);
00069 
00070 struct fxp_attrs {
00071     unsigned long flags;
00072     uint64 size;
00073     unsigned long uid;
00074     unsigned long gid;
00075     unsigned long permissions;
00076     unsigned long atime;
00077     unsigned long mtime;
00078 };
00079 
00080 struct fxp_handle {
00081     char *hstring;
00082     int hlen;
00083 };
00084 
00085 struct fxp_name {
00086     char *filename, *longname;
00087     struct fxp_attrs attrs;
00088 };
00089 
00090 struct fxp_names {
00091     int nnames;
00092     struct fxp_name *names;
00093 };
00094 
00095 const char *fxp_error(void);
00096 int fxp_error_type(void);
00097 
00098 /*
00099  * Perform exchange of init/version packets. Return 0 on failure.
00100  */
00101 int fxp_init(void);
00102 
00103 /*
00104  * Canonify a pathname. Concatenate the two given path elements
00105  * with a separating slash, unless the second is NULL.
00106  */
00107 char *fxp_realpath(char *path);
00108 
00109 /*
00110  * Open a file.
00111  */
00112 struct fxp_handle *fxp_open(char *path, int type);
00113 
00114 /*
00115  * Open a directory.
00116  */
00117 struct fxp_handle *fxp_opendir(char *path);
00118 
00119 /*
00120  * Close a file/dir.
00121  */
00122 void fxp_close(struct fxp_handle *handle);
00123 
00124 /*
00125  * Make a directory.
00126  */
00127 int fxp_mkdir(char *path);
00128 
00129 /*
00130  * Remove a directory.
00131  */
00132 int fxp_rmdir(char *path);
00133 
00134 /*
00135  * Remove a file.
00136  */
00137 int fxp_remove(char *fname);
00138 
00139 /*
00140  * Rename a file.
00141  */
00142 int fxp_rename(char *srcfname, char *dstfname);
00143 
00144 /*
00145  * Return file attributes.
00146  */
00147 int fxp_stat(char *fname, struct fxp_attrs *attrs);
00148 int fxp_fstat(struct fxp_handle *handle, struct fxp_attrs *attrs);
00149 
00150 /*
00151  * Set file attributes.
00152  */
00153 int fxp_setstat(char *fname, struct fxp_attrs attrs);
00154 int fxp_fsetstat(struct fxp_handle *handle, struct fxp_attrs attrs);
00155 
00156 /*
00157  * Read from a file.
00158  */
00159 int fxp_read(struct fxp_handle *handle, char *buffer, uint64 offset,
00160              int len);
00161 
00162 /*
00163  * Write to a file. Returns 0 on error, 1 on OK.
00164  */
00165 int fxp_write(struct fxp_handle *handle, char *buffer, uint64 offset,
00166               int len);
00167 
00168 /*
00169  * Read from a directory.
00170  */
00171 struct fxp_names *fxp_readdir(struct fxp_handle *handle);
00172 
00173 /*
00174  * Free up an fxp_names structure.
00175  */
00176 void fxp_free_names(struct fxp_names *names);
00177 
00178 /*
00179  * Duplicate and free fxp_name structures.
00180  */
00181 struct fxp_name *fxp_dup_name(struct fxp_name *name);
00182 void fxp_free_name(struct fxp_name *name);

Generated on Sun Feb 9 13:01:29 2003 for PuTTY by doxygen1.2.18