source: branches/samba-3.2.x/source/include/libsmb_internal.h

Last change on this file was 232, checked in by Herwig Bauernfeind, 16 years ago

Update 3.2 branch to 3.2.8

File size: 14.8 KB
Line 
1/*
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
10
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.
15
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.
20
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/>.
23*/
24
25#include "includes.h"
26
27
28#ifndef _LIBSMB_INTERNAL_H_
29#define _LIBSMB_INTERNAL_H_
30
31#include "../include/libsmbclient.h"
32
33#define SMBC_MAX_NAME 1023
34#define SMBC_FILE_MODE (S_IFREG | 0444)
35#define SMBC_DIR_MODE (S_IFDIR | 0555)
36
37/*
38 * DOS Attribute values (used internally)
39 */
40typedef struct DOS_ATTR_DESC {
41 int mode;
42 SMB_OFF_T size;
43 time_t create_time;
44 time_t access_time;
45 time_t write_time;
46 time_t change_time;
47 SMB_INO_T inode;
48} DOS_ATTR_DESC;
49
50
51/*
52 * Internal flags for extended attributes
53 */
54
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
62
63#define CREATE_ACCESS_READ READ_CONTROL_ACCESS
64
65/*We should test for this in configure ... */
66#ifndef ENOTSUP
67#define ENOTSUP EOPNOTSUPP
68#endif
69
70
71struct _SMBCSRV {
72 struct cli_state *cli;
73 dev_t dev;
74 bool no_pathinfo;
75 bool no_pathinfo2;
76 bool no_nt_session;
77 POLICY_HND pol;
78
79 SMBCSRV *next, *prev;
80
81};
82
83/*
84 * Keep directory entries in a list
85 */
86struct smbc_dir_list {
87 struct smbc_dir_list *next;
88 struct smbc_dirent *dirent;
89};
90
91
92/*
93 * Structure for open file management
94 */
95struct _SMBCFILE {
96 int cli_fd;
97 char *fname;
98 SMB_OFF_T offset;
99 struct _SMBCSRV *srv;
100 bool file;
101 struct smbc_dir_list *dir_list, *dir_end, *dir_next;
102 int dir_type, dir_error;
103
104 SMBCFILE *next, *prev;
105};
106
107
108/*
109 * Context structure
110 */
111struct SMBC_internal_data {
112
113 /* True when this handle is initialized */
114 bool initialized;
115
116 /* dirent pointer location */
117 struct smbc_dirent dirent;
118 /*
119 * Leave room for any urlencoded filename and the comment field.
120 *
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).
124 *
125 * According to <linux/limits.h>, NAME_MAX is 255. Is it longer
126 * anyplace else?
127 */
128 char _dirent_name[1024];
129
130 /*
131 * server connection list
132 */
133 SMBCSRV * servers;
134
135 /*
136 * open file/dir list
137 */
138 SMBCFILE * files;
139
140 /*
141 * Log to standard error instead of the more typical standard output
142 */
143 bool debug_stderr;
144
145 /*
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.
151 */
152 bool full_time_names;
153
154 /*
155 * The share mode of a file being opened. To match POSIX semantics
156 * (and maintain backward compatibility), DENY_NONE is the default.
157 */
158 smbc_share_mode share_mode;
159
160 /*
161 * Authentication function which includes the context. This will be
162 * used if set; otherwise context->callbacks.auth_fn() will be used.
163 */
164 smbc_get_auth_data_with_context_fn auth_fn_with_context;
165
166 /*
167 * An opaque (to this library) user data handle which can be set
168 * and retrieved with smbc_option_set() and smbc_option_get().
169 */
170 void * user_data;
171
172 /*
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.
176 */
177 smbc_smb_encrypt_level smb_encryption_level;
178
179 /*
180 * Should we request case sensitivity of file names?
181 */
182 bool case_sensitive;
183
184 struct smbc_server_cache * server_cache;
185
186 /* POSIX emulation functions */
187 struct
188 {
189#if 0 /* Left in libsmbclient.h for backward compatibility */
190 smbc_open_fn open_fn;
191 smbc_creat_fn creat_fn;
192 smbc_read_fn read_fn;
193 smbc_write_fn write_fn;
194 smbc_unlink_fn unlink_fn;
195 smbc_rename_fn rename_fn;
196 smbc_lseek_fn lseek_fn;
197 smbc_stat_fn stat_fn;
198 smbc_fstat_fn fstat_fn;
199#endif
200 smbc_ftruncate_fn ftruncate_fn;
201#if 0 /* Left in libsmbclient.h for backward compatibility */
202 smbc_close_fn close_fn;
203 smbc_opendir_fn opendir_fn;
204 smbc_closedir_fn closedir_fn;
205 smbc_readdir_fn readdir_fn;
206 smbc_getdents_fn getdents_fn;
207 smbc_mkdir_fn mkdir_fn;
208 smbc_rmdir_fn rmdir_fn;
209 smbc_telldir_fn telldir_fn;
210 smbc_lseekdir_fn lseekdir_fn;
211 smbc_fstatdir_fn fstatdir_fn;
212 smbc_chmod_fn chmod_fn;
213 smbc_utimes_fn utimes_fn;
214 smbc_setxattr_fn setxattr_fn;
215 smbc_getxattr_fn getxattr_fn;
216 smbc_removexattr_fn removexattr_fn;
217 smbc_listxattr_fn listxattr_fn;
218#endif
219 } posix_emu;
220
221#if 0 /* Left in libsmbclient.h for backward compatibility */
222 /* Printing-related functions */
223 struct
224 {
225 smbc_print_file_fn print_file_fn;
226 smbc_open_print_job_fn open_print_job_fn;
227 smbc_list_print_jobs_fn list_print_jobs_fn;
228 smbc_unlink_print_job_fn unlink_print_job_fn;
229 } printing;
230#endif
231
232#if 0 /* None available yet */
233 /* SMB high-level functions */
234 struct
235 {
236 } smb;
237
238#endif
239};
240
241/* Functions in libsmb_cache.c */
242int
243SMBC_add_cached_server(SMBCCTX * context,
244 SMBCSRV * newsrv,
245 const char * server,
246 const char * share,
247 const char * workgroup,
248 const char * username);
249
250SMBCSRV *
251SMBC_get_cached_server(SMBCCTX * context,
252 const char * server,
253 const char * share,
254 const char * workgroup,
255 const char * user);
256
257int
258SMBC_remove_cached_server(SMBCCTX * context,
259 SMBCSRV * server);
260
261int
262SMBC_purge_cached_servers(SMBCCTX * context);
263
264
265/* Functions in libsmb_dir.c */
266int
267SMBC_check_options(char *server,
268 char *share,
269 char *path,
270 char *options);
271
272SMBCFILE *
273SMBC_opendir_ctx(SMBCCTX *context,
274 const char *fname);
275
276int
277SMBC_closedir_ctx(SMBCCTX *context,
278 SMBCFILE *dir);
279
280struct smbc_dirent *
281SMBC_readdir_ctx(SMBCCTX *context,
282 SMBCFILE *dir);
283
284int
285SMBC_getdents_ctx(SMBCCTX *context,
286 SMBCFILE *dir,
287 struct smbc_dirent *dirp,
288 int count);
289
290int
291SMBC_mkdir_ctx(SMBCCTX *context,
292 const char *fname,
293 mode_t mode);
294
295int
296SMBC_rmdir_ctx(SMBCCTX *context,
297 const char *fname);
298
299off_t
300SMBC_telldir_ctx(SMBCCTX *context,
301 SMBCFILE *dir);
302
303int
304SMBC_lseekdir_ctx(SMBCCTX *context,
305 SMBCFILE *dir,
306 off_t offset);
307
308int
309SMBC_fstatdir_ctx(SMBCCTX *context,
310 SMBCFILE *dir,
311 struct stat *st);
312
313int
314SMBC_chmod_ctx(SMBCCTX *context,
315 const char *fname,
316 mode_t newmode);
317
318int
319SMBC_utimes_ctx(SMBCCTX *context,
320 const char *fname,
321 struct timeval *tbuf);
322
323int
324SMBC_unlink_ctx(SMBCCTX *context,
325 const char *fname);
326
327int
328SMBC_rename_ctx(SMBCCTX *ocontext,
329 const char *oname,
330 SMBCCTX *ncontext,
331 const char *nname);
332
333
334/* Functions in libsmb_file.c */
335SMBCFILE *
336SMBC_open_ctx(SMBCCTX *context,
337 const char *fname,
338 int flags,
339 mode_t mode);
340
341SMBCFILE *
342SMBC_creat_ctx(SMBCCTX *context,
343 const char *path,
344 mode_t mode);
345
346ssize_t
347SMBC_read_ctx(SMBCCTX *context,
348 SMBCFILE *file,
349 void *buf,
350 size_t count);
351
352ssize_t
353SMBC_write_ctx(SMBCCTX *context,
354 SMBCFILE *file,
355 void *buf,
356 size_t count);
357
358int
359SMBC_close_ctx(SMBCCTX *context,
360 SMBCFILE *file);
361
362bool
363SMBC_getatr(SMBCCTX * context,
364 SMBCSRV *srv,
365 char *path,
366 uint16 *mode,
367 SMB_OFF_T *size,
368 struct timespec *create_time_ts,
369 struct timespec *access_time_ts,
370 struct timespec *write_time_ts,
371 struct timespec *change_time_ts,
372 SMB_INO_T *ino);
373
374bool
375SMBC_setatr(SMBCCTX * context, SMBCSRV *srv, char *path,
376 time_t create_time,
377 time_t access_time,
378 time_t write_time,
379 time_t change_time,
380 uint16 mode);
381
382off_t
383SMBC_lseek_ctx(SMBCCTX *context,
384 SMBCFILE *file,
385 off_t offset,
386 int whence);
387
388int
389SMBC_ftruncate_ctx(SMBCCTX *context,
390 SMBCFILE *file,
391 off_t length);
392
393
394/* Functions in libsmb_misc.c */
395int
396SMBC_dlist_contains(SMBCFILE * list, SMBCFILE *p);
397
398int
399SMBC_errno(SMBCCTX *context,
400 struct cli_state *c);
401
402
403/* Functions in libsmb_path.c */
404int
405SMBC_parse_path(TALLOC_CTX *ctx,
406 SMBCCTX *context,
407 const char *fname,
408 char **pp_workgroup,
409 char **pp_server,
410 char **pp_share,
411 char **pp_path,
412 char **pp_user,
413 char **pp_password,
414 char **pp_options);
415
416
417/* Functions in libsmb_printjob.c */
418SMBCFILE *
419SMBC_open_print_job_ctx(SMBCCTX *context,
420 const char *fname);
421
422int
423SMBC_print_file_ctx(SMBCCTX *c_file,
424 const char *fname,
425 SMBCCTX *c_print,
426 const char *printq);
427
428int
429SMBC_list_print_jobs_ctx(SMBCCTX *context,
430 const char *fname,
431 smbc_list_print_job_fn fn);
432
433int
434SMBC_unlink_print_job_ctx(SMBCCTX *context,
435 const char *fname,
436 int id);
437
438
439/* Functions in libsmb_server.c */
440int
441SMBC_check_server(SMBCCTX * context,
442 SMBCSRV * server);
443
444int
445SMBC_remove_unused_server(SMBCCTX * context,
446 SMBCSRV * srv);
447
448void
449SMBC_call_auth_fn(TALLOC_CTX *ctx,
450 SMBCCTX *context,
451 const char *server,
452 const char *share,
453 char **pp_workgroup,
454 char **pp_username,
455 char **pp_password);
456
457void
458SMBC_get_auth_data(const char *server, const char *share,
459 char *workgroup_buf, int workgroup_buf_len,
460 char *username_buf, int username_buf_len,
461 char *password_buf, int password_buf_len);
462
463SMBCSRV *
464SMBC_find_server(TALLOC_CTX *ctx,
465 SMBCCTX *context,
466 const char *server,
467 const char *share,
468 char **pp_workgroup,
469 char **pp_username,
470 char **pp_password);
471
472SMBCSRV *
473SMBC_server(TALLOC_CTX *ctx,
474 SMBCCTX *context,
475 bool connect_if_not_found,
476 const char *server,
477 const char *share,
478 char **pp_workgroup,
479 char **pp_username,
480 char **pp_password);
481
482SMBCSRV *
483SMBC_attr_server(TALLOC_CTX *ctx,
484 SMBCCTX *context,
485 const char *server,
486 const char *share,
487 char **pp_workgroup,
488 char **pp_username,
489 char **pp_password);
490
491
492/* Functions in libsmb_stat.c */
493int
494SMBC_stat_ctx(SMBCCTX *context,
495 const char *fname,
496 struct stat *st);
497
498int
499SMBC_fstat_ctx(SMBCCTX *context,
500 SMBCFILE *file,
501 struct stat *st);
502
503
504/* Functions in libsmb_xattr.c */
505int
506SMBC_setxattr_ctx(SMBCCTX *context,
507 const char *fname,
508 const char *name,
509 const void *value,
510 size_t size,
511 int flags);
512
513int
514SMBC_getxattr_ctx(SMBCCTX *context,
515 const char *fname,
516 const char *name,
517 const void *value,
518 size_t size);
519
520int
521SMBC_removexattr_ctx(SMBCCTX *context,
522 const char *fname,
523 const char *name);
524
525int
526SMBC_listxattr_ctx(SMBCCTX *context,
527 const char *fname,
528 char *list,
529 size_t size);
530
531
532#endif
Note: See TracBrowser for help on using the repository browser.