1*5087Sjp161948 /* 2*5087Sjp161948 * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> 3*5087Sjp161948 * 4*5087Sjp161948 * Permission to use, copy, modify, and distribute this software for any 5*5087Sjp161948 * purpose with or without fee is hereby granted, provided that the above 6*5087Sjp161948 * copyright notice and this permission notice appear in all copies. 7*5087Sjp161948 * 8*5087Sjp161948 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9*5087Sjp161948 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10*5087Sjp161948 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11*5087Sjp161948 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12*5087Sjp161948 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13*5087Sjp161948 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14*5087Sjp161948 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15*5087Sjp161948 */ 160Sstevel@tonic-gate 17*5087Sjp161948 #ifndef _SFTP_CLIENT_H 18*5087Sjp161948 #define _SFTP_CLIENT_H 19*5087Sjp161948 20*5087Sjp161948 /* $OpenBSD: sftp-client.h,v 1.14 2005/04/26 12:59:02 jmc Exp $ */ 210Sstevel@tonic-gate 220Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 230Sstevel@tonic-gate 240Sstevel@tonic-gate #ifdef __cplusplus 250Sstevel@tonic-gate extern "C" { 260Sstevel@tonic-gate #endif 270Sstevel@tonic-gate 280Sstevel@tonic-gate /* Client side of SSH2 filexfer protocol */ 290Sstevel@tonic-gate 300Sstevel@tonic-gate typedef struct SFTP_DIRENT SFTP_DIRENT; 310Sstevel@tonic-gate 320Sstevel@tonic-gate struct SFTP_DIRENT { 330Sstevel@tonic-gate char *filename; 340Sstevel@tonic-gate char *longname; 350Sstevel@tonic-gate Attrib a; 360Sstevel@tonic-gate }; 370Sstevel@tonic-gate 380Sstevel@tonic-gate /* 39*5087Sjp161948 * Initialise a SSH filexfer connection. Returns NULL on error or 40*5087Sjp161948 * a pointer to a initialized sftp_conn struct on success. 410Sstevel@tonic-gate */ 420Sstevel@tonic-gate struct sftp_conn *do_init(int, int, u_int, u_int); 430Sstevel@tonic-gate 440Sstevel@tonic-gate u_int sftp_proto_version(struct sftp_conn *); 450Sstevel@tonic-gate 460Sstevel@tonic-gate /* Close file referred to by 'handle' */ 470Sstevel@tonic-gate int do_close(struct sftp_conn *, char *, u_int); 480Sstevel@tonic-gate 490Sstevel@tonic-gate /* Read contents of 'path' to NULL-terminated array 'dir' */ 500Sstevel@tonic-gate int do_readdir(struct sftp_conn *, char *, SFTP_DIRENT ***); 510Sstevel@tonic-gate 520Sstevel@tonic-gate /* Frees a NULL-terminated array of SFTP_DIRENTs (eg. from do_readdir) */ 530Sstevel@tonic-gate void free_sftp_dirents(SFTP_DIRENT **); 540Sstevel@tonic-gate 550Sstevel@tonic-gate /* Delete file 'path' */ 560Sstevel@tonic-gate int do_rm(struct sftp_conn *, char *); 570Sstevel@tonic-gate 580Sstevel@tonic-gate /* Create directory 'path' */ 590Sstevel@tonic-gate int do_mkdir(struct sftp_conn *, char *, Attrib *); 600Sstevel@tonic-gate 610Sstevel@tonic-gate /* Remove directory 'path' */ 620Sstevel@tonic-gate int do_rmdir(struct sftp_conn *, char *); 630Sstevel@tonic-gate 640Sstevel@tonic-gate /* Get file attributes of 'path' (follows symlinks) */ 650Sstevel@tonic-gate Attrib *do_stat(struct sftp_conn *, char *, int); 660Sstevel@tonic-gate 670Sstevel@tonic-gate /* Get file attributes of 'path' (does not follow symlinks) */ 680Sstevel@tonic-gate Attrib *do_lstat(struct sftp_conn *, char *, int); 690Sstevel@tonic-gate 700Sstevel@tonic-gate /* Get file attributes of open file 'handle' */ 710Sstevel@tonic-gate Attrib *do_fstat(struct sftp_conn *, char *, u_int, int); 720Sstevel@tonic-gate 730Sstevel@tonic-gate /* Set file attributes of 'path' */ 740Sstevel@tonic-gate int do_setstat(struct sftp_conn *, char *, Attrib *); 750Sstevel@tonic-gate 760Sstevel@tonic-gate /* Set file attributes of open file 'handle' */ 770Sstevel@tonic-gate int do_fsetstat(struct sftp_conn *, char *, u_int, Attrib *); 780Sstevel@tonic-gate 790Sstevel@tonic-gate /* Canonicalise 'path' - caller must free result */ 800Sstevel@tonic-gate char *do_realpath(struct sftp_conn *, char *); 810Sstevel@tonic-gate 820Sstevel@tonic-gate /* Rename 'oldpath' to 'newpath' */ 830Sstevel@tonic-gate int do_rename(struct sftp_conn *, char *, char *); 840Sstevel@tonic-gate 850Sstevel@tonic-gate /* Rename 'oldpath' to 'newpath' */ 860Sstevel@tonic-gate int do_symlink(struct sftp_conn *, char *, char *); 870Sstevel@tonic-gate 880Sstevel@tonic-gate /* Return target of symlink 'path' - caller must free result */ 890Sstevel@tonic-gate char *do_readlink(struct sftp_conn *, char *); 900Sstevel@tonic-gate 910Sstevel@tonic-gate /* XXX: add callbacks to do_download/do_upload so we can do progress meter */ 920Sstevel@tonic-gate 930Sstevel@tonic-gate /* 940Sstevel@tonic-gate * Download 'remote_path' to 'local_path'. Preserve permissions and times 950Sstevel@tonic-gate * if 'pflag' is set 960Sstevel@tonic-gate */ 970Sstevel@tonic-gate int do_download(struct sftp_conn *, char *, char *, int); 980Sstevel@tonic-gate 990Sstevel@tonic-gate /* 1000Sstevel@tonic-gate * Upload 'local_path' to 'remote_path'. Preserve permissions and times 1010Sstevel@tonic-gate * if 'pflag' is set 1020Sstevel@tonic-gate */ 1030Sstevel@tonic-gate int do_upload(struct sftp_conn *, char *, char *, int); 1040Sstevel@tonic-gate 1050Sstevel@tonic-gate #ifdef __cplusplus 1060Sstevel@tonic-gate } 1070Sstevel@tonic-gate #endif 1080Sstevel@tonic-gate 1090Sstevel@tonic-gate #endif /* _SFTP_CLIENT_H */ 110