Merge branch 'vendor/ZLIB'
[dragonfly.git] / crypto / openssh / sftp-client.h
1 /* $OpenBSD: sftp-client.h,v 1.28 2019/01/16 23:23:45 djm Exp $ */
2
3 /*
4  * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
5  *
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.
9  *
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.
17  */
18
19 /* Client side of SSH2 filexfer protocol */
20
21 #ifndef _SFTP_CLIENT_H
22 #define _SFTP_CLIENT_H
23
24 #ifdef USE_SYSTEM_GLOB
25 # include <glob.h>
26 #else
27 # include "openbsd-compat/glob.h"
28 #endif
29
30 typedef struct SFTP_DIRENT SFTP_DIRENT;
31
32 struct SFTP_DIRENT {
33         char *filename;
34         char *longname;
35         Attrib a;
36 };
37
38 /*
39  * Used for statvfs responses on the wire from the server, because the
40  * server's native format may be larger than the client's.
41  */
42 struct sftp_statvfs {
43         u_int64_t f_bsize;
44         u_int64_t f_frsize;
45         u_int64_t f_blocks;
46         u_int64_t f_bfree;
47         u_int64_t f_bavail;
48         u_int64_t f_files;
49         u_int64_t f_ffree;
50         u_int64_t f_favail;
51         u_int64_t f_fsid;
52         u_int64_t f_flag;
53         u_int64_t f_namemax;
54 };
55
56 /*
57  * Initialise a SSH filexfer connection. Returns NULL on error or
58  * a pointer to a initialized sftp_conn struct on success.
59  */
60 struct sftp_conn *do_init(int, int, u_int, u_int, u_int64_t);
61
62 u_int sftp_proto_version(struct sftp_conn *);
63
64 /* Close file referred to by 'handle' */
65 int do_close(struct sftp_conn *, const u_char *, u_int);
66
67 /* Read contents of 'path' to NULL-terminated array 'dir' */
68 int do_readdir(struct sftp_conn *, const char *, SFTP_DIRENT ***);
69
70 /* Frees a NULL-terminated array of SFTP_DIRENTs (eg. from do_readdir) */
71 void free_sftp_dirents(SFTP_DIRENT **);
72
73 /* Delete file 'path' */
74 int do_rm(struct sftp_conn *, const char *);
75
76 /* Create directory 'path' */
77 int do_mkdir(struct sftp_conn *, const char *, Attrib *, int);
78
79 /* Remove directory 'path' */
80 int do_rmdir(struct sftp_conn *, const char *);
81
82 /* Get file attributes of 'path' (follows symlinks) */
83 Attrib *do_stat(struct sftp_conn *, const char *, int);
84
85 /* Get file attributes of 'path' (does not follow symlinks) */
86 Attrib *do_lstat(struct sftp_conn *, const char *, int);
87
88 /* Set file attributes of 'path' */
89 int do_setstat(struct sftp_conn *, const char *, Attrib *);
90
91 /* Set file attributes of open file 'handle' */
92 int do_fsetstat(struct sftp_conn *, const u_char *, u_int, Attrib *);
93
94 /* Set file attributes of 'path', not following symlinks */
95 int do_lsetstat(struct sftp_conn *conn, const char *path, Attrib *a);
96
97 /* Canonicalise 'path' - caller must free result */
98 char *do_realpath(struct sftp_conn *, const char *);
99
100 /* Get statistics for filesystem hosting file at "path" */
101 int do_statvfs(struct sftp_conn *, const char *, struct sftp_statvfs *, int);
102
103 /* Rename 'oldpath' to 'newpath' */
104 int do_rename(struct sftp_conn *, const char *, const char *, int force_legacy);
105
106 /* Link 'oldpath' to 'newpath' */
107 int do_hardlink(struct sftp_conn *, const char *, const char *);
108
109 /* Rename 'oldpath' to 'newpath' */
110 int do_symlink(struct sftp_conn *, const char *, const char *);
111
112 /* Call fsync() on open file 'handle' */
113 int do_fsync(struct sftp_conn *conn, u_char *, u_int);
114
115 /*
116  * Download 'remote_path' to 'local_path'. Preserve permissions and times
117  * if 'pflag' is set
118  */
119 int do_download(struct sftp_conn *, const char *, const char *,
120     Attrib *, int, int, int);
121
122 /*
123  * Recursively download 'remote_directory' to 'local_directory'. Preserve
124  * times if 'pflag' is set
125  */
126 int download_dir(struct sftp_conn *, const char *, const char *,
127     Attrib *, int, int, int, int);
128
129 /*
130  * Upload 'local_path' to 'remote_path'. Preserve permissions and times
131  * if 'pflag' is set
132  */
133 int do_upload(struct sftp_conn *, const char *, const char *, int, int, int);
134
135 /*
136  * Recursively upload 'local_directory' to 'remote_directory'. Preserve
137  * times if 'pflag' is set
138  */
139 int upload_dir(struct sftp_conn *, const char *, const char *, int, int, int,
140     int);
141
142 /* Concatenate paths, taking care of slashes. Caller must free result. */
143 char *path_append(const char *, const char *);
144
145 #endif