[BACK]Return to sftp-client.h CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

Annotation of src/usr.bin/ssh/sftp-client.h, Revision 1.30

1.30    ! djm         1: /* $OpenBSD: sftp-client.h,v 1.29 2020/12/04 02:41:10 djm Exp $ */
1.1       djm         2:
                      3: /*
1.12      djm         4:  * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
1.1       djm         5:  *
1.12      djm         6:  * Permission to use, copy, modify, and distribute this software for any
                      7:  * purpose with or without fee is hereby granted, provided that the above
                      8:  * copyright notice and this permission notice appear in all copies.
1.1       djm         9:  *
1.12      djm        10:  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
                     11:  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
                     12:  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
                     13:  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
                     14:  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
                     15:  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
                     16:  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1.1       djm        17:  */
                     18:
                     19: /* Client side of SSH2 filexfer protocol */
                     20:
1.9       djm        21: #ifndef _SFTP_CLIENT_H
                     22: #define _SFTP_CLIENT_H
                     23:
1.3       djm        24: typedef struct SFTP_DIRENT SFTP_DIRENT;
                     25:
                     26: struct SFTP_DIRENT {
                     27:        char *filename;
                     28:        char *longname;
                     29:        Attrib a;
                     30: };
                     31:
1.5       markus     32: /*
1.17      dtucker    33:  * Used for statvfs responses on the wire from the server, because the
                     34:  * server's native format may be larger than the client's.
                     35:  */
                     36: struct sftp_statvfs {
                     37:        u_int64_t f_bsize;
                     38:        u_int64_t f_frsize;
                     39:        u_int64_t f_blocks;
                     40:        u_int64_t f_bfree;
                     41:        u_int64_t f_bavail;
                     42:        u_int64_t f_files;
                     43:        u_int64_t f_ffree;
                     44:        u_int64_t f_favail;
                     45:        u_int64_t f_fsid;
                     46:        u_int64_t f_flag;
                     47:        u_int64_t f_namemax;
                     48: };
                     49:
1.30    ! djm        50: /* Used for limits response on the wire from the server */
        !            51: struct sftp_limits {
        !            52:        u_int64_t packet_length;
        !            53:        u_int64_t read_length;
        !            54:        u_int64_t write_length;
        !            55:        u_int64_t open_handles;
        !            56: };
        !            57:
1.17      dtucker    58: /*
1.14      jmc        59:  * Initialise a SSH filexfer connection. Returns NULL on error or
1.13      djm        60:  * a pointer to a initialized sftp_conn struct on success.
1.2       djm        61:  */
1.19      djm        62: struct sftp_conn *do_init(int, int, u_int, u_int, u_int64_t);
1.9       djm        63:
1.10      deraadt    64: u_int sftp_proto_version(struct sftp_conn *);
1.30    ! djm        65:
        !            66: /* Query server limits */
        !            67: int do_limits(struct sftp_conn *, struct sftp_limits *);
1.1       djm        68:
                     69: /* Close file referred to by 'handle' */
1.26      djm        70: int do_close(struct sftp_conn *, const u_char *, u_int);
1.3       djm        71:
                     72: /* Read contents of 'path' to NULL-terminated array 'dir' */
1.26      djm        73: int do_readdir(struct sftp_conn *, const char *, SFTP_DIRENT ***);
1.3       djm        74:
                     75: /* Frees a NULL-terminated array of SFTP_DIRENTs (eg. from do_readdir) */
1.6       itojun     76: void free_sftp_dirents(SFTP_DIRENT **);
1.1       djm        77:
                     78: /* Delete file 'path' */
1.26      djm        79: int do_rm(struct sftp_conn *, const char *);
1.1       djm        80:
                     81: /* Create directory 'path' */
1.26      djm        82: int do_mkdir(struct sftp_conn *, const char *, Attrib *, int);
1.1       djm        83:
                     84: /* Remove directory 'path' */
1.26      djm        85: int do_rmdir(struct sftp_conn *, const char *);
1.1       djm        86:
                     87: /* Get file attributes of 'path' (follows symlinks) */
1.26      djm        88: Attrib *do_stat(struct sftp_conn *, const char *, int);
1.1       djm        89:
                     90: /* Get file attributes of 'path' (does not follow symlinks) */
1.26      djm        91: Attrib *do_lstat(struct sftp_conn *, const char *, int);
1.1       djm        92:
                     93: /* Set file attributes of 'path' */
1.26      djm        94: int do_setstat(struct sftp_conn *, const char *, Attrib *);
1.1       djm        95:
                     96: /* Set file attributes of open file 'handle' */
1.26      djm        97: int do_fsetstat(struct sftp_conn *, const u_char *, u_int, Attrib *);
1.28      djm        98:
                     99: /* Set file attributes of 'path', not following symlinks */
                    100: int do_lsetstat(struct sftp_conn *conn, const char *path, Attrib *a);
1.1       djm       101:
                    102: /* Canonicalise 'path' - caller must free result */
1.26      djm       103: char *do_realpath(struct sftp_conn *, const char *);
1.16      djm       104:
                    105: /* Get statistics for filesystem hosting file at "path" */
1.17      dtucker   106: int do_statvfs(struct sftp_conn *, const char *, struct sftp_statvfs *, int);
1.1       djm       107:
                    108: /* Rename 'oldpath' to 'newpath' */
1.26      djm       109: int do_rename(struct sftp_conn *, const char *, const char *, int force_legacy);
1.20      djm       110:
                    111: /* Link 'oldpath' to 'newpath' */
1.26      djm       112: int do_hardlink(struct sftp_conn *, const char *, const char *);
1.2       djm       113:
                    114: /* Rename 'oldpath' to 'newpath' */
1.26      djm       115: int do_symlink(struct sftp_conn *, const char *, const char *);
1.1       djm       116:
1.24      djm       117: /* Call fsync() on open file 'handle' */
1.26      djm       118: int do_fsync(struct sftp_conn *conn, u_char *, u_int);
1.24      djm       119:
1.1       djm       120: /*
                    121:  * Download 'remote_path' to 'local_path'. Preserve permissions and times
                    122:  * if 'pflag' is set
                    123:  */
1.26      djm       124: int do_download(struct sftp_conn *, const char *, const char *,
                    125:     Attrib *, int, int, int);
1.18      djm       126:
                    127: /*
1.27      djm       128:  * Recursively download 'remote_directory' to 'local_directory'. Preserve
1.18      djm       129:  * times if 'pflag' is set
                    130:  */
1.26      djm       131: int download_dir(struct sftp_conn *, const char *, const char *,
                    132:     Attrib *, int, int, int, int);
1.1       djm       133:
                    134: /*
                    135:  * Upload 'local_path' to 'remote_path'. Preserve permissions and times
                    136:  * if 'pflag' is set
                    137:  */
1.26      djm       138: int do_upload(struct sftp_conn *, const char *, const char *, int, int, int);
1.18      djm       139:
                    140: /*
1.27      djm       141:  * Recursively upload 'local_directory' to 'remote_directory'. Preserve
1.18      djm       142:  * times if 'pflag' is set
                    143:  */
1.26      djm       144: int upload_dir(struct sftp_conn *, const char *, const char *, int, int, int,
                    145:     int);
1.18      djm       146:
                    147: /* Concatenate paths, taking care of slashes. Caller must free result. */
1.26      djm       148: char *path_append(const char *, const char *);
1.29      djm       149:
                    150: /* Make absolute path if relative path and CWD is given. Does not modify
                    151:  * original if the the path is already absolute. */
                    152: char *make_absolute(char *, const char *);
                    153:
                    154: /* Check if remote path is directory */
                    155: int remote_is_dir(struct sftp_conn *conn, const char *path);
                    156:
                    157: /* Check if local path is directory */
                    158: int local_is_dir(const char *path);
                    159:
                    160: /* Check whether path returned from glob(..., GLOB_MARK, ...) is a directory */
                    161: int globpath_is_dir(const char *pathname);
1.9       djm       162:
                    163: #endif