]>
Commit | Line | Data |
---|---|---|
416fd2a8 | 1 | /* $OpenBSD: sftp-client.h,v 1.12 2004/02/17 05:39:51 djm Exp $ */ |
3c0ef626 | 2 | |
3 | /* | |
416fd2a8 | 4 | * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> |
3c0ef626 | 5 | * |
416fd2a8 | 6 | * 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. | |
3c0ef626 | 9 | * |
416fd2a8 | 10 | * 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. | |
3c0ef626 | 17 | */ |
18 | ||
19 | /* Client side of SSH2 filexfer protocol */ | |
20 | ||
e9a17296 | 21 | #ifndef _SFTP_CLIENT_H |
22 | #define _SFTP_CLIENT_H | |
23 | ||
3c0ef626 | 24 | typedef struct SFTP_DIRENT SFTP_DIRENT; |
25 | ||
26 | struct SFTP_DIRENT { | |
27 | char *filename; | |
28 | char *longname; | |
29 | Attrib a; | |
30 | }; | |
31 | ||
32 | /* | |
33 | * Initialiase a SSH filexfer connection. Returns -1 on error or | |
34 | * protocol version on success. | |
35 | */ | |
ff2d7a98 | 36 | struct sftp_conn *do_init(int, int, u_int, u_int); |
e9a17296 | 37 | |
ff2d7a98 | 38 | u_int sftp_proto_version(struct sftp_conn *); |
3c0ef626 | 39 | |
40 | /* Close file referred to by 'handle' */ | |
e9a17296 | 41 | int do_close(struct sftp_conn *, char *, u_int); |
3c0ef626 | 42 | |
3c0ef626 | 43 | /* Read contents of 'path' to NULL-terminated array 'dir' */ |
e9a17296 | 44 | int do_readdir(struct sftp_conn *, char *, SFTP_DIRENT ***); |
3c0ef626 | 45 | |
46 | /* Frees a NULL-terminated array of SFTP_DIRENTs (eg. from do_readdir) */ | |
47 | void free_sftp_dirents(SFTP_DIRENT **); | |
48 | ||
49 | /* Delete file 'path' */ | |
e9a17296 | 50 | int do_rm(struct sftp_conn *, char *); |
3c0ef626 | 51 | |
52 | /* Create directory 'path' */ | |
e9a17296 | 53 | int do_mkdir(struct sftp_conn *, char *, Attrib *); |
3c0ef626 | 54 | |
55 | /* Remove directory 'path' */ | |
e9a17296 | 56 | int do_rmdir(struct sftp_conn *, char *); |
3c0ef626 | 57 | |
58 | /* Get file attributes of 'path' (follows symlinks) */ | |
e9a17296 | 59 | Attrib *do_stat(struct sftp_conn *, char *, int); |
3c0ef626 | 60 | |
61 | /* Get file attributes of 'path' (does not follow symlinks) */ | |
e9a17296 | 62 | Attrib *do_lstat(struct sftp_conn *, char *, int); |
3c0ef626 | 63 | |
64 | /* Get file attributes of open file 'handle' */ | |
e9a17296 | 65 | Attrib *do_fstat(struct sftp_conn *, char *, u_int, int); |
3c0ef626 | 66 | |
67 | /* Set file attributes of 'path' */ | |
e9a17296 | 68 | int do_setstat(struct sftp_conn *, char *, Attrib *); |
3c0ef626 | 69 | |
70 | /* Set file attributes of open file 'handle' */ | |
e9a17296 | 71 | int do_fsetstat(struct sftp_conn *, char *, u_int, Attrib *); |
3c0ef626 | 72 | |
73 | /* Canonicalise 'path' - caller must free result */ | |
e9a17296 | 74 | char *do_realpath(struct sftp_conn *, char *); |
3c0ef626 | 75 | |
76 | /* Rename 'oldpath' to 'newpath' */ | |
e9a17296 | 77 | int do_rename(struct sftp_conn *, char *, char *); |
3c0ef626 | 78 | |
79 | /* Rename 'oldpath' to 'newpath' */ | |
e9a17296 | 80 | int do_symlink(struct sftp_conn *, char *, char *); |
3c0ef626 | 81 | |
82 | /* Return target of symlink 'path' - caller must free result */ | |
e9a17296 | 83 | char *do_readlink(struct sftp_conn *, char *); |
3c0ef626 | 84 | |
85 | /* 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 | */ | |
e9a17296 | 91 | int do_download(struct sftp_conn *, char *, char *, int); |
3c0ef626 | 92 | |
93 | /* | |
94 | * Upload 'local_path' to 'remote_path'. Preserve permissions and times | |
95 | * if 'pflag' is set | |
96 | */ | |
e9a17296 | 97 | int do_upload(struct sftp_conn *, char *, char *, int); |
98 | ||
99 | #endif |