blob: a322b2571088be602b9262b2b1029b58c01d75bd [file] [log] [blame]
Ben Lindstromb4c774c2001-07-04 04:07:12 +00001/* $OpenBSD: sftp-client.h,v 1.6 2001/06/26 06:33:01 itojun 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 */
Ben Lindstromb4c774c2001-07-04 04:07:12 +000041int do_init(int, int);
Damien Miller33804262001-02-04 23:20:18 +110042
43/* Close file referred to by 'handle' */
Ben Lindstromb4c774c2001-07-04 04:07:12 +000044int do_close(int, int, char *, u_int);
Damien Miller33804262001-02-04 23:20:18 +110045
46/* List contents of directory 'path' to stdout */
Ben Lindstromb4c774c2001-07-04 04:07:12 +000047int do_ls(int, int, char *);
Damien Miller33804262001-02-04 23:20:18 +110048
Damien Miller4870afd2001-03-14 10:27:09 +110049/* Read contents of 'path' to NULL-terminated array 'dir' */
Ben Lindstromb4c774c2001-07-04 04:07:12 +000050int do_readdir(int, int, char *, SFTP_DIRENT ***);
Damien Miller4870afd2001-03-14 10:27:09 +110051
52/* Frees a NULL-terminated array of SFTP_DIRENTs (eg. from do_readdir) */
Ben Lindstromb4c774c2001-07-04 04:07:12 +000053void free_sftp_dirents(SFTP_DIRENT **);
Damien Miller4870afd2001-03-14 10:27:09 +110054
Damien Miller33804262001-02-04 23:20:18 +110055/* Delete file 'path' */
Ben Lindstromb4c774c2001-07-04 04:07:12 +000056int do_rm(int, int, char *);
Damien Miller33804262001-02-04 23:20:18 +110057
58/* Create directory 'path' */
Ben Lindstromb4c774c2001-07-04 04:07:12 +000059int do_mkdir(int, int, char *, Attrib *);
Damien Miller33804262001-02-04 23:20:18 +110060
61/* Remove directory 'path' */
Ben Lindstromb4c774c2001-07-04 04:07:12 +000062int do_rmdir(int, int, char *);
Damien Miller33804262001-02-04 23:20:18 +110063
64/* Get file attributes of 'path' (follows symlinks) */
Ben Lindstromb4c774c2001-07-04 04:07:12 +000065Attrib *do_stat(int, int, char *, int);
Damien Miller33804262001-02-04 23:20:18 +110066
67/* Get file attributes of 'path' (does not follow symlinks) */
Ben Lindstromb4c774c2001-07-04 04:07:12 +000068Attrib *do_lstat(int, int, char *, int);
Damien Miller33804262001-02-04 23:20:18 +110069
70/* Get file attributes of open file 'handle' */
Ben Lindstromb4c774c2001-07-04 04:07:12 +000071Attrib *do_fstat(int, int, char *, u_int, int);
Damien Miller33804262001-02-04 23:20:18 +110072
73/* Set file attributes of 'path' */
Ben Lindstromb4c774c2001-07-04 04:07:12 +000074int do_setstat(int, int, char *, Attrib *);
Damien Miller33804262001-02-04 23:20:18 +110075
76/* Set file attributes of open file 'handle' */
Ben Lindstromb4c774c2001-07-04 04:07:12 +000077int do_fsetstat(int, int, char *, u_int, Attrib *);
Damien Miller33804262001-02-04 23:20:18 +110078
79/* Canonicalise 'path' - caller must free result */
Ben Lindstromb4c774c2001-07-04 04:07:12 +000080char *do_realpath(int, int, char *);
Damien Miller33804262001-02-04 23:20:18 +110081
82/* Rename 'oldpath' to 'newpath' */
Ben Lindstromb4c774c2001-07-04 04:07:12 +000083int do_rename(int, int, char *, char *);
Damien Miller33804262001-02-04 23:20:18 +110084
Damien Miller058316f2001-03-08 10:08:49 +110085/* Rename 'oldpath' to 'newpath' */
Ben Lindstromb4c774c2001-07-04 04:07:12 +000086int do_symlink(int, int, char *, char *);
Damien Miller058316f2001-03-08 10:08:49 +110087
88/* Return target of symlink 'path' - caller must free result */
Ben Lindstromb4c774c2001-07-04 04:07:12 +000089char *do_readlink(int, int, char *);
Damien Miller058316f2001-03-08 10:08:49 +110090
Damien Miller33804262001-02-04 23:20:18 +110091/* XXX: add callbacks to do_download/do_upload so we can do progress meter */
92
93/*
94 * Download 'remote_path' to 'local_path'. Preserve permissions and times
95 * if 'pflag' is set
96 */
Ben Lindstromb4c774c2001-07-04 04:07:12 +000097int do_download(int, int, char *, char *, int);
Damien Miller33804262001-02-04 23:20:18 +110098
99/*
100 * Upload 'local_path' to 'remote_path'. Preserve permissions and times
101 * if 'pflag' is set
102 */
Ben Lindstromb4c774c2001-07-04 04:07:12 +0000103int do_upload(int, int, char *, char *, int);