source: vendor/3.5.0/source3/include/libsmbclient.h

Last change on this file was 414, checked in by Herwig Bauernfeind, 15 years ago

Samba 3.5.0: Initial import

File size: 115.2 KB
Line 
1/*=====================================================================
2 Unix SMB/Netbios implementation.
3 SMB client library API definitions
4 Copyright (C) Andrew Tridgell 1998
5 Copyright (C) Richard Sharpe 2000
6 Copyright (C) John Terpsra 2000
7 Copyright (C) Tom Jansen (Ninja ISD) 2002
8 Copyright (C) Derrell Lipman 2003-2008
9
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#ifndef SMBCLIENT_H_INCLUDED
26#define SMBCLIENT_H_INCLUDED
27
28#undef DEPRECATED_SMBC_INTERFACE
29#if ! defined(__LIBSMBCLIENT_INTERNAL__) && defined(__GNUC__)
30# define DEPRECATED_SMBC_INTERFACE __attribute__ ((deprecated))
31#else
32# define DEPRECATED_SMBC_INTERFACE
33#endif
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
39/*-------------------------------------------------------------------*/
40/* The following are special comments to instruct DOXYGEN (automated
41 * documentation tool:
42*/
43/** \defgroup libsmbclient
44*/
45/** \defgroup structure Data Structures Type and Constants
46* \ingroup libsmbclient
47* Data structures, types, and constants
48*/
49/** \defgroup callback Callback function types
50* \ingroup libsmbclient
51* Callback functions
52*/
53/** \defgroup file File Functions
54* \ingroup libsmbclient
55* Functions used to access individual file contents
56*/
57/** \defgroup directory Directory Functions
58* \ingroup libsmbclient
59* Functions used to access directory entries
60*/
61/** \defgroup attribute Attributes Functions
62* \ingroup libsmbclient
63* Functions used to view or change file and directory attributes
64*/
65/** \defgroup print Print Functions
66* \ingroup libsmbclient
67* Functions used to access printing functionality
68*/
69/** \defgroup misc Miscellaneous Functions
70* \ingroup libsmbclient
71* Functions that don't fit in to other categories
72*/
73/*-------------------------------------------------------------------*/
74
75/* Make sure we have the following includes for now ... */
76#include <sys/types.h>
77#include <sys/stat.h>
78#include <sys/statvfs.h>
79#include <fcntl.h>
80#include <utime.h>
81
82#define SMBC_BASE_FD 10000 /* smallest file descriptor returned */
83
84#define SMBC_WORKGROUP 1
85#define SMBC_SERVER 2
86#define SMBC_FILE_SHARE 3
87#define SMBC_PRINTER_SHARE 4
88#define SMBC_COMMS_SHARE 5
89#define SMBC_IPC_SHARE 6
90#define SMBC_DIR 7
91#define SMBC_FILE 8
92#define SMBC_LINK 9
93
94/**@ingroup structure
95 * Structure that represents a directory entry.
96 *
97 */
98struct smbc_dirent
99{
100 /** Type of entity.
101 SMBC_WORKGROUP=1,
102 SMBC_SERVER=2,
103 SMBC_FILE_SHARE=3,
104 SMBC_PRINTER_SHARE=4,
105 SMBC_COMMS_SHARE=5,
106 SMBC_IPC_SHARE=6,
107 SMBC_DIR=7,
108 SMBC_FILE=8,
109 SMBC_LINK=9,*/
110 unsigned int smbc_type;
111
112 /** Length of this smbc_dirent in bytes
113 */
114 unsigned int dirlen;
115 /** The length of the comment string in bytes (does not include
116 * null terminator)
117 */
118 unsigned int commentlen;
119 /** Points to the null terminated comment string
120 */
121 char *comment;
122 /** The length of the name string in bytes (does not include
123 * null terminator)
124 */
125 unsigned int namelen;
126 /** Points to the null terminated name string
127 */
128 char name[1];
129};
130
131/*
132 * Flags for smbc_setxattr()
133 * Specify a bitwise OR of these, or 0 to add or replace as necessary
134 */
135#define SMBC_XATTR_FLAG_CREATE 0x1 /* fail if attr already exists */
136#define SMBC_XATTR_FLAG_REPLACE 0x2 /* fail if attr does not exist */
137
138
139/*
140 * Mappings of the DOS mode bits, as returned by smbc_getxattr() when the
141 * attribute name "system.dos_attr.mode" (or "system.dos_attr.*" or
142 * "system.*") is specified.
143 */
144#define SMBC_DOS_MODE_READONLY 0x01
145#define SMBC_DOS_MODE_HIDDEN 0x02
146#define SMBC_DOS_MODE_SYSTEM 0x04
147#define SMBC_DOS_MODE_VOLUME_ID 0x08
148#define SMBC_DOS_MODE_DIRECTORY 0x10
149#define SMBC_DOS_MODE_ARCHIVE 0x20
150
151/*
152 * Valid values for the option "open_share_mode", when calling
153 * smbc_setOptionOpenShareMode()
154 */
155typedef enum smbc_share_mode
156{
157 SMBC_SHAREMODE_DENY_DOS = 0,
158 SMBC_SHAREMODE_DENY_ALL = 1,
159 SMBC_SHAREMODE_DENY_WRITE = 2,
160 SMBC_SHAREMODE_DENY_READ = 3,
161 SMBC_SHAREMODE_DENY_NONE = 4,
162 SMBC_SHAREMODE_DENY_FCB = 7
163} smbc_share_mode;
164
165
166/**
167 * Values for option SMB Encryption Level, as set and retrieved with
168 * smbc_setOptionSmbEncryptionLevel() and smbc_getOptionSmbEncryptionLevel()
169 */
170typedef enum smbc_smb_encrypt_level
171{
172 SMBC_ENCRYPTLEVEL_NONE = 0,
173 SMBC_ENCRYPTLEVEL_REQUEST = 1,
174 SMBC_ENCRYPTLEVEL_REQUIRE = 2
175} smbc_smb_encrypt_level;
176
177
178/**
179 * Capabilities set in the f_flag field of struct statvfs, from
180 * smbc_statvfs(). These may be OR-ed together to reflect a full set of
181 * available capabilities.
182 */
183typedef enum smbc_vfs_feature
184{
185 /* Defined by POSIX or in Linux include files (low-order bits) */
186 SMBC_VFS_FEATURE_RDONLY = (1 << 0),
187
188 /* Specific to libsmbclient (high-order bits) */
189 SMBC_VFS_FEATURE_DFS = (1 << 28),
190 SMBC_VFS_FEATURE_CASE_INSENSITIVE = (1 << 29),
191 SMBC_VFS_FEATURE_NO_UNIXCIFS = (1 << 30)
192} smbc_vfs_feature;
193
194typedef int smbc_bool;
195
196
197#ifndef ENOATTR
198# define ENOATTR ENOENT /* No such attribute */
199#endif
200
201
202
203
204/**@ingroup structure
205 * Structure that represents a print job.
206 *
207 */
208#ifndef _CLIENT_H
209struct print_job_info
210{
211 /** numeric ID of the print job
212 */
213 unsigned short id;
214
215 /** represents print job priority (lower numbers mean higher priority)
216 */
217 unsigned short priority;
218
219 /** Size of the print job
220 */
221 size_t size;
222
223 /** Name of the user that owns the print job
224 */
225 char user[128];
226
227 /** Name of the print job. This will have no name if an anonymous print
228 * file was opened. Ie smb://server/printer
229 */
230 char name[128];
231
232 /** Time the print job was spooled
233 */
234 time_t t;
235};
236#endif /* _CLIENT_H */
237
238
239/**@ingroup structure
240 * Server handle
241 */
242typedef struct _SMBCSRV SMBCSRV;
243
244/**@ingroup structure
245 * File or directory handle
246 */
247typedef struct _SMBCFILE SMBCFILE;
248
249/**@ingroup structure
250 * File or directory handle
251 */
252typedef struct _SMBCCTX SMBCCTX;
253
254
255/*
256 * Flags for SMBCCTX->flags
257 *
258 * NEW CODE SHOULD NOT DIRECTLY MANIPULATE THE CONTEXT STRUCTURE.
259 * Instead, use:
260 * smbc_setOptionUseKerberos()
261 * smbc_getOptionUseKerberos()
262 * smbc_setOptionFallbackAfterKerberos()
263 * smbc_getOptionFallbackAFterKerberos()
264 * smbc_setOptionNoAutoAnonymousLogin()
265 * smbc_getOptionNoAutoAnonymousLogin()
266 * smbc_setOptionUseCCache()
267 * smbc_getOptionUseCCache()
268 */
269# define SMB_CTX_FLAG_USE_KERBEROS (1 << 0)
270# define SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS (1 << 1)
271# define SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON (1 << 2)
272# define SMB_CTX_FLAG_USE_CCACHE (1 << 3)
273
274
275
276/**@ingroup callback
277 * Authentication callback function type (traditional method)
278 *
279 * Type for the the authentication function called by the library to
280 * obtain authentication credentals
281 *
282 * For kerberos support the function should just be called without
283 * prompting the user for credentials. Which means a simple 'return'
284 * should work. Take a look at examples/libsmbclient/get_auth_data_fn.h
285 * and examples/libsmbclient/testbrowse.c.
286 *
287 * @param srv Server being authenticated to
288 *
289 * @param shr Share being authenticated to
290 *
291 * @param wg Pointer to buffer containing a "hint" for the
292 * workgroup to be authenticated. Should be filled in
293 * with the correct workgroup if the hint is wrong.
294 *
295 * @param wglen The size of the workgroup buffer in bytes
296 *
297 * @param un Pointer to buffer containing a "hint" for the
298 * user name to be use for authentication. Should be
299 * filled in with the correct workgroup if the hint is
300 * wrong.
301 *
302 * @param unlen The size of the username buffer in bytes
303 *
304 * @param pw Pointer to buffer containing to which password
305 * copied
306 *
307 * @param pwlen The size of the password buffer in bytes
308 *
309 */
310typedef void (*smbc_get_auth_data_fn)(const char *srv,
311 const char *shr,
312 char *wg, int wglen,
313 char *un, int unlen,
314 char *pw, int pwlen);
315/**@ingroup callback
316 * Authentication callback function type (method that includes context)
317 *
318 * Type for the the authentication function called by the library to
319 * obtain authentication credentals
320 *
321 * For kerberos support the function should just be called without
322 * prompting the user for credentials. Which means a simple 'return'
323 * should work. Take a look at examples/libsmbclient/get_auth_data_fn.h
324 * and examples/libsmbclient/testbrowse.c.
325 *
326 * @param c Pointer to the smb context
327 *
328 * @param srv Server being authenticated to
329 *
330 * @param shr Share being authenticated to
331 *
332 * @param wg Pointer to buffer containing a "hint" for the
333 * workgroup to be authenticated. Should be filled in
334 * with the correct workgroup if the hint is wrong.
335 *
336 * @param wglen The size of the workgroup buffer in bytes
337 *
338 * @param un Pointer to buffer containing a "hint" for the
339 * user name to be use for authentication. Should be
340 * filled in with the correct workgroup if the hint is
341 * wrong.
342 *
343 * @param unlen The size of the username buffer in bytes
344 *
345 * @param pw Pointer to buffer containing to which password
346 * copied
347 *
348 * @param pwlen The size of the password buffer in bytes
349 *
350 */
351typedef void (*smbc_get_auth_data_with_context_fn)(SMBCCTX *c,
352 const char *srv,
353 const char *shr,
354 char *wg, int wglen,
355 char *un, int unlen,
356 char *pw, int pwlen);
357
358
359/**@ingroup callback
360 * Print job info callback function type.
361 *
362 * @param i pointer to print job information structure
363 *
364 */
365typedef void (*smbc_list_print_job_fn)(struct print_job_info *i);
366
367
368/**@ingroup callback
369 * Check if a server is still good
370 *
371 * @param c pointer to smb context
372 *
373 * @param srv pointer to server to check
374 *
375 * @return 0 when connection is good. 1 on error.
376 *
377 */
378typedef int (*smbc_check_server_fn)(SMBCCTX * c, SMBCSRV *srv);
379
380/**@ingroup callback
381 * Remove a server if unused
382 *
383 * @param c pointer to smb context
384 *
385 * @param srv pointer to server to remove
386 *
387 * @return 0 on success. 1 on failure.
388 *
389 */
390typedef int (*smbc_remove_unused_server_fn)(SMBCCTX * c, SMBCSRV *srv);
391
392
393/**@ingroup callback
394 * Add a server to the cache system
395 *
396 * @param c pointer to smb context
397 *
398 * @param srv pointer to server to add
399 *
400 * @param server server name
401 *
402 * @param share share name
403 *
404 * @param workgroup workgroup used to connect
405 *
406 * @param username username used to connect
407 *
408 * @return 0 on success. 1 on failure.
409 *
410 */
411typedef int (*smbc_add_cached_srv_fn) (SMBCCTX * c, SMBCSRV *srv,
412 const char * server, const char * share,
413 const char * workgroup, const char * username);
414
415/**@ingroup callback
416 * Look up a server in the cache system
417 *
418 * @param c pointer to smb context
419 *
420 * @param server server name to match
421 *
422 * @param share share name to match
423 *
424 * @param workgroup workgroup to match
425 *
426 * @param username username to match
427 *
428 * @return pointer to SMBCSRV on success. NULL on failure.
429 *
430 */
431typedef SMBCSRV * (*smbc_get_cached_srv_fn) (SMBCCTX * c, const char * server,
432 const char * share, const char * workgroup,
433 const char * username);
434
435/**@ingroup callback
436 * Check if a server is still good
437 *
438 * @param c pointer to smb context
439 *
440 * @param srv pointer to server to remove
441 *
442 * @return 0 when found and removed. 1 on failure.
443 *
444 */
445typedef int (*smbc_remove_cached_srv_fn)(SMBCCTX * c, SMBCSRV *srv);
446
447
448/**@ingroup callback
449 * Try to remove all servers from the cache system and disconnect
450 *
451 * @param c pointer to smb context
452 *
453 * @return 0 when found and removed. 1 on failure.
454 *
455 */
456typedef int (*smbc_purge_cached_fn) (SMBCCTX * c);
457
458
459
460/*****************************************
461 * Getters and setters for CONFIGURATION *
462 *****************************************/
463
464/** Get the debug level */
465int
466smbc_getDebug(SMBCCTX *c);
467
468/** Set the debug level */
469void
470smbc_setDebug(SMBCCTX *c, int debug);
471
472/** Get the netbios name used for making connections */
473char *
474smbc_getNetbiosName(SMBCCTX *c);
475
476/** Set the netbios name used for making connections */
477void
478smbc_setNetbiosName(SMBCCTX *c, char * netbios_name);
479
480/** Get the workgroup used for making connections */
481char *
482smbc_getWorkgroup(SMBCCTX *c);
483
484/** Set the workgroup used for making connections */
485void smbc_setWorkgroup(SMBCCTX *c, char * workgroup);
486
487/** Get the username used for making connections */
488char *
489smbc_getUser(SMBCCTX *c);
490
491/** Set the username used for making connections */
492void
493smbc_setUser(SMBCCTX *c, char * user);
494
495/**
496 * Get the timeout used for waiting on connections and response data
497 * (in milliseconds)
498 */
499int
500smbc_getTimeout(SMBCCTX *c);
501
502/**
503 * Set the timeout used for waiting on connections and response data
504 * (in milliseconds)
505 */
506void
507smbc_setTimeout(SMBCCTX *c, int timeout);
508
509
510
511/***********************************
512 * Getters and setters for OPTIONS *
513 ***********************************/
514
515/** Get whether to log to standard error instead of standard output */
516smbc_bool
517smbc_getOptionDebugToStderr(SMBCCTX *c);
518
519/** Set whether to log to standard error instead of standard output */
520void
521smbc_setOptionDebugToStderr(SMBCCTX *c, smbc_bool b);
522
523/**
524 * Get whether to use new-style time attribute names, e.g. WRITE_TIME rather
525 * than the old-style names such as M_TIME. This allows also setting/getting
526 * CREATE_TIME which was previously unimplemented. (Note that the old C_TIME
527 * was supposed to be CHANGE_TIME but was confused and sometimes referred to
528 * CREATE_TIME.)
529 */
530smbc_bool
531smbc_getOptionFullTimeNames(SMBCCTX *c);
532
533/**
534 * Set whether to use new-style time attribute names, e.g. WRITE_TIME rather
535 * than the old-style names such as M_TIME. This allows also setting/getting
536 * CREATE_TIME which was previously unimplemented. (Note that the old C_TIME
537 * was supposed to be CHANGE_TIME but was confused and sometimes referred to
538 * CREATE_TIME.)
539 */
540void
541smbc_setOptionFullTimeNames(SMBCCTX *c, smbc_bool b);
542
543/**
544 * Get the share mode to use for files opened with SMBC_open_ctx(). The
545 * default is SMBC_SHAREMODE_DENY_NONE.
546 */
547smbc_share_mode
548smbc_getOptionOpenShareMode(SMBCCTX *c);
549
550/**
551 * Set the share mode to use for files opened with SMBC_open_ctx(). The
552 * default is SMBC_SHAREMODE_DENY_NONE.
553 */
554void
555smbc_setOptionOpenShareMode(SMBCCTX *c, smbc_share_mode share_mode);
556
557/** Retrieve a previously saved user data handle */
558void *
559smbc_getOptionUserData(SMBCCTX *c);
560
561/** Save a user data handle */
562void
563smbc_setOptionUserData(SMBCCTX *c, void *user_data);
564
565/** Get the encoded value for encryption level. */
566smbc_smb_encrypt_level
567smbc_getOptionSmbEncryptionLevel(SMBCCTX *c);
568
569/** Set the encoded value for encryption level. */
570void
571smbc_setOptionSmbEncryptionLevel(SMBCCTX *c, smbc_smb_encrypt_level level);
572
573/**
574 * Get whether to treat file names as case-sensitive if we can't determine
575 * when connecting to the remote share whether the file system is case
576 * sensitive. This defaults to FALSE since it's most likely that if we can't
577 * retrieve the file system attributes, it's a very old file system that does
578 * not support case sensitivity.
579 */
580smbc_bool
581smbc_getOptionCaseSensitive(SMBCCTX *c);
582
583/**
584 * Set whether to treat file names as case-sensitive if we can't determine
585 * when connecting to the remote share whether the file system is case
586 * sensitive. This defaults to FALSE since it's most likely that if we can't
587 * retrieve the file system attributes, it's a very old file system that does
588 * not support case sensitivity.
589 */
590void
591smbc_setOptionCaseSensitive(SMBCCTX *c, smbc_bool b);
592
593
594/**
595 * Get from how many local master browsers should the list of workgroups be
596 * retrieved. It can take up to 12 minutes or longer after a server becomes a
597 * local master browser, for it to have the entire browse list (the list of
598 * workgroups/domains) from an entire network. Since a client never knows
599 * which local master browser will be found first, the one which is found
600 * first and used to retrieve a browse list may have an incomplete or empty
601 * browse list. By requesting the browse list from multiple local master
602 * browsers, a more complete list can be generated. For small networks (few
603 * workgroups), it is recommended that this value be set to 0, causing the
604 * browse lists from all found local master browsers to be retrieved and
605 * merged. For networks with many workgroups, a suitable value for this
606 * variable is probably somewhere around 3. (Default: 3).
607 */
608int
609smbc_getOptionBrowseMaxLmbCount(SMBCCTX *c);
610
611/**
612 * Set from how many local master browsers should the list of workgroups be
613 * retrieved. It can take up to 12 minutes or longer after a server becomes a
614 * local master browser, for it to have the entire browse list (the list of
615 * workgroups/domains) from an entire network. Since a client never knows
616 * which local master browser will be found first, the one which is found
617 * first and used to retrieve a browse list may have an incomplete or empty
618 * browse list. By requesting the browse list from multiple local master
619 * browsers, a more complete list can be generated. For small networks (few
620 * workgroups), it is recommended that this value be set to 0, causing the
621 * browse lists from all found local master browsers to be retrieved and
622 * merged. For networks with many workgroups, a suitable value for this
623 * variable is probably somewhere around 3. (Default: 3).
624 */
625void
626smbc_setOptionBrowseMaxLmbCount(SMBCCTX *c, int count);
627
628/**
629 * Get whether to url-encode readdir entries.
630 *
631 * There is a difference in the desired return strings from
632 * smbc_readdir() depending upon whether the filenames are to
633 * be displayed to the user, or whether they are to be
634 * appended to the path name passed to smbc_opendir() to call
635 * a further smbc_ function (e.g. open the file with
636 * smbc_open()). In the former case, the filename should be
637 * in "human readable" form. In the latter case, the smbc_
638 * functions expect a URL which must be url-encoded. Those
639 * functions decode the URL. If, for example, smbc_readdir()
640 * returned a file name of "abc%20def.txt", passing a path
641 * with this file name attached to smbc_open() would cause
642 * smbc_open to attempt to open the file "abc def.txt" since
643 * the %20 is decoded into a space.
644 *
645 * Set this option to True if the names returned by
646 * smbc_readdir() should be url-encoded such that they can be
647 * passed back to another smbc_ call. Set it to False if the
648 * names returned by smbc_readdir() are to be presented to the
649 * user.
650 *
651 * For backwards compatibility, this option defaults to False.
652 */
653smbc_bool
654smbc_getOptionUrlEncodeReaddirEntries(SMBCCTX *c);
655
656/**
657 * Set whether to url-encode readdir entries.
658 *
659 * There is a difference in the desired return strings from
660 * smbc_readdir() depending upon whether the filenames are to
661 * be displayed to the user, or whether they are to be
662 * appended to the path name passed to smbc_opendir() to call
663 * a further smbc_ function (e.g. open the file with
664 * smbc_open()). In the former case, the filename should be
665 * in "human readable" form. In the latter case, the smbc_
666 * functions expect a URL which must be url-encoded. Those
667 * functions decode the URL. If, for example, smbc_readdir()
668 * returned a file name of "abc%20def.txt", passing a path
669 * with this file name attached to smbc_open() would cause
670 * smbc_open to attempt to open the file "abc def.txt" since
671 * the %20 is decoded into a space.
672 *
673 * Set this option to True if the names returned by
674 * smbc_readdir() should be url-encoded such that they can be
675 * passed back to another smbc_ call. Set it to False if the
676 * names returned by smbc_readdir() are to be presented to the
677 * user.
678 *
679 * For backwards compatibility, this option defaults to False.
680 */
681void
682smbc_setOptionUrlEncodeReaddirEntries(SMBCCTX *c, smbc_bool b);
683
684/**
685 * Get whether to use the same connection for all shares on a server.
686 *
687 * Some Windows versions appear to have a limit to the number
688 * of concurrent SESSIONs and/or TREE CONNECTions. In
689 * one-shot programs (i.e. the program runs and then quickly
690 * ends, thereby shutting down all connections), it is
691 * probably reasonable to establish a new connection for each
692 * share. In long-running applications, the limitation can be
693 * avoided by using only a single connection to each server,
694 * and issuing a new TREE CONNECT when the share is accessed.
695 */
696smbc_bool
697smbc_getOptionOneSharePerServer(SMBCCTX *c);
698
699/**
700 * Set whether to use the same connection for all shares on a server.
701 *
702 * Some Windows versions appear to have a limit to the number
703 * of concurrent SESSIONs and/or TREE CONNECTions. In
704 * one-shot programs (i.e. the program runs and then quickly
705 * ends, thereby shutting down all connections), it is
706 * probably reasonable to establish a new connection for each
707 * share. In long-running applications, the limitation can be
708 * avoided by using only a single connection to each server,
709 * and issuing a new TREE CONNECT when the share is accessed.
710 */
711void
712smbc_setOptionOneSharePerServer(SMBCCTX *c, smbc_bool b);
713
714/** Get whether to enable use of kerberos */
715smbc_bool
716smbc_getOptionUseKerberos(SMBCCTX *c);
717
718/** Set whether to enable use of kerberos */
719void
720smbc_setOptionUseKerberos(SMBCCTX *c, smbc_bool b);
721
722/** Get whether to fallback after kerberos */
723smbc_bool
724smbc_getOptionFallbackAfterKerberos(SMBCCTX *c);
725
726/** Set whether to fallback after kerberos */
727void
728smbc_setOptionFallbackAfterKerberos(SMBCCTX *c, smbc_bool b);
729
730/** Get whether to automatically select anonymous login */
731smbc_bool
732smbc_getOptionNoAutoAnonymousLogin(SMBCCTX *c);
733
734/** Set whether to automatically select anonymous login */
735void
736smbc_setOptionNoAutoAnonymousLogin(SMBCCTX *c, smbc_bool b);
737
738/** Get whether to enable use of the winbind ccache */
739smbc_bool
740smbc_getOptionUseCCache(SMBCCTX *c);
741
742/** Set whether to enable use of the winbind ccache */
743void
744smbc_setOptionUseCCache(SMBCCTX *c, smbc_bool b);
745
746
747
748/*************************************
749 * Getters and setters for FUNCTIONS *
750 *************************************/
751
752/** Get the function for obtaining authentication data */
753smbc_get_auth_data_fn smbc_getFunctionAuthData(SMBCCTX *c);
754
755/** Set the function for obtaining authentication data */
756void smbc_setFunctionAuthData(SMBCCTX *c, smbc_get_auth_data_fn fn);
757
758/** Get the new-style authentication function which includes the context. */
759smbc_get_auth_data_with_context_fn
760smbc_getFunctionAuthDataWithContext(SMBCCTX *c);
761
762/** Set the new-style authentication function which includes the context. */
763void
764smbc_setFunctionAuthDataWithContext(SMBCCTX *c,
765 smbc_get_auth_data_with_context_fn fn);
766
767/** Get the function for checking if a server is still good */
768smbc_check_server_fn smbc_getFunctionCheckServer(SMBCCTX *c);
769
770/** Set the function for checking if a server is still good */
771void smbc_setFunctionCheckServer(SMBCCTX *c, smbc_check_server_fn fn);
772
773/** Get the function for removing a server if unused */
774smbc_remove_unused_server_fn smbc_getFunctionRemoveUnusedServer(SMBCCTX *c);
775
776/** Set the function for removing a server if unused */
777void smbc_setFunctionRemoveUnusedServer(SMBCCTX *c,
778 smbc_remove_unused_server_fn fn);
779
780/** Get the function for adding a cached server */
781smbc_add_cached_srv_fn smbc_getFunctionAddCachedServer(SMBCCTX *c);
782
783/** Set the function for adding a cached server */
784void smbc_setFunctionAddCachedServer(SMBCCTX *c, smbc_add_cached_srv_fn fn);
785
786/** Get the function for server cache lookup */
787smbc_get_cached_srv_fn smbc_getFunctionGetCachedServer(SMBCCTX *c);
788
789/** Set the function for server cache lookup */
790void smbc_setFunctionGetCachedServer(SMBCCTX *c, smbc_get_cached_srv_fn fn);
791
792/** Get the function for server cache removal */
793smbc_remove_cached_srv_fn smbc_getFunctionRemoveCachedServer(SMBCCTX *c);
794
795/** Set the function for server cache removal */
796void smbc_setFunctionRemoveCachedServer(SMBCCTX *c,
797 smbc_remove_cached_srv_fn fn);
798
799/**
800 * Get the function for server cache purging. This function tries to
801 * remove all cached servers (e.g. on disconnect)
802 */
803smbc_purge_cached_fn smbc_getFunctionPurgeCachedServers(SMBCCTX *c);
804
805/**
806 * Set the function for server cache purging. This function tries to
807 * remove all cached servers (e.g. on disconnect)
808 */
809void smbc_setFunctionPurgeCachedServers(SMBCCTX *c,
810 smbc_purge_cached_fn fn);
811
812/** Get the function to store private data of the server cache */
813struct smbc_server_cache * smbc_getServerCacheData(SMBCCTX *c);
814
815/** Set the function to store private data of the server cache */
816void smbc_setServerCacheData(SMBCCTX *c, struct smbc_server_cache * cache);
817
818
819
820/*****************************************************************
821 * Callable functions for files. *
822 * Each callable has a function signature typedef, a declaration *
823 * for the getter, and a declaration for the setter. *
824 *****************************************************************/
825
826typedef SMBCFILE * (*smbc_open_fn)(SMBCCTX *c,
827 const char *fname,
828 int flags,
829 mode_t mode);
830smbc_open_fn smbc_getFunctionOpen(SMBCCTX *c);
831void smbc_setFunctionOpen(SMBCCTX *c, smbc_open_fn fn);
832
833typedef SMBCFILE * (*smbc_creat_fn)(SMBCCTX *c,
834 const char *path,
835 mode_t mode);
836smbc_creat_fn smbc_getFunctionCreat(SMBCCTX *c);
837void smbc_setFunctionCreat(SMBCCTX *c, smbc_creat_fn);
838
839typedef ssize_t (*smbc_read_fn)(SMBCCTX *c,
840 SMBCFILE *file,
841 void *buf,
842 size_t count);
843smbc_read_fn smbc_getFunctionRead(SMBCCTX *c);
844void smbc_setFunctionRead(SMBCCTX *c, smbc_read_fn fn);
845
846typedef ssize_t (*smbc_write_fn)(SMBCCTX *c,
847 SMBCFILE *file,
848 const void *buf,
849 size_t count);
850smbc_write_fn smbc_getFunctionWrite(SMBCCTX *c);
851void smbc_setFunctionWrite(SMBCCTX *c, smbc_write_fn fn);
852
853typedef int (*smbc_unlink_fn)(SMBCCTX *c,
854 const char *fname);
855smbc_unlink_fn smbc_getFunctionUnlink(SMBCCTX *c);
856void smbc_setFunctionUnlink(SMBCCTX *c, smbc_unlink_fn fn);
857
858typedef int (*smbc_rename_fn)(SMBCCTX *ocontext,
859 const char *oname,
860 SMBCCTX *ncontext,
861 const char *nname);
862smbc_rename_fn smbc_getFunctionRename(SMBCCTX *c);
863void smbc_setFunctionRename(SMBCCTX *c, smbc_rename_fn fn);
864
865typedef off_t (*smbc_lseek_fn)(SMBCCTX *c,
866 SMBCFILE * file,
867 off_t offset,
868 int whence);
869smbc_lseek_fn smbc_getFunctionLseek(SMBCCTX *c);
870void smbc_setFunctionLseek(SMBCCTX *c, smbc_lseek_fn fn);
871
872typedef int (*smbc_stat_fn)(SMBCCTX *c,
873 const char *fname,
874 struct stat *st);
875smbc_stat_fn smbc_getFunctionStat(SMBCCTX *c);
876void smbc_setFunctionStat(SMBCCTX *c, smbc_stat_fn fn);
877
878typedef int (*smbc_fstat_fn)(SMBCCTX *c,
879 SMBCFILE *file,
880 struct stat *st);
881smbc_fstat_fn smbc_getFunctionFstat(SMBCCTX *c);
882void smbc_setFunctionFstat(SMBCCTX *c, smbc_fstat_fn fn);
883
884typedef int (*smbc_statvfs_fn)(SMBCCTX *c,
885 char *path,
886 struct statvfs *st);
887smbc_statvfs_fn smbc_getFunctionStatVFS(SMBCCTX *c);
888void smbc_setFunctionStatVFS(SMBCCTX *c, smbc_statvfs_fn fn);
889
890typedef int (*smbc_fstatvfs_fn)(SMBCCTX *c,
891 SMBCFILE *file,
892 struct statvfs *st);
893smbc_fstatvfs_fn smbc_getFunctionFstatVFS(SMBCCTX *c);
894void smbc_setFunctionFstatVFS(SMBCCTX *c, smbc_fstatvfs_fn fn);
895
896typedef int (*smbc_ftruncate_fn)(SMBCCTX *c,
897 SMBCFILE *f,
898 off_t size);
899smbc_ftruncate_fn smbc_getFunctionFtruncate(SMBCCTX *c);
900void smbc_setFunctionFtruncate(SMBCCTX *c, smbc_ftruncate_fn fn);
901
902typedef int (*smbc_close_fn)(SMBCCTX *c,
903 SMBCFILE *file);
904smbc_close_fn smbc_getFunctionClose(SMBCCTX *c);
905void smbc_setFunctionClose(SMBCCTX *c, smbc_close_fn fn);
906
907
908
909/*****************************************************************
910 * Callable functions for directories. *
911 * Each callable has a function signature typedef, a declaration *
912 * for the getter, and a declaration for the setter. *
913 *****************************************************************/
914
915typedef SMBCFILE * (*smbc_opendir_fn)(SMBCCTX *c,
916 const char *fname);
917smbc_opendir_fn smbc_getFunctionOpendir(SMBCCTX *c);
918void smbc_setFunctionOpendir(SMBCCTX *c, smbc_opendir_fn fn);
919
920typedef int (*smbc_closedir_fn)(SMBCCTX *c,
921 SMBCFILE *dir);
922smbc_closedir_fn smbc_getFunctionClosedir(SMBCCTX *c);
923void smbc_setFunctionClosedir(SMBCCTX *c, smbc_closedir_fn fn);
924
925typedef struct smbc_dirent * (*smbc_readdir_fn)(SMBCCTX *c,
926 SMBCFILE *dir);
927smbc_readdir_fn smbc_getFunctionReaddir(SMBCCTX *c);
928void smbc_setFunctionReaddir(SMBCCTX *c, smbc_readdir_fn fn);
929
930typedef int (*smbc_getdents_fn)(SMBCCTX *c,
931 SMBCFILE *dir,
932 struct smbc_dirent *dirp,
933 int count);
934smbc_getdents_fn smbc_getFunctionGetdents(SMBCCTX *c);
935void smbc_setFunctionGetdents(SMBCCTX *c, smbc_getdents_fn fn);
936
937typedef int (*smbc_mkdir_fn)(SMBCCTX *c,
938 const char *fname,
939 mode_t mode);
940smbc_mkdir_fn smbc_getFunctionMkdir(SMBCCTX *c);
941void smbc_setFunctionMkdir(SMBCCTX *c, smbc_mkdir_fn fn);
942
943typedef int (*smbc_rmdir_fn)(SMBCCTX *c,
944 const char *fname);
945smbc_rmdir_fn smbc_getFunctionRmdir(SMBCCTX *c);
946void smbc_setFunctionRmdir(SMBCCTX *c, smbc_rmdir_fn fn);
947
948typedef off_t (*smbc_telldir_fn)(SMBCCTX *c,
949 SMBCFILE *dir);
950smbc_telldir_fn smbc_getFunctionTelldir(SMBCCTX *c);
951void smbc_setFunctionTelldir(SMBCCTX *c, smbc_telldir_fn fn);
952
953typedef int (*smbc_lseekdir_fn)(SMBCCTX *c,
954 SMBCFILE *dir,
955 off_t offset);
956smbc_lseekdir_fn smbc_getFunctionLseekdir(SMBCCTX *c);
957void smbc_setFunctionLseekdir(SMBCCTX *c, smbc_lseekdir_fn fn);
958
959typedef int (*smbc_fstatdir_fn)(SMBCCTX *c,
960 SMBCFILE *dir,
961 struct stat *st);
962smbc_fstatdir_fn smbc_getFunctionFstatdir(SMBCCTX *c);
963void smbc_setFunctionFstatdir(SMBCCTX *c, smbc_fstatdir_fn fn);
964
965
966
967/*****************************************************************
968 * Callable functions applicable to both files and directories. *
969 * Each callable has a function signature typedef, a declaration *
970 * for the getter, and a declaration for the setter. *
971 *****************************************************************/
972
973typedef int (*smbc_chmod_fn)(SMBCCTX *c,
974 const char *fname,
975 mode_t mode);
976smbc_chmod_fn smbc_getFunctionChmod(SMBCCTX *c);
977void smbc_setFunctionChmod(SMBCCTX *c, smbc_chmod_fn fn);
978
979typedef int (*smbc_utimes_fn)(SMBCCTX *c,
980 const char *fname,
981 struct timeval *tbuf);
982smbc_utimes_fn smbc_getFunctionUtimes(SMBCCTX *c);
983void smbc_setFunctionUtimes(SMBCCTX *c, smbc_utimes_fn fn);
984
985typedef int (*smbc_setxattr_fn)(SMBCCTX *context,
986 const char *fname,
987 const char *name,
988 const void *value,
989 size_t size,
990 int flags);
991smbc_setxattr_fn smbc_getFunctionSetxattr(SMBCCTX *c);
992void smbc_setFunctionSetxattr(SMBCCTX *c, smbc_setxattr_fn fn);
993
994typedef int (*smbc_getxattr_fn)(SMBCCTX *context,
995 const char *fname,
996 const char *name,
997 const void *value,
998 size_t size);
999smbc_getxattr_fn smbc_getFunctionGetxattr(SMBCCTX *c);
1000void smbc_setFunctionGetxattr(SMBCCTX *c, smbc_getxattr_fn fn);
1001
1002typedef int (*smbc_removexattr_fn)(SMBCCTX *context,
1003 const char *fname,
1004 const char *name);
1005smbc_removexattr_fn smbc_getFunctionRemovexattr(SMBCCTX *c);
1006void smbc_setFunctionRemovexattr(SMBCCTX *c, smbc_removexattr_fn fn);
1007
1008typedef int (*smbc_listxattr_fn)(SMBCCTX *context,
1009 const char *fname,
1010 char *list,
1011 size_t size);
1012smbc_listxattr_fn smbc_getFunctionListxattr(SMBCCTX *c);
1013void smbc_setFunctionListxattr(SMBCCTX *c, smbc_listxattr_fn fn);
1014
1015
1016
1017/*****************************************************************
1018 * Callable functions for printing. *
1019 * Each callable has a function signature typedef, a declaration *
1020 * for the getter, and a declaration for the setter. *
1021 *****************************************************************/
1022
1023typedef int (*smbc_print_file_fn)(SMBCCTX *c_file,
1024 const char *fname,
1025 SMBCCTX *c_print,
1026 const char *printq);
1027smbc_print_file_fn smbc_getFunctionPrintFile(SMBCCTX *c);
1028void smbc_setFunctionPrintFile(SMBCCTX *c, smbc_print_file_fn fn);
1029
1030typedef SMBCFILE * (*smbc_open_print_job_fn)(SMBCCTX *c,
1031 const char *fname);
1032smbc_open_print_job_fn smbc_getFunctionOpenPrintJob(SMBCCTX *c);
1033void smbc_setFunctionOpenPrintJob(SMBCCTX *c,
1034 smbc_open_print_job_fn fn);
1035
1036typedef int (*smbc_list_print_jobs_fn)(SMBCCTX *c,
1037 const char *fname,
1038 smbc_list_print_job_fn fn);
1039smbc_list_print_jobs_fn smbc_getFunctionListPrintJobs(SMBCCTX *c);
1040void smbc_setFunctionListPrintJobs(SMBCCTX *c,
1041 smbc_list_print_jobs_fn fn);
1042
1043typedef int (*smbc_unlink_print_job_fn)(SMBCCTX *c,
1044 const char *fname,
1045 int id);
1046smbc_unlink_print_job_fn smbc_getFunctionUnlinkPrintJob(SMBCCTX *c);
1047void smbc_setFunctionUnlinkPrintJob(SMBCCTX *c,
1048 smbc_unlink_print_job_fn fn);
1049
1050
1051/**@ingroup misc
1052 * Create a new SBMCCTX (a context).
1053 *
1054 * Must be called before the context is passed to smbc_context_init()
1055 *
1056 * @return The given SMBCCTX pointer on success, NULL on error with errno set:
1057 * - ENOMEM Out of memory
1058 *
1059 * @see smbc_free_context(), smbc_init_context()
1060 *
1061 * @note Do not forget to smbc_init_context() the returned SMBCCTX pointer !
1062 */
1063SMBCCTX * smbc_new_context(void);
1064
1065/**@ingroup misc
1066 * Delete a SBMCCTX (a context) acquired from smbc_new_context().
1067 *
1068 * The context will be deleted if possible.
1069 *
1070 * @param context A pointer to a SMBCCTX obtained from smbc_new_context()
1071 *
1072 * @param shutdown_ctx If 1, all connections and files will be closed even if they are busy.
1073 *
1074 *
1075 * @return Returns 0 on succes. Returns 1 on failure with errno set:
1076 * - EBUSY Server connections are still used, Files are open or cache
1077 * could not be purged
1078 * - EBADF context == NULL
1079 *
1080 * @see smbc_new_context()
1081 *
1082 * @note It is advised to clean up all the contexts with shutdown_ctx set to 1
1083 * just before exit()'ing. When shutdown_ctx is 0, this function can be
1084 * use in periodical cleanup functions for example.
1085 */
1086int smbc_free_context(SMBCCTX * context, int shutdown_ctx);
1087
1088
1089/**@ingroup misc
1090 *
1091 * @deprecated. Use smbc_setOption*() functions instead.
1092 */
1093void
1094smbc_option_set(SMBCCTX *context,
1095 char *option_name,
1096 ... /* option_value */);
1097
1098/*
1099 * @deprecated. Use smbc_getOption*() functions instead.
1100 */
1101void *
1102smbc_option_get(SMBCCTX *context,
1103 char *option_name);
1104
1105/**@ingroup misc
1106 * Initialize a SBMCCTX (a context).
1107 *
1108 * Must be called before using any SMBCCTX API function
1109 *
1110 * @param context A pointer to a SMBCCTX obtained from smbc_new_context()
1111 *
1112 * @return A pointer to the given SMBCCTX on success,
1113 * NULL on error with errno set:
1114 * - EBADF NULL context given
1115 * - ENOMEM Out of memory
1116 * - ENOENT The smb.conf file would not load
1117 *
1118 * @see smbc_new_context()
1119 *
1120 * @note my_context = smbc_init_context(smbc_new_context())
1121 * is perfectly safe, but it might leak memory on
1122 * smbc_context_init() failure. Avoid this.
1123 * You'll have to call smbc_free_context() yourself
1124 * on failure.
1125 */
1126
1127SMBCCTX * smbc_init_context(SMBCCTX * context);
1128
1129/**@ingroup misc
1130 * Initialize the samba client library.
1131 *
1132 * Must be called before using any of the smbclient API function
1133 *
1134 * @param fn The function that will be called to obtaion
1135 * authentication credentials.
1136 *
1137 * @param debug Allows caller to set the debug level. Can be
1138 * changed in smb.conf file. Allows caller to set
1139 * debugging if no smb.conf.
1140 *
1141 * @return 0 on success, < 0 on error with errno set:
1142 * - ENOMEM Out of memory
1143 * - ENOENT The smb.conf file would not load
1144 *
1145 */
1146
1147int smbc_init(smbc_get_auth_data_fn fn, int debug);
1148
1149/**@ingroup misc
1150 * Set or retrieve the compatibility library's context pointer
1151 *
1152 * @param context New context to use, or NULL. If a new context is provided,
1153 * it must have allocated with smbc_new_context() and
1154 * initialized with smbc_init_context(), followed, optionally,
1155 * by some manual changes to some of the non-internal fields.
1156 *
1157 * @return The old context.
1158 *
1159 * @see smbc_new_context(), smbc_init_context(), smbc_init()
1160 *
1161 * @note This function may be called prior to smbc_init() to force
1162 * use of the next context without any internal calls to
1163 * smbc_new_context() or smbc_init_context(). It may also
1164 * be called after smbc_init() has already called those two
1165 * functions, to replace the existing context with a new one.
1166 * Care should be taken, in this latter case, to ensure that
1167 * the server cache and any data allocated by the
1168 * authentication functions have been freed, if necessary.
1169 */
1170
1171SMBCCTX * smbc_set_context(SMBCCTX * new_context);
1172
1173/**@ingroup file
1174 * Open a file on an SMB server.
1175 *
1176 * @param furl The smb url of the file to be opened.
1177 *
1178 * @param flags Is one of O_RDONLY, O_WRONLY or O_RDWR which
1179 * request opening the file read-only,write-only
1180 * or read/write. flags may also be bitwise-or'd with
1181 * one or more of the following:
1182 * O_CREAT - If the file does not exist it will be
1183 * created.
1184 * O_EXCL - When used with O_CREAT, if the file
1185 * already exists it is an error and the open will
1186 * fail.
1187 * O_TRUNC - If the file already exists it will be
1188 * truncated.
1189 * O_APPEND The file is opened in append mode
1190 *
1191 * @param mode mode specifies the permissions to use if a new
1192 * file is created. It is modified by the
1193 * process's umask in the usual way: the permissions
1194 * of the created file are (mode & ~umask)
1195 *
1196 * Not currently use, but there for future use.
1197 * We will map this to SYSTEM, HIDDEN, etc bits
1198 * that reverses the mapping that smbc_fstat does.
1199 *
1200 * @return Valid file handle, < 0 on error with errno set:
1201 * - ENOMEM Out of memory
1202 * - EINVAL if an invalid parameter passed, like no
1203 * file, or smbc_init not called.
1204 * - EEXIST pathname already exists and O_CREAT and
1205 * O_EXCL were used.
1206 * - EISDIR pathname refers to a directory and
1207 * the access requested involved writing.
1208 * - EACCES The requested access to the file is not
1209 * allowed
1210 * - ENODEV The requested share does not exist
1211 * - ENOTDIR A file on the path is not a directory
1212 * - ENOENT A directory component in pathname does
1213 * not exist.
1214 *
1215 * @see smbc_creat()
1216 *
1217 * @note This call uses an underlying routine that may create
1218 * a new connection to the server specified in the URL.
1219 * If the credentials supplied in the URL, or via the
1220 * auth_fn in the smbc_init call, fail, this call will
1221 * try again with an empty username and password. This
1222 * often gets mapped to the guest account on some machines.
1223 */
1224
1225int smbc_open(const char *furl, int flags, mode_t mode);
1226
1227/**@ingroup file
1228 * Create a file on an SMB server.
1229 *
1230 * Same as calling smbc_open() with flags = O_CREAT|O_WRONLY|O_TRUNC
1231 *
1232 * @param furl The smb url of the file to be created
1233 *
1234 * @param mode mode specifies the permissions to use if a new
1235 * file is created. It is modified by the
1236 * process's umask in the usual way: the permissions
1237 * of the created file are (mode & ~umask)
1238 *
1239 * NOTE, the above is not true. We are dealing with
1240 * an SMB server, which has no concept of a umask!
1241 *
1242 * @return Valid file handle, < 0 on error with errno set:
1243 * - ENOMEM Out of memory
1244 * - EINVAL if an invalid parameter passed, like no
1245 * file, or smbc_init not called.
1246 * - EEXIST pathname already exists and O_CREAT and
1247 * O_EXCL were used.
1248 * - EISDIR pathname refers to a directory and
1249 * the access requested involved writing.
1250 * - EACCES The requested access to the file is not
1251 * allowed
1252 * - ENOENT A directory component in pathname does
1253 * not exist.
1254 * - ENODEV The requested share does not exist.
1255 * @see smbc_open()
1256 *
1257 */
1258
1259int smbc_creat(const char *furl, mode_t mode);
1260
1261/**@ingroup file
1262 * Read from a file using an opened file handle.
1263 *
1264 * @param fd Open file handle from smbc_open() or smbc_creat()
1265 *
1266 * @param buf Pointer to buffer to recieve read data
1267 *
1268 * @param bufsize Size of buf in bytes
1269 *
1270 * @return Number of bytes read, < 0 on error with errno set:
1271 * - EISDIR fd refers to a directory
1272 * - EBADF fd is not a valid file descriptor or
1273 * is not open for reading.
1274 * - EINVAL fd is attached to an object which is
1275 * unsuitable for reading, or no buffer passed or
1276 * smbc_init not called.
1277 *
1278 * @see smbc_open(), smbc_write()
1279 *
1280 */
1281ssize_t smbc_read(int fd, void *buf, size_t bufsize);
1282
1283
1284/**@ingroup file
1285 * Write to a file using an opened file handle.
1286 *
1287 * @param fd Open file handle from smbc_open() or smbc_creat()
1288 *
1289 * @param buf Pointer to buffer to recieve read data
1290 *
1291 * @param bufsize Size of buf in bytes
1292 *
1293 * @return Number of bytes written, < 0 on error with errno set:
1294 * - EISDIR fd refers to a directory.
1295 * - EBADF fd is not a valid file descriptor or
1296 * is not open for reading.
1297 * - EINVAL fd is attached to an object which is
1298 * unsuitable for reading, or no buffer passed or
1299 * smbc_init not called.
1300 *
1301 * @see smbc_open(), smbc_read()
1302 *
1303 */
1304ssize_t smbc_write(int fd, const void *buf, size_t bufsize);
1305
1306
1307/**@ingroup file
1308 * Seek to a specific location in a file.
1309 *
1310 * @param fd Open file handle from smbc_open() or smbc_creat()
1311 *
1312 * @param offset Offset in bytes from whence
1313 *
1314 * @param whence A location in the file:
1315 * - SEEK_SET The offset is set to offset bytes from
1316 * the beginning of the file
1317 * - SEEK_CUR The offset is set to current location
1318 * plus offset bytes.
1319 * - SEEK_END The offset is set to the size of the
1320 * file plus offset bytes.
1321 *
1322 * @return Upon successful completion, lseek returns the
1323 * resulting offset location as measured in bytes
1324 * from the beginning of the file. Otherwise, a value
1325 * of (off_t)-1 is returned and errno is set to
1326 * indicate the error:
1327 * - EBADF Fildes is not an open file descriptor.
1328 * - EINVAL Whence is not a proper value or smbc_init
1329 * not called.
1330 *
1331 * @todo Are all the whence values really supported?
1332 *
1333 * @todo Are errno values complete and correct?
1334 */
1335off_t smbc_lseek(int fd, off_t offset, int whence);
1336
1337
1338/**@ingroup file
1339 * Close an open file handle.
1340 *
1341 * @param fd The file handle to close
1342 *
1343 * @return 0 on success, < 0 on error with errno set:
1344 * - EBADF fd isn't a valid open file descriptor
1345 * - EINVAL smbc_init() failed or has not been called
1346 *
1347 * @see smbc_open(), smbc_creat()
1348 */
1349int smbc_close(int fd);
1350
1351
1352/**@ingroup directory
1353 * Unlink (delete) a file or directory.
1354 *
1355 * @param furl The smb url of the file to delete
1356 *
1357 * @return 0 on success, < 0 on error with errno set:
1358 * - EACCES or EPERM Write access to the directory
1359 * containing pathname is not allowed or one
1360 * of the directories in pathname did not allow
1361 * search (execute) permission
1362 * - ENOENT A directory component in pathname does
1363 * not exist
1364 * - EINVAL NULL was passed in the file param or
1365 * smbc_init not called.
1366 * - EACCES You do not have access to the file
1367 * - ENOMEM Insufficient kernel memory was available
1368 *
1369 * @see smbc_rmdir()s
1370 *
1371 * @todo Are errno values complete and correct?
1372 */
1373int smbc_unlink(const char *furl);
1374
1375
1376/**@ingroup directory
1377 * Rename or move a file or directory.
1378 *
1379 * @param ourl The original smb url (source url) of file or
1380 * directory to be moved
1381 *
1382 * @param nurl The new smb url (destination url) of the file
1383 * or directory after the move. Currently nurl must
1384 * be on the same share as ourl.
1385 *
1386 * @return 0 on success, < 0 on error with errno set:
1387 * - EISDIR nurl is an existing directory, but ourl is
1388 * not a directory.
1389 * - EEXIST nurl is a non-empty directory,
1390 * i.e., contains entries other than "." and ".."
1391 * - EINVAL The new url contained a path prefix
1392 * of the old, or, more generally, an attempt was
1393 * made to make a directory a subdirectory of itself
1394 * or smbc_init not called.
1395 * - ENOTDIR A component used as a directory in ourl
1396 * or nurl path is not, in fact, a directory. Or,
1397 * ourl is a directory, and newpath exists but is not
1398 * a directory.
1399 * - EACCES or EPERM Write access to the directory
1400 * containing ourl or nurl is not allowed for the
1401 * process's effective uid, or one of the
1402 * directories in ourl or nurl did not allow search
1403 * (execute) permission, or ourl was a directory
1404 * and did not allow write permission.
1405 * - ENOENT A directory component in ourl or nurl
1406 * does not exist.
1407 * - EXDEV Rename across shares not supported.
1408 * - ENOMEM Insufficient kernel memory was available.
1409 * - EEXIST The target file, nurl, already exists.
1410 *
1411 *
1412 * @todo Are we going to support copying when urls are not on the same
1413 * share? I say no... NOTE. I agree for the moment.
1414 *
1415 */
1416int smbc_rename(const char *ourl, const char *nurl);
1417
1418
1419/**@ingroup directory
1420 * Open a directory used to obtain directory entries.
1421 *
1422 * @param durl The smb url of the directory to open
1423 *
1424 * @return Valid directory handle. < 0 on error with errno set:
1425 * - EACCES Permission denied.
1426 * - EINVAL A NULL file/URL was passed, or the URL would
1427 * not parse, or was of incorrect form or smbc_init not
1428 * called.
1429 * - ENOENT durl does not exist, or name is an
1430 * - ENOMEM Insufficient memory to complete the
1431 * operation.
1432 * - ENOTDIR name is not a directory.
1433 * - EPERM the workgroup could not be found.
1434 * - ENODEV the workgroup or server could not be found.
1435 *
1436 * @see smbc_getdents(), smbc_readdir(), smbc_closedir()
1437 *
1438 */
1439int smbc_opendir(const char *durl);
1440
1441
1442/**@ingroup directory
1443 * Close a directory handle opened by smbc_opendir().
1444 *
1445 * @param dh Directory handle to close
1446 *
1447 * @return 0 on success, < 0 on error with errno set:
1448 * - EBADF dh is an invalid directory handle
1449 *
1450 * @see smbc_opendir()
1451 */
1452int smbc_closedir(int dh);
1453
1454
1455/**@ingroup directory
1456 * Get multiple directory entries.
1457 *
1458 * smbc_getdents() reads as many dirent structures from the an open
1459 * directory handle into a specified memory area as will fit.
1460 *
1461 * @param dh Valid directory as returned by smbc_opendir()
1462 *
1463 * @param dirp pointer to buffer that will receive the directory
1464 * entries.
1465 *
1466 * @param count The size of the dirp buffer in bytes
1467 *
1468 * @returns If any dirents returned, return will indicate the
1469 * total size. If there were no more dirents available,
1470 * 0 is returned. < 0 indicates an error.
1471 * - EBADF Invalid directory handle
1472 * - EINVAL Result buffer is too small or smbc_init
1473 * not called.
1474 * - ENOENT No such directory.
1475 * @see , smbc_dirent, smbc_readdir(), smbc_open()
1476 *
1477 * @todo Are errno values complete and correct?
1478 *
1479 * @todo Add example code so people know how to parse buffers.
1480 */
1481int smbc_getdents(unsigned int dh, struct smbc_dirent *dirp, int count);
1482
1483
1484/**@ingroup directory
1485 * Get a single directory entry.
1486 *
1487 * @param dh Valid directory as returned by smbc_opendir()
1488 *
1489 * @return A pointer to a smbc_dirent structure, or NULL if an
1490 * error occurs or end-of-directory is reached:
1491 * - EBADF Invalid directory handle
1492 * - EINVAL smbc_init() failed or has not been called
1493 *
1494 * @see smbc_dirent, smbc_getdents(), smbc_open()
1495 */
1496struct smbc_dirent* smbc_readdir(unsigned int dh);
1497
1498
1499/**@ingroup directory
1500 * Get the current directory offset.
1501 *
1502 * smbc_telldir() may be used in conjunction with smbc_readdir() and
1503 * smbc_lseekdir().
1504 *
1505 * @param dh Valid directory as returned by smbc_opendir()
1506 *
1507 * @return The current location in the directory stream or -1
1508 * if an error occur. The current location is not
1509 * an offset. Becuase of the implementation, it is a
1510 * handle that allows the library to find the entry
1511 * later.
1512 * - EBADF dh is not a valid directory handle
1513 * - EINVAL smbc_init() failed or has not been called
1514 * - ENOTDIR if dh is not a directory
1515 *
1516 * @see smbc_readdir()
1517 *
1518 */
1519off_t smbc_telldir(int dh);
1520
1521
1522/**@ingroup directory
1523 * lseek on directories.
1524 *
1525 * smbc_lseekdir() may be used in conjunction with smbc_readdir() and
1526 * smbc_telldir(). (rewind by smbc_lseekdir(fd, NULL))
1527 *
1528 * @param fd Valid directory as returned by smbc_opendir()
1529 *
1530 * @param offset The offset (as returned by smbc_telldir). Can be
1531 * NULL, in which case we will rewind
1532 *
1533 * @return 0 on success, -1 on failure
1534 * - EBADF dh is not a valid directory handle
1535 * - ENOTDIR if dh is not a directory
1536 * - EINVAL offset did not refer to a valid dirent or
1537 * smbc_init not called.
1538 *
1539 * @see smbc_telldir()
1540 *
1541 *
1542 * @todo In what does the reture and errno values mean?
1543 */
1544int smbc_lseekdir(int fd, off_t offset);
1545
1546/**@ingroup directory
1547 * Create a directory.
1548 *
1549 * @param durl The url of the directory to create
1550 *
1551 * @param mode Specifies the permissions to use. It is modified
1552 * by the process's umask in the usual way: the
1553 * permissions of the created file are (mode & ~umask).
1554 *
1555 * @return 0 on success, < 0 on error with errno set:
1556 * - EEXIST directory url already exists
1557 * - EACCES The parent directory does not allow write
1558 * permission to the process, or one of the directories
1559 * - ENOENT A directory component in pathname does not
1560 * exist.
1561 * - EINVAL NULL durl passed or smbc_init not called.
1562 * - ENOMEM Insufficient memory was available.
1563 *
1564 * @see smbc_rmdir()
1565 *
1566 */
1567int smbc_mkdir(const char *durl, mode_t mode);
1568
1569
1570/**@ingroup directory
1571 * Remove a directory.
1572 *
1573 * @param durl The smb url of the directory to remove
1574 *
1575 * @return 0 on success, < 0 on error with errno set:
1576 * - EACCES or EPERM Write access to the directory
1577 * containing pathname was not allowed.
1578 * - EINVAL durl is NULL or smbc_init not called.
1579 * - ENOENT A directory component in pathname does not
1580 * exist.
1581 * - ENOTEMPTY directory contains entries.
1582 * - ENOMEM Insufficient kernel memory was available.
1583 *
1584 * @see smbc_mkdir(), smbc_unlink()
1585 *
1586 * @todo Are errno values complete and correct?
1587 */
1588int smbc_rmdir(const char *durl);
1589
1590
1591/**@ingroup attribute
1592 * Get information about a file or directory.
1593 *
1594 * @param url The smb url to get information for
1595 *
1596 * @param st pointer to a buffer that will be filled with
1597 * standard Unix struct stat information.
1598 *
1599 * @return 0 on success, < 0 on error with errno set:
1600 * - ENOENT A component of the path file_name does not
1601 * exist.
1602 * - EINVAL a NULL url was passed or smbc_init not called.
1603 * - EACCES Permission denied.
1604 * - ENOMEM Out of memory
1605 * - ENOTDIR The target dir, url, is not a directory.
1606 *
1607 * @see Unix stat()
1608 *
1609 */
1610int smbc_stat(const char *url, struct stat *st);
1611
1612
1613/**@ingroup attribute
1614 * Get file information via an file descriptor.
1615 *
1616 * @param fd Open file handle from smbc_open() or smbc_creat()
1617 *
1618 * @param st pointer to a buffer that will be filled with
1619 * standard Unix struct stat information.
1620 *
1621 * @return EBADF filedes is bad.
1622 * - EACCES Permission denied.
1623 * - EBADF fd is not a valid file descriptor
1624 * - EINVAL Problems occurred in the underlying routines
1625 * or smbc_init not called.
1626 * - ENOMEM Out of memory
1627 *
1628 * @see smbc_stat(), Unix stat()
1629 *
1630 */
1631int smbc_fstat(int fd, struct stat *st);
1632
1633
1634/**@ingroup attribute
1635 * Get file system information for a specified path.
1636 *
1637 * @param url The smb url to get information for
1638 *
1639 * @param st pointer to a buffer that will be filled with
1640 * standard Unix struct statvfs information.
1641 *
1642 * @return EBADF filedes is bad.
1643 * - EACCES Permission denied.
1644 * - EBADF fd is not a valid file descriptor
1645 * - EINVAL Problems occurred in the underlying routines
1646 * or smbc_init not called.
1647 * - ENOMEM Out of memory
1648 *
1649 * @see Unix fstatvfs()
1650 *
1651 */
1652int
1653smbc_statvfs(char *url,
1654 struct statvfs *st);
1655
1656/**@ingroup attribute
1657 * Get file system information via an file descriptor.
1658 *
1659 * @param fd Open file handle from smbc_open(), smbc_creat(),
1660 * or smbc_opendir()
1661 *
1662 * @param st pointer to a buffer that will be filled with
1663 * standard Unix struct statvfs information.
1664 *
1665 * @return EBADF filedes is bad.
1666 * - EACCES Permission denied.
1667 * - EBADF fd is not a valid file descriptor
1668 * - EINVAL Problems occurred in the underlying routines
1669 * or smbc_init not called.
1670 * - ENOMEM Out of memory
1671 *
1672 * @see Unix fstatvfs()
1673 *
1674 */
1675int
1676smbc_fstatvfs(int fd,
1677 struct statvfs *st);
1678
1679
1680/**@ingroup attribute
1681 * Truncate a file given a file descriptor
1682 *
1683 * @param fd Open file handle from smbc_open() or smbc_creat()
1684 *
1685 * @param size size to truncate the file to
1686 *
1687 * @return EBADF filedes is bad.
1688 * - EACCES Permission denied.
1689 * - EBADF fd is not a valid file descriptor
1690 * - EINVAL Problems occurred in the underlying routines
1691 * or smbc_init not called.
1692 * - ENOMEM Out of memory
1693 *
1694 * @see , Unix ftruncate()
1695 *
1696 */
1697int smbc_ftruncate(int fd, off_t size);
1698
1699
1700/**@ingroup attribute
1701 * Change the permissions of a file.
1702 *
1703 * @param url The smb url of the file or directory to change
1704 * permissions of
1705 *
1706 * @param mode The permissions to set:
1707 * - Put good explaination of permissions here!
1708 *
1709 * @return 0 on success, < 0 on error with errno set:
1710 * - EPERM The effective UID does not match the owner
1711 * of the file, and is not zero
1712 * - ENOENT The file does not exist.
1713 * - ENOMEM Insufficient was available.
1714 * - ENOENT file or directory does not exist
1715 *
1716 * @todo Actually implement this fuction?
1717 *
1718 * @todo Are errno values complete and correct?
1719 */
1720int smbc_chmod(const char *url, mode_t mode);
1721
1722/**
1723 * @ingroup attribute
1724 * Change the last modification time on a file
1725 *
1726 * @param url The smb url of the file or directory to change
1727 * the modification time of
1728 *
1729 * @param tbuf An array of two timeval structures which contains,
1730 * respectively, the desired access and modification times.
1731 * NOTE: Only the tv_sec field off each timeval structure is
1732 * used. The tv_usec (microseconds) portion is ignored.
1733 *
1734 * @return 0 on success, < 0 on error with errno set:
1735 * - EINVAL The client library is not properly initialized
1736 * - EPERM Permission was denied.
1737 *
1738 */
1739int smbc_utimes(const char *url, struct timeval *tbuf);
1740
1741#ifdef HAVE_UTIME_H
1742/**
1743 * @ingroup attribute
1744 * Change the last modification time on a file
1745 *
1746 * @param url The smb url of the file or directory to change
1747 * the modification time of
1748 *
1749 * @param utbuf A pointer to a utimebuf structure which contains the
1750 * desired access and modification times.
1751 *
1752 * @return 0 on success, < 0 on error with errno set:
1753 * - EINVAL The client library is not properly initialized
1754 * - ENOMEM No memory was available for internal needs
1755 * - EPERM Permission was denied.
1756 *
1757 */
1758int smbc_utime(const char *fname, struct utimbuf *utbuf);
1759#endif
1760
1761/**@ingroup attribute
1762 * Set extended attributes for a file. This is used for modifying a file's
1763 * security descriptor (i.e. owner, group, and access control list)
1764 *
1765 * @param url The smb url of the file or directory to set extended
1766 * attributes for.
1767 *
1768 * @param name The name of an attribute to be changed. Names are of
1769 * one of the following forms:
1770 *
1771 * system.nt_sec_desc.<attribute name>
1772 * system.nt_sec_desc.*
1773 * system.nt_sec_desc.*+
1774 *
1775 * where <attribute name> is one of:
1776 *
1777 * revision
1778 * owner
1779 * owner+
1780 * group
1781 * group+
1782 * acl:<name or sid>
1783 * acl+:<name or sid>
1784 *
1785 * In the forms "system.nt_sec_desc.*" and
1786 * "system.nt_sec_desc.*+", the asterisk and plus signs are
1787 * literal, i.e. the string is provided exactly as shown, and
1788 * the value parameter should contain a complete security
1789 * descriptor with name:value pairs separated by tabs,
1790 * commas, or newlines (not spaces!).
1791 *
1792 * The plus sign ('+') indicates that SIDs should be mapped
1793 * to names. Without the plus sign, SIDs are not mapped;
1794 * rather they are simply converted to a string format.
1795 *
1796 * @param value The value to be assigned to the specified attribute name.
1797 * This buffer should contain only the attribute value if the
1798 * name was of the "system.nt_sec_desc.<attribute_name>"
1799 * form. If the name was of the "system.nt_sec_desc.*" form
1800 * then a complete security descriptor, with name:value pairs
1801 * separated by tabs, commas, or newlines (not spaces!),
1802 * should be provided in this value buffer. A complete
1803 * security descriptor will contain one or more entries
1804 * selected from the following:
1805 *
1806 * REVISION:<revision number>
1807 * OWNER:<sid or name>
1808 * GROUP:<sid or name>
1809 * ACL:<sid or name>:<type>/<flags>/<mask>
1810 *
1811 * The revision of the ACL specifies the internal Windows NT
1812 * ACL revision for the security descriptor. If not specified
1813 * it defaults to 1. Using values other than 1 may cause
1814 * strange behaviour.
1815 *
1816 * The owner and group specify the owner and group sids for
1817 * the object. If the attribute name (either '*+' with a
1818 * complete security descriptor, or individual 'owner+' or
1819 * 'group+' attribute names) ended with a plus sign, the
1820 * specified name is resolved to a SID value, using the
1821 * server on which the file or directory resides. Otherwise,
1822 * the value should be provided in SID-printable format as
1823 * S-1-x-y-z, and is used directly. The <sid or name>
1824 * associated with the ACL: attribute should be provided
1825 * similarly.
1826 *
1827 * @param size The number of the bytes of data in the value buffer
1828 *
1829 * @param flags A bit-wise OR of zero or more of the following:
1830 * SMBC_XATTR_FLAG_CREATE -
1831 * fail if the named attribute already exists
1832 * SMBC_XATTR_FLAG_REPLACE -
1833 * fail if the attribute does not already exist
1834 *
1835 * If neither flag is specified, the specified attributes
1836 * will be added or replace existing attributes of the same
1837 * name, as necessary.
1838 *
1839 * @return 0 on success, < 0 on error with errno set:
1840 * - EINVAL The client library is not properly initialized
1841 * or one of the parameters is not of a correct
1842 * form
1843 * - ENOMEM No memory was available for internal needs
1844 * - EEXIST If the attribute already exists and the flag
1845 * SMBC_XATTR_FLAG_CREAT was specified
1846 * - ENOATTR If the attribute does not exist and the flag
1847 * SMBC_XATTR_FLAG_REPLACE was specified
1848 * - EPERM Permission was denied.
1849 * - ENOTSUP The referenced file system does not support
1850 * extended attributes
1851 *
1852 * @note Attribute names are compared in a case-insensitive
1853 * fashion. All of the following are equivalent, although
1854 * the all-lower-case name is the preferred format:
1855 * system.nt_sec_desc.owner
1856 * SYSTEM.NT_SEC_DESC.OWNER
1857 * sYsTeM.nt_sEc_desc.owNER
1858 *
1859 */
1860int smbc_setxattr(const char *url,
1861 const char *name,
1862 const void *value,
1863 size_t size,
1864 int flags);
1865
1866
1867/**@ingroup attribute
1868 * Set extended attributes for a file. This is used for modifying a file's
1869 * security descriptor (i.e. owner, group, and access control list). The
1870 * POSIX function which this maps to would act on a symbolic link rather than
1871 * acting on what the symbolic link points to, but with no symbolic links in
1872 * SMB file systems, this function is functionally identical to
1873 * smbc_setxattr().
1874 *
1875 * @param url The smb url of the file or directory to set extended
1876 * attributes for.
1877 *
1878 * @param name The name of an attribute to be changed. Names are of
1879 * one of the following forms:
1880 *
1881 * system.nt_sec_desc.<attribute name>
1882 * system.nt_sec_desc.*
1883 * system.nt_sec_desc.*+
1884 *
1885 * where <attribute name> is one of:
1886 *
1887 * revision
1888 * owner
1889 * owner+
1890 * group
1891 * group+
1892 * acl:<name or sid>
1893 * acl+:<name or sid>
1894 *
1895 * In the forms "system.nt_sec_desc.*" and
1896 * "system.nt_sec_desc.*+", the asterisk and plus signs are
1897 * literal, i.e. the string is provided exactly as shown, and
1898 * the value parameter should contain a complete security
1899 * descriptor with name:value pairs separated by tabs,
1900 * commas, or newlines (not spaces!).
1901 *
1902 * The plus sign ('+') indicates that SIDs should be mapped
1903 * to names. Without the plus sign, SIDs are not mapped;
1904 * rather they are simply converted to a string format.
1905 *
1906 * @param value The value to be assigned to the specified attribute name.
1907 * This buffer should contain only the attribute value if the
1908 * name was of the "system.nt_sec_desc.<attribute_name>"
1909 * form. If the name was of the "system.nt_sec_desc.*" form
1910 * then a complete security descriptor, with name:value pairs
1911 * separated by tabs, commas, or newlines (not spaces!),
1912 * should be provided in this value buffer. A complete
1913 * security descriptor will contain one or more entries
1914 * selected from the following:
1915 *
1916 * REVISION:<revision number>
1917 * OWNER:<sid or name>
1918 * GROUP:<sid or name>
1919 * ACL:<sid or name>:<type>/<flags>/<mask>
1920 *
1921 * The revision of the ACL specifies the internal Windows NT
1922 * ACL revision for the security descriptor. If not specified
1923 * it defaults to 1. Using values other than 1 may cause
1924 * strange behaviour.
1925 *
1926 * The owner and group specify the owner and group sids for
1927 * the object. If the attribute name (either '*+' with a
1928 * complete security descriptor, or individual 'owner+' or
1929 * 'group+' attribute names) ended with a plus sign, the
1930 * specified name is resolved to a SID value, using the
1931 * server on which the file or directory resides. Otherwise,
1932 * the value should be provided in SID-printable format as
1933 * S-1-x-y-z, and is used directly. The <sid or name>
1934 * associated with the ACL: attribute should be provided
1935 * similarly.
1936 *
1937 * @param size The number of the bytes of data in the value buffer
1938 *
1939 * @param flags A bit-wise OR of zero or more of the following:
1940 * SMBC_XATTR_FLAG_CREATE -
1941 * fail if the named attribute already exists
1942 * SMBC_XATTR_FLAG_REPLACE -
1943 * fail if the attribute does not already exist
1944 *
1945 * If neither flag is specified, the specified attributes
1946 * will be added or replace existing attributes of the same
1947 * name, as necessary.
1948 *
1949 * @return 0 on success, < 0 on error with errno set:
1950 * - EINVAL The client library is not properly initialized
1951 * or one of the parameters is not of a correct
1952 * form
1953 * - ENOMEM No memory was available for internal needs
1954 * - EEXIST If the attribute already exists and the flag
1955 * SMBC_XATTR_FLAG_CREAT was specified
1956 * - ENOATTR If the attribute does not exist and the flag
1957 * SMBC_XATTR_FLAG_REPLACE was specified
1958 * - EPERM Permission was denied.
1959 * - ENOTSUP The referenced file system does not support
1960 * extended attributes
1961 *
1962 * @note Attribute names are compared in a case-insensitive
1963 * fashion. All of the following are equivalent, although
1964 * the all-lower-case name is the preferred format:
1965 * system.nt_sec_desc.owner
1966 * SYSTEM.NT_SEC_DESC.OWNER
1967 * sYsTeM.nt_sEc_desc.owNER
1968 *
1969 */
1970int smbc_lsetxattr(const char *url,
1971 const char *name,
1972 const void *value,
1973 size_t size,
1974 int flags);
1975
1976
1977/**@ingroup attribute
1978 * Set extended attributes for a file. This is used for modifying a file's
1979 * security descriptor (i.e. owner, group, and access control list)
1980 *
1981 * @param fd A file descriptor associated with an open file (as
1982 * previously returned by smbc_open(), to get extended
1983 * attributes for.
1984 *
1985 * @param name The name of an attribute to be changed. Names are of
1986 * one of the following forms:
1987 *
1988 * system.nt_sec_desc.<attribute name>
1989 * system.nt_sec_desc.*
1990 * system.nt_sec_desc.*+
1991 *
1992 * where <attribute name> is one of:
1993 *
1994 * revision
1995 * owner
1996 * owner+
1997 * group
1998 * group+
1999 * acl:<name or sid>
2000 * acl+:<name or sid>
2001 *
2002 * In the forms "system.nt_sec_desc.*" and
2003 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2004 * literal, i.e. the string is provided exactly as shown, and
2005 * the value parameter should contain a complete security
2006 * descriptor with name:value pairs separated by tabs,
2007 * commas, or newlines (not spaces!).
2008 *
2009 * The plus sign ('+') indicates that SIDs should be mapped
2010 * to names. Without the plus sign, SIDs are not mapped;
2011 * rather they are simply converted to a string format.
2012 *
2013 * @param value The value to be assigned to the specified attribute name.
2014 * This buffer should contain only the attribute value if the
2015 * name was of the "system.nt_sec_desc.<attribute_name>"
2016 * form. If the name was of the "system.nt_sec_desc.*" form
2017 * then a complete security descriptor, with name:value pairs
2018 * separated by tabs, commas, or newlines (not spaces!),
2019 * should be provided in this value buffer. A complete
2020 * security descriptor will contain one or more entries
2021 * selected from the following:
2022 *
2023 * REVISION:<revision number>
2024 * OWNER:<sid or name>
2025 * GROUP:<sid or name>
2026 * ACL:<sid or name>:<type>/<flags>/<mask>
2027 *
2028 * The revision of the ACL specifies the internal Windows NT
2029 * ACL revision for the security descriptor. If not specified
2030 * it defaults to 1. Using values other than 1 may cause
2031 * strange behaviour.
2032 *
2033 * The owner and group specify the owner and group sids for
2034 * the object. If the attribute name (either '*+' with a
2035 * complete security descriptor, or individual 'owner+' or
2036 * 'group+' attribute names) ended with a plus sign, the
2037 * specified name is resolved to a SID value, using the
2038 * server on which the file or directory resides. Otherwise,
2039 * the value should be provided in SID-printable format as
2040 * S-1-x-y-z, and is used directly. The <sid or name>
2041 * associated with the ACL: attribute should be provided
2042 * similarly.
2043 *
2044 * @param size The number of the bytes of data in the value buffer
2045 *
2046 * @param flags A bit-wise OR of zero or more of the following:
2047 * SMBC_XATTR_FLAG_CREATE -
2048 * fail if the named attribute already exists
2049 * SMBC_XATTR_FLAG_REPLACE -
2050 * fail if the attribute does not already exist
2051 *
2052 * If neither flag is specified, the specified attributes
2053 * will be added or replace existing attributes of the same
2054 * name, as necessary.
2055 *
2056 * @return 0 on success, < 0 on error with errno set:
2057 * - EINVAL The client library is not properly initialized
2058 * or one of the parameters is not of a correct
2059 * form
2060 * - ENOMEM No memory was available for internal needs
2061 * - EEXIST If the attribute already exists and the flag
2062 * SMBC_XATTR_FLAG_CREAT was specified
2063 * - ENOATTR If the attribute does not exist and the flag
2064 * SMBC_XATTR_FLAG_REPLACE was specified
2065 * - EPERM Permission was denied.
2066 * - ENOTSUP The referenced file system does not support
2067 * extended attributes
2068 *
2069 * @note Attribute names are compared in a case-insensitive
2070 * fashion. All of the following are equivalent, although
2071 * the all-lower-case name is the preferred format:
2072 * system.nt_sec_desc.owner
2073 * SYSTEM.NT_SEC_DESC.OWNER
2074 * sYsTeM.nt_sEc_desc.owNER
2075 *
2076 */
2077int smbc_fsetxattr(int fd,
2078 const char *name,
2079 const void *value,
2080 size_t size,
2081 int flags);
2082
2083
2084/**@ingroup attribute
2085 * Get extended attributes for a file.
2086 *
2087 * @param url The smb url of the file or directory to get extended
2088 * attributes for.
2089 *
2090 * @param name The name of an attribute to be retrieved. Names are of
2091 * one of the following forms:
2092 *
2093 * system.nt_sec_desc.<attribute name>
2094 * system.nt_sec_desc.*
2095 * system.nt_sec_desc.*+
2096 *
2097 * where <attribute name> is one of:
2098 *
2099 * revision
2100 * owner
2101 * owner+
2102 * group
2103 * group+
2104 * acl:<name or sid>
2105 * acl+:<name or sid>
2106 *
2107 * In the forms "system.nt_sec_desc.*" and
2108 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2109 * literal, i.e. the string is provided exactly as shown, and
2110 * the value parameter will return a complete security
2111 * descriptor with name:value pairs separated by tabs,
2112 * commas, or newlines (not spaces!).
2113 *
2114 * The plus sign ('+') indicates that SIDs should be mapped
2115 * to names. Without the plus sign, SIDs are not mapped;
2116 * rather they are simply converted to a string format.
2117 *
2118 * @param value A pointer to a buffer in which the value of the specified
2119 * attribute will be placed (unless size is zero).
2120 *
2121 * @param size The size of the buffer pointed to by value. This parameter
2122 * may also be zero, in which case the size of the buffer
2123 * required to hold the attribute value will be returned,
2124 * but nothing will be placed into the value buffer.
2125 *
2126 * @return 0 on success, < 0 on error with errno set:
2127 * - EINVAL The client library is not properly initialized
2128 * or one of the parameters is not of a correct
2129 * form
2130 * - ENOMEM No memory was available for internal needs
2131 * - EEXIST If the attribute already exists and the flag
2132 * SMBC_XATTR_FLAG_CREAT was specified
2133 * - ENOATTR If the attribute does not exist and the flag
2134 * SMBC_XATTR_FLAG_REPLACE was specified
2135 * - EPERM Permission was denied.
2136 * - ENOTSUP The referenced file system does not support
2137 * extended attributes
2138 *
2139 */
2140int smbc_getxattr(const char *url,
2141 const char *name,
2142 const void *value,
2143 size_t size);
2144
2145
2146/**@ingroup attribute
2147 * Get extended attributes for a file. The POSIX function which this maps to
2148 * would act on a symbolic link rather than acting on what the symbolic link
2149 * points to, but with no symbolic links in SMB file systems, this function
2150 * is functionally identical to smbc_getxattr().
2151 *
2152 * @param url The smb url of the file or directory to get extended
2153 * attributes for.
2154 *
2155 * @param name The name of an attribute to be retrieved. Names are of
2156 * one of the following forms:
2157 *
2158 * system.nt_sec_desc.<attribute name>
2159 * system.nt_sec_desc.*
2160 * system.nt_sec_desc.*+
2161 *
2162 * where <attribute name> is one of:
2163 *
2164 * revision
2165 * owner
2166 * owner+
2167 * group
2168 * group+
2169 * acl:<name or sid>
2170 * acl+:<name or sid>
2171 *
2172 * In the forms "system.nt_sec_desc.*" and
2173 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2174 * literal, i.e. the string is provided exactly as shown, and
2175 * the value parameter will return a complete security
2176 * descriptor with name:value pairs separated by tabs,
2177 * commas, or newlines (not spaces!).
2178 *
2179 * The plus sign ('+') indicates that SIDs should be mapped
2180 * to names. Without the plus sign, SIDs are not mapped;
2181 * rather they are simply converted to a string format.
2182 *
2183 * @param value A pointer to a buffer in which the value of the specified
2184 * attribute will be placed (unless size is zero).
2185 *
2186 * @param size The size of the buffer pointed to by value. This parameter
2187 * may also be zero, in which case the size of the buffer
2188 * required to hold the attribute value will be returned,
2189 * but nothing will be placed into the value buffer.
2190 *
2191 * @return 0 on success, < 0 on error with errno set:
2192 * - EINVAL The client library is not properly initialized
2193 * or one of the parameters is not of a correct
2194 * form
2195 * - ENOMEM No memory was available for internal needs
2196 * - EEXIST If the attribute already exists and the flag
2197 * SMBC_XATTR_FLAG_CREAT was specified
2198 * - ENOATTR If the attribute does not exist and the flag
2199 * SMBC_XATTR_FLAG_REPLACE was specified
2200 * - EPERM Permission was denied.
2201 * - ENOTSUP The referenced file system does not support
2202 * extended attributes
2203 *
2204 */
2205int smbc_lgetxattr(const char *url,
2206 const char *name,
2207 const void *value,
2208 size_t size);
2209
2210
2211/**@ingroup attribute
2212 * Get extended attributes for a file.
2213 *
2214 * @param fd A file descriptor associated with an open file (as
2215 * previously returned by smbc_open(), to get extended
2216 * attributes for.
2217 *
2218 * @param name The name of an attribute to be retrieved. Names are of
2219 * one of the following forms:
2220 *
2221 * system.nt_sec_desc.<attribute name>
2222 * system.nt_sec_desc.*
2223 * system.nt_sec_desc.*+
2224 *
2225 * where <attribute name> is one of:
2226 *
2227 * revision
2228 * owner
2229 * owner+
2230 * group
2231 * group+
2232 * acl:<name or sid>
2233 * acl+:<name or sid>
2234 *
2235 * In the forms "system.nt_sec_desc.*" and
2236 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2237 * literal, i.e. the string is provided exactly as shown, and
2238 * the value parameter will return a complete security
2239 * descriptor with name:value pairs separated by tabs,
2240 * commas, or newlines (not spaces!).
2241 *
2242 * The plus sign ('+') indicates that SIDs should be mapped
2243 * to names. Without the plus sign, SIDs are not mapped;
2244 * rather they are simply converted to a string format.
2245 *
2246 * @param value A pointer to a buffer in which the value of the specified
2247 * attribute will be placed (unless size is zero).
2248 *
2249 * @param size The size of the buffer pointed to by value. This parameter
2250 * may also be zero, in which case the size of the buffer
2251 * required to hold the attribute value will be returned,
2252 * but nothing will be placed into the value buffer.
2253 *
2254 * @return 0 on success, < 0 on error with errno set:
2255 * - EINVAL The client library is not properly initialized
2256 * or one of the parameters is not of a correct
2257 * form
2258 * - ENOMEM No memory was available for internal needs
2259 * - EEXIST If the attribute already exists and the flag
2260 * SMBC_XATTR_FLAG_CREAT was specified
2261 * - ENOATTR If the attribute does not exist and the flag
2262 * SMBC_XATTR_FLAG_REPLACE was specified
2263 * - EPERM Permission was denied.
2264 * - ENOTSUP The referenced file system does not support
2265 * extended attributes
2266 *
2267 */
2268int smbc_fgetxattr(int fd,
2269 const char *name,
2270 const void *value,
2271 size_t size);
2272
2273
2274/**@ingroup attribute
2275 * Remove extended attributes for a file. This is used for modifying a file's
2276 * security descriptor (i.e. owner, group, and access control list)
2277 *
2278 * @param url The smb url of the file or directory to remove the extended
2279 * attributes for.
2280 *
2281 * @param name The name of an attribute to be removed. Names are of
2282 * one of the following forms:
2283 *
2284 * system.nt_sec_desc.<attribute name>
2285 * system.nt_sec_desc.*
2286 * system.nt_sec_desc.*+
2287 *
2288 * where <attribute name> is one of:
2289 *
2290 * revision
2291 * owner
2292 * owner+
2293 * group
2294 * group+
2295 * acl:<name or sid>
2296 * acl+:<name or sid>
2297 *
2298 * In the forms "system.nt_sec_desc.*" and
2299 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2300 * literal, i.e. the string is provided exactly as shown, and
2301 * the value parameter will return a complete security
2302 * descriptor with name:value pairs separated by tabs,
2303 * commas, or newlines (not spaces!).
2304 *
2305 * The plus sign ('+') indicates that SIDs should be mapped
2306 * to names. Without the plus sign, SIDs are not mapped;
2307 * rather they are simply converted to a string format.
2308 *
2309 * @return 0 on success, < 0 on error with errno set:
2310 * - EINVAL The client library is not properly initialized
2311 * - ENOMEM No memory was available for internal needs
2312 * - EPERM Permission was denied.
2313 * - ENOTSUP The referenced file system does not support
2314 * extended attributes
2315 *
2316 */
2317int smbc_removexattr(const char *url,
2318 const char *name);
2319
2320
2321/**@ingroup attribute
2322 * Remove extended attributes for a file. This is used for modifying a file's
2323 * security descriptor (i.e. owner, group, and access control list) The POSIX
2324 * function which this maps to would act on a symbolic link rather than acting
2325 * on what the symbolic link points to, but with no symbolic links in SMB file
2326 * systems, this function is functionally identical to smbc_removexattr().
2327 *
2328 * @param url The smb url of the file or directory to remove the extended
2329 * attributes for.
2330 *
2331 * @param name The name of an attribute to be removed. Names are of
2332 * one of the following forms:
2333 *
2334 * system.nt_sec_desc.<attribute name>
2335 * system.nt_sec_desc.*
2336 * system.nt_sec_desc.*+
2337 *
2338 * where <attribute name> is one of:
2339 *
2340 * revision
2341 * owner
2342 * owner+
2343 * group
2344 * group+
2345 * acl:<name or sid>
2346 * acl+:<name or sid>
2347 *
2348 * In the forms "system.nt_sec_desc.*" and
2349 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2350 * literal, i.e. the string is provided exactly as shown, and
2351 * the value parameter will return a complete security
2352 * descriptor with name:value pairs separated by tabs,
2353 * commas, or newlines (not spaces!).
2354 *
2355 * The plus sign ('+') indicates that SIDs should be mapped
2356 * to names. Without the plus sign, SIDs are not mapped;
2357 * rather they are simply converted to a string format.
2358 *
2359 * @return 0 on success, < 0 on error with errno set:
2360 * - EINVAL The client library is not properly initialized
2361 * - ENOMEM No memory was available for internal needs
2362 * - EPERM Permission was denied.
2363 * - ENOTSUP The referenced file system does not support
2364 * extended attributes
2365 *
2366 */
2367int smbc_lremovexattr(const char *url,
2368 const char *name);
2369
2370
2371/**@ingroup attribute
2372 * Remove extended attributes for a file. This is used for modifying a file's
2373 * security descriptor (i.e. owner, group, and access control list)
2374 *
2375 * @param fd A file descriptor associated with an open file (as
2376 * previously returned by smbc_open(), to get extended
2377 * attributes for.
2378 *
2379 * @param name The name of an attribute to be removed. Names are of
2380 * one of the following forms:
2381 *
2382 * system.nt_sec_desc.<attribute name>
2383 * system.nt_sec_desc.*
2384 * system.nt_sec_desc.*+
2385 *
2386 * where <attribute name> is one of:
2387 *
2388 * revision
2389 * owner
2390 * owner+
2391 * group
2392 * group+
2393 * acl:<name or sid>
2394 * acl+:<name or sid>
2395 *
2396 * In the forms "system.nt_sec_desc.*" and
2397 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2398 * literal, i.e. the string is provided exactly as shown, and
2399 * the value parameter will return a complete security
2400 * descriptor with name:value pairs separated by tabs,
2401 * commas, or newlines (not spaces!).
2402 *
2403 * The plus sign ('+') indicates that SIDs should be mapped
2404 * to names. Without the plus sign, SIDs are not mapped;
2405 * rather they are simply converted to a string format.
2406 *
2407 * @return 0 on success, < 0 on error with errno set:
2408 * - EINVAL The client library is not properly initialized
2409 * - ENOMEM No memory was available for internal needs
2410 * - EPERM Permission was denied.
2411 * - ENOTSUP The referenced file system does not support
2412 * extended attributes
2413 *
2414 */
2415int smbc_fremovexattr(int fd,
2416 const char *name);
2417
2418
2419/**@ingroup attribute
2420 * List the supported extended attribute names associated with a file
2421 *
2422 * @param url The smb url of the file or directory to list the extended
2423 * attributes for.
2424 *
2425 * @param list A pointer to a buffer in which the list of attributes for
2426 * the specified file or directory will be placed (unless
2427 * size is zero).
2428 *
2429 * @param size The size of the buffer pointed to by list. This parameter
2430 * may also be zero, in which case the size of the buffer
2431 * required to hold all of the attribute names will be
2432 * returned, but nothing will be placed into the list buffer.
2433 *
2434 * @return 0 on success, < 0 on error with errno set:
2435 * - EINVAL The client library is not properly initialized
2436 * - ENOMEM No memory was available for internal needs
2437 * - EPERM Permission was denied.
2438 * - ENOTSUP The referenced file system does not support
2439 * extended attributes
2440 *
2441 * @note This function always returns all attribute names supported
2442 * by NT file systems, regardless of whether the referenced
2443 * file system supports extended attributes (e.g. a Windows
2444 * 2000 machine supports extended attributes if NTFS is used,
2445 * but not if FAT is used, and Windows 98 doesn't support
2446 * extended attributes at all. Whether this is a feature or
2447 * a bug is yet to be decided.
2448 */
2449int smbc_listxattr(const char *url,
2450 char *list,
2451 size_t size);
2452
2453/**@ingroup attribute
2454 * List the supported extended attribute names associated with a file The
2455 * POSIX function which this maps to would act on a symbolic link rather than
2456 * acting on what the symbolic link points to, but with no symbolic links in
2457 * SMB file systems, this function is functionally identical to
2458 * smbc_listxattr().
2459 *
2460 * @param url The smb url of the file or directory to list the extended
2461 * attributes for.
2462 *
2463 * @param list A pointer to a buffer in which the list of attributes for
2464 * the specified file or directory will be placed (unless
2465 * size is zero).
2466 *
2467 * @param size The size of the buffer pointed to by list. This parameter
2468 * may also be zero, in which case the size of the buffer
2469 * required to hold all of the attribute names will be
2470 * returned, but nothing will be placed into the list buffer.
2471 *
2472 * @return 0 on success, < 0 on error with errno set:
2473 * - EINVAL The client library is not properly initialized
2474 * - ENOMEM No memory was available for internal needs
2475 * - EPERM Permission was denied.
2476 * - ENOTSUP The referenced file system does not support
2477 * extended attributes
2478 *
2479 * @note This function always returns all attribute names supported
2480 * by NT file systems, regardless of wether the referenced
2481 * file system supports extended attributes (e.g. a Windows
2482 * 2000 machine supports extended attributes if NTFS is used,
2483 * but not if FAT is used, and Windows 98 doesn't support
2484 * extended attributes at all. Whether this is a feature or
2485 * a bug is yet to be decided.
2486 */
2487int smbc_llistxattr(const char *url,
2488 char *list,
2489 size_t size);
2490
2491/**@ingroup attribute
2492 * List the supported extended attribute names associated with a file
2493 *
2494 * @param fd A file descriptor associated with an open file (as
2495 * previously returned by smbc_open(), to get extended
2496 * attributes for.
2497 *
2498 * @param list A pointer to a buffer in which the list of attributes for
2499 * the specified file or directory will be placed (unless
2500 * size is zero).
2501 *
2502 * @param size The size of the buffer pointed to by list. This parameter
2503 * may also be zero, in which case the size of the buffer
2504 * required to hold all of the attribute names will be
2505 * returned, but nothing will be placed into the list buffer.
2506 *
2507 * @return 0 on success, < 0 on error with errno set:
2508 * - EINVAL The client library is not properly initialized
2509 * - ENOMEM No memory was available for internal needs
2510 * - EPERM Permission was denied.
2511 * - ENOTSUP The referenced file system does not support
2512 * extended attributes
2513 *
2514 * @note This function always returns all attribute names supported
2515 * by NT file systems, regardless of wether the referenced
2516 * file system supports extended attributes (e.g. a Windows
2517 * 2000 machine supports extended attributes if NTFS is used,
2518 * but not if FAT is used, and Windows 98 doesn't support
2519 * extended attributes at all. Whether this is a feature or
2520 * a bug is yet to be decided.
2521 */
2522int smbc_flistxattr(int fd,
2523 char *list,
2524 size_t size);
2525
2526/**@ingroup print
2527 * Print a file given the name in fname. It would be a URL ...
2528 *
2529 * @param fname The URL of a file on a remote SMB server that the
2530 * caller wants printed
2531 *
2532 * @param printq The URL of the print share to print the file to.
2533 *
2534 * @return 0 on success, < 0 on error with errno set:
2535 *
2536 * - EINVAL fname or printq was NULL or smbc_init not
2537 * not called.
2538 * and errors returned by smbc_open
2539 *
2540 */
2541int smbc_print_file(const char *fname, const char *printq);
2542
2543/**@ingroup print
2544 * Open a print file that can be written to by other calls. This simply
2545 * does an smbc_open call after checking if there is a file name on the
2546 * URI. If not, a temporary name is added ...
2547 *
2548 * @param fname The URL of the print share to print to?
2549 *
2550 * @returns A file handle for the print file if successful.
2551 * Returns -1 if an error ocurred and errno has the values
2552 * - EINVAL fname was NULL or smbc_init not called.
2553 * - all errors returned by smbc_open
2554 *
2555 */
2556int smbc_open_print_job(const char *fname);
2557
2558/**@ingroup print
2559 * List the print jobs on a print share, for the moment, pass a callback
2560 *
2561 * @param purl The url of the print share to list the jobs of
2562 *
2563 * @param fn Callback function the receives printjob info
2564 *
2565 * @return 0 on success, < 0 on error with errno set:
2566 * - EINVAL fname was NULL or smbc_init not called
2567 * - EACCES ???
2568 */
2569int smbc_list_print_jobs(const char *purl, smbc_list_print_job_fn fn);
2570
2571/**@ingroup print
2572 * Delete a print job
2573 *
2574 * @param purl Url of the print share
2575 *
2576 * @param id The id of the job to delete
2577 *
2578 * @return 0 on success, < 0 on error with errno set:
2579 * - EINVAL fname was NULL or smbc_init not called
2580 *
2581 * @todo what errno values are possible here?
2582 */
2583int smbc_unlink_print_job(const char *purl, int id);
2584
2585/**@ingroup callback
2586 * Remove a server from the cached server list it's unused.
2587 *
2588 * @param context pointer to smb context
2589 *
2590 * @param srv pointer to server to remove
2591 *
2592 * @return On success, 0 is returned. 1 is returned if the server could not
2593 * be removed. Also useable outside libsmbclient.
2594 */
2595int smbc_remove_unused_server(SMBCCTX * context, SMBCSRV * srv);
2596
2597#ifdef __cplusplus
2598}
2599#endif
2600
2601/**@ingroup directory
2602 * Convert strings of %xx to their single character equivalent.
2603 *
2604 * @param dest A pointer to a buffer in which the resulting decoded
2605 * string should be placed. This may be a pointer to the
2606 * same buffer as src_segment.
2607 *
2608 * @param src A pointer to the buffer containing the URL to be decoded.
2609 * Any %xx sequences herein are converted to their single
2610 * character equivalent. Each 'x' must be a valid hexadecimal
2611 * digit, or that % sequence is left undecoded.
2612 *
2613 * @param max_dest_len
2614 * The size of the buffer pointed to by dest_segment.
2615 *
2616 * @return The number of % sequences which could not be converted
2617 * due to lack of two following hexadecimal digits.
2618 */
2619#ifdef __cplusplus
2620extern "C" {
2621#endif
2622int
2623smbc_urldecode(char *dest, char * src, size_t max_dest_len);
2624#ifdef __cplusplus
2625}
2626#endif
2627
2628
2629/*
2630 * Convert any characters not specifically allowed in a URL into their %xx
2631 * equivalent.
2632 *
2633 * @param dest A pointer to a buffer in which the resulting encoded
2634 * string should be placed. Unlike smbc_urldecode(), this
2635 * must be a buffer unique from src.
2636 *
2637 * @param src A pointer to the buffer containing the string to be encoded.
2638 * Any character not specifically allowed in a URL is converted
2639 * into its hexadecimal value and encoded as %xx.
2640 *
2641 * @param max_dest_len
2642 * The size of the buffer pointed to by dest_segment.
2643 *
2644 * @returns The remaining buffer length.
2645 */
2646#ifdef __cplusplus
2647extern "C" {
2648#endif
2649int
2650smbc_urlencode(char * dest, char * src, int max_dest_len);
2651#ifdef __cplusplus
2652}
2653#endif
2654
2655
2656/**@ingroup directory
2657 * Return the version of the linked Samba code, and thus the version of the
2658 * libsmbclient code.
2659 *
2660 * @return The version string.
2661 */
2662#ifdef __cplusplus
2663extern "C" {
2664#endif
2665const char *
2666smbc_version(void);
2667#ifdef __cplusplus
2668}
2669#endif
2670
2671/**@ingroup misc
2672 * Set the users credentials globally so they can be used for DFS
2673 * referrals. Probably best to use this function in the smbc_get_auth_data_fn
2674 * callback.
2675 *
2676 * @param workgroup Workgroup of the user.
2677 *
2678 * @param user Username of user.
2679 *
2680 * @param password Password of user.
2681 *
2682 * @param use_kerberos Whether to use Kerberos
2683 *
2684 * @param signing_state One of these strings (all equivalents on same line):
2685 * "off", "no", "false"
2686 * "on", "yes", "true", "auto"
2687 * "force", "required", "forced"
2688 */
2689
2690void
2691smbc_set_credentials(const char *workgroup,
2692 const char *user,
2693 const char *password,
2694 smbc_bool use_kerberos,
2695 const char *signing_state);
2696
2697/*
2698 * Wrapper around smbc_set_credentials.
2699 * Used to set correct credentials that will
2700 * be used to connect to DFS target share
2701 * in libsmbclient
2702 */
2703
2704void
2705smbc_set_credentials_with_fallback(SMBCCTX *ctx,
2706 const char *workgroup,
2707 const char *user,
2708 const char *password);
2709
2710
2711/**
2712 * @ingroup threads
2713 *
2714 * Initialize for threads using the Posix Threads (pthread)
2715 * implementation. This is a built-in implementation, avoiding the need to
2716 * implement the component functions of the thread interface. If this function
2717 * is used, it is not necessary to call smbc_thread_impl().
2718 *
2719 * @return {void}
2720 */
2721void
2722smbc_thread_posix(void);
2723
2724/**
2725 * @ingroup threads
2726 *
2727 * Initialize for an arbitrary thread implementation. The caller should
2728 * provide, as parameters, pointers to functions to implement the requisite
2729 * low-level thread functionality. A function must be provided for each
2730 * parameter; none may be null.
2731 *
2732 * If the thread implementation is POSIX Threads (pthreads), then the much
2733 * simpler smbc_thread_pthread() function may be used instead of this one.
2734 *
2735 * @param create_mutex
2736 * Create a mutex. This function should expect three parameters: lockname,
2737 * pplock, and location. It should create a unique mutex for each unique
2738 * lockname it is provided, and return the mutex identifier in *pplock. The
2739 * location parameter can be used for debugging, as it contains the
2740 * compiler-provided __location__ of the call.
2741 *
2742 * @param destroy_mutex
2743 * Destroy a mutex. This function should expect two parameters: plock and
2744 * location. It should destroy the mutex associated with the identifier
2745 * plock. The location parameter can be used for debugging, as it contains
2746 * the compiler-provided __location__ of the call.
2747 *
2748 * @param lock_mutex
2749 * Lock a mutex. This function should expect three parameters: plock,
2750 * lock_type, and location. The mutex aassociated with identifier plock
2751 * should be locked if lock_type is 1, and unlocked if lock_type is 2. The
2752 * location parameter can be used for debugging, as it contains the
2753 * compiler-provided __location__ of the call.
2754 *
2755 * @param create_tls
2756 * Create thread local storage. This function should expect three
2757 * parameters: keyname, ppkey, and location. It should allocate an
2758 * implementation-specific amount of memory and assign the pointer to that
2759 * allocated memory to *ppkey. The location parameter can be used for
2760 * debugging, as it contains the compiler-provided __location__ of the
2761 * call. This function should return 0 upon success, non-zero upon failure.
2762 *
2763 * @param destroy_tls
2764 * Destroy thread local storage. This function should expect two parameters:
2765 * ppkey and location. The ppkey parameter points to a variable containing a
2766 * thread local storage key previously provided by the create_tls
2767 * function. The location parameter can be used for debugging, as it
2768 * contains the compiler-provided __location__ of the call.
2769 *
2770 * @param set_tls
2771 * Set a thread local storage variable's value. This function should expect
2772 * three parameters: pkey, pval, and location. The pkey parameter is a
2773 * thread local storage key previously provided by the create_tls
2774 * function. The (void *) pval parameter contains the value to be placed in
2775 * the thread local storage variable identified by pkey. The location
2776 * parameter can be used for debugging, as it contains the compiler-provided
2777 * __location__ of the call. This function should return 0 upon success;
2778 * non-zero otherwise.
2779 *
2780 * @param get_tls
2781 * Retrieve a thread local storage variable's value. This function should
2782 * expect two parameters: pkey and location. The pkey parameter is a thread
2783 * local storage key previously provided by the create_tls function, and
2784 * which has previously been used in a call to the set_tls function to
2785 * initialize a thread local storage variable. The location parameter can be
2786 * used for debugging, as it contains the compiler-provided __location__ of
2787 * the call. This function should return the (void *) value stored in the
2788 * variable identified by pkey.
2789 *
2790 * @return {void}
2791 */
2792void
2793smbc_thread_impl(
2794 /* Mutex functions. */
2795 int (*create_mutex)(const char *lockname,
2796 void **pplock,
2797 const char *location),
2798 void (*destroy_mutex)(void *plock,
2799 const char *location),
2800 int (*lock_mutex)(void *plock,
2801 int lock_type,
2802 const char *location),
2803
2804 /* Thread local storage. */
2805 int (*create_tls)(const char *keyname,
2806 void **ppkey,
2807 const char *location),
2808 void (*destroy_tls)(void **ppkey,
2809 const char *location),
2810 int (*set_tls)(void *pkey,
2811 const void *pval,
2812 const char *location),
2813 void *(*get_tls)(void *pkey,
2814 const char *location)
2815 );
2816
2817
2818
2819/**
2820 * @ingroup structure
2821 * Structure that contains a client context information
2822 * This structure is known as SMBCCTX
2823 *
2824 * DO NOT DIRECTLY MANIPULATE THE CONTEXT STRUCTURE! The data in the context
2825 * structure should all be considered private to the library. It remains here
2826 * only for backward compatibility.
2827 *
2828 * See the comments herein for use of the setter and getter functions which
2829 * should now be used for manipulating these values. New features, functions,
2830 * etc., are not added here but rather in _internal where they are not
2831 * directly visible to applications. This makes it much easier to maintain
2832 * ABI compatibility.
2833 */
2834struct _SMBCCTX
2835{
2836 /**
2837 * debug level
2838 *
2839 * DEPRECATED:
2840 * Use smbc_getDebug() and smbc_setDebug()
2841 */
2842 int debug DEPRECATED_SMBC_INTERFACE;
2843
2844 /**
2845 * netbios name used for making connections
2846 *
2847 * DEPRECATED:
2848 * Use smbc_getNetbiosName() and smbc_setNetbiosName()
2849 */
2850 char * netbios_name DEPRECATED_SMBC_INTERFACE;
2851
2852 /**
2853 * workgroup name used for making connections
2854 *
2855 * DEPRECATED:
2856 * Use smbc_getWorkgroup() and smbc_setWorkgroup()
2857 */
2858 char * workgroup DEPRECATED_SMBC_INTERFACE;
2859
2860 /**
2861 * username used for making connections
2862 *
2863 * DEPRECATED:
2864 * Use smbc_getUser() and smbc_setUser()
2865 */
2866 char * user DEPRECATED_SMBC_INTERFACE;
2867
2868 /**
2869 * timeout used for waiting on connections / response data (in
2870 * milliseconds)
2871 *
2872 * DEPRECATED:
2873 * Use smbc_getTimeout() and smbc_setTimeout()
2874 */
2875 int timeout DEPRECATED_SMBC_INTERFACE;
2876
2877 /**
2878 * callable functions for files:
2879 * For usage and return values see the SMBC_* functions
2880 *
2881 * DEPRECATED:
2882 *
2883 * Use smbc_getFunction*() and smbc_setFunction*(), e.g.
2884 * smbc_getFunctionOpen(), smbc_setFunctionUnlink(), etc.
2885 */
2886 smbc_open_fn open DEPRECATED_SMBC_INTERFACE;
2887 smbc_creat_fn creat DEPRECATED_SMBC_INTERFACE;
2888 smbc_read_fn read DEPRECATED_SMBC_INTERFACE;
2889 smbc_write_fn write DEPRECATED_SMBC_INTERFACE;
2890 smbc_unlink_fn unlink DEPRECATED_SMBC_INTERFACE;
2891 smbc_rename_fn rename DEPRECATED_SMBC_INTERFACE;
2892 smbc_lseek_fn lseek DEPRECATED_SMBC_INTERFACE;
2893 smbc_stat_fn stat DEPRECATED_SMBC_INTERFACE;
2894 smbc_fstat_fn fstat DEPRECATED_SMBC_INTERFACE;
2895#if 0 /* internal */
2896 smbc_ftruncate_fn ftruncate_fn;
2897#endif
2898 smbc_close_fn close_fn DEPRECATED_SMBC_INTERFACE;
2899 smbc_opendir_fn opendir DEPRECATED_SMBC_INTERFACE;
2900 smbc_closedir_fn closedir DEPRECATED_SMBC_INTERFACE;
2901 smbc_readdir_fn readdir DEPRECATED_SMBC_INTERFACE;
2902 smbc_getdents_fn getdents DEPRECATED_SMBC_INTERFACE;
2903 smbc_mkdir_fn mkdir DEPRECATED_SMBC_INTERFACE;
2904 smbc_rmdir_fn rmdir DEPRECATED_SMBC_INTERFACE;
2905 smbc_telldir_fn telldir DEPRECATED_SMBC_INTERFACE;
2906 smbc_lseekdir_fn lseekdir DEPRECATED_SMBC_INTERFACE;
2907 smbc_fstatdir_fn fstatdir DEPRECATED_SMBC_INTERFACE;
2908 smbc_chmod_fn chmod DEPRECATED_SMBC_INTERFACE;
2909 smbc_utimes_fn utimes DEPRECATED_SMBC_INTERFACE;
2910 smbc_setxattr_fn setxattr DEPRECATED_SMBC_INTERFACE;
2911 smbc_getxattr_fn getxattr DEPRECATED_SMBC_INTERFACE;
2912 smbc_removexattr_fn removexattr DEPRECATED_SMBC_INTERFACE;
2913 smbc_listxattr_fn listxattr DEPRECATED_SMBC_INTERFACE;
2914
2915 /* Printing-related functions */
2916 smbc_print_file_fn print_file DEPRECATED_SMBC_INTERFACE;
2917 smbc_open_print_job_fn open_print_job DEPRECATED_SMBC_INTERFACE;
2918 smbc_list_print_jobs_fn list_print_jobs DEPRECATED_SMBC_INTERFACE;
2919 smbc_unlink_print_job_fn unlink_print_job DEPRECATED_SMBC_INTERFACE;
2920
2921 /*
2922 ** Callbacks
2923 *
2924 * DEPRECATED:
2925 *
2926 * See the comment above each field, for the getter and setter
2927 * functions that should now be used.
2928 */
2929 struct _smbc_callbacks
2930 {
2931 /**
2932 * authentication function callback: called upon auth requests
2933 *
2934 * DEPRECATED:
2935 * Use smbc_getFunctionAuthData(), smbc_setFunctionAuthData()
2936 */
2937 smbc_get_auth_data_fn auth_fn DEPRECATED_SMBC_INTERFACE;
2938
2939 /**
2940 * check if a server is still good
2941 *
2942 * DEPRECATED:
2943 * Use smbc_getFunctionCheckServer(),
2944 * smbc_setFunctionCheckServer()
2945 */
2946 smbc_check_server_fn check_server_fn DEPRECATED_SMBC_INTERFACE;
2947
2948 /**
2949 * remove a server if unused
2950 *
2951 * DEPRECATED:
2952 * Use smbc_getFunctionRemoveUnusedServer(),
2953 * smbc_setFunctionCheckServer()
2954 */
2955 smbc_remove_unused_server_fn remove_unused_server_fn DEPRECATED_SMBC_INTERFACE;
2956
2957 /** Cache subsystem
2958 *
2959 * For an example cache system see
2960 * samba/source/libsmb/libsmb_cache.c
2961 *
2962 * Cache subsystem * functions follow.
2963 */
2964
2965 /**
2966 * server cache addition
2967 *
2968 * DEPRECATED:
2969 * Use smbc_getFunctionAddCachedServer(),
2970 * smbc_setFunctionAddCachedServer()
2971 */
2972 smbc_add_cached_srv_fn add_cached_srv_fn DEPRECATED_SMBC_INTERFACE;
2973
2974 /**
2975 * server cache lookup
2976 *
2977 * DEPRECATED:
2978 * Use smbc_getFunctionGetCachedServer(),
2979 * smbc_setFunctionGetCachedServer()
2980 */
2981 smbc_get_cached_srv_fn get_cached_srv_fn DEPRECATED_SMBC_INTERFACE;
2982
2983 /**
2984 * server cache removal
2985 *
2986 * DEPRECATED:
2987 * Use smbc_getFunctionRemoveCachedServer(),
2988 * smbc_setFunctionRemoveCachedServer()
2989 */
2990 smbc_remove_cached_srv_fn remove_cached_srv_fn DEPRECATED_SMBC_INTERFACE;
2991
2992 /**
2993 * server cache purging, try to remove all cached servers
2994 * (disconnect)
2995 *
2996 * DEPRECATED:
2997 * Use smbc_getFunctionPurgeCachedServers(),
2998 * smbc_setFunctionPurgeCachedServers()
2999 */
3000 smbc_purge_cached_fn purge_cached_fn DEPRECATED_SMBC_INTERFACE;
3001 } callbacks;
3002
3003 /**
3004 * Space where the private data of the server cache used to be
3005 *
3006 * DEPRECATED:
3007 * Use smbc_getServerCacheData(), smbc_setServerCacheData()
3008 */
3009 void * reserved DEPRECATED_SMBC_INTERFACE;
3010
3011 /*
3012 * Very old configuration options.
3013 *
3014 * DEPRECATED:
3015 * Use one of the following functions instead:
3016 * smbc_setOptionUseKerberos()
3017 * smbc_getOptionUseKerberos()
3018 * smbc_setOptionFallbackAfterKerberos()
3019 * smbc_getOptionFallbackAfterKerberos()
3020 * smbc_setOptionNoAutoAnonymousLogin()
3021 * smbc_getOptionNoAutoAnonymousLogin()
3022 */
3023 int flags DEPRECATED_SMBC_INTERFACE;
3024
3025 /**
3026 * user options selections that apply to this session
3027 *
3028 * NEW OPTIONS ARE NOT ADDED HERE!
3029 *
3030 * DEPRECATED:
3031 * To set and retrieve options, use the smbc_setOption*() and
3032 * smbc_getOption*() functions.
3033 */
3034 struct _smbc_options {
3035 int browse_max_lmb_count DEPRECATED_SMBC_INTERFACE;
3036 int urlencode_readdir_entries DEPRECATED_SMBC_INTERFACE;
3037 int one_share_per_server DEPRECATED_SMBC_INTERFACE;
3038 } options DEPRECATED_SMBC_INTERFACE;
3039
3040 /** INTERNAL DATA
3041 * do _NOT_ touch this from your program !
3042 */
3043 struct SMBC_internal_data * internal;
3044};
3045
3046
3047#endif /* SMBCLIENT_H_INCLUDED */
Note: See TracBrowser for help on using the repository browser.