1 /* $OpenBSD: sftp-client.h,v 1.18 2009/08/18 18:36:20 djm Exp $ */
4 * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
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.
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.
19 /* Client side of SSH2 filexfer protocol */
21 #ifndef _SFTP_CLIENT_H
22 #define _SFTP_CLIENT_H
24 typedef struct SFTP_DIRENT SFTP_DIRENT
;
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.
51 * Initialise a SSH filexfer connection. Returns NULL on error or
52 * a pointer to a initialized sftp_conn struct on success.
54 struct sftp_conn
*do_init(int, int, u_int
, u_int
);
56 u_int
sftp_proto_version(struct sftp_conn
*);
58 /* Close file referred to by 'handle' */
59 int do_close(struct sftp_conn
*, char *, u_int
);
61 /* Read contents of 'path' to NULL-terminated array 'dir' */
62 int do_readdir(struct sftp_conn
*, char *, SFTP_DIRENT
***);
64 /* Frees a NULL-terminated array of SFTP_DIRENTs (eg. from do_readdir) */
65 void free_sftp_dirents(SFTP_DIRENT
**);
67 /* Delete file 'path' */
68 int do_rm(struct sftp_conn
*, char *);
70 /* Create directory 'path' */
71 int do_mkdir(struct sftp_conn
*, char *, Attrib
*, int);
73 /* Remove directory 'path' */
74 int do_rmdir(struct sftp_conn
*, char *);
76 /* Get file attributes of 'path' (follows symlinks) */
77 Attrib
*do_stat(struct sftp_conn
*, char *, int);
79 /* Get file attributes of 'path' (does not follow symlinks) */
80 Attrib
*do_lstat(struct sftp_conn
*, char *, int);
82 /* Set file attributes of 'path' */
83 int do_setstat(struct sftp_conn
*, char *, Attrib
*);
85 /* Set file attributes of open file 'handle' */
86 int do_fsetstat(struct sftp_conn
*, char *, u_int
, Attrib
*);
88 /* Canonicalise 'path' - caller must free result */
89 char *do_realpath(struct sftp_conn
*, char *);
91 /* Get statistics for filesystem hosting file at "path" */
92 int do_statvfs(struct sftp_conn
*, const char *, struct sftp_statvfs
*, int);
94 /* Rename 'oldpath' to 'newpath' */
95 int do_rename(struct sftp_conn
*, char *, char *);
97 /* Rename 'oldpath' to 'newpath' */
98 int do_symlink(struct sftp_conn
*, char *, char *);
100 /* XXX: add callbacks to do_download/do_upload so we can do progress meter */
103 * Download 'remote_path' to 'local_path'. Preserve permissions and times
106 int do_download(struct sftp_conn
*, char *, char *, Attrib
*, int);
109 * Recursively download 'remote_directory' to 'local_directory'. Preserve
110 * times if 'pflag' is set
112 int download_dir(struct sftp_conn
*, char *, char *, Attrib
*, int, int);
115 * Upload 'local_path' to 'remote_path'. Preserve permissions and times
118 int do_upload(struct sftp_conn
*, char *, char *, int);
121 * Recursively upload 'local_directory' to 'remote_directory'. Preserve
122 * times if 'pflag' is set
124 int upload_dir(struct sftp_conn
*, char *, char *, int, int);
126 /* Concatenate paths, taking care of slashes. Caller must free result. */
127 char *path_append(char *, char *);