2
Unix SMB/Netbios implementation.
3
SMB client library implementation
4
Copyright (C) Andrew Tridgell 1998
5
Copyright (C) Richard Sharpe 2000, 2002
6
Copyright (C) John Terpstra 2000
7
Copyright (C) Tom Jansen (Ninja ISD) 2002
8
Copyright (C) Derrell Lipman 2003-2008
9
Copyright (C) Jeremy Allison 2007, 2008
11
This program is free software; you can redistribute it and/or modify
12
it under the terms of the GNU General Public License as published by
13
the Free Software Foundation; either version 3 of the License, or
14
(at your option) any later version.
16
This program is distributed in the hope that it will be useful,
17
but WITHOUT ANY WARRANTY; without even the implied warranty of
18
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
GNU General Public License for more details.
21
You should have received a copy of the GNU General Public License
22
along with this program. If not, see <http://www.gnu.org/licenses/>.
28
#ifndef _LIBSMB_INTERNAL_H_
29
#define _LIBSMB_INTERNAL_H_
31
#include "../include/libsmbclient.h"
33
#define SMBC_MAX_NAME 1023
34
#define SMBC_FILE_MODE (S_IFREG | 0444)
35
#define SMBC_DIR_MODE (S_IFDIR | 0555)
38
* DOS Attribute values (used internally)
40
typedef struct DOS_ATTR_DESC {
52
* Internal flags for extended attributes
55
/* internal mode values */
56
#define SMBC_XATTR_MODE_ADD 1
57
#define SMBC_XATTR_MODE_REMOVE 2
58
#define SMBC_XATTR_MODE_REMOVE_ALL 3
59
#define SMBC_XATTR_MODE_SET 4
60
#define SMBC_XATTR_MODE_CHOWN 5
61
#define SMBC_XATTR_MODE_CHGRP 6
63
#define CREATE_ACCESS_READ READ_CONTROL_ACCESS
65
/*We should test for this in configure ... */
67
#define ENOTSUP EOPNOTSUPP
72
struct cli_state *cli;
77
struct policy_handle pol;
84
* Keep directory entries in a list
86
struct smbc_dir_list {
87
struct smbc_dir_list *next;
88
struct smbc_dirent *dirent;
93
* Structure for open file management
101
struct smbc_dir_list *dir_list, *dir_end, *dir_next;
102
int dir_type, dir_error;
104
SMBCFILE *next, *prev;
111
struct SMBC_internal_data {
113
/* True when this handle is initialized */
116
/* dirent pointer location */
117
struct smbc_dirent dirent;
119
* Leave room for any urlencoded filename and the comment field.
121
* We use (NAME_MAX * 3) plus whatever the max length of a comment is,
122
* plus a couple of null terminators (one after the filename,
123
* one after the comment).
125
* According to <linux/limits.h>, NAME_MAX is 255. Is it longer
128
char _dirent_name[1024];
131
* server connection list
141
* Log to standard error instead of the more typical standard output
146
* Support "Create Time" in get/set with the *xattr() functions, if
147
* true. This replaces the dos attribute strings C_TIME, A_TIME and
148
* M_TIME with CHANGE_TIME, ACCESS_TIME and WRITE_TIME, and adds
149
* CREATE_TIME. Default is FALSE, i.e. to use the old-style shorter
150
* names and to not support CREATE time, for backward compatibility.
152
bool full_time_names;
155
* The share mode of a file being opened. To match POSIX semantics
156
* (and maintain backward compatibility), DENY_NONE is the default.
158
smbc_share_mode share_mode;
161
* Authentication function which includes the context. This will be
162
* used if set; otherwise context->callbacks.auth_fn() will be used.
164
smbc_get_auth_data_with_context_fn auth_fn_with_context;
167
* An opaque (to this library) user data handle which can be set
168
* and retrieved with smbc_option_set() and smbc_option_get().
173
* Should we attempt UNIX smb encryption ?
174
* Set to 0 if we should never attempt, set to 1 if
175
* encryption requested, set to 2 if encryption required.
177
smbc_smb_encrypt_level smb_encryption_level;
180
* Should we request case sensitivity of file names?
185
* Auth info needed for DFS traversal.
188
struct user_auth_info *auth_info;
190
struct smbc_server_cache * server_cache;
192
/* POSIX emulation functions */
195
#if 0 /* Left in libsmbclient.h for backward compatibility */
196
smbc_open_fn open_fn;
197
smbc_creat_fn creat_fn;
198
smbc_read_fn read_fn;
199
smbc_write_fn write_fn;
200
smbc_unlink_fn unlink_fn;
201
smbc_rename_fn rename_fn;
202
smbc_lseek_fn lseek_fn;
203
smbc_stat_fn stat_fn;
204
smbc_fstat_fn fstat_fn;
206
smbc_statvfs_fn statvfs_fn;
207
smbc_fstatvfs_fn fstatvfs_fn;
208
smbc_ftruncate_fn ftruncate_fn;
209
#if 0 /* Left in libsmbclient.h for backward compatibility */
210
smbc_close_fn close_fn;
211
smbc_opendir_fn opendir_fn;
212
smbc_closedir_fn closedir_fn;
213
smbc_readdir_fn readdir_fn;
214
smbc_getdents_fn getdents_fn;
215
smbc_mkdir_fn mkdir_fn;
216
smbc_rmdir_fn rmdir_fn;
217
smbc_telldir_fn telldir_fn;
218
smbc_lseekdir_fn lseekdir_fn;
219
smbc_fstatdir_fn fstatdir_fn;
220
smbc_chmod_fn chmod_fn;
221
smbc_utimes_fn utimes_fn;
222
smbc_setxattr_fn setxattr_fn;
223
smbc_getxattr_fn getxattr_fn;
224
smbc_removexattr_fn removexattr_fn;
225
smbc_listxattr_fn listxattr_fn;
229
#if 0 /* Left in libsmbclient.h for backward compatibility */
230
/* Printing-related functions */
233
smbc_print_file_fn print_file_fn;
234
smbc_open_print_job_fn open_print_job_fn;
235
smbc_list_print_jobs_fn list_print_jobs_fn;
236
smbc_unlink_print_job_fn unlink_print_job_fn;
240
#if 0 /* None available yet */
241
/* SMB high-level functions */
249
/* Functions in libsmb_cache.c */
251
SMBC_add_cached_server(SMBCCTX * context,
255
const char * workgroup,
256
const char * username);
259
SMBC_get_cached_server(SMBCCTX * context,
262
const char * workgroup,
266
SMBC_remove_cached_server(SMBCCTX * context,
270
SMBC_purge_cached_servers(SMBCCTX * context);
273
/* Functions in libsmb_dir.c */
275
SMBC_check_options(char *server,
281
SMBC_opendir_ctx(SMBCCTX *context,
285
SMBC_closedir_ctx(SMBCCTX *context,
289
SMBC_readdir_ctx(SMBCCTX *context,
293
SMBC_getdents_ctx(SMBCCTX *context,
295
struct smbc_dirent *dirp,
299
SMBC_mkdir_ctx(SMBCCTX *context,
304
SMBC_rmdir_ctx(SMBCCTX *context,
308
SMBC_telldir_ctx(SMBCCTX *context,
312
SMBC_lseekdir_ctx(SMBCCTX *context,
317
SMBC_fstatdir_ctx(SMBCCTX *context,
322
SMBC_chmod_ctx(SMBCCTX *context,
327
SMBC_utimes_ctx(SMBCCTX *context,
329
struct timeval *tbuf);
332
SMBC_unlink_ctx(SMBCCTX *context,
336
SMBC_rename_ctx(SMBCCTX *ocontext,
342
/* Functions in libsmb_file.c */
344
SMBC_open_ctx(SMBCCTX *context,
350
SMBC_creat_ctx(SMBCCTX *context,
355
SMBC_read_ctx(SMBCCTX *context,
361
SMBC_write_ctx(SMBCCTX *context,
367
SMBC_close_ctx(SMBCCTX *context,
371
SMBC_getatr(SMBCCTX * context,
376
struct timespec *create_time_ts,
377
struct timespec *access_time_ts,
378
struct timespec *write_time_ts,
379
struct timespec *change_time_ts,
383
SMBC_setatr(SMBCCTX * context, SMBCSRV *srv, char *path,
391
SMBC_lseek_ctx(SMBCCTX *context,
397
SMBC_ftruncate_ctx(SMBCCTX *context,
402
/* Functions in libsmb_misc.c */
404
SMBC_dlist_contains(SMBCFILE * list, SMBCFILE *p);
407
SMBC_errno(SMBCCTX *context,
408
struct cli_state *c);
411
/* Functions in libsmb_path.c */
413
SMBC_parse_path(TALLOC_CTX *ctx,
425
/* Functions in libsmb_printjob.c */
427
SMBC_open_print_job_ctx(SMBCCTX *context,
431
SMBC_print_file_ctx(SMBCCTX *c_file,
437
SMBC_list_print_jobs_ctx(SMBCCTX *context,
439
smbc_list_print_job_fn fn);
442
SMBC_unlink_print_job_ctx(SMBCCTX *context,
447
/* Functions in libsmb_server.c */
449
SMBC_check_server(SMBCCTX * context,
453
SMBC_remove_unused_server(SMBCCTX * context,
457
SMBC_call_auth_fn(TALLOC_CTX *ctx,
466
SMBC_get_auth_data(const char *server, const char *share,
467
char *workgroup_buf, int workgroup_buf_len,
468
char *username_buf, int username_buf_len,
469
char *password_buf, int password_buf_len);
472
SMBC_find_server(TALLOC_CTX *ctx,
481
SMBC_server(TALLOC_CTX *ctx,
483
bool connect_if_not_found,
491
SMBC_attr_server(TALLOC_CTX *ctx,
500
/* Functions in libsmb_stat.c */
502
SMBC_stat_ctx(SMBCCTX *context,
507
SMBC_fstat_ctx(SMBCCTX *context,
513
SMBC_statvfs_ctx(SMBCCTX *context,
519
SMBC_fstatvfs_ctx(SMBCCTX *context,
524
/* Functions in libsmb_xattr.c */
526
SMBC_setxattr_ctx(SMBCCTX *context,
534
SMBC_getxattr_ctx(SMBCCTX *context,
541
SMBC_removexattr_ctx(SMBCCTX *context,
546
SMBC_listxattr_ctx(SMBCCTX *context,