blob: 09ffcc05cb37bd0ec813d96e2b3c148b8530647e [file] [log] [blame]
Ben Lindstroma3700052001-04-05 23:26:32 +00001/* $OpenBSD: sftp-client.h,v 1.5 2001/04/05 10:42:52 markus Exp $ */
Damien Miller33804262001-02-04 23:20:18 +11002
3/*
4 * Copyright (c) 2001 Damien Miller. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27/* Client side of SSH2 filexfer protocol */
28
Damien Miller4870afd2001-03-14 10:27:09 +110029typedef struct SFTP_DIRENT SFTP_DIRENT;
30
31struct SFTP_DIRENT {
32 char *filename;
33 char *longname;
34 Attrib a;
35};
36
Ben Lindstroma3700052001-04-05 23:26:32 +000037/*
38 * Initialiase a SSH filexfer connection. Returns -1 on error or
Damien Miller058316f2001-03-08 10:08:49 +110039 * protocol version on success.
40 */
Damien Miller33804262001-02-04 23:20:18 +110041int do_init(int fd_in, int fd_out);
42
43/* Close file referred to by 'handle' */
44int do_close(int fd_in, int fd_out, char *handle, u_int handle_len);
45
46/* List contents of directory 'path' to stdout */
47int do_ls(int fd_in, int fd_out, char *path);
48
Damien Miller4870afd2001-03-14 10:27:09 +110049/* Read contents of 'path' to NULL-terminated array 'dir' */
50int do_readdir(int fd_in, int fd_out, char *path, SFTP_DIRENT ***dir);
51
52/* Frees a NULL-terminated array of SFTP_DIRENTs (eg. from do_readdir) */
53void free_sftp_dirents(SFTP_DIRENT **s);
54
Damien Miller33804262001-02-04 23:20:18 +110055/* Delete file 'path' */
56int do_rm(int fd_in, int fd_out, char *path);
57
58/* Create directory 'path' */
59int do_mkdir(int fd_in, int fd_out, char *path, Attrib *a);
60
61/* Remove directory 'path' */
62int do_rmdir(int fd_in, int fd_out, char *path);
63
64/* Get file attributes of 'path' (follows symlinks) */
Ben Lindstromc8d1c302001-03-17 00:34:46 +000065Attrib *do_stat(int fd_in, int fd_out, char *path, int quiet);
Damien Miller33804262001-02-04 23:20:18 +110066
67/* Get file attributes of 'path' (does not follow symlinks) */
Ben Lindstromc8d1c302001-03-17 00:34:46 +000068Attrib *do_lstat(int fd_in, int fd_out, char *path, int quiet);
Damien Miller33804262001-02-04 23:20:18 +110069
70/* Get file attributes of open file 'handle' */
Ben Lindstroma3700052001-04-05 23:26:32 +000071Attrib *do_fstat(int fd_in, int fd_out, char *handle, u_int handle_len,
Ben Lindstromc8d1c302001-03-17 00:34:46 +000072 int quiet);
Damien Miller33804262001-02-04 23:20:18 +110073
74/* Set file attributes of 'path' */
75int do_setstat(int fd_in, int fd_out, char *path, Attrib *a);
76
77/* Set file attributes of open file 'handle' */
78int do_fsetstat(int fd_in, int fd_out, char *handle,
79 u_int handle_len, Attrib *a);
80
81/* Canonicalise 'path' - caller must free result */
82char *do_realpath(int fd_in, int fd_out, char *path);
83
84/* Rename 'oldpath' to 'newpath' */
85int do_rename(int fd_in, int fd_out, char *oldpath, char *newpath);
86
Damien Miller058316f2001-03-08 10:08:49 +110087/* Rename 'oldpath' to 'newpath' */
88int do_symlink(int fd_in, int fd_out, char *oldpath, char *newpath);
89
90/* Return target of symlink 'path' - caller must free result */
91char *do_readlink(int fd_in, int fd_out, char *path);
92
Damien Miller33804262001-02-04 23:20:18 +110093/* XXX: add callbacks to do_download/do_upload so we can do progress meter */
94
95/*
96 * Download 'remote_path' to 'local_path'. Preserve permissions and times
97 * if 'pflag' is set
98 */
99int do_download(int fd_in, int fd_out, char *remote_path, char *local_path,
100 int pflag);
101
102/*
103 * Upload 'local_path' to 'remote_path'. Preserve permissions and times
104 * if 'pflag' is set
105 */
106int do_upload(int fd_in, int fd_out, char *local_path, char *remote_path,
107 int pflag);