blob: c8a41f3773c9c9b54a2eeebf00b6e08a93bcf0ed [file] [log] [blame]
Damien Millerac7a0052005-05-26 12:05:49 +10001/* $OpenBSD: sftp-client.h,v 1.14 2005/04/26 12:59:02 jmc Exp $ */
Damien Miller33804262001-02-04 23:20:18 +11002
3/*
Damien Miller4e60ed72004-02-17 17:07:59 +11004 * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
Damien Miller33804262001-02-04 23:20:18 +11005 *
Damien Miller4e60ed72004-02-17 17:07:59 +11006 * 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.
Damien Miller33804262001-02-04 23:20:18 +11009 *
Damien Miller4e60ed72004-02-17 17:07:59 +110010 * 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.
Damien Miller33804262001-02-04 23:20:18 +110017 */
18
19/* Client side of SSH2 filexfer protocol */
20
Damien Miller3db5f532002-02-13 14:10:32 +110021#ifndef _SFTP_CLIENT_H
22#define _SFTP_CLIENT_H
23
Damien Miller4870afd2001-03-14 10:27:09 +110024typedef struct SFTP_DIRENT SFTP_DIRENT;
25
26struct SFTP_DIRENT {
27 char *filename;
28 char *longname;
29 Attrib a;
30};
31
Ben Lindstroma3700052001-04-05 23:26:32 +000032/*
Damien Millerac7a0052005-05-26 12:05:49 +100033 * Initialise a SSH filexfer connection. Returns NULL on error or
Darren Tuckere2f189a2004-12-06 22:45:53 +110034 * a pointer to a initialized sftp_conn struct on success.
Damien Miller058316f2001-03-08 10:08:49 +110035 */
Ben Lindstromb1f483f2002-06-23 21:27:18 +000036struct sftp_conn *do_init(int, int, u_int, u_int);
Damien Miller3db5f532002-02-13 14:10:32 +110037
Ben Lindstromb1f483f2002-06-23 21:27:18 +000038u_int sftp_proto_version(struct sftp_conn *);
Damien Miller33804262001-02-04 23:20:18 +110039
40/* Close file referred to by 'handle' */
Damien Miller3db5f532002-02-13 14:10:32 +110041int do_close(struct sftp_conn *, char *, u_int);
Damien Miller33804262001-02-04 23:20:18 +110042
Damien Miller4870afd2001-03-14 10:27:09 +110043/* Read contents of 'path' to NULL-terminated array 'dir' */
Damien Miller3db5f532002-02-13 14:10:32 +110044int do_readdir(struct sftp_conn *, char *, SFTP_DIRENT ***);
Damien Miller4870afd2001-03-14 10:27:09 +110045
46/* Frees a NULL-terminated array of SFTP_DIRENTs (eg. from do_readdir) */
Ben Lindstromb4c774c2001-07-04 04:07:12 +000047void free_sftp_dirents(SFTP_DIRENT **);
Damien Miller4870afd2001-03-14 10:27:09 +110048
Damien Miller33804262001-02-04 23:20:18 +110049/* Delete file 'path' */
Damien Miller3db5f532002-02-13 14:10:32 +110050int do_rm(struct sftp_conn *, char *);
Damien Miller33804262001-02-04 23:20:18 +110051
52/* Create directory 'path' */
Damien Miller3db5f532002-02-13 14:10:32 +110053int do_mkdir(struct sftp_conn *, char *, Attrib *);
Damien Miller33804262001-02-04 23:20:18 +110054
55/* Remove directory 'path' */
Damien Miller3db5f532002-02-13 14:10:32 +110056int do_rmdir(struct sftp_conn *, char *);
Damien Miller33804262001-02-04 23:20:18 +110057
58/* Get file attributes of 'path' (follows symlinks) */
Damien Miller3db5f532002-02-13 14:10:32 +110059Attrib *do_stat(struct sftp_conn *, char *, int);
Damien Miller33804262001-02-04 23:20:18 +110060
61/* Get file attributes of 'path' (does not follow symlinks) */
Damien Miller3db5f532002-02-13 14:10:32 +110062Attrib *do_lstat(struct sftp_conn *, char *, int);
Damien Miller33804262001-02-04 23:20:18 +110063
64/* Get file attributes of open file 'handle' */
Damien Miller3db5f532002-02-13 14:10:32 +110065Attrib *do_fstat(struct sftp_conn *, char *, u_int, int);
Damien Miller33804262001-02-04 23:20:18 +110066
67/* Set file attributes of 'path' */
Damien Miller3db5f532002-02-13 14:10:32 +110068int do_setstat(struct sftp_conn *, char *, Attrib *);
Damien Miller33804262001-02-04 23:20:18 +110069
70/* Set file attributes of open file 'handle' */
Damien Miller3db5f532002-02-13 14:10:32 +110071int do_fsetstat(struct sftp_conn *, char *, u_int, Attrib *);
Damien Miller33804262001-02-04 23:20:18 +110072
73/* Canonicalise 'path' - caller must free result */
Damien Miller3db5f532002-02-13 14:10:32 +110074char *do_realpath(struct sftp_conn *, char *);
Damien Miller33804262001-02-04 23:20:18 +110075
76/* Rename 'oldpath' to 'newpath' */
Damien Miller3db5f532002-02-13 14:10:32 +110077int do_rename(struct sftp_conn *, char *, char *);
Damien Miller33804262001-02-04 23:20:18 +110078
Damien Miller058316f2001-03-08 10:08:49 +110079/* Rename 'oldpath' to 'newpath' */
Damien Miller3db5f532002-02-13 14:10:32 +110080int do_symlink(struct sftp_conn *, char *, char *);
Damien Miller058316f2001-03-08 10:08:49 +110081
82/* Return target of symlink 'path' - caller must free result */
Damien Miller3db5f532002-02-13 14:10:32 +110083char *do_readlink(struct sftp_conn *, char *);
Damien Miller058316f2001-03-08 10:08:49 +110084
Damien Miller33804262001-02-04 23:20:18 +110085/* XXX: add callbacks to do_download/do_upload so we can do progress meter */
86
87/*
88 * Download 'remote_path' to 'local_path'. Preserve permissions and times
89 * if 'pflag' is set
90 */
Damien Miller3db5f532002-02-13 14:10:32 +110091int do_download(struct sftp_conn *, char *, char *, int);
Damien Miller33804262001-02-04 23:20:18 +110092
93/*
94 * Upload 'local_path' to 'remote_path'. Preserve permissions and times
95 * if 'pflag' is set
96 */
Damien Miller3db5f532002-02-13 14:10:32 +110097int do_upload(struct sftp_conn *, char *, char *, int);
98
99#endif