1/* 2 * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> 3 * 4 * Permission to use, copy, modify, and distribute this software for any 5 * purpose with or without fee is hereby granted, provided that the above 6 * copyright notice and this permission notice appear in all copies. 7 * 8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 */ 16 17#ifndef _SFTP_CLIENT_H 18#define _SFTP_CLIENT_H 19 20/* $OpenBSD: sftp-client.h,v 1.14 2005/04/26 12:59:02 jmc Exp $ */ 21 22#pragma ident "%Z%%M% %I% %E% SMI" 23 24#ifdef __cplusplus 25extern "C" { 26#endif 27 28/* Client side of SSH2 filexfer protocol */ 29 30typedef struct SFTP_DIRENT SFTP_DIRENT; 31 32struct SFTP_DIRENT { 33 char *filename; 34 char *longname; 35 Attrib a; 36}; 37 38/* 39 * Initialise a SSH filexfer connection. Returns NULL on error or 40 * a pointer to a initialized sftp_conn struct on success. 41 */ 42struct sftp_conn *do_init(int, int, u_int, u_int); 43 44u_int sftp_proto_version(struct sftp_conn *); 45 46/* Close file referred to by 'handle' */ 47int do_close(struct sftp_conn *, char *, u_int); 48 49/* Read contents of 'path' to NULL-terminated array 'dir' */ 50int do_readdir(struct sftp_conn *, char *, SFTP_DIRENT ***); 51 52/* Frees a NULL-terminated array of SFTP_DIRENTs (eg. from do_readdir) */ 53void free_sftp_dirents(SFTP_DIRENT **); 54 55/* Delete file 'path' */ 56int do_rm(struct sftp_conn *, char *); 57 58/* Create directory 'path' */ 59int do_mkdir(struct sftp_conn *, char *, Attrib *); 60 61/* Remove directory 'path' */ 62int do_rmdir(struct sftp_conn *, char *); 63 64/* Get file attributes of 'path' (follows symlinks) */ 65Attrib *do_stat(struct sftp_conn *, char *, int); 66 67/* Get file attributes of 'path' (does not follow symlinks) */ 68Attrib *do_lstat(struct sftp_conn *, char *, int); 69 70/* Get file attributes of open file 'handle' */ 71Attrib *do_fstat(struct sftp_conn *, char *, u_int, int); 72 73/* Set file attributes of 'path' */ 74int do_setstat(struct sftp_conn *, char *, Attrib *); 75 76/* Set file attributes of open file 'handle' */ 77int do_fsetstat(struct sftp_conn *, char *, u_int, Attrib *); 78 79/* Canonicalise 'path' - caller must free result */ 80char *do_realpath(struct sftp_conn *, char *); 81 82/* Rename 'oldpath' to 'newpath' */ 83int do_rename(struct sftp_conn *, char *, char *); 84 85/* Rename 'oldpath' to 'newpath' */ 86int do_symlink(struct sftp_conn *, char *, char *); 87 88/* Return target of symlink 'path' - caller must free result */ 89char *do_readlink(struct sftp_conn *, char *); 90 91/* 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 */ 97int do_download(struct sftp_conn *, char *, char *, int); 98 99/* 100 * Upload 'local_path' to 'remote_path'. Preserve permissions and times 101 * if 'pflag' is set 102 */ 103int do_upload(struct sftp_conn *, char *, char *, int); 104 105#ifdef __cplusplus 106} 107#endif 108 109#endif /* _SFTP_CLIENT_H */ 110