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>
82 #define SMBC_BASE_FD 10000 /* smallest file descriptor returned */
84 #define SMBC_WORKGROUP 1
86 #define SMBC_FILE_SHARE 3
87 #define SMBC_PRINTER_SHARE 4
88 #define SMBC_COMMS_SHARE 5
89 #define SMBC_IPC_SHARE 6
95 * Structure that represents a directory entry.
104 SMBC_PRINTER_SHARE=4,
110 unsigned int smbc_type
;
112 /** Length of this smbc_dirent in bytes
115 /** The length of the comment string in bytes (does not include
118 unsigned int commentlen
;
119 /** Points to the null terminated comment string
122 /** The length of the name string in bytes (does not include
125 unsigned int namelen
;
126 /** Points to the null terminated name string
132 * Flags for smbc_setxattr()
133 * Specify a bitwise OR of these, or 0 to add or replace as necessary
135 #define SMBC_XATTR_FLAG_CREATE 0x1 /* fail if attr already exists */
136 #define SMBC_XATTR_FLAG_REPLACE 0x2 /* fail if attr does not exist */
140 * Mappings of the DOS mode bits, as returned by smbc_getxattr() when the
141 * attribute name "system.dos_attr.mode" (or "system.dos_attr.*" or
142 * "system.*") is specified.
144 #define SMBC_DOS_MODE_READONLY 0x01
145 #define SMBC_DOS_MODE_HIDDEN 0x02
146 #define SMBC_DOS_MODE_SYSTEM 0x04
147 #define SMBC_DOS_MODE_VOLUME_ID 0x08
148 #define SMBC_DOS_MODE_DIRECTORY 0x10
149 #define SMBC_DOS_MODE_ARCHIVE 0x20
152 * Valid values for the option "open_share_mode", when calling
153 * smbc_setOptionOpenShareMode()
155 typedef enum smbc_share_mode
157 SMBC_SHAREMODE_DENY_DOS
= 0,
158 SMBC_SHAREMODE_DENY_ALL
= 1,
159 SMBC_SHAREMODE_DENY_WRITE
= 2,
160 SMBC_SHAREMODE_DENY_READ
= 3,
161 SMBC_SHAREMODE_DENY_NONE
= 4,
162 SMBC_SHAREMODE_DENY_FCB
= 7
167 * Values for option SMB Encryption Level, as set and retrieved with
168 * smbc_setOptionSmbEncryptionLevel() and smbc_getOptionSmbEncryptionLevel()
170 typedef enum smbc_smb_encrypt_level
172 SMBC_ENCRYPTLEVEL_NONE
= 0,
173 SMBC_ENCRYPTLEVEL_REQUEST
= 1,
174 SMBC_ENCRYPTLEVEL_REQUIRE
= 2
175 } smbc_smb_encrypt_level
;
179 * Capabilities set in the f_flag field of struct statvfs, from
180 * smbc_statvfs(). These may be OR-ed together to reflect a full set of
181 * available capabilities.
183 typedef enum smbc_vfs_feature
185 /* Defined by POSIX or in Linux include files (low-order bits) */
186 SMBC_VFS_FEATURE_RDONLY
= (1 << 0),
188 /* Specific to libsmbclient (high-order bits) */
189 SMBC_VFS_FEATURE_DFS
= (1 << 28),
190 SMBC_VFS_FEATURE_CASE_INSENSITIVE
= (1 << 29),
191 SMBC_VFS_FEATURE_NO_UNIXCIFS
= (1 << 30)
194 typedef int smbc_bool
;
198 # define ENOATTR ENOENT /* No such attribute */
204 /**@ingroup structure
205 * Structure that represents a print job.
209 struct print_job_info
211 /** numeric ID of the print job
215 /** represents print job priority (lower numbers mean higher priority)
217 unsigned short priority
;
219 /** Size of the print job
223 /** Name of the user that owns the print job
227 /** Name of the print job. This will have no name if an anonymous print
228 * file was opened. Ie smb://server/printer
232 /** Time the print job was spooled
236 #endif /* _CLIENT_H */
239 /**@ingroup structure
242 typedef struct _SMBCSRV SMBCSRV
;
244 /**@ingroup structure
245 * File or directory handle
247 typedef struct _SMBCFILE SMBCFILE
;
249 /**@ingroup structure
250 * File or directory handle
252 typedef struct _SMBCCTX SMBCCTX
;
256 * Flags for SMBCCTX->flags
258 * NEW CODE SHOULD NOT DIRECTLY MANIPULATE THE CONTEXT STRUCTURE.
260 * smbc_setOptionUseKerberos()
261 * smbc_getOptionUseKerberos()
262 * smbc_setOptionFallbackAfterKerberos()
263 * smbc_getOptionFallbackAFterKerberos()
264 * smbc_setOptionNoAutoAnonymousLogin()
265 * smbc_getOptionNoAutoAnonymousLogin()
266 * smbc_setOptionUseCCache()
267 * smbc_getOptionUseCCache()
269 # define SMB_CTX_FLAG_USE_KERBEROS (1 << 0)
270 # define SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS (1 << 1)
271 # define SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON (1 << 2)
272 # define SMB_CTX_FLAG_USE_CCACHE (1 << 3)
277 * Authentication callback function type (traditional method)
279 * Type for the the authentication function called by the library to
280 * obtain authentication credentals
282 * For kerberos support the function should just be called without
283 * prompting the user for credentials. Which means a simple 'return'
284 * should work. Take a look at examples/libsmbclient/get_auth_data_fn.h
285 * and examples/libsmbclient/testbrowse.c.
287 * @param srv Server being authenticated to
289 * @param shr Share being authenticated to
291 * @param wg Pointer to buffer containing a "hint" for the
292 * workgroup to be authenticated. Should be filled in
293 * with the correct workgroup if the hint is wrong.
295 * @param wglen The size of the workgroup buffer in bytes
297 * @param un Pointer to buffer containing a "hint" for the
298 * user name to be use for authentication. Should be
299 * filled in with the correct workgroup if the hint is
302 * @param unlen The size of the username buffer in bytes
304 * @param pw Pointer to buffer containing to which password
307 * @param pwlen The size of the password buffer in bytes
310 typedef void (*smbc_get_auth_data_fn
)(const char *srv
,
314 char *pw
, int pwlen
);
316 * Authentication callback function type (method that includes context)
318 * Type for the the authentication function called by the library to
319 * obtain authentication credentals
321 * For kerberos support the function should just be called without
322 * prompting the user for credentials. Which means a simple 'return'
323 * should work. Take a look at examples/libsmbclient/get_auth_data_fn.h
324 * and examples/libsmbclient/testbrowse.c.
326 * @param c Pointer to the smb context
328 * @param srv Server being authenticated to
330 * @param shr Share being authenticated to
332 * @param wg Pointer to buffer containing a "hint" for the
333 * workgroup to be authenticated. Should be filled in
334 * with the correct workgroup if the hint is wrong.
336 * @param wglen The size of the workgroup buffer in bytes
338 * @param un Pointer to buffer containing a "hint" for the
339 * user name to be use for authentication. Should be
340 * filled in with the correct workgroup if the hint is
343 * @param unlen The size of the username buffer in bytes
345 * @param pw Pointer to buffer containing to which password
348 * @param pwlen The size of the password buffer in bytes
351 typedef void (*smbc_get_auth_data_with_context_fn
)(SMBCCTX
*c
,
356 char *pw
, int pwlen
);
360 * Print job info callback function type.
362 * @param i pointer to print job information structure
365 typedef void (*smbc_list_print_job_fn
)(struct print_job_info
*i
);
369 * Check if a server is still good
371 * @param c pointer to smb context
373 * @param srv pointer to server to check
375 * @return 0 when connection is good. 1 on error.
378 typedef int (*smbc_check_server_fn
)(SMBCCTX
* c
, SMBCSRV
*srv
);
381 * Remove a server if unused
383 * @param c pointer to smb context
385 * @param srv pointer to server to remove
387 * @return 0 on success. 1 on failure.
390 typedef int (*smbc_remove_unused_server_fn
)(SMBCCTX
* c
, SMBCSRV
*srv
);
394 * Add a server to the cache system
396 * @param c pointer to smb context
398 * @param srv pointer to server to add
400 * @param server server name
402 * @param share share name
404 * @param workgroup workgroup used to connect
406 * @param username username used to connect
408 * @return 0 on success. 1 on failure.
411 typedef int (*smbc_add_cached_srv_fn
) (SMBCCTX
* c
, SMBCSRV
*srv
,
412 const char * server
, const char * share
,
413 const char * workgroup
, const char * username
);
416 * Look up a server in the cache system
418 * @param c pointer to smb context
420 * @param server server name to match
422 * @param share share name to match
424 * @param workgroup workgroup to match
426 * @param username username to match
428 * @return pointer to SMBCSRV on success. NULL on failure.
431 typedef SMBCSRV
* (*smbc_get_cached_srv_fn
) (SMBCCTX
* c
, const char * server
,
432 const char * share
, const char * workgroup
,
433 const char * username
);
436 * Check if a server is still good
438 * @param c pointer to smb context
440 * @param srv pointer to server to remove
442 * @return 0 when found and removed. 1 on failure.
445 typedef int (*smbc_remove_cached_srv_fn
)(SMBCCTX
* c
, SMBCSRV
*srv
);
449 * Try to remove all servers from the cache system and disconnect
451 * @param c pointer to smb context
453 * @return 0 when found and removed. 1 on failure.
456 typedef int (*smbc_purge_cached_fn
) (SMBCCTX
* c
);
460 /*****************************************
461 * Getters and setters for CONFIGURATION *
462 *****************************************/
464 /** Get the debug level */
466 smbc_getDebug(SMBCCTX
*c
);
468 /** Set the debug level */
470 smbc_setDebug(SMBCCTX
*c
, int debug
);
472 /** Get the netbios name used for making connections */
474 smbc_getNetbiosName(SMBCCTX
*c
);
476 /** Set the netbios name used for making connections */
478 smbc_setNetbiosName(SMBCCTX
*c
, char * netbios_name
);
480 /** Get the workgroup used for making connections */
482 smbc_getWorkgroup(SMBCCTX
*c
);
484 /** Set the workgroup used for making connections */
485 void smbc_setWorkgroup(SMBCCTX
*c
, char * workgroup
);
487 /** Get the username used for making connections */
489 smbc_getUser(SMBCCTX
*c
);
491 /** Set the username used for making connections */
493 smbc_setUser(SMBCCTX
*c
, char * user
);
496 * Get the timeout used for waiting on connections and response data
500 smbc_getTimeout(SMBCCTX
*c
);
503 * Set the timeout used for waiting on connections and response data
507 smbc_setTimeout(SMBCCTX
*c
, int timeout
);
511 /***********************************
512 * Getters and setters for OPTIONS *
513 ***********************************/
515 /** Get whether to log to standard error instead of standard output */
517 smbc_getOptionDebugToStderr(SMBCCTX
*c
);
519 /** Set whether to log to standard error instead of standard output */
521 smbc_setOptionDebugToStderr(SMBCCTX
*c
, smbc_bool b
);
524 * Get whether to use new-style time attribute names, e.g. WRITE_TIME rather
525 * than the old-style names such as M_TIME. This allows also setting/getting
526 * CREATE_TIME which was previously unimplemented. (Note that the old C_TIME
527 * was supposed to be CHANGE_TIME but was confused and sometimes referred to
531 smbc_getOptionFullTimeNames(SMBCCTX
*c
);
534 * Set whether to use new-style time attribute names, e.g. WRITE_TIME rather
535 * than the old-style names such as M_TIME. This allows also setting/getting
536 * CREATE_TIME which was previously unimplemented. (Note that the old C_TIME
537 * was supposed to be CHANGE_TIME but was confused and sometimes referred to
541 smbc_setOptionFullTimeNames(SMBCCTX
*c
, smbc_bool b
);
544 * Get the share mode to use for files opened with SMBC_open_ctx(). The
545 * default is SMBC_SHAREMODE_DENY_NONE.
548 smbc_getOptionOpenShareMode(SMBCCTX
*c
);
551 * Set the share mode to use for files opened with SMBC_open_ctx(). The
552 * default is SMBC_SHAREMODE_DENY_NONE.
555 smbc_setOptionOpenShareMode(SMBCCTX
*c
, smbc_share_mode share_mode
);
557 /** Retrieve a previously saved user data handle */
559 smbc_getOptionUserData(SMBCCTX
*c
);
561 /** Save a user data handle */
563 smbc_setOptionUserData(SMBCCTX
*c
, void *user_data
);
565 /** Get the encoded value for encryption level. */
566 smbc_smb_encrypt_level
567 smbc_getOptionSmbEncryptionLevel(SMBCCTX
*c
);
569 /** Set the encoded value for encryption level. */
571 smbc_setOptionSmbEncryptionLevel(SMBCCTX
*c
, smbc_smb_encrypt_level level
);
574 * Get whether to treat file names as case-sensitive if we can't determine
575 * when connecting to the remote share whether the file system is case
576 * sensitive. This defaults to FALSE since it's most likely that if we can't
577 * retrieve the file system attributes, it's a very old file system that does
578 * not support case sensitivity.
581 smbc_getOptionCaseSensitive(SMBCCTX
*c
);
584 * Set whether to treat file names as case-sensitive if we can't determine
585 * when connecting to the remote share whether the file system is case
586 * sensitive. This defaults to FALSE since it's most likely that if we can't
587 * retrieve the file system attributes, it's a very old file system that does
588 * not support case sensitivity.
591 smbc_setOptionCaseSensitive(SMBCCTX
*c
, smbc_bool b
);
595 * Get from how many local master browsers should the list of workgroups be
596 * retrieved. It can take up to 12 minutes or longer after a server becomes a
597 * local master browser, for it to have the entire browse list (the list of
598 * workgroups/domains) from an entire network. Since a client never knows
599 * which local master browser will be found first, the one which is found
600 * first and used to retrieve a browse list may have an incomplete or empty
601 * browse list. By requesting the browse list from multiple local master
602 * browsers, a more complete list can be generated. For small networks (few
603 * workgroups), it is recommended that this value be set to 0, causing the
604 * browse lists from all found local master browsers to be retrieved and
605 * merged. For networks with many workgroups, a suitable value for this
606 * variable is probably somewhere around 3. (Default: 3).
609 smbc_getOptionBrowseMaxLmbCount(SMBCCTX
*c
);
612 * Set from how many local master browsers should the list of workgroups be
613 * retrieved. It can take up to 12 minutes or longer after a server becomes a
614 * local master browser, for it to have the entire browse list (the list of
615 * workgroups/domains) from an entire network. Since a client never knows
616 * which local master browser will be found first, the one which is found
617 * first and used to retrieve a browse list may have an incomplete or empty
618 * browse list. By requesting the browse list from multiple local master
619 * browsers, a more complete list can be generated. For small networks (few
620 * workgroups), it is recommended that this value be set to 0, causing the
621 * browse lists from all found local master browsers to be retrieved and
622 * merged. For networks with many workgroups, a suitable value for this
623 * variable is probably somewhere around 3. (Default: 3).
626 smbc_setOptionBrowseMaxLmbCount(SMBCCTX
*c
, int count
);
629 * Get whether to url-encode readdir entries.
631 * There is a difference in the desired return strings from
632 * smbc_readdir() depending upon whether the filenames are to
633 * be displayed to the user, or whether they are to be
634 * appended to the path name passed to smbc_opendir() to call
635 * a further smbc_ function (e.g. open the file with
636 * smbc_open()). In the former case, the filename should be
637 * in "human readable" form. In the latter case, the smbc_
638 * functions expect a URL which must be url-encoded. Those
639 * functions decode the URL. If, for example, smbc_readdir()
640 * returned a file name of "abc%20def.txt", passing a path
641 * with this file name attached to smbc_open() would cause
642 * smbc_open to attempt to open the file "abc def.txt" since
643 * the %20 is decoded into a space.
645 * Set this option to True if the names returned by
646 * smbc_readdir() should be url-encoded such that they can be
647 * passed back to another smbc_ call. Set it to False if the
648 * names returned by smbc_readdir() are to be presented to the
651 * For backwards compatibility, this option defaults to False.
654 smbc_getOptionUrlEncodeReaddirEntries(SMBCCTX
*c
);
657 * Set whether to url-encode readdir entries.
659 * There is a difference in the desired return strings from
660 * smbc_readdir() depending upon whether the filenames are to
661 * be displayed to the user, or whether they are to be
662 * appended to the path name passed to smbc_opendir() to call
663 * a further smbc_ function (e.g. open the file with
664 * smbc_open()). In the former case, the filename should be
665 * in "human readable" form. In the latter case, the smbc_
666 * functions expect a URL which must be url-encoded. Those
667 * functions decode the URL. If, for example, smbc_readdir()
668 * returned a file name of "abc%20def.txt", passing a path
669 * with this file name attached to smbc_open() would cause
670 * smbc_open to attempt to open the file "abc def.txt" since
671 * the %20 is decoded into a space.
673 * Set this option to True if the names returned by
674 * smbc_readdir() should be url-encoded such that they can be
675 * passed back to another smbc_ call. Set it to False if the
676 * names returned by smbc_readdir() are to be presented to the
679 * For backwards compatibility, this option defaults to False.
682 smbc_setOptionUrlEncodeReaddirEntries(SMBCCTX
*c
, smbc_bool b
);
685 * Get whether to use the same connection for all shares on a server.
687 * Some Windows versions appear to have a limit to the number
688 * of concurrent SESSIONs and/or TREE CONNECTions. In
689 * one-shot programs (i.e. the program runs and then quickly
690 * ends, thereby shutting down all connections), it is
691 * probably reasonable to establish a new connection for each
692 * share. In long-running applications, the limitation can be
693 * avoided by using only a single connection to each server,
694 * and issuing a new TREE CONNECT when the share is accessed.
697 smbc_getOptionOneSharePerServer(SMBCCTX
*c
);
700 * Set whether to use the same connection for all shares on a server.
702 * Some Windows versions appear to have a limit to the number
703 * of concurrent SESSIONs and/or TREE CONNECTions. In
704 * one-shot programs (i.e. the program runs and then quickly
705 * ends, thereby shutting down all connections), it is
706 * probably reasonable to establish a new connection for each
707 * share. In long-running applications, the limitation can be
708 * avoided by using only a single connection to each server,
709 * and issuing a new TREE CONNECT when the share is accessed.
712 smbc_setOptionOneSharePerServer(SMBCCTX
*c
, smbc_bool b
);
714 /** Get whether to enable use of kerberos */
716 smbc_getOptionUseKerberos(SMBCCTX
*c
);
718 /** Set whether to enable use of kerberos */
720 smbc_setOptionUseKerberos(SMBCCTX
*c
, smbc_bool b
);
722 /** Get whether to fallback after kerberos */
724 smbc_getOptionFallbackAfterKerberos(SMBCCTX
*c
);
726 /** Set whether to fallback after kerberos */
728 smbc_setOptionFallbackAfterKerberos(SMBCCTX
*c
, smbc_bool b
);
730 /** Get whether to automatically select anonymous login */
732 smbc_getOptionNoAutoAnonymousLogin(SMBCCTX
*c
);
734 /** Set whether to automatically select anonymous login */
736 smbc_setOptionNoAutoAnonymousLogin(SMBCCTX
*c
, smbc_bool b
);
738 /** Get whether to enable use of the winbind ccache */
740 smbc_getOptionUseCCache(SMBCCTX
*c
);
742 /** Set whether to enable use of the winbind ccache */
744 smbc_setOptionUseCCache(SMBCCTX
*c
, smbc_bool b
);
748 /*************************************
749 * Getters and setters for FUNCTIONS *
750 *************************************/
752 /** Get the function for obtaining authentication data */
753 smbc_get_auth_data_fn
smbc_getFunctionAuthData(SMBCCTX
*c
);
755 /** Set the function for obtaining authentication data */
756 void smbc_setFunctionAuthData(SMBCCTX
*c
, smbc_get_auth_data_fn fn
);
758 /** Get the new-style authentication function which includes the context. */
759 smbc_get_auth_data_with_context_fn
760 smbc_getFunctionAuthDataWithContext(SMBCCTX
*c
);
762 /** Set the new-style authentication function which includes the context. */
764 smbc_setFunctionAuthDataWithContext(SMBCCTX
*c
,
765 smbc_get_auth_data_with_context_fn fn
);
767 /** Get the function for checking if a server is still good */
768 smbc_check_server_fn
smbc_getFunctionCheckServer(SMBCCTX
*c
);
770 /** Set the function for checking if a server is still good */
771 void smbc_setFunctionCheckServer(SMBCCTX
*c
, smbc_check_server_fn fn
);
773 /** Get the function for removing a server if unused */
774 smbc_remove_unused_server_fn
smbc_getFunctionRemoveUnusedServer(SMBCCTX
*c
);
776 /** Set the function for removing a server if unused */
777 void smbc_setFunctionRemoveUnusedServer(SMBCCTX
*c
,
778 smbc_remove_unused_server_fn fn
);
780 /** Get the function for adding a cached server */
781 smbc_add_cached_srv_fn
smbc_getFunctionAddCachedServer(SMBCCTX
*c
);
783 /** Set the function for adding a cached server */
784 void smbc_setFunctionAddCachedServer(SMBCCTX
*c
, smbc_add_cached_srv_fn fn
);
786 /** Get the function for server cache lookup */
787 smbc_get_cached_srv_fn
smbc_getFunctionGetCachedServer(SMBCCTX
*c
);
789 /** Set the function for server cache lookup */
790 void smbc_setFunctionGetCachedServer(SMBCCTX
*c
, smbc_get_cached_srv_fn fn
);
792 /** Get the function for server cache removal */
793 smbc_remove_cached_srv_fn
smbc_getFunctionRemoveCachedServer(SMBCCTX
*c
);
795 /** Set the function for server cache removal */
796 void smbc_setFunctionRemoveCachedServer(SMBCCTX
*c
,
797 smbc_remove_cached_srv_fn fn
);
800 * Get the function for server cache purging. This function tries to
801 * remove all cached servers (e.g. on disconnect)
803 smbc_purge_cached_fn
smbc_getFunctionPurgeCachedServers(SMBCCTX
*c
);
806 * Set the function for server cache purging. This function tries to
807 * remove all cached servers (e.g. on disconnect)
809 void smbc_setFunctionPurgeCachedServers(SMBCCTX
*c
,
810 smbc_purge_cached_fn fn
);
812 /** Get the function to store private data of the server cache */
813 struct smbc_server_cache
* smbc_getServerCacheData(SMBCCTX
*c
);
815 /** Set the function to store private data of the server cache */
816 void smbc_setServerCacheData(SMBCCTX
*c
, struct smbc_server_cache
* cache
);
820 /*****************************************************************
821 * Callable functions for files. *
822 * Each callable has a function signature typedef, a declaration *
823 * for the getter, and a declaration for the setter. *
824 *****************************************************************/
826 typedef SMBCFILE
* (*smbc_open_fn
)(SMBCCTX
*c
,
830 smbc_open_fn
smbc_getFunctionOpen(SMBCCTX
*c
);
831 void smbc_setFunctionOpen(SMBCCTX
*c
, smbc_open_fn fn
);
833 typedef SMBCFILE
* (*smbc_creat_fn
)(SMBCCTX
*c
,
836 smbc_creat_fn
smbc_getFunctionCreat(SMBCCTX
*c
);
837 void smbc_setFunctionCreat(SMBCCTX
*c
, smbc_creat_fn
);
839 typedef ssize_t (*smbc_read_fn
)(SMBCCTX
*c
,
843 smbc_read_fn
smbc_getFunctionRead(SMBCCTX
*c
);
844 void smbc_setFunctionRead(SMBCCTX
*c
, smbc_read_fn fn
);
846 typedef ssize_t (*smbc_write_fn
)(SMBCCTX
*c
,
850 smbc_write_fn
smbc_getFunctionWrite(SMBCCTX
*c
);
851 void smbc_setFunctionWrite(SMBCCTX
*c
, smbc_write_fn fn
);
853 typedef int (*smbc_unlink_fn
)(SMBCCTX
*c
,
855 smbc_unlink_fn
smbc_getFunctionUnlink(SMBCCTX
*c
);
856 void smbc_setFunctionUnlink(SMBCCTX
*c
, smbc_unlink_fn fn
);
858 typedef int (*smbc_rename_fn
)(SMBCCTX
*ocontext
,
862 smbc_rename_fn
smbc_getFunctionRename(SMBCCTX
*c
);
863 void smbc_setFunctionRename(SMBCCTX
*c
, smbc_rename_fn fn
);
865 typedef off_t (*smbc_lseek_fn
)(SMBCCTX
*c
,
869 smbc_lseek_fn
smbc_getFunctionLseek(SMBCCTX
*c
);
870 void smbc_setFunctionLseek(SMBCCTX
*c
, smbc_lseek_fn fn
);
872 typedef int (*smbc_stat_fn
)(SMBCCTX
*c
,
875 smbc_stat_fn
smbc_getFunctionStat(SMBCCTX
*c
);
876 void smbc_setFunctionStat(SMBCCTX
*c
, smbc_stat_fn fn
);
878 typedef int (*smbc_fstat_fn
)(SMBCCTX
*c
,
881 smbc_fstat_fn
smbc_getFunctionFstat(SMBCCTX
*c
);
882 void smbc_setFunctionFstat(SMBCCTX
*c
, smbc_fstat_fn fn
);
884 typedef int (*smbc_statvfs_fn
)(SMBCCTX
*c
,
887 smbc_statvfs_fn
smbc_getFunctionStatVFS(SMBCCTX
*c
);
888 void smbc_setFunctionStatVFS(SMBCCTX
*c
, smbc_statvfs_fn fn
);
890 typedef int (*smbc_fstatvfs_fn
)(SMBCCTX
*c
,
893 smbc_fstatvfs_fn
smbc_getFunctionFstatVFS(SMBCCTX
*c
);
894 void smbc_setFunctionFstatVFS(SMBCCTX
*c
, smbc_fstatvfs_fn fn
);
896 typedef int (*smbc_ftruncate_fn
)(SMBCCTX
*c
,
899 smbc_ftruncate_fn
smbc_getFunctionFtruncate(SMBCCTX
*c
);
900 void smbc_setFunctionFtruncate(SMBCCTX
*c
, smbc_ftruncate_fn fn
);
902 typedef int (*smbc_close_fn
)(SMBCCTX
*c
,
904 smbc_close_fn
smbc_getFunctionClose(SMBCCTX
*c
);
905 void smbc_setFunctionClose(SMBCCTX
*c
, smbc_close_fn fn
);
909 /*****************************************************************
910 * Callable functions for directories. *
911 * Each callable has a function signature typedef, a declaration *
912 * for the getter, and a declaration for the setter. *
913 *****************************************************************/
915 typedef SMBCFILE
* (*smbc_opendir_fn
)(SMBCCTX
*c
,
917 smbc_opendir_fn
smbc_getFunctionOpendir(SMBCCTX
*c
);
918 void smbc_setFunctionOpendir(SMBCCTX
*c
, smbc_opendir_fn fn
);
920 typedef int (*smbc_closedir_fn
)(SMBCCTX
*c
,
922 smbc_closedir_fn
smbc_getFunctionClosedir(SMBCCTX
*c
);
923 void smbc_setFunctionClosedir(SMBCCTX
*c
, smbc_closedir_fn fn
);
925 typedef struct smbc_dirent
* (*smbc_readdir_fn
)(SMBCCTX
*c
,
927 smbc_readdir_fn
smbc_getFunctionReaddir(SMBCCTX
*c
);
928 void smbc_setFunctionReaddir(SMBCCTX
*c
, smbc_readdir_fn fn
);
930 typedef int (*smbc_getdents_fn
)(SMBCCTX
*c
,
932 struct smbc_dirent
*dirp
,
934 smbc_getdents_fn
smbc_getFunctionGetdents(SMBCCTX
*c
);
935 void smbc_setFunctionGetdents(SMBCCTX
*c
, smbc_getdents_fn fn
);
937 typedef int (*smbc_mkdir_fn
)(SMBCCTX
*c
,
940 smbc_mkdir_fn
smbc_getFunctionMkdir(SMBCCTX
*c
);
941 void smbc_setFunctionMkdir(SMBCCTX
*c
, smbc_mkdir_fn fn
);
943 typedef int (*smbc_rmdir_fn
)(SMBCCTX
*c
,
945 smbc_rmdir_fn
smbc_getFunctionRmdir(SMBCCTX
*c
);
946 void smbc_setFunctionRmdir(SMBCCTX
*c
, smbc_rmdir_fn fn
);
948 typedef off_t (*smbc_telldir_fn
)(SMBCCTX
*c
,
950 smbc_telldir_fn
smbc_getFunctionTelldir(SMBCCTX
*c
);
951 void smbc_setFunctionTelldir(SMBCCTX
*c
, smbc_telldir_fn fn
);
953 typedef int (*smbc_lseekdir_fn
)(SMBCCTX
*c
,
956 smbc_lseekdir_fn
smbc_getFunctionLseekdir(SMBCCTX
*c
);
957 void smbc_setFunctionLseekdir(SMBCCTX
*c
, smbc_lseekdir_fn fn
);
959 typedef int (*smbc_fstatdir_fn
)(SMBCCTX
*c
,
962 smbc_fstatdir_fn
smbc_getFunctionFstatdir(SMBCCTX
*c
);
963 void smbc_setFunctionFstatdir(SMBCCTX
*c
, smbc_fstatdir_fn fn
);
967 /*****************************************************************
968 * Callable functions applicable to both files and directories. *
969 * Each callable has a function signature typedef, a declaration *
970 * for the getter, and a declaration for the setter. *
971 *****************************************************************/
973 typedef int (*smbc_chmod_fn
)(SMBCCTX
*c
,
976 smbc_chmod_fn
smbc_getFunctionChmod(SMBCCTX
*c
);
977 void smbc_setFunctionChmod(SMBCCTX
*c
, smbc_chmod_fn fn
);
979 typedef int (*smbc_utimes_fn
)(SMBCCTX
*c
,
981 struct timeval
*tbuf
);
982 smbc_utimes_fn
smbc_getFunctionUtimes(SMBCCTX
*c
);
983 void smbc_setFunctionUtimes(SMBCCTX
*c
, smbc_utimes_fn fn
);
985 typedef int (*smbc_setxattr_fn
)(SMBCCTX
*context
,
991 smbc_setxattr_fn
smbc_getFunctionSetxattr(SMBCCTX
*c
);
992 void smbc_setFunctionSetxattr(SMBCCTX
*c
, smbc_setxattr_fn fn
);
994 typedef int (*smbc_getxattr_fn
)(SMBCCTX
*context
,
999 smbc_getxattr_fn
smbc_getFunctionGetxattr(SMBCCTX
*c
);
1000 void smbc_setFunctionGetxattr(SMBCCTX
*c
, smbc_getxattr_fn fn
);
1002 typedef int (*smbc_removexattr_fn
)(SMBCCTX
*context
,
1005 smbc_removexattr_fn
smbc_getFunctionRemovexattr(SMBCCTX
*c
);
1006 void smbc_setFunctionRemovexattr(SMBCCTX
*c
, smbc_removexattr_fn fn
);
1008 typedef int (*smbc_listxattr_fn
)(SMBCCTX
*context
,
1012 smbc_listxattr_fn
smbc_getFunctionListxattr(SMBCCTX
*c
);
1013 void smbc_setFunctionListxattr(SMBCCTX
*c
, smbc_listxattr_fn fn
);
1017 /*****************************************************************
1018 * Callable functions for printing. *
1019 * Each callable has a function signature typedef, a declaration *
1020 * for the getter, and a declaration for the setter. *
1021 *****************************************************************/
1023 typedef int (*smbc_print_file_fn
)(SMBCCTX
*c_file
,
1026 const char *printq
);
1027 smbc_print_file_fn
smbc_getFunctionPrintFile(SMBCCTX
*c
);
1028 void smbc_setFunctionPrintFile(SMBCCTX
*c
, smbc_print_file_fn fn
);
1030 typedef SMBCFILE
* (*smbc_open_print_job_fn
)(SMBCCTX
*c
,
1032 smbc_open_print_job_fn
smbc_getFunctionOpenPrintJob(SMBCCTX
*c
);
1033 void smbc_setFunctionOpenPrintJob(SMBCCTX
*c
,
1034 smbc_open_print_job_fn fn
);
1036 typedef int (*smbc_list_print_jobs_fn
)(SMBCCTX
*c
,
1038 smbc_list_print_job_fn fn
);
1039 smbc_list_print_jobs_fn
smbc_getFunctionListPrintJobs(SMBCCTX
*c
);
1040 void smbc_setFunctionListPrintJobs(SMBCCTX
*c
,
1041 smbc_list_print_jobs_fn fn
);
1043 typedef int (*smbc_unlink_print_job_fn
)(SMBCCTX
*c
,
1046 smbc_unlink_print_job_fn
smbc_getFunctionUnlinkPrintJob(SMBCCTX
*c
);
1047 void smbc_setFunctionUnlinkPrintJob(SMBCCTX
*c
,
1048 smbc_unlink_print_job_fn fn
);
1052 * Create a new SBMCCTX (a context).
1054 * Must be called before the context is passed to smbc_context_init()
1056 * @return The given SMBCCTX pointer on success, NULL on error with errno set:
1057 * - ENOMEM Out of memory
1059 * @see smbc_free_context(), smbc_init_context()
1061 * @note Do not forget to smbc_init_context() the returned SMBCCTX pointer !
1063 SMBCCTX
* smbc_new_context(void);
1066 * Delete a SBMCCTX (a context) acquired from smbc_new_context().
1068 * The context will be deleted if possible.
1070 * @param context A pointer to a SMBCCTX obtained from smbc_new_context()
1072 * @param shutdown_ctx If 1, all connections and files will be closed even if they are busy.
1075 * @return Returns 0 on succes. Returns 1 on failure with errno set:
1076 * - EBUSY Server connections are still used, Files are open or cache
1077 * could not be purged
1078 * - EBADF context == NULL
1080 * @see smbc_new_context()
1082 * @note It is advised to clean up all the contexts with shutdown_ctx set to 1
1083 * just before exit()'ing. When shutdown_ctx is 0, this function can be
1084 * use in periodical cleanup functions for example.
1086 int smbc_free_context(SMBCCTX
* context
, int shutdown_ctx
);
1091 * @deprecated. Use smbc_setOption*() functions instead.
1094 smbc_option_set(SMBCCTX
*context
,
1096 ... /* option_value */);
1099 * @deprecated. Use smbc_getOption*() functions instead.
1102 smbc_option_get(SMBCCTX
*context
,
1106 * Initialize a SBMCCTX (a context).
1108 * Must be called before using any SMBCCTX API function
1110 * @param context A pointer to a SMBCCTX obtained from smbc_new_context()
1112 * @return A pointer to the given SMBCCTX on success,
1113 * NULL on error with errno set:
1114 * - EBADF NULL context given
1115 * - ENOMEM Out of memory
1116 * - ENOENT The smb.conf file would not load
1118 * @see smbc_new_context()
1120 * @note my_context = smbc_init_context(smbc_new_context())
1121 * is perfectly safe, but it might leak memory on
1122 * smbc_context_init() failure. Avoid this.
1123 * You'll have to call smbc_free_context() yourself
1127 SMBCCTX
* smbc_init_context(SMBCCTX
* context
);
1130 * Initialize the samba client library.
1132 * Must be called before using any of the smbclient API function
1134 * @param fn The function that will be called to obtaion
1135 * authentication credentials.
1137 * @param debug Allows caller to set the debug level. Can be
1138 * changed in smb.conf file. Allows caller to set
1139 * debugging if no smb.conf.
1141 * @return 0 on success, < 0 on error with errno set:
1142 * - ENOMEM Out of memory
1143 * - ENOENT The smb.conf file would not load
1147 int smbc_init(smbc_get_auth_data_fn fn
, int debug
);
1150 * Set or retrieve the compatibility library's context pointer
1152 * @param context New context to use, or NULL. If a new context is provided,
1153 * it must have allocated with smbc_new_context() and
1154 * initialized with smbc_init_context(), followed, optionally,
1155 * by some manual changes to some of the non-internal fields.
1157 * @return The old context.
1159 * @see smbc_new_context(), smbc_init_context(), smbc_init()
1161 * @note This function may be called prior to smbc_init() to force
1162 * use of the next context without any internal calls to
1163 * smbc_new_context() or smbc_init_context(). It may also
1164 * be called after smbc_init() has already called those two
1165 * functions, to replace the existing context with a new one.
1166 * Care should be taken, in this latter case, to ensure that
1167 * the server cache and any data allocated by the
1168 * authentication functions have been freed, if necessary.
1171 SMBCCTX
* smbc_set_context(SMBCCTX
* new_context
);
1174 * Open a file on an SMB server.
1176 * @param furl The smb url of the file to be opened.
1178 * @param flags Is one of O_RDONLY, O_WRONLY or O_RDWR which
1179 * request opening the file read-only,write-only
1180 * or read/write. flags may also be bitwise-or'd with
1181 * one or more of the following:
1182 * O_CREAT - If the file does not exist it will be
1184 * O_EXCL - When used with O_CREAT, if the file
1185 * already exists it is an error and the open will
1187 * O_TRUNC - If the file already exists it will be
1189 * O_APPEND The file is opened in append mode
1191 * @param mode mode specifies the permissions to use if a new
1192 * file is created. It is modified by the
1193 * process's umask in the usual way: the permissions
1194 * of the created file are (mode & ~umask)
1196 * Not currently use, but there for future use.
1197 * We will map this to SYSTEM, HIDDEN, etc bits
1198 * that reverses the mapping that smbc_fstat does.
1200 * @return Valid file handle, < 0 on error with errno set:
1201 * - ENOMEM Out of memory
1202 * - EINVAL if an invalid parameter passed, like no
1203 * file, or smbc_init not called.
1204 * - EEXIST pathname already exists and O_CREAT and
1206 * - EISDIR pathname refers to a directory and
1207 * the access requested involved writing.
1208 * - EACCES The requested access to the file is not
1210 * - ENODEV The requested share does not exist
1211 * - ENOTDIR A file on the path is not a directory
1212 * - ENOENT A directory component in pathname does
1217 * @note This call uses an underlying routine that may create
1218 * a new connection to the server specified in the URL.
1219 * If the credentials supplied in the URL, or via the
1220 * auth_fn in the smbc_init call, fail, this call will
1221 * try again with an empty username and password. This
1222 * often gets mapped to the guest account on some machines.
1225 int smbc_open(const char *furl
, int flags
, mode_t mode
);
1228 * Create a file on an SMB server.
1230 * Same as calling smbc_open() with flags = O_CREAT|O_WRONLY|O_TRUNC
1232 * @param furl The smb url of the file to be created
1234 * @param mode mode specifies the permissions to use if a new
1235 * file is created. It is modified by the
1236 * process's umask in the usual way: the permissions
1237 * of the created file are (mode & ~umask)
1239 * NOTE, the above is not true. We are dealing with
1240 * an SMB server, which has no concept of a umask!
1242 * @return Valid file handle, < 0 on error with errno set:
1243 * - ENOMEM Out of memory
1244 * - EINVAL if an invalid parameter passed, like no
1245 * file, or smbc_init not called.
1246 * - EEXIST pathname already exists and O_CREAT and
1248 * - EISDIR pathname refers to a directory and
1249 * the access requested involved writing.
1250 * - EACCES The requested access to the file is not
1252 * - ENOENT A directory component in pathname does
1254 * - ENODEV The requested share does not exist.
1259 int smbc_creat(const char *furl
, mode_t mode
);
1262 * Read from a file using an opened file handle.
1264 * @param fd Open file handle from smbc_open() or smbc_creat()
1266 * @param buf Pointer to buffer to recieve read data
1268 * @param bufsize Size of buf in bytes
1270 * @return Number of bytes read, < 0 on error with errno set:
1271 * - EISDIR fd refers to a directory
1272 * - EBADF fd is not a valid file descriptor or
1273 * is not open for reading.
1274 * - EINVAL fd is attached to an object which is
1275 * unsuitable for reading, or no buffer passed or
1276 * smbc_init not called.
1278 * @see smbc_open(), smbc_write()
1281 ssize_t
smbc_read(int fd
, void *buf
, size_t bufsize
);
1285 * Write to a file using an opened file handle.
1287 * @param fd Open file handle from smbc_open() or smbc_creat()
1289 * @param buf Pointer to buffer to recieve read data
1291 * @param bufsize Size of buf in bytes
1293 * @return Number of bytes written, < 0 on error with errno set:
1294 * - EISDIR fd refers to a directory.
1295 * - EBADF fd is not a valid file descriptor or
1296 * is not open for reading.
1297 * - EINVAL fd is attached to an object which is
1298 * unsuitable for reading, or no buffer passed or
1299 * smbc_init not called.
1301 * @see smbc_open(), smbc_read()
1304 ssize_t
smbc_write(int fd
, const void *buf
, size_t bufsize
);
1308 * Seek to a specific location in a file.
1310 * @param fd Open file handle from smbc_open() or smbc_creat()
1312 * @param offset Offset in bytes from whence
1314 * @param whence A location in the file:
1315 * - SEEK_SET The offset is set to offset bytes from
1316 * the beginning of the file
1317 * - SEEK_CUR The offset is set to current location
1318 * plus offset bytes.
1319 * - SEEK_END The offset is set to the size of the
1320 * file plus offset bytes.
1322 * @return Upon successful completion, lseek returns the
1323 * resulting offset location as measured in bytes
1324 * from the beginning of the file. Otherwise, a value
1325 * of (off_t)-1 is returned and errno is set to
1326 * indicate the error:
1327 * - EBADF Fildes is not an open file descriptor.
1328 * - EINVAL Whence is not a proper value or smbc_init
1331 * @todo Are all the whence values really supported?
1333 * @todo Are errno values complete and correct?
1335 off_t
smbc_lseek(int fd
, off_t offset
, int whence
);
1339 * Close an open file handle.
1341 * @param fd The file handle to close
1343 * @return 0 on success, < 0 on error with errno set:
1344 * - EBADF fd isn't a valid open file descriptor
1345 * - EINVAL smbc_init() failed or has not been called
1347 * @see smbc_open(), smbc_creat()
1349 int smbc_close(int fd
);
1352 /**@ingroup directory
1353 * Unlink (delete) a file or directory.
1355 * @param furl The smb url of the file to delete
1357 * @return 0 on success, < 0 on error with errno set:
1358 * - EACCES or EPERM Write access to the directory
1359 * containing pathname is not allowed or one
1360 * of the directories in pathname did not allow
1361 * search (execute) permission
1362 * - ENOENT A directory component in pathname does
1364 * - EINVAL NULL was passed in the file param or
1365 * smbc_init not called.
1366 * - EACCES You do not have access to the file
1367 * - ENOMEM Insufficient kernel memory was available
1369 * @see smbc_rmdir()s
1371 * @todo Are errno values complete and correct?
1373 int smbc_unlink(const char *furl
);
1376 /**@ingroup directory
1377 * Rename or move a file or directory.
1379 * @param ourl The original smb url (source url) of file or
1380 * directory to be moved
1382 * @param nurl The new smb url (destination url) of the file
1383 * or directory after the move. Currently nurl must
1384 * be on the same share as ourl.
1386 * @return 0 on success, < 0 on error with errno set:
1387 * - EISDIR nurl is an existing directory, but ourl is
1389 * - EEXIST nurl is a non-empty directory,
1390 * i.e., contains entries other than "." and ".."
1391 * - EINVAL The new url contained a path prefix
1392 * of the old, or, more generally, an attempt was
1393 * made to make a directory a subdirectory of itself
1394 * or smbc_init not called.
1395 * - ENOTDIR A component used as a directory in ourl
1396 * or nurl path is not, in fact, a directory. Or,
1397 * ourl is a directory, and newpath exists but is not
1399 * - EACCES or EPERM Write access to the directory
1400 * containing ourl or nurl is not allowed for the
1401 * process's effective uid, or one of the
1402 * directories in ourl or nurl did not allow search
1403 * (execute) permission, or ourl was a directory
1404 * and did not allow write permission.
1405 * - ENOENT A directory component in ourl or nurl
1407 * - EXDEV Rename across shares not supported.
1408 * - ENOMEM Insufficient kernel memory was available.
1409 * - EEXIST The target file, nurl, already exists.
1412 * @todo Are we going to support copying when urls are not on the same
1413 * share? I say no... NOTE. I agree for the moment.
1416 int smbc_rename(const char *ourl
, const char *nurl
);
1419 /**@ingroup directory
1420 * Open a directory used to obtain directory entries.
1422 * @param durl The smb url of the directory to open
1424 * @return Valid directory handle. < 0 on error with errno set:
1425 * - EACCES Permission denied.
1426 * - EINVAL A NULL file/URL was passed, or the URL would
1427 * not parse, or was of incorrect form or smbc_init not
1429 * - ENOENT durl does not exist, or name is an
1430 * - ENOMEM Insufficient memory to complete the
1432 * - ENOTDIR name is not a directory.
1433 * - EPERM the workgroup could not be found.
1434 * - ENODEV the workgroup or server could not be found.
1436 * @see smbc_getdents(), smbc_readdir(), smbc_closedir()
1439 int smbc_opendir(const char *durl
);
1442 /**@ingroup directory
1443 * Close a directory handle opened by smbc_opendir().
1445 * @param dh Directory handle to close
1447 * @return 0 on success, < 0 on error with errno set:
1448 * - EBADF dh is an invalid directory handle
1450 * @see smbc_opendir()
1452 int smbc_closedir(int dh
);
1455 /**@ingroup directory
1456 * Get multiple directory entries.
1458 * smbc_getdents() reads as many dirent structures from the an open
1459 * directory handle into a specified memory area as will fit.
1461 * @param dh Valid directory as returned by smbc_opendir()
1463 * @param dirp pointer to buffer that will receive the directory
1466 * @param count The size of the dirp buffer in bytes
1468 * @returns If any dirents returned, return will indicate the
1469 * total size. If there were no more dirents available,
1470 * 0 is returned. < 0 indicates an error.
1471 * - EBADF Invalid directory handle
1472 * - EINVAL Result buffer is too small or smbc_init
1474 * - ENOENT No such directory.
1475 * @see , smbc_dirent, smbc_readdir(), smbc_open()
1477 * @todo Are errno values complete and correct?
1479 * @todo Add example code so people know how to parse buffers.
1481 int smbc_getdents(unsigned int dh
, struct smbc_dirent
*dirp
, int count
);
1484 /**@ingroup directory
1485 * Get a single directory entry.
1487 * @param dh Valid directory as returned by smbc_opendir()
1489 * @return A pointer to a smbc_dirent structure, or NULL if an
1490 * error occurs or end-of-directory is reached:
1491 * - EBADF Invalid directory handle
1492 * - EINVAL smbc_init() failed or has not been called
1494 * @see smbc_dirent, smbc_getdents(), smbc_open()
1496 struct smbc_dirent
* smbc_readdir(unsigned int dh
);
1499 /**@ingroup directory
1500 * Get the current directory offset.
1502 * smbc_telldir() may be used in conjunction with smbc_readdir() and
1505 * @param dh Valid directory as returned by smbc_opendir()
1507 * @return The current location in the directory stream or -1
1508 * if an error occur. The current location is not
1509 * an offset. Becuase of the implementation, it is a
1510 * handle that allows the library to find the entry
1512 * - EBADF dh is not a valid directory handle
1513 * - EINVAL smbc_init() failed or has not been called
1514 * - ENOTDIR if dh is not a directory
1516 * @see smbc_readdir()
1519 off_t
smbc_telldir(int dh
);
1522 /**@ingroup directory
1523 * lseek on directories.
1525 * smbc_lseekdir() may be used in conjunction with smbc_readdir() and
1526 * smbc_telldir(). (rewind by smbc_lseekdir(fd, NULL))
1528 * @param fd Valid directory as returned by smbc_opendir()
1530 * @param offset The offset (as returned by smbc_telldir). Can be
1531 * NULL, in which case we will rewind
1533 * @return 0 on success, -1 on failure
1534 * - EBADF dh is not a valid directory handle
1535 * - ENOTDIR if dh is not a directory
1536 * - EINVAL offset did not refer to a valid dirent or
1537 * smbc_init not called.
1539 * @see smbc_telldir()
1542 * @todo In what does the reture and errno values mean?
1544 int smbc_lseekdir(int fd
, off_t offset
);
1546 /**@ingroup directory
1547 * Create a directory.
1549 * @param durl The url of the directory to create
1551 * @param mode Specifies the permissions to use. It is modified
1552 * by the process's umask in the usual way: the
1553 * permissions of the created file are (mode & ~umask).
1555 * @return 0 on success, < 0 on error with errno set:
1556 * - EEXIST directory url already exists
1557 * - EACCES The parent directory does not allow write
1558 * permission to the process, or one of the directories
1559 * - ENOENT A directory component in pathname does not
1561 * - EINVAL NULL durl passed or smbc_init not called.
1562 * - ENOMEM Insufficient memory was available.
1567 int smbc_mkdir(const char *durl
, mode_t mode
);
1570 /**@ingroup directory
1571 * Remove a directory.
1573 * @param durl The smb url of the directory to remove
1575 * @return 0 on success, < 0 on error with errno set:
1576 * - EACCES or EPERM Write access to the directory
1577 * containing pathname was not allowed.
1578 * - EINVAL durl is NULL or smbc_init not called.
1579 * - ENOENT A directory component in pathname does not
1581 * - ENOTEMPTY directory contains entries.
1582 * - ENOMEM Insufficient kernel memory was available.
1584 * @see smbc_mkdir(), smbc_unlink()
1586 * @todo Are errno values complete and correct?
1588 int smbc_rmdir(const char *durl
);
1591 /**@ingroup attribute
1592 * Get information about a file or directory.
1594 * @param url The smb url to get information for
1596 * @param st pointer to a buffer that will be filled with
1597 * standard Unix struct stat information.
1599 * @return 0 on success, < 0 on error with errno set:
1600 * - ENOENT A component of the path file_name does not
1602 * - EINVAL a NULL url was passed or smbc_init not called.
1603 * - EACCES Permission denied.
1604 * - ENOMEM Out of memory
1605 * - ENOTDIR The target dir, url, is not a directory.
1610 int smbc_stat(const char *url
, struct stat
*st
);
1613 /**@ingroup attribute
1614 * Get file information via an file descriptor.
1616 * @param fd Open file handle from smbc_open() or smbc_creat()
1618 * @param st pointer to a buffer that will be filled with
1619 * standard Unix struct stat information.
1621 * @return EBADF filedes is bad.
1622 * - EACCES Permission denied.
1623 * - EBADF fd is not a valid file descriptor
1624 * - EINVAL Problems occurred in the underlying routines
1625 * or smbc_init not called.
1626 * - ENOMEM Out of memory
1628 * @see smbc_stat(), Unix stat()
1631 int smbc_fstat(int fd
, struct stat
*st
);
1634 /**@ingroup attribute
1635 * Get file system information for a specified path.
1637 * @param url The smb url to get information for
1639 * @param st pointer to a buffer that will be filled with
1640 * standard Unix struct statvfs information.
1642 * @return EBADF filedes is bad.
1643 * - EACCES Permission denied.
1644 * - EBADF fd is not a valid file descriptor
1645 * - EINVAL Problems occurred in the underlying routines
1646 * or smbc_init not called.
1647 * - ENOMEM Out of memory
1649 * @see Unix fstatvfs()
1653 smbc_statvfs(char *url
,
1654 struct statvfs
*st
);
1656 /**@ingroup attribute
1657 * Get file system information via an file descriptor.
1659 * @param fd Open file handle from smbc_open(), smbc_creat(),
1662 * @param st pointer to a buffer that will be filled with
1663 * standard Unix struct statvfs information.
1665 * @return EBADF filedes is bad.
1666 * - EACCES Permission denied.
1667 * - EBADF fd is not a valid file descriptor
1668 * - EINVAL Problems occurred in the underlying routines
1669 * or smbc_init not called.
1670 * - ENOMEM Out of memory
1672 * @see Unix fstatvfs()
1676 smbc_fstatvfs(int fd
,
1677 struct statvfs
*st
);
1680 /**@ingroup attribute
1681 * Truncate a file given a file descriptor
1683 * @param fd Open file handle from smbc_open() or smbc_creat()
1685 * @param size size to truncate the file to
1687 * @return EBADF filedes is bad.
1688 * - EACCES Permission denied.
1689 * - EBADF fd is not a valid file descriptor
1690 * - EINVAL Problems occurred in the underlying routines
1691 * or smbc_init not called.
1692 * - ENOMEM Out of memory
1694 * @see , Unix ftruncate()
1697 int smbc_ftruncate(int fd
, off_t size
);
1700 /**@ingroup attribute
1701 * Change the permissions of a file.
1703 * @param url The smb url of the file or directory to change
1706 * @param mode The permissions to set:
1707 * - Put good explaination of permissions here!
1709 * @return 0 on success, < 0 on error with errno set:
1710 * - EPERM The effective UID does not match the owner
1711 * of the file, and is not zero
1712 * - ENOENT The file does not exist.
1713 * - ENOMEM Insufficient was available.
1714 * - ENOENT file or directory does not exist
1716 * @todo Actually implement this fuction?
1718 * @todo Are errno values complete and correct?
1720 int smbc_chmod(const char *url
, mode_t mode
);
1723 * @ingroup attribute
1724 * Change the last modification time on a file
1726 * @param url The smb url of the file or directory to change
1727 * the modification time of
1729 * @param tbuf An array of two timeval structures which contains,
1730 * respectively, the desired access and modification times.
1731 * NOTE: Only the tv_sec field off each timeval structure is
1732 * used. The tv_usec (microseconds) portion is ignored.
1734 * @return 0 on success, < 0 on error with errno set:
1735 * - EINVAL The client library is not properly initialized
1736 * - EPERM Permission was denied.
1739 int smbc_utimes(const char *url
, struct timeval
*tbuf
);
1743 * @ingroup attribute
1744 * Change the last modification time on a file
1746 * @param url The smb url of the file or directory to change
1747 * the modification time of
1749 * @param utbuf A pointer to a utimebuf structure which contains the
1750 * desired access and modification times.
1752 * @return 0 on success, < 0 on error with errno set:
1753 * - EINVAL The client library is not properly initialized
1754 * - ENOMEM No memory was available for internal needs
1755 * - EPERM Permission was denied.
1758 int smbc_utime(const char *fname
, struct utimbuf
*utbuf
);
1761 /**@ingroup attribute
1762 * Set extended attributes for a file. This is used for modifying a file's
1763 * security descriptor (i.e. owner, group, and access control list)
1765 * @param url The smb url of the file or directory to set extended
1768 * @param name The name of an attribute to be changed. Names are of
1769 * one of the following forms:
1771 * system.nt_sec_desc.<attribute name>
1772 * system.nt_sec_desc.*
1773 * system.nt_sec_desc.*+
1775 * where <attribute name> is one of:
1783 * acl+:<name or sid>
1785 * In the forms "system.nt_sec_desc.*" and
1786 * "system.nt_sec_desc.*+", the asterisk and plus signs are
1787 * literal, i.e. the string is provided exactly as shown, and
1788 * the value parameter should contain a complete security
1789 * descriptor with name:value pairs separated by tabs,
1790 * commas, or newlines (not spaces!).
1792 * The plus sign ('+') indicates that SIDs should be mapped
1793 * to names. Without the plus sign, SIDs are not mapped;
1794 * rather they are simply converted to a string format.
1796 * @param value The value to be assigned to the specified attribute name.
1797 * This buffer should contain only the attribute value if the
1798 * name was of the "system.nt_sec_desc.<attribute_name>"
1799 * form. If the name was of the "system.nt_sec_desc.*" form
1800 * then a complete security descriptor, with name:value pairs
1801 * separated by tabs, commas, or newlines (not spaces!),
1802 * should be provided in this value buffer. A complete
1803 * security descriptor will contain one or more entries
1804 * selected from the following:
1806 * REVISION:<revision number>
1807 * OWNER:<sid or name>
1808 * GROUP:<sid or name>
1809 * ACL:<sid or name>:<type>/<flags>/<mask>
1811 * The revision of the ACL specifies the internal Windows NT
1812 * ACL revision for the security descriptor. If not specified
1813 * it defaults to 1. Using values other than 1 may cause
1814 * strange behaviour.
1816 * The owner and group specify the owner and group sids for
1817 * the object. If the attribute name (either '*+' with a
1818 * complete security descriptor, or individual 'owner+' or
1819 * 'group+' attribute names) ended with a plus sign, the
1820 * specified name is resolved to a SID value, using the
1821 * server on which the file or directory resides. Otherwise,
1822 * the value should be provided in SID-printable format as
1823 * S-1-x-y-z, and is used directly. The <sid or name>
1824 * associated with the ACL: attribute should be provided
1827 * @param size The number of the bytes of data in the value buffer
1829 * @param flags A bit-wise OR of zero or more of the following:
1830 * SMBC_XATTR_FLAG_CREATE -
1831 * fail if the named attribute already exists
1832 * SMBC_XATTR_FLAG_REPLACE -
1833 * fail if the attribute does not already exist
1835 * If neither flag is specified, the specified attributes
1836 * will be added or replace existing attributes of the same
1837 * name, as necessary.
1839 * @return 0 on success, < 0 on error with errno set:
1840 * - EINVAL The client library is not properly initialized
1841 * or one of the parameters is not of a correct
1843 * - ENOMEM No memory was available for internal needs
1844 * - EEXIST If the attribute already exists and the flag
1845 * SMBC_XATTR_FLAG_CREAT was specified
1846 * - ENOATTR If the attribute does not exist and the flag
1847 * SMBC_XATTR_FLAG_REPLACE was specified
1848 * - EPERM Permission was denied.
1849 * - ENOTSUP The referenced file system does not support
1850 * extended attributes
1852 * @note Attribute names are compared in a case-insensitive
1853 * fashion. All of the following are equivalent, although
1854 * the all-lower-case name is the preferred format:
1855 * system.nt_sec_desc.owner
1856 * SYSTEM.NT_SEC_DESC.OWNER
1857 * sYsTeM.nt_sEc_desc.owNER
1860 int smbc_setxattr(const char *url
,
1867 /**@ingroup attribute
1868 * Set extended attributes for a file. This is used for modifying a file's
1869 * security descriptor (i.e. owner, group, and access control list). The
1870 * POSIX function which this maps to would act on a symbolic link rather than
1871 * acting on what the symbolic link points to, but with no symbolic links in
1872 * SMB file systems, this function is functionally identical to
1875 * @param url The smb url of the file or directory to set extended
1878 * @param name The name of an attribute to be changed. Names are of
1879 * one of the following forms:
1881 * system.nt_sec_desc.<attribute name>
1882 * system.nt_sec_desc.*
1883 * system.nt_sec_desc.*+
1885 * where <attribute name> is one of:
1893 * acl+:<name or sid>
1895 * In the forms "system.nt_sec_desc.*" and
1896 * "system.nt_sec_desc.*+", the asterisk and plus signs are
1897 * literal, i.e. the string is provided exactly as shown, and
1898 * the value parameter should contain a complete security
1899 * descriptor with name:value pairs separated by tabs,
1900 * commas, or newlines (not spaces!).
1902 * The plus sign ('+') indicates that SIDs should be mapped
1903 * to names. Without the plus sign, SIDs are not mapped;
1904 * rather they are simply converted to a string format.
1906 * @param value The value to be assigned to the specified attribute name.
1907 * This buffer should contain only the attribute value if the
1908 * name was of the "system.nt_sec_desc.<attribute_name>"
1909 * form. If the name was of the "system.nt_sec_desc.*" form
1910 * then a complete security descriptor, with name:value pairs
1911 * separated by tabs, commas, or newlines (not spaces!),
1912 * should be provided in this value buffer. A complete
1913 * security descriptor will contain one or more entries
1914 * selected from the following:
1916 * REVISION:<revision number>
1917 * OWNER:<sid or name>
1918 * GROUP:<sid or name>
1919 * ACL:<sid or name>:<type>/<flags>/<mask>
1921 * The revision of the ACL specifies the internal Windows NT
1922 * ACL revision for the security descriptor. If not specified
1923 * it defaults to 1. Using values other than 1 may cause
1924 * strange behaviour.
1926 * The owner and group specify the owner and group sids for
1927 * the object. If the attribute name (either '*+' with a
1928 * complete security descriptor, or individual 'owner+' or
1929 * 'group+' attribute names) ended with a plus sign, the
1930 * specified name is resolved to a SID value, using the
1931 * server on which the file or directory resides. Otherwise,
1932 * the value should be provided in SID-printable format as
1933 * S-1-x-y-z, and is used directly. The <sid or name>
1934 * associated with the ACL: attribute should be provided
1937 * @param size The number of the bytes of data in the value buffer
1939 * @param flags A bit-wise OR of zero or more of the following:
1940 * SMBC_XATTR_FLAG_CREATE -
1941 * fail if the named attribute already exists
1942 * SMBC_XATTR_FLAG_REPLACE -
1943 * fail if the attribute does not already exist
1945 * If neither flag is specified, the specified attributes
1946 * will be added or replace existing attributes of the same
1947 * name, as necessary.
1949 * @return 0 on success, < 0 on error with errno set:
1950 * - EINVAL The client library is not properly initialized
1951 * or one of the parameters is not of a correct
1953 * - ENOMEM No memory was available for internal needs
1954 * - EEXIST If the attribute already exists and the flag
1955 * SMBC_XATTR_FLAG_CREAT was specified
1956 * - ENOATTR If the attribute does not exist and the flag
1957 * SMBC_XATTR_FLAG_REPLACE was specified
1958 * - EPERM Permission was denied.
1959 * - ENOTSUP The referenced file system does not support
1960 * extended attributes
1962 * @note Attribute names are compared in a case-insensitive
1963 * fashion. All of the following are equivalent, although
1964 * the all-lower-case name is the preferred format:
1965 * system.nt_sec_desc.owner
1966 * SYSTEM.NT_SEC_DESC.OWNER
1967 * sYsTeM.nt_sEc_desc.owNER
1970 int smbc_lsetxattr(const char *url
,
1977 /**@ingroup attribute
1978 * Set extended attributes for a file. This is used for modifying a file's
1979 * security descriptor (i.e. owner, group, and access control list)
1981 * @param fd A file descriptor associated with an open file (as
1982 * previously returned by smbc_open(), to get extended
1985 * @param name The name of an attribute to be changed. Names are of
1986 * one of the following forms:
1988 * system.nt_sec_desc.<attribute name>
1989 * system.nt_sec_desc.*
1990 * system.nt_sec_desc.*+
1992 * where <attribute name> is one of:
2000 * acl+:<name or sid>
2002 * In the forms "system.nt_sec_desc.*" and
2003 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2004 * literal, i.e. the string is provided exactly as shown, and
2005 * the value parameter should contain a complete security
2006 * descriptor with name:value pairs separated by tabs,
2007 * commas, or newlines (not spaces!).
2009 * The plus sign ('+') indicates that SIDs should be mapped
2010 * to names. Without the plus sign, SIDs are not mapped;
2011 * rather they are simply converted to a string format.
2013 * @param value The value to be assigned to the specified attribute name.
2014 * This buffer should contain only the attribute value if the
2015 * name was of the "system.nt_sec_desc.<attribute_name>"
2016 * form. If the name was of the "system.nt_sec_desc.*" form
2017 * then a complete security descriptor, with name:value pairs
2018 * separated by tabs, commas, or newlines (not spaces!),
2019 * should be provided in this value buffer. A complete
2020 * security descriptor will contain one or more entries
2021 * selected from the following:
2023 * REVISION:<revision number>
2024 * OWNER:<sid or name>
2025 * GROUP:<sid or name>
2026 * ACL:<sid or name>:<type>/<flags>/<mask>
2028 * The revision of the ACL specifies the internal Windows NT
2029 * ACL revision for the security descriptor. If not specified
2030 * it defaults to 1. Using values other than 1 may cause
2031 * strange behaviour.
2033 * The owner and group specify the owner and group sids for
2034 * the object. If the attribute name (either '*+' with a
2035 * complete security descriptor, or individual 'owner+' or
2036 * 'group+' attribute names) ended with a plus sign, the
2037 * specified name is resolved to a SID value, using the
2038 * server on which the file or directory resides. Otherwise,
2039 * the value should be provided in SID-printable format as
2040 * S-1-x-y-z, and is used directly. The <sid or name>
2041 * associated with the ACL: attribute should be provided
2044 * @param size The number of the bytes of data in the value buffer
2046 * @param flags A bit-wise OR of zero or more of the following:
2047 * SMBC_XATTR_FLAG_CREATE -
2048 * fail if the named attribute already exists
2049 * SMBC_XATTR_FLAG_REPLACE -
2050 * fail if the attribute does not already exist
2052 * If neither flag is specified, the specified attributes
2053 * will be added or replace existing attributes of the same
2054 * name, as necessary.
2056 * @return 0 on success, < 0 on error with errno set:
2057 * - EINVAL The client library is not properly initialized
2058 * or one of the parameters is not of a correct
2060 * - ENOMEM No memory was available for internal needs
2061 * - EEXIST If the attribute already exists and the flag
2062 * SMBC_XATTR_FLAG_CREAT was specified
2063 * - ENOATTR If the attribute does not exist and the flag
2064 * SMBC_XATTR_FLAG_REPLACE was specified
2065 * - EPERM Permission was denied.
2066 * - ENOTSUP The referenced file system does not support
2067 * extended attributes
2069 * @note Attribute names are compared in a case-insensitive
2070 * fashion. All of the following are equivalent, although
2071 * the all-lower-case name is the preferred format:
2072 * system.nt_sec_desc.owner
2073 * SYSTEM.NT_SEC_DESC.OWNER
2074 * sYsTeM.nt_sEc_desc.owNER
2077 int smbc_fsetxattr(int fd
,
2084 /**@ingroup attribute
2085 * Get extended attributes for a file.
2087 * @param url The smb url of the file or directory to get extended
2090 * @param name The name of an attribute to be retrieved. Names are of
2091 * one of the following forms:
2093 * system.nt_sec_desc.<attribute name>
2094 * system.nt_sec_desc.*
2095 * system.nt_sec_desc.*+
2097 * where <attribute name> is one of:
2105 * acl+:<name or sid>
2107 * In the forms "system.nt_sec_desc.*" and
2108 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2109 * literal, i.e. the string is provided exactly as shown, and
2110 * the value parameter will return a complete security
2111 * descriptor with name:value pairs separated by tabs,
2112 * commas, or newlines (not spaces!).
2114 * The plus sign ('+') indicates that SIDs should be mapped
2115 * to names. Without the plus sign, SIDs are not mapped;
2116 * rather they are simply converted to a string format.
2118 * @param value A pointer to a buffer in which the value of the specified
2119 * attribute will be placed (unless size is zero).
2121 * @param size The size of the buffer pointed to by value. This parameter
2122 * may also be zero, in which case the size of the buffer
2123 * required to hold the attribute value will be returned,
2124 * but nothing will be placed into the value buffer.
2126 * @return 0 on success, < 0 on error with errno set:
2127 * - EINVAL The client library is not properly initialized
2128 * or one of the parameters is not of a correct
2130 * - ENOMEM No memory was available for internal needs
2131 * - EEXIST If the attribute already exists and the flag
2132 * SMBC_XATTR_FLAG_CREAT was specified
2133 * - ENOATTR If the attribute does not exist and the flag
2134 * SMBC_XATTR_FLAG_REPLACE was specified
2135 * - EPERM Permission was denied.
2136 * - ENOTSUP The referenced file system does not support
2137 * extended attributes
2140 int smbc_getxattr(const char *url
,
2146 /**@ingroup attribute
2147 * Get extended attributes for a file. The POSIX function which this maps to
2148 * would act on a symbolic link rather than acting on what the symbolic link
2149 * points to, but with no symbolic links in SMB file systems, this function
2150 * is functionally identical to smbc_getxattr().
2152 * @param url The smb url of the file or directory to get extended
2155 * @param name The name of an attribute to be retrieved. Names are of
2156 * one of the following forms:
2158 * system.nt_sec_desc.<attribute name>
2159 * system.nt_sec_desc.*
2160 * system.nt_sec_desc.*+
2162 * where <attribute name> is one of:
2170 * acl+:<name or sid>
2172 * In the forms "system.nt_sec_desc.*" and
2173 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2174 * literal, i.e. the string is provided exactly as shown, and
2175 * the value parameter will return a complete security
2176 * descriptor with name:value pairs separated by tabs,
2177 * commas, or newlines (not spaces!).
2179 * The plus sign ('+') indicates that SIDs should be mapped
2180 * to names. Without the plus sign, SIDs are not mapped;
2181 * rather they are simply converted to a string format.
2183 * @param value A pointer to a buffer in which the value of the specified
2184 * attribute will be placed (unless size is zero).
2186 * @param size The size of the buffer pointed to by value. This parameter
2187 * may also be zero, in which case the size of the buffer
2188 * required to hold the attribute value will be returned,
2189 * but nothing will be placed into the value buffer.
2191 * @return 0 on success, < 0 on error with errno set:
2192 * - EINVAL The client library is not properly initialized
2193 * or one of the parameters is not of a correct
2195 * - ENOMEM No memory was available for internal needs
2196 * - EEXIST If the attribute already exists and the flag
2197 * SMBC_XATTR_FLAG_CREAT was specified
2198 * - ENOATTR If the attribute does not exist and the flag
2199 * SMBC_XATTR_FLAG_REPLACE was specified
2200 * - EPERM Permission was denied.
2201 * - ENOTSUP The referenced file system does not support
2202 * extended attributes
2205 int smbc_lgetxattr(const char *url
,
2211 /**@ingroup attribute
2212 * Get extended attributes for a file.
2214 * @param fd A file descriptor associated with an open file (as
2215 * previously returned by smbc_open(), to get extended
2218 * @param name The name of an attribute to be retrieved. Names are of
2219 * one of the following forms:
2221 * system.nt_sec_desc.<attribute name>
2222 * system.nt_sec_desc.*
2223 * system.nt_sec_desc.*+
2225 * where <attribute name> is one of:
2233 * acl+:<name or sid>
2235 * In the forms "system.nt_sec_desc.*" and
2236 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2237 * literal, i.e. the string is provided exactly as shown, and
2238 * the value parameter will return a complete security
2239 * descriptor with name:value pairs separated by tabs,
2240 * commas, or newlines (not spaces!).
2242 * The plus sign ('+') indicates that SIDs should be mapped
2243 * to names. Without the plus sign, SIDs are not mapped;
2244 * rather they are simply converted to a string format.
2246 * @param value A pointer to a buffer in which the value of the specified
2247 * attribute will be placed (unless size is zero).
2249 * @param size The size of the buffer pointed to by value. This parameter
2250 * may also be zero, in which case the size of the buffer
2251 * required to hold the attribute value will be returned,
2252 * but nothing will be placed into the value buffer.
2254 * @return 0 on success, < 0 on error with errno set:
2255 * - EINVAL The client library is not properly initialized
2256 * or one of the parameters is not of a correct
2258 * - ENOMEM No memory was available for internal needs
2259 * - EEXIST If the attribute already exists and the flag
2260 * SMBC_XATTR_FLAG_CREAT was specified
2261 * - ENOATTR If the attribute does not exist and the flag
2262 * SMBC_XATTR_FLAG_REPLACE was specified
2263 * - EPERM Permission was denied.
2264 * - ENOTSUP The referenced file system does not support
2265 * extended attributes
2268 int smbc_fgetxattr(int fd
,
2274 /**@ingroup attribute
2275 * Remove extended attributes for a file. This is used for modifying a file's
2276 * security descriptor (i.e. owner, group, and access control list)
2278 * @param url The smb url of the file or directory to remove the extended
2281 * @param name The name of an attribute to be removed. Names are of
2282 * one of the following forms:
2284 * system.nt_sec_desc.<attribute name>
2285 * system.nt_sec_desc.*
2286 * system.nt_sec_desc.*+
2288 * where <attribute name> is one of:
2296 * acl+:<name or sid>
2298 * In the forms "system.nt_sec_desc.*" and
2299 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2300 * literal, i.e. the string is provided exactly as shown, and
2301 * the value parameter will return a complete security
2302 * descriptor with name:value pairs separated by tabs,
2303 * commas, or newlines (not spaces!).
2305 * The plus sign ('+') indicates that SIDs should be mapped
2306 * to names. Without the plus sign, SIDs are not mapped;
2307 * rather they are simply converted to a string format.
2309 * @return 0 on success, < 0 on error with errno set:
2310 * - EINVAL The client library is not properly initialized
2311 * - ENOMEM No memory was available for internal needs
2312 * - EPERM Permission was denied.
2313 * - ENOTSUP The referenced file system does not support
2314 * extended attributes
2317 int smbc_removexattr(const char *url
,
2321 /**@ingroup attribute
2322 * Remove extended attributes for a file. This is used for modifying a file's
2323 * security descriptor (i.e. owner, group, and access control list) The POSIX
2324 * function which this maps to would act on a symbolic link rather than acting
2325 * on what the symbolic link points to, but with no symbolic links in SMB file
2326 * systems, this function is functionally identical to smbc_removexattr().
2328 * @param url The smb url of the file or directory to remove the extended
2331 * @param name The name of an attribute to be removed. Names are of
2332 * one of the following forms:
2334 * system.nt_sec_desc.<attribute name>
2335 * system.nt_sec_desc.*
2336 * system.nt_sec_desc.*+
2338 * where <attribute name> is one of:
2346 * acl+:<name or sid>
2348 * In the forms "system.nt_sec_desc.*" and
2349 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2350 * literal, i.e. the string is provided exactly as shown, and
2351 * the value parameter will return a complete security
2352 * descriptor with name:value pairs separated by tabs,
2353 * commas, or newlines (not spaces!).
2355 * The plus sign ('+') indicates that SIDs should be mapped
2356 * to names. Without the plus sign, SIDs are not mapped;
2357 * rather they are simply converted to a string format.
2359 * @return 0 on success, < 0 on error with errno set:
2360 * - EINVAL The client library is not properly initialized
2361 * - ENOMEM No memory was available for internal needs
2362 * - EPERM Permission was denied.
2363 * - ENOTSUP The referenced file system does not support
2364 * extended attributes
2367 int smbc_lremovexattr(const char *url
,
2371 /**@ingroup attribute
2372 * Remove extended attributes for a file. This is used for modifying a file's
2373 * security descriptor (i.e. owner, group, and access control list)
2375 * @param fd A file descriptor associated with an open file (as
2376 * previously returned by smbc_open(), to get extended
2379 * @param name The name of an attribute to be removed. Names are of
2380 * one of the following forms:
2382 * system.nt_sec_desc.<attribute name>
2383 * system.nt_sec_desc.*
2384 * system.nt_sec_desc.*+
2386 * where <attribute name> is one of:
2394 * acl+:<name or sid>
2396 * In the forms "system.nt_sec_desc.*" and
2397 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2398 * literal, i.e. the string is provided exactly as shown, and
2399 * the value parameter will return a complete security
2400 * descriptor with name:value pairs separated by tabs,
2401 * commas, or newlines (not spaces!).
2403 * The plus sign ('+') indicates that SIDs should be mapped
2404 * to names. Without the plus sign, SIDs are not mapped;
2405 * rather they are simply converted to a string format.
2407 * @return 0 on success, < 0 on error with errno set:
2408 * - EINVAL The client library is not properly initialized
2409 * - ENOMEM No memory was available for internal needs
2410 * - EPERM Permission was denied.
2411 * - ENOTSUP The referenced file system does not support
2412 * extended attributes
2415 int smbc_fremovexattr(int fd
,
2419 /**@ingroup attribute
2420 * List the supported extended attribute names associated with a file
2422 * @param url The smb url of the file or directory to list the extended
2425 * @param list A pointer to a buffer in which the list of attributes for
2426 * the specified file or directory will be placed (unless
2429 * @param size The size of the buffer pointed to by list. This parameter
2430 * may also be zero, in which case the size of the buffer
2431 * required to hold all of the attribute names will be
2432 * returned, but nothing will be placed into the list buffer.
2434 * @return 0 on success, < 0 on error with errno set:
2435 * - EINVAL The client library is not properly initialized
2436 * - ENOMEM No memory was available for internal needs
2437 * - EPERM Permission was denied.
2438 * - ENOTSUP The referenced file system does not support
2439 * extended attributes
2441 * @note This function always returns all attribute names supported
2442 * by NT file systems, regardless of whether the referenced
2443 * file system supports extended attributes (e.g. a Windows
2444 * 2000 machine supports extended attributes if NTFS is used,
2445 * but not if FAT is used, and Windows 98 doesn't support
2446 * extended attributes at all. Whether this is a feature or
2447 * a bug is yet to be decided.
2449 int smbc_listxattr(const char *url
,
2453 /**@ingroup attribute
2454 * List the supported extended attribute names associated with a file The
2455 * POSIX function which this maps to would act on a symbolic link rather than
2456 * acting on what the symbolic link points to, but with no symbolic links in
2457 * SMB file systems, this function is functionally identical to
2460 * @param url The smb url of the file or directory to list the extended
2463 * @param list A pointer to a buffer in which the list of attributes for
2464 * the specified file or directory will be placed (unless
2467 * @param size The size of the buffer pointed to by list. This parameter
2468 * may also be zero, in which case the size of the buffer
2469 * required to hold all of the attribute names will be
2470 * returned, but nothing will be placed into the list buffer.
2472 * @return 0 on success, < 0 on error with errno set:
2473 * - EINVAL The client library is not properly initialized
2474 * - ENOMEM No memory was available for internal needs
2475 * - EPERM Permission was denied.
2476 * - ENOTSUP The referenced file system does not support
2477 * extended attributes
2479 * @note This function always returns all attribute names supported
2480 * by NT file systems, regardless of wether the referenced
2481 * file system supports extended attributes (e.g. a Windows
2482 * 2000 machine supports extended attributes if NTFS is used,
2483 * but not if FAT is used, and Windows 98 doesn't support
2484 * extended attributes at all. Whether this is a feature or
2485 * a bug is yet to be decided.
2487 int smbc_llistxattr(const char *url
,
2491 /**@ingroup attribute
2492 * List the supported extended attribute names associated with a file
2494 * @param fd A file descriptor associated with an open file (as
2495 * previously returned by smbc_open(), to get extended
2498 * @param list A pointer to a buffer in which the list of attributes for
2499 * the specified file or directory will be placed (unless
2502 * @param size The size of the buffer pointed to by list. This parameter
2503 * may also be zero, in which case the size of the buffer
2504 * required to hold all of the attribute names will be
2505 * returned, but nothing will be placed into the list buffer.
2507 * @return 0 on success, < 0 on error with errno set:
2508 * - EINVAL The client library is not properly initialized
2509 * - ENOMEM No memory was available for internal needs
2510 * - EPERM Permission was denied.
2511 * - ENOTSUP The referenced file system does not support
2512 * extended attributes
2514 * @note This function always returns all attribute names supported
2515 * by NT file systems, regardless of wether the referenced
2516 * file system supports extended attributes (e.g. a Windows
2517 * 2000 machine supports extended attributes if NTFS is used,
2518 * but not if FAT is used, and Windows 98 doesn't support
2519 * extended attributes at all. Whether this is a feature or
2520 * a bug is yet to be decided.
2522 int smbc_flistxattr(int fd
,
2527 * Print a file given the name in fname. It would be a URL ...
2529 * @param fname The URL of a file on a remote SMB server that the
2530 * caller wants printed
2532 * @param printq The URL of the print share to print the file to.
2534 * @return 0 on success, < 0 on error with errno set:
2536 * - EINVAL fname or printq was NULL or smbc_init not
2538 * and errors returned by smbc_open
2541 int smbc_print_file(const char *fname
, const char *printq
);
2544 * Open a print file that can be written to by other calls. This simply
2545 * does an smbc_open call after checking if there is a file name on the
2546 * URI. If not, a temporary name is added ...
2548 * @param fname The URL of the print share to print to?
2550 * @returns A file handle for the print file if successful.
2551 * Returns -1 if an error ocurred and errno has the values
2552 * - EINVAL fname was NULL or smbc_init not called.
2553 * - all errors returned by smbc_open
2556 int smbc_open_print_job(const char *fname
);
2559 * List the print jobs on a print share, for the moment, pass a callback
2561 * @param purl The url of the print share to list the jobs of
2563 * @param fn Callback function the receives printjob info
2565 * @return 0 on success, < 0 on error with errno set:
2566 * - EINVAL fname was NULL or smbc_init not called
2569 int smbc_list_print_jobs(const char *purl
, smbc_list_print_job_fn fn
);
2572 * Delete a print job
2574 * @param purl Url of the print share
2576 * @param id The id of the job to delete
2578 * @return 0 on success, < 0 on error with errno set:
2579 * - EINVAL fname was NULL or smbc_init not called
2581 * @todo what errno values are possible here?
2583 int smbc_unlink_print_job(const char *purl
, int id
);
2585 /**@ingroup callback
2586 * Remove a server from the cached server list it's unused.
2588 * @param context pointer to smb context
2590 * @param srv pointer to server to remove
2592 * @return On success, 0 is returned. 1 is returned if the server could not
2593 * be removed. Also useable outside libsmbclient.
2595 int smbc_remove_unused_server(SMBCCTX
* context
, SMBCSRV
* srv
);
2601 /**@ingroup directory
2602 * Convert strings of %xx to their single character equivalent.
2604 * @param dest A pointer to a buffer in which the resulting decoded
2605 * string should be placed. This may be a pointer to the
2606 * same buffer as src_segment.
2608 * @param src A pointer to the buffer containing the URL to be decoded.
2609 * Any %xx sequences herein are converted to their single
2610 * character equivalent. Each 'x' must be a valid hexadecimal
2611 * digit, or that % sequence is left undecoded.
2613 * @param max_dest_len
2614 * The size of the buffer pointed to by dest_segment.
2616 * @return The number of % sequences which could not be converted
2617 * due to lack of two following hexadecimal digits.
2623 smbc_urldecode(char *dest
, char * src
, size_t max_dest_len
);
2630 * Convert any characters not specifically allowed in a URL into their %xx
2633 * @param dest A pointer to a buffer in which the resulting encoded
2634 * string should be placed. Unlike smbc_urldecode(), this
2635 * must be a buffer unique from src.
2637 * @param src A pointer to the buffer containing the string to be encoded.
2638 * Any character not specifically allowed in a URL is converted
2639 * into its hexadecimal value and encoded as %xx.
2641 * @param max_dest_len
2642 * The size of the buffer pointed to by dest_segment.
2644 * @returns The remaining buffer length.
2650 smbc_urlencode(char * dest
, char * src
, int max_dest_len
);
2656 /**@ingroup directory
2657 * Return the version of the linked Samba code, and thus the version of the
2658 * libsmbclient code.
2660 * @return The version string.
2672 * Set the users credentials globally so they can be used for DFS
2673 * referrals. Probably best to use this function in the smbc_get_auth_data_fn
2676 * @param workgroup Workgroup of the user.
2678 * @param user Username of user.
2680 * @param password Password of user.
2682 * @param use_kerberos Whether to use Kerberos
2684 * @param signing_state One of these strings (all equivalents on same line):
2685 * "off", "no", "false"
2686 * "on", "yes", "true", "auto"
2687 * "force", "required", "forced"
2691 smbc_set_credentials(const char *workgroup
,
2693 const char *password
,
2694 smbc_bool use_kerberos
,
2695 const char *signing_state
);
2698 * Wrapper around smbc_set_credentials.
2699 * Used to set correct credentials that will
2700 * be used to connect to DFS target share
2705 smbc_set_credentials_with_fallback(SMBCCTX
*ctx
,
2706 const char *workgroup
,
2708 const char *password
);
2714 * Initialize for threads using the Posix Threads (pthread)
2715 * implementation. This is a built-in implementation, avoiding the need to
2716 * implement the component functions of the thread interface. If this function
2717 * is used, it is not necessary to call smbc_thread_impl().
2722 smbc_thread_posix(void);
2727 * Initialize for an arbitrary thread implementation. The caller should
2728 * provide, as parameters, pointers to functions to implement the requisite
2729 * low-level thread functionality. A function must be provided for each
2730 * parameter; none may be null.
2732 * If the thread implementation is POSIX Threads (pthreads), then the much
2733 * simpler smbc_thread_pthread() function may be used instead of this one.
2735 * @param create_mutex
2736 * Create a mutex. This function should expect three parameters: lockname,
2737 * pplock, and location. It should create a unique mutex for each unique
2738 * lockname it is provided, and return the mutex identifier in *pplock. The
2739 * location parameter can be used for debugging, as it contains the
2740 * compiler-provided __location__ of the call.
2742 * @param destroy_mutex
2743 * Destroy a mutex. This function should expect two parameters: plock and
2744 * location. It should destroy the mutex associated with the identifier
2745 * plock. The location parameter can be used for debugging, as it contains
2746 * the compiler-provided __location__ of the call.
2749 * Lock a mutex. This function should expect three parameters: plock,
2750 * lock_type, and location. The mutex aassociated with identifier plock
2751 * should be locked if lock_type is 1, and unlocked if lock_type is 2. The
2752 * location parameter can be used for debugging, as it contains the
2753 * compiler-provided __location__ of the call.
2756 * Create thread local storage. This function should expect three
2757 * parameters: keyname, ppkey, and location. It should allocate an
2758 * implementation-specific amount of memory and assign the pointer to that
2759 * allocated memory to *ppkey. The location parameter can be used for
2760 * debugging, as it contains the compiler-provided __location__ of the
2761 * call. This function should return 0 upon success, non-zero upon failure.
2763 * @param destroy_tls
2764 * Destroy thread local storage. This function should expect two parameters:
2765 * ppkey and location. The ppkey parameter points to a variable containing a
2766 * thread local storage key previously provided by the create_tls
2767 * function. The location parameter can be used for debugging, as it
2768 * contains the compiler-provided __location__ of the call.
2771 * Set a thread local storage variable's value. This function should expect
2772 * three parameters: pkey, pval, and location. The pkey parameter is a
2773 * thread local storage key previously provided by the create_tls
2774 * function. The (void *) pval parameter contains the value to be placed in
2775 * the thread local storage variable identified by pkey. The location
2776 * parameter can be used for debugging, as it contains the compiler-provided
2777 * __location__ of the call. This function should return 0 upon success;
2778 * non-zero otherwise.
2781 * Retrieve a thread local storage variable's value. This function should
2782 * expect two parameters: pkey and location. The pkey parameter is a thread
2783 * local storage key previously provided by the create_tls function, and
2784 * which has previously been used in a call to the set_tls function to
2785 * initialize a thread local storage variable. The location parameter can be
2786 * used for debugging, as it contains the compiler-provided __location__ of
2787 * the call. This function should return the (void *) value stored in the
2788 * variable identified by pkey.
2794 /* Mutex functions. */
2795 int (*create_mutex
)(const char *lockname
,
2797 const char *location
),
2798 void (*destroy_mutex
)(void *plock
,
2799 const char *location
),
2800 int (*lock_mutex
)(void *plock
,
2802 const char *location
),
2804 /* Thread local storage. */
2805 int (*create_tls
)(const char *keyname
,
2807 const char *location
),
2808 void (*destroy_tls
)(void **ppkey
,
2809 const char *location
),
2810 int (*set_tls
)(void *pkey
,
2812 const char *location
),
2813 void *(*get_tls
)(void *pkey
,
2814 const char *location
)
2820 * @ingroup structure
2821 * Structure that contains a client context information
2822 * This structure is known as SMBCCTX
2824 * DO NOT DIRECTLY MANIPULATE THE CONTEXT STRUCTURE! The data in the context
2825 * structure should all be considered private to the library. It remains here
2826 * only for backward compatibility.
2828 * See the comments herein for use of the setter and getter functions which
2829 * should now be used for manipulating these values. New features, functions,
2830 * etc., are not added here but rather in _internal where they are not
2831 * directly visible to applications. This makes it much easier to maintain
2832 * ABI compatibility.
2840 * Use smbc_getDebug() and smbc_setDebug()
2842 int debug DEPRECATED_SMBC_INTERFACE
;
2845 * netbios name used for making connections
2848 * Use smbc_getNetbiosName() and smbc_setNetbiosName()
2850 char * netbios_name DEPRECATED_SMBC_INTERFACE
;
2853 * workgroup name used for making connections
2856 * Use smbc_getWorkgroup() and smbc_setWorkgroup()
2858 char * workgroup DEPRECATED_SMBC_INTERFACE
;
2861 * username used for making connections
2864 * Use smbc_getUser() and smbc_setUser()
2866 char * user DEPRECATED_SMBC_INTERFACE
;
2869 * timeout used for waiting on connections / response data (in
2873 * Use smbc_getTimeout() and smbc_setTimeout()
2875 int timeout DEPRECATED_SMBC_INTERFACE
;
2878 * callable functions for files:
2879 * For usage and return values see the SMBC_* functions
2883 * Use smbc_getFunction*() and smbc_setFunction*(), e.g.
2884 * smbc_getFunctionOpen(), smbc_setFunctionUnlink(), etc.
2886 smbc_open_fn open DEPRECATED_SMBC_INTERFACE
;
2887 smbc_creat_fn creat DEPRECATED_SMBC_INTERFACE
;
2888 smbc_read_fn read DEPRECATED_SMBC_INTERFACE
;
2889 smbc_write_fn write DEPRECATED_SMBC_INTERFACE
;
2890 smbc_unlink_fn unlink DEPRECATED_SMBC_INTERFACE
;
2891 smbc_rename_fn rename DEPRECATED_SMBC_INTERFACE
;
2892 smbc_lseek_fn lseek DEPRECATED_SMBC_INTERFACE
;
2893 smbc_stat_fn stat DEPRECATED_SMBC_INTERFACE
;
2894 smbc_fstat_fn fstat DEPRECATED_SMBC_INTERFACE
;
2895 #if 0 /* internal */
2896 smbc_ftruncate_fn ftruncate_fn
;
2898 smbc_close_fn close_fn DEPRECATED_SMBC_INTERFACE
;
2899 smbc_opendir_fn opendir DEPRECATED_SMBC_INTERFACE
;
2900 smbc_closedir_fn closedir DEPRECATED_SMBC_INTERFACE
;
2901 smbc_readdir_fn readdir DEPRECATED_SMBC_INTERFACE
;
2902 smbc_getdents_fn getdents DEPRECATED_SMBC_INTERFACE
;
2903 smbc_mkdir_fn mkdir DEPRECATED_SMBC_INTERFACE
;
2904 smbc_rmdir_fn rmdir DEPRECATED_SMBC_INTERFACE
;
2905 smbc_telldir_fn telldir DEPRECATED_SMBC_INTERFACE
;
2906 smbc_lseekdir_fn lseekdir DEPRECATED_SMBC_INTERFACE
;
2907 smbc_fstatdir_fn fstatdir DEPRECATED_SMBC_INTERFACE
;
2908 smbc_chmod_fn chmod DEPRECATED_SMBC_INTERFACE
;
2909 smbc_utimes_fn utimes DEPRECATED_SMBC_INTERFACE
;
2910 smbc_setxattr_fn setxattr DEPRECATED_SMBC_INTERFACE
;
2911 smbc_getxattr_fn getxattr DEPRECATED_SMBC_INTERFACE
;
2912 smbc_removexattr_fn removexattr DEPRECATED_SMBC_INTERFACE
;
2913 smbc_listxattr_fn listxattr DEPRECATED_SMBC_INTERFACE
;
2915 /* Printing-related functions */
2916 smbc_print_file_fn print_file DEPRECATED_SMBC_INTERFACE
;
2917 smbc_open_print_job_fn open_print_job DEPRECATED_SMBC_INTERFACE
;
2918 smbc_list_print_jobs_fn list_print_jobs DEPRECATED_SMBC_INTERFACE
;
2919 smbc_unlink_print_job_fn unlink_print_job DEPRECATED_SMBC_INTERFACE
;
2926 * See the comment above each field, for the getter and setter
2927 * functions that should now be used.
2929 struct _smbc_callbacks
2932 * authentication function callback: called upon auth requests
2935 * Use smbc_getFunctionAuthData(), smbc_setFunctionAuthData()
2937 smbc_get_auth_data_fn auth_fn DEPRECATED_SMBC_INTERFACE
;
2940 * check if a server is still good
2943 * Use smbc_getFunctionCheckServer(),
2944 * smbc_setFunctionCheckServer()
2946 smbc_check_server_fn check_server_fn DEPRECATED_SMBC_INTERFACE
;
2949 * remove a server if unused
2952 * Use smbc_getFunctionRemoveUnusedServer(),
2953 * smbc_setFunctionCheckServer()
2955 smbc_remove_unused_server_fn remove_unused_server_fn DEPRECATED_SMBC_INTERFACE
;
2959 * For an example cache system see
2960 * samba/source/libsmb/libsmb_cache.c
2962 * Cache subsystem * functions follow.
2966 * server cache addition
2969 * Use smbc_getFunctionAddCachedServer(),
2970 * smbc_setFunctionAddCachedServer()
2972 smbc_add_cached_srv_fn add_cached_srv_fn DEPRECATED_SMBC_INTERFACE
;
2975 * server cache lookup
2978 * Use smbc_getFunctionGetCachedServer(),
2979 * smbc_setFunctionGetCachedServer()
2981 smbc_get_cached_srv_fn get_cached_srv_fn DEPRECATED_SMBC_INTERFACE
;
2984 * server cache removal
2987 * Use smbc_getFunctionRemoveCachedServer(),
2988 * smbc_setFunctionRemoveCachedServer()
2990 smbc_remove_cached_srv_fn remove_cached_srv_fn DEPRECATED_SMBC_INTERFACE
;
2993 * server cache purging, try to remove all cached servers
2997 * Use smbc_getFunctionPurgeCachedServers(),
2998 * smbc_setFunctionPurgeCachedServers()
3000 smbc_purge_cached_fn purge_cached_fn DEPRECATED_SMBC_INTERFACE
;
3004 * Space where the private data of the server cache used to be
3007 * Use smbc_getServerCacheData(), smbc_setServerCacheData()
3009 void * reserved DEPRECATED_SMBC_INTERFACE
;
3012 * Very old configuration options.
3015 * Use one of the following functions instead:
3016 * smbc_setOptionUseKerberos()
3017 * smbc_getOptionUseKerberos()
3018 * smbc_setOptionFallbackAfterKerberos()
3019 * smbc_getOptionFallbackAfterKerberos()
3020 * smbc_setOptionNoAutoAnonymousLogin()
3021 * smbc_getOptionNoAutoAnonymousLogin()
3023 int flags DEPRECATED_SMBC_INTERFACE
;
3026 * user options selections that apply to this session
3028 * NEW OPTIONS ARE NOT ADDED HERE!
3031 * To set and retrieve options, use the smbc_setOption*() and
3032 * smbc_getOption*() functions.
3034 struct _smbc_options
{
3035 int browse_max_lmb_count DEPRECATED_SMBC_INTERFACE
;
3036 int urlencode_readdir_entries DEPRECATED_SMBC_INTERFACE
;
3037 int one_share_per_server DEPRECATED_SMBC_INTERFACE
;
3038 } options DEPRECATED_SMBC_INTERFACE
;
3041 * do _NOT_ touch this from your program !
3043 struct SMBC_internal_data
* internal
;
3047 #endif /* SMBCLIENT_H_INCLUDED */