schannel_store.tdb: make it schannel_store.ntdb if 'use ntdb'.
[Samba/bjacke.git] / source4 / libcli / libcli.h
blob9e817408deda743bf3d234ce8d2e96582e128bfb
1 /*
2 Unix SMB/CIFS implementation.
3 SMB parameters and setup
4 Copyright (C) Andrew Tridgell 2004
5 Copyright (C) James Myers 2003 <myersjj@samba.org>
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #ifndef __LIBCLI_H__
22 #define __LIBCLI_H__
24 #include "librpc/gen_ndr/nbt.h"
25 #include "libcli/raw/libcliraw.h"
27 struct substitute_context;
29 /*
30 smbcli_state: internal state used in libcli library for single-threaded callers,
31 i.e. a single session on a single socket.
33 struct smbcli_state {
34 struct smbcli_options options;
35 struct smbcli_socket *sock; /* NULL if connected */
36 struct smbcli_transport *transport;
37 struct smbcli_session *session;
38 struct smbcli_tree *tree;
39 struct substitute_context *substitute;
40 struct smblsa_state *lsa;
43 struct clilist_file_info {
44 uint64_t size;
45 uint16_t attrib;
46 time_t mtime;
47 const char *name;
48 const char *short_name;
51 struct nbt_dc_name {
52 const char *address;
53 const char *name;
56 struct cli_credentials;
57 struct tevent_context;
59 /* passed to br lock code. */
60 enum brl_type {
61 READ_LOCK,
62 WRITE_LOCK,
63 PENDING_READ_LOCK,
64 PENDING_WRITE_LOCK
67 #include "libcli/raw/libcliraw.h"
68 struct gensec_settings;
70 ssize_t smbcli_read(struct smbcli_tree *tree, int fnum, void *_buf, off_t offset, size_t size);
72 /****************************************************************************
73 write to a file
74 write_mode: 0x0001 disallow write cacheing
75 0x0002 return bytes remaining
76 0x0004 use raw named pipe protocol
77 0x0008 start of message mode named pipe protocol
78 ****************************************************************************/
79 ssize_t smbcli_write(struct smbcli_tree *tree,
80 int fnum, uint16_t write_mode,
81 const void *_buf, off_t offset, size_t size);
83 /****************************************************************************
84 write to a file using a SMBwrite and not bypassing 0 byte writes
85 ****************************************************************************/
86 ssize_t smbcli_smbwrite(struct smbcli_tree *tree,
87 int fnum, const void *_buf, off_t offset, size_t size1);
89 bool smbcli_socket_connect(struct smbcli_state *cli, const char *server,
90 const char **ports,
91 struct tevent_context *ev_ctx,
92 struct resolve_context *resolve_ctx,
93 struct smbcli_options *options,
94 const char *socket_options,
95 struct nbt_name *calling,
96 struct nbt_name *called);
97 NTSTATUS smbcli_negprot(struct smbcli_state *cli, bool unicode, int maxprotocol);
98 NTSTATUS smbcli_session_setup(struct smbcli_state *cli,
99 struct cli_credentials *credentials,
100 const char *workgroup,
101 struct smbcli_session_options options,
102 struct gensec_settings *gensec_settings);
103 NTSTATUS smbcli_tconX(struct smbcli_state *cli, const char *sharename,
104 const char *devtype, const char *password);
105 NTSTATUS smbcli_full_connection(TALLOC_CTX *parent_ctx,
106 struct smbcli_state **ret_cli,
107 const char *host,
108 const char **ports,
109 const char *sharename,
110 const char *devtype,
111 const char *socket_options,
112 struct cli_credentials *credentials,
113 struct resolve_context *resolve_ctx,
114 struct tevent_context *ev,
115 struct smbcli_options *options,
116 struct smbcli_session_options *session_options,
117 struct gensec_settings *gensec_settings);
118 NTSTATUS smbcli_tdis(struct smbcli_state *cli);
120 /****************************************************************************
121 Initialise a client state structure.
122 ****************************************************************************/
123 struct smbcli_state *smbcli_state_init(TALLOC_CTX *mem_ctx);
124 bool smbcli_parse_unc(const char *unc_name, TALLOC_CTX *mem_ctx,
125 char **hostname, char **sharename);
127 /****************************************************************************
128 Symlink a file (UNIX extensions).
129 ****************************************************************************/
130 NTSTATUS smbcli_unix_symlink(struct smbcli_tree *tree, const char *fname_src,
131 const char *fname_dst);
133 /****************************************************************************
134 Hard a file (UNIX extensions).
135 ****************************************************************************/
136 NTSTATUS smbcli_unix_hardlink(struct smbcli_tree *tree, const char *fname_src,
137 const char *fname_dst);
139 /****************************************************************************
140 chmod a file (UNIX extensions).
141 ****************************************************************************/
142 NTSTATUS smbcli_unix_chmod(struct smbcli_tree *tree, const char *fname, mode_t mode);
144 /****************************************************************************
145 chown a file (UNIX extensions).
146 ****************************************************************************/
147 NTSTATUS smbcli_unix_chown(struct smbcli_tree *tree, const char *fname, uid_t uid,
148 gid_t gid);
150 /****************************************************************************
151 Rename a file.
152 ****************************************************************************/
153 NTSTATUS smbcli_rename(struct smbcli_tree *tree, const char *fname_src,
154 const char *fname_dst);
156 /****************************************************************************
157 Delete a file.
158 ****************************************************************************/
159 NTSTATUS smbcli_unlink(struct smbcli_tree *tree, const char *fname);
161 /****************************************************************************
162 Create a directory.
163 ****************************************************************************/
164 NTSTATUS smbcli_mkdir(struct smbcli_tree *tree, const char *dname);
166 /****************************************************************************
167 Remove a directory.
168 ****************************************************************************/
169 NTSTATUS smbcli_rmdir(struct smbcli_tree *tree, const char *dname);
171 /****************************************************************************
172 Set or clear the delete on close flag.
173 ****************************************************************************/
174 NTSTATUS smbcli_nt_delete_on_close(struct smbcli_tree *tree, int fnum,
175 bool flag);
177 /****************************************************************************
178 Create/open a file - exposing the full horror of the NT API :-).
179 Used in CIFS-on-CIFS NTVFS.
180 ****************************************************************************/
181 int smbcli_nt_create_full(struct smbcli_tree *tree, const char *fname,
182 uint32_t CreatFlags, uint32_t DesiredAccess,
183 uint32_t FileAttributes, uint32_t ShareAccess,
184 uint32_t CreateDisposition, uint32_t CreateOptions,
185 uint8_t SecurityFlags);
187 /****************************************************************************
188 Open a file (using SMBopenx)
189 WARNING: if you open with O_WRONLY then getattrE won't work!
190 ****************************************************************************/
191 int smbcli_open(struct smbcli_tree *tree, const char *fname, int flags,
192 int share_mode);
194 /****************************************************************************
195 Close a file.
196 ****************************************************************************/
197 NTSTATUS smbcli_close(struct smbcli_tree *tree, int fnum);
199 /****************************************************************************
200 send a lock with a specified locktype
201 this is used for testing LOCKING_ANDX_CANCEL_LOCK
202 ****************************************************************************/
203 NTSTATUS smbcli_locktype(struct smbcli_tree *tree, int fnum,
204 uint32_t offset, uint32_t len, int timeout,
205 uint8_t locktype);
207 /****************************************************************************
208 Lock a file.
209 ****************************************************************************/
210 NTSTATUS smbcli_lock(struct smbcli_tree *tree, int fnum,
211 uint32_t offset, uint32_t len, int timeout,
212 enum brl_type lock_type);
214 /****************************************************************************
215 Unlock a file.
216 ****************************************************************************/
217 NTSTATUS smbcli_unlock(struct smbcli_tree *tree, int fnum, uint32_t offset, uint32_t len);
219 /****************************************************************************
220 Lock a file with 64 bit offsets.
221 ****************************************************************************/
222 NTSTATUS smbcli_lock64(struct smbcli_tree *tree, int fnum,
223 off_t offset, off_t len, int timeout,
224 enum brl_type lock_type);
226 /****************************************************************************
227 Unlock a file with 64 bit offsets.
228 ****************************************************************************/
229 NTSTATUS smbcli_unlock64(struct smbcli_tree *tree, int fnum, off_t offset,
230 off_t len);
232 /****************************************************************************
233 Do a SMBgetattrE call.
234 ****************************************************************************/
235 NTSTATUS smbcli_getattrE(struct smbcli_tree *tree, int fnum,
236 uint16_t *attr, size_t *size,
237 time_t *c_time, time_t *a_time, time_t *m_time);
239 /****************************************************************************
240 Do a SMBgetatr call
241 ****************************************************************************/
242 NTSTATUS smbcli_getatr(struct smbcli_tree *tree, const char *fname,
243 uint16_t *attr, size_t *size, time_t *t);
245 /****************************************************************************
246 Do a SMBsetatr call.
247 ****************************************************************************/
248 NTSTATUS smbcli_setatr(struct smbcli_tree *tree, const char *fname, uint16_t mode,
249 time_t t);
251 /****************************************************************************
252 Do a setfileinfo basic_info call.
253 ****************************************************************************/
254 NTSTATUS smbcli_fsetatr(struct smbcli_tree *tree, int fnum, uint16_t mode,
255 NTTIME create_time, NTTIME access_time,
256 NTTIME write_time, NTTIME change_time);
258 /****************************************************************************
259 truncate a file to a given size
260 ****************************************************************************/
261 NTSTATUS smbcli_ftruncate(struct smbcli_tree *tree, int fnum, uint64_t size);
263 /****************************************************************************
264 Check for existence of a dir.
265 ****************************************************************************/
266 NTSTATUS smbcli_chkpath(struct smbcli_tree *tree, const char *path);
268 /****************************************************************************
269 Query disk space.
270 ****************************************************************************/
271 NTSTATUS smbcli_dskattr(struct smbcli_tree *tree, uint32_t *bsize,
272 uint64_t *total, uint64_t *avail);
274 /****************************************************************************
275 Create and open a temporary file.
276 ****************************************************************************/
277 int smbcli_ctemp(struct smbcli_tree *tree, const char *path, char **tmp_path);
279 /****************************************************************************
280 Interpret a long filename structure.
281 ****************************************************************************/
282 int smbcli_list_new(struct smbcli_tree *tree, const char *Mask, uint16_t attribute,
283 enum smb_search_data_level level,
284 void (*fn)(struct clilist_file_info *, const char *, void *),
285 void *caller_state);
287 /****************************************************************************
288 Interpret a short filename structure.
289 The length of the structure is returned.
290 ****************************************************************************/
291 int smbcli_list_old(struct smbcli_tree *tree, const char *Mask, uint16_t attribute,
292 void (*fn)(struct clilist_file_info *, const char *, void *),
293 void *caller_state);
295 /****************************************************************************
296 Do a directory listing, calling fn on each file found.
297 This auto-switches between old and new style.
298 ****************************************************************************/
299 int smbcli_list(struct smbcli_tree *tree, const char *Mask,uint16_t attribute,
300 void (*fn)(struct clilist_file_info *, const char *, void *), void *state);
302 /****************************************************************************
303 send a qpathinfo call
304 ****************************************************************************/
305 NTSTATUS smbcli_qpathinfo(struct smbcli_tree *tree, const char *fname,
306 time_t *c_time, time_t *a_time, time_t *m_time,
307 size_t *size, uint16_t *mode);
309 /****************************************************************************
310 send a qpathinfo call with the SMB_QUERY_FILE_ALL_INFO info level
311 ****************************************************************************/
312 NTSTATUS smbcli_qpathinfo2(struct smbcli_tree *tree, const char *fname,
313 time_t *c_time, time_t *a_time, time_t *m_time,
314 time_t *w_time, size_t *size, uint16_t *mode,
315 ino_t *ino);
317 /****************************************************************************
318 send a qfileinfo QUERY_FILE_NAME_INFO call
319 ****************************************************************************/
320 NTSTATUS smbcli_qfilename(struct smbcli_tree *tree, int fnum, const char **name);
322 /****************************************************************************
323 send a qfileinfo call
324 ****************************************************************************/
325 NTSTATUS smbcli_qfileinfo(struct smbcli_tree *tree, int fnum,
326 uint16_t *mode, size_t *size,
327 time_t *c_time, time_t *a_time, time_t *m_time,
328 time_t *w_time, ino_t *ino);
330 /****************************************************************************
331 send a qpathinfo SMB_QUERY_FILE_ALT_NAME_INFO call
332 ****************************************************************************/
333 NTSTATUS smbcli_qpathinfo_alt_name(struct smbcli_tree *tree, const char *fname,
334 const char **alt_name);
336 /* The following definitions come from ../source4/libcli/climessage.c */
339 /****************************************************************************
340 start a message sequence
341 ****************************************************************************/
342 bool smbcli_message_start(struct smbcli_tree *tree, const char *host, const char *username,
343 int *grp);
345 /****************************************************************************
346 send a message
347 ****************************************************************************/
348 bool smbcli_message_text(struct smbcli_tree *tree, char *msg, int len, int grp);
350 /****************************************************************************
351 end a message
352 ****************************************************************************/
353 bool smbcli_message_end(struct smbcli_tree *tree, int grp);
355 int smbcli_deltree(struct smbcli_tree *tree, const char *dname);
357 #endif /* __LIBCLI_H__ */