s3-vfs: make vfswrap_llistxattr and vfswrap_flistxattr static.
[samba.git] / source3 / include / proto.h
1 /*
2  * Unix SMB/CIFS implementation.
3  * collected prototypes header
4  *
5  * frozen from "make proto" in May 2008
6  *
7  * Copyright (C) Michael Adam 2008
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, see <http://www.gnu.org/licenses/>.
21  */
22
23 #ifndef _PROTO_H_
24 #define _PROTO_H_
25
26 /* The following definitions come from lib/access.c  */
27
28 bool client_match(const char *tok, const void *item);
29 bool list_match(const char **list,const void *item,
30                 bool (*match_fn)(const char *, const void *));
31 bool allow_access(const char **deny_list,
32                 const char **allow_list,
33                 const char *cname,
34                 const char *caddr);
35
36 /* The following definitions come from lib/adt_tree.c  */
37
38
39 /* The following definitions come from lib/afs.c  */
40
41 char *afs_createtoken_str(const char *username, const char *cell);
42 bool afs_login(connection_struct *conn);
43 bool afs_login(connection_struct *conn);
44 char *afs_createtoken_str(const char *username, const char *cell);
45
46 /* The following definitions come from lib/afs_settoken.c  */
47
48 int afs_syscall( int subcall,
49           char * path,
50           int cmd,
51           char * cmarg,
52           int follow);
53 bool afs_settoken_str(const char *token_string);
54 bool afs_settoken_str(const char *token_string);
55
56 /* The following definitions come from lib/audit.c  */
57
58 const char *audit_category_str(uint32 category);
59 const char *audit_param_str(uint32 category);
60 const char *audit_description_str(uint32 category);
61 bool get_audit_category_from_param(const char *param, uint32 *audit_category);
62 const char *audit_policy_str(TALLOC_CTX *mem_ctx, uint32 policy);
63
64 /* The following definitions come from lib/bitmap.c  */
65
66 struct bitmap *bitmap_talloc(TALLOC_CTX *mem_ctx, int n);
67 int bitmap_copy(struct bitmap * const dst, const struct bitmap * const src);
68 bool bitmap_set(struct bitmap *bm, unsigned i);
69 bool bitmap_clear(struct bitmap *bm, unsigned i);
70 bool bitmap_query(struct bitmap *bm, unsigned i);
71 int bitmap_find(struct bitmap *bm, unsigned ofs);
72
73 /* The following definitions come from lib/charcnv.c  */
74
75 void gfree_charcnv(void);
76 void init_iconv(void);
77 bool convert_string(charset_t from, charset_t to,
78                       void const *src, size_t srclen, 
79                       void *dest, size_t destlen,
80                       size_t *converted_size);
81 bool convert_string_error(charset_t from, charset_t to,
82                             void const *src, size_t srclen,
83                             void *dest, size_t destlen,
84                             size_t *converted_size);
85 size_t ucs2_align(const void *base_ptr, const void *p, int flags);
86 size_t push_ascii(void *dest, const char *src, size_t dest_len, int flags);
87 size_t push_ascii_fstring(void *dest, const char *src);
88 size_t push_ascii_nstring(void *dest, const char *src);
89 size_t pull_ascii(char *dest, const void *src, size_t dest_len, size_t src_len, int flags);
90 size_t pull_ascii_fstring(char *dest, const void *src);
91 size_t pull_ascii_nstring(char *dest, size_t dest_len, const void *src);
92 size_t push_string_check_fn(void *dest, const char *src,
93                             size_t dest_len, int flags);
94 size_t push_string_base(const char *base, uint16 flags2,
95                         void *dest, const char *src,
96                         size_t dest_len, int flags);
97 size_t pull_string_fn(const void *base_ptr,
98                         uint16 smb_flags2,
99                         char *dest,
100                         const void *src,
101                         size_t dest_len,
102                         size_t src_len,
103                         int flags);
104 size_t pull_string_talloc(TALLOC_CTX *ctx,
105                         const void *base_ptr,
106                         uint16 smb_flags2,
107                         char **ppdest,
108                         const void *src,
109                         size_t src_len,
110                         int flags);
111 size_t align_string(const void *base_ptr, const char *p, int flags);
112 size_t dos_PutUniCode(char *dst,const char *src, size_t len, bool null_terminate);
113 int rpcstr_push(void *dest, const char *src, size_t dest_len, int flags);
114 int rpcstr_push_talloc(TALLOC_CTX *ctx, smb_ucs2_t **dest, const char *src);
115
116 /* The following definitions come from lib/conn_tdb.c  */
117
118 struct db_record *connections_fetch_entry(TALLOC_CTX *mem_ctx,
119                                           connection_struct *conn,
120                                           const char *name);
121 int connections_traverse(int (*fn)(struct db_record *rec,
122                                    void *private_data),
123                          void *private_data);
124 int connections_forall(int (*fn)(struct db_record *rec,
125                                  const struct connections_key *key,
126                                  const struct connections_data *data,
127                                  void *private_data),
128                        void *private_data);
129 int connections_forall_read(int (*fn)(const struct connections_key *key,
130                                       const struct connections_data *data,
131                                       void *private_data),
132                             void *private_data);
133 bool connections_init(bool rw);
134
135 /* The following definitions come from lib/dmallocmsg.c  */
136
137 void register_dmalloc_msgs(struct messaging_context *msg_ctx);
138
139 /* The following definitions come from lib/dprintf.c  */
140
141 void display_set_stderr(void);
142
143 /* The following definitions come from lib/errmap_unix.c  */
144
145 NTSTATUS map_nt_error_from_unix(int unix_error);
146 int map_errno_from_nt_status(NTSTATUS status);
147
148 /* The following definitions come from lib/file_id.c  */
149
150 struct file_id vfs_file_id_from_sbuf(connection_struct *conn, const SMB_STRUCT_STAT *sbuf);
151 bool file_id_equal(const struct file_id *id1, const struct file_id *id2);
152 const char *file_id_string_tos(const struct file_id *id);
153 void push_file_id_16(char *buf, const struct file_id *id);
154 void push_file_id_24(char *buf, const struct file_id *id);
155 void pull_file_id_24(char *buf, struct file_id *id);
156
157 /* The following definitions come from lib/gencache.c  */
158
159 bool gencache_set(const char *keystr, const char *value, time_t timeout);
160 bool gencache_del(const char *keystr);
161 bool gencache_get(const char *keystr, char **valstr, time_t *timeout);
162 bool gencache_parse(const char *keystr,
163                     void (*parser)(time_t timeout, DATA_BLOB blob,
164                                    void *private_data),
165                     void *private_data);
166 bool gencache_get_data_blob(const char *keystr, DATA_BLOB *blob,
167                             time_t *timeout, bool *was_expired);
168 bool gencache_stabilize(void);
169 bool gencache_set_data_blob(const char *keystr, const DATA_BLOB *blob, time_t timeout);
170 void gencache_iterate_blobs(void (*fn)(const char *key, DATA_BLOB value,
171                                        time_t timeout, void *private_data),
172                             void *private_data, const char *pattern);
173 void gencache_iterate(void (*fn)(const char* key, const char *value, time_t timeout, void* dptr),
174                       void* data, const char* keystr_pattern);
175
176 /* The following definitions come from lib/interface.c  */
177
178 bool ismyaddr(const struct sockaddr *ip);
179 bool ismyip_v4(struct in_addr ip);
180 bool is_local_net(const struct sockaddr *from);
181 void setup_linklocal_scope_id(struct sockaddr *pss);
182 bool is_local_net_v4(struct in_addr from);
183 int iface_count(void);
184 int iface_count_v4_nl(void);
185 const struct in_addr *first_ipv4_iface(void);
186 struct interface *get_interface(int n);
187 const struct sockaddr_storage *iface_n_sockaddr_storage(int n);
188 const struct in_addr *iface_n_ip_v4(int n);
189 const struct in_addr *iface_n_bcast_v4(int n);
190 const struct sockaddr_storage *iface_n_bcast(int n);
191 const struct sockaddr_storage *iface_ip(const struct sockaddr *ip);
192 bool iface_local(const struct sockaddr *ip);
193 void load_interfaces(void);
194 void gfree_interfaces(void);
195 bool interfaces_changed(void);
196
197 /* The following definitions come from lib/ldap_debug_handler.c  */
198
199 void init_ldap_debugging(void);
200
201 /* The following definitions come from lib/ldap_escape.c  */
202
203 char *escape_ldap_string(TALLOC_CTX *mem_ctx, const char *s);
204 char *escape_rdn_val_string_alloc(const char *s);
205
206 /* The following definitions come from lib/module.c  */
207
208 NTSTATUS smb_load_module(const char *module_name);
209 int smb_load_modules(const char **modules);
210 NTSTATUS smb_probe_module(const char *subsystem, const char *module);
211 NTSTATUS smb_load_module(const char *module_name);
212 int smb_load_modules(const char **modules);
213 NTSTATUS smb_probe_module(const char *subsystem, const char *module);
214 void init_modules(void);
215
216 /* The following definitions come from lib/ms_fnmatch.c  */
217
218 int ms_fnmatch(const char *pattern, const char *string, bool translate_pattern,
219                bool is_case_sensitive);
220 int gen_fnmatch(const char *pattern, const char *string);
221
222 /* The following definitions come from lib/pidfile.c  */
223
224 pid_t pidfile_pid(const char *name);
225 void pidfile_create(const char *program_name);
226 void pidfile_unlink(void);
227
228 /* The following definitions come from lib/recvfile.c  */
229
230 ssize_t sys_recvfile(int fromfd,
231                         int tofd,
232                         SMB_OFF_T offset,
233                         size_t count);
234 ssize_t sys_recvfile(int fromfd,
235                         int tofd,
236                         SMB_OFF_T offset,
237                         size_t count);
238 ssize_t drain_socket(int sockfd, size_t count);
239
240 /* The following definitions come from lib/secdesc.c  */
241
242 uint32_t get_sec_info(const struct security_descriptor *sd);
243 struct security_descriptor *sec_desc_merge(TALLOC_CTX *ctx, struct security_descriptor *new_sdb, struct security_descriptor *old_sdb);
244 struct sec_desc_buf *sec_desc_merge_buf(TALLOC_CTX *ctx, struct sec_desc_buf *new_sdb, struct sec_desc_buf *old_sdb);
245 struct security_descriptor *make_sec_desc(TALLOC_CTX *ctx,
246                         enum security_descriptor_revision revision,
247                         uint16 type,
248                         const struct dom_sid *owner_sid, const struct dom_sid *grp_sid,
249                         struct security_acl *sacl, struct security_acl *dacl, size_t *sd_size);
250 struct security_descriptor *dup_sec_desc(TALLOC_CTX *ctx, const struct security_descriptor *src);
251 NTSTATUS marshall_sec_desc(TALLOC_CTX *mem_ctx,
252                            struct security_descriptor *secdesc,
253                            uint8 **data, size_t *len);
254 NTSTATUS marshall_sec_desc_buf(TALLOC_CTX *mem_ctx,
255                                struct sec_desc_buf *secdesc_buf,
256                                uint8_t **data, size_t *len);
257 NTSTATUS unmarshall_sec_desc(TALLOC_CTX *mem_ctx, uint8 *data, size_t len,
258                              struct security_descriptor **psecdesc);
259 NTSTATUS unmarshall_sec_desc_buf(TALLOC_CTX *mem_ctx, uint8_t *data, size_t len,
260                                  struct sec_desc_buf **psecdesc_buf);
261 struct security_descriptor *make_standard_sec_desc(TALLOC_CTX *ctx, const struct dom_sid *owner_sid, const struct dom_sid *grp_sid,
262                                  struct security_acl *dacl, size_t *sd_size);
263 struct sec_desc_buf *make_sec_desc_buf(TALLOC_CTX *ctx, size_t len, struct security_descriptor *sec_desc);
264 struct sec_desc_buf *dup_sec_desc_buf(TALLOC_CTX *ctx, struct sec_desc_buf *src);
265 NTSTATUS sec_desc_add_sid(TALLOC_CTX *ctx, struct security_descriptor **psd, const struct dom_sid *sid, uint32 mask, size_t *sd_size);
266 NTSTATUS sec_desc_mod_sid(struct security_descriptor *sd, struct dom_sid *sid, uint32 mask);
267 NTSTATUS sec_desc_del_sid(TALLOC_CTX *ctx, struct security_descriptor **psd, struct dom_sid *sid, size_t *sd_size);
268 bool sd_has_inheritable_components(const struct security_descriptor *parent_ctr, bool container);
269 NTSTATUS se_create_child_secdesc(TALLOC_CTX *ctx,
270                                         struct security_descriptor **ppsd,
271                                         size_t *psize,
272                                         const struct security_descriptor *parent_ctr,
273                                         const struct dom_sid *owner_sid,
274                                         const struct dom_sid *group_sid,
275                                         bool container);
276 NTSTATUS se_create_child_secdesc_buf(TALLOC_CTX *ctx,
277                                         struct sec_desc_buf **ppsdb,
278                                         const struct security_descriptor *parent_ctr,
279                                         bool container);
280
281 /* The following definitions come from lib/sendfile.c  */
282
283 ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, SMB_OFF_T offset, size_t count);
284
285 /* The following definitions come from lib/server_mutex.c  */
286
287 struct named_mutex *grab_named_mutex(TALLOC_CTX *mem_ctx, const char *name,
288                                      int timeout);
289
290 /* The following definitions come from lib/sharesec.c  */
291
292 bool share_info_db_init(void);
293 struct security_descriptor *get_share_security_default( TALLOC_CTX *ctx, size_t *psize, uint32 def_access);
294 struct security_descriptor *get_share_security( TALLOC_CTX *ctx, const char *servicename,
295                               size_t *psize);
296 bool set_share_security(const char *share_name, struct security_descriptor *psd);
297 bool delete_share_security(const char *servicename);
298 bool share_access_check(const struct security_token *token, const char *sharename,
299                         uint32 desired_access);
300 bool parse_usershare_acl(TALLOC_CTX *ctx, const char *acl_str, struct security_descriptor **ppsd);
301
302 /* The following definitions come from lib/smbrun.c  */
303
304 int smbrun_no_sanitize(const char *cmd, int *outfd);
305 int smbrun(const char *cmd, int *outfd);
306 int smbrunsecret(const char *cmd, const char *secret);
307
308 /* The following definitions come from lib/sock_exec.c  */
309
310 int sock_exec(const char *prog);
311
312 /* The following definitions come from lib/substitute.c  */
313
314 void free_local_machine_name(void);
315 bool set_local_machine_name(const char *local_name, bool perm);
316 const char *get_local_machine_name(void);
317 bool set_remote_machine_name(const char *remote_name, bool perm);
318 const char *get_remote_machine_name(void);
319 void sub_set_smb_name(const char *name);
320 void set_current_user_info(const char *smb_name, const char *unix_name,
321                            const char *domain);
322 void sub_set_socket_ids(const char *peeraddr, const char *peername,
323                         const char *sockaddr);
324 const char *get_current_username(void);
325 void standard_sub_basic(const char *smb_name, const char *domain_name,
326                         char *str, size_t len);
327 char *talloc_sub_basic(TALLOC_CTX *mem_ctx, const char *smb_name,
328                        const char *domain_name, const char *str);
329 char *talloc_sub_specified(TALLOC_CTX *mem_ctx,
330                         const char *input_string,
331                         const char *username,
332                         const char *domain,
333                         uid_t uid,
334                         gid_t gid);
335 char *talloc_sub_advanced(TALLOC_CTX *mem_ctx,
336                           const char *servicename, const char *user,
337                           const char *connectpath, gid_t gid,
338                           const char *smb_name, const char *domain_name,
339                           const char *str);
340 void standard_sub_advanced(const char *servicename, const char *user,
341                            const char *connectpath, gid_t gid,
342                            const char *smb_name, const char *domain_name,
343                            char *str, size_t len);
344 char *standard_sub_conn(TALLOC_CTX *ctx, connection_struct *conn, const char *str);
345
346 /* The following definitions come from lib/sysacls.c  */
347
348 int sys_acl_get_entry(SMB_ACL_T acl_d, int entry_id, SMB_ACL_ENTRY_T *entry_p);
349 int sys_acl_get_tag_type(SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T *type_p);
350 int sys_acl_get_permset(SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T *permset_p);
351 void *sys_acl_get_qualifier(SMB_ACL_ENTRY_T entry_d);
352 int sys_acl_clear_perms(SMB_ACL_PERMSET_T permset_d);
353 int sys_acl_add_perm(SMB_ACL_PERMSET_T permset_d, SMB_ACL_PERM_T perm);
354 int sys_acl_get_perm(SMB_ACL_PERMSET_T permset_d, SMB_ACL_PERM_T perm);
355 char *sys_acl_to_text(SMB_ACL_T acl_d, ssize_t *len_p);
356 SMB_ACL_T sys_acl_init(int count);
357 int sys_acl_create_entry(SMB_ACL_T *acl_p, SMB_ACL_ENTRY_T *entry_p);
358 int sys_acl_set_tag_type(SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T tag_type);
359 int sys_acl_set_qualifier(SMB_ACL_ENTRY_T entry_d, void *qual_p);
360 int sys_acl_set_permset(SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T permset_d);
361 int sys_acl_free_text(char *text);
362 int sys_acl_free_acl(SMB_ACL_T acl_d) ;
363 int sys_acl_free_qualifier(void *qual, SMB_ACL_TAG_T tagtype);
364 int sys_acl_valid(SMB_ACL_T acl_d);
365 SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle, 
366                            const char *path_p, SMB_ACL_TYPE_T type);
367 SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp);
368 int sys_acl_set_file(vfs_handle_struct *handle,
369                      const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d);
370 int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
371                    SMB_ACL_T acl_d);
372 int sys_acl_delete_def_file(vfs_handle_struct *handle,
373                             const char *path);
374 SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
375                            const char *path_p, SMB_ACL_TYPE_T type);
376 SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp);
377 int sys_acl_set_file(vfs_handle_struct *handle,
378                      const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d);
379 int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
380                    SMB_ACL_T acl_d);
381 int sys_acl_delete_def_file(vfs_handle_struct *handle,
382                             const char *path);
383 SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
384                            const char *path_p, SMB_ACL_TYPE_T type);
385 SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp);
386 int sys_acl_set_file(vfs_handle_struct *handle,
387                      const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d);
388 int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
389                    SMB_ACL_T acl_d);
390 int sys_acl_delete_def_file(vfs_handle_struct *handle,
391                             const char *path);
392 SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
393                            const char *path_p, SMB_ACL_TYPE_T type);
394 SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp);
395 int sys_acl_set_file(vfs_handle_struct *handle,
396                      const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d);
397 int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
398                    SMB_ACL_T acl_d);
399 int sys_acl_delete_def_file(vfs_handle_struct *handle,
400                             const char *path);
401 SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
402                            const char *path_p, SMB_ACL_TYPE_T type);
403 SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp);
404 int sys_acl_set_file(vfs_handle_struct *handle,
405                      const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d);
406 int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
407                    SMB_ACL_T acl_d);
408 int sys_acl_delete_def_file(vfs_handle_struct *handle,
409                             const char *path);
410 SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
411                            const char *path_p, SMB_ACL_TYPE_T type);
412 SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp);
413 int sys_acl_set_file(vfs_handle_struct *handle,
414                      const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d);
415 int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
416                    SMB_ACL_T acl_d);
417 int sys_acl_delete_def_file(vfs_handle_struct *handle,
418                             const char *path);
419 SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
420                            const char *path_p, SMB_ACL_TYPE_T type);
421 SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp);
422 int sys_acl_set_file(vfs_handle_struct *handle,
423                      const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d);
424 int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
425                    SMB_ACL_T acl_d);
426 int sys_acl_delete_def_file(vfs_handle_struct *handle,
427                             const char *path);
428 int no_acl_syscall_error(int err);
429
430 /* The following definitions come from lib/sysquotas.c  */
431
432 int sys_get_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dp);
433 int sys_set_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dp);
434
435 /* The following definitions come from lib/sysquotas_*.c  */
436
437 int sys_get_vfs_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dp);
438 int sys_set_vfs_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dp);
439
440 int sys_get_xfs_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dp);
441 int sys_set_xfs_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dp);
442
443 int sys_get_nfs_quota(const char *path, const char *bdev,
444                       enum SMB_QUOTA_TYPE qtype,
445                       unid_t id, SMB_DISK_QUOTA *dp);
446 int sys_set_nfs_quota(const char *path, const char *bdev,
447                       enum SMB_QUOTA_TYPE qtype,
448                       unid_t id, SMB_DISK_QUOTA *dp);
449
450 /* The following definitions come from lib/system.c  */
451
452 void *sys_memalign( size_t align, size_t size );
453 int sys_usleep(long usecs);
454 ssize_t sys_read(int fd, void *buf, size_t count);
455 ssize_t sys_write(int fd, const void *buf, size_t count);
456 ssize_t sys_writev(int fd, const struct iovec *iov, int iovcnt);
457 ssize_t sys_pread(int fd, void *buf, size_t count, SMB_OFF_T off);
458 ssize_t sys_pwrite(int fd, const void *buf, size_t count, SMB_OFF_T off);
459 ssize_t sys_send(int s, const void *msg, size_t len, int flags);
460 ssize_t sys_sendto(int s,  const void *msg, size_t len, int flags, const struct sockaddr *to, socklen_t tolen);
461 ssize_t sys_recv(int fd, void *buf, size_t count, int flags);
462 ssize_t sys_recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen);
463 int sys_fcntl_ptr(int fd, int cmd, void *arg);
464 int sys_fcntl_long(int fd, int cmd, long arg);
465 void update_stat_ex_mtime(struct stat_ex *dst, struct timespec write_ts);
466 void update_stat_ex_create_time(struct stat_ex *dst, struct timespec create_time);
467 int sys_stat(const char *fname, SMB_STRUCT_STAT *sbuf,
468              bool fake_dir_create_times);
469 int sys_fstat(int fd, SMB_STRUCT_STAT *sbuf,
470               bool fake_dir_create_times);
471 int sys_lstat(const char *fname,SMB_STRUCT_STAT *sbuf,
472               bool fake_dir_create_times);
473 int sys_ftruncate(int fd, SMB_OFF_T offset);
474 int sys_posix_fallocate(int fd, SMB_OFF_T offset, SMB_OFF_T len);
475 int sys_fallocate(int fd, enum vfs_fallocate_mode mode, SMB_OFF_T offset, SMB_OFF_T len);
476 SMB_OFF_T sys_lseek(int fd, SMB_OFF_T offset, int whence);
477 int sys_fseek(FILE *fp, SMB_OFF_T offset, int whence);
478 SMB_OFF_T sys_ftell(FILE *fp);
479 int sys_creat(const char *path, mode_t mode);
480 int sys_open(const char *path, int oflag, mode_t mode);
481 FILE *sys_fopen(const char *path, const char *type);
482 void kernel_flock(int fd, uint32 share_mode, uint32 access_mask);
483 SMB_STRUCT_DIR *sys_opendir(const char *name);
484 SMB_STRUCT_DIR *sys_fdopendir(int fd);
485 SMB_STRUCT_DIRENT *sys_readdir(SMB_STRUCT_DIR *dirp);
486 void sys_seekdir(SMB_STRUCT_DIR *dirp, long offset);
487 long sys_telldir(SMB_STRUCT_DIR *dirp);
488 void sys_rewinddir(SMB_STRUCT_DIR *dirp);
489 int sys_closedir(SMB_STRUCT_DIR *dirp);
490 int sys_mknod(const char *path, mode_t mode, SMB_DEV_T dev);
491 int sys_waitpid(pid_t pid,int *status,int options);
492 char *sys_getwd(char *s);
493 void set_effective_capability(enum smbd_capability capability);
494 void drop_effective_capability(enum smbd_capability capability);
495 long sys_random(void);
496 void sys_srandom(unsigned int seed);
497 int groups_max(void);
498 int sys_getgroups(int setlen, gid_t *gidset);
499 int sys_setgroups(gid_t UNUSED(primary_gid), int setlen, gid_t *gidset);
500 int sys_popen(const char *command);
501 int sys_pclose(int fd);
502 ssize_t sys_getxattr (const char *path, const char *name, void *value, size_t size);
503 ssize_t sys_lgetxattr (const char *path, const char *name, void *value, size_t size);
504 ssize_t sys_fgetxattr (int filedes, const char *name, void *value, size_t size);
505 ssize_t sys_listxattr (const char *path, char *list, size_t size);
506 ssize_t sys_llistxattr (const char *path, char *list, size_t size);
507 ssize_t sys_flistxattr (int filedes, char *list, size_t size);
508 int sys_removexattr (const char *path, const char *name);
509 int sys_lremovexattr (const char *path, const char *name);
510 int sys_fremovexattr (int filedes, const char *name);
511 int sys_setxattr (const char *path, const char *name, const void *value, size_t size, int flags);
512 int sys_lsetxattr (const char *path, const char *name, const void *value, size_t size, int flags);
513 int sys_fsetxattr (int filedes, const char *name, const void *value, size_t size, int flags);
514 uint32 unix_dev_major(SMB_DEV_T dev);
515 uint32 unix_dev_minor(SMB_DEV_T dev);
516 int sys_aio_read(SMB_STRUCT_AIOCB *aiocb);
517 int sys_aio_write(SMB_STRUCT_AIOCB *aiocb);
518 ssize_t sys_aio_return(SMB_STRUCT_AIOCB *aiocb);
519 int sys_aio_cancel(int fd, SMB_STRUCT_AIOCB *aiocb);
520 int sys_aio_error(const SMB_STRUCT_AIOCB *aiocb);
521 int sys_aio_fsync(int op, SMB_STRUCT_AIOCB *aiocb);
522 int sys_aio_suspend(const SMB_STRUCT_AIOCB * const cblist[], int n, const struct timespec *timeout);
523 int sys_aio_read(SMB_STRUCT_AIOCB *aiocb);
524 int sys_aio_write(SMB_STRUCT_AIOCB *aiocb);
525 ssize_t sys_aio_return(SMB_STRUCT_AIOCB *aiocb);
526 int sys_aio_cancel(int fd, SMB_STRUCT_AIOCB *aiocb);
527 int sys_aio_error(const SMB_STRUCT_AIOCB *aiocb);
528 int sys_aio_fsync(int op, SMB_STRUCT_AIOCB *aiocb);
529 int sys_aio_suspend(const SMB_STRUCT_AIOCB * const cblist[], int n, const struct timespec *timeout);
530 /* The following definitions come from lib/system_smbd.c  */
531
532 bool getgroups_unix_user(TALLOC_CTX *mem_ctx, const char *user,
533                          gid_t primary_gid,
534                          gid_t **ret_groups, uint32_t *p_ngroups);
535
536 /* The following definitions come from lib/tallocmsg.c  */
537
538 void register_msg_pool_usage(struct messaging_context *msg_ctx);
539
540 /* The following definitions come from lib/time.c  */
541
542 void push_dos_date(uint8_t *buf, int offset, time_t unixdate, int zone_offset);
543 void push_dos_date2(uint8_t *buf,int offset,time_t unixdate, int zone_offset);
544 void push_dos_date3(uint8_t *buf,int offset,time_t unixdate, int zone_offset);
545 uint32_t convert_time_t_to_uint32_t(time_t t);
546 time_t convert_uint32_t_to_time_t(uint32_t u);
547 bool nt_time_is_zero(const NTTIME *nt);
548 time_t generalized_to_unix_time(const char *str);
549 int get_server_zone_offset(void);
550 int set_server_zone_offset(time_t t);
551 char *timeval_string(TALLOC_CTX *ctx, const struct timeval *tp, bool hires);
552 char *current_timestring(TALLOC_CTX *ctx, bool hires);
553 void srv_put_dos_date(char *buf,int offset,time_t unixdate);
554 void srv_put_dos_date2(char *buf,int offset, time_t unixdate);
555 void srv_put_dos_date3(char *buf,int offset,time_t unixdate);
556 void round_timespec(enum timestamp_set_resolution res, struct timespec *ts);
557 void put_long_date_timespec(enum timestamp_set_resolution res, char *p, struct timespec ts);
558 void put_long_date(char *p, time_t t);
559 void dos_filetime_timespec(struct timespec *tsp);
560 time_t make_unix_date(const void *date_ptr, int zone_offset);
561 time_t make_unix_date2(const void *date_ptr, int zone_offset);
562 time_t make_unix_date3(const void *date_ptr, int zone_offset);
563 time_t srv_make_unix_date(const void *date_ptr);
564 time_t srv_make_unix_date2(const void *date_ptr);
565 time_t srv_make_unix_date3(const void *date_ptr);
566 struct timespec convert_time_t_to_timespec(time_t t);
567 struct timespec convert_timeval_to_timespec(const struct timeval tv);
568 struct timeval convert_timespec_to_timeval(const struct timespec ts);
569 struct timespec timespec_current(void);
570 struct timespec timespec_min(const struct timespec *ts1,
571                            const struct timespec *ts2);
572 int timespec_compare(const struct timespec *ts1, const struct timespec *ts2);
573 void round_timespec_to_sec(struct timespec *ts);
574 void round_timespec_to_usec(struct timespec *ts);
575 struct timespec interpret_long_date(const char *p);
576 void TimeInit(void);
577 void get_process_uptime(struct timeval *ret_time);
578 void get_startup_time(struct timeval *ret_time);
579 time_t nt_time_to_unix_abs(const NTTIME *nt);
580 time_t uint64s_nt_time_to_unix_abs(const uint64_t *src);
581 void unix_timespec_to_nt_time(NTTIME *nt, struct timespec ts);
582 void unix_to_nt_time_abs(NTTIME *nt, time_t t);
583 const char *time_to_asc(const time_t t);
584 const char *display_time(NTTIME nttime);
585 bool nt_time_is_set(const NTTIME *nt);
586
587 /* The following definitions come from lib/username.c  */
588
589 void flush_pwnam_cache(void);
590 char *get_user_home_dir(TALLOC_CTX *mem_ctx, const char *user);
591 struct passwd *Get_Pwnam_alloc(TALLOC_CTX *mem_ctx, const char *user);
592
593 /* The following definitions come from lib/util_names.c  */
594 void gfree_netbios_names(void);
595 bool set_global_myname(const char *myname);
596 const char *global_myname(void);
597 bool set_global_myworkgroup(const char *myworkgroup);
598 const char *lp_workgroup(void);
599 const char *get_global_sam_name(void);
600
601 /* The following definitions come from lib/util.c  */
602
603 enum protocol_types get_Protocol(void);
604 void set_Protocol(enum protocol_types  p);
605 bool all_zero(const uint8_t *ptr, size_t size);
606 bool set_global_scope(const char *scope);
607 const char *global_scope(void);
608 void gfree_names(void);
609 void gfree_all( void );
610 const char *my_netbios_names(int i);
611 bool set_netbios_aliases(const char **str_array);
612 bool init_names(void);
613 bool file_exist_stat(const char *fname,SMB_STRUCT_STAT *sbuf,
614                      bool fake_dir_create_times);
615 bool socket_exist(const char *fname);
616 uint64_t get_file_size_stat(const SMB_STRUCT_STAT *sbuf);
617 SMB_OFF_T get_file_size(char *file_name);
618 void show_msg(char *buf);
619 void smb_set_enclen(char *buf,int len,uint16 enc_ctx_num);
620 void smb_setlen(char *buf,int len);
621 int set_message_bcc(char *buf,int num_bytes);
622 ssize_t message_push_blob(uint8 **outbuf, DATA_BLOB blob);
623 char *unix_clean_name(TALLOC_CTX *ctx, const char *s);
624 char *clean_name(TALLOC_CTX *ctx, const char *s);
625 ssize_t write_data_at_offset(int fd, const char *buffer, size_t N, SMB_OFF_T pos);
626 int set_blocking(int fd, bool set);
627 NTSTATUS reinit_after_fork(struct messaging_context *msg_ctx,
628                            struct event_context *ev_ctx,
629                            struct server_id id,
630                            bool parent_longlived);
631 void *malloc_(size_t size);
632 void *memalign_array(size_t el_size, size_t align, unsigned int count);
633 void *calloc_array(size_t size, size_t nmemb);
634 void *Realloc(void *p, size_t size, bool free_old_on_error);
635 void add_to_large_array(TALLOC_CTX *mem_ctx, size_t element_size,
636                         void *element, void *_array, uint32 *num_elements,
637                         ssize_t *array_size);
638 char *get_myname(TALLOC_CTX *ctx);
639 char *get_mydnsdomname(TALLOC_CTX *ctx);
640 int interpret_protocol(const char *str,int def);
641 char *automount_lookup(TALLOC_CTX *ctx, const char *user_name);
642 char *automount_lookup(TALLOC_CTX *ctx, const char *user_name);
643 bool process_exists(const struct server_id pid);
644 const char *uidtoname(uid_t uid);
645 char *gidtoname(gid_t gid);
646 uid_t nametouid(const char *name);
647 gid_t nametogid(const char *name);
648 void smb_panic_s3(const char *why);
649 void log_stack_trace(void);
650 const char *readdirname(SMB_STRUCT_DIR *p);
651 bool is_in_path(const char *name, name_compare_entry *namelist, bool case_sensitive);
652 void set_namearray(name_compare_entry **ppname_array, const char *namelist);
653 void free_namearray(name_compare_entry *name_array);
654 bool fcntl_lock(int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type);
655 bool fcntl_getlock(int fd, SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid);
656 bool is_myname(const char *s);
657 bool is_myworkgroup(const char *s);
658 void ra_lanman_string( const char *native_lanman );
659 const char *get_remote_arch_str(void);
660 void set_remote_arch(enum remote_arch_types type);
661 enum remote_arch_types get_remote_arch(void);
662 const char *tab_depth(int level, int depth);
663 int str_checksum(const char *s);
664 void zero_free(void *p, size_t size);
665 int set_maxfiles(int requested_max);
666 int smb_mkstemp(char *name_template);
667 void *smb_xmalloc_array(size_t size, unsigned int count);
668 char *myhostname(void);
669 char *lock_path(const char *name);
670 char *pid_path(const char *name);
671 char *lib_path(const char *name);
672 char *modules_path(const char *name);
673 char *data_path(const char *name);
674 char *state_path(const char *name);
675 char *cache_path(const char *name);
676 const char *shlib_ext(void);
677 bool parent_dirname(TALLOC_CTX *mem_ctx, const char *dir, char **parent,
678                     const char **name);
679 bool ms_has_wild(const char *s);
680 bool ms_has_wild_w(const smb_ucs2_t *s);
681 bool mask_match(const char *string, const char *pattern, bool is_case_sensitive);
682 bool mask_match_search(const char *string, const char *pattern, bool is_case_sensitive);
683 bool mask_match_list(const char *string, char **list, int listLen, bool is_case_sensitive);
684 bool unix_wild_match(const char *pattern, const char *string);
685 bool name_to_fqdn(fstring fqdn, const char *name);
686 void *talloc_append_blob(TALLOC_CTX *mem_ctx, void *buf, DATA_BLOB blob);
687 uint32 map_share_mode_to_deny_mode(uint32 share_access, uint32 private_options);
688 pid_t procid_to_pid(const struct server_id *proc);
689 void set_my_vnn(uint32 vnn);
690 uint32 get_my_vnn(void);
691 void set_my_unique_id(uint64_t unique_id);
692 struct server_id pid_to_procid(pid_t pid);
693 struct server_id procid_self(void);
694 bool procid_equal(const struct server_id *p1, const struct server_id *p2);
695 bool cluster_id_equal(const struct server_id *id1,
696                       const struct server_id *id2);
697 bool procid_is_me(const struct server_id *pid);
698 struct server_id interpret_pid(const char *pid_string);
699 char *procid_str(TALLOC_CTX *mem_ctx, const struct server_id *pid);
700 char *procid_str_static(const struct server_id *pid);
701 bool procid_valid(const struct server_id *pid);
702 bool procid_is_local(const struct server_id *pid);
703 bool trans_oob(uint32_t bufsize, uint32_t offset, uint32_t length);
704 bool is_offset_safe(const char *buf_base, size_t buf_len, char *ptr, size_t off);
705 char *get_safe_ptr(const char *buf_base, size_t buf_len, char *ptr, size_t off);
706 char *get_safe_str_ptr(const char *buf_base, size_t buf_len, char *ptr, size_t off);
707 int get_safe_SVAL(const char *buf_base, size_t buf_len, char *ptr, size_t off, int failval);
708 int get_safe_IVAL(const char *buf_base, size_t buf_len, char *ptr, size_t off, int failval);
709 void split_domain_user(TALLOC_CTX *mem_ctx,
710                        const char *full_name,
711                        char **domain,
712                        char **user);
713 void *_talloc_zero_zeronull(const void *ctx, size_t size, const char *name);
714 void *_talloc_memdup_zeronull(const void *t, const void *p, size_t size, const char *name);
715 void *_talloc_array_zeronull(const void *ctx, size_t el_size, unsigned count, const char *name);
716 void *_talloc_zero_array_zeronull(const void *ctx, size_t el_size, unsigned count, const char *name);
717 void *talloc_zeronull(const void *context, size_t size, const char *name);
718 const char *strip_hostname(const char *s);
719 bool tevent_req_poll_ntstatus(struct tevent_req *req,
720                               struct tevent_context *ev,
721                               NTSTATUS *status);
722 bool any_nt_status_not_ok(NTSTATUS err1, NTSTATUS err2, NTSTATUS *result);
723 int timeval_to_msec(struct timeval t);
724 char *valid_share_pathname(TALLOC_CTX *ctx, const char *dos_pathname);
725
726 /* The following definitions come from lib/util_cmdline.c  */
727
728 struct user_auth_info *user_auth_info_init(TALLOC_CTX *mem_ctx);
729 const char *get_cmdline_auth_info_username(const struct user_auth_info *auth_info);
730 void set_cmdline_auth_info_username(struct user_auth_info *auth_info,
731                                     const char *username);
732 const char *get_cmdline_auth_info_domain(const struct user_auth_info *auth_info);
733 void set_cmdline_auth_info_domain(struct user_auth_info *auth_info,
734                                   const char *domain);
735 void set_cmdline_auth_info_password(struct user_auth_info *auth_info,
736                                     const char *password);
737 const char *get_cmdline_auth_info_password(const struct user_auth_info *auth_info);
738 bool set_cmdline_auth_info_signing_state(struct user_auth_info *auth_info,
739                                          const char *arg);
740 int get_cmdline_auth_info_signing_state(const struct user_auth_info *auth_info);
741 void set_cmdline_auth_info_use_ccache(struct user_auth_info *auth_info,
742                                       bool b);
743 bool get_cmdline_auth_info_use_ccache(const struct user_auth_info *auth_info);
744 void set_cmdline_auth_info_use_kerberos(struct user_auth_info *auth_info,
745                                         bool b);
746 bool get_cmdline_auth_info_use_kerberos(const struct user_auth_info *auth_info);
747 void set_cmdline_auth_info_fallback_after_kerberos(struct user_auth_info *auth_info,
748                                         bool b);
749 bool get_cmdline_auth_info_fallback_after_kerberos(const struct user_auth_info *auth_info);
750 void set_cmdline_auth_info_use_krb5_ticket(struct user_auth_info *auth_info);
751 void set_cmdline_auth_info_smb_encrypt(struct user_auth_info *auth_info);
752 void set_cmdline_auth_info_use_machine_account(struct user_auth_info *auth_info);
753 bool get_cmdline_auth_info_got_pass(const struct user_auth_info *auth_info);
754 bool get_cmdline_auth_info_smb_encrypt(const struct user_auth_info *auth_info);
755 bool get_cmdline_auth_info_use_machine_account(const struct user_auth_info *auth_info);
756 struct user_auth_info *get_cmdline_auth_info_copy(TALLOC_CTX *mem_ctx,
757                                                  const struct user_auth_info *info);
758 bool set_cmdline_auth_info_machine_account_creds(struct user_auth_info *auth_info);
759 void set_cmdline_auth_info_getpass(struct user_auth_info *auth_info);
760
761 /* The following definitions come from lib/util_builtin.c  */
762
763 bool lookup_builtin_rid(TALLOC_CTX *mem_ctx, uint32 rid, const char **name);
764 bool lookup_builtin_name(const char *name, uint32 *rid);
765 const char *builtin_domain_name(void);
766 bool sid_check_is_builtin(const struct dom_sid *sid);
767 bool sid_check_is_in_builtin(const struct dom_sid *sid);
768
769 /* The following definitions come from lib/util_file.c  */
770
771 char **file_lines_pload(const char *syscmd, int *numlines);
772 void file_lines_free(char **lines);
773
774 /* The following definitions come from lib/util_nscd.c  */
775
776 void smb_nscd_flush_user_cache(void);
777 void smb_nscd_flush_group_cache(void);
778
779 /* The following definitions come from lib/util_nttoken.c  */
780
781 struct security_token *dup_nt_token(TALLOC_CTX *mem_ctx, const struct security_token *ptoken);
782 NTSTATUS merge_nt_token(TALLOC_CTX *mem_ctx,
783                         const struct security_token *token_1,
784                         const struct security_token *token_2,
785                         struct security_token **token_out);
786 bool token_sid_in_ace(const struct security_token *token, const struct security_ace *ace);
787
788 /* The following definitions come from lib/util_sec.c  */
789
790 void sec_init(void);
791 uid_t sec_initial_uid(void);
792 gid_t sec_initial_gid(void);
793 bool non_root_mode(void);
794 void gain_root_privilege(void);
795 void gain_root_group_privilege(void);
796 void set_effective_uid(uid_t uid);
797 void set_effective_gid(gid_t gid);
798 void save_re_uid(void);
799 void restore_re_uid_fromroot(void);
800 void restore_re_uid(void);
801 void save_re_gid(void);
802 void restore_re_gid(void);
803 int set_re_uid(void);
804 void become_user_permanently(uid_t uid, gid_t gid);
805 bool is_setuid_root(void) ;
806
807 /* The following definitions come from lib/util_sid.c  */
808
809 char *sid_to_fstring(fstring sidstr_out, const struct dom_sid *sid);
810 char *sid_string_talloc(TALLOC_CTX *mem_ctx, const struct dom_sid *sid);
811 char *sid_string_dbg(const struct dom_sid *sid);
812 char *sid_string_tos(const struct dom_sid *sid);
813 bool sid_linearize(char *outbuf, size_t len, const struct dom_sid *sid);
814 bool non_mappable_sid(struct dom_sid *sid);
815 char *sid_binstring_hex(const struct dom_sid *sid);
816 struct netr_SamInfo3;
817 NTSTATUS sid_array_from_info3(TALLOC_CTX *mem_ctx,
818                               const struct netr_SamInfo3 *info3,
819                               struct dom_sid **user_sids,
820                               uint32_t *num_user_sids,
821                               bool include_user_group_rid,
822                               bool skip_ressource_groups);
823
824 /* The following definitions come from lib/util_sock.c  */
825
826 bool is_broadcast_addr(const struct sockaddr *pss);
827 bool is_loopback_ip_v4(struct in_addr ip);
828 bool is_loopback_addr(const struct sockaddr *pss);
829 bool is_zero_addr(const struct sockaddr_storage *pss);
830 void zero_ip_v4(struct in_addr *ip);
831 void in_addr_to_sockaddr_storage(struct sockaddr_storage *ss,
832                 struct in_addr ip);
833 bool same_net(const struct sockaddr *ip1,
834                 const struct sockaddr *ip2,
835                 const struct sockaddr *mask);
836 bool sockaddr_equal(const struct sockaddr *ip1,
837                 const struct sockaddr *ip2);
838 bool is_address_any(const struct sockaddr *psa);
839 uint16_t get_sockaddr_port(const struct sockaddr_storage *pss);
840 char *print_sockaddr(char *dest,
841                         size_t destlen,
842                         const struct sockaddr_storage *psa);
843 char *print_canonical_sockaddr(TALLOC_CTX *ctx,
844                         const struct sockaddr_storage *pss);
845 const char *client_name(int fd);
846 int get_socket_port(int fd);
847 const char *client_addr(int fd, char *addr, size_t addrlen);
848 const char *client_socket_addr(int fd, char *addr, size_t addr_len);
849 int client_socket_port(int fd);
850 void set_smb_read_error(enum smb_read_errors *pre,
851                         enum smb_read_errors newerr);
852 void cond_set_smb_read_error(enum smb_read_errors *pre,
853                         enum smb_read_errors newerr);
854 bool is_a_socket(int fd);
855 void set_socket_options(int fd, const char *options);
856 ssize_t read_udp_v4_socket(int fd,
857                         char *buf,
858                         size_t len,
859                         struct sockaddr_storage *psa);
860 NTSTATUS read_fd_with_timeout(int fd, char *buf,
861                                   size_t mincnt, size_t maxcnt,
862                                   unsigned int time_out,
863                                   size_t *size_ret);
864 NTSTATUS read_data(int fd, char *buffer, size_t N);
865 ssize_t write_data(int fd, const char *buffer, size_t N);
866 ssize_t write_data_iov(int fd, const struct iovec *orig_iov, int iovcnt);
867 bool send_keepalive(int client);
868 NTSTATUS read_smb_length_return_keepalive(int fd, char *inbuf,
869                                           unsigned int timeout,
870                                           size_t *len);
871 NTSTATUS receive_smb_raw(int fd,
872                         char *buffer,
873                         size_t buflen,
874                         unsigned int timeout,
875                         size_t maxlen,
876                         size_t *p_len);
877 int open_socket_in(int type,
878                 uint16_t port,
879                 int dlevel,
880                 const struct sockaddr_storage *psock,
881                 bool rebind);
882 NTSTATUS open_socket_out(const struct sockaddr_storage *pss, uint16_t port,
883                          int timeout, int *pfd);
884 struct tevent_req *open_socket_out_send(TALLOC_CTX *mem_ctx,
885                                         struct event_context *ev,
886                                         const struct sockaddr_storage *pss,
887                                         uint16_t port,
888                                         int timeout);
889 NTSTATUS open_socket_out_recv(struct tevent_req *req, int *pfd);
890 struct tevent_req *open_socket_out_defer_send(TALLOC_CTX *mem_ctx,
891                                               struct event_context *ev,
892                                               struct timeval wait_time,
893                                               const struct sockaddr_storage *pss,
894                                               uint16_t port,
895                                               int timeout);
896 NTSTATUS open_socket_out_defer_recv(struct tevent_req *req, int *pfd);
897 int open_udp_socket(const char *host, int port);
898 const char *get_peer_name(int fd, bool force_lookup);
899 const char *get_peer_addr(int fd, char *addr, size_t addr_len);
900 int create_pipe_sock(const char *socket_dir,
901                      const char *socket_name,
902                      mode_t dir_perms);
903 const char *get_mydnsfullname(void);
904 bool is_myname_or_ipaddr(const char *s);
905 struct tevent_req *getaddrinfo_send(TALLOC_CTX *mem_ctx,
906                                     struct tevent_context *ev,
907                                     struct fncall_context *ctx,
908                                     const char *node,
909                                     const char *service,
910                                     const struct addrinfo *hints);
911 int getaddrinfo_recv(struct tevent_req *req, struct addrinfo **res);
912 int poll_one_fd(int fd, int events, int timeout, int *revents);
913 int poll_intr_one_fd(int fd, int events, int timeout, int *revents);
914 struct tstream_context;
915 struct tevent_req *tstream_read_packet_send(TALLOC_CTX *mem_ctx,
916                                             struct tevent_context *ev,
917                                             struct tstream_context *stream,
918                                             size_t initial,
919                                             ssize_t (*more)(uint8_t *buf,
920                                                             size_t buflen,
921                                                             void *private_data),
922                                             void *private_data);
923 ssize_t tstream_read_packet_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
924                                  uint8_t **pbuf, int *perrno);
925
926 /* The following definitions come from lib/util_str.c  */
927
928 bool next_token(const char **ptr, char *buff, const char *sep, size_t bufsize);
929 int StrCaseCmp(const char *s, const char *t);
930 int StrnCaseCmp(const char *s, const char *t, size_t len);
931 bool strnequal(const char *s1,const char *s2,size_t n);
932 bool strcsequal(const char *s1,const char *s2);
933 void strnorm(char *s, int case_default);
934 char *push_skip_string(char *buf);
935 char *skip_string(const char *base, size_t len, char *buf);
936 size_t str_charnum(const char *s);
937 bool trim_char(char *s,char cfront,char cback);
938 bool strhasupper(const char *s);
939 bool strhaslower(const char *s);
940 char *safe_strcpy_fn(char *dest,
941                 const char *src,
942                 size_t maxlength);
943 char *safe_strcat_fn(char *dest,
944                 const char *src,
945                 size_t maxlength);
946 char *StrnCpy(char *dest,const char *src,size_t n);
947 bool in_list(const char *s, const char *list, bool casesensitive);
948 void string_free(char **s);
949 bool string_set(char **dest,const char *src);
950 void fstring_sub(char *s,const char *pattern,const char *insert);
951 char *realloc_string_sub2(char *string,
952                         const char *pattern,
953                         const char *insert,
954                         bool remove_unsafe_characters,
955                         bool allow_trailing_dollar);
956 char *realloc_string_sub(char *string,
957                         const char *pattern,
958                         const char *insert);
959 char *talloc_string_sub2(TALLOC_CTX *mem_ctx, const char *src,
960                         const char *pattern,
961                         const char *insert,
962                         bool remove_unsafe_characters,
963                         bool replace_once,
964                         bool allow_trailing_dollar);
965 char *talloc_string_sub(TALLOC_CTX *mem_ctx,
966                         const char *src,
967                         const char *pattern,
968                         const char *insert);
969 void all_string_sub(char *s,const char *pattern,const char *insert, size_t len);
970 char *talloc_all_string_sub(TALLOC_CTX *ctx,
971                                 const char *src,
972                                 const char *pattern,
973                                 const char *insert);
974 char *octal_string(int i);
975 char *string_truncate(char *s, unsigned int length);
976 char *strchr_m(const char *src, char c);
977 char *strrchr_m(const char *s, char c);
978 char *strnrchr_m(const char *s, char c, unsigned int n);
979 char *strstr_m(const char *src, const char *findstr);
980 void strlower_m(char *s);
981 void strupper_m(char *s);
982 size_t strlen_m(const char *s);
983 size_t strlen_m_term(const char *s);
984 size_t strlen_m_term_null(const char *s);
985 int fstr_sprintf(fstring s, const char *fmt, ...);
986 bool str_list_sub_basic( char **list, const char *smb_name,
987                          const char *domain_name );
988 bool str_list_substitute(char **list, const char *pattern, const char *insert);
989
990 char *ipstr_list_make(char **ipstr_list,
991                         const struct ip_service *ip_list,
992                         int ip_count);
993 int ipstr_list_parse(const char *ipstr_list, struct ip_service **ip_list);
994 void ipstr_list_free(char* ipstr_list);
995 uint64_t STR_TO_SMB_BIG_UINT(const char *nptr, const char **entptr);
996 uint64_t conv_str_size(const char * str);
997 bool add_string_to_array(TALLOC_CTX *mem_ctx,
998                          const char *str, const char ***strings,
999                          int *num);
1000 void sprintf_append(TALLOC_CTX *mem_ctx, char **string, ssize_t *len,
1001                     size_t *bufsize, const char *fmt, ...);
1002 int asprintf_strupper_m(char **strp, const char *fmt, ...);
1003 char *talloc_asprintf_strupper_m(TALLOC_CTX *t, const char *fmt, ...);
1004 char *talloc_asprintf_strlower_m(TALLOC_CTX *t, const char *fmt, ...);
1005 char *sstring_sub(const char *src, char front, char back);
1006 bool validate_net_name( const char *name,
1007                 const char *invalid_chars,
1008                 int max_len);
1009 char *escape_shell_string(const char *src);
1010 char **str_list_make_v3(TALLOC_CTX *mem_ctx, const char *string, const char *sep);
1011 char *sanitize_username(TALLOC_CTX *mem_ctx, const char *username);
1012
1013 /* The following definitions come from lib/version.c  */
1014
1015 const char *samba_version_string(void);
1016
1017 /* The following definitions come from lib/wins_srv.c  */
1018
1019 bool wins_srv_is_dead(struct in_addr wins_ip, struct in_addr src_ip);
1020 void wins_srv_alive(struct in_addr wins_ip, struct in_addr src_ip);
1021 void wins_srv_died(struct in_addr wins_ip, struct in_addr src_ip);
1022 unsigned wins_srv_count(void);
1023 char **wins_srv_tags(void);
1024 void wins_srv_tags_free(char **list);
1025 struct in_addr wins_srv_ip_tag(const char *tag, struct in_addr src_ip);
1026 unsigned wins_srv_count_tag(const char *tag);
1027
1028 /* The following definitions come from libsmb/cliconnect.c  */
1029
1030 ADS_STATUS cli_session_setup_spnego(struct cli_state *cli, const char *user, 
1031                               const char *pass, const char *user_domain,
1032                                     const char * dest_realm);
1033
1034 NTSTATUS cli_session_setup(struct cli_state *cli,
1035                            const char *user,
1036                            const char *pass, int passlen,
1037                            const char *ntpass, int ntpasslen,
1038                            const char *workgroup);
1039 struct tevent_req *cli_session_setup_guest_create(TALLOC_CTX *mem_ctx,
1040                                                   struct event_context *ev,
1041                                                   struct cli_state *cli,
1042                                                   struct tevent_req **psmbreq);
1043 struct tevent_req *cli_session_setup_guest_send(TALLOC_CTX *mem_ctx,
1044                                                 struct event_context *ev,
1045                                                 struct cli_state *cli);
1046 NTSTATUS cli_session_setup_guest_recv(struct tevent_req *req);
1047 struct tevent_req *cli_ulogoff_send(TALLOC_CTX *mem_ctx,
1048                                     struct tevent_context *ev,
1049                                     struct cli_state *cli);
1050 NTSTATUS cli_ulogoff_recv(struct tevent_req *req);
1051 NTSTATUS cli_ulogoff(struct cli_state *cli);
1052 struct tevent_req *cli_tcon_andx_create(TALLOC_CTX *mem_ctx,
1053                                         struct event_context *ev,
1054                                         struct cli_state *cli,
1055                                         const char *share, const char *dev,
1056                                         const char *pass, int passlen,
1057                                         struct tevent_req **psmbreq);
1058 struct tevent_req *cli_tcon_andx_send(TALLOC_CTX *mem_ctx,
1059                                       struct event_context *ev,
1060                                       struct cli_state *cli,
1061                                       const char *share, const char *dev,
1062                                       const char *pass, int passlen);
1063 NTSTATUS cli_tcon_andx_recv(struct tevent_req *req);
1064 NTSTATUS cli_tcon_andx(struct cli_state *cli, const char *share,
1065                        const char *dev, const char *pass, int passlen);
1066 struct tevent_req *cli_tdis_send(TALLOC_CTX *mem_ctx,
1067                                  struct tevent_context *ev,
1068                                  struct cli_state *cli);
1069 NTSTATUS cli_tdis_recv(struct tevent_req *req);
1070 NTSTATUS cli_tdis(struct cli_state *cli);
1071 NTSTATUS cli_negprot(struct cli_state *cli);
1072 struct tevent_req *cli_negprot_send(TALLOC_CTX *mem_ctx,
1073                                     struct event_context *ev,
1074                                     struct cli_state *cli);
1075 NTSTATUS cli_negprot_recv(struct tevent_req *req);
1076 bool cli_session_request(struct cli_state *cli,
1077                          struct nmb_name *calling, struct nmb_name *called);
1078 NTSTATUS cli_connect(struct cli_state *cli,
1079                 const char *host,
1080                 struct sockaddr_storage *dest_ss);
1081 NTSTATUS cli_start_connection(struct cli_state **output_cli, 
1082                               const char *my_name, 
1083                               const char *dest_host, 
1084                               struct sockaddr_storage *dest_ss, int port,
1085                               int signing_state, int flags);
1086 NTSTATUS cli_full_connection(struct cli_state **output_cli, 
1087                              const char *my_name, 
1088                              const char *dest_host, 
1089                              struct sockaddr_storage *dest_ss, int port,
1090                              const char *service, const char *service_type,
1091                              const char *user, const char *domain, 
1092                              const char *password, int flags,
1093                              int signing_state);
1094 bool attempt_netbios_session_request(struct cli_state **ppcli, const char *srchost, const char *desthost,
1095                                      struct sockaddr_storage *pdest_ss);
1096 NTSTATUS cli_raw_tcon(struct cli_state *cli, 
1097                       const char *service, const char *pass, const char *dev,
1098                       uint16 *max_xmit, uint16 *tid);
1099 struct cli_state *get_ipc_connect(char *server,
1100                                 struct sockaddr_storage *server_ss,
1101                                 const struct user_auth_info *user_info);
1102 struct cli_state *get_ipc_connect_master_ip(TALLOC_CTX *ctx,
1103                                 struct sockaddr_storage *mb_ip,
1104                                 const struct user_auth_info *user_info,
1105                                 char **pp_workgroup_out);
1106 struct cli_state *get_ipc_connect_master_ip_bcast(TALLOC_CTX *ctx,
1107                                         const struct user_auth_info *user_info,
1108                                         char **pp_workgroup_out);
1109
1110 /* The following definitions come from libsmb/clidfs.c  */
1111
1112 NTSTATUS cli_cm_force_encryption(struct cli_state *c,
1113                         const char *username,
1114                         const char *password,
1115                         const char *domain,
1116                         const char *sharename);
1117 struct cli_state *cli_cm_open(TALLOC_CTX *ctx,
1118                                 struct cli_state *referring_cli,
1119                                 const char *server,
1120                                 const char *share,
1121                                 const struct user_auth_info *auth_info,
1122                                 bool show_hdr,
1123                                 bool force_encrypt,
1124                                 int max_protocol,
1125                                 int port,
1126                                 int name_type);
1127 void cli_cm_display(const struct cli_state *c);
1128 struct client_dfs_referral;
1129 NTSTATUS cli_dfs_get_referral(TALLOC_CTX *ctx,
1130                         struct cli_state *cli,
1131                         const char *path,
1132                         struct client_dfs_referral **refs,
1133                         size_t *num_refs,
1134                         size_t *consumed);
1135 bool cli_resolve_path(TALLOC_CTX *ctx,
1136                         const char *mountpt,
1137                         const struct user_auth_info *dfs_auth_info,
1138                         struct cli_state *rootcli,
1139                         const char *path,
1140                         struct cli_state **targetcli,
1141                         char **pp_targetpath);
1142
1143 bool cli_check_msdfs_proxy(TALLOC_CTX *ctx,
1144                         struct cli_state *cli,
1145                         const char *sharename,
1146                         char **pp_newserver,
1147                         char **pp_newshare,
1148                         bool force_encrypt,
1149                         const char *username,
1150                         const char *password,
1151                         const char *domain);
1152
1153 /* The following definitions come from libsmb/clientgen.c  */
1154
1155 int cli_set_message(char *buf,int num_words,int num_bytes,bool zero);
1156 unsigned int cli_set_timeout(struct cli_state *cli, unsigned int timeout);
1157 void cli_set_port(struct cli_state *cli, int port);
1158 bool cli_state_seqnum_persistent(struct cli_state *cli,
1159                                  uint16_t mid);
1160 bool cli_state_seqnum_remove(struct cli_state *cli,
1161                              uint16_t mid);
1162 bool cli_receive_smb(struct cli_state *cli);
1163 bool cli_send_smb(struct cli_state *cli);
1164 void cli_setup_packet_buf(struct cli_state *cli, char *buf);
1165 void cli_setup_packet(struct cli_state *cli);
1166 void cli_setup_bcc(struct cli_state *cli, void *p);
1167 NTSTATUS cli_set_domain(struct cli_state *cli, const char *domain);
1168 NTSTATUS cli_set_username(struct cli_state *cli, const char *username);
1169 NTSTATUS cli_set_password(struct cli_state *cli, const char *password);
1170 NTSTATUS cli_init_creds(struct cli_state *cli, const char *username, const char *domain, const char *password);
1171 struct cli_state *cli_initialise(void);
1172 struct cli_state *cli_initialise_ex(int signing_state);
1173 void cli_nt_pipes_close(struct cli_state *cli);
1174 void cli_shutdown(struct cli_state *cli);
1175 void cli_sockopt(struct cli_state *cli, const char *options);
1176 uint16 cli_setpid(struct cli_state *cli, uint16 pid);
1177 bool cli_set_case_sensitive(struct cli_state *cli, bool case_sensitive);
1178 struct tevent_req *cli_echo_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
1179                                  struct cli_state *cli, uint16_t num_echos,
1180                                  DATA_BLOB data);
1181 NTSTATUS cli_echo_recv(struct tevent_req *req);
1182 NTSTATUS cli_echo(struct cli_state *cli, uint16_t num_echos, DATA_BLOB data);
1183 bool cli_ucs2(struct cli_state *cli);
1184 bool is_andx_req(uint8_t cmd);
1185 NTSTATUS cli_smb(TALLOC_CTX *mem_ctx, struct cli_state *cli,
1186                  uint8_t smb_command, uint8_t additional_flags,
1187                  uint8_t wct, uint16_t *vwv,
1188                  uint32_t num_bytes, const uint8_t *bytes,
1189                  struct tevent_req **result_parent,
1190                  uint8_t min_wct, uint8_t *pwct, uint16_t **pvwv,
1191                  uint32_t *pnum_bytes, uint8_t **pbytes);
1192
1193 /* The following definitions come from libsmb/clierror.c  */
1194
1195 const char *cli_errstr(struct cli_state *cli);
1196 NTSTATUS cli_nt_error(struct cli_state *cli);
1197 void cli_dos_error(struct cli_state *cli, uint8 *eclass, uint32 *ecode);
1198 int cli_errno(struct cli_state *cli);
1199 bool cli_is_error(struct cli_state *cli);
1200 bool cli_is_nt_error(struct cli_state *cli);
1201 bool cli_is_dos_error(struct cli_state *cli);
1202 NTSTATUS cli_get_nt_error(struct cli_state *cli);
1203 void cli_set_nt_error(struct cli_state *cli, NTSTATUS status);
1204 void cli_reset_error(struct cli_state *cli);
1205 bool cli_state_is_connected(struct cli_state *cli);
1206
1207 /* The following definitions come from libsmb/clifile.c  */
1208
1209 struct tevent_req *cli_setpathinfo_send(TALLOC_CTX *mem_ctx,
1210                                         struct tevent_context *ev,
1211                                         struct cli_state *cli,
1212                                         uint16_t level,
1213                                         const char *path,
1214                                         uint8_t *data,
1215                                         size_t data_len);
1216 NTSTATUS cli_setpathinfo_recv(struct tevent_req *req);
1217 NTSTATUS cli_setpathinfo(struct cli_state *cli,
1218                          uint16_t level,
1219                          const char *path,
1220                          uint8_t *data,
1221                          size_t data_len);
1222
1223 struct tevent_req *cli_posix_symlink_send(TALLOC_CTX *mem_ctx,
1224                                         struct event_context *ev,
1225                                         struct cli_state *cli,
1226                                         const char *oldname,
1227                                         const char *newname);
1228 NTSTATUS cli_posix_symlink_recv(struct tevent_req *req);
1229 NTSTATUS cli_posix_symlink(struct cli_state *cli,
1230                         const char *oldname,
1231                         const char *newname);
1232 struct tevent_req *cli_posix_readlink_send(TALLOC_CTX *mem_ctx,
1233                                         struct event_context *ev,
1234                                         struct cli_state *cli,
1235                                         const char *fname,
1236                                         size_t len);
1237 NTSTATUS cli_posix_readlink_recv(struct tevent_req *req, struct cli_state *cli,
1238                                 char *retpath, size_t len);
1239 NTSTATUS cli_posix_readlink(struct cli_state *cli, const char *fname,
1240                         char *linkpath, size_t len);
1241 struct tevent_req *cli_posix_hardlink_send(TALLOC_CTX *mem_ctx,
1242                                         struct event_context *ev,
1243                                         struct cli_state *cli,
1244                                         const char *oldname,
1245                                         const char *newname);
1246 NTSTATUS cli_posix_hardlink_recv(struct tevent_req *req);
1247 NTSTATUS cli_posix_hardlink(struct cli_state *cli,
1248                         const char *oldname,
1249                         const char *newname);
1250 uint32_t unix_perms_to_wire(mode_t perms);
1251 mode_t wire_perms_to_unix(uint32_t perms);
1252 struct tevent_req *cli_posix_getfacl_send(TALLOC_CTX *mem_ctx,
1253                                         struct event_context *ev,
1254                                         struct cli_state *cli,
1255                                         const char *fname);
1256 NTSTATUS cli_posix_getfacl_recv(struct tevent_req *req,
1257                                 TALLOC_CTX *mem_ctx,
1258                                 size_t *prb_size,
1259                                 char **retbuf);
1260 NTSTATUS cli_posix_getfacl(struct cli_state *cli,
1261                         const char *fname,
1262                         TALLOC_CTX *mem_ctx,
1263                         size_t *prb_size,
1264                         char **retbuf);
1265 struct tevent_req *cli_posix_stat_send(TALLOC_CTX *mem_ctx,
1266                                         struct event_context *ev,
1267                                         struct cli_state *cli,
1268                                         const char *fname);
1269 NTSTATUS cli_posix_stat_recv(struct tevent_req *req,
1270                                 SMB_STRUCT_STAT *sbuf);
1271 NTSTATUS cli_posix_stat(struct cli_state *cli,
1272                         const char *fname,
1273                         SMB_STRUCT_STAT *sbuf);
1274 struct tevent_req *cli_posix_chmod_send(TALLOC_CTX *mem_ctx,
1275                                         struct event_context *ev,
1276                                         struct cli_state *cli,
1277                                         const char *fname,
1278                                         mode_t mode);
1279 NTSTATUS cli_posix_chmod_recv(struct tevent_req *req);
1280 NTSTATUS cli_posix_chmod(struct cli_state *cli, const char *fname, mode_t mode);
1281 struct tevent_req *cli_posix_chown_send(TALLOC_CTX *mem_ctx,
1282                                         struct event_context *ev,
1283                                         struct cli_state *cli,
1284                                         const char *fname,
1285                                         uid_t uid,
1286                                         gid_t gid);
1287 NTSTATUS cli_posix_chown_recv(struct tevent_req *req);
1288 NTSTATUS cli_posix_chown(struct cli_state *cli,
1289                         const char *fname,
1290                         uid_t uid,
1291                         gid_t gid);
1292 struct tevent_req *cli_rename_send(TALLOC_CTX *mem_ctx,
1293                                 struct event_context *ev,
1294                                 struct cli_state *cli,
1295                                 const char *fname_src,
1296                                 const char *fname_dst);
1297 NTSTATUS cli_rename_recv(struct tevent_req *req);
1298 NTSTATUS cli_rename(struct cli_state *cli, const char *fname_src, const char *fname_dst);
1299 struct tevent_req *cli_ntrename_send(TALLOC_CTX *mem_ctx,
1300                                 struct event_context *ev,
1301                                 struct cli_state *cli,
1302                                 const char *fname_src,
1303                                 const char *fname_dst);
1304 NTSTATUS cli_ntrename_recv(struct tevent_req *req);
1305 NTSTATUS cli_ntrename(struct cli_state *cli, const char *fname_src, const char *fname_dst);
1306
1307 struct tevent_req *cli_nt_hardlink_send(TALLOC_CTX *mem_ctx,
1308                                 struct event_context *ev,
1309                                 struct cli_state *cli,
1310                                 const char *fname_src,
1311                                 const char *fname_dst);
1312 NTSTATUS cli_nt_hardlink_recv(struct tevent_req *req);
1313 NTSTATUS cli_nt_hardlink(struct cli_state *cli, const char *fname_src, const char *fname_dst);
1314
1315 struct tevent_req *cli_unlink_send(TALLOC_CTX *mem_ctx,
1316                                 struct event_context *ev,
1317                                 struct cli_state *cli,
1318                                 const char *fname,
1319                                 uint16_t mayhave_attrs);
1320 NTSTATUS cli_unlink_recv(struct tevent_req *req);
1321 NTSTATUS cli_unlink(struct cli_state *cli, const char *fname, uint16_t mayhave_attrs);
1322
1323 struct tevent_req *cli_mkdir_send(TALLOC_CTX *mem_ctx,
1324                                   struct event_context *ev,
1325                                   struct cli_state *cli,
1326                                   const char *dname);
1327 NTSTATUS cli_mkdir_recv(struct tevent_req *req);
1328 NTSTATUS cli_mkdir(struct cli_state *cli, const char *dname);
1329 struct tevent_req *cli_rmdir_send(TALLOC_CTX *mem_ctx,
1330                                   struct event_context *ev,
1331                                   struct cli_state *cli,
1332                                   const char *dname);
1333 NTSTATUS cli_rmdir_recv(struct tevent_req *req);
1334 NTSTATUS cli_rmdir(struct cli_state *cli, const char *dname);
1335 struct tevent_req *cli_nt_delete_on_close_send(TALLOC_CTX *mem_ctx,
1336                                         struct event_context *ev,
1337                                         struct cli_state *cli,
1338                                         uint16_t fnum,
1339                                         bool flag);
1340 NTSTATUS cli_nt_delete_on_close_recv(struct tevent_req *req);
1341 NTSTATUS cli_nt_delete_on_close(struct cli_state *cli, uint16_t fnum, bool flag);
1342 struct tevent_req *cli_ntcreate_send(TALLOC_CTX *mem_ctx,
1343                                      struct event_context *ev,
1344                                      struct cli_state *cli,
1345                                      const char *fname,
1346                                      uint32_t CreatFlags,
1347                                      uint32_t DesiredAccess,
1348                                      uint32_t FileAttributes,
1349                                      uint32_t ShareAccess,
1350                                      uint32_t CreateDisposition,
1351                                      uint32_t CreateOptions,
1352                                      uint8_t SecurityFlags);
1353 NTSTATUS cli_ntcreate_recv(struct tevent_req *req, uint16_t *pfnum);
1354 NTSTATUS cli_ntcreate(struct cli_state *cli,
1355                       const char *fname,
1356                       uint32_t CreatFlags,
1357                       uint32_t DesiredAccess,
1358                       uint32_t FileAttributes,
1359                       uint32_t ShareAccess,
1360                       uint32_t CreateDisposition,
1361                       uint32_t CreateOptions,
1362                       uint8_t SecurityFlags,
1363                       uint16_t *pfid);
1364 uint8_t *smb_bytes_push_str(uint8_t *buf, bool ucs2, const char *str,
1365                             size_t str_len, size_t *pconverted_size);
1366 uint8_t *smb_bytes_push_bytes(uint8_t *buf, uint8_t prefix,
1367                               const uint8_t *bytes, size_t num_bytes);
1368 struct tevent_req *cli_open_create(TALLOC_CTX *mem_ctx,
1369                                    struct event_context *ev,
1370                                    struct cli_state *cli, const char *fname,
1371                                    int flags, int share_mode,
1372                                    struct tevent_req **psmbreq);
1373 struct tevent_req *cli_open_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
1374                                  struct cli_state *cli, const char *fname,
1375                                  int flags, int share_mode);
1376 NTSTATUS cli_open_recv(struct tevent_req *req, uint16_t *fnum);
1377 NTSTATUS cli_open(struct cli_state *cli, const char *fname, int flags, int share_mode, uint16_t *pfnum);
1378 struct tevent_req *cli_close_create(TALLOC_CTX *mem_ctx,
1379                                     struct event_context *ev,
1380                                     struct cli_state *cli, uint16_t fnum,
1381                                     struct tevent_req **psubreq);
1382 struct tevent_req *cli_close_send(TALLOC_CTX *mem_ctx,
1383                                   struct event_context *ev,
1384                                   struct cli_state *cli, uint16_t fnum);
1385 NTSTATUS cli_close_recv(struct tevent_req *req);
1386 NTSTATUS cli_close(struct cli_state *cli, uint16_t fnum);
1387 struct tevent_req *cli_ftruncate_send(TALLOC_CTX *mem_ctx,
1388                                         struct event_context *ev,
1389                                         struct cli_state *cli,
1390                                         uint16_t fnum,
1391                                         uint64_t size);
1392 NTSTATUS cli_ftruncate_recv(struct tevent_req *req);
1393 NTSTATUS cli_ftruncate(struct cli_state *cli, uint16_t fnum, uint64_t size);
1394 NTSTATUS cli_locktype(struct cli_state *cli, uint16_t fnum,
1395                       uint32_t offset, uint32_t len,
1396                       int timeout, unsigned char locktype);
1397 bool cli_lock(struct cli_state *cli, uint16_t fnum,
1398               uint32_t offset, uint32_t len, int timeout, enum brl_type lock_type);
1399 struct tevent_req *cli_unlock_send(TALLOC_CTX *mem_ctx,
1400                                 struct event_context *ev,
1401                                 struct cli_state *cli,
1402                                 uint16_t fnum,
1403                                 uint64_t offset,
1404                                 uint64_t len);
1405 NTSTATUS cli_unlock_recv(struct tevent_req *req);
1406 NTSTATUS cli_unlock(struct cli_state *cli, uint16_t fnum, uint32_t offset, uint32_t len);
1407 bool cli_lock64(struct cli_state *cli, uint16_t fnum,
1408                 uint64_t offset, uint64_t len, int timeout, enum brl_type lock_type);
1409 struct tevent_req *cli_unlock64_send(TALLOC_CTX *mem_ctx,
1410                                 struct event_context *ev,
1411                                 struct cli_state *cli,
1412                                 uint16_t fnum,
1413                                 uint64_t offset,
1414                                 uint64_t len);
1415 NTSTATUS cli_unlock64_recv(struct tevent_req *req);
1416 NTSTATUS cli_unlock64(struct cli_state *cli, uint16_t fnum, uint64_t offset, uint64_t len);
1417 struct tevent_req *cli_posix_lock_send(TALLOC_CTX *mem_ctx,
1418                                         struct event_context *ev,
1419                                         struct cli_state *cli,
1420                                         uint16_t fnum,
1421                                         uint64_t offset,
1422                                         uint64_t len,
1423                                         bool wait_lock,
1424                                         enum brl_type lock_type);
1425 NTSTATUS cli_posix_lock_recv(struct tevent_req *req);
1426 NTSTATUS cli_posix_lock(struct cli_state *cli, uint16_t fnum,
1427                         uint64_t offset, uint64_t len,
1428                         bool wait_lock, enum brl_type lock_type);
1429 struct tevent_req *cli_posix_unlock_send(TALLOC_CTX *mem_ctx,
1430                                         struct event_context *ev,
1431                                         struct cli_state *cli,
1432                                         uint16_t fnum,
1433                                         uint64_t offset,
1434                                         uint64_t len);
1435 NTSTATUS cli_posix_unlock_recv(struct tevent_req *req);
1436 NTSTATUS cli_posix_unlock(struct cli_state *cli, uint16_t fnum, uint64_t offset, uint64_t len);
1437 struct tevent_req *cli_getattrE_send(TALLOC_CTX *mem_ctx,
1438                                 struct event_context *ev,
1439                                 struct cli_state *cli,
1440                                 uint16_t fnum);
1441 NTSTATUS cli_getattrE_recv(struct tevent_req *req,
1442                         uint16_t *attr,
1443                         SMB_OFF_T *size,
1444                         time_t *change_time,
1445                         time_t *access_time,
1446                         time_t *write_time);
1447 NTSTATUS cli_getattrE(struct cli_state *cli,
1448                         uint16_t fnum,
1449                         uint16_t *attr,
1450                         SMB_OFF_T *size,
1451                         time_t *change_time,
1452                         time_t *access_time,
1453                         time_t *write_time);
1454 struct tevent_req *cli_setattrE_send(TALLOC_CTX *mem_ctx,
1455                                 struct event_context *ev,
1456                                 struct cli_state *cli,
1457                                 uint16_t fnum,
1458                                 time_t change_time,
1459                                 time_t access_time,
1460                                 time_t write_time);
1461 NTSTATUS cli_setattrE_recv(struct tevent_req *req);
1462 NTSTATUS cli_setattrE(struct cli_state *cli,
1463                         uint16_t fnum,
1464                         time_t change_time,
1465                         time_t access_time,
1466                         time_t write_time);
1467 struct tevent_req *cli_getatr_send(TALLOC_CTX *mem_ctx,
1468                                 struct event_context *ev,
1469                                 struct cli_state *cli,
1470                                 const char *fname);
1471 NTSTATUS cli_getatr_recv(struct tevent_req *req,
1472                                 uint16_t *attr,
1473                                 SMB_OFF_T *size,
1474                                 time_t *write_time);
1475 NTSTATUS cli_getatr(struct cli_state *cli,
1476                         const char *fname,
1477                         uint16_t *attr,
1478                         SMB_OFF_T *size,
1479                         time_t *write_time);
1480 struct tevent_req *cli_setatr_send(TALLOC_CTX *mem_ctx,
1481                                 struct event_context *ev,
1482                                 struct cli_state *cli,
1483                                 const char *fname,
1484                                 uint16_t attr,
1485                                 time_t mtime);
1486 NTSTATUS cli_setatr_recv(struct tevent_req *req);
1487 NTSTATUS cli_setatr(struct cli_state *cli,
1488                 const char *fname,
1489                 uint16_t attr,
1490                 time_t mtime);
1491 struct tevent_req *cli_chkpath_send(TALLOC_CTX *mem_ctx,
1492                                   struct event_context *ev,
1493                                   struct cli_state *cli,
1494                                   const char *fname);
1495 NTSTATUS cli_chkpath_recv(struct tevent_req *req);
1496 NTSTATUS cli_chkpath(struct cli_state *cli, const char *path);
1497 struct tevent_req *cli_dskattr_send(TALLOC_CTX *mem_ctx,
1498                                   struct event_context *ev,
1499                                   struct cli_state *cli);
1500 NTSTATUS cli_dskattr_recv(struct tevent_req *req, int *bsize, int *total,
1501                           int *avail);
1502 NTSTATUS cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail);
1503 struct tevent_req *cli_ctemp_send(TALLOC_CTX *mem_ctx,
1504                                 struct event_context *ev,
1505                                 struct cli_state *cli,
1506                                 const char *path);
1507 NTSTATUS cli_ctemp_recv(struct tevent_req *req,
1508                         TALLOC_CTX *ctx,
1509                         uint16_t *pfnum,
1510                         char **outfile);
1511 NTSTATUS cli_ctemp(struct cli_state *cli,
1512                         TALLOC_CTX *ctx,
1513                         const char *path,
1514                         uint16_t *pfnum,
1515                         char **out_path);
1516 NTSTATUS cli_raw_ioctl(struct cli_state *cli, uint16_t fnum, uint32_t code, DATA_BLOB *blob);
1517 NTSTATUS cli_set_ea_path(struct cli_state *cli, const char *path,
1518                          const char *ea_name, const char *ea_val,
1519                          size_t ea_len);
1520 NTSTATUS cli_set_ea_fnum(struct cli_state *cli, uint16_t fnum,
1521                          const char *ea_name, const char *ea_val,
1522                          size_t ea_len);
1523 struct tevent_req *cli_get_ea_list_path_send(TALLOC_CTX *mem_ctx,
1524                                              struct tevent_context *ev,
1525                                              struct cli_state *cli,
1526                                              const char *fname);
1527 NTSTATUS cli_get_ea_list_path_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
1528                                    size_t *pnum_eas, struct ea_struct **peas);
1529 NTSTATUS cli_get_ea_list_path(struct cli_state *cli, const char *path,
1530                 TALLOC_CTX *ctx,
1531                 size_t *pnum_eas,
1532                 struct ea_struct **pea_list);
1533 struct tevent_req *cli_posix_open_send(TALLOC_CTX *mem_ctx,
1534                                         struct event_context *ev,
1535                                         struct cli_state *cli,
1536                                         const char *fname,
1537                                         int flags,
1538                                         mode_t mode);
1539 NTSTATUS cli_posix_open_recv(struct tevent_req *req, uint16_t *pfnum);
1540 NTSTATUS cli_posix_open(struct cli_state *cli, const char *fname,
1541                         int flags, mode_t mode, uint16_t *fnum);
1542 struct tevent_req *cli_posix_mkdir_send(TALLOC_CTX *mem_ctx,
1543                                         struct event_context *ev,
1544                                         struct cli_state *cli,
1545                                         const char *fname,
1546                                         mode_t mode);
1547 NTSTATUS cli_posix_mkdir_recv(struct tevent_req *req);
1548 NTSTATUS cli_posix_mkdir(struct cli_state *cli, const char *fname, mode_t mode);
1549
1550 struct tevent_req *cli_posix_unlink_send(TALLOC_CTX *mem_ctx,
1551                                         struct event_context *ev,
1552                                         struct cli_state *cli,
1553                                         const char *fname);
1554 NTSTATUS cli_posix_unlink_recv(struct tevent_req *req);
1555 NTSTATUS cli_posix_unlink(struct cli_state *cli, const char *fname);
1556
1557 struct tevent_req *cli_posix_rmdir_send(TALLOC_CTX *mem_ctx,
1558                                         struct event_context *ev,
1559                                         struct cli_state *cli,
1560                                         const char *fname);
1561 NTSTATUS cli_posix_rmdir_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx);
1562 NTSTATUS cli_posix_rmdir(struct cli_state *cli, const char *fname);
1563 struct tevent_req *cli_notify_send(TALLOC_CTX *mem_ctx,
1564                                    struct tevent_context *ev,
1565                                    struct cli_state *cli, uint16_t fnum,
1566                                    uint32_t buffer_size,
1567                                    uint32_t completion_filter, bool recursive);
1568 NTSTATUS cli_notify_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
1569                          uint32_t *pnum_changes,
1570                          struct notify_change **pchanges);
1571
1572 /* The following definitions come from libsmb/clifsinfo.c  */
1573
1574 struct tevent_req *cli_unix_extensions_version_send(TALLOC_CTX *mem_ctx,
1575                                                     struct tevent_context *ev,
1576                                                     struct cli_state *cli);
1577 NTSTATUS cli_unix_extensions_version_recv(struct tevent_req *req,
1578                                           uint16_t *pmajor, uint16_t *pminor,
1579                                           uint32_t *pcaplow,
1580                                           uint32_t *pcaphigh);
1581 NTSTATUS cli_unix_extensions_version(struct cli_state *cli, uint16 *pmajor,
1582                                      uint16 *pminor, uint32 *pcaplow,
1583                                      uint32 *pcaphigh);
1584 struct tevent_req *cli_set_unix_extensions_capabilities_send(
1585         TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct cli_state *cli,
1586         uint16_t major, uint16_t minor, uint32_t caplow, uint32_t caphigh);
1587 NTSTATUS cli_set_unix_extensions_capabilities_recv(struct tevent_req *req);
1588 NTSTATUS cli_set_unix_extensions_capabilities(struct cli_state *cli,
1589                                               uint16 major, uint16 minor,
1590                                               uint32 caplow, uint32 caphigh);
1591 struct tevent_req *cli_get_fs_attr_info_send(TALLOC_CTX *mem_ctx,
1592                                              struct tevent_context *ev,
1593                                              struct cli_state *cli);
1594 NTSTATUS cli_get_fs_attr_info_recv(struct tevent_req *req, uint32_t *fs_attr);
1595 NTSTATUS cli_get_fs_attr_info(struct cli_state *cli, uint32_t *fs_attr);
1596 NTSTATUS cli_get_fs_volume_info(struct cli_state *cli, fstring volume_name,
1597                                 uint32 *pserial_number, time_t *pdate);
1598 NTSTATUS cli_get_fs_full_size_info(struct cli_state *cli,
1599                                    uint64_t *total_allocation_units,
1600                                    uint64_t *caller_allocation_units,
1601                                    uint64_t *actual_allocation_units,
1602                                    uint64_t *sectors_per_allocation_unit,
1603                                    uint64_t *bytes_per_sector);
1604 NTSTATUS cli_get_posix_fs_info(struct cli_state *cli,
1605                                uint32 *optimal_transfer_size,
1606                                uint32 *block_size,
1607                                uint64_t *total_blocks,
1608                                uint64_t *blocks_available,
1609                                uint64_t *user_blocks_available,
1610                                uint64_t *total_file_nodes,
1611                                uint64_t *free_file_nodes,
1612                                uint64_t *fs_identifier);
1613 NTSTATUS cli_raw_ntlm_smb_encryption_start(struct cli_state *cli, 
1614                                 const char *user,
1615                                 const char *pass,
1616                                 const char *domain);
1617 NTSTATUS cli_gss_smb_encryption_start(struct cli_state *cli);
1618 NTSTATUS cli_force_encryption(struct cli_state *c,
1619                         const char *username,
1620                         const char *password,
1621                         const char *domain);
1622
1623 /* The following definitions come from libsmb/clilist.c  */
1624
1625 NTSTATUS cli_list_old(struct cli_state *cli,const char *Mask,uint16 attribute,
1626                       NTSTATUS (*fn)(const char *, struct file_info *,
1627                                  const char *, void *), void *state);
1628 NTSTATUS cli_list_trans(struct cli_state *cli, const char *mask,
1629                         uint16_t attribute, int info_level,
1630                         NTSTATUS (*fn)(const char *mnt, struct file_info *finfo,
1631                                    const char *mask, void *private_data),
1632                         void *private_data);
1633 struct tevent_req *cli_list_send(TALLOC_CTX *mem_ctx,
1634                                  struct tevent_context *ev,
1635                                  struct cli_state *cli,
1636                                  const char *mask,
1637                                  uint16_t attribute,
1638                                  uint16_t info_level);
1639 NTSTATUS cli_list_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
1640                        struct file_info **finfo, size_t *num_finfo);
1641 NTSTATUS cli_list(struct cli_state *cli,const char *Mask,uint16 attribute,
1642                   NTSTATUS (*fn)(const char *, struct file_info *, const char *,
1643                              void *), void *state);
1644
1645 /* The following definitions come from libsmb/climessage.c  */
1646
1647 struct tevent_req *cli_message_send(TALLOC_CTX *mem_ctx,
1648                                     struct tevent_context *ev,
1649                                     struct cli_state *cli,
1650                                     const char *host, const char *username,
1651                                     const char *message);
1652 NTSTATUS cli_message_recv(struct tevent_req *req);
1653 NTSTATUS cli_message(struct cli_state *cli, const char *host,
1654                      const char *username, const char *message);
1655
1656 /* The following definitions come from libsmb/clioplock.c  */
1657
1658 struct tevent_req *cli_oplock_ack_send(TALLOC_CTX *mem_ctx,
1659                                        struct tevent_context *ev,
1660                                        struct cli_state *cli,
1661                                        uint16_t fnum, uint8_t level);
1662 NTSTATUS cli_oplock_ack_recv(struct tevent_req *req);
1663 NTSTATUS cli_oplock_ack(struct cli_state *cli, uint16_t fnum, unsigned char level);
1664 void cli_oplock_handler(struct cli_state *cli, 
1665                         NTSTATUS (*handler)(struct cli_state *, uint16_t, unsigned char));
1666
1667 /* The following definitions come from libsmb/cliprint.c  */
1668
1669 int cli_print_queue(struct cli_state *cli,
1670                     void (*fn)(struct print_job_info *));
1671 int cli_printjob_del(struct cli_state *cli, int job);
1672
1673 /* The following definitions come from libsmb/cliquota.c  */
1674
1675 NTSTATUS cli_get_quota_handle(struct cli_state *cli, uint16_t *quota_fnum);
1676 void free_ntquota_list(SMB_NTQUOTA_LIST **qt_list);
1677 NTSTATUS cli_get_user_quota(struct cli_state *cli, int quota_fnum,
1678                             SMB_NTQUOTA_STRUCT *pqt);
1679 NTSTATUS cli_set_user_quota(struct cli_state *cli, int quota_fnum,
1680                             SMB_NTQUOTA_STRUCT *pqt);
1681 NTSTATUS cli_list_user_quota(struct cli_state *cli, int quota_fnum,
1682                              SMB_NTQUOTA_LIST **pqt_list);
1683 NTSTATUS cli_get_fs_quota_info(struct cli_state *cli, int quota_fnum,
1684                                SMB_NTQUOTA_STRUCT *pqt);
1685 NTSTATUS cli_set_fs_quota_info(struct cli_state *cli, int quota_fnum,
1686                                SMB_NTQUOTA_STRUCT *pqt);
1687
1688 /* The following definitions come from libsmb/clireadwrite.c  */
1689
1690 struct tevent_req *cli_read_andx_create(TALLOC_CTX *mem_ctx,
1691                                         struct event_context *ev,
1692                                         struct cli_state *cli, uint16_t fnum,
1693                                         off_t offset, size_t size,
1694                                         struct tevent_req **psmbreq);
1695 struct tevent_req *cli_read_andx_send(TALLOC_CTX *mem_ctx,
1696                                       struct event_context *ev,
1697                                       struct cli_state *cli, uint16_t fnum,
1698                                       off_t offset, size_t size);
1699 NTSTATUS cli_read_andx_recv(struct tevent_req *req, ssize_t *received,
1700                             uint8_t **rcvbuf);
1701 struct tevent_req *cli_pull_send(TALLOC_CTX *mem_ctx,
1702                                  struct event_context *ev,
1703                                  struct cli_state *cli,
1704                                  uint16_t fnum, off_t start_offset,
1705                                  SMB_OFF_T size, size_t window_size,
1706                                  NTSTATUS (*sink)(char *buf, size_t n,
1707                                                   void *priv),
1708                                  void *priv);
1709 NTSTATUS cli_pull_recv(struct tevent_req *req, SMB_OFF_T *received);
1710 NTSTATUS cli_pull(struct cli_state *cli, uint16_t fnum,
1711                   off_t start_offset, SMB_OFF_T size, size_t window_size,
1712                   NTSTATUS (*sink)(char *buf, size_t n, void *priv),
1713                   void *priv, SMB_OFF_T *received);
1714 ssize_t cli_read(struct cli_state *cli, uint16_t fnum, char *buf,
1715                  off_t offset, size_t size);
1716 NTSTATUS cli_smbwrite(struct cli_state *cli, uint16_t fnum, char *buf,
1717                       off_t offset, size_t size1, size_t *ptotal);
1718 struct tevent_req *cli_write_andx_create(TALLOC_CTX *mem_ctx,
1719                                          struct event_context *ev,
1720                                          struct cli_state *cli, uint16_t fnum,
1721                                          uint16_t mode, const uint8_t *buf,
1722                                          off_t offset, size_t size,
1723                                          struct tevent_req **reqs_before,
1724                                          int num_reqs_before,
1725                                          struct tevent_req **psmbreq);
1726 struct tevent_req *cli_write_andx_send(TALLOC_CTX *mem_ctx,
1727                                        struct event_context *ev,
1728                                        struct cli_state *cli, uint16_t fnum,
1729                                        uint16_t mode, const uint8_t *buf,
1730                                        off_t offset, size_t size);
1731 NTSTATUS cli_write_andx_recv(struct tevent_req *req, size_t *pwritten);
1732
1733 NTSTATUS cli_writeall(struct cli_state *cli, uint16_t fnum, uint16_t mode,
1734                       const uint8_t *buf, off_t offset, size_t size,
1735                       size_t *pwritten);
1736
1737 struct tevent_req *cli_push_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
1738                                  struct cli_state *cli,
1739                                  uint16_t fnum, uint16_t mode,
1740                                  off_t start_offset, size_t window_size,
1741                                  size_t (*source)(uint8_t *buf, size_t n,
1742                                                   void *priv),
1743                                  void *priv);
1744 NTSTATUS cli_push_recv(struct tevent_req *req);
1745 NTSTATUS cli_push(struct cli_state *cli, uint16_t fnum, uint16_t mode,
1746                   off_t start_offset, size_t window_size,
1747                   size_t (*source)(uint8_t *buf, size_t n, void *priv),
1748                   void *priv);
1749
1750 /* The following definitions come from libsmb/clisecdesc.c  */
1751
1752 struct security_descriptor *cli_query_secdesc(struct cli_state *cli, uint16_t fnum,
1753                             TALLOC_CTX *mem_ctx);
1754 NTSTATUS cli_set_secdesc(struct cli_state *cli, uint16_t fnum,
1755                          struct security_descriptor *sd);
1756
1757 /* The following definitions come from libsmb/clispnego.c  */
1758
1759 DATA_BLOB spnego_gen_negTokenInit(TALLOC_CTX *ctx,
1760                                   const char *OIDs[],
1761                                   DATA_BLOB *psecblob,
1762                                   const char *principal);
1763
1764 #ifndef ASN1_MAX_OIDS
1765 #define ASN1_MAX_OIDS 20
1766 #endif
1767 bool spnego_parse_negTokenInit(TALLOC_CTX *ctx,
1768                                DATA_BLOB blob,
1769                                char *OIDs[ASN1_MAX_OIDS],
1770                                char **principal,
1771                                DATA_BLOB *secblob);
1772 DATA_BLOB spnego_gen_krb5_wrap(TALLOC_CTX *ctx, const DATA_BLOB ticket, const uint8 tok_id[2]);
1773 bool spnego_parse_krb5_wrap(TALLOC_CTX *ctx, DATA_BLOB blob, DATA_BLOB *ticket, uint8 tok_id[2]);
1774 int spnego_gen_krb5_negTokenInit(TALLOC_CTX *ctx,
1775                             const char *principal, int time_offset,
1776                             DATA_BLOB *targ,
1777                             DATA_BLOB *session_key_krb5, uint32 extra_ap_opts,
1778                             time_t *expire_time);
1779 bool spnego_parse_challenge(TALLOC_CTX *ctx, const DATA_BLOB blob,
1780                             DATA_BLOB *chal1, DATA_BLOB *chal2);
1781 DATA_BLOB spnego_gen_auth(TALLOC_CTX *ctx, DATA_BLOB blob);
1782 bool spnego_parse_auth(TALLOC_CTX *ctx, DATA_BLOB blob, DATA_BLOB *auth);
1783 DATA_BLOB spnego_gen_auth_response(TALLOC_CTX *ctx, DATA_BLOB *reply, NTSTATUS nt_status,
1784                                    const char *mechOID);
1785 bool spnego_parse_auth_response(TALLOC_CTX *ctx,
1786                                 DATA_BLOB blob, NTSTATUS nt_status,
1787                                 const char *mechOID,
1788                                 DATA_BLOB *auth);
1789
1790 bool spnego_parse_auth_and_mic(TALLOC_CTX *ctx, DATA_BLOB blob,
1791                                 DATA_BLOB *auth, DATA_BLOB *signature);
1792 DATA_BLOB spnego_gen_auth_response_and_mic(TALLOC_CTX *ctx,
1793                                            NTSTATUS nt_status,
1794                                            const char *mechOID,
1795                                            DATA_BLOB *reply,
1796                                            DATA_BLOB *mechlistMIC);
1797 bool spnego_mech_list_blob(TALLOC_CTX *mem_ctx,
1798                            char **oid_list, DATA_BLOB *data);
1799
1800 /* The following definitions come from libsmb/clistr.c  */
1801
1802 size_t clistr_push_fn(struct cli_state *cli,
1803                         void *dest,
1804                         const char *src,
1805                         int dest_len,
1806                         int flags);
1807 size_t clistr_pull_fn(const char *inbuf,
1808                         char *dest,
1809                         const void *src,
1810                         int dest_len,
1811                         int src_len,
1812                         int flags);
1813 size_t clistr_pull_talloc(TALLOC_CTX *ctx,
1814                           const char *base,
1815                           uint16_t flags2,
1816                           char **pp_dest,
1817                           const void *src,
1818                           int src_len,
1819                           int flags);
1820 size_t clistr_align_out(struct cli_state *cli, const void *p, int flags);
1821
1822 /* The following definitions come from libsmb/clitrans.c  */
1823
1824 struct tevent_req *cli_trans_send(
1825         TALLOC_CTX *mem_ctx, struct event_context *ev,
1826         struct cli_state *cli, uint8_t cmd,
1827         const char *pipe_name, uint16_t fid, uint16_t function, int flags,
1828         uint16_t *setup, uint8_t num_setup, uint8_t max_setup,
1829         uint8_t *param, uint32_t num_param, uint32_t max_param,
1830         uint8_t *data, uint32_t num_data, uint32_t max_data);
1831 NTSTATUS cli_trans_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
1832                         uint16_t *recv_flags2,
1833                         uint16_t **setup, uint8_t min_setup,
1834                         uint8_t *num_setup,
1835                         uint8_t **param, uint32_t min_param,
1836                         uint32_t *num_param,
1837                         uint8_t **data, uint32_t min_data,
1838                         uint32_t *num_data);
1839 NTSTATUS cli_trans(TALLOC_CTX *mem_ctx, struct cli_state *cli,
1840                    uint8_t trans_cmd,
1841                    const char *pipe_name, uint16_t fid, uint16_t function,
1842                    int flags,
1843                    uint16_t *setup, uint8_t num_setup, uint8_t max_setup,
1844                    uint8_t *param, uint32_t num_param, uint32_t max_param,
1845                    uint8_t *data, uint32_t num_data, uint32_t max_data,
1846                    uint16_t *recv_flags2,
1847                    uint16_t **rsetup, uint8_t min_rsetup, uint8_t *num_rsetup,
1848                    uint8_t **rparam, uint32_t min_rparam, uint32_t *num_rparam,
1849                    uint8_t **rdata, uint32_t min_rdata, uint32_t *num_rdata);
1850
1851 /* The following definitions come from libsmb/conncache.c  */
1852
1853 NTSTATUS check_negative_conn_cache( const char *domain, const char *server);
1854 void add_failed_connection_entry(const char *domain, const char *server, NTSTATUS result) ;
1855 void flush_negative_conn_cache_for_domain(const char *domain);
1856
1857 /* The following definitions come from libsmb/dsgetdcname.c  */
1858
1859 struct netr_DsRGetDCNameInfo;
1860
1861 void debug_dsdcinfo_flags(int lvl, uint32_t flags);
1862 NTSTATUS dsgetdcname(TALLOC_CTX *mem_ctx,
1863                      struct messaging_context *msg_ctx,
1864                      const char *domain_name,
1865                      const struct GUID *domain_guid,
1866                      const char *site_name,
1867                      uint32_t flags,
1868                      struct netr_DsRGetDCNameInfo **info);
1869
1870 /* The following definitions come from libsmb/errormap.c  */
1871
1872 NTSTATUS dos_to_ntstatus(uint8 eclass, uint32 ecode);
1873 void ntstatus_to_dos(NTSTATUS ntstatus, uint8 *eclass, uint32 *ecode);
1874 NTSTATUS werror_to_ntstatus(WERROR error);
1875 WERROR ntstatus_to_werror(NTSTATUS error);
1876 NTSTATUS map_nt_error_from_gss(uint32 gss_maj, uint32 minor);
1877
1878 /* The following definitions come from libsmb/namecache.c  */
1879
1880 bool namecache_store(const char *name,
1881                         int name_type,
1882                         int num_names,
1883                         struct ip_service *ip_list);
1884 bool namecache_fetch(const char *name,
1885                         int name_type,
1886                         struct ip_service **ip_list,
1887                         int *num_names);
1888 bool namecache_delete(const char *name, int name_type);
1889 void namecache_flush(void);
1890 bool namecache_status_store(const char *keyname, int keyname_type,
1891                 int name_type, const struct sockaddr_storage *keyip,
1892                 const char *srvname);
1893 bool namecache_status_fetch(const char *keyname,
1894                                 int keyname_type,
1895                                 int name_type,
1896                                 const struct sockaddr_storage *keyip,
1897                                 char *srvname_out);
1898
1899 /* The following definitions come from libsmb/namequery.c  */
1900
1901 bool saf_store( const char *domain, const char *servername );
1902 bool saf_join_store( const char *domain, const char *servername );
1903 bool saf_delete( const char *domain );
1904 char *saf_fetch( const char *domain );
1905 struct tevent_req *node_status_query_send(TALLOC_CTX *mem_ctx,
1906                                           struct tevent_context *ev,
1907                                           struct nmb_name *name,
1908                                           const struct sockaddr_storage *addr);
1909 NTSTATUS node_status_query_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
1910                                 struct node_status **pnode_status,
1911                                 int *pnum_names,
1912                                 struct node_status_extra *extra);
1913 NTSTATUS node_status_query(TALLOC_CTX *mem_ctx, struct nmb_name *name,
1914                            const struct sockaddr_storage *addr,
1915                            struct node_status **pnode_status,
1916                            int *pnum_names,
1917                            struct node_status_extra *extra);
1918 bool name_status_find(const char *q_name,
1919                         int q_type,
1920                         int type,
1921                         const struct sockaddr_storage *to_ss,
1922                         fstring name);
1923 int ip_service_compare(struct ip_service *ss1, struct ip_service *ss2);
1924 struct tevent_req *name_query_send(TALLOC_CTX *mem_ctx,
1925                                    struct tevent_context *ev,
1926                                    const char *name, int name_type,
1927                                    bool bcast, bool recurse,
1928                                    const struct sockaddr_storage *addr);
1929 NTSTATUS name_query_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
1930                          struct sockaddr_storage **addrs, int *num_addrs,
1931                          uint8_t *flags);
1932 NTSTATUS name_query(const char *name, int name_type,
1933                     bool bcast, bool recurse,
1934                     const struct sockaddr_storage *to_ss,
1935                     TALLOC_CTX *mem_ctx,
1936                     struct sockaddr_storage **addrs,
1937                     int *num_addrs, uint8_t *flags);
1938 NTSTATUS name_resolve_bcast(const char *name,
1939                         int name_type,
1940                         TALLOC_CTX *mem_ctx,
1941                         struct sockaddr_storage **return_iplist,
1942                         int *return_count);
1943 NTSTATUS resolve_wins(const char *name,
1944                 int name_type,
1945                 struct ip_service **return_iplist,
1946                 int *return_count);
1947 NTSTATUS internal_resolve_name(const char *name,
1948                                 int name_type,
1949                                 const char *sitename,
1950                                 struct ip_service **return_iplist,
1951                                 int *return_count,
1952                                 const char *resolve_order);
1953 bool resolve_name(const char *name,
1954                 struct sockaddr_storage *return_ss,
1955                 int name_type,
1956                 bool prefer_ipv4);
1957 NTSTATUS resolve_name_list(TALLOC_CTX *ctx,
1958                 const char *name,
1959                 int name_type,
1960                 struct sockaddr_storage **return_ss_arr,
1961                 unsigned int *p_num_entries);
1962 bool find_master_ip(const char *group, struct sockaddr_storage *master_ss);
1963 bool get_pdc_ip(const char *domain, struct sockaddr_storage *pss);
1964 NTSTATUS get_sorted_dc_list( const char *domain,
1965                         const char *sitename,
1966                         struct ip_service **ip_list,
1967                         int *count,
1968                         bool ads_only );
1969 NTSTATUS get_kdc_list( const char *realm,
1970                         const char *sitename,
1971                         struct ip_service **ip_list,
1972                         int *count);
1973
1974 /* The following definitions come from libsmb/namequery_dc.c  */
1975
1976 bool get_dc_name(const char *domain,
1977                 const char *realm,
1978                 fstring srv_name,
1979                 struct sockaddr_storage *ss_out);
1980
1981 /* The following definitions come from libsmb/nterr.c  */
1982
1983 const char *nt_errstr(NTSTATUS nt_code);
1984 const char *get_friendly_nt_error_msg(NTSTATUS nt_code);
1985 const char *get_nt_error_c_code(NTSTATUS nt_code);
1986 NTSTATUS nt_status_string_to_code(const char *nt_status_str);
1987 NTSTATUS nt_status_squash(NTSTATUS nt_status);
1988
1989 /* The following definitions come from libsmb/ntlmssp.c  */
1990 struct ntlmssp_state;
1991 NTSTATUS ntlmssp_set_username(struct ntlmssp_state *ntlmssp_state, const char *user) ;
1992 NTSTATUS ntlmssp_set_hashes(struct ntlmssp_state *ntlmssp_state,
1993                             const uint8_t lm_hash[16],
1994                             const uint8_t nt_hash[16]) ;
1995 NTSTATUS ntlmssp_set_password(struct ntlmssp_state *ntlmssp_state, const char *password) ;
1996 NTSTATUS ntlmssp_set_domain(struct ntlmssp_state *ntlmssp_state, const char *domain) ;
1997 void ntlmssp_want_feature_list(struct ntlmssp_state *ntlmssp_state, char *feature_list);
1998 void ntlmssp_want_feature(struct ntlmssp_state *ntlmssp_state, uint32_t feature);
1999 NTSTATUS ntlmssp_update(struct ntlmssp_state *ntlmssp_state,
2000                         const DATA_BLOB in, DATA_BLOB *out) ;
2001 NTSTATUS ntlmssp_server_start(TALLOC_CTX *mem_ctx,
2002                               bool is_standalone,
2003                               const char *netbios_name,
2004                               const char *netbios_domain,
2005                               const char *dns_name,
2006                               const char *dns_domain,
2007                               struct ntlmssp_state **ntlmssp_state);
2008 NTSTATUS ntlmssp_client_start(TALLOC_CTX *mem_ctx,
2009                               const char *netbios_name,
2010                               const char *netbios_domain,
2011                               bool use_ntlmv2,
2012                               struct ntlmssp_state **_ntlmssp_state);
2013
2014 /* The following definitions come from libsmb/passchange.c  */
2015
2016 NTSTATUS remote_password_change(const char *remote_machine, const char *user_name, 
2017                                 const char *old_passwd, const char *new_passwd,
2018                                 char **err_str);
2019
2020 /* The following definitions come from libsmb/samlogon_cache.c  */
2021
2022 bool netsamlogon_cache_init(void);
2023 bool netsamlogon_cache_shutdown(void);
2024 void netsamlogon_clear_cached_user(const struct dom_sid *user_sid);
2025 bool netsamlogon_cache_store(const char *username, struct netr_SamInfo3 *info3);
2026 struct netr_SamInfo3 *netsamlogon_cache_get(TALLOC_CTX *mem_ctx, const struct dom_sid *user_sid);
2027 bool netsamlogon_cache_have(const struct dom_sid *user_sid);
2028
2029 /* The following definitions come from libsmb/smb_seal.c  */
2030
2031 NTSTATUS get_enc_ctx_num(const uint8_t *buf, uint16 *p_enc_ctx_num);
2032 bool common_encryption_on(struct smb_trans_enc_state *es);
2033 NTSTATUS common_ntlm_decrypt_buffer(struct ntlmssp_state *ntlmssp_state, char *buf);
2034 NTSTATUS common_ntlm_encrypt_buffer(struct ntlmssp_state *ntlmssp_state,
2035                                 uint16 enc_ctx_num,
2036                                 char *buf,
2037                                 char **ppbuf_out);
2038 NTSTATUS common_encrypt_buffer(struct smb_trans_enc_state *es, char *buffer, char **buf_out);
2039 NTSTATUS common_decrypt_buffer(struct smb_trans_enc_state *es, char *buf);
2040 void common_free_encryption_state(struct smb_trans_enc_state **pp_es);
2041 void common_free_enc_buffer(struct smb_trans_enc_state *es, char *buf);
2042 bool cli_encryption_on(struct cli_state *cli);
2043 void cli_free_encryption_context(struct cli_state *cli);
2044 void cli_free_enc_buffer(struct cli_state *cli, char *buf);
2045 NTSTATUS cli_decrypt_message(struct cli_state *cli);
2046 NTSTATUS cli_encrypt_message(struct cli_state *cli, char *buf, char **buf_out);
2047
2048 /* The following definitions come from libsmb/clisigning.c  */
2049
2050 bool cli_simple_set_signing(struct cli_state *cli,
2051                             const DATA_BLOB user_session_key,
2052                             const DATA_BLOB response);
2053 bool cli_temp_set_signing(struct cli_state *cli);
2054 void cli_calculate_sign_mac(struct cli_state *cli, char *buf, uint32_t *seqnum);
2055 bool cli_check_sign_mac(struct cli_state *cli, const char *buf, uint32_t seqnum);
2056 bool client_is_signing_on(struct cli_state *cli);
2057 bool client_is_signing_allowed(struct cli_state *cli);
2058 bool client_is_signing_mandatory(struct cli_state *cli);
2059 void cli_set_signing_negotiated(struct cli_state *cli);
2060
2061 /* The following definitions come from libsmb/smberr.c  */
2062
2063 const char *smb_dos_err_name(uint8 e_class, uint16 num);
2064 const char *get_dos_error_msg(WERROR result);
2065 const char *smb_dos_err_class(uint8 e_class);
2066 char *smb_dos_errstr(char *inbuf);
2067 WERROR map_werror_from_unix(int error);
2068
2069 /* The following definitions come from libsmb/trustdom_cache.c  */
2070
2071 bool trustdom_cache_enable(void);
2072 bool trustdom_cache_shutdown(void);
2073 bool trustdom_cache_store(char* name, char* alt_name, const struct dom_sid *sid,
2074                           time_t timeout);
2075 bool trustdom_cache_fetch(const char* name, struct dom_sid* sid);
2076 uint32 trustdom_cache_fetch_timestamp( void );
2077 bool trustdom_cache_store_timestamp( uint32 t, time_t timeout );
2078 void trustdom_cache_flush(void);
2079 void update_trustdom_cache( void );
2080
2081 /* The following definitions come from libsmb/trusts_util.c  */
2082
2083 NTSTATUS trust_pw_change_and_store_it(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, 
2084                                       const char *domain,
2085                                       const char *account_name,
2086                                       unsigned char orig_trust_passwd_hash[16],
2087                                       enum netr_SchannelType sec_channel_type);
2088 NTSTATUS trust_pw_find_change_and_store_it(struct rpc_pipe_client *cli, 
2089                                            TALLOC_CTX *mem_ctx, 
2090                                            const char *domain) ;
2091 bool enumerate_domain_trusts( TALLOC_CTX *mem_ctx, const char *domain,
2092                                      char ***domain_names, uint32 *num_domains,
2093                                      struct dom_sid **sids );
2094 NTSTATUS change_trust_account_password( const char *domain, const char *remote_machine);
2095
2096 /* The following definitions come from param/loadparm.c  */
2097
2098 char *lp_smb_ports(void);
2099 char *lp_dos_charset(void);
2100 char *lp_unix_charset(void);
2101 char *lp_display_charset(void);
2102 char *lp_logfile(void);
2103 char *lp_configfile(void);
2104 char *lp_smb_passwd_file(void);
2105 char *lp_private_dir(void);
2106 char *lp_serverstring(void);
2107 int lp_printcap_cache_time(void);
2108 char *lp_addport_cmd(void);
2109 char *lp_enumports_cmd(void);
2110 char *lp_addprinter_cmd(void);
2111 char *lp_deleteprinter_cmd(void);
2112 char *lp_os2_driver_map(void);
2113 char *lp_lockdir(void);
2114 char *lp_statedir(void);
2115 char *lp_cachedir(void);
2116 char *lp_piddir(void);
2117 char *lp_mangling_method(void);
2118 int lp_mangle_prefix(void);
2119 char *lp_utmpdir(void);
2120 char *lp_wtmpdir(void);
2121 bool lp_utmp(void);
2122 char *lp_rootdir(void);
2123 char *lp_defaultservice(void);
2124 char *lp_msg_command(void);
2125 char *lp_get_quota_command(void);
2126 char *lp_set_quota_command(void);
2127 char *lp_auto_services(void);
2128 char *lp_passwd_program(void);
2129 char *lp_passwd_chat(void);
2130 char *lp_passwordserver(void);
2131 char *lp_name_resolve_order(void);
2132 char *lp_realm(void);
2133 const char *lp_afs_username_map(void);
2134 int lp_afs_token_lifetime(void);
2135 char *lp_log_nt_token_command(void);
2136 char *lp_username_map(void);
2137 const char *lp_logon_script(void);
2138 const char *lp_logon_path(void);
2139 const char *lp_logon_drive(void);
2140 const char *lp_logon_home(void);
2141 char *lp_remote_announce(void);
2142 char *lp_remote_browse_sync(void);
2143 bool lp_nmbd_bind_explicit_broadcast(void);
2144 const char **lp_wins_server_list(void);
2145 const char **lp_interfaces(void);
2146 const char *lp_socket_address(void);
2147 char *lp_nis_home_map_name(void);
2148 const char **lp_netbios_aliases(void);
2149 const char *lp_passdb_backend(void);
2150 const char **lp_preload_modules(void);
2151 char *lp_panic_action(void);
2152 char *lp_adduser_script(void);
2153 char *lp_renameuser_script(void);
2154 char *lp_deluser_script(void);
2155 const char *lp_guestaccount(void);
2156 char *lp_addgroup_script(void);
2157 char *lp_delgroup_script(void);
2158 char *lp_addusertogroup_script(void);
2159 char *lp_deluserfromgroup_script(void);
2160 char *lp_setprimarygroup_script(void);
2161 char *lp_addmachine_script(void);
2162 char *lp_shutdown_script(void);
2163 char *lp_abort_shutdown_script(void);
2164 char *lp_username_map_script(void);
2165 int lp_username_map_cache_time(void);
2166 char *lp_check_password_script(void);
2167 char *lp_wins_hook(void);
2168 const char *lp_template_homedir(void);
2169 const char *lp_template_shell(void);
2170 const char *lp_winbind_separator(void);
2171 int lp_acl_compatibility(void);
2172 bool lp_winbind_enum_users(void);
2173 bool lp_winbind_enum_groups(void);
2174 bool lp_winbind_use_default_domain(void);
2175 bool lp_winbind_trusted_domains_only(void);
2176 bool lp_winbind_nested_groups(void);
2177 int lp_winbind_expand_groups(void);
2178 bool lp_winbind_refresh_tickets(void);
2179 bool lp_winbind_offline_logon(void);
2180 bool lp_winbind_normalize_names(void);
2181 bool lp_winbind_rpc_only(void);
2182 bool lp_create_krb5_conf(void);
2183 int lp_winbind_max_domain_connections(void);
2184 const char *lp_idmap_backend(void);
2185 int lp_idmap_cache_time(void);
2186 int lp_idmap_negative_cache_time(void);
2187 int lp_keepalive(void);
2188 bool lp_passdb_expand_explicit(void);
2189 char *lp_ldap_suffix(void);
2190 char *lp_ldap_admin_dn(void);
2191 int lp_ldap_ssl(void);
2192 bool lp_ldap_ssl_ads(void);
2193 int lp_ldap_deref(void);
2194 int lp_ldap_follow_referral(void);
2195 int lp_ldap_passwd_sync(void);
2196 bool lp_ldap_delete_dn(void);
2197 int lp_ldap_replication_sleep(void);
2198 int lp_ldap_timeout(void);
2199 int lp_ldap_connection_timeout(void);
2200 int lp_ldap_page_size(void);
2201 int lp_ldap_debug_level(void);
2202 int lp_ldap_debug_threshold(void);
2203 char *lp_add_share_cmd(void);
2204 char *lp_change_share_cmd(void);
2205 char *lp_delete_share_cmd(void);
2206 char *lp_usershare_path(void);
2207 const char **lp_usershare_prefix_allow_list(void);
2208 const char **lp_usershare_prefix_deny_list(void);
2209 const char **lp_eventlog_list(void);
2210 bool lp_registry_shares(void);
2211 bool lp_usershare_allow_guests(void);
2212 bool lp_usershare_owner_only(void);
2213 bool lp_disable_netbios(void);
2214 bool lp_reset_on_zero_vc(void);
2215 bool lp_log_writeable_files_on_exit(void);
2216 bool lp_ms_add_printer_wizard(void);
2217 bool lp_dns_proxy(void);
2218 bool lp_wins_support(void);
2219 bool lp_we_are_a_wins_server(void);
2220 bool lp_wins_proxy(void);
2221 bool lp_local_master(void);
2222 bool lp_domain_logons(void);
2223 const char **lp_init_logon_delayed_hosts(void);
2224 int lp_init_logon_delay(void);
2225 bool lp_load_printers(void);
2226 bool lp_readraw(void);
2227 bool _lp_readraw(void);
2228 bool lp_large_readwrite(void);
2229 bool lp_writeraw(void);
2230 bool _lp_writeraw(void);
2231 bool lp_null_passwords(void);
2232 bool lp_obey_pam_restrictions(void);
2233 bool lp_encrypted_passwords(void);
2234 int lp_client_schannel(void);
2235 int lp_server_schannel(void);
2236 bool lp_syslog_only(void);
2237 bool lp_timestamp_logs(void);
2238 bool lp_debug_prefix_timestamp(void);
2239 bool lp_debug_hires_timestamp(void);
2240 bool lp_debug_pid(void);
2241 bool lp_debug_uid(void);
2242 bool lp_debug_class(void);
2243 bool lp_enable_core_files(void);
2244 bool lp_browse_list(void);
2245 bool lp_nis_home_map(void);
2246 bool lp_bind_interfaces_only(void);
2247 bool lp_pam_password_change(void);
2248 bool lp_unix_password_sync(void);
2249 bool lp_passwd_chat_debug(void);
2250 int lp_passwd_chat_timeout(void);
2251 bool lp_nt_pipe_support(void);
2252 bool lp_nt_status_support(void);
2253 bool lp_stat_cache(void);
2254 int lp_max_stat_cache_size(void);
2255 bool lp_allow_trusted_domains(void);
2256 bool lp_map_untrusted_to_domain(void);
2257 int lp_restrict_anonymous(void);
2258 bool lp_lanman_auth(void);
2259 bool lp_ntlm_auth(void);
2260 bool lp_client_plaintext_auth(void);
2261 bool lp_client_lanman_auth(void);
2262 bool lp_client_ntlmv2_auth(void);
2263 bool lp_host_msdfs(void);
2264 bool lp_kernel_oplocks(void);
2265 bool lp_enhanced_browsing(void);
2266 bool lp_use_mmap(void);
2267 bool lp_unix_extensions(void);
2268 bool lp_use_spnego(void);
2269 bool lp_client_use_spnego(void);
2270 bool lp_client_use_spnego_principal(void);
2271 bool lp_send_spnego_principal(void);
2272 bool lp_hostname_lookups(void);
2273 bool lp_change_notify(const struct share_params *p );
2274 bool lp_kernel_change_notify(const struct share_params *p );
2275 char * lp_dedicated_keytab_file(void);
2276 int lp_kerberos_method(void);
2277 bool lp_defer_sharing_violations(void);
2278 bool lp_enable_privileges(void);
2279 bool lp_enable_asu_support(void);
2280 int lp_os_level(void);
2281 int lp_max_ttl(void);
2282 int lp_max_wins_ttl(void);
2283 int lp_min_wins_ttl(void);
2284 int lp_max_log_size(void);
2285 int lp_max_open_files(void);
2286 int lp_open_files_db_hash_size(void);
2287 int lp_maxxmit(void);
2288 int lp_maxmux(void);
2289 int lp_passwordlevel(void);
2290 int lp_usernamelevel(void);
2291 int lp_deadtime(void);
2292 bool lp_getwd_cache(void);
2293 int lp_maxprotocol(void);
2294 int lp_minprotocol(void);
2295 int lp_security(void);
2296 const char **lp_auth_methods(void);
2297 bool lp_paranoid_server_security(void);
2298 int lp_maxdisksize(void);
2299 int lp_lpqcachetime(void);
2300 int lp_max_smbd_processes(void);
2301 bool _lp_disable_spoolss(void);
2302 int lp_syslog(void);
2303 int lp_lm_announce(void);
2304 int lp_lm_interval(void);
2305 int lp_machine_password_timeout(void);
2306 int lp_map_to_guest(void);
2307 int lp_oplock_break_wait_time(void);
2308 int lp_lock_spin_time(void);
2309 int lp_usershare_max_shares(void);
2310 const char *lp_socket_options(void);
2311 int lp_config_backend(void);
2312 int lp_smb2_max_read(void);
2313 int lp_smb2_max_write(void);
2314 int lp_smb2_max_trans(void);
2315 int lp_smb2_max_credits(void);
2316 char *lp_preexec(int );
2317 char *lp_postexec(int );
2318 char *lp_rootpreexec(int );
2319 char *lp_rootpostexec(int );
2320 char *lp_servicename(int );
2321 const char *lp_const_servicename(int );
2322 char *lp_pathname(int );
2323 char *lp_dontdescend(int );
2324 char *lp_username(int );
2325 const char **lp_invalid_users(int );
2326 const char **lp_valid_users(int );
2327 const char **lp_admin_users(int );
2328 const char **lp_svcctl_list(void);
2329 char *lp_cups_options(int );
2330 char *lp_cups_server(void);
2331 int lp_cups_encrypt(void);
2332 char *lp_iprint_server(void);
2333 int lp_cups_connection_timeout(void);
2334 const char *lp_ctdbd_socket(void);
2335 const char **lp_cluster_addresses(void);
2336 bool lp_clustering(void);
2337 int lp_ctdb_timeout(void);
2338 int lp_ctdb_locktime_warn_threshold(void);
2339 char *lp_printcommand(int );
2340 char *lp_lpqcommand(int );
2341 char *lp_lprmcommand(int );
2342 char *lp_lppausecommand(int );
2343 char *lp_lpresumecommand(int );
2344 char *lp_queuepausecommand(int );
2345 char *lp_queueresumecommand(int );
2346 const char *lp_printjob_username(int );
2347 const char **lp_hostsallow(int );
2348 const char **lp_hostsdeny(int );
2349 char *lp_magicscript(int );
2350 char *lp_magicoutput(int );
2351 char *lp_comment(int );
2352 char *lp_force_user(int );
2353 char *lp_force_group(int );
2354 const char **lp_readlist(int );
2355 const char **lp_writelist(int );
2356 const char **lp_printer_admin(int );
2357 char *lp_fstype(int );
2358 const char **lp_vfs_objects(int );
2359 char *lp_msdfs_proxy(int );
2360 char *lp_veto_files(int );
2361 char *lp_hide_files(int );
2362 char *lp_veto_oplocks(int );
2363 bool lp_msdfs_root(int );
2364 char *lp_aio_write_behind(int );
2365 char *lp_dfree_command(int );
2366 bool lp_autoloaded(int );
2367 bool lp_preexec_close(int );
2368 bool lp_rootpreexec_close(int );
2369 int lp_casesensitive(int );
2370 bool lp_preservecase(int );
2371 bool lp_shortpreservecase(int );
2372 bool lp_hide_dot_files(int );
2373 bool lp_hide_special_files(int );
2374 bool lp_hideunreadable(int );
2375 bool lp_hideunwriteable_files(int );
2376 bool lp_browseable(int );
2377 bool lp_access_based_share_enum(int );
2378 bool lp_readonly(int );
2379 bool lp_no_set_dir(int );
2380 bool lp_guest_ok(int );
2381 bool lp_guest_only(int );
2382 bool lp_administrative_share(int );
2383 bool lp_print_ok(int );
2384 bool lp_print_notify_backchannel(int );
2385 bool lp_map_hidden(int );
2386 bool lp_map_archive(int );
2387 bool lp_store_dos_attributes(int );
2388 bool lp_dmapi_support(int );
2389 bool lp_locking(const struct share_params *p );
2390 int lp_strict_locking(const struct share_params *p );
2391 bool lp_posix_locking(const struct share_params *p );
2392 bool lp_share_modes(int );
2393 bool lp_oplocks(int );
2394 bool lp_level2_oplocks(int );
2395 bool lp_onlyuser(int );
2396 bool lp_manglednames(const struct share_params *p );
2397 bool lp_widelinks(int );
2398 bool lp_symlinks(int );
2399 bool lp_syncalways(int );
2400 bool lp_strict_allocate(int );
2401 bool lp_strict_sync(int );
2402 bool lp_map_system(int );
2403 bool lp_delete_readonly(int );
2404 bool lp_fake_oplocks(int );
2405 bool lp_recursive_veto_delete(int );
2406 bool lp_dos_filemode(int );
2407 bool lp_dos_filetimes(int );
2408 bool lp_dos_filetime_resolution(int );
2409 bool lp_fake_dir_create_times(int);
2410 bool lp_async_smb_echo_handler(void);
2411 bool lp_multicast_dns_register(void);
2412 bool lp_blocking_locks(int );
2413 bool lp_inherit_perms(int );
2414 bool lp_inherit_acls(int );
2415 bool lp_inherit_owner(int );
2416 bool lp_use_client_driver(int );
2417 bool lp_default_devmode(int );
2418 bool lp_force_printername(int );
2419 bool lp_nt_acl_support(int );
2420 bool lp_force_unknown_acl_user(int );
2421 bool lp_ea_support(int );
2422 bool _lp_use_sendfile(int );
2423 bool lp_profile_acls(int );
2424 bool lp_map_acl_inherit(int );
2425 bool lp_afs_share(int );
2426 bool lp_acl_check_permissions(int );
2427 bool lp_acl_group_control(int );
2428 bool lp_acl_map_full_control(int );
2429 int lp_create_mask(int );
2430 int lp_force_create_mode(int );
2431 int lp_security_mask(int );
2432 int lp_force_security_mode(int );
2433 int lp_dir_mask(int );
2434 int lp_force_dir_mode(int );
2435 int lp_dir_security_mask(int );
2436 int lp_force_dir_security_mode(int );
2437 int lp_max_connections(int );
2438 int lp_defaultcase(int );
2439 int lp_minprintspace(int );
2440 int lp_printing(int );
2441 int lp_max_reported_jobs(int );
2442 int lp_oplock_contention_limit(int );
2443 int lp_csc_policy(int );
2444 int lp_write_cache_size(int );
2445 int lp_block_size(int );
2446 int lp_dfree_cache_time(int );
2447 int lp_allocation_roundup_size(int );
2448 int lp_aio_read_size(int );
2449 int lp_aio_write_size(int );
2450 int lp_map_readonly(int );
2451 int lp_directory_name_cache_size(int );
2452 int lp_smb_encrypt(int );
2453 char lp_magicchar(const struct share_params *p );
2454 int lp_winbind_cache_time(void);
2455 int lp_winbind_reconnect_delay(void);
2456 int lp_winbind_max_clients(void);
2457 const char **lp_winbind_nss_info(void);
2458 int lp_algorithmic_rid_base(void);
2459 int lp_name_cache_timeout(void);
2460 int lp_client_signing(void);
2461 int lp_server_signing(void);
2462 int lp_client_ldap_sasl_wrapping(void);
2463 char *lp_parm_talloc_string(int snum, const char *type, const char *option, const char *def);
2464 const char *lp_parm_const_string(int snum, const char *type, const char *option, const char *def);
2465 const char **lp_parm_string_list(int snum, const char *type, const char *option, const char **def);
2466 int lp_parm_int(int snum, const char *type, const char *option, int def);
2467 unsigned long lp_parm_ulong(int snum, const char *type, const char *option, unsigned long def);
2468 bool lp_parm_bool(int snum, const char *type, const char *option, bool def);
2469 int lp_parm_enum(int snum, const char *type, const char *option,
2470                  const struct enum_list *_enum, int def);
2471 char *canonicalize_servicename(TALLOC_CTX *ctx, const char *src);
2472 bool lp_add_home(const char *pszHomename, int iDefaultService,
2473                  const char *user, const char *pszHomedir);
2474 int lp_add_service(const char *pszService, int iDefaultService);
2475 bool lp_add_printer(const char *pszPrintername, int iDefaultService);
2476 bool lp_parameter_is_valid(const char *pszParmName);
2477 bool lp_parameter_is_global(const char *pszParmName);
2478 bool lp_parameter_is_canonical(const char *parm_name);
2479 bool lp_canonicalize_parameter(const char *parm_name, const char **canon_parm,
2480                                bool *inverse);
2481 bool lp_canonicalize_parameter_with_value(const char *parm_name,
2482                                           const char *val,
2483                                           const char **canon_parm,
2484                                           const char **canon_val);
2485 void show_parameter_list(void);
2486 bool lp_string_is_valid_boolean(const char *parm_value);
2487 bool lp_invert_boolean(const char *str, const char **inverse_str);
2488 bool lp_canonicalize_boolean(const char *str, const char**canon_str);
2489 bool service_ok(int iService);
2490 bool process_registry_service(const char *service_name);
2491 bool process_registry_shares(void);
2492 bool lp_config_backend_is_registry(void);
2493 bool lp_config_backend_is_file(void);
2494 bool lp_file_list_changed(void);
2495 bool lp_idmap_uid(uid_t *low, uid_t *high);
2496 bool lp_idmap_gid(gid_t *low, gid_t *high);
2497 const char *lp_ldap_machine_suffix(void);
2498 const char *lp_ldap_user_suffix(void);
2499 const char *lp_ldap_group_suffix(void);
2500 const char *lp_ldap_idmap_suffix(void);
2501 void *lp_local_ptr_by_snum(int snum, void *ptr);
2502 bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue);
2503 bool lp_set_cmdline(const char *pszParmName, const char *pszParmValue);
2504 bool lp_set_option(const char *option);
2505 void init_locals(void);
2506 bool lp_is_default(int snum, struct parm_struct *parm);
2507 bool dump_a_parameter(int snum, char *parm_name, FILE * f, bool isGlobal);
2508 struct parm_struct *lp_get_parameter(const char *param_name);
2509 struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters);
2510 bool lp_snum_ok(int iService);
2511 void lp_add_one_printer(const char *name, const char *comment, void *pdata);
2512 bool lp_loaded(void);
2513 void lp_killunused(bool (*snumused) (int));
2514 void lp_kill_all_services(void);
2515 void lp_killservice(int iServiceIn);
2516 const char* server_role_str(uint32 role);
2517 enum usershare_err parse_usershare_file(TALLOC_CTX *ctx,
2518                         SMB_STRUCT_STAT *psbuf,
2519                         const char *servicename,
2520                         int snum,
2521                         char **lines,
2522                         int numlines,
2523                         char **pp_sharepath,
2524                         char **pp_comment,
2525                         char **pp_cp_share_name,
2526                         struct security_descriptor **ppsd,
2527                         bool *pallow_guest);
2528 int load_usershare_service(const char *servicename);
2529 int load_usershare_shares(void);
2530 void gfree_loadparm(void);
2531 void lp_set_in_client(bool b);
2532 bool lp_is_in_client(void);
2533 bool lp_load(const char *pszFname,
2534              bool global_only,
2535              bool save_defaults,
2536              bool add_ipc,
2537              bool initialize_globals);
2538 bool lp_load_initial_only(const char *pszFname);
2539 bool lp_load_with_registry_shares(const char *pszFname,
2540                                   bool global_only,
2541                                   bool save_defaults,
2542                                   bool add_ipc,
2543                                   bool initialize_globals);
2544 int lp_numservices(void);
2545 void lp_dump(FILE *f, bool show_defaults, int maxtoprint);
2546 void lp_dump_one(FILE * f, bool show_defaults, int snum);
2547 int lp_servicenumber(const char *pszServiceName);
2548 bool share_defined(const char *service_name);
2549 struct share_params *get_share_params(TALLOC_CTX *mem_ctx,
2550                                       const char *sharename);
2551 struct share_iterator *share_list_all(TALLOC_CTX *mem_ctx);
2552 struct share_params *next_share(struct share_iterator *list);
2553 struct share_params *next_printer(struct share_iterator *list);
2554 struct share_params *snum2params_static(int snum);
2555 const char *volume_label(int snum);
2556 bool lp_domain_master(void);
2557 bool lp_domain_master_true_or_auto(void);
2558 bool lp_preferred_master(void);
2559 void lp_remove_service(int snum);
2560 void lp_copy_service(int snum, const char *new_name);
2561 int lp_default_server_announce(void);
2562 int lp_major_announce_version(void);
2563 int lp_minor_announce_version(void);
2564 void lp_set_name_resolve_order(const char *new_order);
2565 const char *lp_printername(int snum);
2566 void lp_set_logfile(const char *name);
2567 int lp_maxprintjobs(int snum);
2568 const char *lp_printcapname(void);
2569 bool lp_disable_spoolss( void );
2570 void lp_set_spoolss_state( uint32 state );
2571 uint32 lp_get_spoolss_state( void );
2572 bool lp_use_sendfile(int snum, struct smb_signing_state *signing_state);
2573 void set_use_sendfile(int snum, bool val);
2574 void set_store_dos_attributes(int snum, bool val);
2575 void lp_set_mangling_method(const char *new_method);
2576 bool lp_posix_pathnames(void);
2577 void lp_set_posix_pathnames(void);
2578 enum brl_flavour lp_posix_cifsu_locktype(files_struct *fsp);
2579 void lp_set_posix_default_cifsx_readwrite_locktype(enum brl_flavour val);
2580 int lp_min_receive_file_size(void);
2581 char* lp_perfcount_module(void);
2582 void lp_set_passdb_backend(const char *backend);
2583 void widelinks_warning(int snum);
2584 char *lp_ncalrpc_dir(void);
2585
2586 /* The following definitions come from param/loadparm_server_role.c  */
2587
2588 int lp_server_role(void);
2589 void set_server_role(void);
2590
2591 /* The following definitions come from param/util.c  */
2592
2593 uint32 get_int_param( const char* param );
2594 char* get_string_param( const char* param );
2595
2596 /* The following definitions come from lib/server_contexts.c  */
2597 struct tevent_context *server_event_context(void);
2598 void server_event_context_free(void);
2599 struct messaging_context *server_messaging_context(void);
2600 void server_messaging_context_free(void);
2601
2602 /* The following definitions come from lib/sessionid_tdb.c  */
2603 struct sessionid;
2604 bool sessionid_init(void);
2605 struct db_record *sessionid_fetch_record(TALLOC_CTX *mem_ctx, const char *key);
2606 int sessionid_traverse(int (*fn)(struct db_record *rec, const char *key,
2607                                  struct sessionid *session,
2608                                  void *private_data),
2609                        void *private_data);
2610 int sessionid_traverse_read(int (*fn)(const char *key,
2611                                       struct sessionid *session,
2612                                       void *private_data),
2613                             void *private_data);
2614
2615 /* The following definitions come from utils/passwd_util.c  */
2616
2617 char *stdin_new_passwd( void);
2618 char *get_pass( const char *prompt, bool stdin_get);
2619
2620 /* The following definitions come from lib/avahi.c */
2621
2622 struct AvahiPoll *tevent_avahi_poll(TALLOC_CTX *mem_ctx,
2623                                     struct tevent_context *ev);
2624
2625 /* The following definitions come from lib/fncall.c */
2626
2627 struct fncall_context *fncall_context_init(TALLOC_CTX *mem_ctx,
2628                                            int max_threads);
2629 struct tevent_req *fncall_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
2630                                struct fncall_context *ctx,
2631                                void (*fn)(void *private_data),
2632                                void *private_data);
2633 int fncall_recv(struct tevent_req *req, int *perr);
2634
2635 /* The following definitions come from libsmb/smbsock_connect.c */
2636
2637 struct tevent_req *smbsock_connect_send(TALLOC_CTX *mem_ctx,
2638                                         struct tevent_context *ev,
2639                                         const struct sockaddr_storage *addr,
2640                                         uint16_t port,
2641                                         const char *called_name,
2642                                         int called_type,
2643                                         const char *calling_name,
2644                                         int calling_type);
2645 NTSTATUS smbsock_connect_recv(struct tevent_req *req, int *sock,
2646                               uint16_t *ret_port);
2647 NTSTATUS smbsock_connect(const struct sockaddr_storage *addr, uint16_t port,
2648                          const char *called_name, int called_type,
2649                          const char *calling_name, int calling_type,
2650                          int *pfd, uint16_t *ret_port, int sec_timeout);
2651
2652 struct tevent_req *smbsock_any_connect_send(TALLOC_CTX *mem_ctx,
2653                                             struct tevent_context *ev,
2654                                             const struct sockaddr_storage *addrs,
2655                                             const char **called_names,
2656                                             int *called_types,
2657                                             const char **calling_names,
2658                                             int *calling_types,
2659                                             size_t num_addrs, uint16_t port);
2660 NTSTATUS smbsock_any_connect_recv(struct tevent_req *req, int *pfd,
2661                                   size_t *chosen_index, uint16_t *chosen_port);
2662 NTSTATUS smbsock_any_connect(const struct sockaddr_storage *addrs,
2663                              const char **called_names,
2664                              int *called_types,
2665                              const char **calling_names,
2666                              int *calling_types,
2667                              size_t num_addrs,
2668                              uint16_t port,
2669                              int sec_timeout,
2670                              int *pfd, size_t *chosen_index,
2671                              uint16_t *chosen_port);
2672
2673 /* The following definitions come from lib/util_wellknown.c  */
2674
2675 bool sid_check_is_wellknown_domain(const struct dom_sid *sid, const char **name);
2676 bool sid_check_is_in_wellknown_domain(const struct dom_sid *sid);
2677 bool lookup_wellknown_sid(TALLOC_CTX *mem_ctx, const struct dom_sid *sid,
2678                           const char **domain, const char **name);
2679 bool lookup_wellknown_name(TALLOC_CTX *mem_ctx, const char *name,
2680                            struct dom_sid *sid, const char **domain);
2681
2682 /* The following definitions come from lib/util_unixsids.c  */
2683
2684 bool sid_check_is_unix_users(const struct dom_sid *sid);
2685 bool sid_check_is_in_unix_users(const struct dom_sid *sid);
2686 void uid_to_unix_users_sid(uid_t uid, struct dom_sid *sid);
2687 void gid_to_unix_groups_sid(gid_t gid, struct dom_sid *sid);
2688 const char *unix_users_domain_name(void);
2689 bool lookup_unix_user_name(const char *name, struct dom_sid *sid);
2690 bool sid_check_is_unix_groups(const struct dom_sid *sid);
2691 bool sid_check_is_in_unix_groups(const struct dom_sid *sid);
2692 const char *unix_groups_domain_name(void);
2693 bool lookup_unix_group_name(const char *name, struct dom_sid *sid);
2694
2695 /* The following definitions come from lib/filename_util.c */
2696
2697 NTSTATUS get_full_smb_filename(TALLOC_CTX *ctx, const struct smb_filename *smb_fname,
2698                               char **full_name);
2699 NTSTATUS create_synthetic_smb_fname(TALLOC_CTX *ctx, const char *base_name,
2700                                     const char *stream_name,
2701                                     const SMB_STRUCT_STAT *psbuf,
2702                                     struct smb_filename **smb_fname_out);
2703 NTSTATUS create_synthetic_smb_fname_split(TALLOC_CTX *ctx,
2704                                           const char *fname,
2705                                           const SMB_STRUCT_STAT *psbuf,
2706                                           struct smb_filename **smb_fname_out);
2707 const char *smb_fname_str_dbg(const struct smb_filename *smb_fname);
2708 const char *fsp_str_dbg(const struct files_struct *fsp);
2709 NTSTATUS copy_smb_filename(TALLOC_CTX *ctx,
2710                            const struct smb_filename *smb_fname_in,
2711                            struct smb_filename **smb_fname_out);
2712 bool is_ntfs_stream_smb_fname(const struct smb_filename *smb_fname);
2713 bool is_ntfs_default_stream_smb_fname(const struct smb_filename *smb_fname);
2714
2715 /* The following definitions come from lib/dummyroot.c */
2716
2717 void become_root(void);
2718 void unbecome_root(void);
2719
2720 /* The following definitions come from lib/dummysmbd.c */
2721
2722 int find_service(TALLOC_CTX *ctx, const char *service_in, char **p_service_out);
2723 bool conn_snum_used(int snum);
2724 void cancel_pending_lock_requests_by_fid(files_struct *fsp,
2725                         struct byte_range_lock *br_lck,
2726                         enum file_close_type close_type);
2727 void send_stat_cache_delete_message(struct messaging_context *msg_ctx,
2728                                     const char *name);
2729 NTSTATUS can_delete_directory(struct connection_struct *conn,
2730                                 const char *dirname);
2731 bool change_to_root_user(void);
2732 struct event_context *smbd_event_context(void);
2733 void contend_level2_oplocks_begin(files_struct *fsp,
2734                                   enum level2_contention_type type);
2735 void contend_level2_oplocks_end(files_struct *fsp,
2736                                 enum level2_contention_type type);
2737
2738 #endif /*  _PROTO_H_  */