docs-xml: Fix rid idmap backend documentation
[Samba.git] / source3 / include / libsmbclient.h
blob47eae80ca171bf2fce14fb39811ad454b926ce60
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
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 3 of the License, or
14 (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, see <http://www.gnu.org/licenses/>.
23 =====================================================================*/
25 #ifndef SMBCLIENT_H_INCLUDED
26 #define SMBCLIENT_H_INCLUDED
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
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
39 /*-------------------------------------------------------------------*/
40 /* The following are special comments to instruct DOXYGEN (automated
41 * documentation tool:
43 /** \defgroup libsmbclient
45 /** \defgroup structure Data Structures Type and Constants
46 * \ingroup libsmbclient
47 * Data structures, types, and constants
49 /** \defgroup callback Callback function types
50 * \ingroup libsmbclient
51 * Callback functions
53 /** \defgroup file File Functions
54 * \ingroup libsmbclient
55 * Functions used to access individual file contents
57 /** \defgroup directory Directory Functions
58 * \ingroup libsmbclient
59 * Functions used to access directory entries
61 /** \defgroup attribute Attributes Functions
62 * \ingroup libsmbclient
63 * Functions used to view or change file and directory attributes
65 /** \defgroup print Print Functions
66 * \ingroup libsmbclient
67 * Functions used to access printing functionality
69 /** \defgroup misc Miscellaneous Functions
70 * \ingroup libsmbclient
71 * Functions that don't fit in to other categories
73 /*-------------------------------------------------------------------*/
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 <stdint.h>
80 #include <fcntl.h>
81 #include <time.h>
82 #include <utime.h>
84 #define SMBC_BASE_FD 10000 /* smallest file descriptor returned */
86 #define SMBC_WORKGROUP 1
87 #define SMBC_SERVER 2
88 #define SMBC_FILE_SHARE 3
89 #define SMBC_PRINTER_SHARE 4
90 #define SMBC_COMMS_SHARE 5
91 #define SMBC_IPC_SHARE 6
92 #define SMBC_DIR 7
93 #define SMBC_FILE 8
94 #define SMBC_LINK 9
96 /**@ingroup structure
97 * Structure that represents a directory entry.
100 struct smbc_dirent
102 /** Type of entity.
103 SMBC_WORKGROUP=1,
104 SMBC_SERVER=2,
105 SMBC_FILE_SHARE=3,
106 SMBC_PRINTER_SHARE=4,
107 SMBC_COMMS_SHARE=5,
108 SMBC_IPC_SHARE=6,
109 SMBC_DIR=7,
110 SMBC_FILE=8,
111 SMBC_LINK=9,*/
112 unsigned int smbc_type;
114 /** Length of this smbc_dirent in bytes
116 unsigned int dirlen;
117 /** The length of the comment string in bytes (does not include
118 * null terminator)
120 unsigned int commentlen;
121 /** Points to the null terminated comment string
123 char *comment;
124 /** The length of the name string in bytes (does not include
125 * null terminator)
127 unsigned int namelen;
128 /** Points to the null terminated name string
130 char name[1];
133 /**@ingroup structure
134 * Structure that represents all attributes of a directory entry.
137 struct libsmb_file_info
140 * Size of file
142 uint64_t size;
144 * DOS attributes of file
146 uint16_t attrs;
148 * User ID of file
150 uid_t uid;
152 * Group ID of file
154 gid_t gid;
156 * Birth/Create time of file (if supported by system)
157 * Otherwise the value will be 0
159 struct timespec btime_ts;
161 * Modified time for the file
163 struct timespec mtime_ts;
165 * Access time for the file
167 struct timespec atime_ts;
169 * Change time for the file
171 struct timespec ctime_ts;
173 * Name of file
175 char *name;
177 * Short name of file
179 char *short_name;
183 * Logging callback function
185 typedef void (*smbc_debug_callback_fn)(void *private_ptr, int level, const char *msg);
188 * Flags for smbc_setxattr()
189 * Specify a bitwise OR of these, or 0 to add or replace as necessary
191 #define SMBC_XATTR_FLAG_CREATE 0x1 /* fail if attr already exists */
192 #define SMBC_XATTR_FLAG_REPLACE 0x2 /* fail if attr does not exist */
196 * Mappings of the DOS mode bits, as returned by smbc_getxattr() when the
197 * attribute name "system.dos_attr.mode" (or "system.dos_attr.*" or
198 * "system.*") is specified.
200 #define SMBC_DOS_MODE_READONLY 0x01
201 #define SMBC_DOS_MODE_HIDDEN 0x02
202 #define SMBC_DOS_MODE_SYSTEM 0x04
203 #define SMBC_DOS_MODE_VOLUME_ID 0x08
204 #define SMBC_DOS_MODE_DIRECTORY 0x10
205 #define SMBC_DOS_MODE_ARCHIVE 0x20
208 * Valid values for the option "open_share_mode", when calling
209 * smbc_setOptionOpenShareMode()
211 typedef enum smbc_share_mode
213 SMBC_SHAREMODE_DENY_DOS = 0,
214 SMBC_SHAREMODE_DENY_ALL = 1,
215 SMBC_SHAREMODE_DENY_WRITE = 2,
216 SMBC_SHAREMODE_DENY_READ = 3,
217 SMBC_SHAREMODE_DENY_NONE = 4,
218 SMBC_SHAREMODE_DENY_FCB = 7
219 } smbc_share_mode;
223 * Values for option SMB Encryption Level, as set and retrieved with
224 * smbc_setOptionSmbEncryptionLevel() and smbc_getOptionSmbEncryptionLevel()
226 typedef enum smbc_smb_encrypt_level
228 SMBC_ENCRYPTLEVEL_DEFAULT = -1,
229 SMBC_ENCRYPTLEVEL_NONE = 0,
230 SMBC_ENCRYPTLEVEL_REQUEST = 1,
231 SMBC_ENCRYPTLEVEL_REQUIRE = 2
232 } smbc_smb_encrypt_level;
236 * Capabilities set in the f_flag field of struct statvfs, from
237 * smbc_statvfs(). These may be OR-ed together to reflect a full set of
238 * available capabilities.
240 typedef enum smbc_vfs_feature
242 /* Defined by POSIX or in Linux include files (low-order bits) */
243 SMBC_VFS_FEATURE_RDONLY = (1 << 0),
245 /* Specific to libsmbclient (high-order bits) */
246 SMBC_VFS_FEATURE_DFS = (1 << 28),
247 SMBC_VFS_FEATURE_CASE_INSENSITIVE = (1 << 29),
248 SMBC_VFS_FEATURE_NO_UNIXCIFS = (1 << 30)
249 } smbc_vfs_feature;
251 typedef int smbc_bool;
254 #ifndef ENOATTR
255 # define ENOATTR ENOENT /* No such attribute */
256 #endif
261 /**@ingroup structure
262 * Structure that represents a print job.
265 #ifndef _CLIENT_H
266 struct print_job_info
268 /** numeric ID of the print job
270 unsigned short id;
272 /** represents print job priority (lower numbers mean higher priority)
274 unsigned short priority;
276 /** Size of the print job
278 size_t size;
280 /** Name of the user that owns the print job
282 char user[128];
284 /** Name of the print job. This will have no name if an anonymous print
285 * file was opened. Ie smb://server/printer
287 char name[128];
289 /** Time the print job was spooled
291 time_t t;
293 #endif /* _CLIENT_H */
296 /**@ingroup structure
297 * Server handle
299 typedef struct _SMBCSRV SMBCSRV;
301 /**@ingroup structure
302 * File or directory handle
304 typedef struct _SMBCFILE SMBCFILE;
306 /**@ingroup structure
307 * File or directory handle
309 typedef struct _SMBCCTX SMBCCTX;
313 * Flags for SMBCCTX->flags
315 * NEW CODE SHOULD NOT DIRECTLY MANIPULATE THE CONTEXT STRUCTURE.
316 * Instead, use:
317 * smbc_setOptionUseKerberos()
318 * smbc_getOptionUseKerberos()
319 * smbc_setOptionFallbackAfterKerberos()
320 * smbc_getOptionFallbackAFterKerberos()
321 * smbc_setOptionNoAutoAnonymousLogin()
322 * smbc_getOptionNoAutoAnonymousLogin()
323 * smbc_setOptionUseCCache()
324 * smbc_getOptionUseCCache()
326 # define SMB_CTX_FLAG_USE_KERBEROS (1 << 0)
327 # define SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS (1 << 1)
328 # define SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON (1 << 2)
329 # define SMB_CTX_FLAG_USE_CCACHE (1 << 3)
333 /**@ingroup callback
334 * Authentication callback function type (traditional method)
336 * Type for the the authentication function called by the library to
337 * obtain authentication credentials
339 * For kerberos support the function should just be called without
340 * prompting the user for credentials. Which means a simple 'return'
341 * should work. Take a look at examples/libsmbclient/get_auth_data_fn.h
342 * and examples/libsmbclient/testbrowse.c.
344 * @param srv Server being authenticated to
346 * @param shr Share being authenticated to
348 * @param wg Pointer to buffer containing a "hint" for the
349 * workgroup to be authenticated. Should be filled in
350 * with the correct workgroup if the hint is wrong.
352 * @param wglen The size of the workgroup buffer in bytes
354 * @param un Pointer to buffer containing a "hint" for the
355 * user name to be use for authentication. Should be
356 * filled in with the correct workgroup if the hint is
357 * wrong.
359 * @param unlen The size of the username buffer in bytes
361 * @param pw Pointer to buffer containing to which password
362 * copied
364 * @param pwlen The size of the password buffer in bytes
367 typedef void (*smbc_get_auth_data_fn)(const char *srv,
368 const char *shr,
369 char *wg, int wglen,
370 char *un, int unlen,
371 char *pw, int pwlen);
372 /**@ingroup callback
373 * Authentication callback function type (method that includes context)
375 * Type for the the authentication function called by the library to
376 * obtain authentication credentials
378 * For kerberos support the function should just be called without
379 * prompting the user for credentials. Which means a simple 'return'
380 * should work. Take a look at examples/libsmbclient/get_auth_data_fn.h
381 * and examples/libsmbclient/testbrowse.c.
383 * @param c Pointer to the smb context
385 * @param srv Server being authenticated to
387 * @param shr Share being authenticated to
389 * @param wg Pointer to buffer containing a "hint" for the
390 * workgroup to be authenticated. Should be filled in
391 * with the correct workgroup if the hint is wrong.
393 * @param wglen The size of the workgroup buffer in bytes
395 * @param un Pointer to buffer containing a "hint" for the
396 * user name to be use for authentication. Should be
397 * filled in with the correct workgroup if the hint is
398 * wrong.
400 * @param unlen The size of the username buffer in bytes
402 * @param pw Pointer to buffer containing to which password
403 * copied
405 * @param pwlen The size of the password buffer in bytes
408 typedef void (*smbc_get_auth_data_with_context_fn)(SMBCCTX *c,
409 const char *srv,
410 const char *shr,
411 char *wg, int wglen,
412 char *un, int unlen,
413 char *pw, int pwlen);
416 /**@ingroup callback
417 * Print job info callback function type.
419 * @param i pointer to print job information structure
422 typedef void (*smbc_list_print_job_fn)(struct print_job_info *i);
425 /**@ingroup callback
426 * Check if a server is still good
428 * @param c pointer to smb context
430 * @param srv pointer to server to check
432 * @return 0 when connection is good. 1 on error.
435 typedef int (*smbc_check_server_fn)(SMBCCTX * c, SMBCSRV *srv);
437 /**@ingroup callback
438 * Remove a server if unused
440 * @param c pointer to smb context
442 * @param srv pointer to server to remove
444 * @return 0 on success. 1 on failure.
447 typedef int (*smbc_remove_unused_server_fn)(SMBCCTX * c, SMBCSRV *srv);
450 /**@ingroup callback
451 * Add a server to the cache system
453 * @param c pointer to smb context
455 * @param srv pointer to server to add
457 * @param server server name
459 * @param share share name
461 * @param workgroup workgroup used to connect
463 * @param username username used to connect
465 * @return 0 on success. 1 on failure.
468 typedef int (*smbc_add_cached_srv_fn) (SMBCCTX * c, SMBCSRV *srv,
469 const char * server, const char * share,
470 const char * workgroup, const char * username);
472 /**@ingroup callback
473 * Look up a server in the cache system
475 * @param c pointer to smb context
477 * @param server server name to match
479 * @param share share name to match
481 * @param workgroup workgroup to match
483 * @param username username to match
485 * @return pointer to SMBCSRV on success. NULL on failure.
488 typedef SMBCSRV * (*smbc_get_cached_srv_fn) (SMBCCTX * c, const char * server,
489 const char * share, const char * workgroup,
490 const char * username);
492 /**@ingroup callback
493 * Remove a cached server
495 * @param c pointer to smb context
497 * @param srv pointer to server to remove
499 * @return 0 when found and removed. 1 on failure.
502 typedef int (*smbc_remove_cached_srv_fn)(SMBCCTX * c, SMBCSRV *srv);
505 /**@ingroup callback
506 * Try to remove all servers from the cache system and disconnect
508 * @param c pointer to smb context
510 * @return 0 when found and removed. 1 on failure.
513 typedef int (*smbc_purge_cached_fn) (SMBCCTX * c);
517 /*****************************************
518 * Getters and setters for CONFIGURATION *
519 *****************************************/
521 /** Get the debug level */
523 smbc_getDebug(SMBCCTX *c);
525 /** Set the debug level */
526 void
527 smbc_setDebug(SMBCCTX *c, int debug);
530 * set log callback function to capture logs from libsmbclient, this
531 * is applied at global level
533 void
534 smbc_setLogCallback(SMBCCTX *c, void *private_ptr,
535 smbc_debug_callback_fn fn);
537 /** set configuration file, this is applied at global level */
539 smbc_setConfiguration(SMBCCTX *c, const char *file);
541 /** Get the netbios name used for making connections */
542 const char *
543 smbc_getNetbiosName(SMBCCTX *c);
545 /** Set the netbios name used for making connections */
546 void
547 smbc_setNetbiosName(SMBCCTX *c, const char *netbios_name);
549 /** Get the workgroup used for making connections */
550 const char *
551 smbc_getWorkgroup(SMBCCTX *c);
553 /** Set the workgroup used for making connections */
554 void smbc_setWorkgroup(SMBCCTX *c, const char *workgroup);
556 /** Get the username used for making connections */
557 const char *
558 smbc_getUser(SMBCCTX *c);
560 /** Set the username used for making connections */
561 void
562 smbc_setUser(SMBCCTX *c, const char *user);
565 * Get the timeout used for waiting on connections and response data
566 * (in milliseconds)
569 smbc_getTimeout(SMBCCTX *c);
572 * Set the timeout used for waiting on connections and response data
573 * (in milliseconds)
575 void
576 smbc_setTimeout(SMBCCTX *c, int timeout);
580 * Get the TCP port used to connect (0 means default).
582 uint16_t
583 smbc_getPort(SMBCCTX *c);
586 * Set the TCP port used to connect (0 means default).
588 void
589 smbc_setPort(SMBCCTX *c, uint16_t port);
593 /***********************************
594 * Getters and setters for OPTIONS *
595 ***********************************/
597 /** Get whether to log to standard error instead of standard output */
598 smbc_bool
599 smbc_getOptionDebugToStderr(SMBCCTX *c);
601 /** Set whether to log to standard error instead of standard output */
602 void
603 smbc_setOptionDebugToStderr(SMBCCTX *c, smbc_bool b);
606 * Get whether to use new-style time attribute names, e.g. WRITE_TIME rather
607 * than the old-style names such as M_TIME. This allows also setting/getting
608 * CREATE_TIME which was previously unimplemented. (Note that the old C_TIME
609 * was supposed to be CHANGE_TIME but was confused and sometimes referred to
610 * CREATE_TIME.)
612 smbc_bool
613 smbc_getOptionFullTimeNames(SMBCCTX *c);
616 * Set whether to use new-style time attribute names, e.g. WRITE_TIME rather
617 * than the old-style names such as M_TIME. This allows also setting/getting
618 * CREATE_TIME which was previously unimplemented. (Note that the old C_TIME
619 * was supposed to be CHANGE_TIME but was confused and sometimes referred to
620 * CREATE_TIME.)
622 void
623 smbc_setOptionFullTimeNames(SMBCCTX *c, smbc_bool b);
626 * Get the share mode to use for files opened with SMBC_open_ctx(). The
627 * default is SMBC_SHAREMODE_DENY_NONE.
629 smbc_share_mode
630 smbc_getOptionOpenShareMode(SMBCCTX *c);
633 * Set the share mode to use for files opened with SMBC_open_ctx(). The
634 * default is SMBC_SHAREMODE_DENY_NONE.
636 void
637 smbc_setOptionOpenShareMode(SMBCCTX *c, smbc_share_mode share_mode);
639 /** Retrieve a previously saved user data handle */
640 void *
641 smbc_getOptionUserData(SMBCCTX *c);
643 /** Save a user data handle */
644 void
645 smbc_setOptionUserData(SMBCCTX *c, void *user_data);
647 /** Get the encoded value for encryption level. */
648 smbc_smb_encrypt_level
649 smbc_getOptionSmbEncryptionLevel(SMBCCTX *c);
651 /** Set the encoded value for encryption level. */
652 void
653 smbc_setOptionSmbEncryptionLevel(SMBCCTX *c, smbc_smb_encrypt_level level);
656 * Get whether to treat file names as case-sensitive if we can't determine
657 * when connecting to the remote share whether the file system is case
658 * sensitive. This defaults to FALSE since it's most likely that if we can't
659 * retrieve the file system attributes, it's a very old file system that does
660 * not support case sensitivity.
662 smbc_bool
663 smbc_getOptionCaseSensitive(SMBCCTX *c);
666 * Set whether to treat file names as case-sensitive if we can't determine
667 * when connecting to the remote share whether the file system is case
668 * sensitive. This defaults to FALSE since it's most likely that if we can't
669 * retrieve the file system attributes, it's a very old file system that does
670 * not support case sensitivity.
672 void
673 smbc_setOptionCaseSensitive(SMBCCTX *c, smbc_bool b);
677 * Get from how many local master browsers should the list of workgroups be
678 * retrieved. It can take up to 12 minutes or longer after a server becomes a
679 * local master browser, for it to have the entire browse list (the list of
680 * workgroups/domains) from an entire network. Since a client never knows
681 * which local master browser will be found first, the one which is found
682 * first and used to retrieve a browse list may have an incomplete or empty
683 * browse list. By requesting the browse list from multiple local master
684 * browsers, a more complete list can be generated. For small networks (few
685 * workgroups), it is recommended that this value be set to 0, causing the
686 * browse lists from all found local master browsers to be retrieved and
687 * merged. For networks with many workgroups, a suitable value for this
688 * variable is probably somewhere around 3. (Default: 3).
691 smbc_getOptionBrowseMaxLmbCount(SMBCCTX *c);
694 * Set from how many local master browsers should the list of workgroups be
695 * retrieved. It can take up to 12 minutes or longer after a server becomes a
696 * local master browser, for it to have the entire browse list (the list of
697 * workgroups/domains) from an entire network. Since a client never knows
698 * which local master browser will be found first, the one which is found
699 * first and used to retrieve a browse list may have an incomplete or empty
700 * browse list. By requesting the browse list from multiple local master
701 * browsers, a more complete list can be generated. For small networks (few
702 * workgroups), it is recommended that this value be set to 0, causing the
703 * browse lists from all found local master browsers to be retrieved and
704 * merged. For networks with many workgroups, a suitable value for this
705 * variable is probably somewhere around 3. (Default: 3).
707 void
708 smbc_setOptionBrowseMaxLmbCount(SMBCCTX *c, int count);
711 * Get whether to url-encode readdir entries.
713 * There is a difference in the desired return strings from
714 * smbc_readdir() depending upon whether the filenames are to
715 * be displayed to the user, or whether they are to be
716 * appended to the path name passed to smbc_opendir() to call
717 * a further smbc_ function (e.g. open the file with
718 * smbc_open()). In the former case, the filename should be
719 * in "human readable" form. In the latter case, the smbc_
720 * functions expect a URL which must be url-encoded. Those
721 * functions decode the URL. If, for example, smbc_readdir()
722 * returned a file name of "abc%20def.txt", passing a path
723 * with this file name attached to smbc_open() would cause
724 * smbc_open to attempt to open the file "abc def.txt" since
725 * the %20 is decoded into a space.
727 * Set this option to True if the names returned by
728 * smbc_readdir() should be url-encoded such that they can be
729 * passed back to another smbc_ call. Set it to False if the
730 * names returned by smbc_readdir() are to be presented to the
731 * user.
733 * For backwards compatibility, this option defaults to False.
735 smbc_bool
736 smbc_getOptionUrlEncodeReaddirEntries(SMBCCTX *c);
739 * Set whether to url-encode readdir entries.
741 * There is a difference in the desired return strings from
742 * smbc_readdir() depending upon whether the filenames are to
743 * be displayed to the user, or whether they are to be
744 * appended to the path name passed to smbc_opendir() to call
745 * a further smbc_ function (e.g. open the file with
746 * smbc_open()). In the former case, the filename should be
747 * in "human readable" form. In the latter case, the smbc_
748 * functions expect a URL which must be url-encoded. Those
749 * functions decode the URL. If, for example, smbc_readdir()
750 * returned a file name of "abc%20def.txt", passing a path
751 * with this file name attached to smbc_open() would cause
752 * smbc_open to attempt to open the file "abc def.txt" since
753 * the %20 is decoded into a space.
755 * Set this option to True if the names returned by
756 * smbc_readdir() should be url-encoded such that they can be
757 * passed back to another smbc_ call. Set it to False if the
758 * names returned by smbc_readdir() are to be presented to the
759 * user.
761 * For backwards compatibility, this option defaults to False.
763 void
764 smbc_setOptionUrlEncodeReaddirEntries(SMBCCTX *c, smbc_bool b);
767 * Get whether to use the same connection for all shares on a server.
769 * Some Windows versions appear to have a limit to the number
770 * of concurrent SESSIONs and/or TREE CONNECTions. In
771 * one-shot programs (i.e. the program runs and then quickly
772 * ends, thereby shutting down all connections), it is
773 * probably reasonable to establish a new connection for each
774 * share. In long-running applications, the limitation can be
775 * avoided by using only a single connection to each server,
776 * and issuing a new TREE CONNECT when the share is accessed.
778 smbc_bool
779 smbc_getOptionOneSharePerServer(SMBCCTX *c);
782 * Set whether to use the same connection for all shares on a server.
784 * Some Windows versions appear to have a limit to the number
785 * of concurrent SESSIONs and/or TREE CONNECTions. In
786 * one-shot programs (i.e. the program runs and then quickly
787 * ends, thereby shutting down all connections), it is
788 * probably reasonable to establish a new connection for each
789 * share. In long-running applications, the limitation can be
790 * avoided by using only a single connection to each server,
791 * and issuing a new TREE CONNECT when the share is accessed.
793 void
794 smbc_setOptionOneSharePerServer(SMBCCTX *c, smbc_bool b);
796 /** Get whether to enable use of kerberos */
797 smbc_bool
798 smbc_getOptionUseKerberos(SMBCCTX *c);
800 /** Set whether to enable use of kerberos */
801 void
802 smbc_setOptionUseKerberos(SMBCCTX *c, smbc_bool b);
804 /** Get whether to fallback after kerberos */
805 smbc_bool
806 smbc_getOptionFallbackAfterKerberos(SMBCCTX *c);
808 /** Set whether to fallback after kerberos */
809 void
810 smbc_setOptionFallbackAfterKerberos(SMBCCTX *c, smbc_bool b);
812 /** Get whether to automatically select anonymous login */
813 smbc_bool
814 smbc_getOptionNoAutoAnonymousLogin(SMBCCTX *c);
816 /** Set whether to automatically select anonymous login */
817 void
818 smbc_setOptionNoAutoAnonymousLogin(SMBCCTX *c, smbc_bool b);
820 /** Get whether to enable use of the winbind ccache */
821 smbc_bool
822 smbc_getOptionUseCCache(SMBCCTX *c);
824 /** Set whether to enable use of the winbind ccache */
825 void
826 smbc_setOptionUseCCache(SMBCCTX *c, smbc_bool b);
828 /** Get indication that the password supplied is the NT hash */
829 smbc_bool
830 smbc_getOptionUseNTHash(SMBCCTX *c);
832 /** Set indication that the password supplied is the NT hash */
833 void
834 smbc_setOptionUseNTHash(SMBCCTX *c, smbc_bool b);
837 * @brief Set the 'client min protocol' and the 'client max protocol'.
839 * IMPORTANT: This overrides the values 'client min protocol' and 'client max
840 * protocol' set in the smb.conf file!
842 * @param[in] c The smbc context to use.
844 * @param[in] min_proto The minimal protocol to use or NULL for leaving it
845 * untouched.
847 * @param[in] max_proto The maximum protocol to use or NULL for leaving it
848 * untouched.
850 * @returns true for success, false otherwise
852 smbc_bool
853 smbc_setOptionProtocols(SMBCCTX *c, const char *min_proto, const char *max_proto);
855 /*************************************
856 * Getters and setters for FUNCTIONS *
857 *************************************/
859 /** Get the function for obtaining authentication data */
860 smbc_get_auth_data_fn smbc_getFunctionAuthData(SMBCCTX *c);
862 /** Set the function for obtaining authentication data */
863 void smbc_setFunctionAuthData(SMBCCTX *c, smbc_get_auth_data_fn fn);
865 /** Get the new-style authentication function which includes the context. */
866 smbc_get_auth_data_with_context_fn
867 smbc_getFunctionAuthDataWithContext(SMBCCTX *c);
869 /** Set the new-style authentication function which includes the context. */
870 void
871 smbc_setFunctionAuthDataWithContext(SMBCCTX *c,
872 smbc_get_auth_data_with_context_fn fn);
874 /** Get the function for checking if a server is still good */
875 smbc_check_server_fn smbc_getFunctionCheckServer(SMBCCTX *c);
877 /** Set the function for checking if a server is still good */
878 void smbc_setFunctionCheckServer(SMBCCTX *c, smbc_check_server_fn fn);
880 /** Get the function for removing a server if unused */
881 smbc_remove_unused_server_fn smbc_getFunctionRemoveUnusedServer(SMBCCTX *c);
883 /** Set the function for removing a server if unused */
884 void smbc_setFunctionRemoveUnusedServer(SMBCCTX *c,
885 smbc_remove_unused_server_fn fn);
887 /** Get the function for adding a cached server */
888 smbc_add_cached_srv_fn smbc_getFunctionAddCachedServer(SMBCCTX *c);
890 /** Set the function for adding a cached server */
891 void smbc_setFunctionAddCachedServer(SMBCCTX *c, smbc_add_cached_srv_fn fn);
893 /** Get the function for server cache lookup */
894 smbc_get_cached_srv_fn smbc_getFunctionGetCachedServer(SMBCCTX *c);
896 /** Set the function for server cache lookup */
897 void smbc_setFunctionGetCachedServer(SMBCCTX *c, smbc_get_cached_srv_fn fn);
899 /** Get the function for server cache removal */
900 smbc_remove_cached_srv_fn smbc_getFunctionRemoveCachedServer(SMBCCTX *c);
902 /** Set the function for server cache removal */
903 void smbc_setFunctionRemoveCachedServer(SMBCCTX *c,
904 smbc_remove_cached_srv_fn fn);
907 * Get the function for server cache purging. This function tries to
908 * remove all cached servers (e.g. on disconnect)
910 smbc_purge_cached_fn smbc_getFunctionPurgeCachedServers(SMBCCTX *c);
913 * Set the function for server cache purging. This function tries to
914 * remove all cached servers (e.g. on disconnect)
916 void smbc_setFunctionPurgeCachedServers(SMBCCTX *c,
917 smbc_purge_cached_fn fn);
919 /** Get the function to store private data of the server cache */
920 struct smbc_server_cache * smbc_getServerCacheData(SMBCCTX *c);
922 /** Set the function to store private data of the server cache */
923 void smbc_setServerCacheData(SMBCCTX *c, struct smbc_server_cache * cache);
927 /*****************************************************************
928 * Callable functions for files. *
929 * Each callable has a function signature typedef, a declaration *
930 * for the getter, and a declaration for the setter. *
931 *****************************************************************/
933 typedef SMBCFILE * (*smbc_open_fn)(SMBCCTX *c,
934 const char *fname,
935 int flags,
936 mode_t mode);
937 smbc_open_fn smbc_getFunctionOpen(SMBCCTX *c);
938 void smbc_setFunctionOpen(SMBCCTX *c, smbc_open_fn fn);
940 typedef SMBCFILE * (*smbc_creat_fn)(SMBCCTX *c,
941 const char *path,
942 mode_t mode);
943 smbc_creat_fn smbc_getFunctionCreat(SMBCCTX *c);
944 void smbc_setFunctionCreat(SMBCCTX *c, smbc_creat_fn);
946 typedef ssize_t (*smbc_read_fn)(SMBCCTX *c,
947 SMBCFILE *file,
948 void *buf,
949 size_t count);
950 smbc_read_fn smbc_getFunctionRead(SMBCCTX *c);
951 void smbc_setFunctionRead(SMBCCTX *c, smbc_read_fn fn);
953 typedef ssize_t (*smbc_write_fn)(SMBCCTX *c,
954 SMBCFILE *file,
955 const void *buf,
956 size_t count);
957 smbc_write_fn smbc_getFunctionWrite(SMBCCTX *c);
958 void smbc_setFunctionWrite(SMBCCTX *c, smbc_write_fn fn);
960 typedef off_t (*smbc_splice_fn)(SMBCCTX *c,
961 SMBCFILE *srcfile,
962 SMBCFILE *dstfile,
963 off_t count,
964 int (*splice_cb)(off_t n, void *priv),
965 void *priv);
966 smbc_splice_fn smbc_getFunctionSplice(SMBCCTX *c);
967 void smbc_setFunctionSplice(SMBCCTX *c, smbc_splice_fn fn);
969 typedef int (*smbc_unlink_fn)(SMBCCTX *c,
970 const char *fname);
971 smbc_unlink_fn smbc_getFunctionUnlink(SMBCCTX *c);
972 void smbc_setFunctionUnlink(SMBCCTX *c, smbc_unlink_fn fn);
974 typedef int (*smbc_rename_fn)(SMBCCTX *ocontext,
975 const char *oname,
976 SMBCCTX *ncontext,
977 const char *nname);
978 smbc_rename_fn smbc_getFunctionRename(SMBCCTX *c);
979 void smbc_setFunctionRename(SMBCCTX *c, smbc_rename_fn fn);
981 typedef off_t (*smbc_lseek_fn)(SMBCCTX *c,
982 SMBCFILE * file,
983 off_t offset,
984 int whence);
985 smbc_lseek_fn smbc_getFunctionLseek(SMBCCTX *c);
986 void smbc_setFunctionLseek(SMBCCTX *c, smbc_lseek_fn fn);
988 typedef int (*smbc_stat_fn)(SMBCCTX *c,
989 const char *fname,
990 struct stat *st);
991 smbc_stat_fn smbc_getFunctionStat(SMBCCTX *c);
992 void smbc_setFunctionStat(SMBCCTX *c, smbc_stat_fn fn);
994 typedef int (*smbc_fstat_fn)(SMBCCTX *c,
995 SMBCFILE *file,
996 struct stat *st);
997 smbc_fstat_fn smbc_getFunctionFstat(SMBCCTX *c);
998 void smbc_setFunctionFstat(SMBCCTX *c, smbc_fstat_fn fn);
1000 typedef int (*smbc_statvfs_fn)(SMBCCTX *c,
1001 char *path,
1002 struct statvfs *st);
1003 smbc_statvfs_fn smbc_getFunctionStatVFS(SMBCCTX *c);
1004 void smbc_setFunctionStatVFS(SMBCCTX *c, smbc_statvfs_fn fn);
1006 typedef int (*smbc_fstatvfs_fn)(SMBCCTX *c,
1007 SMBCFILE *file,
1008 struct statvfs *st);
1009 smbc_fstatvfs_fn smbc_getFunctionFstatVFS(SMBCCTX *c);
1010 void smbc_setFunctionFstatVFS(SMBCCTX *c, smbc_fstatvfs_fn fn);
1012 typedef int (*smbc_ftruncate_fn)(SMBCCTX *c,
1013 SMBCFILE *f,
1014 off_t size);
1015 smbc_ftruncate_fn smbc_getFunctionFtruncate(SMBCCTX *c);
1016 void smbc_setFunctionFtruncate(SMBCCTX *c, smbc_ftruncate_fn fn);
1018 typedef int (*smbc_close_fn)(SMBCCTX *c,
1019 SMBCFILE *file);
1020 smbc_close_fn smbc_getFunctionClose(SMBCCTX *c);
1021 void smbc_setFunctionClose(SMBCCTX *c, smbc_close_fn fn);
1025 /*****************************************************************
1026 * Callable functions for directories. *
1027 * Each callable has a function signature typedef, a declaration *
1028 * for the getter, and a declaration for the setter. *
1029 *****************************************************************/
1031 typedef SMBCFILE * (*smbc_opendir_fn)(SMBCCTX *c,
1032 const char *fname);
1033 smbc_opendir_fn smbc_getFunctionOpendir(SMBCCTX *c);
1034 void smbc_setFunctionOpendir(SMBCCTX *c, smbc_opendir_fn fn);
1036 typedef int (*smbc_closedir_fn)(SMBCCTX *c,
1037 SMBCFILE *dir);
1038 smbc_closedir_fn smbc_getFunctionClosedir(SMBCCTX *c);
1039 void smbc_setFunctionClosedir(SMBCCTX *c, smbc_closedir_fn fn);
1041 typedef struct smbc_dirent * (*smbc_readdir_fn)(SMBCCTX *c,
1042 SMBCFILE *dir);
1043 smbc_readdir_fn smbc_getFunctionReaddir(SMBCCTX *c);
1044 void smbc_setFunctionReaddir(SMBCCTX *c, smbc_readdir_fn fn);
1046 typedef const struct libsmb_file_info * (*smbc_readdirplus_fn)(SMBCCTX *c,
1047 SMBCFILE *dir);
1048 smbc_readdirplus_fn smbc_getFunctionReaddirPlus(SMBCCTX *c);
1049 void smbc_setFunctionReaddirPlus(SMBCCTX *c, smbc_readdirplus_fn fn);
1051 typedef const struct libsmb_file_info * (*smbc_readdirplus2_fn)(SMBCCTX *c,
1052 SMBCFILE *dir,
1053 struct stat *st);
1054 smbc_readdirplus2_fn smbc_getFunctionReaddirPlus2(SMBCCTX *c);
1055 void smbc_setFunctionReaddirPlus2(SMBCCTX *c, smbc_readdirplus2_fn fn);
1057 typedef int (*smbc_getdents_fn)(SMBCCTX *c,
1058 SMBCFILE *dir,
1059 struct smbc_dirent *dirp,
1060 int count);
1061 smbc_getdents_fn smbc_getFunctionGetdents(SMBCCTX *c);
1062 void smbc_setFunctionGetdents(SMBCCTX *c, smbc_getdents_fn fn);
1064 typedef int (*smbc_mkdir_fn)(SMBCCTX *c,
1065 const char *fname,
1066 mode_t mode);
1067 smbc_mkdir_fn smbc_getFunctionMkdir(SMBCCTX *c);
1068 void smbc_setFunctionMkdir(SMBCCTX *c, smbc_mkdir_fn fn);
1070 typedef int (*smbc_rmdir_fn)(SMBCCTX *c,
1071 const char *fname);
1072 smbc_rmdir_fn smbc_getFunctionRmdir(SMBCCTX *c);
1073 void smbc_setFunctionRmdir(SMBCCTX *c, smbc_rmdir_fn fn);
1075 typedef off_t (*smbc_telldir_fn)(SMBCCTX *c,
1076 SMBCFILE *dir);
1077 smbc_telldir_fn smbc_getFunctionTelldir(SMBCCTX *c);
1078 void smbc_setFunctionTelldir(SMBCCTX *c, smbc_telldir_fn fn);
1080 typedef int (*smbc_lseekdir_fn)(SMBCCTX *c,
1081 SMBCFILE *dir,
1082 off_t offset);
1083 smbc_lseekdir_fn smbc_getFunctionLseekdir(SMBCCTX *c);
1084 void smbc_setFunctionLseekdir(SMBCCTX *c, smbc_lseekdir_fn fn);
1086 typedef int (*smbc_fstatdir_fn)(SMBCCTX *c,
1087 SMBCFILE *dir,
1088 struct stat *st);
1089 smbc_fstatdir_fn smbc_getFunctionFstatdir(SMBCCTX *c);
1090 void smbc_setFunctionFstatdir(SMBCCTX *c, smbc_fstatdir_fn fn);
1092 #define SMBC_NOTIFY_ACTION_ADDED 1
1093 #define SMBC_NOTIFY_ACTION_REMOVED 2
1094 #define SMBC_NOTIFY_ACTION_MODIFIED 3
1095 #define SMBC_NOTIFY_ACTION_OLD_NAME 4
1096 #define SMBC_NOTIFY_ACTION_NEW_NAME 5
1097 #define SMBC_NOTIFY_ACTION_ADDED_STREAM 6
1098 #define SMBC_NOTIFY_ACTION_REMOVED_STREAM 7
1099 #define SMBC_NOTIFY_ACTION_MODIFIED_STREAM 8
1101 struct smbc_notify_callback_action {
1102 uint32_t action;
1103 const char *filename;
1106 typedef int (*smbc_notify_callback_fn)(
1107 const struct smbc_notify_callback_action *actions,
1108 size_t num_actions, void *private_data);
1110 typedef int (*smbc_notify_fn)(SMBCCTX *c, SMBCFILE *dir, smbc_bool recursive,
1111 uint32_t completion_filter,
1112 unsigned callback_timeout_ms,
1113 smbc_notify_callback_fn cb, void *private_data);
1114 smbc_notify_fn smbc_getFunctionNotify(SMBCCTX *c);
1115 void smbc_setFunctionNotify(SMBCCTX *c, smbc_notify_fn fn);
1118 /*****************************************************************
1119 * Callable functions applicable to both files and directories. *
1120 * Each callable has a function signature typedef, a declaration *
1121 * for the getter, and a declaration for the setter. *
1122 *****************************************************************/
1124 typedef int (*smbc_chmod_fn)(SMBCCTX *c,
1125 const char *fname,
1126 mode_t mode);
1127 smbc_chmod_fn smbc_getFunctionChmod(SMBCCTX *c);
1128 void smbc_setFunctionChmod(SMBCCTX *c, smbc_chmod_fn fn);
1130 typedef int (*smbc_utimes_fn)(SMBCCTX *c,
1131 const char *fname,
1132 struct timeval *tbuf);
1133 smbc_utimes_fn smbc_getFunctionUtimes(SMBCCTX *c);
1134 void smbc_setFunctionUtimes(SMBCCTX *c, smbc_utimes_fn fn);
1136 typedef int (*smbc_setxattr_fn)(SMBCCTX *context,
1137 const char *fname,
1138 const char *name,
1139 const void *value,
1140 size_t size,
1141 int flags);
1142 smbc_setxattr_fn smbc_getFunctionSetxattr(SMBCCTX *c);
1143 void smbc_setFunctionSetxattr(SMBCCTX *c, smbc_setxattr_fn fn);
1145 typedef int (*smbc_getxattr_fn)(SMBCCTX *context,
1146 const char *fname,
1147 const char *name,
1148 const void *value,
1149 size_t size);
1150 smbc_getxattr_fn smbc_getFunctionGetxattr(SMBCCTX *c);
1151 void smbc_setFunctionGetxattr(SMBCCTX *c, smbc_getxattr_fn fn);
1153 typedef int (*smbc_removexattr_fn)(SMBCCTX *context,
1154 const char *fname,
1155 const char *name);
1156 smbc_removexattr_fn smbc_getFunctionRemovexattr(SMBCCTX *c);
1157 void smbc_setFunctionRemovexattr(SMBCCTX *c, smbc_removexattr_fn fn);
1159 typedef int (*smbc_listxattr_fn)(SMBCCTX *context,
1160 const char *fname,
1161 char *list,
1162 size_t size);
1163 smbc_listxattr_fn smbc_getFunctionListxattr(SMBCCTX *c);
1164 void smbc_setFunctionListxattr(SMBCCTX *c, smbc_listxattr_fn fn);
1168 /*****************************************************************
1169 * Callable functions for printing. *
1170 * Each callable has a function signature typedef, a declaration *
1171 * for the getter, and a declaration for the setter. *
1172 *****************************************************************/
1174 typedef int (*smbc_print_file_fn)(SMBCCTX *c_file,
1175 const char *fname,
1176 SMBCCTX *c_print,
1177 const char *printq);
1178 smbc_print_file_fn smbc_getFunctionPrintFile(SMBCCTX *c);
1179 void smbc_setFunctionPrintFile(SMBCCTX *c, smbc_print_file_fn fn);
1181 typedef SMBCFILE * (*smbc_open_print_job_fn)(SMBCCTX *c,
1182 const char *fname);
1183 smbc_open_print_job_fn smbc_getFunctionOpenPrintJob(SMBCCTX *c);
1184 void smbc_setFunctionOpenPrintJob(SMBCCTX *c,
1185 smbc_open_print_job_fn fn);
1187 typedef int (*smbc_list_print_jobs_fn)(SMBCCTX *c,
1188 const char *fname,
1189 smbc_list_print_job_fn fn);
1190 smbc_list_print_jobs_fn smbc_getFunctionListPrintJobs(SMBCCTX *c);
1191 void smbc_setFunctionListPrintJobs(SMBCCTX *c,
1192 smbc_list_print_jobs_fn fn);
1194 typedef int (*smbc_unlink_print_job_fn)(SMBCCTX *c,
1195 const char *fname,
1196 int id);
1197 smbc_unlink_print_job_fn smbc_getFunctionUnlinkPrintJob(SMBCCTX *c);
1198 void smbc_setFunctionUnlinkPrintJob(SMBCCTX *c,
1199 smbc_unlink_print_job_fn fn);
1202 /**@ingroup misc
1203 * Create a new SBMCCTX (a context).
1205 * Must be called before the context is passed to smbc_context_init()
1207 * @return The given SMBCCTX pointer on success, NULL on error with errno set:
1208 * - ENOMEM Out of memory
1210 * @see smbc_free_context(), smbc_init_context()
1212 * @note Do not forget to smbc_init_context() the returned SMBCCTX pointer !
1214 SMBCCTX * smbc_new_context(void);
1216 /**@ingroup misc
1217 * Delete a SBMCCTX (a context) acquired from smbc_new_context().
1219 * The context will be deleted if possible.
1221 * @param context A pointer to a SMBCCTX obtained from smbc_new_context()
1223 * @param shutdown_ctx If 1, all connections and files will be closed even if they are busy.
1226 * @return Returns 0 on success. Returns 1 on failure with errno set:
1227 * - EBUSY Server connections are still used, Files are open or cache
1228 * could not be purged
1229 * - EBADF context == NULL
1231 * @see smbc_new_context()
1233 * @note It is advised to clean up all the contexts with shutdown_ctx set to 1
1234 * just before exit()'ing. When shutdown_ctx is 0, this function can be
1235 * use in periodical cleanup functions for example.
1237 int smbc_free_context(SMBCCTX * context, int shutdown_ctx);
1240 /**@ingroup misc
1242 * @deprecated. Use smbc_setOption*() functions instead.
1244 void
1245 smbc_option_set(SMBCCTX *context,
1246 char *option_name,
1247 ... /* option_value */);
1250 * @deprecated. Use smbc_getOption*() functions instead.
1252 void *
1253 smbc_option_get(SMBCCTX *context,
1254 char *option_name);
1256 /**@ingroup misc
1257 * Initialize a SBMCCTX (a context).
1259 * Must be called before using any SMBCCTX API function
1261 * @param context A pointer to a SMBCCTX obtained from smbc_new_context()
1263 * @return A pointer to the given SMBCCTX on success,
1264 * NULL on error with errno set:
1265 * - EBADF NULL context given
1266 * - ENOMEM Out of memory
1267 * - ENOENT The smb.conf file would not load
1269 * @see smbc_new_context()
1271 * @note my_context = smbc_init_context(smbc_new_context())
1272 * is perfectly safe, but it might leak memory on
1273 * smbc_context_init() failure. Avoid this.
1274 * You'll have to call smbc_free_context() yourself
1275 * on failure.
1278 SMBCCTX * smbc_init_context(SMBCCTX * context);
1280 /**@ingroup misc
1281 * Initialize the samba client library.
1283 * @deprecated use smbc_init_context()
1284 * @see smbc_init_context()
1286 DEPRECATED_SMBC_INTERFACE
1287 int smbc_init(smbc_get_auth_data_fn fn, int debug);
1289 /**@ingroup misc
1290 * Set or retrieve the compatibility library's context pointer
1292 * @param context New context to use, or NULL. If a new context is provided,
1293 * it must have allocated with smbc_new_context() and
1294 * initialized with smbc_init_context(), followed, optionally,
1295 * by some manual changes to some of the non-internal fields.
1297 * @return The old context.
1299 * @see smbc_new_context(), smbc_init_context(), smbc_init()
1301 * @note This function may be called prior to smbc_init() to force
1302 * use of the next context without any internal calls to
1303 * smbc_new_context() or smbc_init_context(). It may also
1304 * be called after smbc_init() has already called those two
1305 * functions, to replace the existing context with a new one.
1306 * Care should be taken, in this latter case, to ensure that
1307 * the server cache and any data allocated by the
1308 * authentication functions have been freed, if necessary.
1311 SMBCCTX * smbc_set_context(SMBCCTX * new_context);
1313 /**@ingroup file
1314 * Open a file on an SMB server.
1316 * @param furl The smb url of the file to be opened.
1318 * @param flags Is one of O_RDONLY, O_WRONLY or O_RDWR which
1319 * request opening the file read-only,write-only
1320 * or read/write. flags may also be bitwise-or'd with
1321 * one or more of the following:
1322 * O_CREAT - If the file does not exist it will be
1323 * created.
1324 * O_EXCL - When used with O_CREAT, if the file
1325 * already exists it is an error and the open will
1326 * fail.
1327 * O_TRUNC - If the file already exists it will be
1328 * truncated.
1329 * O_APPEND The file is opened in append mode
1331 * @param mode mode specifies the permissions to use if a new
1332 * file is created. It is modified by the
1333 * process's umask in the usual way: the permissions
1334 * of the created file are (mode & ~umask)
1336 * Not currently use, but there for future use.
1337 * We will map this to SYSTEM, HIDDEN, etc bits
1338 * that reverses the mapping that smbc_fstat does.
1340 * @return Valid file handle, < 0 on error with errno set:
1341 * - ENOMEM Out of memory
1342 * - EINVAL if an invalid parameter passed, like no
1343 * file, or smbc_init not called.
1344 * - EEXIST pathname already exists and O_CREAT and
1345 * O_EXCL were used.
1346 * - EISDIR pathname refers to a directory and
1347 * the access requested involved writing.
1348 * - EACCES The requested access to the file is not
1349 * allowed
1350 * - ENODEV The requested share does not exist
1351 * - ENOTDIR A file on the path is not a directory
1352 * - ENOENT A directory component in pathname does
1353 * not exist.
1355 * @see smbc_creat()
1357 * @note This call uses an underlying routine that may create
1358 * a new connection to the server specified in the URL.
1359 * If the credentials supplied in the URL, or via the
1360 * auth_fn in the smbc_init call, fail, this call will
1361 * try again with an empty username and password. This
1362 * often gets mapped to the guest account on some machines.
1365 int smbc_open(const char *furl, int flags, mode_t mode);
1367 /**@ingroup file
1368 * Create a file on an SMB server.
1370 * Same as calling smbc_open() with flags = O_CREAT|O_WRONLY|O_TRUNC
1372 * @param furl The smb url of the file to be created
1374 * @param mode mode specifies the permissions to use if a new
1375 * file is created. It is modified by the
1376 * process's umask in the usual way: the permissions
1377 * of the created file are (mode & ~umask)
1379 * NOTE, the above is not true. We are dealing with
1380 * an SMB server, which has no concept of a umask!
1382 * @return Valid file handle, < 0 on error with errno set:
1383 * - ENOMEM Out of memory
1384 * - EINVAL if an invalid parameter passed, like no
1385 * file, or smbc_init not called.
1386 * - EEXIST pathname already exists and O_CREAT and
1387 * O_EXCL were used.
1388 * - EISDIR pathname refers to a directory and
1389 * the access requested involved writing.
1390 * - EACCES The requested access to the file is not
1391 * allowed
1392 * - ENOENT A directory component in pathname does
1393 * not exist.
1394 * - ENODEV The requested share does not exist.
1395 * @see smbc_open()
1399 int smbc_creat(const char *furl, mode_t mode);
1401 /**@ingroup file
1402 * Read from a file using an opened file handle.
1404 * @param fd Open file handle from smbc_open() or smbc_creat()
1406 * @param buf Pointer to buffer to receive read data
1408 * @param bufsize Size of buf in bytes
1410 * @return Number of bytes read;
1411 * 0 upon EOF;
1412 * < 0 on error, with errno set:
1413 * - EISDIR fd refers to a directory
1414 * - EBADF fd is not a valid file descriptor or
1415 * is not open for reading.
1416 * - EINVAL fd is attached to an object which is
1417 * unsuitable for reading, or no buffer passed or
1418 * smbc_init not called.
1420 * @see smbc_open(), smbc_write()
1423 ssize_t smbc_read(int fd, void *buf, size_t bufsize);
1426 /**@ingroup file
1427 * Write to a file using an opened file handle.
1429 * @param fd Open file handle from smbc_open() or smbc_creat()
1431 * @param buf Pointer to buffer to receive read data
1433 * @param bufsize Size of buf in bytes
1435 * @return Number of bytes written, < 0 on error with errno set:
1436 * - EISDIR fd refers to a directory.
1437 * - EBADF fd is not a valid file descriptor or
1438 * is not open for reading.
1439 * - EINVAL fd is attached to an object which is
1440 * unsuitable for reading, or no buffer passed or
1441 * smbc_init not called.
1443 * @see smbc_open(), smbc_read()
1446 ssize_t smbc_write(int fd, const void *buf, size_t bufsize);
1449 /**@ingroup file
1450 * Seek to a specific location in a file.
1452 * @param fd Open file handle from smbc_open() or smbc_creat()
1454 * @param offset Offset in bytes from whence
1456 * @param whence A location in the file:
1457 * - SEEK_SET The offset is set to offset bytes from
1458 * the beginning of the file
1459 * - SEEK_CUR The offset is set to current location
1460 * plus offset bytes.
1461 * - SEEK_END The offset is set to the size of the
1462 * file plus offset bytes.
1464 * @return Upon successful completion, lseek returns the
1465 * resulting offset location as measured in bytes
1466 * from the beginning of the file. Otherwise, a value
1467 * of (off_t)-1 is returned and errno is set to
1468 * indicate the error:
1469 * - EBADF Fildes is not an open file descriptor.
1470 * - EINVAL Whence is not a proper value or smbc_init
1471 * not called.
1473 * @todo Are all the whence values really supported?
1475 * @todo Are errno values complete and correct?
1477 off_t smbc_lseek(int fd, off_t offset, int whence);
1480 /**@ingroup file
1481 * Close an open file handle.
1483 * @param fd The file handle to close
1485 * @return 0 on success, < 0 on error with errno set:
1486 * - EBADF fd isn't a valid open file descriptor
1487 * - EINVAL smbc_init() failed or has not been called
1489 * @see smbc_open(), smbc_creat()
1491 int smbc_close(int fd);
1494 /**@ingroup directory
1495 * Unlink (delete) a file or directory.
1497 * @param furl The smb url of the file to delete
1499 * @return 0 on success, < 0 on error with errno set:
1500 * - EACCES or EPERM Write access to the directory
1501 * containing pathname is not allowed or one
1502 * of the directories in pathname did not allow
1503 * search (execute) permission
1504 * - ENOENT A directory component in pathname does
1505 * not exist
1506 * - EINVAL NULL was passed in the file param or
1507 * smbc_init not called.
1508 * - EACCES You do not have access to the file
1509 * - ENOMEM Insufficient kernel memory was available
1511 * @see smbc_rmdir()s
1513 * @todo Are errno values complete and correct?
1515 int smbc_unlink(const char *furl);
1518 /**@ingroup directory
1519 * Rename or move a file or directory.
1521 * @param ourl The original smb url (source url) of file or
1522 * directory to be moved
1524 * @param nurl The new smb url (destination url) of the file
1525 * or directory after the move. Currently nurl must
1526 * be on the same share as ourl.
1528 * @return 0 on success, < 0 on error with errno set:
1529 * - EISDIR nurl is an existing directory, but ourl is
1530 * not a directory.
1531 * - EEXIST nurl is a non-empty directory,
1532 * i.e., contains entries other than "." and ".."
1533 * - EINVAL The new url contained a path prefix
1534 * of the old, or, more generally, an attempt was
1535 * made to make a directory a subdirectory of itself
1536 * or smbc_init not called.
1537 * - ENOTDIR A component used as a directory in ourl
1538 * or nurl path is not, in fact, a directory. Or,
1539 * ourl is a directory, and newpath exists but is not
1540 * a directory.
1541 * - EACCES or EPERM Write access to the directory
1542 * containing ourl or nurl is not allowed for the
1543 * process's effective uid, or one of the
1544 * directories in ourl or nurl did not allow search
1545 * (execute) permission, or ourl was a directory
1546 * and did not allow write permission.
1547 * - ENOENT A directory component in ourl or nurl
1548 * does not exist.
1549 * - EXDEV Rename across shares not supported.
1550 * - ENOMEM Insufficient kernel memory was available.
1551 * - EEXIST The target file, nurl, already exists.
1554 * @todo Are we going to support copying when urls are not on the same
1555 * share? I say no... NOTE. I agree for the moment.
1558 int smbc_rename(const char *ourl, const char *nurl);
1561 /**@ingroup directory
1562 * Open a directory used to obtain directory entries.
1564 * @param durl The smb url of the directory to open
1566 * @return Valid directory handle. < 0 on error with errno set:
1567 * - EACCES Permission denied.
1568 * - EINVAL A NULL file/URL was passed, or the URL would
1569 * not parse, or was of incorrect form or smbc_init not
1570 * called.
1571 * - ENOENT durl does not exist, or name is an
1572 * - ENOMEM Insufficient memory to complete the
1573 * operation.
1574 * - ENOTDIR name is not a directory.
1575 * - EPERM the workgroup could not be found.
1576 * - ENODEV the workgroup or server could not be found.
1578 * @see smbc_getdents(), smbc_readdir(), smbc_closedir()
1581 int smbc_opendir(const char *durl);
1584 /**@ingroup directory
1585 * Close a directory handle opened by smbc_opendir().
1587 * @param dh Directory handle to close
1589 * @return 0 on success, < 0 on error with errno set:
1590 * - EBADF dh is an invalid directory handle
1592 * @see smbc_opendir()
1594 int smbc_closedir(int dh);
1597 /**@ingroup directory
1598 * Get multiple directory entries.
1600 * smbc_getdents() reads as many dirent structures from the an open
1601 * directory handle into a specified memory area as will fit.
1603 * @param dh Valid directory as returned by smbc_opendir()
1605 * @param dirp pointer to buffer that will receive the directory
1606 * entries.
1608 * @param count The size of the dirp buffer in bytes
1610 * @returns If any dirents returned, return will indicate the
1611 * total size. If there were no more dirents available,
1612 * 0 is returned. < 0 indicates an error.
1613 * - EBADF Invalid directory handle
1614 * - EINVAL Result buffer is too small or smbc_init
1615 * not called.
1616 * - ENOENT No such directory.
1617 * @see , smbc_dirent, smbc_readdir(), smbc_open()
1619 * @todo Are errno values complete and correct?
1621 * @todo Add example code so people know how to parse buffers.
1623 int smbc_getdents(unsigned int dh, struct smbc_dirent *dirp, int count);
1626 /**@ingroup directory
1627 * Get a single directory entry.
1629 * @param dh Valid directory as returned by smbc_opendir()
1631 * @return A pointer to a smbc_dirent structure, or NULL if an
1632 * error occurs or end-of-directory is reached:
1633 * - EBADF Invalid directory handle
1634 * - EINVAL smbc_init() failed or has not been called
1636 * @see smbc_dirent, smbc_getdents(), smbc_open()
1638 struct smbc_dirent* smbc_readdir(unsigned int dh);
1640 /**@ingroup directory
1641 * Works similar as smbc_readdir() but returns more information about file.
1643 * @param dh Valid directory as returned by smbc_opendir()
1645 * @return A const pointer to a libsmb_file_info structure,
1646 * or NULL if an error occurs or end-of-directory is reached:
1647 * - EBADF Invalid directory handle
1648 * - EINVAL smbc_init() failed or has not been called
1650 * @see smbc_open(), smbc_readdir()
1652 const struct libsmb_file_info *smbc_readdirplus(unsigned int dh);
1654 /**@ingroup directory
1655 * Works similar as smbc_readdirplus() as well as fills up stat structure if
1656 * provided.
1658 * @param dh Valid directory as returned by smbc_opendir()
1660 * @param stat Pointer to stat structure which will receive the
1661 * information. If this pointer is null the call
1662 * is identical to smbc_readdirplus.
1664 * @return A const pointer to a libsmb_file_info structure,
1665 * or NULL if an error occurs or end-of-directory is reached:
1666 * - EBADF Invalid directory handle
1667 * - EINVAL smbc_init() failed or has not been called
1669 * @see smbc_open(), smbc_readdir(), smbc_readdirplus2()
1671 const struct libsmb_file_info *smbc_readdirplus2(unsigned int dh,
1672 struct stat *st);
1674 /**@ingroup directory
1675 * Get the current directory offset.
1677 * smbc_telldir() may be used in conjunction with smbc_readdir() and
1678 * smbc_lseekdir().
1680 * @param dh Valid directory as returned by smbc_opendir()
1682 * @return The current location in the directory stream or -1
1683 * if an error occur. The current location is not
1684 * an offset. Because of the implementation, it is a
1685 * handle that allows the library to find the entry
1686 * later.
1687 * - EBADF dh is not a valid directory handle
1688 * - EINVAL smbc_init() failed or has not been called
1689 * - ENOTDIR if dh is not a directory
1691 * @see smbc_readdir()
1694 off_t smbc_telldir(int dh);
1697 /**@ingroup directory
1698 * lseek on directories.
1700 * smbc_lseekdir() may be used in conjunction with smbc_readdir() and
1701 * smbc_telldir(). (rewind by smbc_lseekdir(fd, NULL))
1703 * @param fd Valid directory as returned by smbc_opendir()
1705 * @param offset The offset (as returned by smbc_telldir). Can be
1706 * NULL, in which case we will rewind
1708 * @return 0 on success, -1 on failure
1709 * - EBADF dh is not a valid directory handle
1710 * - ENOTDIR if dh is not a directory
1711 * - EINVAL offset did not refer to a valid dirent or
1712 * smbc_init not called.
1714 * @see smbc_telldir()
1717 * @todo In what does the return and errno values mean?
1719 int smbc_lseekdir(int fd, off_t offset);
1721 /**@ingroup directory
1722 * Create a directory.
1724 * @param durl The url of the directory to create
1726 * @param mode Specifies the permissions to use. It is modified
1727 * by the process's umask in the usual way: the
1728 * permissions of the created file are (mode & ~umask).
1730 * @return 0 on success, < 0 on error with errno set:
1731 * - EEXIST directory url already exists
1732 * - EACCES The parent directory does not allow write
1733 * permission to the process, or one of the directories
1734 * - ENOENT A directory component in pathname does not
1735 * exist.
1736 * - EINVAL NULL durl passed or smbc_init not called.
1737 * - ENOMEM Insufficient memory was available.
1739 * @see smbc_rmdir()
1742 int smbc_mkdir(const char *durl, mode_t mode);
1745 /**@ingroup directory
1746 * Remove a directory.
1748 * @param durl The smb url of the directory to remove
1750 * @return 0 on success, < 0 on error with errno set:
1751 * - EACCES or EPERM Write access to the directory
1752 * containing pathname was not allowed.
1753 * - EINVAL durl is NULL or smbc_init not called.
1754 * - ENOENT A directory component in pathname does not
1755 * exist.
1756 * - ENOTEMPTY directory contains entries.
1757 * - ENOMEM Insufficient kernel memory was available.
1759 * @see smbc_mkdir(), smbc_unlink()
1761 * @todo Are errno values complete and correct?
1763 int smbc_rmdir(const char *durl);
1765 /**@ingroup directory
1766 * Request directory notifications
1768 * @param dh Valid directory as returned by smbc_opendir()
1770 * @param recursive Are changes in subdirectories wanted?
1772 * @param completion_filter Bitwise-or of the SMBC_NOTIFY_CHANGE_*
1773 * events that are interesting
1775 * @param callback_timeout_ms If set to non-zero, interval in milliseconds
1776 * that "cb" will be called with 0 actions.
1777 * This gives "cb" the chance to cancel the
1778 * smbc_notify call.
1780 * @param cb Callback functions taking events. If "cb"
1781 * returns nonzero, smbc_notify will return.
1783 * @param private_data Pointer given to "cb"
1785 * @return 0 on success, -1 on error with errno set
1787 * @see smbc_opendir(), smbc_closedir()
1790 #define SMBC_NOTIFY_CHANGE_FILE_NAME 0x001
1791 #define SMBC_NOTIFY_CHANGE_DIR_NAME 0x002
1792 #define SMBC_NOTIFY_CHANGE_ATTRIBUTES 0x004
1793 #define SMBC_NOTIFY_CHANGE_SIZE 0x008
1794 #define SMBC_NOTIFY_CHANGE_LAST_WRITE 0x010
1795 #define SMBC_NOTIFY_CHANGE_LAST_ACCESS 0x020
1796 #define SMBC_NOTIFY_CHANGE_CREATION 0x040
1797 #define SMBC_NOTIFY_CHANGE_EA 0x080
1798 #define SMBC_NOTIFY_CHANGE_SECURITY 0x100
1799 #define SMBC_NOTIFY_CHANGE_STREAM_NAME 0x200
1800 #define SMBC_NOTIFY_CHANGE_STREAM_SIZE 0x400
1801 #define SMBC_NOTIFY_CHANGE_STREAM_WRITE 0x800
1803 int smbc_notify(int dh, smbc_bool recursive, uint32_t completion_filter,
1804 unsigned callback_timeout_ms,
1805 smbc_notify_callback_fn cb, void *private_data);
1807 /**@ingroup attribute
1808 * Get information about a file or directory.
1810 * @param url The smb url to get information for
1812 * @param st pointer to a buffer that will be filled with
1813 * standard Unix struct stat information.
1815 * @return 0 on success, < 0 on error with errno set:
1816 * - ENOENT A component of the path file_name does not
1817 * exist.
1818 * - EINVAL a NULL url was passed or smbc_init not called.
1819 * - EACCES Permission denied.
1820 * - ENOMEM Out of memory
1821 * - ENOTDIR The target dir, url, is not a directory.
1823 * @see Unix stat()
1826 int smbc_stat(const char *url, struct stat *st);
1829 /**@ingroup attribute
1830 * Get file information via an file descriptor.
1832 * @param fd Open file handle from smbc_open() or smbc_creat()
1834 * @param st pointer to a buffer that will be filled with
1835 * standard Unix struct stat information.
1837 * @return 0 on success, < 0 on error with errno set:
1838 * - EBADF filedes is bad.
1839 * - EACCES Permission denied.
1840 * - EBADF fd is not a valid file descriptor
1841 * - EINVAL Problems occurred in the underlying routines
1842 * or smbc_init not called.
1843 * - ENOMEM Out of memory
1845 * @see smbc_stat(), Unix stat()
1848 int smbc_fstat(int fd, struct stat *st);
1851 /**@ingroup attribute
1852 * Get file system information for a specified path.
1854 * @param url The smb url to get information for
1856 * @param st pointer to a buffer that will be filled with
1857 * standard Unix struct statvfs information.
1859 * @return 0 on success, < 0 on error with errno set:
1860 * - EBADF filedes is bad.
1861 * - EACCES Permission denied.
1862 * - EBADF fd is not a valid file descriptor
1863 * - EINVAL Problems occurred in the underlying routines
1864 * or smbc_init not called.
1865 * - ENOMEM Out of memory
1867 * @see Unix fstatvfs()
1871 smbc_statvfs(char *url,
1872 struct statvfs *st);
1874 /**@ingroup attribute
1875 * Get file system information via an file descriptor.
1877 * @param fd Open file handle from smbc_open(), smbc_creat(),
1878 * or smbc_opendir()
1880 * @param st pointer to a buffer that will be filled with
1881 * standard Unix struct statvfs information.
1883 * @return 0 on success, < 0 on error with errno set:
1884 * - EBADF filedes is bad.
1885 * - EACCES Permission denied.
1886 * - EBADF fd is not a valid file descriptor
1887 * - EINVAL Problems occurred in the underlying routines
1888 * or smbc_init not called.
1889 * - ENOMEM Out of memory
1891 * @see Unix fstatvfs()
1895 smbc_fstatvfs(int fd,
1896 struct statvfs *st);
1899 /**@ingroup attribute
1900 * Truncate a file given a file descriptor
1902 * @param fd Open file handle from smbc_open() or smbc_creat()
1904 * @param size size to truncate the file to
1906 * @return 0 on success, < 0 on error with errno set:
1907 * - EBADF filedes is bad.
1908 * - EACCES Permission denied.
1909 * - EBADF fd is not a valid file descriptor
1910 * - EINVAL Problems occurred in the underlying routines
1911 * or smbc_init not called.
1912 * - ENOMEM Out of memory
1914 * @see , Unix ftruncate()
1917 int smbc_ftruncate(int fd, off_t size);
1920 /**@ingroup attribute
1921 * Change the permissions of a file.
1923 * @param url The smb url of the file or directory to change
1924 * permissions of
1926 * @param mode The permissions to set:
1927 * - Put good explanation of permissions here!
1929 * @return 0 on success, < 0 on error with errno set:
1930 * - EPERM The effective UID does not match the owner
1931 * of the file, and is not zero
1932 * - ENOENT The file does not exist.
1933 * - ENOMEM Insufficient was available.
1934 * - ENOENT file or directory does not exist
1936 * @todo Actually implement this function?
1938 * @todo Are errno values complete and correct?
1940 int smbc_chmod(const char *url, mode_t mode);
1943 * @ingroup attribute
1944 * Change the last modification time on a file
1946 * @param url The smb url of the file or directory to change
1947 * the modification time of
1949 * @param tbuf An array of two timeval structures which contains,
1950 * respectively, the desired access and modification times.
1951 * NOTE: Only the tv_sec field off each timeval structure is
1952 * used. The tv_usec (microseconds) portion is ignored.
1954 * @return 0 on success, < 0 on error with errno set:
1955 * - EINVAL The client library is not properly initialized
1956 * - EPERM Permission was denied.
1959 int smbc_utimes(const char *url, struct timeval *tbuf);
1961 #ifdef HAVE_UTIME_H
1963 * @ingroup attribute
1964 * Change the last modification time on a file
1966 * @param url The smb url of the file or directory to change
1967 * the modification time of
1969 * @param utbuf A pointer to a utimebuf structure which contains the
1970 * desired access and modification times.
1972 * @return 0 on success, < 0 on error with errno set:
1973 * - EINVAL The client library is not properly initialized
1974 * - ENOMEM No memory was available for internal needs
1975 * - EPERM Permission was denied.
1978 int smbc_utime(const char *fname, struct utimbuf *utbuf);
1979 #endif
1981 /**@ingroup attribute
1982 * Set extended attributes for a file. This is used for modifying a file's
1983 * security descriptor (i.e. owner, group, and access control list)
1985 * @param url The smb url of the file or directory to set extended
1986 * attributes for.
1988 * @param name The name of an attribute to be changed. Names are of
1989 * one of the following forms:
1991 * system.nt_sec_desc.<attribute name>
1992 * system.nt_sec_desc.*
1993 * system.nt_sec_desc.*+
1995 * where <attribute name> is one of:
1997 * revision
1998 * owner
1999 * owner+
2000 * group
2001 * group+
2002 * acl:<name or sid>
2003 * acl+:<name or sid>
2005 * In the forms "system.nt_sec_desc.*" and
2006 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2007 * literal, i.e. the string is provided exactly as shown, and
2008 * the value parameter should contain a complete security
2009 * descriptor with name:value pairs separated by tabs,
2010 * commas, or newlines (not spaces!).
2012 * The plus sign ('+') indicates that SIDs should be mapped
2013 * to names. Without the plus sign, SIDs are not mapped;
2014 * rather they are simply converted to a string format.
2016 * @param value The value to be assigned to the specified attribute name.
2017 * This buffer should contain only the attribute value if the
2018 * name was of the "system.nt_sec_desc.<attribute_name>"
2019 * form. If the name was of the "system.nt_sec_desc.*" form
2020 * then a complete security descriptor, with name:value pairs
2021 * separated by tabs, commas, or newlines (not spaces!),
2022 * should be provided in this value buffer. A complete
2023 * security descriptor will contain one or more entries
2024 * selected from the following:
2026 * REVISION:<revision number>
2027 * OWNER:<sid or name>
2028 * GROUP:<sid or name>
2029 * ACL:<sid or name>:<type>/<flags>/<mask>
2031 * The revision of the ACL specifies the internal Windows NT
2032 * ACL revision for the security descriptor. If not specified
2033 * it defaults to 1. Using values other than 1 may cause
2034 * strange behaviour.
2036 * The owner and group specify the owner and group sids for
2037 * the object. If the attribute name (either '*+' with a
2038 * complete security descriptor, or individual 'owner+' or
2039 * 'group+' attribute names) ended with a plus sign, the
2040 * specified name is resolved to a SID value, using the
2041 * server on which the file or directory resides. Otherwise,
2042 * the value should be provided in SID-printable format as
2043 * S-1-x-y-z, and is used directly. The <sid or name>
2044 * associated with the ACL: attribute should be provided
2045 * similarly.
2047 * @param size The number of the bytes of data in the value buffer
2049 * @param flags A bit-wise OR of zero or more of the following:
2050 * SMBC_XATTR_FLAG_CREATE -
2051 * fail if the named attribute already exists
2052 * SMBC_XATTR_FLAG_REPLACE -
2053 * fail if the attribute does not already exist
2055 * If neither flag is specified, the specified attributes
2056 * will be added or replace existing attributes of the same
2057 * name, as necessary.
2059 * @return 0 on success, < 0 on error with errno set:
2060 * - EINVAL The client library is not properly initialized
2061 * or one of the parameters is not of a correct
2062 * form
2063 * - ENOMEM No memory was available for internal needs
2064 * - EEXIST If the attribute already exists and the flag
2065 * SMBC_XATTR_FLAG_CREAT was specified
2066 * - ENOATTR If the attribute does not exist and the flag
2067 * SMBC_XATTR_FLAG_REPLACE was specified
2068 * - EPERM Permission was denied.
2069 * - ENOTSUP The referenced file system does not support
2070 * extended attributes
2072 * @note Attribute names are compared in a case-insensitive
2073 * fashion. All of the following are equivalent, although
2074 * the all-lower-case name is the preferred format:
2075 * system.nt_sec_desc.owner
2076 * SYSTEM.NT_SEC_DESC.OWNER
2077 * sYsTeM.nt_sEc_desc.owNER
2080 int smbc_setxattr(const char *url,
2081 const char *name,
2082 const void *value,
2083 size_t size,
2084 int flags);
2087 /**@ingroup attribute
2088 * Set extended attributes for a file. This is used for modifying a file's
2089 * security descriptor (i.e. owner, group, and access control list). The
2090 * POSIX function which this maps to would act on a symbolic link rather than
2091 * acting on what the symbolic link points to, but with no symbolic links in
2092 * SMB file systems, this function is functionally identical to
2093 * smbc_setxattr().
2095 * @param url The smb url of the file or directory to set extended
2096 * attributes for.
2098 * @param name The name of an attribute to be changed. Names are of
2099 * one of the following forms:
2101 * system.nt_sec_desc.<attribute name>
2102 * system.nt_sec_desc.*
2103 * system.nt_sec_desc.*+
2105 * where <attribute name> is one of:
2107 * revision
2108 * owner
2109 * owner+
2110 * group
2111 * group+
2112 * acl:<name or sid>
2113 * acl+:<name or sid>
2115 * In the forms "system.nt_sec_desc.*" and
2116 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2117 * literal, i.e. the string is provided exactly as shown, and
2118 * the value parameter should contain a complete security
2119 * descriptor with name:value pairs separated by tabs,
2120 * commas, or newlines (not spaces!).
2122 * The plus sign ('+') indicates that SIDs should be mapped
2123 * to names. Without the plus sign, SIDs are not mapped;
2124 * rather they are simply converted to a string format.
2126 * @param value The value to be assigned to the specified attribute name.
2127 * This buffer should contain only the attribute value if the
2128 * name was of the "system.nt_sec_desc.<attribute_name>"
2129 * form. If the name was of the "system.nt_sec_desc.*" form
2130 * then a complete security descriptor, with name:value pairs
2131 * separated by tabs, commas, or newlines (not spaces!),
2132 * should be provided in this value buffer. A complete
2133 * security descriptor will contain one or more entries
2134 * selected from the following:
2136 * REVISION:<revision number>
2137 * OWNER:<sid or name>
2138 * GROUP:<sid or name>
2139 * ACL:<sid or name>:<type>/<flags>/<mask>
2141 * The revision of the ACL specifies the internal Windows NT
2142 * ACL revision for the security descriptor. If not specified
2143 * it defaults to 1. Using values other than 1 may cause
2144 * strange behaviour.
2146 * The owner and group specify the owner and group sids for
2147 * the object. If the attribute name (either '*+' with a
2148 * complete security descriptor, or individual 'owner+' or
2149 * 'group+' attribute names) ended with a plus sign, the
2150 * specified name is resolved to a SID value, using the
2151 * server on which the file or directory resides. Otherwise,
2152 * the value should be provided in SID-printable format as
2153 * S-1-x-y-z, and is used directly. The <sid or name>
2154 * associated with the ACL: attribute should be provided
2155 * similarly.
2157 * @param size The number of the bytes of data in the value buffer
2159 * @param flags A bit-wise OR of zero or more of the following:
2160 * SMBC_XATTR_FLAG_CREATE -
2161 * fail if the named attribute already exists
2162 * SMBC_XATTR_FLAG_REPLACE -
2163 * fail if the attribute does not already exist
2165 * If neither flag is specified, the specified attributes
2166 * will be added or replace existing attributes of the same
2167 * name, as necessary.
2169 * @return 0 on success, < 0 on error with errno set:
2170 * - EINVAL The client library is not properly initialized
2171 * or one of the parameters is not of a correct
2172 * form
2173 * - ENOMEM No memory was available for internal needs
2174 * - EEXIST If the attribute already exists and the flag
2175 * SMBC_XATTR_FLAG_CREAT was specified
2176 * - ENOATTR If the attribute does not exist and the flag
2177 * SMBC_XATTR_FLAG_REPLACE was specified
2178 * - EPERM Permission was denied.
2179 * - ENOTSUP The referenced file system does not support
2180 * extended attributes
2182 * @note Attribute names are compared in a case-insensitive
2183 * fashion. All of the following are equivalent, although
2184 * the all-lower-case name is the preferred format:
2185 * system.nt_sec_desc.owner
2186 * SYSTEM.NT_SEC_DESC.OWNER
2187 * sYsTeM.nt_sEc_desc.owNER
2190 int smbc_lsetxattr(const char *url,
2191 const char *name,
2192 const void *value,
2193 size_t size,
2194 int flags);
2197 /**@ingroup attribute
2198 * Set extended attributes for a file. This is used for modifying a file's
2199 * security descriptor (i.e. owner, group, and access control list)
2201 * @param fd A file descriptor associated with an open file (as
2202 * previously returned by smbc_open(), to get extended
2203 * attributes for.
2205 * @param name The name of an attribute to be changed. Names are of
2206 * one of the following forms:
2208 * system.nt_sec_desc.<attribute name>
2209 * system.nt_sec_desc.*
2210 * system.nt_sec_desc.*+
2212 * where <attribute name> is one of:
2214 * revision
2215 * owner
2216 * owner+
2217 * group
2218 * group+
2219 * acl:<name or sid>
2220 * acl+:<name or sid>
2222 * In the forms "system.nt_sec_desc.*" and
2223 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2224 * literal, i.e. the string is provided exactly as shown, and
2225 * the value parameter should contain a complete security
2226 * descriptor with name:value pairs separated by tabs,
2227 * commas, or newlines (not spaces!).
2229 * The plus sign ('+') indicates that SIDs should be mapped
2230 * to names. Without the plus sign, SIDs are not mapped;
2231 * rather they are simply converted to a string format.
2233 * @param value The value to be assigned to the specified attribute name.
2234 * This buffer should contain only the attribute value if the
2235 * name was of the "system.nt_sec_desc.<attribute_name>"
2236 * form. If the name was of the "system.nt_sec_desc.*" form
2237 * then a complete security descriptor, with name:value pairs
2238 * separated by tabs, commas, or newlines (not spaces!),
2239 * should be provided in this value buffer. A complete
2240 * security descriptor will contain one or more entries
2241 * selected from the following:
2243 * REVISION:<revision number>
2244 * OWNER:<sid or name>
2245 * GROUP:<sid or name>
2246 * ACL:<sid or name>:<type>/<flags>/<mask>
2248 * The revision of the ACL specifies the internal Windows NT
2249 * ACL revision for the security descriptor. If not specified
2250 * it defaults to 1. Using values other than 1 may cause
2251 * strange behaviour.
2253 * The owner and group specify the owner and group sids for
2254 * the object. If the attribute name (either '*+' with a
2255 * complete security descriptor, or individual 'owner+' or
2256 * 'group+' attribute names) ended with a plus sign, the
2257 * specified name is resolved to a SID value, using the
2258 * server on which the file or directory resides. Otherwise,
2259 * the value should be provided in SID-printable format as
2260 * S-1-x-y-z, and is used directly. The <sid or name>
2261 * associated with the ACL: attribute should be provided
2262 * similarly.
2264 * @param size The number of the bytes of data in the value buffer
2266 * @param flags A bit-wise OR of zero or more of the following:
2267 * SMBC_XATTR_FLAG_CREATE -
2268 * fail if the named attribute already exists
2269 * SMBC_XATTR_FLAG_REPLACE -
2270 * fail if the attribute does not already exist
2272 * If neither flag is specified, the specified attributes
2273 * will be added or replace existing attributes of the same
2274 * name, as necessary.
2276 * @return 0 on success, < 0 on error with errno set:
2277 * - EINVAL The client library is not properly initialized
2278 * or one of the parameters is not of a correct
2279 * form
2280 * - ENOMEM No memory was available for internal needs
2281 * - EEXIST If the attribute already exists and the flag
2282 * SMBC_XATTR_FLAG_CREAT was specified
2283 * - ENOATTR If the attribute does not exist and the flag
2284 * SMBC_XATTR_FLAG_REPLACE was specified
2285 * - EPERM Permission was denied.
2286 * - ENOTSUP The referenced file system does not support
2287 * extended attributes
2289 * @note Attribute names are compared in a case-insensitive
2290 * fashion. All of the following are equivalent, although
2291 * the all-lower-case name is the preferred format:
2292 * system.nt_sec_desc.owner
2293 * SYSTEM.NT_SEC_DESC.OWNER
2294 * sYsTeM.nt_sEc_desc.owNER
2297 int smbc_fsetxattr(int fd,
2298 const char *name,
2299 const void *value,
2300 size_t size,
2301 int flags);
2304 /**@ingroup attribute
2305 * Get extended attributes for a file.
2307 * @param url The smb url of the file or directory to get extended
2308 * attributes for.
2310 * @param name The name of an attribute to be retrieved. Names are of
2311 * one of the following forms:
2313 * system.nt_sec_desc.<attribute name>
2314 * system.nt_sec_desc.*
2315 * system.nt_sec_desc.*+
2317 * where <attribute name> is one of:
2319 * revision
2320 * owner
2321 * owner+
2322 * group
2323 * group+
2324 * acl:<name or sid>
2325 * acl+:<name or sid>
2327 * In the forms "system.nt_sec_desc.*" and
2328 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2329 * literal, i.e. the string is provided exactly as shown, and
2330 * the value parameter will return a complete security
2331 * descriptor with name:value pairs separated by tabs,
2332 * commas, or newlines (not spaces!).
2334 * The plus sign ('+') indicates that SIDs should be mapped
2335 * to names. Without the plus sign, SIDs are not mapped;
2336 * rather they are simply converted to a string format.
2338 * @param value A pointer to a buffer in which the value of the specified
2339 * attribute will be placed (unless size is zero).
2341 * @param size The size of the buffer pointed to by value. This parameter
2342 * may also be zero, in which case the size of the buffer
2343 * required to hold the attribute value will be returned,
2344 * but nothing will be placed into the value buffer.
2346 * @return 0 on success, < 0 on error with errno set:
2347 * - EINVAL The client library is not properly initialized
2348 * or one of the parameters is not of a correct
2349 * form
2350 * - ENOMEM No memory was available for internal needs
2351 * - EEXIST If the attribute already exists and the flag
2352 * SMBC_XATTR_FLAG_CREAT was specified
2353 * - ENOATTR If the attribute does not exist and the flag
2354 * SMBC_XATTR_FLAG_REPLACE was specified
2355 * - EPERM Permission was denied.
2356 * - ENOTSUP The referenced file system does not support
2357 * extended attributes
2360 int smbc_getxattr(const char *url,
2361 const char *name,
2362 const void *value,
2363 size_t size);
2366 /**@ingroup attribute
2367 * Get extended attributes for a file. The POSIX function which this maps to
2368 * would act on a symbolic link rather than acting on what the symbolic link
2369 * points to, but with no symbolic links in SMB file systems, this function
2370 * is functionally identical to smbc_getxattr().
2372 * @param url The smb url of the file or directory to get extended
2373 * attributes for.
2375 * @param name The name of an attribute to be retrieved. Names are of
2376 * one of the following forms:
2378 * system.nt_sec_desc.<attribute name>
2379 * system.nt_sec_desc.*
2380 * system.nt_sec_desc.*+
2382 * where <attribute name> is one of:
2384 * revision
2385 * owner
2386 * owner+
2387 * group
2388 * group+
2389 * acl:<name or sid>
2390 * acl+:<name or sid>
2392 * In the forms "system.nt_sec_desc.*" and
2393 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2394 * literal, i.e. the string is provided exactly as shown, and
2395 * the value parameter will return a complete security
2396 * descriptor with name:value pairs separated by tabs,
2397 * commas, or newlines (not spaces!).
2399 * The plus sign ('+') indicates that SIDs should be mapped
2400 * to names. Without the plus sign, SIDs are not mapped;
2401 * rather they are simply converted to a string format.
2403 * @param value A pointer to a buffer in which the value of the specified
2404 * attribute will be placed (unless size is zero).
2406 * @param size The size of the buffer pointed to by value. This parameter
2407 * may also be zero, in which case the size of the buffer
2408 * required to hold the attribute value will be returned,
2409 * but nothing will be placed into the value buffer.
2411 * @return size on success, < 0 on error with errno set:
2412 * - EINVAL The client library is not properly initialized
2413 * or one of the parameters is not of a correct
2414 * form
2415 * - ENOMEM No memory was available for internal needs
2416 * - EEXIST If the attribute already exists and the flag
2417 * SMBC_XATTR_FLAG_CREAT was specified
2418 * - ENOATTR If the attribute does not exist and the flag
2419 * SMBC_XATTR_FLAG_REPLACE was specified
2420 * - EPERM Permission was denied.
2421 * - ENOTSUP The referenced file system does not support
2422 * extended attributes
2425 int smbc_lgetxattr(const char *url,
2426 const char *name,
2427 const void *value,
2428 size_t size);
2431 /**@ingroup attribute
2432 * Get extended attributes for a file.
2434 * @param fd A file descriptor associated with an open file (as
2435 * previously returned by smbc_open(), to get extended
2436 * attributes for.
2438 * @param name The name of an attribute to be retrieved. Names are of
2439 * one of the following forms:
2441 * system.nt_sec_desc.<attribute name>
2442 * system.nt_sec_desc.*
2443 * system.nt_sec_desc.*+
2445 * where <attribute name> is one of:
2447 * revision
2448 * owner
2449 * owner+
2450 * group
2451 * group+
2452 * acl:<name or sid>
2453 * acl+:<name or sid>
2455 * In the forms "system.nt_sec_desc.*" and
2456 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2457 * literal, i.e. the string is provided exactly as shown, and
2458 * the value parameter will return a complete security
2459 * descriptor with name:value pairs separated by tabs,
2460 * commas, or newlines (not spaces!).
2462 * The plus sign ('+') indicates that SIDs should be mapped
2463 * to names. Without the plus sign, SIDs are not mapped;
2464 * rather they are simply converted to a string format.
2466 * @param value A pointer to a buffer in which the value of the specified
2467 * attribute will be placed (unless size is zero).
2469 * @param size The size of the buffer pointed to by value. This parameter
2470 * may also be zero, in which case the size of the buffer
2471 * required to hold the attribute value will be returned,
2472 * but nothing will be placed into the value buffer.
2474 * @return 0 on success, < 0 on error with errno set:
2475 * - EINVAL The client library is not properly initialized
2476 * or one of the parameters is not of a correct
2477 * form
2478 * - ENOMEM No memory was available for internal needs
2479 * - EEXIST If the attribute already exists and the flag
2480 * SMBC_XATTR_FLAG_CREAT was specified
2481 * - ENOATTR If the attribute does not exist and the flag
2482 * SMBC_XATTR_FLAG_REPLACE was specified
2483 * - EPERM Permission was denied.
2484 * - ENOTSUP The referenced file system does not support
2485 * extended attributes
2488 int smbc_fgetxattr(int fd,
2489 const char *name,
2490 const void *value,
2491 size_t size);
2494 /**@ingroup attribute
2495 * Remove extended attributes for a file. This is used for modifying a file's
2496 * security descriptor (i.e. owner, group, and access control list)
2498 * @param url The smb url of the file or directory to remove the extended
2499 * attributes for.
2501 * @param name The name of an attribute to be removed. Names are of
2502 * one of the following forms:
2504 * system.nt_sec_desc.<attribute name>
2505 * system.nt_sec_desc.*
2506 * system.nt_sec_desc.*+
2508 * where <attribute name> is one of:
2510 * revision
2511 * owner
2512 * owner+
2513 * group
2514 * group+
2515 * acl:<name or sid>
2516 * acl+:<name or sid>
2518 * In the forms "system.nt_sec_desc.*" and
2519 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2520 * literal, i.e. the string is provided exactly as shown, and
2521 * the value parameter will return a complete security
2522 * descriptor with name:value pairs separated by tabs,
2523 * commas, or newlines (not spaces!).
2525 * The plus sign ('+') indicates that SIDs should be mapped
2526 * to names. Without the plus sign, SIDs are not mapped;
2527 * rather they are simply converted to a string format.
2529 * @return 0 on success, < 0 on error with errno set:
2530 * - EINVAL The client library is not properly initialized
2531 * - ENOMEM No memory was available for internal needs
2532 * - EPERM Permission was denied.
2533 * - ENOTSUP The referenced file system does not support
2534 * extended attributes
2537 int smbc_removexattr(const char *url,
2538 const char *name);
2541 /**@ingroup attribute
2542 * Remove extended attributes for a file. This is used for modifying a file's
2543 * security descriptor (i.e. owner, group, and access control list) The POSIX
2544 * function which this maps to would act on a symbolic link rather than acting
2545 * on what the symbolic link points to, but with no symbolic links in SMB file
2546 * systems, this function is functionally identical to smbc_removexattr().
2548 * @param url The smb url of the file or directory to remove the extended
2549 * attributes for.
2551 * @param name The name of an attribute to be removed. Names are of
2552 * one of the following forms:
2554 * system.nt_sec_desc.<attribute name>
2555 * system.nt_sec_desc.*
2556 * system.nt_sec_desc.*+
2558 * where <attribute name> is one of:
2560 * revision
2561 * owner
2562 * owner+
2563 * group
2564 * group+
2565 * acl:<name or sid>
2566 * acl+:<name or sid>
2568 * In the forms "system.nt_sec_desc.*" and
2569 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2570 * literal, i.e. the string is provided exactly as shown, and
2571 * the value parameter will return a complete security
2572 * descriptor with name:value pairs separated by tabs,
2573 * commas, or newlines (not spaces!).
2575 * The plus sign ('+') indicates that SIDs should be mapped
2576 * to names. Without the plus sign, SIDs are not mapped;
2577 * rather they are simply converted to a string format.
2579 * @return 0 on success, < 0 on error with errno set:
2580 * - EINVAL The client library is not properly initialized
2581 * - ENOMEM No memory was available for internal needs
2582 * - EPERM Permission was denied.
2583 * - ENOTSUP The referenced file system does not support
2584 * extended attributes
2587 int smbc_lremovexattr(const char *url,
2588 const char *name);
2591 /**@ingroup attribute
2592 * Remove extended attributes for a file. This is used for modifying a file's
2593 * security descriptor (i.e. owner, group, and access control list)
2595 * @param fd A file descriptor associated with an open file (as
2596 * previously returned by smbc_open(), to get extended
2597 * attributes for.
2599 * @param name The name of an attribute to be removed. Names are of
2600 * one of the following forms:
2602 * system.nt_sec_desc.<attribute name>
2603 * system.nt_sec_desc.*
2604 * system.nt_sec_desc.*+
2606 * where <attribute name> is one of:
2608 * revision
2609 * owner
2610 * owner+
2611 * group
2612 * group+
2613 * acl:<name or sid>
2614 * acl+:<name or sid>
2616 * In the forms "system.nt_sec_desc.*" and
2617 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2618 * literal, i.e. the string is provided exactly as shown, and
2619 * the value parameter will return a complete security
2620 * descriptor with name:value pairs separated by tabs,
2621 * commas, or newlines (not spaces!).
2623 * The plus sign ('+') indicates that SIDs should be mapped
2624 * to names. Without the plus sign, SIDs are not mapped;
2625 * rather they are simply converted to a string format.
2627 * @return 0 on success, < 0 on error with errno set:
2628 * - EINVAL The client library is not properly initialized
2629 * - ENOMEM No memory was available for internal needs
2630 * - EPERM Permission was denied.
2631 * - ENOTSUP The referenced file system does not support
2632 * extended attributes
2635 int smbc_fremovexattr(int fd,
2636 const char *name);
2639 /**@ingroup attribute
2640 * List the supported extended attribute names associated with a file
2642 * @param url The smb url of the file or directory to list the extended
2643 * attributes for.
2645 * @param list A pointer to a buffer in which the list of attributes for
2646 * the specified file or directory will be placed (unless
2647 * size is zero).
2649 * @param size The size of the buffer pointed to by list. This parameter
2650 * may also be zero, in which case the size of the buffer
2651 * required to hold all of the attribute names will be
2652 * returned, but nothing will be placed into the list buffer.
2654 * @return 0 on success, < 0 on error with errno set:
2655 * - EINVAL The client library is not properly initialized
2656 * - ENOMEM No memory was available for internal needs
2657 * - EPERM Permission was denied.
2658 * - ENOTSUP The referenced file system does not support
2659 * extended attributes
2661 * @note This function always returns all attribute names supported
2662 * by NT file systems, regardless of whether the referenced
2663 * file system supports extended attributes (e.g. a Windows
2664 * 2000 machine supports extended attributes if NTFS is used,
2665 * but not if FAT is used, and Windows 98 doesn't support
2666 * extended attributes at all. Whether this is a feature or
2667 * a bug is yet to be decided.
2669 int smbc_listxattr(const char *url,
2670 char *list,
2671 size_t size);
2673 /**@ingroup attribute
2674 * List the supported extended attribute names associated with a file The
2675 * POSIX function which this maps to would act on a symbolic link rather than
2676 * acting on what the symbolic link points to, but with no symbolic links in
2677 * SMB file systems, this function is functionally identical to
2678 * smbc_listxattr().
2680 * @param url The smb url of the file or directory to list the extended
2681 * attributes for.
2683 * @param list A pointer to a buffer in which the list of attributes for
2684 * the specified file or directory will be placed (unless
2685 * size is zero).
2687 * @param size The size of the buffer pointed to by list. This parameter
2688 * may also be zero, in which case the size of the buffer
2689 * required to hold all of the attribute names will be
2690 * returned, but nothing will be placed into the list buffer.
2692 * @return 0 on success, < 0 on error with errno set:
2693 * - EINVAL The client library is not properly initialized
2694 * - ENOMEM No memory was available for internal needs
2695 * - EPERM Permission was denied.
2696 * - ENOTSUP The referenced file system does not support
2697 * extended attributes
2699 * @note This function always returns all attribute names supported
2700 * by NT file systems, regardless of whether the referenced
2701 * file system supports extended attributes (e.g. a Windows
2702 * 2000 machine supports extended attributes if NTFS is used,
2703 * but not if FAT is used, and Windows 98 doesn't support
2704 * extended attributes at all. Whether this is a feature or
2705 * a bug is yet to be decided.
2707 int smbc_llistxattr(const char *url,
2708 char *list,
2709 size_t size);
2711 /**@ingroup attribute
2712 * List the supported extended attribute names associated with a file
2714 * @param fd A file descriptor associated with an open file (as
2715 * previously returned by smbc_open(), to get extended
2716 * attributes for.
2718 * @param list A pointer to a buffer in which the list of attributes for
2719 * the specified file or directory will be placed (unless
2720 * size is zero).
2722 * @param size The size of the buffer pointed to by list. This parameter
2723 * may also be zero, in which case the size of the buffer
2724 * required to hold all of the attribute names will be
2725 * returned, but nothing will be placed into the list buffer.
2727 * @return 0 on success, < 0 on error with errno set:
2728 * - EINVAL The client library is not properly initialized
2729 * - ENOMEM No memory was available for internal needs
2730 * - EPERM Permission was denied.
2731 * - ENOTSUP The referenced file system does not support
2732 * extended attributes
2734 * @note This function always returns all attribute names supported
2735 * by NT file systems, regardless of whether the referenced
2736 * file system supports extended attributes (e.g. a Windows
2737 * 2000 machine supports extended attributes if NTFS is used,
2738 * but not if FAT is used, and Windows 98 doesn't support
2739 * extended attributes at all. Whether this is a feature or
2740 * a bug is yet to be decided.
2742 int smbc_flistxattr(int fd,
2743 char *list,
2744 size_t size);
2746 /**@ingroup print
2747 * Print a file given the name in fname. It would be a URL ...
2749 * @param fname The URL of a file on a remote SMB server that the
2750 * caller wants printed
2752 * @param printq The URL of the print share to print the file to.
2754 * @return 0 on success, < 0 on error with errno set:
2756 * - EINVAL fname or printq was NULL or smbc_init not
2757 * not called.
2758 * and errors returned by smbc_open
2761 int smbc_print_file(const char *fname, const char *printq);
2763 /**@ingroup print
2764 * Open a print file that can be written to by other calls. This simply
2765 * does an smbc_open call after checking if there is a file name on the
2766 * URI. If not, a temporary name is added ...
2768 * @param fname The URL of the print share to print to?
2770 * @returns A file handle for the print file if successful.
2771 * Returns -1 if an error occurred and errno has the values
2772 * - EINVAL fname was NULL or smbc_init not called.
2773 * - all errors returned by smbc_open
2776 int smbc_open_print_job(const char *fname);
2778 /**@ingroup print
2779 * List the print jobs on a print share, for the moment, pass a callback
2781 * @param purl The url of the print share to list the jobs of
2783 * @param fn Callback function the receives printjob info
2785 * @return 0 on success, < 0 on error with errno set:
2786 * - EINVAL fname was NULL or smbc_init not called
2787 * - EACCES ???
2789 int smbc_list_print_jobs(const char *purl, smbc_list_print_job_fn fn);
2791 /**@ingroup print
2792 * Delete a print job
2794 * @param purl Url of the print share
2796 * @param id The id of the job to delete
2798 * @return 0 on success, < 0 on error with errno set:
2799 * - EINVAL fname was NULL or smbc_init not called
2801 * @todo what errno values are possible here?
2803 int smbc_unlink_print_job(const char *purl, int id);
2805 /**@ingroup callback
2806 * Remove a server from the cached server list it's unused.
2808 * @param context pointer to smb context
2810 * @param srv pointer to server to remove
2812 * @return On success, 0 is returned. 1 is returned if the server could not
2813 * be removed. Also usable outside libsmbclient.
2815 int smbc_remove_unused_server(SMBCCTX * context, SMBCSRV * srv);
2817 #ifdef __cplusplus
2819 #endif
2821 /**@ingroup directory
2822 * Convert strings of %xx to their single character equivalent.
2824 * @param dest A pointer to a buffer in which the resulting decoded
2825 * string should be placed. This may be a pointer to the
2826 * same buffer as src_segment.
2828 * @param src A pointer to the buffer containing the URL to be decoded.
2829 * Any %xx sequences herein are converted to their single
2830 * character equivalent. Each 'x' must be a valid hexadecimal
2831 * digit, or that % sequence is left undecoded.
2833 * @param max_dest_len
2834 * The size of the buffer pointed to by dest_segment.
2836 * @return The number of % sequences which could not be converted
2837 * due to lack of two following hexadecimal digits.
2839 #ifdef __cplusplus
2840 extern "C" {
2841 #endif
2843 smbc_urldecode(char *dest, char * src, size_t max_dest_len);
2844 #ifdef __cplusplus
2846 #endif
2850 * Convert any characters not specifically allowed in a URL into their %xx
2851 * equivalent.
2853 * @param dest A pointer to a buffer in which the resulting encoded
2854 * string should be placed. Unlike smbc_urldecode(), this
2855 * must be a buffer unique from src.
2857 * @param src A pointer to the buffer containing the string to be encoded.
2858 * Any character not specifically allowed in a URL is converted
2859 * into its hexadecimal value and encoded as %xx.
2861 * @param max_dest_len
2862 * The size of the buffer pointed to by dest_segment.
2864 * @returns The remaining buffer length.
2866 #ifdef __cplusplus
2867 extern "C" {
2868 #endif
2870 smbc_urlencode(char * dest, char * src, int max_dest_len);
2871 #ifdef __cplusplus
2873 #endif
2876 /**@ingroup directory
2877 * Return the version of the linked Samba code, and thus the version of the
2878 * libsmbclient code.
2880 * @return The version string.
2882 #ifdef __cplusplus
2883 extern "C" {
2884 #endif
2885 const char *
2886 smbc_version(void);
2887 #ifdef __cplusplus
2889 #endif
2891 /**@ingroup misc
2892 * @deprecated This interface has been deprecated use
2893 * smbc_set_credentials_with_fallback() instead.
2895 * @see smbc_set_credentials_with_fallback()
2897 DEPRECATED_SMBC_INTERFACE
2898 void
2899 smbc_set_credentials(const char *workgroup,
2900 const char *user,
2901 const char *password,
2902 smbc_bool use_kerberos,
2903 const char *signing_state);
2905 /**@ingroup misc
2907 * Set the users credentials globally so they can be used for DFS
2908 * referrals. Probably best to use this function in the smbc_get_auth_data_fn
2909 * callback.
2911 * @param ctx The smb context.
2913 * @param workgroup Workgroup of the user.
2915 * @param user Username of user.
2917 * @param password Password of user.
2919 void
2920 smbc_set_credentials_with_fallback(SMBCCTX *ctx,
2921 const char *workgroup,
2922 const char *user,
2923 const char *password);
2927 * @ingroup threads
2929 * Initialize for threads using the Posix Threads (pthread)
2930 * implementation. This is a built-in implementation, avoiding the need to
2931 * implement the component functions of the thread interface. If this function
2932 * is used, it is not necessary to call smbc_thread_impl().
2934 * @return {void}
2936 void
2937 smbc_thread_posix(void);
2940 * @ingroup threads
2942 * Initialize for an arbitrary thread implementation. The caller should
2943 * provide, as parameters, pointers to functions to implement the requisite
2944 * low-level thread functionality. A function must be provided for each
2945 * parameter; none may be null.
2947 * If the thread implementation is POSIX Threads (pthreads), then the much
2948 * simpler smbc_thread_pthread() function may be used instead of this one.
2950 * @param create_mutex
2951 * Create a mutex. This function should expect three parameters: lockname,
2952 * pplock, and location. It should create a unique mutex for each unique
2953 * lockname it is provided, and return the mutex identifier in *pplock. The
2954 * location parameter can be used for debugging, as it contains the
2955 * compiler-provided __location__ of the call.
2957 * @param destroy_mutex
2958 * Destroy a mutex. This function should expect two parameters: plock and
2959 * location. It should destroy the mutex associated with the identifier
2960 * plock. The location parameter can be used for debugging, as it contains
2961 * the compiler-provided __location__ of the call.
2963 * @param lock_mutex
2964 * Lock a mutex. This function should expect three parameters: plock,
2965 * lock_type, and location. The mutex associated with identifier plock
2966 * should be locked if lock_type is 1, and unlocked if lock_type is 2. The
2967 * location parameter can be used for debugging, as it contains the
2968 * compiler-provided __location__ of the call.
2970 * @param create_tls
2971 * Create thread local storage. This function should expect three
2972 * parameters: keyname, ppkey, and location. It should allocate an
2973 * implementation-specific amount of memory and assign the pointer to that
2974 * allocated memory to *ppkey. The location parameter can be used for
2975 * debugging, as it contains the compiler-provided __location__ of the
2976 * call. This function should return 0 upon success, non-zero upon failure.
2978 * @param destroy_tls
2979 * Destroy thread local storage. This function should expect two parameters:
2980 * ppkey and location. The ppkey parameter points to a variable containing a
2981 * thread local storage key previously provided by the create_tls
2982 * function. The location parameter can be used for debugging, as it
2983 * contains the compiler-provided __location__ of the call.
2985 * @param set_tls
2986 * Set a thread local storage variable's value. This function should expect
2987 * three parameters: pkey, pval, and location. The pkey parameter is a
2988 * thread local storage key previously provided by the create_tls
2989 * function. The (void *) pval parameter contains the value to be placed in
2990 * the thread local storage variable identified by pkey. The location
2991 * parameter can be used for debugging, as it contains the compiler-provided
2992 * __location__ of the call. This function should return 0 upon success;
2993 * non-zero otherwise.
2995 * @param get_tls
2996 * Retrieve a thread local storage variable's value. This function should
2997 * expect two parameters: pkey and location. The pkey parameter is a thread
2998 * local storage key previously provided by the create_tls function, and
2999 * which has previously been used in a call to the set_tls function to
3000 * initialize a thread local storage variable. The location parameter can be
3001 * used for debugging, as it contains the compiler-provided __location__ of
3002 * the call. This function should return the (void *) value stored in the
3003 * variable identified by pkey.
3005 * @return {void}
3007 void
3008 smbc_thread_impl(
3009 /* Mutex functions. */
3010 int (*create_mutex)(const char *lockname,
3011 void **pplock,
3012 const char *location),
3013 void (*destroy_mutex)(void *plock,
3014 const char *location),
3015 int (*lock_mutex)(void *plock,
3016 int lock_type,
3017 const char *location),
3019 /* Thread local storage. */
3020 int (*create_tls)(const char *keyname,
3021 void **ppkey,
3022 const char *location),
3023 void (*destroy_tls)(void **ppkey,
3024 const char *location),
3025 int (*set_tls)(void *pkey,
3026 const void *pval,
3027 const char *location),
3028 void *(*get_tls)(void *pkey,
3029 const char *location)
3035 * @ingroup structure
3036 * Structure that contains a client context information
3037 * This structure is known as SMBCCTX
3039 * DO NOT DIRECTLY MANIPULATE THE CONTEXT STRUCTURE! The data in the context
3040 * structure should all be considered private to the library. It remains here
3041 * only for backward compatibility.
3043 * See the comments herein for use of the setter and getter functions which
3044 * should now be used for manipulating these values. New features, functions,
3045 * etc., are not added here but rather in _internal where they are not
3046 * directly visible to applications. This makes it much easier to maintain
3047 * ABI compatibility.
3049 struct _SMBCCTX
3052 * debug level
3054 * DEPRECATED:
3055 * Use smbc_getDebug() and smbc_setDebug()
3057 int debug DEPRECATED_SMBC_INTERFACE;
3060 * netbios name used for making connections
3062 * DEPRECATED:
3063 * Use smbc_getNetbiosName() and smbc_setNetbiosName()
3065 char * netbios_name DEPRECATED_SMBC_INTERFACE;
3068 * workgroup name used for making connections
3070 * DEPRECATED:
3071 * Use smbc_getWorkgroup() and smbc_setWorkgroup()
3073 char * workgroup DEPRECATED_SMBC_INTERFACE;
3076 * username used for making connections
3078 * DEPRECATED:
3079 * Use smbc_getUser() and smbc_setUser()
3081 char * user DEPRECATED_SMBC_INTERFACE;
3084 * timeout used for waiting on connections / response data (in
3085 * milliseconds)
3087 * DEPRECATED:
3088 * Use smbc_getTimeout() and smbc_setTimeout()
3090 int timeout DEPRECATED_SMBC_INTERFACE;
3093 * callable functions for files:
3094 * For usage and return values see the SMBC_* functions
3096 * DEPRECATED:
3098 * Use smbc_getFunction*() and smbc_setFunction*(), e.g.
3099 * smbc_getFunctionOpen(), smbc_setFunctionUnlink(), etc.
3101 smbc_open_fn open DEPRECATED_SMBC_INTERFACE;
3102 smbc_creat_fn creat DEPRECATED_SMBC_INTERFACE;
3103 smbc_read_fn read DEPRECATED_SMBC_INTERFACE;
3104 smbc_write_fn write DEPRECATED_SMBC_INTERFACE;
3105 smbc_unlink_fn unlink DEPRECATED_SMBC_INTERFACE;
3106 smbc_rename_fn rename DEPRECATED_SMBC_INTERFACE;
3107 smbc_lseek_fn lseek DEPRECATED_SMBC_INTERFACE;
3108 smbc_stat_fn stat DEPRECATED_SMBC_INTERFACE;
3109 smbc_fstat_fn fstat DEPRECATED_SMBC_INTERFACE;
3110 #if 0 /* internal */
3111 smbc_ftruncate_fn ftruncate_fn;
3112 #endif
3113 smbc_close_fn close_fn DEPRECATED_SMBC_INTERFACE;
3114 smbc_opendir_fn opendir DEPRECATED_SMBC_INTERFACE;
3115 smbc_closedir_fn closedir DEPRECATED_SMBC_INTERFACE;
3116 smbc_readdir_fn readdir DEPRECATED_SMBC_INTERFACE;
3117 smbc_readdirplus_fn readdirplus DEPRECATED_SMBC_INTERFACE;
3118 smbc_readdirplus2_fn readdirplus2 DEPRECATED_SMBC_INTERFACE;
3119 smbc_getdents_fn getdents DEPRECATED_SMBC_INTERFACE;
3120 smbc_mkdir_fn mkdir DEPRECATED_SMBC_INTERFACE;
3121 smbc_rmdir_fn rmdir DEPRECATED_SMBC_INTERFACE;
3122 smbc_telldir_fn telldir DEPRECATED_SMBC_INTERFACE;
3123 smbc_lseekdir_fn lseekdir DEPRECATED_SMBC_INTERFACE;
3124 smbc_fstatdir_fn fstatdir DEPRECATED_SMBC_INTERFACE;
3125 smbc_chmod_fn chmod DEPRECATED_SMBC_INTERFACE;
3126 smbc_utimes_fn utimes DEPRECATED_SMBC_INTERFACE;
3127 smbc_setxattr_fn setxattr DEPRECATED_SMBC_INTERFACE;
3128 smbc_getxattr_fn getxattr DEPRECATED_SMBC_INTERFACE;
3129 smbc_removexattr_fn removexattr DEPRECATED_SMBC_INTERFACE;
3130 smbc_listxattr_fn listxattr DEPRECATED_SMBC_INTERFACE;
3132 /* Printing-related functions */
3133 smbc_print_file_fn print_file DEPRECATED_SMBC_INTERFACE;
3134 smbc_open_print_job_fn open_print_job DEPRECATED_SMBC_INTERFACE;
3135 smbc_list_print_jobs_fn list_print_jobs DEPRECATED_SMBC_INTERFACE;
3136 smbc_unlink_print_job_fn unlink_print_job DEPRECATED_SMBC_INTERFACE;
3139 ** Callbacks
3141 * DEPRECATED:
3143 * See the comment above each field, for the getter and setter
3144 * functions that should now be used.
3146 struct _smbc_callbacks
3149 * authentication function callback: called upon auth requests
3151 * DEPRECATED:
3152 * Use smbc_getFunctionAuthData(), smbc_setFunctionAuthData()
3154 smbc_get_auth_data_fn auth_fn DEPRECATED_SMBC_INTERFACE;
3157 * check if a server is still good
3159 * DEPRECATED:
3160 * Use smbc_getFunctionCheckServer(),
3161 * smbc_setFunctionCheckServer()
3163 smbc_check_server_fn check_server_fn DEPRECATED_SMBC_INTERFACE;
3166 * remove a server if unused
3168 * DEPRECATED:
3169 * Use smbc_getFunctionRemoveUnusedServer(),
3170 * smbc_setFunctionCheckServer()
3172 smbc_remove_unused_server_fn remove_unused_server_fn DEPRECATED_SMBC_INTERFACE;
3174 /** Cache subsystem
3176 * For an example cache system see
3177 * samba/source/libsmb/libsmb_cache.c
3179 * Cache subsystem * functions follow.
3183 * server cache addition
3185 * DEPRECATED:
3186 * Use smbc_getFunctionAddCachedServer(),
3187 * smbc_setFunctionAddCachedServer()
3189 smbc_add_cached_srv_fn add_cached_srv_fn DEPRECATED_SMBC_INTERFACE;
3192 * server cache lookup
3194 * DEPRECATED:
3195 * Use smbc_getFunctionGetCachedServer(),
3196 * smbc_setFunctionGetCachedServer()
3198 smbc_get_cached_srv_fn get_cached_srv_fn DEPRECATED_SMBC_INTERFACE;
3201 * server cache removal
3203 * DEPRECATED:
3204 * Use smbc_getFunctionRemoveCachedServer(),
3205 * smbc_setFunctionRemoveCachedServer()
3207 smbc_remove_cached_srv_fn remove_cached_srv_fn DEPRECATED_SMBC_INTERFACE;
3210 * server cache purging, try to remove all cached servers
3211 * (disconnect)
3213 * DEPRECATED:
3214 * Use smbc_getFunctionPurgeCachedServers(),
3215 * smbc_setFunctionPurgeCachedServers()
3217 smbc_purge_cached_fn purge_cached_fn DEPRECATED_SMBC_INTERFACE;
3218 } callbacks;
3221 * Space where the private data of the server cache used to be
3223 * DEPRECATED:
3224 * Use smbc_getServerCacheData(), smbc_setServerCacheData()
3226 void * reserved DEPRECATED_SMBC_INTERFACE;
3229 * Very old configuration options.
3231 * DEPRECATED:
3232 * Use one of the following functions instead:
3233 * smbc_setOptionUseKerberos()
3234 * smbc_getOptionUseKerberos()
3235 * smbc_setOptionFallbackAfterKerberos()
3236 * smbc_getOptionFallbackAfterKerberos()
3237 * smbc_setOptionNoAutoAnonymousLogin()
3238 * smbc_getOptionNoAutoAnonymousLogin()
3240 int flags DEPRECATED_SMBC_INTERFACE;
3243 * user options selections that apply to this session
3245 * NEW OPTIONS ARE NOT ADDED HERE!
3247 * DEPRECATED:
3248 * To set and retrieve options, use the smbc_setOption*() and
3249 * smbc_getOption*() functions.
3251 struct _smbc_options {
3252 int browse_max_lmb_count DEPRECATED_SMBC_INTERFACE;
3253 int urlencode_readdir_entries DEPRECATED_SMBC_INTERFACE;
3254 int one_share_per_server DEPRECATED_SMBC_INTERFACE;
3255 } options DEPRECATED_SMBC_INTERFACE;
3257 /** INTERNAL DATA
3258 * do _NOT_ touch this from your program !
3260 struct SMBC_internal_data * internal;
3264 #endif /* SMBCLIENT_H_INCLUDED */