1*90685d2cSjp161948 /* 2*90685d2cSjp161948 * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> 3*90685d2cSjp161948 * 4*90685d2cSjp161948 * Permission to use, copy, modify, and distribute this software for any 5*90685d2cSjp161948 * purpose with or without fee is hereby granted, provided that the above 6*90685d2cSjp161948 * copyright notice and this permission notice appear in all copies. 7*90685d2cSjp161948 * 8*90685d2cSjp161948 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9*90685d2cSjp161948 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10*90685d2cSjp161948 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11*90685d2cSjp161948 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12*90685d2cSjp161948 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13*90685d2cSjp161948 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14*90685d2cSjp161948 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15*90685d2cSjp161948 */ 167c478bd9Sstevel@tonic-gate 177c478bd9Sstevel@tonic-gate #ifndef _SFTP_CLIENT_H 187c478bd9Sstevel@tonic-gate #define _SFTP_CLIENT_H 197c478bd9Sstevel@tonic-gate 20*90685d2cSjp161948 /* $OpenBSD: sftp-client.h,v 1.14 2005/04/26 12:59:02 jmc Exp $ */ 21*90685d2cSjp161948 227c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 237c478bd9Sstevel@tonic-gate 247c478bd9Sstevel@tonic-gate #ifdef __cplusplus 257c478bd9Sstevel@tonic-gate extern "C" { 267c478bd9Sstevel@tonic-gate #endif 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate /* Client side of SSH2 filexfer protocol */ 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate typedef struct SFTP_DIRENT SFTP_DIRENT; 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate struct SFTP_DIRENT { 337c478bd9Sstevel@tonic-gate char *filename; 347c478bd9Sstevel@tonic-gate char *longname; 357c478bd9Sstevel@tonic-gate Attrib a; 367c478bd9Sstevel@tonic-gate }; 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate /* 39*90685d2cSjp161948 * Initialise a SSH filexfer connection. Returns NULL on error or 40*90685d2cSjp161948 * a pointer to a initialized sftp_conn struct on success. 417c478bd9Sstevel@tonic-gate */ 427c478bd9Sstevel@tonic-gate struct sftp_conn *do_init(int, int, u_int, u_int); 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate u_int sftp_proto_version(struct sftp_conn *); 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate /* Close file referred to by 'handle' */ 477c478bd9Sstevel@tonic-gate int do_close(struct sftp_conn *, char *, u_int); 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate /* Read contents of 'path' to NULL-terminated array 'dir' */ 507c478bd9Sstevel@tonic-gate int do_readdir(struct sftp_conn *, char *, SFTP_DIRENT ***); 517c478bd9Sstevel@tonic-gate 527c478bd9Sstevel@tonic-gate /* Frees a NULL-terminated array of SFTP_DIRENTs (eg. from do_readdir) */ 537c478bd9Sstevel@tonic-gate void free_sftp_dirents(SFTP_DIRENT **); 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate /* Delete file 'path' */ 567c478bd9Sstevel@tonic-gate int do_rm(struct sftp_conn *, char *); 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate /* Create directory 'path' */ 597c478bd9Sstevel@tonic-gate int do_mkdir(struct sftp_conn *, char *, Attrib *); 607c478bd9Sstevel@tonic-gate 617c478bd9Sstevel@tonic-gate /* Remove directory 'path' */ 627c478bd9Sstevel@tonic-gate int do_rmdir(struct sftp_conn *, char *); 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate /* Get file attributes of 'path' (follows symlinks) */ 657c478bd9Sstevel@tonic-gate Attrib *do_stat(struct sftp_conn *, char *, int); 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate /* Get file attributes of 'path' (does not follow symlinks) */ 687c478bd9Sstevel@tonic-gate Attrib *do_lstat(struct sftp_conn *, char *, int); 697c478bd9Sstevel@tonic-gate 707c478bd9Sstevel@tonic-gate /* Get file attributes of open file 'handle' */ 717c478bd9Sstevel@tonic-gate Attrib *do_fstat(struct sftp_conn *, char *, u_int, int); 727c478bd9Sstevel@tonic-gate 737c478bd9Sstevel@tonic-gate /* Set file attributes of 'path' */ 747c478bd9Sstevel@tonic-gate int do_setstat(struct sftp_conn *, char *, Attrib *); 757c478bd9Sstevel@tonic-gate 767c478bd9Sstevel@tonic-gate /* Set file attributes of open file 'handle' */ 777c478bd9Sstevel@tonic-gate int do_fsetstat(struct sftp_conn *, char *, u_int, Attrib *); 787c478bd9Sstevel@tonic-gate 797c478bd9Sstevel@tonic-gate /* Canonicalise 'path' - caller must free result */ 807c478bd9Sstevel@tonic-gate char *do_realpath(struct sftp_conn *, char *); 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate /* Rename 'oldpath' to 'newpath' */ 837c478bd9Sstevel@tonic-gate int do_rename(struct sftp_conn *, char *, char *); 847c478bd9Sstevel@tonic-gate 857c478bd9Sstevel@tonic-gate /* Rename 'oldpath' to 'newpath' */ 867c478bd9Sstevel@tonic-gate int do_symlink(struct sftp_conn *, char *, char *); 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate /* Return target of symlink 'path' - caller must free result */ 897c478bd9Sstevel@tonic-gate char *do_readlink(struct sftp_conn *, char *); 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate /* XXX: add callbacks to do_download/do_upload so we can do progress meter */ 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate /* 947c478bd9Sstevel@tonic-gate * Download 'remote_path' to 'local_path'. Preserve permissions and times 957c478bd9Sstevel@tonic-gate * if 'pflag' is set 967c478bd9Sstevel@tonic-gate */ 977c478bd9Sstevel@tonic-gate int do_download(struct sftp_conn *, char *, char *, int); 987c478bd9Sstevel@tonic-gate 997c478bd9Sstevel@tonic-gate /* 1007c478bd9Sstevel@tonic-gate * Upload 'local_path' to 'remote_path'. Preserve permissions and times 1017c478bd9Sstevel@tonic-gate * if 'pflag' is set 1027c478bd9Sstevel@tonic-gate */ 1037c478bd9Sstevel@tonic-gate int do_upload(struct sftp_conn *, char *, char *, int); 1047c478bd9Sstevel@tonic-gate 1057c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1067c478bd9Sstevel@tonic-gate } 1077c478bd9Sstevel@tonic-gate #endif 1087c478bd9Sstevel@tonic-gate 1097c478bd9Sstevel@tonic-gate #endif /* _SFTP_CLIENT_H */ 110