s3: libsmbclient: Add internal/external structures needed for readdirplus.
[Samba.git] / source3 / include / libsmbclient.h
blob65aa7db21d3e15322e6d6884d3bffe65f713e0d0
1 /*=====================================================================
2 Unix SMB/Netbios implementation.
3 SMB client library API definitions
4 Copyright (C) Andrew Tridgell 1998
5 Copyright (C) Richard Sharpe 2000
6 Copyright (C) John Terpsra 2000
7 Copyright (C) Tom Jansen (Ninja ISD) 2002
8 Copyright (C) Derrell Lipman 2003-2008
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 3 of the License, or
14 (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, see <http://www.gnu.org/licenses/>.
23 =====================================================================*/
25 #ifndef SMBCLIENT_H_INCLUDED
26 #define SMBCLIENT_H_INCLUDED
28 #undef DEPRECATED_SMBC_INTERFACE
29 #if ! defined(__LIBSMBCLIENT_INTERNAL__) && defined(__GNUC__)
30 # define DEPRECATED_SMBC_INTERFACE __attribute__ ((deprecated))
31 #else
32 # define DEPRECATED_SMBC_INTERFACE
33 #endif
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
39 /*-------------------------------------------------------------------*/
40 /* The following are special comments to instruct DOXYGEN (automated
41 * documentation tool:
43 /** \defgroup libsmbclient
45 /** \defgroup structure Data Structures Type and Constants
46 * \ingroup libsmbclient
47 * Data structures, types, and constants
49 /** \defgroup callback Callback function types
50 * \ingroup libsmbclient
51 * Callback functions
53 /** \defgroup file File Functions
54 * \ingroup libsmbclient
55 * Functions used to access individual file contents
57 /** \defgroup directory Directory Functions
58 * \ingroup libsmbclient
59 * Functions used to access directory entries
61 /** \defgroup attribute Attributes Functions
62 * \ingroup libsmbclient
63 * Functions used to view or change file and directory attributes
65 /** \defgroup print Print Functions
66 * \ingroup libsmbclient
67 * Functions used to access printing functionality
69 /** \defgroup misc Miscellaneous Functions
70 * \ingroup libsmbclient
71 * Functions that don't fit in to other categories
73 /*-------------------------------------------------------------------*/
75 /* Make sure we have the following includes for now ... */
76 #include <sys/types.h>
77 #include <sys/stat.h>
78 #include <sys/statvfs.h>
79 #include <stdint.h>
80 #include <fcntl.h>
81 #include <utime.h>
83 #define SMBC_BASE_FD 10000 /* smallest file descriptor returned */
85 #define SMBC_WORKGROUP 1
86 #define SMBC_SERVER 2
87 #define SMBC_FILE_SHARE 3
88 #define SMBC_PRINTER_SHARE 4
89 #define SMBC_COMMS_SHARE 5
90 #define SMBC_IPC_SHARE 6
91 #define SMBC_DIR 7
92 #define SMBC_FILE 8
93 #define SMBC_LINK 9
95 /**@ingroup structure
96 * Structure that represents a directory entry.
99 struct smbc_dirent
101 /** Type of entity.
102 SMBC_WORKGROUP=1,
103 SMBC_SERVER=2,
104 SMBC_FILE_SHARE=3,
105 SMBC_PRINTER_SHARE=4,
106 SMBC_COMMS_SHARE=5,
107 SMBC_IPC_SHARE=6,
108 SMBC_DIR=7,
109 SMBC_FILE=8,
110 SMBC_LINK=9,*/
111 unsigned int smbc_type;
113 /** Length of this smbc_dirent in bytes
115 unsigned int dirlen;
116 /** The length of the comment string in bytes (does not include
117 * null terminator)
119 unsigned int commentlen;
120 /** Points to the null terminated comment string
122 char *comment;
123 /** The length of the name string in bytes (does not include
124 * null terminator)
126 unsigned int namelen;
127 /** Points to the null terminated name string
129 char name[1];
132 /**@ingroup structure
133 * Structure that represents all attributes of a directory entry.
136 struct libsmb_file_info
139 * Size of file
141 uint64_t size;
143 * DOS attributes of file
145 uint16_t attrs;
147 * User ID of file
149 uid_t uid;
151 * Group ID of file
153 gid_t gid;
155 * Birth/Create time of file (if supported by system)
156 * Otherwise the value will be 0
158 struct timespec btime_ts;
160 * Modified time for the file
162 struct timespec mtime_ts;
164 * Access time for the file
166 struct timespec atime_ts;
168 * Change time for the file
170 struct timespec ctime_ts;
172 * Name of file
174 char *name;
176 * Short name of file
178 char *short_name;
182 * Logging callback function
184 typedef void (*smbc_debug_callback_fn)(void *private_ptr, int level, const char *msg);
187 * Flags for smbc_setxattr()
188 * Specify a bitwise OR of these, or 0 to add or replace as necessary
190 #define SMBC_XATTR_FLAG_CREATE 0x1 /* fail if attr already exists */
191 #define SMBC_XATTR_FLAG_REPLACE 0x2 /* fail if attr does not exist */
195 * Mappings of the DOS mode bits, as returned by smbc_getxattr() when the
196 * attribute name "system.dos_attr.mode" (or "system.dos_attr.*" or
197 * "system.*") is specified.
199 #define SMBC_DOS_MODE_READONLY 0x01
200 #define SMBC_DOS_MODE_HIDDEN 0x02
201 #define SMBC_DOS_MODE_SYSTEM 0x04
202 #define SMBC_DOS_MODE_VOLUME_ID 0x08
203 #define SMBC_DOS_MODE_DIRECTORY 0x10
204 #define SMBC_DOS_MODE_ARCHIVE 0x20
207 * Valid values for the option "open_share_mode", when calling
208 * smbc_setOptionOpenShareMode()
210 typedef enum smbc_share_mode
212 SMBC_SHAREMODE_DENY_DOS = 0,
213 SMBC_SHAREMODE_DENY_ALL = 1,
214 SMBC_SHAREMODE_DENY_WRITE = 2,
215 SMBC_SHAREMODE_DENY_READ = 3,
216 SMBC_SHAREMODE_DENY_NONE = 4,
217 SMBC_SHAREMODE_DENY_FCB = 7
218 } smbc_share_mode;
222 * Values for option SMB Encryption Level, as set and retrieved with
223 * smbc_setOptionSmbEncryptionLevel() and smbc_getOptionSmbEncryptionLevel()
225 typedef enum smbc_smb_encrypt_level
227 SMBC_ENCRYPTLEVEL_NONE = 0,
228 SMBC_ENCRYPTLEVEL_REQUEST = 1,
229 SMBC_ENCRYPTLEVEL_REQUIRE = 2
230 } smbc_smb_encrypt_level;
234 * Capabilities set in the f_flag field of struct statvfs, from
235 * smbc_statvfs(). These may be OR-ed together to reflect a full set of
236 * available capabilities.
238 typedef enum smbc_vfs_feature
240 /* Defined by POSIX or in Linux include files (low-order bits) */
241 SMBC_VFS_FEATURE_RDONLY = (1 << 0),
243 /* Specific to libsmbclient (high-order bits) */
244 SMBC_VFS_FEATURE_DFS = (1 << 28),
245 SMBC_VFS_FEATURE_CASE_INSENSITIVE = (1 << 29),
246 SMBC_VFS_FEATURE_NO_UNIXCIFS = (1 << 30)
247 } smbc_vfs_feature;
249 typedef int smbc_bool;
252 #ifndef ENOATTR
253 # define ENOATTR ENOENT /* No such attribute */
254 #endif
259 /**@ingroup structure
260 * Structure that represents a print job.
263 #ifndef _CLIENT_H
264 struct print_job_info
266 /** numeric ID of the print job
268 unsigned short id;
270 /** represents print job priority (lower numbers mean higher priority)
272 unsigned short priority;
274 /** Size of the print job
276 size_t size;
278 /** Name of the user that owns the print job
280 char user[128];
282 /** Name of the print job. This will have no name if an anonymous print
283 * file was opened. Ie smb://server/printer
285 char name[128];
287 /** Time the print job was spooled
289 time_t t;
291 #endif /* _CLIENT_H */
294 /**@ingroup structure
295 * Server handle
297 typedef struct _SMBCSRV SMBCSRV;
299 /**@ingroup structure
300 * File or directory handle
302 typedef struct _SMBCFILE SMBCFILE;
304 /**@ingroup structure
305 * File or directory handle
307 typedef struct _SMBCCTX SMBCCTX;
311 * Flags for SMBCCTX->flags
313 * NEW CODE SHOULD NOT DIRECTLY MANIPULATE THE CONTEXT STRUCTURE.
314 * Instead, use:
315 * smbc_setOptionUseKerberos()
316 * smbc_getOptionUseKerberos()
317 * smbc_setOptionFallbackAfterKerberos()
318 * smbc_getOptionFallbackAFterKerberos()
319 * smbc_setOptionNoAutoAnonymousLogin()
320 * smbc_getOptionNoAutoAnonymousLogin()
321 * smbc_setOptionUseCCache()
322 * smbc_getOptionUseCCache()
324 # define SMB_CTX_FLAG_USE_KERBEROS (1 << 0)
325 # define SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS (1 << 1)
326 # define SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON (1 << 2)
327 # define SMB_CTX_FLAG_USE_CCACHE (1 << 3)
331 /**@ingroup callback
332 * Authentication callback function type (traditional method)
334 * Type for the the authentication function called by the library to
335 * obtain authentication credentials
337 * For kerberos support the function should just be called without
338 * prompting the user for credentials. Which means a simple 'return'
339 * should work. Take a look at examples/libsmbclient/get_auth_data_fn.h
340 * and examples/libsmbclient/testbrowse.c.
342 * @param srv Server being authenticated to
344 * @param shr Share being authenticated to
346 * @param wg Pointer to buffer containing a "hint" for the
347 * workgroup to be authenticated. Should be filled in
348 * with the correct workgroup if the hint is wrong.
350 * @param wglen The size of the workgroup buffer in bytes
352 * @param un Pointer to buffer containing a "hint" for the
353 * user name to be use for authentication. Should be
354 * filled in with the correct workgroup if the hint is
355 * wrong.
357 * @param unlen The size of the username buffer in bytes
359 * @param pw Pointer to buffer containing to which password
360 * copied
362 * @param pwlen The size of the password buffer in bytes
365 typedef void (*smbc_get_auth_data_fn)(const char *srv,
366 const char *shr,
367 char *wg, int wglen,
368 char *un, int unlen,
369 char *pw, int pwlen);
370 /**@ingroup callback
371 * Authentication callback function type (method that includes context)
373 * Type for the the authentication function called by the library to
374 * obtain authentication credentials
376 * For kerberos support the function should just be called without
377 * prompting the user for credentials. Which means a simple 'return'
378 * should work. Take a look at examples/libsmbclient/get_auth_data_fn.h
379 * and examples/libsmbclient/testbrowse.c.
381 * @param c Pointer to the smb context
383 * @param srv Server being authenticated to
385 * @param shr Share being authenticated to
387 * @param wg Pointer to buffer containing a "hint" for the
388 * workgroup to be authenticated. Should be filled in
389 * with the correct workgroup if the hint is wrong.
391 * @param wglen The size of the workgroup buffer in bytes
393 * @param un Pointer to buffer containing a "hint" for the
394 * user name to be use for authentication. Should be
395 * filled in with the correct workgroup if the hint is
396 * wrong.
398 * @param unlen The size of the username buffer in bytes
400 * @param pw Pointer to buffer containing to which password
401 * copied
403 * @param pwlen The size of the password buffer in bytes
406 typedef void (*smbc_get_auth_data_with_context_fn)(SMBCCTX *c,
407 const char *srv,
408 const char *shr,
409 char *wg, int wglen,
410 char *un, int unlen,
411 char *pw, int pwlen);
414 /**@ingroup callback
415 * Print job info callback function type.
417 * @param i pointer to print job information structure
420 typedef void (*smbc_list_print_job_fn)(struct print_job_info *i);
423 /**@ingroup callback
424 * Check if a server is still good
426 * @param c pointer to smb context
428 * @param srv pointer to server to check
430 * @return 0 when connection is good. 1 on error.
433 typedef int (*smbc_check_server_fn)(SMBCCTX * c, SMBCSRV *srv);
435 /**@ingroup callback
436 * Remove a server if unused
438 * @param c pointer to smb context
440 * @param srv pointer to server to remove
442 * @return 0 on success. 1 on failure.
445 typedef int (*smbc_remove_unused_server_fn)(SMBCCTX * c, SMBCSRV *srv);
448 /**@ingroup callback
449 * Add a server to the cache system
451 * @param c pointer to smb context
453 * @param srv pointer to server to add
455 * @param server server name
457 * @param share share name
459 * @param workgroup workgroup used to connect
461 * @param username username used to connect
463 * @return 0 on success. 1 on failure.
466 typedef int (*smbc_add_cached_srv_fn) (SMBCCTX * c, SMBCSRV *srv,
467 const char * server, const char * share,
468 const char * workgroup, const char * username);
470 /**@ingroup callback
471 * Look up a server in the cache system
473 * @param c pointer to smb context
475 * @param server server name to match
477 * @param share share name to match
479 * @param workgroup workgroup to match
481 * @param username username to match
483 * @return pointer to SMBCSRV on success. NULL on failure.
486 typedef SMBCSRV * (*smbc_get_cached_srv_fn) (SMBCCTX * c, const char * server,
487 const char * share, const char * workgroup,
488 const char * username);
490 /**@ingroup callback
491 * Check if a server is still good
493 * @param c pointer to smb context
495 * @param srv pointer to server to remove
497 * @return 0 when found and removed. 1 on failure.
500 typedef int (*smbc_remove_cached_srv_fn)(SMBCCTX * c, SMBCSRV *srv);
503 /**@ingroup callback
504 * Try to remove all servers from the cache system and disconnect
506 * @param c pointer to smb context
508 * @return 0 when found and removed. 1 on failure.
511 typedef int (*smbc_purge_cached_fn) (SMBCCTX * c);
515 /*****************************************
516 * Getters and setters for CONFIGURATION *
517 *****************************************/
519 /** Get the debug level */
521 smbc_getDebug(SMBCCTX *c);
523 /** Set the debug level */
524 void
525 smbc_setDebug(SMBCCTX *c, int debug);
528 * set log callback function to capture logs from libsmbclient, this
529 * is applied at global level
531 void
532 smbc_setLogCallback(SMBCCTX *c, void *private_ptr,
533 smbc_debug_callback_fn fn);
535 /** set configuration file, this is applied at global level */
537 smbc_setConfiguration(SMBCCTX *c, const char *file);
539 /** Get the netbios name used for making connections */
540 char *
541 smbc_getNetbiosName(SMBCCTX *c);
543 /** Set the netbios name used for making connections */
544 void
545 smbc_setNetbiosName(SMBCCTX *c, char * netbios_name);
547 /** Get the workgroup used for making connections */
548 char *
549 smbc_getWorkgroup(SMBCCTX *c);
551 /** Set the workgroup used for making connections */
552 void smbc_setWorkgroup(SMBCCTX *c, char * workgroup);
554 /** Get the username used for making connections */
555 char *
556 smbc_getUser(SMBCCTX *c);
558 /** Set the username used for making connections */
559 void
560 smbc_setUser(SMBCCTX *c, const char *user);
563 * Get the timeout used for waiting on connections and response data
564 * (in milliseconds)
567 smbc_getTimeout(SMBCCTX *c);
570 * Set the timeout used for waiting on connections and response data
571 * (in milliseconds)
573 void
574 smbc_setTimeout(SMBCCTX *c, int timeout);
578 * Get the TCP port used to connect (0 means default).
580 uint16_t
581 smbc_getPort(SMBCCTX *c);
584 * Set the TCP port used to connect (0 means default).
586 void
587 smbc_setPort(SMBCCTX *c, uint16_t port);
591 /***********************************
592 * Getters and setters for OPTIONS *
593 ***********************************/
595 /** Get whether to log to standard error instead of standard output */
596 smbc_bool
597 smbc_getOptionDebugToStderr(SMBCCTX *c);
599 /** Set whether to log to standard error instead of standard output */
600 void
601 smbc_setOptionDebugToStderr(SMBCCTX *c, smbc_bool b);
604 * Get whether to use new-style time attribute names, e.g. WRITE_TIME rather
605 * than the old-style names such as M_TIME. This allows also setting/getting
606 * CREATE_TIME which was previously unimplemented. (Note that the old C_TIME
607 * was supposed to be CHANGE_TIME but was confused and sometimes referred to
608 * CREATE_TIME.)
610 smbc_bool
611 smbc_getOptionFullTimeNames(SMBCCTX *c);
614 * Set whether to use new-style time attribute names, e.g. WRITE_TIME rather
615 * than the old-style names such as M_TIME. This allows also setting/getting
616 * CREATE_TIME which was previously unimplemented. (Note that the old C_TIME
617 * was supposed to be CHANGE_TIME but was confused and sometimes referred to
618 * CREATE_TIME.)
620 void
621 smbc_setOptionFullTimeNames(SMBCCTX *c, smbc_bool b);
624 * Get the share mode to use for files opened with SMBC_open_ctx(). The
625 * default is SMBC_SHAREMODE_DENY_NONE.
627 smbc_share_mode
628 smbc_getOptionOpenShareMode(SMBCCTX *c);
631 * Set the share mode to use for files opened with SMBC_open_ctx(). The
632 * default is SMBC_SHAREMODE_DENY_NONE.
634 void
635 smbc_setOptionOpenShareMode(SMBCCTX *c, smbc_share_mode share_mode);
637 /** Retrieve a previously saved user data handle */
638 void *
639 smbc_getOptionUserData(SMBCCTX *c);
641 /** Save a user data handle */
642 void
643 smbc_setOptionUserData(SMBCCTX *c, void *user_data);
645 /** Get the encoded value for encryption level. */
646 smbc_smb_encrypt_level
647 smbc_getOptionSmbEncryptionLevel(SMBCCTX *c);
649 /** Set the encoded value for encryption level. */
650 void
651 smbc_setOptionSmbEncryptionLevel(SMBCCTX *c, smbc_smb_encrypt_level level);
654 * Get whether to treat file names as case-sensitive if we can't determine
655 * when connecting to the remote share whether the file system is case
656 * sensitive. This defaults to FALSE since it's most likely that if we can't
657 * retrieve the file system attributes, it's a very old file system that does
658 * not support case sensitivity.
660 smbc_bool
661 smbc_getOptionCaseSensitive(SMBCCTX *c);
664 * Set whether to treat file names as case-sensitive if we can't determine
665 * when connecting to the remote share whether the file system is case
666 * sensitive. This defaults to FALSE since it's most likely that if we can't
667 * retrieve the file system attributes, it's a very old file system that does
668 * not support case sensitivity.
670 void
671 smbc_setOptionCaseSensitive(SMBCCTX *c, smbc_bool b);
675 * Get from how many local master browsers should the list of workgroups be
676 * retrieved. It can take up to 12 minutes or longer after a server becomes a
677 * local master browser, for it to have the entire browse list (the list of
678 * workgroups/domains) from an entire network. Since a client never knows
679 * which local master browser will be found first, the one which is found
680 * first and used to retrieve a browse list may have an incomplete or empty
681 * browse list. By requesting the browse list from multiple local master
682 * browsers, a more complete list can be generated. For small networks (few
683 * workgroups), it is recommended that this value be set to 0, causing the
684 * browse lists from all found local master browsers to be retrieved and
685 * merged. For networks with many workgroups, a suitable value for this
686 * variable is probably somewhere around 3. (Default: 3).
689 smbc_getOptionBrowseMaxLmbCount(SMBCCTX *c);
692 * Set from how many local master browsers should the list of workgroups be
693 * retrieved. It can take up to 12 minutes or longer after a server becomes a
694 * local master browser, for it to have the entire browse list (the list of
695 * workgroups/domains) from an entire network. Since a client never knows
696 * which local master browser will be found first, the one which is found
697 * first and used to retrieve a browse list may have an incomplete or empty
698 * browse list. By requesting the browse list from multiple local master
699 * browsers, a more complete list can be generated. For small networks (few
700 * workgroups), it is recommended that this value be set to 0, causing the
701 * browse lists from all found local master browsers to be retrieved and
702 * merged. For networks with many workgroups, a suitable value for this
703 * variable is probably somewhere around 3. (Default: 3).
705 void
706 smbc_setOptionBrowseMaxLmbCount(SMBCCTX *c, int count);
709 * Get whether to url-encode readdir entries.
711 * There is a difference in the desired return strings from
712 * smbc_readdir() depending upon whether the filenames are to
713 * be displayed to the user, or whether they are to be
714 * appended to the path name passed to smbc_opendir() to call
715 * a further smbc_ function (e.g. open the file with
716 * smbc_open()). In the former case, the filename should be
717 * in "human readable" form. In the latter case, the smbc_
718 * functions expect a URL which must be url-encoded. Those
719 * functions decode the URL. If, for example, smbc_readdir()
720 * returned a file name of "abc%20def.txt", passing a path
721 * with this file name attached to smbc_open() would cause
722 * smbc_open to attempt to open the file "abc def.txt" since
723 * the %20 is decoded into a space.
725 * Set this option to True if the names returned by
726 * smbc_readdir() should be url-encoded such that they can be
727 * passed back to another smbc_ call. Set it to False if the
728 * names returned by smbc_readdir() are to be presented to the
729 * user.
731 * For backwards compatibility, this option defaults to False.
733 smbc_bool
734 smbc_getOptionUrlEncodeReaddirEntries(SMBCCTX *c);
737 * Set whether to url-encode readdir entries.
739 * There is a difference in the desired return strings from
740 * smbc_readdir() depending upon whether the filenames are to
741 * be displayed to the user, or whether they are to be
742 * appended to the path name passed to smbc_opendir() to call
743 * a further smbc_ function (e.g. open the file with
744 * smbc_open()). In the former case, the filename should be
745 * in "human readable" form. In the latter case, the smbc_
746 * functions expect a URL which must be url-encoded. Those
747 * functions decode the URL. If, for example, smbc_readdir()
748 * returned a file name of "abc%20def.txt", passing a path
749 * with this file name attached to smbc_open() would cause
750 * smbc_open to attempt to open the file "abc def.txt" since
751 * the %20 is decoded into a space.
753 * Set this option to True if the names returned by
754 * smbc_readdir() should be url-encoded such that they can be
755 * passed back to another smbc_ call. Set it to False if the
756 * names returned by smbc_readdir() are to be presented to the
757 * user.
759 * For backwards compatibility, this option defaults to False.
761 void
762 smbc_setOptionUrlEncodeReaddirEntries(SMBCCTX *c, smbc_bool b);
765 * Get whether to use the same connection for all shares on a server.
767 * Some Windows versions appear to have a limit to the number
768 * of concurrent SESSIONs and/or TREE CONNECTions. In
769 * one-shot programs (i.e. the program runs and then quickly
770 * ends, thereby shutting down all connections), it is
771 * probably reasonable to establish a new connection for each
772 * share. In long-running applications, the limitation can be
773 * avoided by using only a single connection to each server,
774 * and issuing a new TREE CONNECT when the share is accessed.
776 smbc_bool
777 smbc_getOptionOneSharePerServer(SMBCCTX *c);
780 * Set whether to use the same connection for all shares on a server.
782 * Some Windows versions appear to have a limit to the number
783 * of concurrent SESSIONs and/or TREE CONNECTions. In
784 * one-shot programs (i.e. the program runs and then quickly
785 * ends, thereby shutting down all connections), it is
786 * probably reasonable to establish a new connection for each
787 * share. In long-running applications, the limitation can be
788 * avoided by using only a single connection to each server,
789 * and issuing a new TREE CONNECT when the share is accessed.
791 void
792 smbc_setOptionOneSharePerServer(SMBCCTX *c, smbc_bool b);
794 /** Get whether to enable use of kerberos */
795 smbc_bool
796 smbc_getOptionUseKerberos(SMBCCTX *c);
798 /** Set whether to enable use of kerberos */
799 void
800 smbc_setOptionUseKerberos(SMBCCTX *c, smbc_bool b);
802 /** Get whether to fallback after kerberos */
803 smbc_bool
804 smbc_getOptionFallbackAfterKerberos(SMBCCTX *c);
806 /** Set whether to fallback after kerberos */
807 void
808 smbc_setOptionFallbackAfterKerberos(SMBCCTX *c, smbc_bool b);
810 /** Get whether to automatically select anonymous login */
811 smbc_bool
812 smbc_getOptionNoAutoAnonymousLogin(SMBCCTX *c);
814 /** Set whether to automatically select anonymous login */
815 void
816 smbc_setOptionNoAutoAnonymousLogin(SMBCCTX *c, smbc_bool b);
818 /** Get whether to enable use of the winbind ccache */
819 smbc_bool
820 smbc_getOptionUseCCache(SMBCCTX *c);
822 /** Set whether to enable use of the winbind ccache */
823 void
824 smbc_setOptionUseCCache(SMBCCTX *c, smbc_bool b);
826 /** Get indication that the password supplied is the NT hash */
827 smbc_bool
828 smbc_getOptionUseNTHash(SMBCCTX *c);
830 /** Set indication that the password supplied is the NT hash */
831 void
832 smbc_setOptionUseNTHash(SMBCCTX *c, smbc_bool b);
836 /*************************************
837 * Getters and setters for FUNCTIONS *
838 *************************************/
840 /** Get the function for obtaining authentication data */
841 smbc_get_auth_data_fn smbc_getFunctionAuthData(SMBCCTX *c);
843 /** Set the function for obtaining authentication data */
844 void smbc_setFunctionAuthData(SMBCCTX *c, smbc_get_auth_data_fn fn);
846 /** Get the new-style authentication function which includes the context. */
847 smbc_get_auth_data_with_context_fn
848 smbc_getFunctionAuthDataWithContext(SMBCCTX *c);
850 /** Set the new-style authentication function which includes the context. */
851 void
852 smbc_setFunctionAuthDataWithContext(SMBCCTX *c,
853 smbc_get_auth_data_with_context_fn fn);
855 /** Get the function for checking if a server is still good */
856 smbc_check_server_fn smbc_getFunctionCheckServer(SMBCCTX *c);
858 /** Set the function for checking if a server is still good */
859 void smbc_setFunctionCheckServer(SMBCCTX *c, smbc_check_server_fn fn);
861 /** Get the function for removing a server if unused */
862 smbc_remove_unused_server_fn smbc_getFunctionRemoveUnusedServer(SMBCCTX *c);
864 /** Set the function for removing a server if unused */
865 void smbc_setFunctionRemoveUnusedServer(SMBCCTX *c,
866 smbc_remove_unused_server_fn fn);
868 /** Get the function for adding a cached server */
869 smbc_add_cached_srv_fn smbc_getFunctionAddCachedServer(SMBCCTX *c);
871 /** Set the function for adding a cached server */
872 void smbc_setFunctionAddCachedServer(SMBCCTX *c, smbc_add_cached_srv_fn fn);
874 /** Get the function for server cache lookup */
875 smbc_get_cached_srv_fn smbc_getFunctionGetCachedServer(SMBCCTX *c);
877 /** Set the function for server cache lookup */
878 void smbc_setFunctionGetCachedServer(SMBCCTX *c, smbc_get_cached_srv_fn fn);
880 /** Get the function for server cache removal */
881 smbc_remove_cached_srv_fn smbc_getFunctionRemoveCachedServer(SMBCCTX *c);
883 /** Set the function for server cache removal */
884 void smbc_setFunctionRemoveCachedServer(SMBCCTX *c,
885 smbc_remove_cached_srv_fn fn);
888 * Get the function for server cache purging. This function tries to
889 * remove all cached servers (e.g. on disconnect)
891 smbc_purge_cached_fn smbc_getFunctionPurgeCachedServers(SMBCCTX *c);
894 * Set the function for server cache purging. This function tries to
895 * remove all cached servers (e.g. on disconnect)
897 void smbc_setFunctionPurgeCachedServers(SMBCCTX *c,
898 smbc_purge_cached_fn fn);
900 /** Get the function to store private data of the server cache */
901 struct smbc_server_cache * smbc_getServerCacheData(SMBCCTX *c);
903 /** Set the function to store private data of the server cache */
904 void smbc_setServerCacheData(SMBCCTX *c, struct smbc_server_cache * cache);
908 /*****************************************************************
909 * Callable functions for files. *
910 * Each callable has a function signature typedef, a declaration *
911 * for the getter, and a declaration for the setter. *
912 *****************************************************************/
914 typedef SMBCFILE * (*smbc_open_fn)(SMBCCTX *c,
915 const char *fname,
916 int flags,
917 mode_t mode);
918 smbc_open_fn smbc_getFunctionOpen(SMBCCTX *c);
919 void smbc_setFunctionOpen(SMBCCTX *c, smbc_open_fn fn);
921 typedef SMBCFILE * (*smbc_creat_fn)(SMBCCTX *c,
922 const char *path,
923 mode_t mode);
924 smbc_creat_fn smbc_getFunctionCreat(SMBCCTX *c);
925 void smbc_setFunctionCreat(SMBCCTX *c, smbc_creat_fn);
927 typedef ssize_t (*smbc_read_fn)(SMBCCTX *c,
928 SMBCFILE *file,
929 void *buf,
930 size_t count);
931 smbc_read_fn smbc_getFunctionRead(SMBCCTX *c);
932 void smbc_setFunctionRead(SMBCCTX *c, smbc_read_fn fn);
934 typedef ssize_t (*smbc_write_fn)(SMBCCTX *c,
935 SMBCFILE *file,
936 const void *buf,
937 size_t count);
938 smbc_write_fn smbc_getFunctionWrite(SMBCCTX *c);
939 void smbc_setFunctionWrite(SMBCCTX *c, smbc_write_fn fn);
941 typedef off_t (*smbc_splice_fn)(SMBCCTX *c,
942 SMBCFILE *srcfile,
943 SMBCFILE *dstfile,
944 off_t count,
945 int (*splice_cb)(off_t n, void *priv),
946 void *priv);
947 smbc_splice_fn smbc_getFunctionSplice(SMBCCTX *c);
948 void smbc_setFunctionSplice(SMBCCTX *c, smbc_splice_fn fn);
950 typedef int (*smbc_unlink_fn)(SMBCCTX *c,
951 const char *fname);
952 smbc_unlink_fn smbc_getFunctionUnlink(SMBCCTX *c);
953 void smbc_setFunctionUnlink(SMBCCTX *c, smbc_unlink_fn fn);
955 typedef int (*smbc_rename_fn)(SMBCCTX *ocontext,
956 const char *oname,
957 SMBCCTX *ncontext,
958 const char *nname);
959 smbc_rename_fn smbc_getFunctionRename(SMBCCTX *c);
960 void smbc_setFunctionRename(SMBCCTX *c, smbc_rename_fn fn);
962 typedef off_t (*smbc_lseek_fn)(SMBCCTX *c,
963 SMBCFILE * file,
964 off_t offset,
965 int whence);
966 smbc_lseek_fn smbc_getFunctionLseek(SMBCCTX *c);
967 void smbc_setFunctionLseek(SMBCCTX *c, smbc_lseek_fn fn);
969 typedef int (*smbc_stat_fn)(SMBCCTX *c,
970 const char *fname,
971 struct stat *st);
972 smbc_stat_fn smbc_getFunctionStat(SMBCCTX *c);
973 void smbc_setFunctionStat(SMBCCTX *c, smbc_stat_fn fn);
975 typedef int (*smbc_fstat_fn)(SMBCCTX *c,
976 SMBCFILE *file,
977 struct stat *st);
978 smbc_fstat_fn smbc_getFunctionFstat(SMBCCTX *c);
979 void smbc_setFunctionFstat(SMBCCTX *c, smbc_fstat_fn fn);
981 typedef int (*smbc_statvfs_fn)(SMBCCTX *c,
982 char *path,
983 struct statvfs *st);
984 smbc_statvfs_fn smbc_getFunctionStatVFS(SMBCCTX *c);
985 void smbc_setFunctionStatVFS(SMBCCTX *c, smbc_statvfs_fn fn);
987 typedef int (*smbc_fstatvfs_fn)(SMBCCTX *c,
988 SMBCFILE *file,
989 struct statvfs *st);
990 smbc_fstatvfs_fn smbc_getFunctionFstatVFS(SMBCCTX *c);
991 void smbc_setFunctionFstatVFS(SMBCCTX *c, smbc_fstatvfs_fn fn);
993 typedef int (*smbc_ftruncate_fn)(SMBCCTX *c,
994 SMBCFILE *f,
995 off_t size);
996 smbc_ftruncate_fn smbc_getFunctionFtruncate(SMBCCTX *c);
997 void smbc_setFunctionFtruncate(SMBCCTX *c, smbc_ftruncate_fn fn);
999 typedef int (*smbc_close_fn)(SMBCCTX *c,
1000 SMBCFILE *file);
1001 smbc_close_fn smbc_getFunctionClose(SMBCCTX *c);
1002 void smbc_setFunctionClose(SMBCCTX *c, smbc_close_fn fn);
1006 /*****************************************************************
1007 * Callable functions for directories. *
1008 * Each callable has a function signature typedef, a declaration *
1009 * for the getter, and a declaration for the setter. *
1010 *****************************************************************/
1012 typedef SMBCFILE * (*smbc_opendir_fn)(SMBCCTX *c,
1013 const char *fname);
1014 smbc_opendir_fn smbc_getFunctionOpendir(SMBCCTX *c);
1015 void smbc_setFunctionOpendir(SMBCCTX *c, smbc_opendir_fn fn);
1017 typedef int (*smbc_closedir_fn)(SMBCCTX *c,
1018 SMBCFILE *dir);
1019 smbc_closedir_fn smbc_getFunctionClosedir(SMBCCTX *c);
1020 void smbc_setFunctionClosedir(SMBCCTX *c, smbc_closedir_fn fn);
1022 typedef struct smbc_dirent * (*smbc_readdir_fn)(SMBCCTX *c,
1023 SMBCFILE *dir);
1024 smbc_readdir_fn smbc_getFunctionReaddir(SMBCCTX *c);
1025 void smbc_setFunctionReaddir(SMBCCTX *c, smbc_readdir_fn fn);
1027 typedef int (*smbc_getdents_fn)(SMBCCTX *c,
1028 SMBCFILE *dir,
1029 struct smbc_dirent *dirp,
1030 int count);
1031 smbc_getdents_fn smbc_getFunctionGetdents(SMBCCTX *c);
1032 void smbc_setFunctionGetdents(SMBCCTX *c, smbc_getdents_fn fn);
1034 typedef int (*smbc_mkdir_fn)(SMBCCTX *c,
1035 const char *fname,
1036 mode_t mode);
1037 smbc_mkdir_fn smbc_getFunctionMkdir(SMBCCTX *c);
1038 void smbc_setFunctionMkdir(SMBCCTX *c, smbc_mkdir_fn fn);
1040 typedef int (*smbc_rmdir_fn)(SMBCCTX *c,
1041 const char *fname);
1042 smbc_rmdir_fn smbc_getFunctionRmdir(SMBCCTX *c);
1043 void smbc_setFunctionRmdir(SMBCCTX *c, smbc_rmdir_fn fn);
1045 typedef off_t (*smbc_telldir_fn)(SMBCCTX *c,
1046 SMBCFILE *dir);
1047 smbc_telldir_fn smbc_getFunctionTelldir(SMBCCTX *c);
1048 void smbc_setFunctionTelldir(SMBCCTX *c, smbc_telldir_fn fn);
1050 typedef int (*smbc_lseekdir_fn)(SMBCCTX *c,
1051 SMBCFILE *dir,
1052 off_t offset);
1053 smbc_lseekdir_fn smbc_getFunctionLseekdir(SMBCCTX *c);
1054 void smbc_setFunctionLseekdir(SMBCCTX *c, smbc_lseekdir_fn fn);
1056 typedef int (*smbc_fstatdir_fn)(SMBCCTX *c,
1057 SMBCFILE *dir,
1058 struct stat *st);
1059 smbc_fstatdir_fn smbc_getFunctionFstatdir(SMBCCTX *c);
1060 void smbc_setFunctionFstatdir(SMBCCTX *c, smbc_fstatdir_fn fn);
1062 #define SMBC_NOTIFY_ACTION_ADDED 1
1063 #define SMBC_NOTIFY_ACTION_REMOVED 2
1064 #define SMBC_NOTIFY_ACTION_MODIFIED 3
1065 #define SMBC_NOTIFY_ACTION_OLD_NAME 4
1066 #define SMBC_NOTIFY_ACTION_NEW_NAME 5
1067 #define SMBC_NOTIFY_ACTION_ADDED_STREAM 6
1068 #define SMBC_NOTIFY_ACTION_REMOVED_STREAM 7
1069 #define SMBC_NOTIFY_ACTION_MODIFIED_STREAM 8
1071 struct smbc_notify_callback_action {
1072 uint32_t action;
1073 const char *filename;
1076 typedef int (*smbc_notify_callback_fn)(
1077 const struct smbc_notify_callback_action *actions,
1078 size_t num_actions, void *private_data);
1080 typedef int (*smbc_notify_fn)(SMBCCTX *c, SMBCFILE *dir, smbc_bool recursive,
1081 uint32_t completion_filter,
1082 unsigned callback_timeout_ms,
1083 smbc_notify_callback_fn cb, void *private_data);
1084 smbc_notify_fn smbc_getFunctionNotify(SMBCCTX *c);
1085 void smbc_setFunctionNotify(SMBCCTX *c, smbc_notify_fn fn);
1088 /*****************************************************************
1089 * Callable functions applicable to both files and directories. *
1090 * Each callable has a function signature typedef, a declaration *
1091 * for the getter, and a declaration for the setter. *
1092 *****************************************************************/
1094 typedef int (*smbc_chmod_fn)(SMBCCTX *c,
1095 const char *fname,
1096 mode_t mode);
1097 smbc_chmod_fn smbc_getFunctionChmod(SMBCCTX *c);
1098 void smbc_setFunctionChmod(SMBCCTX *c, smbc_chmod_fn fn);
1100 typedef int (*smbc_utimes_fn)(SMBCCTX *c,
1101 const char *fname,
1102 struct timeval *tbuf);
1103 smbc_utimes_fn smbc_getFunctionUtimes(SMBCCTX *c);
1104 void smbc_setFunctionUtimes(SMBCCTX *c, smbc_utimes_fn fn);
1106 typedef int (*smbc_setxattr_fn)(SMBCCTX *context,
1107 const char *fname,
1108 const char *name,
1109 const void *value,
1110 size_t size,
1111 int flags);
1112 smbc_setxattr_fn smbc_getFunctionSetxattr(SMBCCTX *c);
1113 void smbc_setFunctionSetxattr(SMBCCTX *c, smbc_setxattr_fn fn);
1115 typedef int (*smbc_getxattr_fn)(SMBCCTX *context,
1116 const char *fname,
1117 const char *name,
1118 const void *value,
1119 size_t size);
1120 smbc_getxattr_fn smbc_getFunctionGetxattr(SMBCCTX *c);
1121 void smbc_setFunctionGetxattr(SMBCCTX *c, smbc_getxattr_fn fn);
1123 typedef int (*smbc_removexattr_fn)(SMBCCTX *context,
1124 const char *fname,
1125 const char *name);
1126 smbc_removexattr_fn smbc_getFunctionRemovexattr(SMBCCTX *c);
1127 void smbc_setFunctionRemovexattr(SMBCCTX *c, smbc_removexattr_fn fn);
1129 typedef int (*smbc_listxattr_fn)(SMBCCTX *context,
1130 const char *fname,
1131 char *list,
1132 size_t size);
1133 smbc_listxattr_fn smbc_getFunctionListxattr(SMBCCTX *c);
1134 void smbc_setFunctionListxattr(SMBCCTX *c, smbc_listxattr_fn fn);
1138 /*****************************************************************
1139 * Callable functions for printing. *
1140 * Each callable has a function signature typedef, a declaration *
1141 * for the getter, and a declaration for the setter. *
1142 *****************************************************************/
1144 typedef int (*smbc_print_file_fn)(SMBCCTX *c_file,
1145 const char *fname,
1146 SMBCCTX *c_print,
1147 const char *printq);
1148 smbc_print_file_fn smbc_getFunctionPrintFile(SMBCCTX *c);
1149 void smbc_setFunctionPrintFile(SMBCCTX *c, smbc_print_file_fn fn);
1151 typedef SMBCFILE * (*smbc_open_print_job_fn)(SMBCCTX *c,
1152 const char *fname);
1153 smbc_open_print_job_fn smbc_getFunctionOpenPrintJob(SMBCCTX *c);
1154 void smbc_setFunctionOpenPrintJob(SMBCCTX *c,
1155 smbc_open_print_job_fn fn);
1157 typedef int (*smbc_list_print_jobs_fn)(SMBCCTX *c,
1158 const char *fname,
1159 smbc_list_print_job_fn fn);
1160 smbc_list_print_jobs_fn smbc_getFunctionListPrintJobs(SMBCCTX *c);
1161 void smbc_setFunctionListPrintJobs(SMBCCTX *c,
1162 smbc_list_print_jobs_fn fn);
1164 typedef int (*smbc_unlink_print_job_fn)(SMBCCTX *c,
1165 const char *fname,
1166 int id);
1167 smbc_unlink_print_job_fn smbc_getFunctionUnlinkPrintJob(SMBCCTX *c);
1168 void smbc_setFunctionUnlinkPrintJob(SMBCCTX *c,
1169 smbc_unlink_print_job_fn fn);
1172 /**@ingroup misc
1173 * Create a new SBMCCTX (a context).
1175 * Must be called before the context is passed to smbc_context_init()
1177 * @return The given SMBCCTX pointer on success, NULL on error with errno set:
1178 * - ENOMEM Out of memory
1180 * @see smbc_free_context(), smbc_init_context()
1182 * @note Do not forget to smbc_init_context() the returned SMBCCTX pointer !
1184 SMBCCTX * smbc_new_context(void);
1186 /**@ingroup misc
1187 * Delete a SBMCCTX (a context) acquired from smbc_new_context().
1189 * The context will be deleted if possible.
1191 * @param context A pointer to a SMBCCTX obtained from smbc_new_context()
1193 * @param shutdown_ctx If 1, all connections and files will be closed even if they are busy.
1196 * @return Returns 0 on succes. Returns 1 on failure with errno set:
1197 * - EBUSY Server connections are still used, Files are open or cache
1198 * could not be purged
1199 * - EBADF context == NULL
1201 * @see smbc_new_context()
1203 * @note It is advised to clean up all the contexts with shutdown_ctx set to 1
1204 * just before exit()'ing. When shutdown_ctx is 0, this function can be
1205 * use in periodical cleanup functions for example.
1207 int smbc_free_context(SMBCCTX * context, int shutdown_ctx);
1210 /**@ingroup misc
1212 * @deprecated. Use smbc_setOption*() functions instead.
1214 void
1215 smbc_option_set(SMBCCTX *context,
1216 char *option_name,
1217 ... /* option_value */);
1220 * @deprecated. Use smbc_getOption*() functions instead.
1222 void *
1223 smbc_option_get(SMBCCTX *context,
1224 char *option_name);
1226 /**@ingroup misc
1227 * Initialize a SBMCCTX (a context).
1229 * Must be called before using any SMBCCTX API function
1231 * @param context A pointer to a SMBCCTX obtained from smbc_new_context()
1233 * @return A pointer to the given SMBCCTX on success,
1234 * NULL on error with errno set:
1235 * - EBADF NULL context given
1236 * - ENOMEM Out of memory
1237 * - ENOENT The smb.conf file would not load
1239 * @see smbc_new_context()
1241 * @note my_context = smbc_init_context(smbc_new_context())
1242 * is perfectly safe, but it might leak memory on
1243 * smbc_context_init() failure. Avoid this.
1244 * You'll have to call smbc_free_context() yourself
1245 * on failure.
1248 SMBCCTX * smbc_init_context(SMBCCTX * context);
1250 /**@ingroup misc
1251 * Initialize the samba client library.
1253 * Must be called before using any of the smbclient API function
1255 * @param fn The function that will be called to obtaion
1256 * authentication credentials.
1258 * @param debug Allows caller to set the debug level. Can be
1259 * changed in smb.conf file. Allows caller to set
1260 * debugging if no smb.conf.
1262 * @return 0 on success, < 0 on error with errno set:
1263 * - ENOMEM Out of memory
1264 * - ENOENT The smb.conf file would not load
1268 int smbc_init(smbc_get_auth_data_fn fn, int debug);
1270 /**@ingroup misc
1271 * Set or retrieve the compatibility library's context pointer
1273 * @param context New context to use, or NULL. If a new context is provided,
1274 * it must have allocated with smbc_new_context() and
1275 * initialized with smbc_init_context(), followed, optionally,
1276 * by some manual changes to some of the non-internal fields.
1278 * @return The old context.
1280 * @see smbc_new_context(), smbc_init_context(), smbc_init()
1282 * @note This function may be called prior to smbc_init() to force
1283 * use of the next context without any internal calls to
1284 * smbc_new_context() or smbc_init_context(). It may also
1285 * be called after smbc_init() has already called those two
1286 * functions, to replace the existing context with a new one.
1287 * Care should be taken, in this latter case, to ensure that
1288 * the server cache and any data allocated by the
1289 * authentication functions have been freed, if necessary.
1292 SMBCCTX * smbc_set_context(SMBCCTX * new_context);
1294 /**@ingroup file
1295 * Open a file on an SMB server.
1297 * @param furl The smb url of the file to be opened.
1299 * @param flags Is one of O_RDONLY, O_WRONLY or O_RDWR which
1300 * request opening the file read-only,write-only
1301 * or read/write. flags may also be bitwise-or'd with
1302 * one or more of the following:
1303 * O_CREAT - If the file does not exist it will be
1304 * created.
1305 * O_EXCL - When used with O_CREAT, if the file
1306 * already exists it is an error and the open will
1307 * fail.
1308 * O_TRUNC - If the file already exists it will be
1309 * truncated.
1310 * O_APPEND The file is opened in append mode
1312 * @param mode mode specifies the permissions to use if a new
1313 * file is created. It is modified by the
1314 * process's umask in the usual way: the permissions
1315 * of the created file are (mode & ~umask)
1317 * Not currently use, but there for future use.
1318 * We will map this to SYSTEM, HIDDEN, etc bits
1319 * that reverses the mapping that smbc_fstat does.
1321 * @return Valid file handle, < 0 on error with errno set:
1322 * - ENOMEM Out of memory
1323 * - EINVAL if an invalid parameter passed, like no
1324 * file, or smbc_init not called.
1325 * - EEXIST pathname already exists and O_CREAT and
1326 * O_EXCL were used.
1327 * - EISDIR pathname refers to a directory and
1328 * the access requested involved writing.
1329 * - EACCES The requested access to the file is not
1330 * allowed
1331 * - ENODEV The requested share does not exist
1332 * - ENOTDIR A file on the path is not a directory
1333 * - ENOENT A directory component in pathname does
1334 * not exist.
1336 * @see smbc_creat()
1338 * @note This call uses an underlying routine that may create
1339 * a new connection to the server specified in the URL.
1340 * If the credentials supplied in the URL, or via the
1341 * auth_fn in the smbc_init call, fail, this call will
1342 * try again with an empty username and password. This
1343 * often gets mapped to the guest account on some machines.
1346 int smbc_open(const char *furl, int flags, mode_t mode);
1348 /**@ingroup file
1349 * Create a file on an SMB server.
1351 * Same as calling smbc_open() with flags = O_CREAT|O_WRONLY|O_TRUNC
1353 * @param furl The smb url of the file to be created
1355 * @param mode mode specifies the permissions to use if a new
1356 * file is created. It is modified by the
1357 * process's umask in the usual way: the permissions
1358 * of the created file are (mode & ~umask)
1360 * NOTE, the above is not true. We are dealing with
1361 * an SMB server, which has no concept of a umask!
1363 * @return Valid file handle, < 0 on error with errno set:
1364 * - ENOMEM Out of memory
1365 * - EINVAL if an invalid parameter passed, like no
1366 * file, or smbc_init not called.
1367 * - EEXIST pathname already exists and O_CREAT and
1368 * O_EXCL were used.
1369 * - EISDIR pathname refers to a directory and
1370 * the access requested involved writing.
1371 * - EACCES The requested access to the file is not
1372 * allowed
1373 * - ENOENT A directory component in pathname does
1374 * not exist.
1375 * - ENODEV The requested share does not exist.
1376 * @see smbc_open()
1380 int smbc_creat(const char *furl, mode_t mode);
1382 /**@ingroup file
1383 * Read from a file using an opened file handle.
1385 * @param fd Open file handle from smbc_open() or smbc_creat()
1387 * @param buf Pointer to buffer to receive read data
1389 * @param bufsize Size of buf in bytes
1391 * @return Number of bytes read;
1392 * 0 upon EOF;
1393 * < 0 on error, with errno set:
1394 * - EISDIR fd refers to a directory
1395 * - EBADF fd is not a valid file descriptor or
1396 * is not open for reading.
1397 * - EINVAL fd is attached to an object which is
1398 * unsuitable for reading, or no buffer passed or
1399 * smbc_init not called.
1401 * @see smbc_open(), smbc_write()
1404 ssize_t smbc_read(int fd, void *buf, size_t bufsize);
1407 /**@ingroup file
1408 * Write to a file using an opened file handle.
1410 * @param fd Open file handle from smbc_open() or smbc_creat()
1412 * @param buf Pointer to buffer to recieve read data
1414 * @param bufsize Size of buf in bytes
1416 * @return Number of bytes written, < 0 on error with errno set:
1417 * - EISDIR fd refers to a directory.
1418 * - EBADF fd is not a valid file descriptor or
1419 * is not open for reading.
1420 * - EINVAL fd is attached to an object which is
1421 * unsuitable for reading, or no buffer passed or
1422 * smbc_init not called.
1424 * @see smbc_open(), smbc_read()
1427 ssize_t smbc_write(int fd, const void *buf, size_t bufsize);
1430 /**@ingroup file
1431 * Seek to a specific location in a file.
1433 * @param fd Open file handle from smbc_open() or smbc_creat()
1435 * @param offset Offset in bytes from whence
1437 * @param whence A location in the file:
1438 * - SEEK_SET The offset is set to offset bytes from
1439 * the beginning of the file
1440 * - SEEK_CUR The offset is set to current location
1441 * plus offset bytes.
1442 * - SEEK_END The offset is set to the size of the
1443 * file plus offset bytes.
1445 * @return Upon successful completion, lseek returns the
1446 * resulting offset location as measured in bytes
1447 * from the beginning of the file. Otherwise, a value
1448 * of (off_t)-1 is returned and errno is set to
1449 * indicate the error:
1450 * - EBADF Fildes is not an open file descriptor.
1451 * - EINVAL Whence is not a proper value or smbc_init
1452 * not called.
1454 * @todo Are all the whence values really supported?
1456 * @todo Are errno values complete and correct?
1458 off_t smbc_lseek(int fd, off_t offset, int whence);
1461 /**@ingroup file
1462 * Close an open file handle.
1464 * @param fd The file handle to close
1466 * @return 0 on success, < 0 on error with errno set:
1467 * - EBADF fd isn't a valid open file descriptor
1468 * - EINVAL smbc_init() failed or has not been called
1470 * @see smbc_open(), smbc_creat()
1472 int smbc_close(int fd);
1475 /**@ingroup directory
1476 * Unlink (delete) a file or directory.
1478 * @param furl The smb url of the file to delete
1480 * @return 0 on success, < 0 on error with errno set:
1481 * - EACCES or EPERM Write access to the directory
1482 * containing pathname is not allowed or one
1483 * of the directories in pathname did not allow
1484 * search (execute) permission
1485 * - ENOENT A directory component in pathname does
1486 * not exist
1487 * - EINVAL NULL was passed in the file param or
1488 * smbc_init not called.
1489 * - EACCES You do not have access to the file
1490 * - ENOMEM Insufficient kernel memory was available
1492 * @see smbc_rmdir()s
1494 * @todo Are errno values complete and correct?
1496 int smbc_unlink(const char *furl);
1499 /**@ingroup directory
1500 * Rename or move a file or directory.
1502 * @param ourl The original smb url (source url) of file or
1503 * directory to be moved
1505 * @param nurl The new smb url (destination url) of the file
1506 * or directory after the move. Currently nurl must
1507 * be on the same share as ourl.
1509 * @return 0 on success, < 0 on error with errno set:
1510 * - EISDIR nurl is an existing directory, but ourl is
1511 * not a directory.
1512 * - EEXIST nurl is a non-empty directory,
1513 * i.e., contains entries other than "." and ".."
1514 * - EINVAL The new url contained a path prefix
1515 * of the old, or, more generally, an attempt was
1516 * made to make a directory a subdirectory of itself
1517 * or smbc_init not called.
1518 * - ENOTDIR A component used as a directory in ourl
1519 * or nurl path is not, in fact, a directory. Or,
1520 * ourl is a directory, and newpath exists but is not
1521 * a directory.
1522 * - EACCES or EPERM Write access to the directory
1523 * containing ourl or nurl is not allowed for the
1524 * process's effective uid, or one of the
1525 * directories in ourl or nurl did not allow search
1526 * (execute) permission, or ourl was a directory
1527 * and did not allow write permission.
1528 * - ENOENT A directory component in ourl or nurl
1529 * does not exist.
1530 * - EXDEV Rename across shares not supported.
1531 * - ENOMEM Insufficient kernel memory was available.
1532 * - EEXIST The target file, nurl, already exists.
1535 * @todo Are we going to support copying when urls are not on the same
1536 * share? I say no... NOTE. I agree for the moment.
1539 int smbc_rename(const char *ourl, const char *nurl);
1542 /**@ingroup directory
1543 * Open a directory used to obtain directory entries.
1545 * @param durl The smb url of the directory to open
1547 * @return Valid directory handle. < 0 on error with errno set:
1548 * - EACCES Permission denied.
1549 * - EINVAL A NULL file/URL was passed, or the URL would
1550 * not parse, or was of incorrect form or smbc_init not
1551 * called.
1552 * - ENOENT durl does not exist, or name is an
1553 * - ENOMEM Insufficient memory to complete the
1554 * operation.
1555 * - ENOTDIR name is not a directory.
1556 * - EPERM the workgroup could not be found.
1557 * - ENODEV the workgroup or server could not be found.
1559 * @see smbc_getdents(), smbc_readdir(), smbc_closedir()
1562 int smbc_opendir(const char *durl);
1565 /**@ingroup directory
1566 * Close a directory handle opened by smbc_opendir().
1568 * @param dh Directory handle to close
1570 * @return 0 on success, < 0 on error with errno set:
1571 * - EBADF dh is an invalid directory handle
1573 * @see smbc_opendir()
1575 int smbc_closedir(int dh);
1578 /**@ingroup directory
1579 * Get multiple directory entries.
1581 * smbc_getdents() reads as many dirent structures from the an open
1582 * directory handle into a specified memory area as will fit.
1584 * @param dh Valid directory as returned by smbc_opendir()
1586 * @param dirp pointer to buffer that will receive the directory
1587 * entries.
1589 * @param count The size of the dirp buffer in bytes
1591 * @returns If any dirents returned, return will indicate the
1592 * total size. If there were no more dirents available,
1593 * 0 is returned. < 0 indicates an error.
1594 * - EBADF Invalid directory handle
1595 * - EINVAL Result buffer is too small or smbc_init
1596 * not called.
1597 * - ENOENT No such directory.
1598 * @see , smbc_dirent, smbc_readdir(), smbc_open()
1600 * @todo Are errno values complete and correct?
1602 * @todo Add example code so people know how to parse buffers.
1604 int smbc_getdents(unsigned int dh, struct smbc_dirent *dirp, int count);
1607 /**@ingroup directory
1608 * Get a single directory entry.
1610 * @param dh Valid directory as returned by smbc_opendir()
1612 * @return A pointer to a smbc_dirent structure, or NULL if an
1613 * error occurs or end-of-directory is reached:
1614 * - EBADF Invalid directory handle
1615 * - EINVAL smbc_init() failed or has not been called
1617 * @see smbc_dirent, smbc_getdents(), smbc_open()
1619 struct smbc_dirent* smbc_readdir(unsigned int dh);
1622 /**@ingroup directory
1623 * Get the current directory offset.
1625 * smbc_telldir() may be used in conjunction with smbc_readdir() and
1626 * smbc_lseekdir().
1628 * @param dh Valid directory as returned by smbc_opendir()
1630 * @return The current location in the directory stream or -1
1631 * if an error occur. The current location is not
1632 * an offset. Becuase of the implementation, it is a
1633 * handle that allows the library to find the entry
1634 * later.
1635 * - EBADF dh is not a valid directory handle
1636 * - EINVAL smbc_init() failed or has not been called
1637 * - ENOTDIR if dh is not a directory
1639 * @see smbc_readdir()
1642 off_t smbc_telldir(int dh);
1645 /**@ingroup directory
1646 * lseek on directories.
1648 * smbc_lseekdir() may be used in conjunction with smbc_readdir() and
1649 * smbc_telldir(). (rewind by smbc_lseekdir(fd, NULL))
1651 * @param fd Valid directory as returned by smbc_opendir()
1653 * @param offset The offset (as returned by smbc_telldir). Can be
1654 * NULL, in which case we will rewind
1656 * @return 0 on success, -1 on failure
1657 * - EBADF dh is not a valid directory handle
1658 * - ENOTDIR if dh is not a directory
1659 * - EINVAL offset did not refer to a valid dirent or
1660 * smbc_init not called.
1662 * @see smbc_telldir()
1665 * @todo In what does the reture and errno values mean?
1667 int smbc_lseekdir(int fd, off_t offset);
1669 /**@ingroup directory
1670 * Create a directory.
1672 * @param durl The url of the directory to create
1674 * @param mode Specifies the permissions to use. It is modified
1675 * by the process's umask in the usual way: the
1676 * permissions of the created file are (mode & ~umask).
1678 * @return 0 on success, < 0 on error with errno set:
1679 * - EEXIST directory url already exists
1680 * - EACCES The parent directory does not allow write
1681 * permission to the process, or one of the directories
1682 * - ENOENT A directory component in pathname does not
1683 * exist.
1684 * - EINVAL NULL durl passed or smbc_init not called.
1685 * - ENOMEM Insufficient memory was available.
1687 * @see smbc_rmdir()
1690 int smbc_mkdir(const char *durl, mode_t mode);
1693 /**@ingroup directory
1694 * Remove a directory.
1696 * @param durl The smb url of the directory to remove
1698 * @return 0 on success, < 0 on error with errno set:
1699 * - EACCES or EPERM Write access to the directory
1700 * containing pathname was not allowed.
1701 * - EINVAL durl is NULL or smbc_init not called.
1702 * - ENOENT A directory component in pathname does not
1703 * exist.
1704 * - ENOTEMPTY directory contains entries.
1705 * - ENOMEM Insufficient kernel memory was available.
1707 * @see smbc_mkdir(), smbc_unlink()
1709 * @todo Are errno values complete and correct?
1711 int smbc_rmdir(const char *durl);
1713 /**@ingroup directory
1714 * Request directory notifications
1716 * @param dh Valid directory as returned by smbc_opendir()
1718 * @param recursive Are changes in subdirectories wanted?
1720 * @param completion_filter Bitwise-or of the SMBC_NOTIFY_CHANGE_*
1721 * events that are interesting
1723 * @param callback_timeout_ms If set to non-zero, interval in milliseconds
1724 * that "cb" will be called with 0 actions.
1725 * This gives "cb" the chance to cancel the
1726 * smbc_notify call.
1728 * @param cb Callback functions taking events. If "cb"
1729 * returns nonzero, smbc_notify will return.
1731 * @param private_data Pointer given to "cb"
1733 * @return 0 on success, -1 on error with errno set
1735 * @see smbc_opendir(), smbc_closedir()
1738 #define SMBC_NOTIFY_CHANGE_FILE_NAME 0x001
1739 #define SMBC_NOTIFY_CHANGE_DIR_NAME 0x002
1740 #define SMBC_NOTIFY_CHANGE_ATTRIBUTES 0x004
1741 #define SMBC_NOTIFY_CHANGE_SIZE 0x008
1742 #define SMBC_NOTIFY_CHANGE_LAST_WRITE 0x010
1743 #define SMBC_NOTIFY_CHANGE_LAST_ACCESS 0x020
1744 #define SMBC_NOTIFY_CHANGE_CREATION 0x040
1745 #define SMBC_NOTIFY_CHANGE_EA 0x080
1746 #define SMBC_NOTIFY_CHANGE_SECURITY 0x100
1747 #define SMBC_NOTIFY_CHANGE_STREAM_NAME 0x200
1748 #define SMBC_NOTIFY_CHANGE_STREAM_SIZE 0x400
1749 #define SMBC_NOTIFY_CHANGE_STREAM_WRITE 0x800
1751 int smbc_notify(int dh, smbc_bool recursive, uint32_t completion_filter,
1752 unsigned callback_timeout_ms,
1753 smbc_notify_callback_fn cb, void *private_data);
1755 /**@ingroup attribute
1756 * Get information about a file or directory.
1758 * @param url The smb url to get information for
1760 * @param st pointer to a buffer that will be filled with
1761 * standard Unix struct stat information.
1763 * @return 0 on success, < 0 on error with errno set:
1764 * - ENOENT A component of the path file_name does not
1765 * exist.
1766 * - EINVAL a NULL url was passed or smbc_init not called.
1767 * - EACCES Permission denied.
1768 * - ENOMEM Out of memory
1769 * - ENOTDIR The target dir, url, is not a directory.
1771 * @see Unix stat()
1774 int smbc_stat(const char *url, struct stat *st);
1777 /**@ingroup attribute
1778 * Get file information via an file descriptor.
1780 * @param fd Open file handle from smbc_open() or smbc_creat()
1782 * @param st pointer to a buffer that will be filled with
1783 * standard Unix struct stat information.
1785 * @return 0 on success, < 0 on error with errno set:
1786 * - EBADF filedes is bad.
1787 * - EACCES Permission denied.
1788 * - EBADF fd is not a valid file descriptor
1789 * - EINVAL Problems occurred in the underlying routines
1790 * or smbc_init not called.
1791 * - ENOMEM Out of memory
1793 * @see smbc_stat(), Unix stat()
1796 int smbc_fstat(int fd, struct stat *st);
1799 /**@ingroup attribute
1800 * Get file system information for a specified path.
1802 * @param url The smb url to get information for
1804 * @param st pointer to a buffer that will be filled with
1805 * standard Unix struct statvfs information.
1807 * @return 0 on success, < 0 on error with errno set:
1808 * - EBADF filedes is bad.
1809 * - EACCES Permission denied.
1810 * - EBADF fd is not a valid file descriptor
1811 * - EINVAL Problems occurred in the underlying routines
1812 * or smbc_init not called.
1813 * - ENOMEM Out of memory
1815 * @see Unix fstatvfs()
1819 smbc_statvfs(char *url,
1820 struct statvfs *st);
1822 /**@ingroup attribute
1823 * Get file system information via an file descriptor.
1825 * @param fd Open file handle from smbc_open(), smbc_creat(),
1826 * or smbc_opendir()
1828 * @param st pointer to a buffer that will be filled with
1829 * standard Unix struct statvfs information.
1831 * @return 0 on success, < 0 on error with errno set:
1832 * - EBADF filedes is bad.
1833 * - EACCES Permission denied.
1834 * - EBADF fd is not a valid file descriptor
1835 * - EINVAL Problems occurred in the underlying routines
1836 * or smbc_init not called.
1837 * - ENOMEM Out of memory
1839 * @see Unix fstatvfs()
1843 smbc_fstatvfs(int fd,
1844 struct statvfs *st);
1847 /**@ingroup attribute
1848 * Truncate a file given a file descriptor
1850 * @param fd Open file handle from smbc_open() or smbc_creat()
1852 * @param size size to truncate the file to
1854 * @return 0 on success, < 0 on error with errno set:
1855 * - EBADF filedes is bad.
1856 * - EACCES Permission denied.
1857 * - EBADF fd is not a valid file descriptor
1858 * - EINVAL Problems occurred in the underlying routines
1859 * or smbc_init not called.
1860 * - ENOMEM Out of memory
1862 * @see , Unix ftruncate()
1865 int smbc_ftruncate(int fd, off_t size);
1868 /**@ingroup attribute
1869 * Change the permissions of a file.
1871 * @param url The smb url of the file or directory to change
1872 * permissions of
1874 * @param mode The permissions to set:
1875 * - Put good explaination of permissions here!
1877 * @return 0 on success, < 0 on error with errno set:
1878 * - EPERM The effective UID does not match the owner
1879 * of the file, and is not zero
1880 * - ENOENT The file does not exist.
1881 * - ENOMEM Insufficient was available.
1882 * - ENOENT file or directory does not exist
1884 * @todo Actually implement this fuction?
1886 * @todo Are errno values complete and correct?
1888 int smbc_chmod(const char *url, mode_t mode);
1891 * @ingroup attribute
1892 * Change the last modification time on a file
1894 * @param url The smb url of the file or directory to change
1895 * the modification time of
1897 * @param tbuf An array of two timeval structures which contains,
1898 * respectively, the desired access and modification times.
1899 * NOTE: Only the tv_sec field off each timeval structure is
1900 * used. The tv_usec (microseconds) portion is ignored.
1902 * @return 0 on success, < 0 on error with errno set:
1903 * - EINVAL The client library is not properly initialized
1904 * - EPERM Permission was denied.
1907 int smbc_utimes(const char *url, struct timeval *tbuf);
1909 #ifdef HAVE_UTIME_H
1911 * @ingroup attribute
1912 * Change the last modification time on a file
1914 * @param url The smb url of the file or directory to change
1915 * the modification time of
1917 * @param utbuf A pointer to a utimebuf structure which contains the
1918 * desired access and modification times.
1920 * @return 0 on success, < 0 on error with errno set:
1921 * - EINVAL The client library is not properly initialized
1922 * - ENOMEM No memory was available for internal needs
1923 * - EPERM Permission was denied.
1926 int smbc_utime(const char *fname, struct utimbuf *utbuf);
1927 #endif
1929 /**@ingroup attribute
1930 * Set extended attributes for a file. This is used for modifying a file's
1931 * security descriptor (i.e. owner, group, and access control list)
1933 * @param url The smb url of the file or directory to set extended
1934 * attributes for.
1936 * @param name The name of an attribute to be changed. Names are of
1937 * one of the following forms:
1939 * system.nt_sec_desc.<attribute name>
1940 * system.nt_sec_desc.*
1941 * system.nt_sec_desc.*+
1943 * where <attribute name> is one of:
1945 * revision
1946 * owner
1947 * owner+
1948 * group
1949 * group+
1950 * acl:<name or sid>
1951 * acl+:<name or sid>
1953 * In the forms "system.nt_sec_desc.*" and
1954 * "system.nt_sec_desc.*+", the asterisk and plus signs are
1955 * literal, i.e. the string is provided exactly as shown, and
1956 * the value parameter should contain a complete security
1957 * descriptor with name:value pairs separated by tabs,
1958 * commas, or newlines (not spaces!).
1960 * The plus sign ('+') indicates that SIDs should be mapped
1961 * to names. Without the plus sign, SIDs are not mapped;
1962 * rather they are simply converted to a string format.
1964 * @param value The value to be assigned to the specified attribute name.
1965 * This buffer should contain only the attribute value if the
1966 * name was of the "system.nt_sec_desc.<attribute_name>"
1967 * form. If the name was of the "system.nt_sec_desc.*" form
1968 * then a complete security descriptor, with name:value pairs
1969 * separated by tabs, commas, or newlines (not spaces!),
1970 * should be provided in this value buffer. A complete
1971 * security descriptor will contain one or more entries
1972 * selected from the following:
1974 * REVISION:<revision number>
1975 * OWNER:<sid or name>
1976 * GROUP:<sid or name>
1977 * ACL:<sid or name>:<type>/<flags>/<mask>
1979 * The revision of the ACL specifies the internal Windows NT
1980 * ACL revision for the security descriptor. If not specified
1981 * it defaults to 1. Using values other than 1 may cause
1982 * strange behaviour.
1984 * The owner and group specify the owner and group sids for
1985 * the object. If the attribute name (either '*+' with a
1986 * complete security descriptor, or individual 'owner+' or
1987 * 'group+' attribute names) ended with a plus sign, the
1988 * specified name is resolved to a SID value, using the
1989 * server on which the file or directory resides. Otherwise,
1990 * the value should be provided in SID-printable format as
1991 * S-1-x-y-z, and is used directly. The <sid or name>
1992 * associated with the ACL: attribute should be provided
1993 * similarly.
1995 * @param size The number of the bytes of data in the value buffer
1997 * @param flags A bit-wise OR of zero or more of the following:
1998 * SMBC_XATTR_FLAG_CREATE -
1999 * fail if the named attribute already exists
2000 * SMBC_XATTR_FLAG_REPLACE -
2001 * fail if the attribute does not already exist
2003 * If neither flag is specified, the specified attributes
2004 * will be added or replace existing attributes of the same
2005 * name, as necessary.
2007 * @return 0 on success, < 0 on error with errno set:
2008 * - EINVAL The client library is not properly initialized
2009 * or one of the parameters is not of a correct
2010 * form
2011 * - ENOMEM No memory was available for internal needs
2012 * - EEXIST If the attribute already exists and the flag
2013 * SMBC_XATTR_FLAG_CREAT was specified
2014 * - ENOATTR If the attribute does not exist and the flag
2015 * SMBC_XATTR_FLAG_REPLACE was specified
2016 * - EPERM Permission was denied.
2017 * - ENOTSUP The referenced file system does not support
2018 * extended attributes
2020 * @note Attribute names are compared in a case-insensitive
2021 * fashion. All of the following are equivalent, although
2022 * the all-lower-case name is the preferred format:
2023 * system.nt_sec_desc.owner
2024 * SYSTEM.NT_SEC_DESC.OWNER
2025 * sYsTeM.nt_sEc_desc.owNER
2028 int smbc_setxattr(const char *url,
2029 const char *name,
2030 const void *value,
2031 size_t size,
2032 int flags);
2035 /**@ingroup attribute
2036 * Set extended attributes for a file. This is used for modifying a file's
2037 * security descriptor (i.e. owner, group, and access control list). The
2038 * POSIX function which this maps to would act on a symbolic link rather than
2039 * acting on what the symbolic link points to, but with no symbolic links in
2040 * SMB file systems, this function is functionally identical to
2041 * smbc_setxattr().
2043 * @param url The smb url of the file or directory to set extended
2044 * attributes for.
2046 * @param name The name of an attribute to be changed. Names are of
2047 * one of the following forms:
2049 * system.nt_sec_desc.<attribute name>
2050 * system.nt_sec_desc.*
2051 * system.nt_sec_desc.*+
2053 * where <attribute name> is one of:
2055 * revision
2056 * owner
2057 * owner+
2058 * group
2059 * group+
2060 * acl:<name or sid>
2061 * acl+:<name or sid>
2063 * In the forms "system.nt_sec_desc.*" and
2064 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2065 * literal, i.e. the string is provided exactly as shown, and
2066 * the value parameter should contain a complete security
2067 * descriptor with name:value pairs separated by tabs,
2068 * commas, or newlines (not spaces!).
2070 * The plus sign ('+') indicates that SIDs should be mapped
2071 * to names. Without the plus sign, SIDs are not mapped;
2072 * rather they are simply converted to a string format.
2074 * @param value The value to be assigned to the specified attribute name.
2075 * This buffer should contain only the attribute value if the
2076 * name was of the "system.nt_sec_desc.<attribute_name>"
2077 * form. If the name was of the "system.nt_sec_desc.*" form
2078 * then a complete security descriptor, with name:value pairs
2079 * separated by tabs, commas, or newlines (not spaces!),
2080 * should be provided in this value buffer. A complete
2081 * security descriptor will contain one or more entries
2082 * selected from the following:
2084 * REVISION:<revision number>
2085 * OWNER:<sid or name>
2086 * GROUP:<sid or name>
2087 * ACL:<sid or name>:<type>/<flags>/<mask>
2089 * The revision of the ACL specifies the internal Windows NT
2090 * ACL revision for the security descriptor. If not specified
2091 * it defaults to 1. Using values other than 1 may cause
2092 * strange behaviour.
2094 * The owner and group specify the owner and group sids for
2095 * the object. If the attribute name (either '*+' with a
2096 * complete security descriptor, or individual 'owner+' or
2097 * 'group+' attribute names) ended with a plus sign, the
2098 * specified name is resolved to a SID value, using the
2099 * server on which the file or directory resides. Otherwise,
2100 * the value should be provided in SID-printable format as
2101 * S-1-x-y-z, and is used directly. The <sid or name>
2102 * associated with the ACL: attribute should be provided
2103 * similarly.
2105 * @param size The number of the bytes of data in the value buffer
2107 * @param flags A bit-wise OR of zero or more of the following:
2108 * SMBC_XATTR_FLAG_CREATE -
2109 * fail if the named attribute already exists
2110 * SMBC_XATTR_FLAG_REPLACE -
2111 * fail if the attribute does not already exist
2113 * If neither flag is specified, the specified attributes
2114 * will be added or replace existing attributes of the same
2115 * name, as necessary.
2117 * @return 0 on success, < 0 on error with errno set:
2118 * - EINVAL The client library is not properly initialized
2119 * or one of the parameters is not of a correct
2120 * form
2121 * - ENOMEM No memory was available for internal needs
2122 * - EEXIST If the attribute already exists and the flag
2123 * SMBC_XATTR_FLAG_CREAT was specified
2124 * - ENOATTR If the attribute does not exist and the flag
2125 * SMBC_XATTR_FLAG_REPLACE was specified
2126 * - EPERM Permission was denied.
2127 * - ENOTSUP The referenced file system does not support
2128 * extended attributes
2130 * @note Attribute names are compared in a case-insensitive
2131 * fashion. All of the following are equivalent, although
2132 * the all-lower-case name is the preferred format:
2133 * system.nt_sec_desc.owner
2134 * SYSTEM.NT_SEC_DESC.OWNER
2135 * sYsTeM.nt_sEc_desc.owNER
2138 int smbc_lsetxattr(const char *url,
2139 const char *name,
2140 const void *value,
2141 size_t size,
2142 int flags);
2145 /**@ingroup attribute
2146 * Set extended attributes for a file. This is used for modifying a file's
2147 * security descriptor (i.e. owner, group, and access control list)
2149 * @param fd A file descriptor associated with an open file (as
2150 * previously returned by smbc_open(), to get extended
2151 * attributes for.
2153 * @param name The name of an attribute to be changed. Names are of
2154 * one of the following forms:
2156 * system.nt_sec_desc.<attribute name>
2157 * system.nt_sec_desc.*
2158 * system.nt_sec_desc.*+
2160 * where <attribute name> is one of:
2162 * revision
2163 * owner
2164 * owner+
2165 * group
2166 * group+
2167 * acl:<name or sid>
2168 * acl+:<name or sid>
2170 * In the forms "system.nt_sec_desc.*" and
2171 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2172 * literal, i.e. the string is provided exactly as shown, and
2173 * the value parameter should contain a complete security
2174 * descriptor with name:value pairs separated by tabs,
2175 * commas, or newlines (not spaces!).
2177 * The plus sign ('+') indicates that SIDs should be mapped
2178 * to names. Without the plus sign, SIDs are not mapped;
2179 * rather they are simply converted to a string format.
2181 * @param value The value to be assigned to the specified attribute name.
2182 * This buffer should contain only the attribute value if the
2183 * name was of the "system.nt_sec_desc.<attribute_name>"
2184 * form. If the name was of the "system.nt_sec_desc.*" form
2185 * then a complete security descriptor, with name:value pairs
2186 * separated by tabs, commas, or newlines (not spaces!),
2187 * should be provided in this value buffer. A complete
2188 * security descriptor will contain one or more entries
2189 * selected from the following:
2191 * REVISION:<revision number>
2192 * OWNER:<sid or name>
2193 * GROUP:<sid or name>
2194 * ACL:<sid or name>:<type>/<flags>/<mask>
2196 * The revision of the ACL specifies the internal Windows NT
2197 * ACL revision for the security descriptor. If not specified
2198 * it defaults to 1. Using values other than 1 may cause
2199 * strange behaviour.
2201 * The owner and group specify the owner and group sids for
2202 * the object. If the attribute name (either '*+' with a
2203 * complete security descriptor, or individual 'owner+' or
2204 * 'group+' attribute names) ended with a plus sign, the
2205 * specified name is resolved to a SID value, using the
2206 * server on which the file or directory resides. Otherwise,
2207 * the value should be provided in SID-printable format as
2208 * S-1-x-y-z, and is used directly. The <sid or name>
2209 * associated with the ACL: attribute should be provided
2210 * similarly.
2212 * @param size The number of the bytes of data in the value buffer
2214 * @param flags A bit-wise OR of zero or more of the following:
2215 * SMBC_XATTR_FLAG_CREATE -
2216 * fail if the named attribute already exists
2217 * SMBC_XATTR_FLAG_REPLACE -
2218 * fail if the attribute does not already exist
2220 * If neither flag is specified, the specified attributes
2221 * will be added or replace existing attributes of the same
2222 * name, as necessary.
2224 * @return 0 on success, < 0 on error with errno set:
2225 * - EINVAL The client library is not properly initialized
2226 * or one of the parameters is not of a correct
2227 * form
2228 * - ENOMEM No memory was available for internal needs
2229 * - EEXIST If the attribute already exists and the flag
2230 * SMBC_XATTR_FLAG_CREAT was specified
2231 * - ENOATTR If the attribute does not exist and the flag
2232 * SMBC_XATTR_FLAG_REPLACE was specified
2233 * - EPERM Permission was denied.
2234 * - ENOTSUP The referenced file system does not support
2235 * extended attributes
2237 * @note Attribute names are compared in a case-insensitive
2238 * fashion. All of the following are equivalent, although
2239 * the all-lower-case name is the preferred format:
2240 * system.nt_sec_desc.owner
2241 * SYSTEM.NT_SEC_DESC.OWNER
2242 * sYsTeM.nt_sEc_desc.owNER
2245 int smbc_fsetxattr(int fd,
2246 const char *name,
2247 const void *value,
2248 size_t size,
2249 int flags);
2252 /**@ingroup attribute
2253 * Get extended attributes for a file.
2255 * @param url The smb url of the file or directory to get extended
2256 * attributes for.
2258 * @param name The name of an attribute to be retrieved. Names are of
2259 * one of the following forms:
2261 * system.nt_sec_desc.<attribute name>
2262 * system.nt_sec_desc.*
2263 * system.nt_sec_desc.*+
2265 * where <attribute name> is one of:
2267 * revision
2268 * owner
2269 * owner+
2270 * group
2271 * group+
2272 * acl:<name or sid>
2273 * acl+:<name or sid>
2275 * In the forms "system.nt_sec_desc.*" and
2276 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2277 * literal, i.e. the string is provided exactly as shown, and
2278 * the value parameter will return a complete security
2279 * descriptor with name:value pairs separated by tabs,
2280 * commas, or newlines (not spaces!).
2282 * The plus sign ('+') indicates that SIDs should be mapped
2283 * to names. Without the plus sign, SIDs are not mapped;
2284 * rather they are simply converted to a string format.
2286 * @param value A pointer to a buffer in which the value of the specified
2287 * attribute will be placed (unless size is zero).
2289 * @param size The size of the buffer pointed to by value. This parameter
2290 * may also be zero, in which case the size of the buffer
2291 * required to hold the attribute value will be returned,
2292 * but nothing will be placed into the value buffer.
2294 * @return 0 on success, < 0 on error with errno set:
2295 * - EINVAL The client library is not properly initialized
2296 * or one of the parameters is not of a correct
2297 * form
2298 * - ENOMEM No memory was available for internal needs
2299 * - EEXIST If the attribute already exists and the flag
2300 * SMBC_XATTR_FLAG_CREAT was specified
2301 * - ENOATTR If the attribute does not exist and the flag
2302 * SMBC_XATTR_FLAG_REPLACE was specified
2303 * - EPERM Permission was denied.
2304 * - ENOTSUP The referenced file system does not support
2305 * extended attributes
2308 int smbc_getxattr(const char *url,
2309 const char *name,
2310 const void *value,
2311 size_t size);
2314 /**@ingroup attribute
2315 * Get extended attributes for a file. The POSIX function which this maps to
2316 * would act on a symbolic link rather than acting on what the symbolic link
2317 * points to, but with no symbolic links in SMB file systems, this function
2318 * is functionally identical to smbc_getxattr().
2320 * @param url The smb url of the file or directory to get extended
2321 * attributes for.
2323 * @param name The name of an attribute to be retrieved. Names are of
2324 * one of the following forms:
2326 * system.nt_sec_desc.<attribute name>
2327 * system.nt_sec_desc.*
2328 * system.nt_sec_desc.*+
2330 * where <attribute name> is one of:
2332 * revision
2333 * owner
2334 * owner+
2335 * group
2336 * group+
2337 * acl:<name or sid>
2338 * acl+:<name or sid>
2340 * In the forms "system.nt_sec_desc.*" and
2341 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2342 * literal, i.e. the string is provided exactly as shown, and
2343 * the value parameter will return a complete security
2344 * descriptor with name:value pairs separated by tabs,
2345 * commas, or newlines (not spaces!).
2347 * The plus sign ('+') indicates that SIDs should be mapped
2348 * to names. Without the plus sign, SIDs are not mapped;
2349 * rather they are simply converted to a string format.
2351 * @param value A pointer to a buffer in which the value of the specified
2352 * attribute will be placed (unless size is zero).
2354 * @param size The size of the buffer pointed to by value. This parameter
2355 * may also be zero, in which case the size of the buffer
2356 * required to hold the attribute value will be returned,
2357 * but nothing will be placed into the value buffer.
2359 * @return 0 on success, < 0 on error with errno set:
2360 * - EINVAL The client library is not properly initialized
2361 * or one of the parameters is not of a correct
2362 * form
2363 * - ENOMEM No memory was available for internal needs
2364 * - EEXIST If the attribute already exists and the flag
2365 * SMBC_XATTR_FLAG_CREAT was specified
2366 * - ENOATTR If the attribute does not exist and the flag
2367 * SMBC_XATTR_FLAG_REPLACE was specified
2368 * - EPERM Permission was denied.
2369 * - ENOTSUP The referenced file system does not support
2370 * extended attributes
2373 int smbc_lgetxattr(const char *url,
2374 const char *name,
2375 const void *value,
2376 size_t size);
2379 /**@ingroup attribute
2380 * Get extended attributes for a file.
2382 * @param fd A file descriptor associated with an open file (as
2383 * previously returned by smbc_open(), to get extended
2384 * attributes for.
2386 * @param name The name of an attribute to be retrieved. Names are of
2387 * one of the following forms:
2389 * system.nt_sec_desc.<attribute name>
2390 * system.nt_sec_desc.*
2391 * system.nt_sec_desc.*+
2393 * where <attribute name> is one of:
2395 * revision
2396 * owner
2397 * owner+
2398 * group
2399 * group+
2400 * acl:<name or sid>
2401 * acl+:<name or sid>
2403 * In the forms "system.nt_sec_desc.*" and
2404 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2405 * literal, i.e. the string is provided exactly as shown, and
2406 * the value parameter will return a complete security
2407 * descriptor with name:value pairs separated by tabs,
2408 * commas, or newlines (not spaces!).
2410 * The plus sign ('+') indicates that SIDs should be mapped
2411 * to names. Without the plus sign, SIDs are not mapped;
2412 * rather they are simply converted to a string format.
2414 * @param value A pointer to a buffer in which the value of the specified
2415 * attribute will be placed (unless size is zero).
2417 * @param size The size of the buffer pointed to by value. This parameter
2418 * may also be zero, in which case the size of the buffer
2419 * required to hold the attribute value will be returned,
2420 * but nothing will be placed into the value buffer.
2422 * @return 0 on success, < 0 on error with errno set:
2423 * - EINVAL The client library is not properly initialized
2424 * or one of the parameters is not of a correct
2425 * form
2426 * - ENOMEM No memory was available for internal needs
2427 * - EEXIST If the attribute already exists and the flag
2428 * SMBC_XATTR_FLAG_CREAT was specified
2429 * - ENOATTR If the attribute does not exist and the flag
2430 * SMBC_XATTR_FLAG_REPLACE was specified
2431 * - EPERM Permission was denied.
2432 * - ENOTSUP The referenced file system does not support
2433 * extended attributes
2436 int smbc_fgetxattr(int fd,
2437 const char *name,
2438 const void *value,
2439 size_t size);
2442 /**@ingroup attribute
2443 * Remove extended attributes for a file. This is used for modifying a file's
2444 * security descriptor (i.e. owner, group, and access control list)
2446 * @param url The smb url of the file or directory to remove the extended
2447 * attributes for.
2449 * @param name The name of an attribute to be removed. Names are of
2450 * one of the following forms:
2452 * system.nt_sec_desc.<attribute name>
2453 * system.nt_sec_desc.*
2454 * system.nt_sec_desc.*+
2456 * where <attribute name> is one of:
2458 * revision
2459 * owner
2460 * owner+
2461 * group
2462 * group+
2463 * acl:<name or sid>
2464 * acl+:<name or sid>
2466 * In the forms "system.nt_sec_desc.*" and
2467 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2468 * literal, i.e. the string is provided exactly as shown, and
2469 * the value parameter will return a complete security
2470 * descriptor with name:value pairs separated by tabs,
2471 * commas, or newlines (not spaces!).
2473 * The plus sign ('+') indicates that SIDs should be mapped
2474 * to names. Without the plus sign, SIDs are not mapped;
2475 * rather they are simply converted to a string format.
2477 * @return 0 on success, < 0 on error with errno set:
2478 * - EINVAL The client library is not properly initialized
2479 * - ENOMEM No memory was available for internal needs
2480 * - EPERM Permission was denied.
2481 * - ENOTSUP The referenced file system does not support
2482 * extended attributes
2485 int smbc_removexattr(const char *url,
2486 const char *name);
2489 /**@ingroup attribute
2490 * Remove extended attributes for a file. This is used for modifying a file's
2491 * security descriptor (i.e. owner, group, and access control list) The POSIX
2492 * function which this maps to would act on a symbolic link rather than acting
2493 * on what the symbolic link points to, but with no symbolic links in SMB file
2494 * systems, this function is functionally identical to smbc_removexattr().
2496 * @param url The smb url of the file or directory to remove the extended
2497 * attributes for.
2499 * @param name The name of an attribute to be removed. Names are of
2500 * one of the following forms:
2502 * system.nt_sec_desc.<attribute name>
2503 * system.nt_sec_desc.*
2504 * system.nt_sec_desc.*+
2506 * where <attribute name> is one of:
2508 * revision
2509 * owner
2510 * owner+
2511 * group
2512 * group+
2513 * acl:<name or sid>
2514 * acl+:<name or sid>
2516 * In the forms "system.nt_sec_desc.*" and
2517 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2518 * literal, i.e. the string is provided exactly as shown, and
2519 * the value parameter will return a complete security
2520 * descriptor with name:value pairs separated by tabs,
2521 * commas, or newlines (not spaces!).
2523 * The plus sign ('+') indicates that SIDs should be mapped
2524 * to names. Without the plus sign, SIDs are not mapped;
2525 * rather they are simply converted to a string format.
2527 * @return 0 on success, < 0 on error with errno set:
2528 * - EINVAL The client library is not properly initialized
2529 * - ENOMEM No memory was available for internal needs
2530 * - EPERM Permission was denied.
2531 * - ENOTSUP The referenced file system does not support
2532 * extended attributes
2535 int smbc_lremovexattr(const char *url,
2536 const char *name);
2539 /**@ingroup attribute
2540 * Remove extended attributes for a file. This is used for modifying a file's
2541 * security descriptor (i.e. owner, group, and access control list)
2543 * @param fd A file descriptor associated with an open file (as
2544 * previously returned by smbc_open(), to get extended
2545 * attributes for.
2547 * @param name The name of an attribute to be removed. Names are of
2548 * one of the following forms:
2550 * system.nt_sec_desc.<attribute name>
2551 * system.nt_sec_desc.*
2552 * system.nt_sec_desc.*+
2554 * where <attribute name> is one of:
2556 * revision
2557 * owner
2558 * owner+
2559 * group
2560 * group+
2561 * acl:<name or sid>
2562 * acl+:<name or sid>
2564 * In the forms "system.nt_sec_desc.*" and
2565 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2566 * literal, i.e. the string is provided exactly as shown, and
2567 * the value parameter will return a complete security
2568 * descriptor with name:value pairs separated by tabs,
2569 * commas, or newlines (not spaces!).
2571 * The plus sign ('+') indicates that SIDs should be mapped
2572 * to names. Without the plus sign, SIDs are not mapped;
2573 * rather they are simply converted to a string format.
2575 * @return 0 on success, < 0 on error with errno set:
2576 * - EINVAL The client library is not properly initialized
2577 * - ENOMEM No memory was available for internal needs
2578 * - EPERM Permission was denied.
2579 * - ENOTSUP The referenced file system does not support
2580 * extended attributes
2583 int smbc_fremovexattr(int fd,
2584 const char *name);
2587 /**@ingroup attribute
2588 * List the supported extended attribute names associated with a file
2590 * @param url The smb url of the file or directory to list the extended
2591 * attributes for.
2593 * @param list A pointer to a buffer in which the list of attributes for
2594 * the specified file or directory will be placed (unless
2595 * size is zero).
2597 * @param size The size of the buffer pointed to by list. This parameter
2598 * may also be zero, in which case the size of the buffer
2599 * required to hold all of the attribute names will be
2600 * returned, but nothing will be placed into the list buffer.
2602 * @return 0 on success, < 0 on error with errno set:
2603 * - EINVAL The client library is not properly initialized
2604 * - ENOMEM No memory was available for internal needs
2605 * - EPERM Permission was denied.
2606 * - ENOTSUP The referenced file system does not support
2607 * extended attributes
2609 * @note This function always returns all attribute names supported
2610 * by NT file systems, regardless of whether the referenced
2611 * file system supports extended attributes (e.g. a Windows
2612 * 2000 machine supports extended attributes if NTFS is used,
2613 * but not if FAT is used, and Windows 98 doesn't support
2614 * extended attributes at all. Whether this is a feature or
2615 * a bug is yet to be decided.
2617 int smbc_listxattr(const char *url,
2618 char *list,
2619 size_t size);
2621 /**@ingroup attribute
2622 * List the supported extended attribute names associated with a file The
2623 * POSIX function which this maps to would act on a symbolic link rather than
2624 * acting on what the symbolic link points to, but with no symbolic links in
2625 * SMB file systems, this function is functionally identical to
2626 * smbc_listxattr().
2628 * @param url The smb url of the file or directory to list the extended
2629 * attributes for.
2631 * @param list A pointer to a buffer in which the list of attributes for
2632 * the specified file or directory will be placed (unless
2633 * size is zero).
2635 * @param size The size of the buffer pointed to by list. This parameter
2636 * may also be zero, in which case the size of the buffer
2637 * required to hold all of the attribute names will be
2638 * returned, but nothing will be placed into the list buffer.
2640 * @return 0 on success, < 0 on error with errno set:
2641 * - EINVAL The client library is not properly initialized
2642 * - ENOMEM No memory was available for internal needs
2643 * - EPERM Permission was denied.
2644 * - ENOTSUP The referenced file system does not support
2645 * extended attributes
2647 * @note This function always returns all attribute names supported
2648 * by NT file systems, regardless of wether the referenced
2649 * file system supports extended attributes (e.g. a Windows
2650 * 2000 machine supports extended attributes if NTFS is used,
2651 * but not if FAT is used, and Windows 98 doesn't support
2652 * extended attributes at all. Whether this is a feature or
2653 * a bug is yet to be decided.
2655 int smbc_llistxattr(const char *url,
2656 char *list,
2657 size_t size);
2659 /**@ingroup attribute
2660 * List the supported extended attribute names associated with a file
2662 * @param fd A file descriptor associated with an open file (as
2663 * previously returned by smbc_open(), to get extended
2664 * attributes for.
2666 * @param list A pointer to a buffer in which the list of attributes for
2667 * the specified file or directory will be placed (unless
2668 * size is zero).
2670 * @param size The size of the buffer pointed to by list. This parameter
2671 * may also be zero, in which case the size of the buffer
2672 * required to hold all of the attribute names will be
2673 * returned, but nothing will be placed into the list buffer.
2675 * @return 0 on success, < 0 on error with errno set:
2676 * - EINVAL The client library is not properly initialized
2677 * - ENOMEM No memory was available for internal needs
2678 * - EPERM Permission was denied.
2679 * - ENOTSUP The referenced file system does not support
2680 * extended attributes
2682 * @note This function always returns all attribute names supported
2683 * by NT file systems, regardless of wether the referenced
2684 * file system supports extended attributes (e.g. a Windows
2685 * 2000 machine supports extended attributes if NTFS is used,
2686 * but not if FAT is used, and Windows 98 doesn't support
2687 * extended attributes at all. Whether this is a feature or
2688 * a bug is yet to be decided.
2690 int smbc_flistxattr(int fd,
2691 char *list,
2692 size_t size);
2694 /**@ingroup print
2695 * Print a file given the name in fname. It would be a URL ...
2697 * @param fname The URL of a file on a remote SMB server that the
2698 * caller wants printed
2700 * @param printq The URL of the print share to print the file to.
2702 * @return 0 on success, < 0 on error with errno set:
2704 * - EINVAL fname or printq was NULL or smbc_init not
2705 * not called.
2706 * and errors returned by smbc_open
2709 int smbc_print_file(const char *fname, const char *printq);
2711 /**@ingroup print
2712 * Open a print file that can be written to by other calls. This simply
2713 * does an smbc_open call after checking if there is a file name on the
2714 * URI. If not, a temporary name is added ...
2716 * @param fname The URL of the print share to print to?
2718 * @returns A file handle for the print file if successful.
2719 * Returns -1 if an error ocurred and errno has the values
2720 * - EINVAL fname was NULL or smbc_init not called.
2721 * - all errors returned by smbc_open
2724 int smbc_open_print_job(const char *fname);
2726 /**@ingroup print
2727 * List the print jobs on a print share, for the moment, pass a callback
2729 * @param purl The url of the print share to list the jobs of
2731 * @param fn Callback function the receives printjob info
2733 * @return 0 on success, < 0 on error with errno set:
2734 * - EINVAL fname was NULL or smbc_init not called
2735 * - EACCES ???
2737 int smbc_list_print_jobs(const char *purl, smbc_list_print_job_fn fn);
2739 /**@ingroup print
2740 * Delete a print job
2742 * @param purl Url of the print share
2744 * @param id The id of the job to delete
2746 * @return 0 on success, < 0 on error with errno set:
2747 * - EINVAL fname was NULL or smbc_init not called
2749 * @todo what errno values are possible here?
2751 int smbc_unlink_print_job(const char *purl, int id);
2753 /**@ingroup callback
2754 * Remove a server from the cached server list it's unused.
2756 * @param context pointer to smb context
2758 * @param srv pointer to server to remove
2760 * @return On success, 0 is returned. 1 is returned if the server could not
2761 * be removed. Also useable outside libsmbclient.
2763 int smbc_remove_unused_server(SMBCCTX * context, SMBCSRV * srv);
2765 #ifdef __cplusplus
2767 #endif
2769 /**@ingroup directory
2770 * Convert strings of %xx to their single character equivalent.
2772 * @param dest A pointer to a buffer in which the resulting decoded
2773 * string should be placed. This may be a pointer to the
2774 * same buffer as src_segment.
2776 * @param src A pointer to the buffer containing the URL to be decoded.
2777 * Any %xx sequences herein are converted to their single
2778 * character equivalent. Each 'x' must be a valid hexadecimal
2779 * digit, or that % sequence is left undecoded.
2781 * @param max_dest_len
2782 * The size of the buffer pointed to by dest_segment.
2784 * @return The number of % sequences which could not be converted
2785 * due to lack of two following hexadecimal digits.
2787 #ifdef __cplusplus
2788 extern "C" {
2789 #endif
2791 smbc_urldecode(char *dest, char * src, size_t max_dest_len);
2792 #ifdef __cplusplus
2794 #endif
2798 * Convert any characters not specifically allowed in a URL into their %xx
2799 * equivalent.
2801 * @param dest A pointer to a buffer in which the resulting encoded
2802 * string should be placed. Unlike smbc_urldecode(), this
2803 * must be a buffer unique from src.
2805 * @param src A pointer to the buffer containing the string to be encoded.
2806 * Any character not specifically allowed in a URL is converted
2807 * into its hexadecimal value and encoded as %xx.
2809 * @param max_dest_len
2810 * The size of the buffer pointed to by dest_segment.
2812 * @returns The remaining buffer length.
2814 #ifdef __cplusplus
2815 extern "C" {
2816 #endif
2818 smbc_urlencode(char * dest, char * src, int max_dest_len);
2819 #ifdef __cplusplus
2821 #endif
2824 /**@ingroup directory
2825 * Return the version of the linked Samba code, and thus the version of the
2826 * libsmbclient code.
2828 * @return The version string.
2830 #ifdef __cplusplus
2831 extern "C" {
2832 #endif
2833 const char *
2834 smbc_version(void);
2835 #ifdef __cplusplus
2837 #endif
2839 /**@ingroup misc
2840 * Set the users credentials globally so they can be used for DFS
2841 * referrals. Probably best to use this function in the smbc_get_auth_data_fn
2842 * callback.
2844 * @param workgroup Workgroup of the user.
2846 * @param user Username of user.
2848 * @param password Password of user.
2850 * @param use_kerberos Whether to use Kerberos
2852 * @param signing_state One of these strings (all equivalents on same line):
2853 * "off", "no", "false"
2854 * "on", "yes", "true", "auto"
2855 * "force", "required", "forced"
2858 void
2859 smbc_set_credentials(const char *workgroup,
2860 const char *user,
2861 const char *password,
2862 smbc_bool use_kerberos,
2863 const char *signing_state);
2866 * Wrapper around smbc_set_credentials.
2867 * Used to set correct credentials that will
2868 * be used to connect to DFS target share
2869 * in libsmbclient
2872 void
2873 smbc_set_credentials_with_fallback(SMBCCTX *ctx,
2874 const char *workgroup,
2875 const char *user,
2876 const char *password);
2880 * @ingroup threads
2882 * Initialize for threads using the Posix Threads (pthread)
2883 * implementation. This is a built-in implementation, avoiding the need to
2884 * implement the component functions of the thread interface. If this function
2885 * is used, it is not necessary to call smbc_thread_impl().
2887 * @return {void}
2889 void
2890 smbc_thread_posix(void);
2893 * @ingroup threads
2895 * Initialize for an arbitrary thread implementation. The caller should
2896 * provide, as parameters, pointers to functions to implement the requisite
2897 * low-level thread functionality. A function must be provided for each
2898 * parameter; none may be null.
2900 * If the thread implementation is POSIX Threads (pthreads), then the much
2901 * simpler smbc_thread_pthread() function may be used instead of this one.
2903 * @param create_mutex
2904 * Create a mutex. This function should expect three parameters: lockname,
2905 * pplock, and location. It should create a unique mutex for each unique
2906 * lockname it is provided, and return the mutex identifier in *pplock. The
2907 * location parameter can be used for debugging, as it contains the
2908 * compiler-provided __location__ of the call.
2910 * @param destroy_mutex
2911 * Destroy a mutex. This function should expect two parameters: plock and
2912 * location. It should destroy the mutex associated with the identifier
2913 * plock. The location parameter can be used for debugging, as it contains
2914 * the compiler-provided __location__ of the call.
2916 * @param lock_mutex
2917 * Lock a mutex. This function should expect three parameters: plock,
2918 * lock_type, and location. The mutex aassociated with identifier plock
2919 * should be locked if lock_type is 1, and unlocked if lock_type is 2. The
2920 * location parameter can be used for debugging, as it contains the
2921 * compiler-provided __location__ of the call.
2923 * @param create_tls
2924 * Create thread local storage. This function should expect three
2925 * parameters: keyname, ppkey, and location. It should allocate an
2926 * implementation-specific amount of memory and assign the pointer to that
2927 * allocated memory to *ppkey. The location parameter can be used for
2928 * debugging, as it contains the compiler-provided __location__ of the
2929 * call. This function should return 0 upon success, non-zero upon failure.
2931 * @param destroy_tls
2932 * Destroy thread local storage. This function should expect two parameters:
2933 * ppkey and location. The ppkey parameter points to a variable containing a
2934 * thread local storage key previously provided by the create_tls
2935 * function. The location parameter can be used for debugging, as it
2936 * contains the compiler-provided __location__ of the call.
2938 * @param set_tls
2939 * Set a thread local storage variable's value. This function should expect
2940 * three parameters: pkey, pval, and location. The pkey parameter is a
2941 * thread local storage key previously provided by the create_tls
2942 * function. The (void *) pval parameter contains the value to be placed in
2943 * the thread local storage variable identified by pkey. The location
2944 * parameter can be used for debugging, as it contains the compiler-provided
2945 * __location__ of the call. This function should return 0 upon success;
2946 * non-zero otherwise.
2948 * @param get_tls
2949 * Retrieve a thread local storage variable's value. This function should
2950 * expect two parameters: pkey and location. The pkey parameter is a thread
2951 * local storage key previously provided by the create_tls function, and
2952 * which has previously been used in a call to the set_tls function to
2953 * initialize a thread local storage variable. The location parameter can be
2954 * used for debugging, as it contains the compiler-provided __location__ of
2955 * the call. This function should return the (void *) value stored in the
2956 * variable identified by pkey.
2958 * @return {void}
2960 void
2961 smbc_thread_impl(
2962 /* Mutex functions. */
2963 int (*create_mutex)(const char *lockname,
2964 void **pplock,
2965 const char *location),
2966 void (*destroy_mutex)(void *plock,
2967 const char *location),
2968 int (*lock_mutex)(void *plock,
2969 int lock_type,
2970 const char *location),
2972 /* Thread local storage. */
2973 int (*create_tls)(const char *keyname,
2974 void **ppkey,
2975 const char *location),
2976 void (*destroy_tls)(void **ppkey,
2977 const char *location),
2978 int (*set_tls)(void *pkey,
2979 const void *pval,
2980 const char *location),
2981 void *(*get_tls)(void *pkey,
2982 const char *location)
2988 * @ingroup structure
2989 * Structure that contains a client context information
2990 * This structure is known as SMBCCTX
2992 * DO NOT DIRECTLY MANIPULATE THE CONTEXT STRUCTURE! The data in the context
2993 * structure should all be considered private to the library. It remains here
2994 * only for backward compatibility.
2996 * See the comments herein for use of the setter and getter functions which
2997 * should now be used for manipulating these values. New features, functions,
2998 * etc., are not added here but rather in _internal where they are not
2999 * directly visible to applications. This makes it much easier to maintain
3000 * ABI compatibility.
3002 struct _SMBCCTX
3005 * debug level
3007 * DEPRECATED:
3008 * Use smbc_getDebug() and smbc_setDebug()
3010 int debug DEPRECATED_SMBC_INTERFACE;
3013 * netbios name used for making connections
3015 * DEPRECATED:
3016 * Use smbc_getNetbiosName() and smbc_setNetbiosName()
3018 char * netbios_name DEPRECATED_SMBC_INTERFACE;
3021 * workgroup name used for making connections
3023 * DEPRECATED:
3024 * Use smbc_getWorkgroup() and smbc_setWorkgroup()
3026 char * workgroup DEPRECATED_SMBC_INTERFACE;
3029 * username used for making connections
3031 * DEPRECATED:
3032 * Use smbc_getUser() and smbc_setUser()
3034 char * user DEPRECATED_SMBC_INTERFACE;
3037 * timeout used for waiting on connections / response data (in
3038 * milliseconds)
3040 * DEPRECATED:
3041 * Use smbc_getTimeout() and smbc_setTimeout()
3043 int timeout DEPRECATED_SMBC_INTERFACE;
3046 * callable functions for files:
3047 * For usage and return values see the SMBC_* functions
3049 * DEPRECATED:
3051 * Use smbc_getFunction*() and smbc_setFunction*(), e.g.
3052 * smbc_getFunctionOpen(), smbc_setFunctionUnlink(), etc.
3054 smbc_open_fn open DEPRECATED_SMBC_INTERFACE;
3055 smbc_creat_fn creat DEPRECATED_SMBC_INTERFACE;
3056 smbc_read_fn read DEPRECATED_SMBC_INTERFACE;
3057 smbc_write_fn write DEPRECATED_SMBC_INTERFACE;
3058 smbc_unlink_fn unlink DEPRECATED_SMBC_INTERFACE;
3059 smbc_rename_fn rename DEPRECATED_SMBC_INTERFACE;
3060 smbc_lseek_fn lseek DEPRECATED_SMBC_INTERFACE;
3061 smbc_stat_fn stat DEPRECATED_SMBC_INTERFACE;
3062 smbc_fstat_fn fstat DEPRECATED_SMBC_INTERFACE;
3063 #if 0 /* internal */
3064 smbc_ftruncate_fn ftruncate_fn;
3065 #endif
3066 smbc_close_fn close_fn DEPRECATED_SMBC_INTERFACE;
3067 smbc_opendir_fn opendir DEPRECATED_SMBC_INTERFACE;
3068 smbc_closedir_fn closedir DEPRECATED_SMBC_INTERFACE;
3069 smbc_readdir_fn readdir DEPRECATED_SMBC_INTERFACE;
3070 smbc_getdents_fn getdents DEPRECATED_SMBC_INTERFACE;
3071 smbc_mkdir_fn mkdir DEPRECATED_SMBC_INTERFACE;
3072 smbc_rmdir_fn rmdir DEPRECATED_SMBC_INTERFACE;
3073 smbc_telldir_fn telldir DEPRECATED_SMBC_INTERFACE;
3074 smbc_lseekdir_fn lseekdir DEPRECATED_SMBC_INTERFACE;
3075 smbc_fstatdir_fn fstatdir DEPRECATED_SMBC_INTERFACE;
3076 smbc_chmod_fn chmod DEPRECATED_SMBC_INTERFACE;
3077 smbc_utimes_fn utimes DEPRECATED_SMBC_INTERFACE;
3078 smbc_setxattr_fn setxattr DEPRECATED_SMBC_INTERFACE;
3079 smbc_getxattr_fn getxattr DEPRECATED_SMBC_INTERFACE;
3080 smbc_removexattr_fn removexattr DEPRECATED_SMBC_INTERFACE;
3081 smbc_listxattr_fn listxattr DEPRECATED_SMBC_INTERFACE;
3083 /* Printing-related functions */
3084 smbc_print_file_fn print_file DEPRECATED_SMBC_INTERFACE;
3085 smbc_open_print_job_fn open_print_job DEPRECATED_SMBC_INTERFACE;
3086 smbc_list_print_jobs_fn list_print_jobs DEPRECATED_SMBC_INTERFACE;
3087 smbc_unlink_print_job_fn unlink_print_job DEPRECATED_SMBC_INTERFACE;
3090 ** Callbacks
3092 * DEPRECATED:
3094 * See the comment above each field, for the getter and setter
3095 * functions that should now be used.
3097 struct _smbc_callbacks
3100 * authentication function callback: called upon auth requests
3102 * DEPRECATED:
3103 * Use smbc_getFunctionAuthData(), smbc_setFunctionAuthData()
3105 smbc_get_auth_data_fn auth_fn DEPRECATED_SMBC_INTERFACE;
3108 * check if a server is still good
3110 * DEPRECATED:
3111 * Use smbc_getFunctionCheckServer(),
3112 * smbc_setFunctionCheckServer()
3114 smbc_check_server_fn check_server_fn DEPRECATED_SMBC_INTERFACE;
3117 * remove a server if unused
3119 * DEPRECATED:
3120 * Use smbc_getFunctionRemoveUnusedServer(),
3121 * smbc_setFunctionCheckServer()
3123 smbc_remove_unused_server_fn remove_unused_server_fn DEPRECATED_SMBC_INTERFACE;
3125 /** Cache subsystem
3127 * For an example cache system see
3128 * samba/source/libsmb/libsmb_cache.c
3130 * Cache subsystem * functions follow.
3134 * server cache addition
3136 * DEPRECATED:
3137 * Use smbc_getFunctionAddCachedServer(),
3138 * smbc_setFunctionAddCachedServer()
3140 smbc_add_cached_srv_fn add_cached_srv_fn DEPRECATED_SMBC_INTERFACE;
3143 * server cache lookup
3145 * DEPRECATED:
3146 * Use smbc_getFunctionGetCachedServer(),
3147 * smbc_setFunctionGetCachedServer()
3149 smbc_get_cached_srv_fn get_cached_srv_fn DEPRECATED_SMBC_INTERFACE;
3152 * server cache removal
3154 * DEPRECATED:
3155 * Use smbc_getFunctionRemoveCachedServer(),
3156 * smbc_setFunctionRemoveCachedServer()
3158 smbc_remove_cached_srv_fn remove_cached_srv_fn DEPRECATED_SMBC_INTERFACE;
3161 * server cache purging, try to remove all cached servers
3162 * (disconnect)
3164 * DEPRECATED:
3165 * Use smbc_getFunctionPurgeCachedServers(),
3166 * smbc_setFunctionPurgeCachedServers()
3168 smbc_purge_cached_fn purge_cached_fn DEPRECATED_SMBC_INTERFACE;
3169 } callbacks;
3172 * Space where the private data of the server cache used to be
3174 * DEPRECATED:
3175 * Use smbc_getServerCacheData(), smbc_setServerCacheData()
3177 void * reserved DEPRECATED_SMBC_INTERFACE;
3180 * Very old configuration options.
3182 * DEPRECATED:
3183 * Use one of the following functions instead:
3184 * smbc_setOptionUseKerberos()
3185 * smbc_getOptionUseKerberos()
3186 * smbc_setOptionFallbackAfterKerberos()
3187 * smbc_getOptionFallbackAfterKerberos()
3188 * smbc_setOptionNoAutoAnonymousLogin()
3189 * smbc_getOptionNoAutoAnonymousLogin()
3191 int flags DEPRECATED_SMBC_INTERFACE;
3194 * user options selections that apply to this session
3196 * NEW OPTIONS ARE NOT ADDED HERE!
3198 * DEPRECATED:
3199 * To set and retrieve options, use the smbc_setOption*() and
3200 * smbc_getOption*() functions.
3202 struct _smbc_options {
3203 int browse_max_lmb_count DEPRECATED_SMBC_INTERFACE;
3204 int urlencode_readdir_entries DEPRECATED_SMBC_INTERFACE;
3205 int one_share_per_server DEPRECATED_SMBC_INTERFACE;
3206 } options DEPRECATED_SMBC_INTERFACE;
3208 /** INTERNAL DATA
3209 * do _NOT_ touch this from your program !
3211 struct SMBC_internal_data * internal;
3215 #endif /* SMBCLIENT_H_INCLUDED */