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))
32 # define DEPRECATED_SMBC_INTERFACE
39 /*-------------------------------------------------------------------*/
40 /* The following are special comments to instruct DOXYGEN (automated
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
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>
78 #include <sys/statvfs.h>
83 #define SMBC_BASE_FD 10000 /* smallest file descriptor returned */
85 #define SMBC_WORKGROUP 1
87 #define SMBC_FILE_SHARE 3
88 #define SMBC_PRINTER_SHARE 4
89 #define SMBC_COMMS_SHARE 5
90 #define SMBC_IPC_SHARE 6
96 * Structure that represents a directory entry.
105 SMBC_PRINTER_SHARE=4,
111 unsigned int smbc_type
;
113 /** Length of this smbc_dirent in bytes
116 /** The length of the comment string in bytes (does not include
119 unsigned int commentlen
;
120 /** Points to the null terminated comment string
123 /** The length of the name string in bytes (does not include
126 unsigned int namelen
;
127 /** Points to the null terminated name string
132 /**@ingroup structure
133 * Structure that represents all attributes of a directory entry.
136 struct libsmb_file_info
143 * DOS attributes of file
155 * Birth/Create time of file (if supported by system)
156 * Otherwise the value will be 0
158 struct timespec btime_ts
;
160 * Modified time for the file
162 struct timespec mtime_ts
;
164 * Access time for the file
166 struct timespec atime_ts
;
168 * Change time for the file
170 struct timespec ctime_ts
;
182 * Logging callback function
184 typedef void (*smbc_debug_callback_fn
)(void *private_ptr
, int level
, const char *msg
);
187 * Flags for smbc_setxattr()
188 * Specify a bitwise OR of these, or 0 to add or replace as necessary
190 #define SMBC_XATTR_FLAG_CREATE 0x1 /* fail if attr already exists */
191 #define SMBC_XATTR_FLAG_REPLACE 0x2 /* fail if attr does not exist */
195 * Mappings of the DOS mode bits, as returned by smbc_getxattr() when the
196 * attribute name "system.dos_attr.mode" (or "system.dos_attr.*" or
197 * "system.*") is specified.
199 #define SMBC_DOS_MODE_READONLY 0x01
200 #define SMBC_DOS_MODE_HIDDEN 0x02
201 #define SMBC_DOS_MODE_SYSTEM 0x04
202 #define SMBC_DOS_MODE_VOLUME_ID 0x08
203 #define SMBC_DOS_MODE_DIRECTORY 0x10
204 #define SMBC_DOS_MODE_ARCHIVE 0x20
207 * Valid values for the option "open_share_mode", when calling
208 * smbc_setOptionOpenShareMode()
210 typedef enum smbc_share_mode
212 SMBC_SHAREMODE_DENY_DOS
= 0,
213 SMBC_SHAREMODE_DENY_ALL
= 1,
214 SMBC_SHAREMODE_DENY_WRITE
= 2,
215 SMBC_SHAREMODE_DENY_READ
= 3,
216 SMBC_SHAREMODE_DENY_NONE
= 4,
217 SMBC_SHAREMODE_DENY_FCB
= 7
222 * Values for option SMB Encryption Level, as set and retrieved with
223 * smbc_setOptionSmbEncryptionLevel() and smbc_getOptionSmbEncryptionLevel()
225 typedef enum smbc_smb_encrypt_level
227 SMBC_ENCRYPTLEVEL_NONE
= 0,
228 SMBC_ENCRYPTLEVEL_REQUEST
= 1,
229 SMBC_ENCRYPTLEVEL_REQUIRE
= 2
230 } smbc_smb_encrypt_level
;
234 * Capabilities set in the f_flag field of struct statvfs, from
235 * smbc_statvfs(). These may be OR-ed together to reflect a full set of
236 * available capabilities.
238 typedef enum smbc_vfs_feature
240 /* Defined by POSIX or in Linux include files (low-order bits) */
241 SMBC_VFS_FEATURE_RDONLY
= (1 << 0),
243 /* Specific to libsmbclient (high-order bits) */
244 SMBC_VFS_FEATURE_DFS
= (1 << 28),
245 SMBC_VFS_FEATURE_CASE_INSENSITIVE
= (1 << 29),
246 SMBC_VFS_FEATURE_NO_UNIXCIFS
= (1 << 30)
249 typedef int smbc_bool
;
253 # define ENOATTR ENOENT /* No such attribute */
259 /**@ingroup structure
260 * Structure that represents a print job.
264 struct print_job_info
266 /** numeric ID of the print job
270 /** represents print job priority (lower numbers mean higher priority)
272 unsigned short priority
;
274 /** Size of the print job
278 /** Name of the user that owns the print job
282 /** Name of the print job. This will have no name if an anonymous print
283 * file was opened. Ie smb://server/printer
287 /** Time the print job was spooled
291 #endif /* _CLIENT_H */
294 /**@ingroup structure
297 typedef struct _SMBCSRV SMBCSRV
;
299 /**@ingroup structure
300 * File or directory handle
302 typedef struct _SMBCFILE SMBCFILE
;
304 /**@ingroup structure
305 * File or directory handle
307 typedef struct _SMBCCTX SMBCCTX
;
311 * Flags for SMBCCTX->flags
313 * NEW CODE SHOULD NOT DIRECTLY MANIPULATE THE CONTEXT STRUCTURE.
315 * smbc_setOptionUseKerberos()
316 * smbc_getOptionUseKerberos()
317 * smbc_setOptionFallbackAfterKerberos()
318 * smbc_getOptionFallbackAFterKerberos()
319 * smbc_setOptionNoAutoAnonymousLogin()
320 * smbc_getOptionNoAutoAnonymousLogin()
321 * smbc_setOptionUseCCache()
322 * smbc_getOptionUseCCache()
324 # define SMB_CTX_FLAG_USE_KERBEROS (1 << 0)
325 # define SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS (1 << 1)
326 # define SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON (1 << 2)
327 # define SMB_CTX_FLAG_USE_CCACHE (1 << 3)
332 * Authentication callback function type (traditional method)
334 * Type for the the authentication function called by the library to
335 * obtain authentication credentials
337 * For kerberos support the function should just be called without
338 * prompting the user for credentials. Which means a simple 'return'
339 * should work. Take a look at examples/libsmbclient/get_auth_data_fn.h
340 * and examples/libsmbclient/testbrowse.c.
342 * @param srv Server being authenticated to
344 * @param shr Share being authenticated to
346 * @param wg Pointer to buffer containing a "hint" for the
347 * workgroup to be authenticated. Should be filled in
348 * with the correct workgroup if the hint is wrong.
350 * @param wglen The size of the workgroup buffer in bytes
352 * @param un Pointer to buffer containing a "hint" for the
353 * user name to be use for authentication. Should be
354 * filled in with the correct workgroup if the hint is
357 * @param unlen The size of the username buffer in bytes
359 * @param pw Pointer to buffer containing to which password
362 * @param pwlen The size of the password buffer in bytes
365 typedef void (*smbc_get_auth_data_fn
)(const char *srv
,
369 char *pw
, int pwlen
);
371 * Authentication callback function type (method that includes context)
373 * Type for the the authentication function called by the library to
374 * obtain authentication credentials
376 * For kerberos support the function should just be called without
377 * prompting the user for credentials. Which means a simple 'return'
378 * should work. Take a look at examples/libsmbclient/get_auth_data_fn.h
379 * and examples/libsmbclient/testbrowse.c.
381 * @param c Pointer to the smb context
383 * @param srv Server being authenticated to
385 * @param shr Share being authenticated to
387 * @param wg Pointer to buffer containing a "hint" for the
388 * workgroup to be authenticated. Should be filled in
389 * with the correct workgroup if the hint is wrong.
391 * @param wglen The size of the workgroup buffer in bytes
393 * @param un Pointer to buffer containing a "hint" for the
394 * user name to be use for authentication. Should be
395 * filled in with the correct workgroup if the hint is
398 * @param unlen The size of the username buffer in bytes
400 * @param pw Pointer to buffer containing to which password
403 * @param pwlen The size of the password buffer in bytes
406 typedef void (*smbc_get_auth_data_with_context_fn
)(SMBCCTX
*c
,
411 char *pw
, int pwlen
);
415 * Print job info callback function type.
417 * @param i pointer to print job information structure
420 typedef void (*smbc_list_print_job_fn
)(struct print_job_info
*i
);
424 * Check if a server is still good
426 * @param c pointer to smb context
428 * @param srv pointer to server to check
430 * @return 0 when connection is good. 1 on error.
433 typedef int (*smbc_check_server_fn
)(SMBCCTX
* c
, SMBCSRV
*srv
);
436 * Remove a server if unused
438 * @param c pointer to smb context
440 * @param srv pointer to server to remove
442 * @return 0 on success. 1 on failure.
445 typedef int (*smbc_remove_unused_server_fn
)(SMBCCTX
* c
, SMBCSRV
*srv
);
449 * Add a server to the cache system
451 * @param c pointer to smb context
453 * @param srv pointer to server to add
455 * @param server server name
457 * @param share share name
459 * @param workgroup workgroup used to connect
461 * @param username username used to connect
463 * @return 0 on success. 1 on failure.
466 typedef int (*smbc_add_cached_srv_fn
) (SMBCCTX
* c
, SMBCSRV
*srv
,
467 const char * server
, const char * share
,
468 const char * workgroup
, const char * username
);
471 * Look up a server in the cache system
473 * @param c pointer to smb context
475 * @param server server name to match
477 * @param share share name to match
479 * @param workgroup workgroup to match
481 * @param username username to match
483 * @return pointer to SMBCSRV on success. NULL on failure.
486 typedef SMBCSRV
* (*smbc_get_cached_srv_fn
) (SMBCCTX
* c
, const char * server
,
487 const char * share
, const char * workgroup
,
488 const char * username
);
491 * Check if a server is still good
493 * @param c pointer to smb context
495 * @param srv pointer to server to remove
497 * @return 0 when found and removed. 1 on failure.
500 typedef int (*smbc_remove_cached_srv_fn
)(SMBCCTX
* c
, SMBCSRV
*srv
);
504 * Try to remove all servers from the cache system and disconnect
506 * @param c pointer to smb context
508 * @return 0 when found and removed. 1 on failure.
511 typedef int (*smbc_purge_cached_fn
) (SMBCCTX
* c
);
515 /*****************************************
516 * Getters and setters for CONFIGURATION *
517 *****************************************/
519 /** Get the debug level */
521 smbc_getDebug(SMBCCTX
*c
);
523 /** Set the debug level */
525 smbc_setDebug(SMBCCTX
*c
, int debug
);
528 * set log callback function to capture logs from libsmbclient, this
529 * is applied at global level
532 smbc_setLogCallback(SMBCCTX
*c
, void *private_ptr
,
533 smbc_debug_callback_fn fn
);
535 /** set configuration file, this is applied at global level */
537 smbc_setConfiguration(SMBCCTX
*c
, const char *file
);
539 /** Get the netbios name used for making connections */
541 smbc_getNetbiosName(SMBCCTX
*c
);
543 /** Set the netbios name used for making connections */
545 smbc_setNetbiosName(SMBCCTX
*c
, const char *netbios_name
);
547 /** Get the workgroup used for making connections */
549 smbc_getWorkgroup(SMBCCTX
*c
);
551 /** Set the workgroup used for making connections */
552 void smbc_setWorkgroup(SMBCCTX
*c
, const char *workgroup
);
554 /** Get the username used for making connections */
556 smbc_getUser(SMBCCTX
*c
);
558 /** Set the username used for making connections */
560 smbc_setUser(SMBCCTX
*c
, const char *user
);
563 * Get the timeout used for waiting on connections and response data
567 smbc_getTimeout(SMBCCTX
*c
);
570 * Set the timeout used for waiting on connections and response data
574 smbc_setTimeout(SMBCCTX
*c
, int timeout
);
578 * Get the TCP port used to connect (0 means default).
581 smbc_getPort(SMBCCTX
*c
);
584 * Set the TCP port used to connect (0 means default).
587 smbc_setPort(SMBCCTX
*c
, uint16_t port
);
591 /***********************************
592 * Getters and setters for OPTIONS *
593 ***********************************/
595 /** Get whether to log to standard error instead of standard output */
597 smbc_getOptionDebugToStderr(SMBCCTX
*c
);
599 /** Set whether to log to standard error instead of standard output */
601 smbc_setOptionDebugToStderr(SMBCCTX
*c
, smbc_bool b
);
604 * Get whether to use new-style time attribute names, e.g. WRITE_TIME rather
605 * than the old-style names such as M_TIME. This allows also setting/getting
606 * CREATE_TIME which was previously unimplemented. (Note that the old C_TIME
607 * was supposed to be CHANGE_TIME but was confused and sometimes referred to
611 smbc_getOptionFullTimeNames(SMBCCTX
*c
);
614 * Set whether to use new-style time attribute names, e.g. WRITE_TIME rather
615 * than the old-style names such as M_TIME. This allows also setting/getting
616 * CREATE_TIME which was previously unimplemented. (Note that the old C_TIME
617 * was supposed to be CHANGE_TIME but was confused and sometimes referred to
621 smbc_setOptionFullTimeNames(SMBCCTX
*c
, smbc_bool b
);
624 * Get the share mode to use for files opened with SMBC_open_ctx(). The
625 * default is SMBC_SHAREMODE_DENY_NONE.
628 smbc_getOptionOpenShareMode(SMBCCTX
*c
);
631 * Set the share mode to use for files opened with SMBC_open_ctx(). The
632 * default is SMBC_SHAREMODE_DENY_NONE.
635 smbc_setOptionOpenShareMode(SMBCCTX
*c
, smbc_share_mode share_mode
);
637 /** Retrieve a previously saved user data handle */
639 smbc_getOptionUserData(SMBCCTX
*c
);
641 /** Save a user data handle */
643 smbc_setOptionUserData(SMBCCTX
*c
, void *user_data
);
645 /** Get the encoded value for encryption level. */
646 smbc_smb_encrypt_level
647 smbc_getOptionSmbEncryptionLevel(SMBCCTX
*c
);
649 /** Set the encoded value for encryption level. */
651 smbc_setOptionSmbEncryptionLevel(SMBCCTX
*c
, smbc_smb_encrypt_level level
);
654 * Get whether to treat file names as case-sensitive if we can't determine
655 * when connecting to the remote share whether the file system is case
656 * sensitive. This defaults to FALSE since it's most likely that if we can't
657 * retrieve the file system attributes, it's a very old file system that does
658 * not support case sensitivity.
661 smbc_getOptionCaseSensitive(SMBCCTX
*c
);
664 * Set whether to treat file names as case-sensitive if we can't determine
665 * when connecting to the remote share whether the file system is case
666 * sensitive. This defaults to FALSE since it's most likely that if we can't
667 * retrieve the file system attributes, it's a very old file system that does
668 * not support case sensitivity.
671 smbc_setOptionCaseSensitive(SMBCCTX
*c
, smbc_bool b
);
675 * Get from how many local master browsers should the list of workgroups be
676 * retrieved. It can take up to 12 minutes or longer after a server becomes a
677 * local master browser, for it to have the entire browse list (the list of
678 * workgroups/domains) from an entire network. Since a client never knows
679 * which local master browser will be found first, the one which is found
680 * first and used to retrieve a browse list may have an incomplete or empty
681 * browse list. By requesting the browse list from multiple local master
682 * browsers, a more complete list can be generated. For small networks (few
683 * workgroups), it is recommended that this value be set to 0, causing the
684 * browse lists from all found local master browsers to be retrieved and
685 * merged. For networks with many workgroups, a suitable value for this
686 * variable is probably somewhere around 3. (Default: 3).
689 smbc_getOptionBrowseMaxLmbCount(SMBCCTX
*c
);
692 * Set from how many local master browsers should the list of workgroups be
693 * retrieved. It can take up to 12 minutes or longer after a server becomes a
694 * local master browser, for it to have the entire browse list (the list of
695 * workgroups/domains) from an entire network. Since a client never knows
696 * which local master browser will be found first, the one which is found
697 * first and used to retrieve a browse list may have an incomplete or empty
698 * browse list. By requesting the browse list from multiple local master
699 * browsers, a more complete list can be generated. For small networks (few
700 * workgroups), it is recommended that this value be set to 0, causing the
701 * browse lists from all found local master browsers to be retrieved and
702 * merged. For networks with many workgroups, a suitable value for this
703 * variable is probably somewhere around 3. (Default: 3).
706 smbc_setOptionBrowseMaxLmbCount(SMBCCTX
*c
, int count
);
709 * Get whether to url-encode readdir entries.
711 * There is a difference in the desired return strings from
712 * smbc_readdir() depending upon whether the filenames are to
713 * be displayed to the user, or whether they are to be
714 * appended to the path name passed to smbc_opendir() to call
715 * a further smbc_ function (e.g. open the file with
716 * smbc_open()). In the former case, the filename should be
717 * in "human readable" form. In the latter case, the smbc_
718 * functions expect a URL which must be url-encoded. Those
719 * functions decode the URL. If, for example, smbc_readdir()
720 * returned a file name of "abc%20def.txt", passing a path
721 * with this file name attached to smbc_open() would cause
722 * smbc_open to attempt to open the file "abc def.txt" since
723 * the %20 is decoded into a space.
725 * Set this option to True if the names returned by
726 * smbc_readdir() should be url-encoded such that they can be
727 * passed back to another smbc_ call. Set it to False if the
728 * names returned by smbc_readdir() are to be presented to the
731 * For backwards compatibility, this option defaults to False.
734 smbc_getOptionUrlEncodeReaddirEntries(SMBCCTX
*c
);
737 * Set whether to url-encode readdir entries.
739 * There is a difference in the desired return strings from
740 * smbc_readdir() depending upon whether the filenames are to
741 * be displayed to the user, or whether they are to be
742 * appended to the path name passed to smbc_opendir() to call
743 * a further smbc_ function (e.g. open the file with
744 * smbc_open()). In the former case, the filename should be
745 * in "human readable" form. In the latter case, the smbc_
746 * functions expect a URL which must be url-encoded. Those
747 * functions decode the URL. If, for example, smbc_readdir()
748 * returned a file name of "abc%20def.txt", passing a path
749 * with this file name attached to smbc_open() would cause
750 * smbc_open to attempt to open the file "abc def.txt" since
751 * the %20 is decoded into a space.
753 * Set this option to True if the names returned by
754 * smbc_readdir() should be url-encoded such that they can be
755 * passed back to another smbc_ call. Set it to False if the
756 * names returned by smbc_readdir() are to be presented to the
759 * For backwards compatibility, this option defaults to False.
762 smbc_setOptionUrlEncodeReaddirEntries(SMBCCTX
*c
, smbc_bool b
);
765 * Get whether to use the same connection for all shares on a server.
767 * Some Windows versions appear to have a limit to the number
768 * of concurrent SESSIONs and/or TREE CONNECTions. In
769 * one-shot programs (i.e. the program runs and then quickly
770 * ends, thereby shutting down all connections), it is
771 * probably reasonable to establish a new connection for each
772 * share. In long-running applications, the limitation can be
773 * avoided by using only a single connection to each server,
774 * and issuing a new TREE CONNECT when the share is accessed.
777 smbc_getOptionOneSharePerServer(SMBCCTX
*c
);
780 * Set whether to use the same connection for all shares on a server.
782 * Some Windows versions appear to have a limit to the number
783 * of concurrent SESSIONs and/or TREE CONNECTions. In
784 * one-shot programs (i.e. the program runs and then quickly
785 * ends, thereby shutting down all connections), it is
786 * probably reasonable to establish a new connection for each
787 * share. In long-running applications, the limitation can be
788 * avoided by using only a single connection to each server,
789 * and issuing a new TREE CONNECT when the share is accessed.
792 smbc_setOptionOneSharePerServer(SMBCCTX
*c
, smbc_bool b
);
794 /** Get whether to enable use of kerberos */
796 smbc_getOptionUseKerberos(SMBCCTX
*c
);
798 /** Set whether to enable use of kerberos */
800 smbc_setOptionUseKerberos(SMBCCTX
*c
, smbc_bool b
);
802 /** Get whether to fallback after kerberos */
804 smbc_getOptionFallbackAfterKerberos(SMBCCTX
*c
);
806 /** Set whether to fallback after kerberos */
808 smbc_setOptionFallbackAfterKerberos(SMBCCTX
*c
, smbc_bool b
);
810 /** Get whether to automatically select anonymous login */
812 smbc_getOptionNoAutoAnonymousLogin(SMBCCTX
*c
);
814 /** Set whether to automatically select anonymous login */
816 smbc_setOptionNoAutoAnonymousLogin(SMBCCTX
*c
, smbc_bool b
);
818 /** Get whether to enable use of the winbind ccache */
820 smbc_getOptionUseCCache(SMBCCTX
*c
);
822 /** Set whether to enable use of the winbind ccache */
824 smbc_setOptionUseCCache(SMBCCTX
*c
, smbc_bool b
);
826 /** Get indication that the password supplied is the NT hash */
828 smbc_getOptionUseNTHash(SMBCCTX
*c
);
830 /** Set indication that the password supplied is the NT hash */
832 smbc_setOptionUseNTHash(SMBCCTX
*c
, smbc_bool b
);
835 * @brief Set the 'client min protocol' and the 'client max protocol'.
837 * IMPORTANT: This overrrides the values 'client min protocol' and 'client max
838 * protocol' set in the smb.conf file!
840 * @param[in] c The smbc context to use.
842 * @param[in] min_proto The minimal protocol to use or NULL for leaving it
845 * @param[in] max_proto The maximum protocol to use or NULL for leaving it
848 * @returns true for success, false otherwise
851 smbc_setOptionProtocols(SMBCCTX
*c
, const char *min_proto
, const char *max_proto
);
853 /*************************************
854 * Getters and setters for FUNCTIONS *
855 *************************************/
857 /** Get the function for obtaining authentication data */
858 smbc_get_auth_data_fn
smbc_getFunctionAuthData(SMBCCTX
*c
);
860 /** Set the function for obtaining authentication data */
861 void smbc_setFunctionAuthData(SMBCCTX
*c
, smbc_get_auth_data_fn fn
);
863 /** Get the new-style authentication function which includes the context. */
864 smbc_get_auth_data_with_context_fn
865 smbc_getFunctionAuthDataWithContext(SMBCCTX
*c
);
867 /** Set the new-style authentication function which includes the context. */
869 smbc_setFunctionAuthDataWithContext(SMBCCTX
*c
,
870 smbc_get_auth_data_with_context_fn fn
);
872 /** Get the function for checking if a server is still good */
873 smbc_check_server_fn
smbc_getFunctionCheckServer(SMBCCTX
*c
);
875 /** Set the function for checking if a server is still good */
876 void smbc_setFunctionCheckServer(SMBCCTX
*c
, smbc_check_server_fn fn
);
878 /** Get the function for removing a server if unused */
879 smbc_remove_unused_server_fn
smbc_getFunctionRemoveUnusedServer(SMBCCTX
*c
);
881 /** Set the function for removing a server if unused */
882 void smbc_setFunctionRemoveUnusedServer(SMBCCTX
*c
,
883 smbc_remove_unused_server_fn fn
);
885 /** Get the function for adding a cached server */
886 smbc_add_cached_srv_fn
smbc_getFunctionAddCachedServer(SMBCCTX
*c
);
888 /** Set the function for adding a cached server */
889 void smbc_setFunctionAddCachedServer(SMBCCTX
*c
, smbc_add_cached_srv_fn fn
);
891 /** Get the function for server cache lookup */
892 smbc_get_cached_srv_fn
smbc_getFunctionGetCachedServer(SMBCCTX
*c
);
894 /** Set the function for server cache lookup */
895 void smbc_setFunctionGetCachedServer(SMBCCTX
*c
, smbc_get_cached_srv_fn fn
);
897 /** Get the function for server cache removal */
898 smbc_remove_cached_srv_fn
smbc_getFunctionRemoveCachedServer(SMBCCTX
*c
);
900 /** Set the function for server cache removal */
901 void smbc_setFunctionRemoveCachedServer(SMBCCTX
*c
,
902 smbc_remove_cached_srv_fn fn
);
905 * Get the function for server cache purging. This function tries to
906 * remove all cached servers (e.g. on disconnect)
908 smbc_purge_cached_fn
smbc_getFunctionPurgeCachedServers(SMBCCTX
*c
);
911 * Set the function for server cache purging. This function tries to
912 * remove all cached servers (e.g. on disconnect)
914 void smbc_setFunctionPurgeCachedServers(SMBCCTX
*c
,
915 smbc_purge_cached_fn fn
);
917 /** Get the function to store private data of the server cache */
918 struct smbc_server_cache
* smbc_getServerCacheData(SMBCCTX
*c
);
920 /** Set the function to store private data of the server cache */
921 void smbc_setServerCacheData(SMBCCTX
*c
, struct smbc_server_cache
* cache
);
925 /*****************************************************************
926 * Callable functions for files. *
927 * Each callable has a function signature typedef, a declaration *
928 * for the getter, and a declaration for the setter. *
929 *****************************************************************/
931 typedef SMBCFILE
* (*smbc_open_fn
)(SMBCCTX
*c
,
935 smbc_open_fn
smbc_getFunctionOpen(SMBCCTX
*c
);
936 void smbc_setFunctionOpen(SMBCCTX
*c
, smbc_open_fn fn
);
938 typedef SMBCFILE
* (*smbc_creat_fn
)(SMBCCTX
*c
,
941 smbc_creat_fn
smbc_getFunctionCreat(SMBCCTX
*c
);
942 void smbc_setFunctionCreat(SMBCCTX
*c
, smbc_creat_fn
);
944 typedef ssize_t (*smbc_read_fn
)(SMBCCTX
*c
,
948 smbc_read_fn
smbc_getFunctionRead(SMBCCTX
*c
);
949 void smbc_setFunctionRead(SMBCCTX
*c
, smbc_read_fn fn
);
951 typedef ssize_t (*smbc_write_fn
)(SMBCCTX
*c
,
955 smbc_write_fn
smbc_getFunctionWrite(SMBCCTX
*c
);
956 void smbc_setFunctionWrite(SMBCCTX
*c
, smbc_write_fn fn
);
958 typedef off_t (*smbc_splice_fn
)(SMBCCTX
*c
,
962 int (*splice_cb
)(off_t n
, void *priv
),
964 smbc_splice_fn
smbc_getFunctionSplice(SMBCCTX
*c
);
965 void smbc_setFunctionSplice(SMBCCTX
*c
, smbc_splice_fn fn
);
967 typedef int (*smbc_unlink_fn
)(SMBCCTX
*c
,
969 smbc_unlink_fn
smbc_getFunctionUnlink(SMBCCTX
*c
);
970 void smbc_setFunctionUnlink(SMBCCTX
*c
, smbc_unlink_fn fn
);
972 typedef int (*smbc_rename_fn
)(SMBCCTX
*ocontext
,
976 smbc_rename_fn
smbc_getFunctionRename(SMBCCTX
*c
);
977 void smbc_setFunctionRename(SMBCCTX
*c
, smbc_rename_fn fn
);
979 typedef off_t (*smbc_lseek_fn
)(SMBCCTX
*c
,
983 smbc_lseek_fn
smbc_getFunctionLseek(SMBCCTX
*c
);
984 void smbc_setFunctionLseek(SMBCCTX
*c
, smbc_lseek_fn fn
);
986 typedef int (*smbc_stat_fn
)(SMBCCTX
*c
,
989 smbc_stat_fn
smbc_getFunctionStat(SMBCCTX
*c
);
990 void smbc_setFunctionStat(SMBCCTX
*c
, smbc_stat_fn fn
);
992 typedef int (*smbc_fstat_fn
)(SMBCCTX
*c
,
995 smbc_fstat_fn
smbc_getFunctionFstat(SMBCCTX
*c
);
996 void smbc_setFunctionFstat(SMBCCTX
*c
, smbc_fstat_fn fn
);
998 typedef int (*smbc_statvfs_fn
)(SMBCCTX
*c
,
1000 struct statvfs
*st
);
1001 smbc_statvfs_fn
smbc_getFunctionStatVFS(SMBCCTX
*c
);
1002 void smbc_setFunctionStatVFS(SMBCCTX
*c
, smbc_statvfs_fn fn
);
1004 typedef int (*smbc_fstatvfs_fn
)(SMBCCTX
*c
,
1006 struct statvfs
*st
);
1007 smbc_fstatvfs_fn
smbc_getFunctionFstatVFS(SMBCCTX
*c
);
1008 void smbc_setFunctionFstatVFS(SMBCCTX
*c
, smbc_fstatvfs_fn fn
);
1010 typedef int (*smbc_ftruncate_fn
)(SMBCCTX
*c
,
1013 smbc_ftruncate_fn
smbc_getFunctionFtruncate(SMBCCTX
*c
);
1014 void smbc_setFunctionFtruncate(SMBCCTX
*c
, smbc_ftruncate_fn fn
);
1016 typedef int (*smbc_close_fn
)(SMBCCTX
*c
,
1018 smbc_close_fn
smbc_getFunctionClose(SMBCCTX
*c
);
1019 void smbc_setFunctionClose(SMBCCTX
*c
, smbc_close_fn fn
);
1023 /*****************************************************************
1024 * Callable functions for directories. *
1025 * Each callable has a function signature typedef, a declaration *
1026 * for the getter, and a declaration for the setter. *
1027 *****************************************************************/
1029 typedef SMBCFILE
* (*smbc_opendir_fn
)(SMBCCTX
*c
,
1031 smbc_opendir_fn
smbc_getFunctionOpendir(SMBCCTX
*c
);
1032 void smbc_setFunctionOpendir(SMBCCTX
*c
, smbc_opendir_fn fn
);
1034 typedef int (*smbc_closedir_fn
)(SMBCCTX
*c
,
1036 smbc_closedir_fn
smbc_getFunctionClosedir(SMBCCTX
*c
);
1037 void smbc_setFunctionClosedir(SMBCCTX
*c
, smbc_closedir_fn fn
);
1039 typedef struct smbc_dirent
* (*smbc_readdir_fn
)(SMBCCTX
*c
,
1041 smbc_readdir_fn
smbc_getFunctionReaddir(SMBCCTX
*c
);
1042 void smbc_setFunctionReaddir(SMBCCTX
*c
, smbc_readdir_fn fn
);
1044 typedef const struct libsmb_file_info
* (*smbc_readdirplus_fn
)(SMBCCTX
*c
,
1046 smbc_readdirplus_fn
smbc_getFunctionReaddirPlus(SMBCCTX
*c
);
1047 void smbc_setFunctionReaddirPlus(SMBCCTX
*c
, smbc_readdirplus_fn fn
);
1049 typedef const struct libsmb_file_info
* (*smbc_readdirplus2_fn
)(SMBCCTX
*c
,
1052 smbc_readdirplus2_fn
smbc_getFunctionReaddirPlus2(SMBCCTX
*c
);
1053 void smbc_setFunctionReaddirPlus2(SMBCCTX
*c
, smbc_readdirplus2_fn fn
);
1055 typedef int (*smbc_getdents_fn
)(SMBCCTX
*c
,
1057 struct smbc_dirent
*dirp
,
1059 smbc_getdents_fn
smbc_getFunctionGetdents(SMBCCTX
*c
);
1060 void smbc_setFunctionGetdents(SMBCCTX
*c
, smbc_getdents_fn fn
);
1062 typedef int (*smbc_mkdir_fn
)(SMBCCTX
*c
,
1065 smbc_mkdir_fn
smbc_getFunctionMkdir(SMBCCTX
*c
);
1066 void smbc_setFunctionMkdir(SMBCCTX
*c
, smbc_mkdir_fn fn
);
1068 typedef int (*smbc_rmdir_fn
)(SMBCCTX
*c
,
1070 smbc_rmdir_fn
smbc_getFunctionRmdir(SMBCCTX
*c
);
1071 void smbc_setFunctionRmdir(SMBCCTX
*c
, smbc_rmdir_fn fn
);
1073 typedef off_t (*smbc_telldir_fn
)(SMBCCTX
*c
,
1075 smbc_telldir_fn
smbc_getFunctionTelldir(SMBCCTX
*c
);
1076 void smbc_setFunctionTelldir(SMBCCTX
*c
, smbc_telldir_fn fn
);
1078 typedef int (*smbc_lseekdir_fn
)(SMBCCTX
*c
,
1081 smbc_lseekdir_fn
smbc_getFunctionLseekdir(SMBCCTX
*c
);
1082 void smbc_setFunctionLseekdir(SMBCCTX
*c
, smbc_lseekdir_fn fn
);
1084 typedef int (*smbc_fstatdir_fn
)(SMBCCTX
*c
,
1087 smbc_fstatdir_fn
smbc_getFunctionFstatdir(SMBCCTX
*c
);
1088 void smbc_setFunctionFstatdir(SMBCCTX
*c
, smbc_fstatdir_fn fn
);
1090 #define SMBC_NOTIFY_ACTION_ADDED 1
1091 #define SMBC_NOTIFY_ACTION_REMOVED 2
1092 #define SMBC_NOTIFY_ACTION_MODIFIED 3
1093 #define SMBC_NOTIFY_ACTION_OLD_NAME 4
1094 #define SMBC_NOTIFY_ACTION_NEW_NAME 5
1095 #define SMBC_NOTIFY_ACTION_ADDED_STREAM 6
1096 #define SMBC_NOTIFY_ACTION_REMOVED_STREAM 7
1097 #define SMBC_NOTIFY_ACTION_MODIFIED_STREAM 8
1099 struct smbc_notify_callback_action
{
1101 const char *filename
;
1104 typedef int (*smbc_notify_callback_fn
)(
1105 const struct smbc_notify_callback_action
*actions
,
1106 size_t num_actions
, void *private_data
);
1108 typedef int (*smbc_notify_fn
)(SMBCCTX
*c
, SMBCFILE
*dir
, smbc_bool recursive
,
1109 uint32_t completion_filter
,
1110 unsigned callback_timeout_ms
,
1111 smbc_notify_callback_fn cb
, void *private_data
);
1112 smbc_notify_fn
smbc_getFunctionNotify(SMBCCTX
*c
);
1113 void smbc_setFunctionNotify(SMBCCTX
*c
, smbc_notify_fn fn
);
1116 /*****************************************************************
1117 * Callable functions applicable to both files and directories. *
1118 * Each callable has a function signature typedef, a declaration *
1119 * for the getter, and a declaration for the setter. *
1120 *****************************************************************/
1122 typedef int (*smbc_chmod_fn
)(SMBCCTX
*c
,
1125 smbc_chmod_fn
smbc_getFunctionChmod(SMBCCTX
*c
);
1126 void smbc_setFunctionChmod(SMBCCTX
*c
, smbc_chmod_fn fn
);
1128 typedef int (*smbc_utimes_fn
)(SMBCCTX
*c
,
1130 struct timeval
*tbuf
);
1131 smbc_utimes_fn
smbc_getFunctionUtimes(SMBCCTX
*c
);
1132 void smbc_setFunctionUtimes(SMBCCTX
*c
, smbc_utimes_fn fn
);
1134 typedef int (*smbc_setxattr_fn
)(SMBCCTX
*context
,
1140 smbc_setxattr_fn
smbc_getFunctionSetxattr(SMBCCTX
*c
);
1141 void smbc_setFunctionSetxattr(SMBCCTX
*c
, smbc_setxattr_fn fn
);
1143 typedef int (*smbc_getxattr_fn
)(SMBCCTX
*context
,
1148 smbc_getxattr_fn
smbc_getFunctionGetxattr(SMBCCTX
*c
);
1149 void smbc_setFunctionGetxattr(SMBCCTX
*c
, smbc_getxattr_fn fn
);
1151 typedef int (*smbc_removexattr_fn
)(SMBCCTX
*context
,
1154 smbc_removexattr_fn
smbc_getFunctionRemovexattr(SMBCCTX
*c
);
1155 void smbc_setFunctionRemovexattr(SMBCCTX
*c
, smbc_removexattr_fn fn
);
1157 typedef int (*smbc_listxattr_fn
)(SMBCCTX
*context
,
1161 smbc_listxattr_fn
smbc_getFunctionListxattr(SMBCCTX
*c
);
1162 void smbc_setFunctionListxattr(SMBCCTX
*c
, smbc_listxattr_fn fn
);
1166 /*****************************************************************
1167 * Callable functions for printing. *
1168 * Each callable has a function signature typedef, a declaration *
1169 * for the getter, and a declaration for the setter. *
1170 *****************************************************************/
1172 typedef int (*smbc_print_file_fn
)(SMBCCTX
*c_file
,
1175 const char *printq
);
1176 smbc_print_file_fn
smbc_getFunctionPrintFile(SMBCCTX
*c
);
1177 void smbc_setFunctionPrintFile(SMBCCTX
*c
, smbc_print_file_fn fn
);
1179 typedef SMBCFILE
* (*smbc_open_print_job_fn
)(SMBCCTX
*c
,
1181 smbc_open_print_job_fn
smbc_getFunctionOpenPrintJob(SMBCCTX
*c
);
1182 void smbc_setFunctionOpenPrintJob(SMBCCTX
*c
,
1183 smbc_open_print_job_fn fn
);
1185 typedef int (*smbc_list_print_jobs_fn
)(SMBCCTX
*c
,
1187 smbc_list_print_job_fn fn
);
1188 smbc_list_print_jobs_fn
smbc_getFunctionListPrintJobs(SMBCCTX
*c
);
1189 void smbc_setFunctionListPrintJobs(SMBCCTX
*c
,
1190 smbc_list_print_jobs_fn fn
);
1192 typedef int (*smbc_unlink_print_job_fn
)(SMBCCTX
*c
,
1195 smbc_unlink_print_job_fn
smbc_getFunctionUnlinkPrintJob(SMBCCTX
*c
);
1196 void smbc_setFunctionUnlinkPrintJob(SMBCCTX
*c
,
1197 smbc_unlink_print_job_fn fn
);
1201 * Create a new SBMCCTX (a context).
1203 * Must be called before the context is passed to smbc_context_init()
1205 * @return The given SMBCCTX pointer on success, NULL on error with errno set:
1206 * - ENOMEM Out of memory
1208 * @see smbc_free_context(), smbc_init_context()
1210 * @note Do not forget to smbc_init_context() the returned SMBCCTX pointer !
1212 SMBCCTX
* smbc_new_context(void);
1215 * Delete a SBMCCTX (a context) acquired from smbc_new_context().
1217 * The context will be deleted if possible.
1219 * @param context A pointer to a SMBCCTX obtained from smbc_new_context()
1221 * @param shutdown_ctx If 1, all connections and files will be closed even if they are busy.
1224 * @return Returns 0 on succes. Returns 1 on failure with errno set:
1225 * - EBUSY Server connections are still used, Files are open or cache
1226 * could not be purged
1227 * - EBADF context == NULL
1229 * @see smbc_new_context()
1231 * @note It is advised to clean up all the contexts with shutdown_ctx set to 1
1232 * just before exit()'ing. When shutdown_ctx is 0, this function can be
1233 * use in periodical cleanup functions for example.
1235 int smbc_free_context(SMBCCTX
* context
, int shutdown_ctx
);
1240 * @deprecated. Use smbc_setOption*() functions instead.
1243 smbc_option_set(SMBCCTX
*context
,
1245 ... /* option_value */);
1248 * @deprecated. Use smbc_getOption*() functions instead.
1251 smbc_option_get(SMBCCTX
*context
,
1255 * Initialize a SBMCCTX (a context).
1257 * Must be called before using any SMBCCTX API function
1259 * @param context A pointer to a SMBCCTX obtained from smbc_new_context()
1261 * @return A pointer to the given SMBCCTX on success,
1262 * NULL on error with errno set:
1263 * - EBADF NULL context given
1264 * - ENOMEM Out of memory
1265 * - ENOENT The smb.conf file would not load
1267 * @see smbc_new_context()
1269 * @note my_context = smbc_init_context(smbc_new_context())
1270 * is perfectly safe, but it might leak memory on
1271 * smbc_context_init() failure. Avoid this.
1272 * You'll have to call smbc_free_context() yourself
1276 SMBCCTX
* smbc_init_context(SMBCCTX
* context
);
1279 * Initialize the samba client library.
1281 * Must be called before using any of the smbclient API function
1283 * @param fn The function that will be called to obtaion
1284 * authentication credentials.
1286 * @param debug Allows caller to set the debug level. Can be
1287 * changed in smb.conf file. Allows caller to set
1288 * debugging if no smb.conf.
1290 * @return 0 on success, < 0 on error with errno set:
1291 * - ENOMEM Out of memory
1292 * - ENOENT The smb.conf file would not load
1296 int smbc_init(smbc_get_auth_data_fn fn
, int debug
);
1299 * Set or retrieve the compatibility library's context pointer
1301 * @param context New context to use, or NULL. If a new context is provided,
1302 * it must have allocated with smbc_new_context() and
1303 * initialized with smbc_init_context(), followed, optionally,
1304 * by some manual changes to some of the non-internal fields.
1306 * @return The old context.
1308 * @see smbc_new_context(), smbc_init_context(), smbc_init()
1310 * @note This function may be called prior to smbc_init() to force
1311 * use of the next context without any internal calls to
1312 * smbc_new_context() or smbc_init_context(). It may also
1313 * be called after smbc_init() has already called those two
1314 * functions, to replace the existing context with a new one.
1315 * Care should be taken, in this latter case, to ensure that
1316 * the server cache and any data allocated by the
1317 * authentication functions have been freed, if necessary.
1320 SMBCCTX
* smbc_set_context(SMBCCTX
* new_context
);
1323 * Open a file on an SMB server.
1325 * @param furl The smb url of the file to be opened.
1327 * @param flags Is one of O_RDONLY, O_WRONLY or O_RDWR which
1328 * request opening the file read-only,write-only
1329 * or read/write. flags may also be bitwise-or'd with
1330 * one or more of the following:
1331 * O_CREAT - If the file does not exist it will be
1333 * O_EXCL - When used with O_CREAT, if the file
1334 * already exists it is an error and the open will
1336 * O_TRUNC - If the file already exists it will be
1338 * O_APPEND The file is opened in append mode
1340 * @param mode mode specifies the permissions to use if a new
1341 * file is created. It is modified by the
1342 * process's umask in the usual way: the permissions
1343 * of the created file are (mode & ~umask)
1345 * Not currently use, but there for future use.
1346 * We will map this to SYSTEM, HIDDEN, etc bits
1347 * that reverses the mapping that smbc_fstat does.
1349 * @return Valid file handle, < 0 on error with errno set:
1350 * - ENOMEM Out of memory
1351 * - EINVAL if an invalid parameter passed, like no
1352 * file, or smbc_init not called.
1353 * - EEXIST pathname already exists and O_CREAT and
1355 * - EISDIR pathname refers to a directory and
1356 * the access requested involved writing.
1357 * - EACCES The requested access to the file is not
1359 * - ENODEV The requested share does not exist
1360 * - ENOTDIR A file on the path is not a directory
1361 * - ENOENT A directory component in pathname does
1366 * @note This call uses an underlying routine that may create
1367 * a new connection to the server specified in the URL.
1368 * If the credentials supplied in the URL, or via the
1369 * auth_fn in the smbc_init call, fail, this call will
1370 * try again with an empty username and password. This
1371 * often gets mapped to the guest account on some machines.
1374 int smbc_open(const char *furl
, int flags
, mode_t mode
);
1377 * Create a file on an SMB server.
1379 * Same as calling smbc_open() with flags = O_CREAT|O_WRONLY|O_TRUNC
1381 * @param furl The smb url of the file to be created
1383 * @param mode mode specifies the permissions to use if a new
1384 * file is created. It is modified by the
1385 * process's umask in the usual way: the permissions
1386 * of the created file are (mode & ~umask)
1388 * NOTE, the above is not true. We are dealing with
1389 * an SMB server, which has no concept of a umask!
1391 * @return Valid file handle, < 0 on error with errno set:
1392 * - ENOMEM Out of memory
1393 * - EINVAL if an invalid parameter passed, like no
1394 * file, or smbc_init not called.
1395 * - EEXIST pathname already exists and O_CREAT and
1397 * - EISDIR pathname refers to a directory and
1398 * the access requested involved writing.
1399 * - EACCES The requested access to the file is not
1401 * - ENOENT A directory component in pathname does
1403 * - ENODEV The requested share does not exist.
1408 int smbc_creat(const char *furl
, mode_t mode
);
1411 * Read from a file using an opened file handle.
1413 * @param fd Open file handle from smbc_open() or smbc_creat()
1415 * @param buf Pointer to buffer to receive read data
1417 * @param bufsize Size of buf in bytes
1419 * @return Number of bytes read;
1421 * < 0 on error, with errno set:
1422 * - EISDIR fd refers to a directory
1423 * - EBADF fd is not a valid file descriptor or
1424 * is not open for reading.
1425 * - EINVAL fd is attached to an object which is
1426 * unsuitable for reading, or no buffer passed or
1427 * smbc_init not called.
1429 * @see smbc_open(), smbc_write()
1432 ssize_t
smbc_read(int fd
, void *buf
, size_t bufsize
);
1436 * Write to a file using an opened file handle.
1438 * @param fd Open file handle from smbc_open() or smbc_creat()
1440 * @param buf Pointer to buffer to recieve read data
1442 * @param bufsize Size of buf in bytes
1444 * @return Number of bytes written, < 0 on error with errno set:
1445 * - EISDIR fd refers to a directory.
1446 * - EBADF fd is not a valid file descriptor or
1447 * is not open for reading.
1448 * - EINVAL fd is attached to an object which is
1449 * unsuitable for reading, or no buffer passed or
1450 * smbc_init not called.
1452 * @see smbc_open(), smbc_read()
1455 ssize_t
smbc_write(int fd
, const void *buf
, size_t bufsize
);
1459 * Seek to a specific location in a file.
1461 * @param fd Open file handle from smbc_open() or smbc_creat()
1463 * @param offset Offset in bytes from whence
1465 * @param whence A location in the file:
1466 * - SEEK_SET The offset is set to offset bytes from
1467 * the beginning of the file
1468 * - SEEK_CUR The offset is set to current location
1469 * plus offset bytes.
1470 * - SEEK_END The offset is set to the size of the
1471 * file plus offset bytes.
1473 * @return Upon successful completion, lseek returns the
1474 * resulting offset location as measured in bytes
1475 * from the beginning of the file. Otherwise, a value
1476 * of (off_t)-1 is returned and errno is set to
1477 * indicate the error:
1478 * - EBADF Fildes is not an open file descriptor.
1479 * - EINVAL Whence is not a proper value or smbc_init
1482 * @todo Are all the whence values really supported?
1484 * @todo Are errno values complete and correct?
1486 off_t
smbc_lseek(int fd
, off_t offset
, int whence
);
1490 * Close an open file handle.
1492 * @param fd The file handle to close
1494 * @return 0 on success, < 0 on error with errno set:
1495 * - EBADF fd isn't a valid open file descriptor
1496 * - EINVAL smbc_init() failed or has not been called
1498 * @see smbc_open(), smbc_creat()
1500 int smbc_close(int fd
);
1503 /**@ingroup directory
1504 * Unlink (delete) a file or directory.
1506 * @param furl The smb url of the file to delete
1508 * @return 0 on success, < 0 on error with errno set:
1509 * - EACCES or EPERM Write access to the directory
1510 * containing pathname is not allowed or one
1511 * of the directories in pathname did not allow
1512 * search (execute) permission
1513 * - ENOENT A directory component in pathname does
1515 * - EINVAL NULL was passed in the file param or
1516 * smbc_init not called.
1517 * - EACCES You do not have access to the file
1518 * - ENOMEM Insufficient kernel memory was available
1520 * @see smbc_rmdir()s
1522 * @todo Are errno values complete and correct?
1524 int smbc_unlink(const char *furl
);
1527 /**@ingroup directory
1528 * Rename or move a file or directory.
1530 * @param ourl The original smb url (source url) of file or
1531 * directory to be moved
1533 * @param nurl The new smb url (destination url) of the file
1534 * or directory after the move. Currently nurl must
1535 * be on the same share as ourl.
1537 * @return 0 on success, < 0 on error with errno set:
1538 * - EISDIR nurl is an existing directory, but ourl is
1540 * - EEXIST nurl is a non-empty directory,
1541 * i.e., contains entries other than "." and ".."
1542 * - EINVAL The new url contained a path prefix
1543 * of the old, or, more generally, an attempt was
1544 * made to make a directory a subdirectory of itself
1545 * or smbc_init not called.
1546 * - ENOTDIR A component used as a directory in ourl
1547 * or nurl path is not, in fact, a directory. Or,
1548 * ourl is a directory, and newpath exists but is not
1550 * - EACCES or EPERM Write access to the directory
1551 * containing ourl or nurl is not allowed for the
1552 * process's effective uid, or one of the
1553 * directories in ourl or nurl did not allow search
1554 * (execute) permission, or ourl was a directory
1555 * and did not allow write permission.
1556 * - ENOENT A directory component in ourl or nurl
1558 * - EXDEV Rename across shares not supported.
1559 * - ENOMEM Insufficient kernel memory was available.
1560 * - EEXIST The target file, nurl, already exists.
1563 * @todo Are we going to support copying when urls are not on the same
1564 * share? I say no... NOTE. I agree for the moment.
1567 int smbc_rename(const char *ourl
, const char *nurl
);
1570 /**@ingroup directory
1571 * Open a directory used to obtain directory entries.
1573 * @param durl The smb url of the directory to open
1575 * @return Valid directory handle. < 0 on error with errno set:
1576 * - EACCES Permission denied.
1577 * - EINVAL A NULL file/URL was passed, or the URL would
1578 * not parse, or was of incorrect form or smbc_init not
1580 * - ENOENT durl does not exist, or name is an
1581 * - ENOMEM Insufficient memory to complete the
1583 * - ENOTDIR name is not a directory.
1584 * - EPERM the workgroup could not be found.
1585 * - ENODEV the workgroup or server could not be found.
1587 * @see smbc_getdents(), smbc_readdir(), smbc_closedir()
1590 int smbc_opendir(const char *durl
);
1593 /**@ingroup directory
1594 * Close a directory handle opened by smbc_opendir().
1596 * @param dh Directory handle to close
1598 * @return 0 on success, < 0 on error with errno set:
1599 * - EBADF dh is an invalid directory handle
1601 * @see smbc_opendir()
1603 int smbc_closedir(int dh
);
1606 /**@ingroup directory
1607 * Get multiple directory entries.
1609 * smbc_getdents() reads as many dirent structures from the an open
1610 * directory handle into a specified memory area as will fit.
1612 * @param dh Valid directory as returned by smbc_opendir()
1614 * @param dirp pointer to buffer that will receive the directory
1617 * @param count The size of the dirp buffer in bytes
1619 * @returns If any dirents returned, return will indicate the
1620 * total size. If there were no more dirents available,
1621 * 0 is returned. < 0 indicates an error.
1622 * - EBADF Invalid directory handle
1623 * - EINVAL Result buffer is too small or smbc_init
1625 * - ENOENT No such directory.
1626 * @see , smbc_dirent, smbc_readdir(), smbc_open()
1628 * @todo Are errno values complete and correct?
1630 * @todo Add example code so people know how to parse buffers.
1632 int smbc_getdents(unsigned int dh
, struct smbc_dirent
*dirp
, int count
);
1635 /**@ingroup directory
1636 * Get a single directory entry.
1638 * @param dh Valid directory as returned by smbc_opendir()
1640 * @return A pointer to a smbc_dirent structure, or NULL if an
1641 * error occurs or end-of-directory is reached:
1642 * - EBADF Invalid directory handle
1643 * - EINVAL smbc_init() failed or has not been called
1645 * @see smbc_dirent, smbc_getdents(), smbc_open()
1647 struct smbc_dirent
* smbc_readdir(unsigned int dh
);
1649 /**@ingroup directory
1650 * Works similar as smbc_readdir but returns more information about file.
1652 * @param dh Valid directory as returned by smbc_opendir()
1654 * @return A const pointer to a libsmb_file_info structure,
1655 * or NULL if an error occurs or end-of-directory is reached:
1656 * - EBADF Invalid directory handle
1657 * - EINVAL smbc_init() failed or has not been called
1659 * @see smbc_open(), smbc_readdir()
1661 const struct libsmb_file_info
*smbc_readdirplus(unsigned int dh
);
1663 /**@ingroup directory
1664 * Works similar as smbc_readdirplus as well as fills up stat structure if
1667 * @param dh Valid directory as returned by smbc_opendir()
1669 * @param stat Pointer to stat structure which will receive the
1670 * information. If this pointer is null the call
1671 * is identical to smbc_readdirplus.
1673 * @return A const pointer to a libsmb_file_info structure,
1674 * or NULL if an error occurs or end-of-directory is reached:
1675 * - EBADF Invalid directory handle
1676 * - EINVAL smbc_init() failed or has not been called
1678 * @see smbc_open(), smbc_readdir(), smbc_readdirplus2()
1680 const struct libsmb_file_info
*smbc_readdirplus2(unsigned int dh
,
1683 /**@ingroup directory
1684 * Get the current directory offset.
1686 * smbc_telldir() may be used in conjunction with smbc_readdir() and
1689 * @param dh Valid directory as returned by smbc_opendir()
1691 * @return The current location in the directory stream or -1
1692 * if an error occur. The current location is not
1693 * an offset. Becuase of the implementation, it is a
1694 * handle that allows the library to find the entry
1696 * - EBADF dh is not a valid directory handle
1697 * - EINVAL smbc_init() failed or has not been called
1698 * - ENOTDIR if dh is not a directory
1700 * @see smbc_readdir()
1703 off_t
smbc_telldir(int dh
);
1706 /**@ingroup directory
1707 * lseek on directories.
1709 * smbc_lseekdir() may be used in conjunction with smbc_readdir() and
1710 * smbc_telldir(). (rewind by smbc_lseekdir(fd, NULL))
1712 * @param fd Valid directory as returned by smbc_opendir()
1714 * @param offset The offset (as returned by smbc_telldir). Can be
1715 * NULL, in which case we will rewind
1717 * @return 0 on success, -1 on failure
1718 * - EBADF dh is not a valid directory handle
1719 * - ENOTDIR if dh is not a directory
1720 * - EINVAL offset did not refer to a valid dirent or
1721 * smbc_init not called.
1723 * @see smbc_telldir()
1726 * @todo In what does the reture and errno values mean?
1728 int smbc_lseekdir(int fd
, off_t offset
);
1730 /**@ingroup directory
1731 * Create a directory.
1733 * @param durl The url of the directory to create
1735 * @param mode Specifies the permissions to use. It is modified
1736 * by the process's umask in the usual way: the
1737 * permissions of the created file are (mode & ~umask).
1739 * @return 0 on success, < 0 on error with errno set:
1740 * - EEXIST directory url already exists
1741 * - EACCES The parent directory does not allow write
1742 * permission to the process, or one of the directories
1743 * - ENOENT A directory component in pathname does not
1745 * - EINVAL NULL durl passed or smbc_init not called.
1746 * - ENOMEM Insufficient memory was available.
1751 int smbc_mkdir(const char *durl
, mode_t mode
);
1754 /**@ingroup directory
1755 * Remove a directory.
1757 * @param durl The smb url of the directory to remove
1759 * @return 0 on success, < 0 on error with errno set:
1760 * - EACCES or EPERM Write access to the directory
1761 * containing pathname was not allowed.
1762 * - EINVAL durl is NULL or smbc_init not called.
1763 * - ENOENT A directory component in pathname does not
1765 * - ENOTEMPTY directory contains entries.
1766 * - ENOMEM Insufficient kernel memory was available.
1768 * @see smbc_mkdir(), smbc_unlink()
1770 * @todo Are errno values complete and correct?
1772 int smbc_rmdir(const char *durl
);
1774 /**@ingroup directory
1775 * Request directory notifications
1777 * @param dh Valid directory as returned by smbc_opendir()
1779 * @param recursive Are changes in subdirectories wanted?
1781 * @param completion_filter Bitwise-or of the SMBC_NOTIFY_CHANGE_*
1782 * events that are interesting
1784 * @param callback_timeout_ms If set to non-zero, interval in milliseconds
1785 * that "cb" will be called with 0 actions.
1786 * This gives "cb" the chance to cancel the
1789 * @param cb Callback functions taking events. If "cb"
1790 * returns nonzero, smbc_notify will return.
1792 * @param private_data Pointer given to "cb"
1794 * @return 0 on success, -1 on error with errno set
1796 * @see smbc_opendir(), smbc_closedir()
1799 #define SMBC_NOTIFY_CHANGE_FILE_NAME 0x001
1800 #define SMBC_NOTIFY_CHANGE_DIR_NAME 0x002
1801 #define SMBC_NOTIFY_CHANGE_ATTRIBUTES 0x004
1802 #define SMBC_NOTIFY_CHANGE_SIZE 0x008
1803 #define SMBC_NOTIFY_CHANGE_LAST_WRITE 0x010
1804 #define SMBC_NOTIFY_CHANGE_LAST_ACCESS 0x020
1805 #define SMBC_NOTIFY_CHANGE_CREATION 0x040
1806 #define SMBC_NOTIFY_CHANGE_EA 0x080
1807 #define SMBC_NOTIFY_CHANGE_SECURITY 0x100
1808 #define SMBC_NOTIFY_CHANGE_STREAM_NAME 0x200
1809 #define SMBC_NOTIFY_CHANGE_STREAM_SIZE 0x400
1810 #define SMBC_NOTIFY_CHANGE_STREAM_WRITE 0x800
1812 int smbc_notify(int dh
, smbc_bool recursive
, uint32_t completion_filter
,
1813 unsigned callback_timeout_ms
,
1814 smbc_notify_callback_fn cb
, void *private_data
);
1816 /**@ingroup attribute
1817 * Get information about a file or directory.
1819 * @param url The smb url to get information for
1821 * @param st pointer to a buffer that will be filled with
1822 * standard Unix struct stat information.
1824 * @return 0 on success, < 0 on error with errno set:
1825 * - ENOENT A component of the path file_name does not
1827 * - EINVAL a NULL url was passed or smbc_init not called.
1828 * - EACCES Permission denied.
1829 * - ENOMEM Out of memory
1830 * - ENOTDIR The target dir, url, is not a directory.
1835 int smbc_stat(const char *url
, struct stat
*st
);
1838 /**@ingroup attribute
1839 * Get file information via an file descriptor.
1841 * @param fd Open file handle from smbc_open() or smbc_creat()
1843 * @param st pointer to a buffer that will be filled with
1844 * standard Unix struct stat information.
1846 * @return 0 on success, < 0 on error with errno set:
1847 * - EBADF filedes is bad.
1848 * - EACCES Permission denied.
1849 * - EBADF fd is not a valid file descriptor
1850 * - EINVAL Problems occurred in the underlying routines
1851 * or smbc_init not called.
1852 * - ENOMEM Out of memory
1854 * @see smbc_stat(), Unix stat()
1857 int smbc_fstat(int fd
, struct stat
*st
);
1860 /**@ingroup attribute
1861 * Get file system information for a specified path.
1863 * @param url The smb url to get information for
1865 * @param st pointer to a buffer that will be filled with
1866 * standard Unix struct statvfs information.
1868 * @return 0 on success, < 0 on error with errno set:
1869 * - EBADF filedes is bad.
1870 * - EACCES Permission denied.
1871 * - EBADF fd is not a valid file descriptor
1872 * - EINVAL Problems occurred in the underlying routines
1873 * or smbc_init not called.
1874 * - ENOMEM Out of memory
1876 * @see Unix fstatvfs()
1880 smbc_statvfs(char *url
,
1881 struct statvfs
*st
);
1883 /**@ingroup attribute
1884 * Get file system information via an file descriptor.
1886 * @param fd Open file handle from smbc_open(), smbc_creat(),
1889 * @param st pointer to a buffer that will be filled with
1890 * standard Unix struct statvfs information.
1892 * @return 0 on success, < 0 on error with errno set:
1893 * - EBADF filedes is bad.
1894 * - EACCES Permission denied.
1895 * - EBADF fd is not a valid file descriptor
1896 * - EINVAL Problems occurred in the underlying routines
1897 * or smbc_init not called.
1898 * - ENOMEM Out of memory
1900 * @see Unix fstatvfs()
1904 smbc_fstatvfs(int fd
,
1905 struct statvfs
*st
);
1908 /**@ingroup attribute
1909 * Truncate a file given a file descriptor
1911 * @param fd Open file handle from smbc_open() or smbc_creat()
1913 * @param size size to truncate the file to
1915 * @return 0 on success, < 0 on error with errno set:
1916 * - EBADF filedes is bad.
1917 * - EACCES Permission denied.
1918 * - EBADF fd is not a valid file descriptor
1919 * - EINVAL Problems occurred in the underlying routines
1920 * or smbc_init not called.
1921 * - ENOMEM Out of memory
1923 * @see , Unix ftruncate()
1926 int smbc_ftruncate(int fd
, off_t size
);
1929 /**@ingroup attribute
1930 * Change the permissions of a file.
1932 * @param url The smb url of the file or directory to change
1935 * @param mode The permissions to set:
1936 * - Put good explaination of permissions here!
1938 * @return 0 on success, < 0 on error with errno set:
1939 * - EPERM The effective UID does not match the owner
1940 * of the file, and is not zero
1941 * - ENOENT The file does not exist.
1942 * - ENOMEM Insufficient was available.
1943 * - ENOENT file or directory does not exist
1945 * @todo Actually implement this fuction?
1947 * @todo Are errno values complete and correct?
1949 int smbc_chmod(const char *url
, mode_t mode
);
1952 * @ingroup attribute
1953 * Change the last modification time on a file
1955 * @param url The smb url of the file or directory to change
1956 * the modification time of
1958 * @param tbuf An array of two timeval structures which contains,
1959 * respectively, the desired access and modification times.
1960 * NOTE: Only the tv_sec field off each timeval structure is
1961 * used. The tv_usec (microseconds) portion is ignored.
1963 * @return 0 on success, < 0 on error with errno set:
1964 * - EINVAL The client library is not properly initialized
1965 * - EPERM Permission was denied.
1968 int smbc_utimes(const char *url
, struct timeval
*tbuf
);
1972 * @ingroup attribute
1973 * Change the last modification time on a file
1975 * @param url The smb url of the file or directory to change
1976 * the modification time of
1978 * @param utbuf A pointer to a utimebuf structure which contains the
1979 * desired access and modification times.
1981 * @return 0 on success, < 0 on error with errno set:
1982 * - EINVAL The client library is not properly initialized
1983 * - ENOMEM No memory was available for internal needs
1984 * - EPERM Permission was denied.
1987 int smbc_utime(const char *fname
, struct utimbuf
*utbuf
);
1990 /**@ingroup attribute
1991 * Set extended attributes for a file. This is used for modifying a file's
1992 * security descriptor (i.e. owner, group, and access control list)
1994 * @param url The smb url of the file or directory to set extended
1997 * @param name The name of an attribute to be changed. Names are of
1998 * one of the following forms:
2000 * system.nt_sec_desc.<attribute name>
2001 * system.nt_sec_desc.*
2002 * system.nt_sec_desc.*+
2004 * where <attribute name> is one of:
2012 * acl+:<name or sid>
2014 * In the forms "system.nt_sec_desc.*" and
2015 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2016 * literal, i.e. the string is provided exactly as shown, and
2017 * the value parameter should contain a complete security
2018 * descriptor with name:value pairs separated by tabs,
2019 * commas, or newlines (not spaces!).
2021 * The plus sign ('+') indicates that SIDs should be mapped
2022 * to names. Without the plus sign, SIDs are not mapped;
2023 * rather they are simply converted to a string format.
2025 * @param value The value to be assigned to the specified attribute name.
2026 * This buffer should contain only the attribute value if the
2027 * name was of the "system.nt_sec_desc.<attribute_name>"
2028 * form. If the name was of the "system.nt_sec_desc.*" form
2029 * then a complete security descriptor, with name:value pairs
2030 * separated by tabs, commas, or newlines (not spaces!),
2031 * should be provided in this value buffer. A complete
2032 * security descriptor will contain one or more entries
2033 * selected from the following:
2035 * REVISION:<revision number>
2036 * OWNER:<sid or name>
2037 * GROUP:<sid or name>
2038 * ACL:<sid or name>:<type>/<flags>/<mask>
2040 * The revision of the ACL specifies the internal Windows NT
2041 * ACL revision for the security descriptor. If not specified
2042 * it defaults to 1. Using values other than 1 may cause
2043 * strange behaviour.
2045 * The owner and group specify the owner and group sids for
2046 * the object. If the attribute name (either '*+' with a
2047 * complete security descriptor, or individual 'owner+' or
2048 * 'group+' attribute names) ended with a plus sign, the
2049 * specified name is resolved to a SID value, using the
2050 * server on which the file or directory resides. Otherwise,
2051 * the value should be provided in SID-printable format as
2052 * S-1-x-y-z, and is used directly. The <sid or name>
2053 * associated with the ACL: attribute should be provided
2056 * @param size The number of the bytes of data in the value buffer
2058 * @param flags A bit-wise OR of zero or more of the following:
2059 * SMBC_XATTR_FLAG_CREATE -
2060 * fail if the named attribute already exists
2061 * SMBC_XATTR_FLAG_REPLACE -
2062 * fail if the attribute does not already exist
2064 * If neither flag is specified, the specified attributes
2065 * will be added or replace existing attributes of the same
2066 * name, as necessary.
2068 * @return 0 on success, < 0 on error with errno set:
2069 * - EINVAL The client library is not properly initialized
2070 * or one of the parameters is not of a correct
2072 * - ENOMEM No memory was available for internal needs
2073 * - EEXIST If the attribute already exists and the flag
2074 * SMBC_XATTR_FLAG_CREAT was specified
2075 * - ENOATTR If the attribute does not exist and the flag
2076 * SMBC_XATTR_FLAG_REPLACE was specified
2077 * - EPERM Permission was denied.
2078 * - ENOTSUP The referenced file system does not support
2079 * extended attributes
2081 * @note Attribute names are compared in a case-insensitive
2082 * fashion. All of the following are equivalent, although
2083 * the all-lower-case name is the preferred format:
2084 * system.nt_sec_desc.owner
2085 * SYSTEM.NT_SEC_DESC.OWNER
2086 * sYsTeM.nt_sEc_desc.owNER
2089 int smbc_setxattr(const char *url
,
2096 /**@ingroup attribute
2097 * Set extended attributes for a file. This is used for modifying a file's
2098 * security descriptor (i.e. owner, group, and access control list). The
2099 * POSIX function which this maps to would act on a symbolic link rather than
2100 * acting on what the symbolic link points to, but with no symbolic links in
2101 * SMB file systems, this function is functionally identical to
2104 * @param url The smb url of the file or directory to set extended
2107 * @param name The name of an attribute to be changed. Names are of
2108 * one of the following forms:
2110 * system.nt_sec_desc.<attribute name>
2111 * system.nt_sec_desc.*
2112 * system.nt_sec_desc.*+
2114 * where <attribute name> is one of:
2122 * acl+:<name or sid>
2124 * In the forms "system.nt_sec_desc.*" and
2125 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2126 * literal, i.e. the string is provided exactly as shown, and
2127 * the value parameter should contain a complete security
2128 * descriptor with name:value pairs separated by tabs,
2129 * commas, or newlines (not spaces!).
2131 * The plus sign ('+') indicates that SIDs should be mapped
2132 * to names. Without the plus sign, SIDs are not mapped;
2133 * rather they are simply converted to a string format.
2135 * @param value The value to be assigned to the specified attribute name.
2136 * This buffer should contain only the attribute value if the
2137 * name was of the "system.nt_sec_desc.<attribute_name>"
2138 * form. If the name was of the "system.nt_sec_desc.*" form
2139 * then a complete security descriptor, with name:value pairs
2140 * separated by tabs, commas, or newlines (not spaces!),
2141 * should be provided in this value buffer. A complete
2142 * security descriptor will contain one or more entries
2143 * selected from the following:
2145 * REVISION:<revision number>
2146 * OWNER:<sid or name>
2147 * GROUP:<sid or name>
2148 * ACL:<sid or name>:<type>/<flags>/<mask>
2150 * The revision of the ACL specifies the internal Windows NT
2151 * ACL revision for the security descriptor. If not specified
2152 * it defaults to 1. Using values other than 1 may cause
2153 * strange behaviour.
2155 * The owner and group specify the owner and group sids for
2156 * the object. If the attribute name (either '*+' with a
2157 * complete security descriptor, or individual 'owner+' or
2158 * 'group+' attribute names) ended with a plus sign, the
2159 * specified name is resolved to a SID value, using the
2160 * server on which the file or directory resides. Otherwise,
2161 * the value should be provided in SID-printable format as
2162 * S-1-x-y-z, and is used directly. The <sid or name>
2163 * associated with the ACL: attribute should be provided
2166 * @param size The number of the bytes of data in the value buffer
2168 * @param flags A bit-wise OR of zero or more of the following:
2169 * SMBC_XATTR_FLAG_CREATE -
2170 * fail if the named attribute already exists
2171 * SMBC_XATTR_FLAG_REPLACE -
2172 * fail if the attribute does not already exist
2174 * If neither flag is specified, the specified attributes
2175 * will be added or replace existing attributes of the same
2176 * name, as necessary.
2178 * @return 0 on success, < 0 on error with errno set:
2179 * - EINVAL The client library is not properly initialized
2180 * or one of the parameters is not of a correct
2182 * - ENOMEM No memory was available for internal needs
2183 * - EEXIST If the attribute already exists and the flag
2184 * SMBC_XATTR_FLAG_CREAT was specified
2185 * - ENOATTR If the attribute does not exist and the flag
2186 * SMBC_XATTR_FLAG_REPLACE was specified
2187 * - EPERM Permission was denied.
2188 * - ENOTSUP The referenced file system does not support
2189 * extended attributes
2191 * @note Attribute names are compared in a case-insensitive
2192 * fashion. All of the following are equivalent, although
2193 * the all-lower-case name is the preferred format:
2194 * system.nt_sec_desc.owner
2195 * SYSTEM.NT_SEC_DESC.OWNER
2196 * sYsTeM.nt_sEc_desc.owNER
2199 int smbc_lsetxattr(const char *url
,
2206 /**@ingroup attribute
2207 * Set extended attributes for a file. This is used for modifying a file's
2208 * security descriptor (i.e. owner, group, and access control list)
2210 * @param fd A file descriptor associated with an open file (as
2211 * previously returned by smbc_open(), to get extended
2214 * @param name The name of an attribute to be changed. Names are of
2215 * one of the following forms:
2217 * system.nt_sec_desc.<attribute name>
2218 * system.nt_sec_desc.*
2219 * system.nt_sec_desc.*+
2221 * where <attribute name> is one of:
2229 * acl+:<name or sid>
2231 * In the forms "system.nt_sec_desc.*" and
2232 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2233 * literal, i.e. the string is provided exactly as shown, and
2234 * the value parameter should contain a complete security
2235 * descriptor with name:value pairs separated by tabs,
2236 * commas, or newlines (not spaces!).
2238 * The plus sign ('+') indicates that SIDs should be mapped
2239 * to names. Without the plus sign, SIDs are not mapped;
2240 * rather they are simply converted to a string format.
2242 * @param value The value to be assigned to the specified attribute name.
2243 * This buffer should contain only the attribute value if the
2244 * name was of the "system.nt_sec_desc.<attribute_name>"
2245 * form. If the name was of the "system.nt_sec_desc.*" form
2246 * then a complete security descriptor, with name:value pairs
2247 * separated by tabs, commas, or newlines (not spaces!),
2248 * should be provided in this value buffer. A complete
2249 * security descriptor will contain one or more entries
2250 * selected from the following:
2252 * REVISION:<revision number>
2253 * OWNER:<sid or name>
2254 * GROUP:<sid or name>
2255 * ACL:<sid or name>:<type>/<flags>/<mask>
2257 * The revision of the ACL specifies the internal Windows NT
2258 * ACL revision for the security descriptor. If not specified
2259 * it defaults to 1. Using values other than 1 may cause
2260 * strange behaviour.
2262 * The owner and group specify the owner and group sids for
2263 * the object. If the attribute name (either '*+' with a
2264 * complete security descriptor, or individual 'owner+' or
2265 * 'group+' attribute names) ended with a plus sign, the
2266 * specified name is resolved to a SID value, using the
2267 * server on which the file or directory resides. Otherwise,
2268 * the value should be provided in SID-printable format as
2269 * S-1-x-y-z, and is used directly. The <sid or name>
2270 * associated with the ACL: attribute should be provided
2273 * @param size The number of the bytes of data in the value buffer
2275 * @param flags A bit-wise OR of zero or more of the following:
2276 * SMBC_XATTR_FLAG_CREATE -
2277 * fail if the named attribute already exists
2278 * SMBC_XATTR_FLAG_REPLACE -
2279 * fail if the attribute does not already exist
2281 * If neither flag is specified, the specified attributes
2282 * will be added or replace existing attributes of the same
2283 * name, as necessary.
2285 * @return 0 on success, < 0 on error with errno set:
2286 * - EINVAL The client library is not properly initialized
2287 * or one of the parameters is not of a correct
2289 * - ENOMEM No memory was available for internal needs
2290 * - EEXIST If the attribute already exists and the flag
2291 * SMBC_XATTR_FLAG_CREAT was specified
2292 * - ENOATTR If the attribute does not exist and the flag
2293 * SMBC_XATTR_FLAG_REPLACE was specified
2294 * - EPERM Permission was denied.
2295 * - ENOTSUP The referenced file system does not support
2296 * extended attributes
2298 * @note Attribute names are compared in a case-insensitive
2299 * fashion. All of the following are equivalent, although
2300 * the all-lower-case name is the preferred format:
2301 * system.nt_sec_desc.owner
2302 * SYSTEM.NT_SEC_DESC.OWNER
2303 * sYsTeM.nt_sEc_desc.owNER
2306 int smbc_fsetxattr(int fd
,
2313 /**@ingroup attribute
2314 * Get extended attributes for a file.
2316 * @param url The smb url of the file or directory to get extended
2319 * @param name The name of an attribute to be retrieved. Names are of
2320 * one of the following forms:
2322 * system.nt_sec_desc.<attribute name>
2323 * system.nt_sec_desc.*
2324 * system.nt_sec_desc.*+
2326 * where <attribute name> is one of:
2334 * acl+:<name or sid>
2336 * In the forms "system.nt_sec_desc.*" and
2337 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2338 * literal, i.e. the string is provided exactly as shown, and
2339 * the value parameter will return a complete security
2340 * descriptor with name:value pairs separated by tabs,
2341 * commas, or newlines (not spaces!).
2343 * The plus sign ('+') indicates that SIDs should be mapped
2344 * to names. Without the plus sign, SIDs are not mapped;
2345 * rather they are simply converted to a string format.
2347 * @param value A pointer to a buffer in which the value of the specified
2348 * attribute will be placed (unless size is zero).
2350 * @param size The size of the buffer pointed to by value. This parameter
2351 * may also be zero, in which case the size of the buffer
2352 * required to hold the attribute value will be returned,
2353 * but nothing will be placed into the value buffer.
2355 * @return 0 on success, < 0 on error with errno set:
2356 * - EINVAL The client library is not properly initialized
2357 * or one of the parameters is not of a correct
2359 * - ENOMEM No memory was available for internal needs
2360 * - EEXIST If the attribute already exists and the flag
2361 * SMBC_XATTR_FLAG_CREAT was specified
2362 * - ENOATTR If the attribute does not exist and the flag
2363 * SMBC_XATTR_FLAG_REPLACE was specified
2364 * - EPERM Permission was denied.
2365 * - ENOTSUP The referenced file system does not support
2366 * extended attributes
2369 int smbc_getxattr(const char *url
,
2375 /**@ingroup attribute
2376 * Get extended attributes for a file. The POSIX function which this maps to
2377 * would act on a symbolic link rather than acting on what the symbolic link
2378 * points to, but with no symbolic links in SMB file systems, this function
2379 * is functionally identical to smbc_getxattr().
2381 * @param url The smb url of the file or directory to get extended
2384 * @param name The name of an attribute to be retrieved. Names are of
2385 * one of the following forms:
2387 * system.nt_sec_desc.<attribute name>
2388 * system.nt_sec_desc.*
2389 * system.nt_sec_desc.*+
2391 * where <attribute name> is one of:
2399 * acl+:<name or sid>
2401 * In the forms "system.nt_sec_desc.*" and
2402 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2403 * literal, i.e. the string is provided exactly as shown, and
2404 * the value parameter will return a complete security
2405 * descriptor with name:value pairs separated by tabs,
2406 * commas, or newlines (not spaces!).
2408 * The plus sign ('+') indicates that SIDs should be mapped
2409 * to names. Without the plus sign, SIDs are not mapped;
2410 * rather they are simply converted to a string format.
2412 * @param value A pointer to a buffer in which the value of the specified
2413 * attribute will be placed (unless size is zero).
2415 * @param size The size of the buffer pointed to by value. This parameter
2416 * may also be zero, in which case the size of the buffer
2417 * required to hold the attribute value will be returned,
2418 * but nothing will be placed into the value buffer.
2420 * @return 0 on success, < 0 on error with errno set:
2421 * - EINVAL The client library is not properly initialized
2422 * or one of the parameters is not of a correct
2424 * - ENOMEM No memory was available for internal needs
2425 * - EEXIST If the attribute already exists and the flag
2426 * SMBC_XATTR_FLAG_CREAT was specified
2427 * - ENOATTR If the attribute does not exist and the flag
2428 * SMBC_XATTR_FLAG_REPLACE was specified
2429 * - EPERM Permission was denied.
2430 * - ENOTSUP The referenced file system does not support
2431 * extended attributes
2434 int smbc_lgetxattr(const char *url
,
2440 /**@ingroup attribute
2441 * Get extended attributes for a file.
2443 * @param fd A file descriptor associated with an open file (as
2444 * previously returned by smbc_open(), to get extended
2447 * @param name The name of an attribute to be retrieved. Names are of
2448 * one of the following forms:
2450 * system.nt_sec_desc.<attribute name>
2451 * system.nt_sec_desc.*
2452 * system.nt_sec_desc.*+
2454 * where <attribute name> is one of:
2462 * acl+:<name or sid>
2464 * In the forms "system.nt_sec_desc.*" and
2465 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2466 * literal, i.e. the string is provided exactly as shown, and
2467 * the value parameter will return a complete security
2468 * descriptor with name:value pairs separated by tabs,
2469 * commas, or newlines (not spaces!).
2471 * The plus sign ('+') indicates that SIDs should be mapped
2472 * to names. Without the plus sign, SIDs are not mapped;
2473 * rather they are simply converted to a string format.
2475 * @param value A pointer to a buffer in which the value of the specified
2476 * attribute will be placed (unless size is zero).
2478 * @param size The size of the buffer pointed to by value. This parameter
2479 * may also be zero, in which case the size of the buffer
2480 * required to hold the attribute value will be returned,
2481 * but nothing will be placed into the value buffer.
2483 * @return 0 on success, < 0 on error with errno set:
2484 * - EINVAL The client library is not properly initialized
2485 * or one of the parameters is not of a correct
2487 * - ENOMEM No memory was available for internal needs
2488 * - EEXIST If the attribute already exists and the flag
2489 * SMBC_XATTR_FLAG_CREAT was specified
2490 * - ENOATTR If the attribute does not exist and the flag
2491 * SMBC_XATTR_FLAG_REPLACE was specified
2492 * - EPERM Permission was denied.
2493 * - ENOTSUP The referenced file system does not support
2494 * extended attributes
2497 int smbc_fgetxattr(int fd
,
2503 /**@ingroup attribute
2504 * Remove extended attributes for a file. This is used for modifying a file's
2505 * security descriptor (i.e. owner, group, and access control list)
2507 * @param url The smb url of the file or directory to remove the extended
2510 * @param name The name of an attribute to be removed. Names are of
2511 * one of the following forms:
2513 * system.nt_sec_desc.<attribute name>
2514 * system.nt_sec_desc.*
2515 * system.nt_sec_desc.*+
2517 * where <attribute name> is one of:
2525 * acl+:<name or sid>
2527 * In the forms "system.nt_sec_desc.*" and
2528 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2529 * literal, i.e. the string is provided exactly as shown, and
2530 * the value parameter will return a complete security
2531 * descriptor with name:value pairs separated by tabs,
2532 * commas, or newlines (not spaces!).
2534 * The plus sign ('+') indicates that SIDs should be mapped
2535 * to names. Without the plus sign, SIDs are not mapped;
2536 * rather they are simply converted to a string format.
2538 * @return 0 on success, < 0 on error with errno set:
2539 * - EINVAL The client library is not properly initialized
2540 * - ENOMEM No memory was available for internal needs
2541 * - EPERM Permission was denied.
2542 * - ENOTSUP The referenced file system does not support
2543 * extended attributes
2546 int smbc_removexattr(const char *url
,
2550 /**@ingroup attribute
2551 * Remove extended attributes for a file. This is used for modifying a file's
2552 * security descriptor (i.e. owner, group, and access control list) The POSIX
2553 * function which this maps to would act on a symbolic link rather than acting
2554 * on what the symbolic link points to, but with no symbolic links in SMB file
2555 * systems, this function is functionally identical to smbc_removexattr().
2557 * @param url The smb url of the file or directory to remove the extended
2560 * @param name The name of an attribute to be removed. Names are of
2561 * one of the following forms:
2563 * system.nt_sec_desc.<attribute name>
2564 * system.nt_sec_desc.*
2565 * system.nt_sec_desc.*+
2567 * where <attribute name> is one of:
2575 * acl+:<name or sid>
2577 * In the forms "system.nt_sec_desc.*" and
2578 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2579 * literal, i.e. the string is provided exactly as shown, and
2580 * the value parameter will return a complete security
2581 * descriptor with name:value pairs separated by tabs,
2582 * commas, or newlines (not spaces!).
2584 * The plus sign ('+') indicates that SIDs should be mapped
2585 * to names. Without the plus sign, SIDs are not mapped;
2586 * rather they are simply converted to a string format.
2588 * @return 0 on success, < 0 on error with errno set:
2589 * - EINVAL The client library is not properly initialized
2590 * - ENOMEM No memory was available for internal needs
2591 * - EPERM Permission was denied.
2592 * - ENOTSUP The referenced file system does not support
2593 * extended attributes
2596 int smbc_lremovexattr(const char *url
,
2600 /**@ingroup attribute
2601 * Remove extended attributes for a file. This is used for modifying a file's
2602 * security descriptor (i.e. owner, group, and access control list)
2604 * @param fd A file descriptor associated with an open file (as
2605 * previously returned by smbc_open(), to get extended
2608 * @param name The name of an attribute to be removed. Names are of
2609 * one of the following forms:
2611 * system.nt_sec_desc.<attribute name>
2612 * system.nt_sec_desc.*
2613 * system.nt_sec_desc.*+
2615 * where <attribute name> is one of:
2623 * acl+:<name or sid>
2625 * In the forms "system.nt_sec_desc.*" and
2626 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2627 * literal, i.e. the string is provided exactly as shown, and
2628 * the value parameter will return a complete security
2629 * descriptor with name:value pairs separated by tabs,
2630 * commas, or newlines (not spaces!).
2632 * The plus sign ('+') indicates that SIDs should be mapped
2633 * to names. Without the plus sign, SIDs are not mapped;
2634 * rather they are simply converted to a string format.
2636 * @return 0 on success, < 0 on error with errno set:
2637 * - EINVAL The client library is not properly initialized
2638 * - ENOMEM No memory was available for internal needs
2639 * - EPERM Permission was denied.
2640 * - ENOTSUP The referenced file system does not support
2641 * extended attributes
2644 int smbc_fremovexattr(int fd
,
2648 /**@ingroup attribute
2649 * List the supported extended attribute names associated with a file
2651 * @param url The smb url of the file or directory to list the extended
2654 * @param list A pointer to a buffer in which the list of attributes for
2655 * the specified file or directory will be placed (unless
2658 * @param size The size of the buffer pointed to by list. This parameter
2659 * may also be zero, in which case the size of the buffer
2660 * required to hold all of the attribute names will be
2661 * returned, but nothing will be placed into the list buffer.
2663 * @return 0 on success, < 0 on error with errno set:
2664 * - EINVAL The client library is not properly initialized
2665 * - ENOMEM No memory was available for internal needs
2666 * - EPERM Permission was denied.
2667 * - ENOTSUP The referenced file system does not support
2668 * extended attributes
2670 * @note This function always returns all attribute names supported
2671 * by NT file systems, regardless of whether the referenced
2672 * file system supports extended attributes (e.g. a Windows
2673 * 2000 machine supports extended attributes if NTFS is used,
2674 * but not if FAT is used, and Windows 98 doesn't support
2675 * extended attributes at all. Whether this is a feature or
2676 * a bug is yet to be decided.
2678 int smbc_listxattr(const char *url
,
2682 /**@ingroup attribute
2683 * List the supported extended attribute names associated with a file The
2684 * POSIX function which this maps to would act on a symbolic link rather than
2685 * acting on what the symbolic link points to, but with no symbolic links in
2686 * SMB file systems, this function is functionally identical to
2689 * @param url The smb url of the file or directory to list the extended
2692 * @param list A pointer to a buffer in which the list of attributes for
2693 * the specified file or directory will be placed (unless
2696 * @param size The size of the buffer pointed to by list. This parameter
2697 * may also be zero, in which case the size of the buffer
2698 * required to hold all of the attribute names will be
2699 * returned, but nothing will be placed into the list buffer.
2701 * @return 0 on success, < 0 on error with errno set:
2702 * - EINVAL The client library is not properly initialized
2703 * - ENOMEM No memory was available for internal needs
2704 * - EPERM Permission was denied.
2705 * - ENOTSUP The referenced file system does not support
2706 * extended attributes
2708 * @note This function always returns all attribute names supported
2709 * by NT file systems, regardless of whether the referenced
2710 * file system supports extended attributes (e.g. a Windows
2711 * 2000 machine supports extended attributes if NTFS is used,
2712 * but not if FAT is used, and Windows 98 doesn't support
2713 * extended attributes at all. Whether this is a feature or
2714 * a bug is yet to be decided.
2716 int smbc_llistxattr(const char *url
,
2720 /**@ingroup attribute
2721 * List the supported extended attribute names associated with a file
2723 * @param fd A file descriptor associated with an open file (as
2724 * previously returned by smbc_open(), to get extended
2727 * @param list A pointer to a buffer in which the list of attributes for
2728 * the specified file or directory will be placed (unless
2731 * @param size The size of the buffer pointed to by list. This parameter
2732 * may also be zero, in which case the size of the buffer
2733 * required to hold all of the attribute names will be
2734 * returned, but nothing will be placed into the list buffer.
2736 * @return 0 on success, < 0 on error with errno set:
2737 * - EINVAL The client library is not properly initialized
2738 * - ENOMEM No memory was available for internal needs
2739 * - EPERM Permission was denied.
2740 * - ENOTSUP The referenced file system does not support
2741 * extended attributes
2743 * @note This function always returns all attribute names supported
2744 * by NT file systems, regardless of whether the referenced
2745 * file system supports extended attributes (e.g. a Windows
2746 * 2000 machine supports extended attributes if NTFS is used,
2747 * but not if FAT is used, and Windows 98 doesn't support
2748 * extended attributes at all. Whether this is a feature or
2749 * a bug is yet to be decided.
2751 int smbc_flistxattr(int fd
,
2756 * Print a file given the name in fname. It would be a URL ...
2758 * @param fname The URL of a file on a remote SMB server that the
2759 * caller wants printed
2761 * @param printq The URL of the print share to print the file to.
2763 * @return 0 on success, < 0 on error with errno set:
2765 * - EINVAL fname or printq was NULL or smbc_init not
2767 * and errors returned by smbc_open
2770 int smbc_print_file(const char *fname
, const char *printq
);
2773 * Open a print file that can be written to by other calls. This simply
2774 * does an smbc_open call after checking if there is a file name on the
2775 * URI. If not, a temporary name is added ...
2777 * @param fname The URL of the print share to print to?
2779 * @returns A file handle for the print file if successful.
2780 * Returns -1 if an error ocurred and errno has the values
2781 * - EINVAL fname was NULL or smbc_init not called.
2782 * - all errors returned by smbc_open
2785 int smbc_open_print_job(const char *fname
);
2788 * List the print jobs on a print share, for the moment, pass a callback
2790 * @param purl The url of the print share to list the jobs of
2792 * @param fn Callback function the receives printjob info
2794 * @return 0 on success, < 0 on error with errno set:
2795 * - EINVAL fname was NULL or smbc_init not called
2798 int smbc_list_print_jobs(const char *purl
, smbc_list_print_job_fn fn
);
2801 * Delete a print job
2803 * @param purl Url of the print share
2805 * @param id The id of the job to delete
2807 * @return 0 on success, < 0 on error with errno set:
2808 * - EINVAL fname was NULL or smbc_init not called
2810 * @todo what errno values are possible here?
2812 int smbc_unlink_print_job(const char *purl
, int id
);
2814 /**@ingroup callback
2815 * Remove a server from the cached server list it's unused.
2817 * @param context pointer to smb context
2819 * @param srv pointer to server to remove
2821 * @return On success, 0 is returned. 1 is returned if the server could not
2822 * be removed. Also useable outside libsmbclient.
2824 int smbc_remove_unused_server(SMBCCTX
* context
, SMBCSRV
* srv
);
2830 /**@ingroup directory
2831 * Convert strings of %xx to their single character equivalent.
2833 * @param dest A pointer to a buffer in which the resulting decoded
2834 * string should be placed. This may be a pointer to the
2835 * same buffer as src_segment.
2837 * @param src A pointer to the buffer containing the URL to be decoded.
2838 * Any %xx sequences herein are converted to their single
2839 * character equivalent. Each 'x' must be a valid hexadecimal
2840 * digit, or that % sequence is left undecoded.
2842 * @param max_dest_len
2843 * The size of the buffer pointed to by dest_segment.
2845 * @return The number of % sequences which could not be converted
2846 * due to lack of two following hexadecimal digits.
2852 smbc_urldecode(char *dest
, char * src
, size_t max_dest_len
);
2859 * Convert any characters not specifically allowed in a URL into their %xx
2862 * @param dest A pointer to a buffer in which the resulting encoded
2863 * string should be placed. Unlike smbc_urldecode(), this
2864 * must be a buffer unique from src.
2866 * @param src A pointer to the buffer containing the string to be encoded.
2867 * Any character not specifically allowed in a URL is converted
2868 * into its hexadecimal value and encoded as %xx.
2870 * @param max_dest_len
2871 * The size of the buffer pointed to by dest_segment.
2873 * @returns The remaining buffer length.
2879 smbc_urlencode(char * dest
, char * src
, int max_dest_len
);
2885 /**@ingroup directory
2886 * Return the version of the linked Samba code, and thus the version of the
2887 * libsmbclient code.
2889 * @return The version string.
2901 * Set the users credentials globally so they can be used for DFS
2902 * referrals. Probably best to use this function in the smbc_get_auth_data_fn
2905 * @param workgroup Workgroup of the user.
2907 * @param user Username of user.
2909 * @param password Password of user.
2911 * @param use_kerberos Whether to use Kerberos
2913 * @param signing_state One of these strings (all equivalents on same line):
2914 * "off", "no", "false"
2915 * "on", "yes", "true", "auto"
2916 * "force", "required", "forced"
2920 smbc_set_credentials(const char *workgroup
,
2922 const char *password
,
2923 smbc_bool use_kerberos
,
2924 const char *signing_state
);
2927 * Wrapper around smbc_set_credentials.
2928 * Used to set correct credentials that will
2929 * be used to connect to DFS target share
2934 smbc_set_credentials_with_fallback(SMBCCTX
*ctx
,
2935 const char *workgroup
,
2937 const char *password
);
2943 * Initialize for threads using the Posix Threads (pthread)
2944 * implementation. This is a built-in implementation, avoiding the need to
2945 * implement the component functions of the thread interface. If this function
2946 * is used, it is not necessary to call smbc_thread_impl().
2951 smbc_thread_posix(void);
2956 * Initialize for an arbitrary thread implementation. The caller should
2957 * provide, as parameters, pointers to functions to implement the requisite
2958 * low-level thread functionality. A function must be provided for each
2959 * parameter; none may be null.
2961 * If the thread implementation is POSIX Threads (pthreads), then the much
2962 * simpler smbc_thread_pthread() function may be used instead of this one.
2964 * @param create_mutex
2965 * Create a mutex. This function should expect three parameters: lockname,
2966 * pplock, and location. It should create a unique mutex for each unique
2967 * lockname it is provided, and return the mutex identifier in *pplock. The
2968 * location parameter can be used for debugging, as it contains the
2969 * compiler-provided __location__ of the call.
2971 * @param destroy_mutex
2972 * Destroy a mutex. This function should expect two parameters: plock and
2973 * location. It should destroy the mutex associated with the identifier
2974 * plock. The location parameter can be used for debugging, as it contains
2975 * the compiler-provided __location__ of the call.
2978 * Lock a mutex. This function should expect three parameters: plock,
2979 * lock_type, and location. The mutex aassociated with identifier plock
2980 * should be locked if lock_type is 1, and unlocked if lock_type is 2. The
2981 * location parameter can be used for debugging, as it contains the
2982 * compiler-provided __location__ of the call.
2985 * Create thread local storage. This function should expect three
2986 * parameters: keyname, ppkey, and location. It should allocate an
2987 * implementation-specific amount of memory and assign the pointer to that
2988 * allocated memory to *ppkey. The location parameter can be used for
2989 * debugging, as it contains the compiler-provided __location__ of the
2990 * call. This function should return 0 upon success, non-zero upon failure.
2992 * @param destroy_tls
2993 * Destroy thread local storage. This function should expect two parameters:
2994 * ppkey and location. The ppkey parameter points to a variable containing a
2995 * thread local storage key previously provided by the create_tls
2996 * function. The location parameter can be used for debugging, as it
2997 * contains the compiler-provided __location__ of the call.
3000 * Set a thread local storage variable's value. This function should expect
3001 * three parameters: pkey, pval, and location. The pkey parameter is a
3002 * thread local storage key previously provided by the create_tls
3003 * function. The (void *) pval parameter contains the value to be placed in
3004 * the thread local storage variable identified by pkey. The location
3005 * parameter can be used for debugging, as it contains the compiler-provided
3006 * __location__ of the call. This function should return 0 upon success;
3007 * non-zero otherwise.
3010 * Retrieve a thread local storage variable's value. This function should
3011 * expect two parameters: pkey and location. The pkey parameter is a thread
3012 * local storage key previously provided by the create_tls function, and
3013 * which has previously been used in a call to the set_tls function to
3014 * initialize a thread local storage variable. The location parameter can be
3015 * used for debugging, as it contains the compiler-provided __location__ of
3016 * the call. This function should return the (void *) value stored in the
3017 * variable identified by pkey.
3023 /* Mutex functions. */
3024 int (*create_mutex
)(const char *lockname
,
3026 const char *location
),
3027 void (*destroy_mutex
)(void *plock
,
3028 const char *location
),
3029 int (*lock_mutex
)(void *plock
,
3031 const char *location
),
3033 /* Thread local storage. */
3034 int (*create_tls
)(const char *keyname
,
3036 const char *location
),
3037 void (*destroy_tls
)(void **ppkey
,
3038 const char *location
),
3039 int (*set_tls
)(void *pkey
,
3041 const char *location
),
3042 void *(*get_tls
)(void *pkey
,
3043 const char *location
)
3049 * @ingroup structure
3050 * Structure that contains a client context information
3051 * This structure is known as SMBCCTX
3053 * DO NOT DIRECTLY MANIPULATE THE CONTEXT STRUCTURE! The data in the context
3054 * structure should all be considered private to the library. It remains here
3055 * only for backward compatibility.
3057 * See the comments herein for use of the setter and getter functions which
3058 * should now be used for manipulating these values. New features, functions,
3059 * etc., are not added here but rather in _internal where they are not
3060 * directly visible to applications. This makes it much easier to maintain
3061 * ABI compatibility.
3069 * Use smbc_getDebug() and smbc_setDebug()
3071 int debug DEPRECATED_SMBC_INTERFACE
;
3074 * netbios name used for making connections
3077 * Use smbc_getNetbiosName() and smbc_setNetbiosName()
3079 char * netbios_name DEPRECATED_SMBC_INTERFACE
;
3082 * workgroup name used for making connections
3085 * Use smbc_getWorkgroup() and smbc_setWorkgroup()
3087 char * workgroup DEPRECATED_SMBC_INTERFACE
;
3090 * username used for making connections
3093 * Use smbc_getUser() and smbc_setUser()
3095 char * user DEPRECATED_SMBC_INTERFACE
;
3098 * timeout used for waiting on connections / response data (in
3102 * Use smbc_getTimeout() and smbc_setTimeout()
3104 int timeout DEPRECATED_SMBC_INTERFACE
;
3107 * callable functions for files:
3108 * For usage and return values see the SMBC_* functions
3112 * Use smbc_getFunction*() and smbc_setFunction*(), e.g.
3113 * smbc_getFunctionOpen(), smbc_setFunctionUnlink(), etc.
3115 smbc_open_fn open DEPRECATED_SMBC_INTERFACE
;
3116 smbc_creat_fn creat DEPRECATED_SMBC_INTERFACE
;
3117 smbc_read_fn read DEPRECATED_SMBC_INTERFACE
;
3118 smbc_write_fn write DEPRECATED_SMBC_INTERFACE
;
3119 smbc_unlink_fn unlink DEPRECATED_SMBC_INTERFACE
;
3120 smbc_rename_fn rename DEPRECATED_SMBC_INTERFACE
;
3121 smbc_lseek_fn lseek DEPRECATED_SMBC_INTERFACE
;
3122 smbc_stat_fn stat DEPRECATED_SMBC_INTERFACE
;
3123 smbc_fstat_fn fstat DEPRECATED_SMBC_INTERFACE
;
3124 #if 0 /* internal */
3125 smbc_ftruncate_fn ftruncate_fn
;
3127 smbc_close_fn close_fn DEPRECATED_SMBC_INTERFACE
;
3128 smbc_opendir_fn opendir DEPRECATED_SMBC_INTERFACE
;
3129 smbc_closedir_fn closedir DEPRECATED_SMBC_INTERFACE
;
3130 smbc_readdir_fn readdir DEPRECATED_SMBC_INTERFACE
;
3131 smbc_readdirplus_fn readdirplus DEPRECATED_SMBC_INTERFACE
;
3132 smbc_readdirplus2_fn readdirplus2 DEPRECATED_SMBC_INTERFACE
;
3133 smbc_getdents_fn getdents DEPRECATED_SMBC_INTERFACE
;
3134 smbc_mkdir_fn mkdir DEPRECATED_SMBC_INTERFACE
;
3135 smbc_rmdir_fn rmdir DEPRECATED_SMBC_INTERFACE
;
3136 smbc_telldir_fn telldir DEPRECATED_SMBC_INTERFACE
;
3137 smbc_lseekdir_fn lseekdir DEPRECATED_SMBC_INTERFACE
;
3138 smbc_fstatdir_fn fstatdir DEPRECATED_SMBC_INTERFACE
;
3139 smbc_chmod_fn chmod DEPRECATED_SMBC_INTERFACE
;
3140 smbc_utimes_fn utimes DEPRECATED_SMBC_INTERFACE
;
3141 smbc_setxattr_fn setxattr DEPRECATED_SMBC_INTERFACE
;
3142 smbc_getxattr_fn getxattr DEPRECATED_SMBC_INTERFACE
;
3143 smbc_removexattr_fn removexattr DEPRECATED_SMBC_INTERFACE
;
3144 smbc_listxattr_fn listxattr DEPRECATED_SMBC_INTERFACE
;
3146 /* Printing-related functions */
3147 smbc_print_file_fn print_file DEPRECATED_SMBC_INTERFACE
;
3148 smbc_open_print_job_fn open_print_job DEPRECATED_SMBC_INTERFACE
;
3149 smbc_list_print_jobs_fn list_print_jobs DEPRECATED_SMBC_INTERFACE
;
3150 smbc_unlink_print_job_fn unlink_print_job DEPRECATED_SMBC_INTERFACE
;
3157 * See the comment above each field, for the getter and setter
3158 * functions that should now be used.
3160 struct _smbc_callbacks
3163 * authentication function callback: called upon auth requests
3166 * Use smbc_getFunctionAuthData(), smbc_setFunctionAuthData()
3168 smbc_get_auth_data_fn auth_fn DEPRECATED_SMBC_INTERFACE
;
3171 * check if a server is still good
3174 * Use smbc_getFunctionCheckServer(),
3175 * smbc_setFunctionCheckServer()
3177 smbc_check_server_fn check_server_fn DEPRECATED_SMBC_INTERFACE
;
3180 * remove a server if unused
3183 * Use smbc_getFunctionRemoveUnusedServer(),
3184 * smbc_setFunctionCheckServer()
3186 smbc_remove_unused_server_fn remove_unused_server_fn DEPRECATED_SMBC_INTERFACE
;
3190 * For an example cache system see
3191 * samba/source/libsmb/libsmb_cache.c
3193 * Cache subsystem * functions follow.
3197 * server cache addition
3200 * Use smbc_getFunctionAddCachedServer(),
3201 * smbc_setFunctionAddCachedServer()
3203 smbc_add_cached_srv_fn add_cached_srv_fn DEPRECATED_SMBC_INTERFACE
;
3206 * server cache lookup
3209 * Use smbc_getFunctionGetCachedServer(),
3210 * smbc_setFunctionGetCachedServer()
3212 smbc_get_cached_srv_fn get_cached_srv_fn DEPRECATED_SMBC_INTERFACE
;
3215 * server cache removal
3218 * Use smbc_getFunctionRemoveCachedServer(),
3219 * smbc_setFunctionRemoveCachedServer()
3221 smbc_remove_cached_srv_fn remove_cached_srv_fn DEPRECATED_SMBC_INTERFACE
;
3224 * server cache purging, try to remove all cached servers
3228 * Use smbc_getFunctionPurgeCachedServers(),
3229 * smbc_setFunctionPurgeCachedServers()
3231 smbc_purge_cached_fn purge_cached_fn DEPRECATED_SMBC_INTERFACE
;
3235 * Space where the private data of the server cache used to be
3238 * Use smbc_getServerCacheData(), smbc_setServerCacheData()
3240 void * reserved DEPRECATED_SMBC_INTERFACE
;
3243 * Very old configuration options.
3246 * Use one of the following functions instead:
3247 * smbc_setOptionUseKerberos()
3248 * smbc_getOptionUseKerberos()
3249 * smbc_setOptionFallbackAfterKerberos()
3250 * smbc_getOptionFallbackAfterKerberos()
3251 * smbc_setOptionNoAutoAnonymousLogin()
3252 * smbc_getOptionNoAutoAnonymousLogin()
3254 int flags DEPRECATED_SMBC_INTERFACE
;
3257 * user options selections that apply to this session
3259 * NEW OPTIONS ARE NOT ADDED HERE!
3262 * To set and retrieve options, use the smbc_setOption*() and
3263 * smbc_getOption*() functions.
3265 struct _smbc_options
{
3266 int browse_max_lmb_count DEPRECATED_SMBC_INTERFACE
;
3267 int urlencode_readdir_entries DEPRECATED_SMBC_INTERFACE
;
3268 int one_share_per_server DEPRECATED_SMBC_INTERFACE
;
3269 } options DEPRECATED_SMBC_INTERFACE
;
3272 * do _NOT_ touch this from your program !
3274 struct SMBC_internal_data
* internal
;
3278 #endif /* SMBCLIENT_H_INCLUDED */