2 /* $OpenBSD: sftp-client.h,v 1.17 2008/06/08 20:15:29 dtucker Exp $ */
5 * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 /* Client side of SSH2 filexfer protocol */
22 #ifndef _SFTP_CLIENT_H
23 #define _SFTP_CLIENT_H
25 typedef struct SFTP_DIRENT SFTP_DIRENT
;
34 * Used for statvfs responses on the wire from the server, because the
35 * server's native format may be larger than the client's.
52 * Initialise a SSH filexfer connection. Returns NULL on error or
53 * a pointer to a initialized sftp_conn struct on success.
55 struct sftp_conn
*do_init(int, int, u_int
, u_int
);
57 u_int
sftp_proto_version(struct sftp_conn
*);
59 /* Close file referred to by 'handle' */
60 int do_close(struct sftp_conn
*, char *, u_int
);
62 /* Read contents of 'path' to NULL-terminated array 'dir' */
63 int do_readdir(struct sftp_conn
*, char *, SFTP_DIRENT
***);
65 /* Frees a NULL-terminated array of SFTP_DIRENTs (eg. from do_readdir) */
66 void free_sftp_dirents(SFTP_DIRENT
**);
68 /* Delete file 'path' */
69 int do_rm(struct sftp_conn
*, char *);
71 /* Create directory 'path' */
72 int do_mkdir(struct sftp_conn
*, char *, Attrib
*);
74 /* Remove directory 'path' */
75 int do_rmdir(struct sftp_conn
*, char *);
77 /* Get file attributes of 'path' (follows symlinks) */
78 Attrib
*do_stat(struct sftp_conn
*, char *, int);
80 /* Get file attributes of 'path' (does not follow symlinks) */
81 Attrib
*do_lstat(struct sftp_conn
*, char *, int);
83 /* Set file attributes of 'path' */
84 int do_setstat(struct sftp_conn
*, char *, Attrib
*);
86 /* Set file attributes of open file 'handle' */
87 int do_fsetstat(struct sftp_conn
*, char *, u_int
, Attrib
*);
89 /* Canonicalise 'path' - caller must free result */
90 char *do_realpath(struct sftp_conn
*, char *);
92 /* Get statistics for filesystem hosting file at "path" */
93 int do_statvfs(struct sftp_conn
*, const char *, struct sftp_statvfs
*, int);
95 /* Rename 'oldpath' to 'newpath' */
96 int do_rename(struct sftp_conn
*, char *, char *);
98 /* Rename 'oldpath' to 'newpath' */
99 int do_symlink(struct sftp_conn
*, char *, char *);
101 /* XXX: add callbacks to do_download/do_upload so we can do progress meter */
104 * Download 'remote_path' to 'local_path'. Preserve permissions and times
107 int do_download(struct sftp_conn
*, char *, char *, int);
110 * Upload 'local_path' to 'remote_path'. Preserve permissions and times
113 int do_upload(struct sftp_conn
*, char *, char *, int);