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