docs-xml: "cluster addresses" dns registration
[Samba.git] / source3 / include / libsmbclient.h
blobb045221f12b685e6ca38f049470e9570a349637f
1 /*=====================================================================
2 Unix SMB/Netbios implementation.
3 SMB client library API definitions
4 Copyright (C) Andrew Tridgell 1998
5 Copyright (C) Richard Sharpe 2000
6 Copyright (C) John Terpsra 2000
7 Copyright (C) Tom Jansen (Ninja ISD) 2002
8 Copyright (C) Derrell Lipman 2003-2008
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 3 of the License, or
14 (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, see <http://www.gnu.org/licenses/>.
23 =====================================================================*/
25 #ifndef SMBCLIENT_H_INCLUDED
26 #define SMBCLIENT_H_INCLUDED
28 #undef DEPRECATED_SMBC_INTERFACE
29 #if ! defined(__LIBSMBCLIENT_INTERNAL__) && defined(__GNUC__)
30 # define DEPRECATED_SMBC_INTERFACE __attribute__ ((deprecated))
31 #else
32 # define DEPRECATED_SMBC_INTERFACE
33 #endif
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
39 /*-------------------------------------------------------------------*/
40 /* The following are special comments to instruct DOXYGEN (automated
41 * documentation tool:
43 /** \defgroup libsmbclient
45 /** \defgroup structure Data Structures Type and Constants
46 * \ingroup libsmbclient
47 * Data structures, types, and constants
49 /** \defgroup callback Callback function types
50 * \ingroup libsmbclient
51 * Callback functions
53 /** \defgroup file File Functions
54 * \ingroup libsmbclient
55 * Functions used to access individual file contents
57 /** \defgroup directory Directory Functions
58 * \ingroup libsmbclient
59 * Functions used to access directory entries
61 /** \defgroup attribute Attributes Functions
62 * \ingroup libsmbclient
63 * Functions used to view or change file and directory attributes
65 /** \defgroup print Print Functions
66 * \ingroup libsmbclient
67 * Functions used to access printing functionality
69 /** \defgroup misc Miscellaneous Functions
70 * \ingroup libsmbclient
71 * Functions that don't fit in to other categories
73 /*-------------------------------------------------------------------*/
75 /* Make sure we have the following includes for now ... */
76 #include <sys/types.h>
77 #include <sys/stat.h>
78 #include <sys/statvfs.h>
79 #include <stdint.h>
80 #include <fcntl.h>
81 #include <utime.h>
83 #define SMBC_BASE_FD 10000 /* smallest file descriptor returned */
85 #define SMBC_WORKGROUP 1
86 #define SMBC_SERVER 2
87 #define SMBC_FILE_SHARE 3
88 #define SMBC_PRINTER_SHARE 4
89 #define SMBC_COMMS_SHARE 5
90 #define SMBC_IPC_SHARE 6
91 #define SMBC_DIR 7
92 #define SMBC_FILE 8
93 #define SMBC_LINK 9
95 /**@ingroup structure
96 * Structure that represents a directory entry.
99 struct smbc_dirent
101 /** Type of entity.
102 SMBC_WORKGROUP=1,
103 SMBC_SERVER=2,
104 SMBC_FILE_SHARE=3,
105 SMBC_PRINTER_SHARE=4,
106 SMBC_COMMS_SHARE=5,
107 SMBC_IPC_SHARE=6,
108 SMBC_DIR=7,
109 SMBC_FILE=8,
110 SMBC_LINK=9,*/
111 unsigned int smbc_type;
113 /** Length of this smbc_dirent in bytes
115 unsigned int dirlen;
116 /** The length of the comment string in bytes (does not include
117 * null terminator)
119 unsigned int commentlen;
120 /** Points to the null terminated comment string
122 char *comment;
123 /** The length of the name string in bytes (does not include
124 * null terminator)
126 unsigned int namelen;
127 /** Points to the null terminated name string
129 char name[1];
132 /**@ingroup structure
133 * Structure that represents all attributes of a directory entry.
136 struct libsmb_file_info
139 * Size of file
141 uint64_t size;
143 * DOS attributes of file
145 uint16_t attrs;
147 * User ID of file
149 uid_t uid;
151 * Group ID of file
153 gid_t gid;
155 * Birth/Create time of file (if supported by system)
156 * Otherwise the value will be 0
158 struct timespec btime_ts;
160 * Modified time for the file
162 struct timespec mtime_ts;
164 * Access time for the file
166 struct timespec atime_ts;
168 * Change time for the file
170 struct timespec ctime_ts;
172 * Name of file
174 char *name;
176 * Short name of file
178 char *short_name;
182 * Logging callback function
184 typedef void (*smbc_debug_callback_fn)(void *private_ptr, int level, const char *msg);
187 * Flags for smbc_setxattr()
188 * Specify a bitwise OR of these, or 0 to add or replace as necessary
190 #define SMBC_XATTR_FLAG_CREATE 0x1 /* fail if attr already exists */
191 #define SMBC_XATTR_FLAG_REPLACE 0x2 /* fail if attr does not exist */
195 * Mappings of the DOS mode bits, as returned by smbc_getxattr() when the
196 * attribute name "system.dos_attr.mode" (or "system.dos_attr.*" or
197 * "system.*") is specified.
199 #define SMBC_DOS_MODE_READONLY 0x01
200 #define SMBC_DOS_MODE_HIDDEN 0x02
201 #define SMBC_DOS_MODE_SYSTEM 0x04
202 #define SMBC_DOS_MODE_VOLUME_ID 0x08
203 #define SMBC_DOS_MODE_DIRECTORY 0x10
204 #define SMBC_DOS_MODE_ARCHIVE 0x20
207 * Valid values for the option "open_share_mode", when calling
208 * smbc_setOptionOpenShareMode()
210 typedef enum smbc_share_mode
212 SMBC_SHAREMODE_DENY_DOS = 0,
213 SMBC_SHAREMODE_DENY_ALL = 1,
214 SMBC_SHAREMODE_DENY_WRITE = 2,
215 SMBC_SHAREMODE_DENY_READ = 3,
216 SMBC_SHAREMODE_DENY_NONE = 4,
217 SMBC_SHAREMODE_DENY_FCB = 7
218 } smbc_share_mode;
222 * Values for option SMB Encryption Level, as set and retrieved with
223 * smbc_setOptionSmbEncryptionLevel() and smbc_getOptionSmbEncryptionLevel()
225 typedef enum smbc_smb_encrypt_level
227 SMBC_ENCRYPTLEVEL_NONE = 0,
228 SMBC_ENCRYPTLEVEL_REQUEST = 1,
229 SMBC_ENCRYPTLEVEL_REQUIRE = 2
230 } smbc_smb_encrypt_level;
234 * Capabilities set in the f_flag field of struct statvfs, from
235 * smbc_statvfs(). These may be OR-ed together to reflect a full set of
236 * available capabilities.
238 typedef enum smbc_vfs_feature
240 /* Defined by POSIX or in Linux include files (low-order bits) */
241 SMBC_VFS_FEATURE_RDONLY = (1 << 0),
243 /* Specific to libsmbclient (high-order bits) */
244 SMBC_VFS_FEATURE_DFS = (1 << 28),
245 SMBC_VFS_FEATURE_CASE_INSENSITIVE = (1 << 29),
246 SMBC_VFS_FEATURE_NO_UNIXCIFS = (1 << 30)
247 } smbc_vfs_feature;
249 typedef int smbc_bool;
252 #ifndef ENOATTR
253 # define ENOATTR ENOENT /* No such attribute */
254 #endif
259 /**@ingroup structure
260 * Structure that represents a print job.
263 #ifndef _CLIENT_H
264 struct print_job_info
266 /** numeric ID of the print job
268 unsigned short id;
270 /** represents print job priority (lower numbers mean higher priority)
272 unsigned short priority;
274 /** Size of the print job
276 size_t size;
278 /** Name of the user that owns the print job
280 char user[128];
282 /** Name of the print job. This will have no name if an anonymous print
283 * file was opened. Ie smb://server/printer
285 char name[128];
287 /** Time the print job was spooled
289 time_t t;
291 #endif /* _CLIENT_H */
294 /**@ingroup structure
295 * Server handle
297 typedef struct _SMBCSRV SMBCSRV;
299 /**@ingroup structure
300 * File or directory handle
302 typedef struct _SMBCFILE SMBCFILE;
304 /**@ingroup structure
305 * File or directory handle
307 typedef struct _SMBCCTX SMBCCTX;
311 * Flags for SMBCCTX->flags
313 * NEW CODE SHOULD NOT DIRECTLY MANIPULATE THE CONTEXT STRUCTURE.
314 * Instead, use:
315 * smbc_setOptionUseKerberos()
316 * smbc_getOptionUseKerberos()
317 * smbc_setOptionFallbackAfterKerberos()
318 * smbc_getOptionFallbackAFterKerberos()
319 * smbc_setOptionNoAutoAnonymousLogin()
320 * smbc_getOptionNoAutoAnonymousLogin()
321 * smbc_setOptionUseCCache()
322 * smbc_getOptionUseCCache()
324 # define SMB_CTX_FLAG_USE_KERBEROS (1 << 0)
325 # define SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS (1 << 1)
326 # define SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON (1 << 2)
327 # define SMB_CTX_FLAG_USE_CCACHE (1 << 3)
331 /**@ingroup callback
332 * Authentication callback function type (traditional method)
334 * Type for the the authentication function called by the library to
335 * obtain authentication credentials
337 * For kerberos support the function should just be called without
338 * prompting the user for credentials. Which means a simple 'return'
339 * should work. Take a look at examples/libsmbclient/get_auth_data_fn.h
340 * and examples/libsmbclient/testbrowse.c.
342 * @param srv Server being authenticated to
344 * @param shr Share being authenticated to
346 * @param wg Pointer to buffer containing a "hint" for the
347 * workgroup to be authenticated. Should be filled in
348 * with the correct workgroup if the hint is wrong.
350 * @param wglen The size of the workgroup buffer in bytes
352 * @param un Pointer to buffer containing a "hint" for the
353 * user name to be use for authentication. Should be
354 * filled in with the correct workgroup if the hint is
355 * wrong.
357 * @param unlen The size of the username buffer in bytes
359 * @param pw Pointer to buffer containing to which password
360 * copied
362 * @param pwlen The size of the password buffer in bytes
365 typedef void (*smbc_get_auth_data_fn)(const char *srv,
366 const char *shr,
367 char *wg, int wglen,
368 char *un, int unlen,
369 char *pw, int pwlen);
370 /**@ingroup callback
371 * Authentication callback function type (method that includes context)
373 * Type for the the authentication function called by the library to
374 * obtain authentication credentials
376 * For kerberos support the function should just be called without
377 * prompting the user for credentials. Which means a simple 'return'
378 * should work. Take a look at examples/libsmbclient/get_auth_data_fn.h
379 * and examples/libsmbclient/testbrowse.c.
381 * @param c Pointer to the smb context
383 * @param srv Server being authenticated to
385 * @param shr Share being authenticated to
387 * @param wg Pointer to buffer containing a "hint" for the
388 * workgroup to be authenticated. Should be filled in
389 * with the correct workgroup if the hint is wrong.
391 * @param wglen The size of the workgroup buffer in bytes
393 * @param un Pointer to buffer containing a "hint" for the
394 * user name to be use for authentication. Should be
395 * filled in with the correct workgroup if the hint is
396 * wrong.
398 * @param unlen The size of the username buffer in bytes
400 * @param pw Pointer to buffer containing to which password
401 * copied
403 * @param pwlen The size of the password buffer in bytes
406 typedef void (*smbc_get_auth_data_with_context_fn)(SMBCCTX *c,
407 const char *srv,
408 const char *shr,
409 char *wg, int wglen,
410 char *un, int unlen,
411 char *pw, int pwlen);
414 /**@ingroup callback
415 * Print job info callback function type.
417 * @param i pointer to print job information structure
420 typedef void (*smbc_list_print_job_fn)(struct print_job_info *i);
423 /**@ingroup callback
424 * Check if a server is still good
426 * @param c pointer to smb context
428 * @param srv pointer to server to check
430 * @return 0 when connection is good. 1 on error.
433 typedef int (*smbc_check_server_fn)(SMBCCTX * c, SMBCSRV *srv);
435 /**@ingroup callback
436 * Remove a server if unused
438 * @param c pointer to smb context
440 * @param srv pointer to server to remove
442 * @return 0 on success. 1 on failure.
445 typedef int (*smbc_remove_unused_server_fn)(SMBCCTX * c, SMBCSRV *srv);
448 /**@ingroup callback
449 * Add a server to the cache system
451 * @param c pointer to smb context
453 * @param srv pointer to server to add
455 * @param server server name
457 * @param share share name
459 * @param workgroup workgroup used to connect
461 * @param username username used to connect
463 * @return 0 on success. 1 on failure.
466 typedef int (*smbc_add_cached_srv_fn) (SMBCCTX * c, SMBCSRV *srv,
467 const char * server, const char * share,
468 const char * workgroup, const char * username);
470 /**@ingroup callback
471 * Look up a server in the cache system
473 * @param c pointer to smb context
475 * @param server server name to match
477 * @param share share name to match
479 * @param workgroup workgroup to match
481 * @param username username to match
483 * @return pointer to SMBCSRV on success. NULL on failure.
486 typedef SMBCSRV * (*smbc_get_cached_srv_fn) (SMBCCTX * c, const char * server,
487 const char * share, const char * workgroup,
488 const char * username);
490 /**@ingroup callback
491 * Check if a server is still good
493 * @param c pointer to smb context
495 * @param srv pointer to server to remove
497 * @return 0 when found and removed. 1 on failure.
500 typedef int (*smbc_remove_cached_srv_fn)(SMBCCTX * c, SMBCSRV *srv);
503 /**@ingroup callback
504 * Try to remove all servers from the cache system and disconnect
506 * @param c pointer to smb context
508 * @return 0 when found and removed. 1 on failure.
511 typedef int (*smbc_purge_cached_fn) (SMBCCTX * c);
515 /*****************************************
516 * Getters and setters for CONFIGURATION *
517 *****************************************/
519 /** Get the debug level */
521 smbc_getDebug(SMBCCTX *c);
523 /** Set the debug level */
524 void
525 smbc_setDebug(SMBCCTX *c, int debug);
528 * set log callback function to capture logs from libsmbclient, this
529 * is applied at global level
531 void
532 smbc_setLogCallback(SMBCCTX *c, void *private_ptr,
533 smbc_debug_callback_fn fn);
535 /** set configuration file, this is applied at global level */
537 smbc_setConfiguration(SMBCCTX *c, const char *file);
539 /** Get the netbios name used for making connections */
540 const char *
541 smbc_getNetbiosName(SMBCCTX *c);
543 /** Set the netbios name used for making connections */
544 void
545 smbc_setNetbiosName(SMBCCTX *c, const char *netbios_name);
547 /** Get the workgroup used for making connections */
548 const char *
549 smbc_getWorkgroup(SMBCCTX *c);
551 /** Set the workgroup used for making connections */
552 void smbc_setWorkgroup(SMBCCTX *c, const char *workgroup);
554 /** Get the username used for making connections */
555 const char *
556 smbc_getUser(SMBCCTX *c);
558 /** Set the username used for making connections */
559 void
560 smbc_setUser(SMBCCTX *c, const char *user);
563 * Get the timeout used for waiting on connections and response data
564 * (in milliseconds)
567 smbc_getTimeout(SMBCCTX *c);
570 * Set the timeout used for waiting on connections and response data
571 * (in milliseconds)
573 void
574 smbc_setTimeout(SMBCCTX *c, int timeout);
578 * Get the TCP port used to connect (0 means default).
580 uint16_t
581 smbc_getPort(SMBCCTX *c);
584 * Set the TCP port used to connect (0 means default).
586 void
587 smbc_setPort(SMBCCTX *c, uint16_t port);
591 /***********************************
592 * Getters and setters for OPTIONS *
593 ***********************************/
595 /** Get whether to log to standard error instead of standard output */
596 smbc_bool
597 smbc_getOptionDebugToStderr(SMBCCTX *c);
599 /** Set whether to log to standard error instead of standard output */
600 void
601 smbc_setOptionDebugToStderr(SMBCCTX *c, smbc_bool b);
604 * Get whether to use new-style time attribute names, e.g. WRITE_TIME rather
605 * than the old-style names such as M_TIME. This allows also setting/getting
606 * CREATE_TIME which was previously unimplemented. (Note that the old C_TIME
607 * was supposed to be CHANGE_TIME but was confused and sometimes referred to
608 * CREATE_TIME.)
610 smbc_bool
611 smbc_getOptionFullTimeNames(SMBCCTX *c);
614 * Set whether to use new-style time attribute names, e.g. WRITE_TIME rather
615 * than the old-style names such as M_TIME. This allows also setting/getting
616 * CREATE_TIME which was previously unimplemented. (Note that the old C_TIME
617 * was supposed to be CHANGE_TIME but was confused and sometimes referred to
618 * CREATE_TIME.)
620 void
621 smbc_setOptionFullTimeNames(SMBCCTX *c, smbc_bool b);
624 * Get the share mode to use for files opened with SMBC_open_ctx(). The
625 * default is SMBC_SHAREMODE_DENY_NONE.
627 smbc_share_mode
628 smbc_getOptionOpenShareMode(SMBCCTX *c);
631 * Set the share mode to use for files opened with SMBC_open_ctx(). The
632 * default is SMBC_SHAREMODE_DENY_NONE.
634 void
635 smbc_setOptionOpenShareMode(SMBCCTX *c, smbc_share_mode share_mode);
637 /** Retrieve a previously saved user data handle */
638 void *
639 smbc_getOptionUserData(SMBCCTX *c);
641 /** Save a user data handle */
642 void
643 smbc_setOptionUserData(SMBCCTX *c, void *user_data);
645 /** Get the encoded value for encryption level. */
646 smbc_smb_encrypt_level
647 smbc_getOptionSmbEncryptionLevel(SMBCCTX *c);
649 /** Set the encoded value for encryption level. */
650 void
651 smbc_setOptionSmbEncryptionLevel(SMBCCTX *c, smbc_smb_encrypt_level level);
654 * Get whether to treat file names as case-sensitive if we can't determine
655 * when connecting to the remote share whether the file system is case
656 * sensitive. This defaults to FALSE since it's most likely that if we can't
657 * retrieve the file system attributes, it's a very old file system that does
658 * not support case sensitivity.
660 smbc_bool
661 smbc_getOptionCaseSensitive(SMBCCTX *c);
664 * Set whether to treat file names as case-sensitive if we can't determine
665 * when connecting to the remote share whether the file system is case
666 * sensitive. This defaults to FALSE since it's most likely that if we can't
667 * retrieve the file system attributes, it's a very old file system that does
668 * not support case sensitivity.
670 void
671 smbc_setOptionCaseSensitive(SMBCCTX *c, smbc_bool b);
675 * Get from how many local master browsers should the list of workgroups be
676 * retrieved. It can take up to 12 minutes or longer after a server becomes a
677 * local master browser, for it to have the entire browse list (the list of
678 * workgroups/domains) from an entire network. Since a client never knows
679 * which local master browser will be found first, the one which is found
680 * first and used to retrieve a browse list may have an incomplete or empty
681 * browse list. By requesting the browse list from multiple local master
682 * browsers, a more complete list can be generated. For small networks (few
683 * workgroups), it is recommended that this value be set to 0, causing the
684 * browse lists from all found local master browsers to be retrieved and
685 * merged. For networks with many workgroups, a suitable value for this
686 * variable is probably somewhere around 3. (Default: 3).
689 smbc_getOptionBrowseMaxLmbCount(SMBCCTX *c);
692 * Set from how many local master browsers should the list of workgroups be
693 * retrieved. It can take up to 12 minutes or longer after a server becomes a
694 * local master browser, for it to have the entire browse list (the list of
695 * workgroups/domains) from an entire network. Since a client never knows
696 * which local master browser will be found first, the one which is found
697 * first and used to retrieve a browse list may have an incomplete or empty
698 * browse list. By requesting the browse list from multiple local master
699 * browsers, a more complete list can be generated. For small networks (few
700 * workgroups), it is recommended that this value be set to 0, causing the
701 * browse lists from all found local master browsers to be retrieved and
702 * merged. For networks with many workgroups, a suitable value for this
703 * variable is probably somewhere around 3. (Default: 3).
705 void
706 smbc_setOptionBrowseMaxLmbCount(SMBCCTX *c, int count);
709 * Get whether to url-encode readdir entries.
711 * There is a difference in the desired return strings from
712 * smbc_readdir() depending upon whether the filenames are to
713 * be displayed to the user, or whether they are to be
714 * appended to the path name passed to smbc_opendir() to call
715 * a further smbc_ function (e.g. open the file with
716 * smbc_open()). In the former case, the filename should be
717 * in "human readable" form. In the latter case, the smbc_
718 * functions expect a URL which must be url-encoded. Those
719 * functions decode the URL. If, for example, smbc_readdir()
720 * returned a file name of "abc%20def.txt", passing a path
721 * with this file name attached to smbc_open() would cause
722 * smbc_open to attempt to open the file "abc def.txt" since
723 * the %20 is decoded into a space.
725 * Set this option to True if the names returned by
726 * smbc_readdir() should be url-encoded such that they can be
727 * passed back to another smbc_ call. Set it to False if the
728 * names returned by smbc_readdir() are to be presented to the
729 * user.
731 * For backwards compatibility, this option defaults to False.
733 smbc_bool
734 smbc_getOptionUrlEncodeReaddirEntries(SMBCCTX *c);
737 * Set whether to url-encode readdir entries.
739 * There is a difference in the desired return strings from
740 * smbc_readdir() depending upon whether the filenames are to
741 * be displayed to the user, or whether they are to be
742 * appended to the path name passed to smbc_opendir() to call
743 * a further smbc_ function (e.g. open the file with
744 * smbc_open()). In the former case, the filename should be
745 * in "human readable" form. In the latter case, the smbc_
746 * functions expect a URL which must be url-encoded. Those
747 * functions decode the URL. If, for example, smbc_readdir()
748 * returned a file name of "abc%20def.txt", passing a path
749 * with this file name attached to smbc_open() would cause
750 * smbc_open to attempt to open the file "abc def.txt" since
751 * the %20 is decoded into a space.
753 * Set this option to True if the names returned by
754 * smbc_readdir() should be url-encoded such that they can be
755 * passed back to another smbc_ call. Set it to False if the
756 * names returned by smbc_readdir() are to be presented to the
757 * user.
759 * For backwards compatibility, this option defaults to False.
761 void
762 smbc_setOptionUrlEncodeReaddirEntries(SMBCCTX *c, smbc_bool b);
765 * Get whether to use the same connection for all shares on a server.
767 * Some Windows versions appear to have a limit to the number
768 * of concurrent SESSIONs and/or TREE CONNECTions. In
769 * one-shot programs (i.e. the program runs and then quickly
770 * ends, thereby shutting down all connections), it is
771 * probably reasonable to establish a new connection for each
772 * share. In long-running applications, the limitation can be
773 * avoided by using only a single connection to each server,
774 * and issuing a new TREE CONNECT when the share is accessed.
776 smbc_bool
777 smbc_getOptionOneSharePerServer(SMBCCTX *c);
780 * Set whether to use the same connection for all shares on a server.
782 * Some Windows versions appear to have a limit to the number
783 * of concurrent SESSIONs and/or TREE CONNECTions. In
784 * one-shot programs (i.e. the program runs and then quickly
785 * ends, thereby shutting down all connections), it is
786 * probably reasonable to establish a new connection for each
787 * share. In long-running applications, the limitation can be
788 * avoided by using only a single connection to each server,
789 * and issuing a new TREE CONNECT when the share is accessed.
791 void
792 smbc_setOptionOneSharePerServer(SMBCCTX *c, smbc_bool b);
794 /** Get whether to enable use of kerberos */
795 smbc_bool
796 smbc_getOptionUseKerberos(SMBCCTX *c);
798 /** Set whether to enable use of kerberos */
799 void
800 smbc_setOptionUseKerberos(SMBCCTX *c, smbc_bool b);
802 /** Get whether to fallback after kerberos */
803 smbc_bool
804 smbc_getOptionFallbackAfterKerberos(SMBCCTX *c);
806 /** Set whether to fallback after kerberos */
807 void
808 smbc_setOptionFallbackAfterKerberos(SMBCCTX *c, smbc_bool b);
810 /** Get whether to automatically select anonymous login */
811 smbc_bool
812 smbc_getOptionNoAutoAnonymousLogin(SMBCCTX *c);
814 /** Set whether to automatically select anonymous login */
815 void
816 smbc_setOptionNoAutoAnonymousLogin(SMBCCTX *c, smbc_bool b);
818 /** Get whether to enable use of the winbind ccache */
819 smbc_bool
820 smbc_getOptionUseCCache(SMBCCTX *c);
822 /** Set whether to enable use of the winbind ccache */
823 void
824 smbc_setOptionUseCCache(SMBCCTX *c, smbc_bool b);
826 /** Get indication that the password supplied is the NT hash */
827 smbc_bool
828 smbc_getOptionUseNTHash(SMBCCTX *c);
830 /** Set indication that the password supplied is the NT hash */
831 void
832 smbc_setOptionUseNTHash(SMBCCTX *c, smbc_bool b);
835 * @brief Set the 'client min protocol' and the 'client max protocol'.
837 * IMPORTANT: This overrrides the values 'client min protocol' and 'client max
838 * protocol' set in the smb.conf file!
840 * @param[in] c The smbc context to use.
842 * @param[in] min_proto The minimal protocol to use or NULL for leaving it
843 * untouched.
845 * @param[in] max_proto The maximum protocol to use or NULL for leaving it
846 * untouched.
848 * @returns true for success, false otherwise
850 smbc_bool
851 smbc_setOptionProtocols(SMBCCTX *c, const char *min_proto, const char *max_proto);
853 /*************************************
854 * Getters and setters for FUNCTIONS *
855 *************************************/
857 /** Get the function for obtaining authentication data */
858 smbc_get_auth_data_fn smbc_getFunctionAuthData(SMBCCTX *c);
860 /** Set the function for obtaining authentication data */
861 void smbc_setFunctionAuthData(SMBCCTX *c, smbc_get_auth_data_fn fn);
863 /** Get the new-style authentication function which includes the context. */
864 smbc_get_auth_data_with_context_fn
865 smbc_getFunctionAuthDataWithContext(SMBCCTX *c);
867 /** Set the new-style authentication function which includes the context. */
868 void
869 smbc_setFunctionAuthDataWithContext(SMBCCTX *c,
870 smbc_get_auth_data_with_context_fn fn);
872 /** Get the function for checking if a server is still good */
873 smbc_check_server_fn smbc_getFunctionCheckServer(SMBCCTX *c);
875 /** Set the function for checking if a server is still good */
876 void smbc_setFunctionCheckServer(SMBCCTX *c, smbc_check_server_fn fn);
878 /** Get the function for removing a server if unused */
879 smbc_remove_unused_server_fn smbc_getFunctionRemoveUnusedServer(SMBCCTX *c);
881 /** Set the function for removing a server if unused */
882 void smbc_setFunctionRemoveUnusedServer(SMBCCTX *c,
883 smbc_remove_unused_server_fn fn);
885 /** Get the function for adding a cached server */
886 smbc_add_cached_srv_fn smbc_getFunctionAddCachedServer(SMBCCTX *c);
888 /** Set the function for adding a cached server */
889 void smbc_setFunctionAddCachedServer(SMBCCTX *c, smbc_add_cached_srv_fn fn);
891 /** Get the function for server cache lookup */
892 smbc_get_cached_srv_fn smbc_getFunctionGetCachedServer(SMBCCTX *c);
894 /** Set the function for server cache lookup */
895 void smbc_setFunctionGetCachedServer(SMBCCTX *c, smbc_get_cached_srv_fn fn);
897 /** Get the function for server cache removal */
898 smbc_remove_cached_srv_fn smbc_getFunctionRemoveCachedServer(SMBCCTX *c);
900 /** Set the function for server cache removal */
901 void smbc_setFunctionRemoveCachedServer(SMBCCTX *c,
902 smbc_remove_cached_srv_fn fn);
905 * Get the function for server cache purging. This function tries to
906 * remove all cached servers (e.g. on disconnect)
908 smbc_purge_cached_fn smbc_getFunctionPurgeCachedServers(SMBCCTX *c);
911 * Set the function for server cache purging. This function tries to
912 * remove all cached servers (e.g. on disconnect)
914 void smbc_setFunctionPurgeCachedServers(SMBCCTX *c,
915 smbc_purge_cached_fn fn);
917 /** Get the function to store private data of the server cache */
918 struct smbc_server_cache * smbc_getServerCacheData(SMBCCTX *c);
920 /** Set the function to store private data of the server cache */
921 void smbc_setServerCacheData(SMBCCTX *c, struct smbc_server_cache * cache);
925 /*****************************************************************
926 * Callable functions for files. *
927 * Each callable has a function signature typedef, a declaration *
928 * for the getter, and a declaration for the setter. *
929 *****************************************************************/
931 typedef SMBCFILE * (*smbc_open_fn)(SMBCCTX *c,
932 const char *fname,
933 int flags,
934 mode_t mode);
935 smbc_open_fn smbc_getFunctionOpen(SMBCCTX *c);
936 void smbc_setFunctionOpen(SMBCCTX *c, smbc_open_fn fn);
938 typedef SMBCFILE * (*smbc_creat_fn)(SMBCCTX *c,
939 const char *path,
940 mode_t mode);
941 smbc_creat_fn smbc_getFunctionCreat(SMBCCTX *c);
942 void smbc_setFunctionCreat(SMBCCTX *c, smbc_creat_fn);
944 typedef ssize_t (*smbc_read_fn)(SMBCCTX *c,
945 SMBCFILE *file,
946 void *buf,
947 size_t count);
948 smbc_read_fn smbc_getFunctionRead(SMBCCTX *c);
949 void smbc_setFunctionRead(SMBCCTX *c, smbc_read_fn fn);
951 typedef ssize_t (*smbc_write_fn)(SMBCCTX *c,
952 SMBCFILE *file,
953 const void *buf,
954 size_t count);
955 smbc_write_fn smbc_getFunctionWrite(SMBCCTX *c);
956 void smbc_setFunctionWrite(SMBCCTX *c, smbc_write_fn fn);
958 typedef off_t (*smbc_splice_fn)(SMBCCTX *c,
959 SMBCFILE *srcfile,
960 SMBCFILE *dstfile,
961 off_t count,
962 int (*splice_cb)(off_t n, void *priv),
963 void *priv);
964 smbc_splice_fn smbc_getFunctionSplice(SMBCCTX *c);
965 void smbc_setFunctionSplice(SMBCCTX *c, smbc_splice_fn fn);
967 typedef int (*smbc_unlink_fn)(SMBCCTX *c,
968 const char *fname);
969 smbc_unlink_fn smbc_getFunctionUnlink(SMBCCTX *c);
970 void smbc_setFunctionUnlink(SMBCCTX *c, smbc_unlink_fn fn);
972 typedef int (*smbc_rename_fn)(SMBCCTX *ocontext,
973 const char *oname,
974 SMBCCTX *ncontext,
975 const char *nname);
976 smbc_rename_fn smbc_getFunctionRename(SMBCCTX *c);
977 void smbc_setFunctionRename(SMBCCTX *c, smbc_rename_fn fn);
979 typedef off_t (*smbc_lseek_fn)(SMBCCTX *c,
980 SMBCFILE * file,
981 off_t offset,
982 int whence);
983 smbc_lseek_fn smbc_getFunctionLseek(SMBCCTX *c);
984 void smbc_setFunctionLseek(SMBCCTX *c, smbc_lseek_fn fn);
986 typedef int (*smbc_stat_fn)(SMBCCTX *c,
987 const char *fname,
988 struct stat *st);
989 smbc_stat_fn smbc_getFunctionStat(SMBCCTX *c);
990 void smbc_setFunctionStat(SMBCCTX *c, smbc_stat_fn fn);
992 typedef int (*smbc_fstat_fn)(SMBCCTX *c,
993 SMBCFILE *file,
994 struct stat *st);
995 smbc_fstat_fn smbc_getFunctionFstat(SMBCCTX *c);
996 void smbc_setFunctionFstat(SMBCCTX *c, smbc_fstat_fn fn);
998 typedef int (*smbc_statvfs_fn)(SMBCCTX *c,
999 char *path,
1000 struct statvfs *st);
1001 smbc_statvfs_fn smbc_getFunctionStatVFS(SMBCCTX *c);
1002 void smbc_setFunctionStatVFS(SMBCCTX *c, smbc_statvfs_fn fn);
1004 typedef int (*smbc_fstatvfs_fn)(SMBCCTX *c,
1005 SMBCFILE *file,
1006 struct statvfs *st);
1007 smbc_fstatvfs_fn smbc_getFunctionFstatVFS(SMBCCTX *c);
1008 void smbc_setFunctionFstatVFS(SMBCCTX *c, smbc_fstatvfs_fn fn);
1010 typedef int (*smbc_ftruncate_fn)(SMBCCTX *c,
1011 SMBCFILE *f,
1012 off_t size);
1013 smbc_ftruncate_fn smbc_getFunctionFtruncate(SMBCCTX *c);
1014 void smbc_setFunctionFtruncate(SMBCCTX *c, smbc_ftruncate_fn fn);
1016 typedef int (*smbc_close_fn)(SMBCCTX *c,
1017 SMBCFILE *file);
1018 smbc_close_fn smbc_getFunctionClose(SMBCCTX *c);
1019 void smbc_setFunctionClose(SMBCCTX *c, smbc_close_fn fn);
1023 /*****************************************************************
1024 * Callable functions for directories. *
1025 * Each callable has a function signature typedef, a declaration *
1026 * for the getter, and a declaration for the setter. *
1027 *****************************************************************/
1029 typedef SMBCFILE * (*smbc_opendir_fn)(SMBCCTX *c,
1030 const char *fname);
1031 smbc_opendir_fn smbc_getFunctionOpendir(SMBCCTX *c);
1032 void smbc_setFunctionOpendir(SMBCCTX *c, smbc_opendir_fn fn);
1034 typedef int (*smbc_closedir_fn)(SMBCCTX *c,
1035 SMBCFILE *dir);
1036 smbc_closedir_fn smbc_getFunctionClosedir(SMBCCTX *c);
1037 void smbc_setFunctionClosedir(SMBCCTX *c, smbc_closedir_fn fn);
1039 typedef struct smbc_dirent * (*smbc_readdir_fn)(SMBCCTX *c,
1040 SMBCFILE *dir);
1041 smbc_readdir_fn smbc_getFunctionReaddir(SMBCCTX *c);
1042 void smbc_setFunctionReaddir(SMBCCTX *c, smbc_readdir_fn fn);
1044 typedef const struct libsmb_file_info * (*smbc_readdirplus_fn)(SMBCCTX *c,
1045 SMBCFILE *dir);
1046 smbc_readdirplus_fn smbc_getFunctionReaddirPlus(SMBCCTX *c);
1047 void smbc_setFunctionReaddirPlus(SMBCCTX *c, smbc_readdirplus_fn fn);
1049 typedef int (*smbc_getdents_fn)(SMBCCTX *c,
1050 SMBCFILE *dir,
1051 struct smbc_dirent *dirp,
1052 int count);
1053 smbc_getdents_fn smbc_getFunctionGetdents(SMBCCTX *c);
1054 void smbc_setFunctionGetdents(SMBCCTX *c, smbc_getdents_fn fn);
1056 typedef int (*smbc_mkdir_fn)(SMBCCTX *c,
1057 const char *fname,
1058 mode_t mode);
1059 smbc_mkdir_fn smbc_getFunctionMkdir(SMBCCTX *c);
1060 void smbc_setFunctionMkdir(SMBCCTX *c, smbc_mkdir_fn fn);
1062 typedef int (*smbc_rmdir_fn)(SMBCCTX *c,
1063 const char *fname);
1064 smbc_rmdir_fn smbc_getFunctionRmdir(SMBCCTX *c);
1065 void smbc_setFunctionRmdir(SMBCCTX *c, smbc_rmdir_fn fn);
1067 typedef off_t (*smbc_telldir_fn)(SMBCCTX *c,
1068 SMBCFILE *dir);
1069 smbc_telldir_fn smbc_getFunctionTelldir(SMBCCTX *c);
1070 void smbc_setFunctionTelldir(SMBCCTX *c, smbc_telldir_fn fn);
1072 typedef int (*smbc_lseekdir_fn)(SMBCCTX *c,
1073 SMBCFILE *dir,
1074 off_t offset);
1075 smbc_lseekdir_fn smbc_getFunctionLseekdir(SMBCCTX *c);
1076 void smbc_setFunctionLseekdir(SMBCCTX *c, smbc_lseekdir_fn fn);
1078 typedef int (*smbc_fstatdir_fn)(SMBCCTX *c,
1079 SMBCFILE *dir,
1080 struct stat *st);
1081 smbc_fstatdir_fn smbc_getFunctionFstatdir(SMBCCTX *c);
1082 void smbc_setFunctionFstatdir(SMBCCTX *c, smbc_fstatdir_fn fn);
1084 #define SMBC_NOTIFY_ACTION_ADDED 1
1085 #define SMBC_NOTIFY_ACTION_REMOVED 2
1086 #define SMBC_NOTIFY_ACTION_MODIFIED 3
1087 #define SMBC_NOTIFY_ACTION_OLD_NAME 4
1088 #define SMBC_NOTIFY_ACTION_NEW_NAME 5
1089 #define SMBC_NOTIFY_ACTION_ADDED_STREAM 6
1090 #define SMBC_NOTIFY_ACTION_REMOVED_STREAM 7
1091 #define SMBC_NOTIFY_ACTION_MODIFIED_STREAM 8
1093 struct smbc_notify_callback_action {
1094 uint32_t action;
1095 const char *filename;
1098 typedef int (*smbc_notify_callback_fn)(
1099 const struct smbc_notify_callback_action *actions,
1100 size_t num_actions, void *private_data);
1102 typedef int (*smbc_notify_fn)(SMBCCTX *c, SMBCFILE *dir, smbc_bool recursive,
1103 uint32_t completion_filter,
1104 unsigned callback_timeout_ms,
1105 smbc_notify_callback_fn cb, void *private_data);
1106 smbc_notify_fn smbc_getFunctionNotify(SMBCCTX *c);
1107 void smbc_setFunctionNotify(SMBCCTX *c, smbc_notify_fn fn);
1110 /*****************************************************************
1111 * Callable functions applicable to both files and directories. *
1112 * Each callable has a function signature typedef, a declaration *
1113 * for the getter, and a declaration for the setter. *
1114 *****************************************************************/
1116 typedef int (*smbc_chmod_fn)(SMBCCTX *c,
1117 const char *fname,
1118 mode_t mode);
1119 smbc_chmod_fn smbc_getFunctionChmod(SMBCCTX *c);
1120 void smbc_setFunctionChmod(SMBCCTX *c, smbc_chmod_fn fn);
1122 typedef int (*smbc_utimes_fn)(SMBCCTX *c,
1123 const char *fname,
1124 struct timeval *tbuf);
1125 smbc_utimes_fn smbc_getFunctionUtimes(SMBCCTX *c);
1126 void smbc_setFunctionUtimes(SMBCCTX *c, smbc_utimes_fn fn);
1128 typedef int (*smbc_setxattr_fn)(SMBCCTX *context,
1129 const char *fname,
1130 const char *name,
1131 const void *value,
1132 size_t size,
1133 int flags);
1134 smbc_setxattr_fn smbc_getFunctionSetxattr(SMBCCTX *c);
1135 void smbc_setFunctionSetxattr(SMBCCTX *c, smbc_setxattr_fn fn);
1137 typedef int (*smbc_getxattr_fn)(SMBCCTX *context,
1138 const char *fname,
1139 const char *name,
1140 const void *value,
1141 size_t size);
1142 smbc_getxattr_fn smbc_getFunctionGetxattr(SMBCCTX *c);
1143 void smbc_setFunctionGetxattr(SMBCCTX *c, smbc_getxattr_fn fn);
1145 typedef int (*smbc_removexattr_fn)(SMBCCTX *context,
1146 const char *fname,
1147 const char *name);
1148 smbc_removexattr_fn smbc_getFunctionRemovexattr(SMBCCTX *c);
1149 void smbc_setFunctionRemovexattr(SMBCCTX *c, smbc_removexattr_fn fn);
1151 typedef int (*smbc_listxattr_fn)(SMBCCTX *context,
1152 const char *fname,
1153 char *list,
1154 size_t size);
1155 smbc_listxattr_fn smbc_getFunctionListxattr(SMBCCTX *c);
1156 void smbc_setFunctionListxattr(SMBCCTX *c, smbc_listxattr_fn fn);
1160 /*****************************************************************
1161 * Callable functions for printing. *
1162 * Each callable has a function signature typedef, a declaration *
1163 * for the getter, and a declaration for the setter. *
1164 *****************************************************************/
1166 typedef int (*smbc_print_file_fn)(SMBCCTX *c_file,
1167 const char *fname,
1168 SMBCCTX *c_print,
1169 const char *printq);
1170 smbc_print_file_fn smbc_getFunctionPrintFile(SMBCCTX *c);
1171 void smbc_setFunctionPrintFile(SMBCCTX *c, smbc_print_file_fn fn);
1173 typedef SMBCFILE * (*smbc_open_print_job_fn)(SMBCCTX *c,
1174 const char *fname);
1175 smbc_open_print_job_fn smbc_getFunctionOpenPrintJob(SMBCCTX *c);
1176 void smbc_setFunctionOpenPrintJob(SMBCCTX *c,
1177 smbc_open_print_job_fn fn);
1179 typedef int (*smbc_list_print_jobs_fn)(SMBCCTX *c,
1180 const char *fname,
1181 smbc_list_print_job_fn fn);
1182 smbc_list_print_jobs_fn smbc_getFunctionListPrintJobs(SMBCCTX *c);
1183 void smbc_setFunctionListPrintJobs(SMBCCTX *c,
1184 smbc_list_print_jobs_fn fn);
1186 typedef int (*smbc_unlink_print_job_fn)(SMBCCTX *c,
1187 const char *fname,
1188 int id);
1189 smbc_unlink_print_job_fn smbc_getFunctionUnlinkPrintJob(SMBCCTX *c);
1190 void smbc_setFunctionUnlinkPrintJob(SMBCCTX *c,
1191 smbc_unlink_print_job_fn fn);
1194 /**@ingroup misc
1195 * Create a new SBMCCTX (a context).
1197 * Must be called before the context is passed to smbc_context_init()
1199 * @return The given SMBCCTX pointer on success, NULL on error with errno set:
1200 * - ENOMEM Out of memory
1202 * @see smbc_free_context(), smbc_init_context()
1204 * @note Do not forget to smbc_init_context() the returned SMBCCTX pointer !
1206 SMBCCTX * smbc_new_context(void);
1208 /**@ingroup misc
1209 * Delete a SBMCCTX (a context) acquired from smbc_new_context().
1211 * The context will be deleted if possible.
1213 * @param context A pointer to a SMBCCTX obtained from smbc_new_context()
1215 * @param shutdown_ctx If 1, all connections and files will be closed even if they are busy.
1218 * @return Returns 0 on succes. Returns 1 on failure with errno set:
1219 * - EBUSY Server connections are still used, Files are open or cache
1220 * could not be purged
1221 * - EBADF context == NULL
1223 * @see smbc_new_context()
1225 * @note It is advised to clean up all the contexts with shutdown_ctx set to 1
1226 * just before exit()'ing. When shutdown_ctx is 0, this function can be
1227 * use in periodical cleanup functions for example.
1229 int smbc_free_context(SMBCCTX * context, int shutdown_ctx);
1232 /**@ingroup misc
1234 * @deprecated. Use smbc_setOption*() functions instead.
1236 void
1237 smbc_option_set(SMBCCTX *context,
1238 char *option_name,
1239 ... /* option_value */);
1242 * @deprecated. Use smbc_getOption*() functions instead.
1244 void *
1245 smbc_option_get(SMBCCTX *context,
1246 char *option_name);
1248 /**@ingroup misc
1249 * Initialize a SBMCCTX (a context).
1251 * Must be called before using any SMBCCTX API function
1253 * @param context A pointer to a SMBCCTX obtained from smbc_new_context()
1255 * @return A pointer to the given SMBCCTX on success,
1256 * NULL on error with errno set:
1257 * - EBADF NULL context given
1258 * - ENOMEM Out of memory
1259 * - ENOENT The smb.conf file would not load
1261 * @see smbc_new_context()
1263 * @note my_context = smbc_init_context(smbc_new_context())
1264 * is perfectly safe, but it might leak memory on
1265 * smbc_context_init() failure. Avoid this.
1266 * You'll have to call smbc_free_context() yourself
1267 * on failure.
1270 SMBCCTX * smbc_init_context(SMBCCTX * context);
1272 /**@ingroup misc
1273 * Initialize the samba client library.
1275 * Must be called before using any of the smbclient API function
1277 * @param fn The function that will be called to obtaion
1278 * authentication credentials.
1280 * @param debug Allows caller to set the debug level. Can be
1281 * changed in smb.conf file. Allows caller to set
1282 * debugging if no smb.conf.
1284 * @return 0 on success, < 0 on error with errno set:
1285 * - ENOMEM Out of memory
1286 * - ENOENT The smb.conf file would not load
1290 int smbc_init(smbc_get_auth_data_fn fn, int debug);
1292 /**@ingroup misc
1293 * Set or retrieve the compatibility library's context pointer
1295 * @param context New context to use, or NULL. If a new context is provided,
1296 * it must have allocated with smbc_new_context() and
1297 * initialized with smbc_init_context(), followed, optionally,
1298 * by some manual changes to some of the non-internal fields.
1300 * @return The old context.
1302 * @see smbc_new_context(), smbc_init_context(), smbc_init()
1304 * @note This function may be called prior to smbc_init() to force
1305 * use of the next context without any internal calls to
1306 * smbc_new_context() or smbc_init_context(). It may also
1307 * be called after smbc_init() has already called those two
1308 * functions, to replace the existing context with a new one.
1309 * Care should be taken, in this latter case, to ensure that
1310 * the server cache and any data allocated by the
1311 * authentication functions have been freed, if necessary.
1314 SMBCCTX * smbc_set_context(SMBCCTX * new_context);
1316 /**@ingroup file
1317 * Open a file on an SMB server.
1319 * @param furl The smb url of the file to be opened.
1321 * @param flags Is one of O_RDONLY, O_WRONLY or O_RDWR which
1322 * request opening the file read-only,write-only
1323 * or read/write. flags may also be bitwise-or'd with
1324 * one or more of the following:
1325 * O_CREAT - If the file does not exist it will be
1326 * created.
1327 * O_EXCL - When used with O_CREAT, if the file
1328 * already exists it is an error and the open will
1329 * fail.
1330 * O_TRUNC - If the file already exists it will be
1331 * truncated.
1332 * O_APPEND The file is opened in append mode
1334 * @param mode mode specifies the permissions to use if a new
1335 * file is created. It is modified by the
1336 * process's umask in the usual way: the permissions
1337 * of the created file are (mode & ~umask)
1339 * Not currently use, but there for future use.
1340 * We will map this to SYSTEM, HIDDEN, etc bits
1341 * that reverses the mapping that smbc_fstat does.
1343 * @return Valid file handle, < 0 on error with errno set:
1344 * - ENOMEM Out of memory
1345 * - EINVAL if an invalid parameter passed, like no
1346 * file, or smbc_init not called.
1347 * - EEXIST pathname already exists and O_CREAT and
1348 * O_EXCL were used.
1349 * - EISDIR pathname refers to a directory and
1350 * the access requested involved writing.
1351 * - EACCES The requested access to the file is not
1352 * allowed
1353 * - ENODEV The requested share does not exist
1354 * - ENOTDIR A file on the path is not a directory
1355 * - ENOENT A directory component in pathname does
1356 * not exist.
1358 * @see smbc_creat()
1360 * @note This call uses an underlying routine that may create
1361 * a new connection to the server specified in the URL.
1362 * If the credentials supplied in the URL, or via the
1363 * auth_fn in the smbc_init call, fail, this call will
1364 * try again with an empty username and password. This
1365 * often gets mapped to the guest account on some machines.
1368 int smbc_open(const char *furl, int flags, mode_t mode);
1370 /**@ingroup file
1371 * Create a file on an SMB server.
1373 * Same as calling smbc_open() with flags = O_CREAT|O_WRONLY|O_TRUNC
1375 * @param furl The smb url of the file to be created
1377 * @param mode mode specifies the permissions to use if a new
1378 * file is created. It is modified by the
1379 * process's umask in the usual way: the permissions
1380 * of the created file are (mode & ~umask)
1382 * NOTE, the above is not true. We are dealing with
1383 * an SMB server, which has no concept of a umask!
1385 * @return Valid file handle, < 0 on error with errno set:
1386 * - ENOMEM Out of memory
1387 * - EINVAL if an invalid parameter passed, like no
1388 * file, or smbc_init not called.
1389 * - EEXIST pathname already exists and O_CREAT and
1390 * O_EXCL were used.
1391 * - EISDIR pathname refers to a directory and
1392 * the access requested involved writing.
1393 * - EACCES The requested access to the file is not
1394 * allowed
1395 * - ENOENT A directory component in pathname does
1396 * not exist.
1397 * - ENODEV The requested share does not exist.
1398 * @see smbc_open()
1402 int smbc_creat(const char *furl, mode_t mode);
1404 /**@ingroup file
1405 * Read from a file using an opened file handle.
1407 * @param fd Open file handle from smbc_open() or smbc_creat()
1409 * @param buf Pointer to buffer to receive read data
1411 * @param bufsize Size of buf in bytes
1413 * @return Number of bytes read;
1414 * 0 upon EOF;
1415 * < 0 on error, with errno set:
1416 * - EISDIR fd refers to a directory
1417 * - EBADF fd is not a valid file descriptor or
1418 * is not open for reading.
1419 * - EINVAL fd is attached to an object which is
1420 * unsuitable for reading, or no buffer passed or
1421 * smbc_init not called.
1423 * @see smbc_open(), smbc_write()
1426 ssize_t smbc_read(int fd, void *buf, size_t bufsize);
1429 /**@ingroup file
1430 * Write to a file using an opened file handle.
1432 * @param fd Open file handle from smbc_open() or smbc_creat()
1434 * @param buf Pointer to buffer to recieve read data
1436 * @param bufsize Size of buf in bytes
1438 * @return Number of bytes written, < 0 on error with errno set:
1439 * - EISDIR fd refers to a directory.
1440 * - EBADF fd is not a valid file descriptor or
1441 * is not open for reading.
1442 * - EINVAL fd is attached to an object which is
1443 * unsuitable for reading, or no buffer passed or
1444 * smbc_init not called.
1446 * @see smbc_open(), smbc_read()
1449 ssize_t smbc_write(int fd, const void *buf, size_t bufsize);
1452 /**@ingroup file
1453 * Seek to a specific location in a file.
1455 * @param fd Open file handle from smbc_open() or smbc_creat()
1457 * @param offset Offset in bytes from whence
1459 * @param whence A location in the file:
1460 * - SEEK_SET The offset is set to offset bytes from
1461 * the beginning of the file
1462 * - SEEK_CUR The offset is set to current location
1463 * plus offset bytes.
1464 * - SEEK_END The offset is set to the size of the
1465 * file plus offset bytes.
1467 * @return Upon successful completion, lseek returns the
1468 * resulting offset location as measured in bytes
1469 * from the beginning of the file. Otherwise, a value
1470 * of (off_t)-1 is returned and errno is set to
1471 * indicate the error:
1472 * - EBADF Fildes is not an open file descriptor.
1473 * - EINVAL Whence is not a proper value or smbc_init
1474 * not called.
1476 * @todo Are all the whence values really supported?
1478 * @todo Are errno values complete and correct?
1480 off_t smbc_lseek(int fd, off_t offset, int whence);
1483 /**@ingroup file
1484 * Close an open file handle.
1486 * @param fd The file handle to close
1488 * @return 0 on success, < 0 on error with errno set:
1489 * - EBADF fd isn't a valid open file descriptor
1490 * - EINVAL smbc_init() failed or has not been called
1492 * @see smbc_open(), smbc_creat()
1494 int smbc_close(int fd);
1497 /**@ingroup directory
1498 * Unlink (delete) a file or directory.
1500 * @param furl The smb url of the file to delete
1502 * @return 0 on success, < 0 on error with errno set:
1503 * - EACCES or EPERM Write access to the directory
1504 * containing pathname is not allowed or one
1505 * of the directories in pathname did not allow
1506 * search (execute) permission
1507 * - ENOENT A directory component in pathname does
1508 * not exist
1509 * - EINVAL NULL was passed in the file param or
1510 * smbc_init not called.
1511 * - EACCES You do not have access to the file
1512 * - ENOMEM Insufficient kernel memory was available
1514 * @see smbc_rmdir()s
1516 * @todo Are errno values complete and correct?
1518 int smbc_unlink(const char *furl);
1521 /**@ingroup directory
1522 * Rename or move a file or directory.
1524 * @param ourl The original smb url (source url) of file or
1525 * directory to be moved
1527 * @param nurl The new smb url (destination url) of the file
1528 * or directory after the move. Currently nurl must
1529 * be on the same share as ourl.
1531 * @return 0 on success, < 0 on error with errno set:
1532 * - EISDIR nurl is an existing directory, but ourl is
1533 * not a directory.
1534 * - EEXIST nurl is a non-empty directory,
1535 * i.e., contains entries other than "." and ".."
1536 * - EINVAL The new url contained a path prefix
1537 * of the old, or, more generally, an attempt was
1538 * made to make a directory a subdirectory of itself
1539 * or smbc_init not called.
1540 * - ENOTDIR A component used as a directory in ourl
1541 * or nurl path is not, in fact, a directory. Or,
1542 * ourl is a directory, and newpath exists but is not
1543 * a directory.
1544 * - EACCES or EPERM Write access to the directory
1545 * containing ourl or nurl is not allowed for the
1546 * process's effective uid, or one of the
1547 * directories in ourl or nurl did not allow search
1548 * (execute) permission, or ourl was a directory
1549 * and did not allow write permission.
1550 * - ENOENT A directory component in ourl or nurl
1551 * does not exist.
1552 * - EXDEV Rename across shares not supported.
1553 * - ENOMEM Insufficient kernel memory was available.
1554 * - EEXIST The target file, nurl, already exists.
1557 * @todo Are we going to support copying when urls are not on the same
1558 * share? I say no... NOTE. I agree for the moment.
1561 int smbc_rename(const char *ourl, const char *nurl);
1564 /**@ingroup directory
1565 * Open a directory used to obtain directory entries.
1567 * @param durl The smb url of the directory to open
1569 * @return Valid directory handle. < 0 on error with errno set:
1570 * - EACCES Permission denied.
1571 * - EINVAL A NULL file/URL was passed, or the URL would
1572 * not parse, or was of incorrect form or smbc_init not
1573 * called.
1574 * - ENOENT durl does not exist, or name is an
1575 * - ENOMEM Insufficient memory to complete the
1576 * operation.
1577 * - ENOTDIR name is not a directory.
1578 * - EPERM the workgroup could not be found.
1579 * - ENODEV the workgroup or server could not be found.
1581 * @see smbc_getdents(), smbc_readdir(), smbc_closedir()
1584 int smbc_opendir(const char *durl);
1587 /**@ingroup directory
1588 * Close a directory handle opened by smbc_opendir().
1590 * @param dh Directory handle to close
1592 * @return 0 on success, < 0 on error with errno set:
1593 * - EBADF dh is an invalid directory handle
1595 * @see smbc_opendir()
1597 int smbc_closedir(int dh);
1600 /**@ingroup directory
1601 * Get multiple directory entries.
1603 * smbc_getdents() reads as many dirent structures from the an open
1604 * directory handle into a specified memory area as will fit.
1606 * @param dh Valid directory as returned by smbc_opendir()
1608 * @param dirp pointer to buffer that will receive the directory
1609 * entries.
1611 * @param count The size of the dirp buffer in bytes
1613 * @returns If any dirents returned, return will indicate the
1614 * total size. If there were no more dirents available,
1615 * 0 is returned. < 0 indicates an error.
1616 * - EBADF Invalid directory handle
1617 * - EINVAL Result buffer is too small or smbc_init
1618 * not called.
1619 * - ENOENT No such directory.
1620 * @see , smbc_dirent, smbc_readdir(), smbc_open()
1622 * @todo Are errno values complete and correct?
1624 * @todo Add example code so people know how to parse buffers.
1626 int smbc_getdents(unsigned int dh, struct smbc_dirent *dirp, int count);
1629 /**@ingroup directory
1630 * Get a single directory entry.
1632 * @param dh Valid directory as returned by smbc_opendir()
1634 * @return A pointer to a smbc_dirent structure, or NULL if an
1635 * error occurs or end-of-directory is reached:
1636 * - EBADF Invalid directory handle
1637 * - EINVAL smbc_init() failed or has not been called
1639 * @see smbc_dirent, smbc_getdents(), smbc_open()
1641 struct smbc_dirent* smbc_readdir(unsigned int dh);
1643 /**@ingroup directory
1644 * Works similar as smbc_readdir but returns more information about file.
1646 * @param dh Valid directory as returned by smbc_opendir()
1648 * @return A const pointer to a libsmb_file_info structure,
1649 * or NULL if an error occurs or end-of-directory is reached:
1650 * - EBADF Invalid directory handle
1651 * - EINVAL smbc_init() failed or has not been called
1653 * @see smbc_open(), smbc_readdir()
1655 const struct libsmb_file_info *smbc_readdirplus(unsigned int dh);
1658 /**@ingroup directory
1659 * Get the current directory offset.
1661 * smbc_telldir() may be used in conjunction with smbc_readdir() and
1662 * smbc_lseekdir().
1664 * @param dh Valid directory as returned by smbc_opendir()
1666 * @return The current location in the directory stream or -1
1667 * if an error occur. The current location is not
1668 * an offset. Becuase of the implementation, it is a
1669 * handle that allows the library to find the entry
1670 * later.
1671 * - EBADF dh is not a valid directory handle
1672 * - EINVAL smbc_init() failed or has not been called
1673 * - ENOTDIR if dh is not a directory
1675 * @see smbc_readdir()
1678 off_t smbc_telldir(int dh);
1681 /**@ingroup directory
1682 * lseek on directories.
1684 * smbc_lseekdir() may be used in conjunction with smbc_readdir() and
1685 * smbc_telldir(). (rewind by smbc_lseekdir(fd, NULL))
1687 * @param fd Valid directory as returned by smbc_opendir()
1689 * @param offset The offset (as returned by smbc_telldir). Can be
1690 * NULL, in which case we will rewind
1692 * @return 0 on success, -1 on failure
1693 * - EBADF dh is not a valid directory handle
1694 * - ENOTDIR if dh is not a directory
1695 * - EINVAL offset did not refer to a valid dirent or
1696 * smbc_init not called.
1698 * @see smbc_telldir()
1701 * @todo In what does the reture and errno values mean?
1703 int smbc_lseekdir(int fd, off_t offset);
1705 /**@ingroup directory
1706 * Create a directory.
1708 * @param durl The url of the directory to create
1710 * @param mode Specifies the permissions to use. It is modified
1711 * by the process's umask in the usual way: the
1712 * permissions of the created file are (mode & ~umask).
1714 * @return 0 on success, < 0 on error with errno set:
1715 * - EEXIST directory url already exists
1716 * - EACCES The parent directory does not allow write
1717 * permission to the process, or one of the directories
1718 * - ENOENT A directory component in pathname does not
1719 * exist.
1720 * - EINVAL NULL durl passed or smbc_init not called.
1721 * - ENOMEM Insufficient memory was available.
1723 * @see smbc_rmdir()
1726 int smbc_mkdir(const char *durl, mode_t mode);
1729 /**@ingroup directory
1730 * Remove a directory.
1732 * @param durl The smb url of the directory to remove
1734 * @return 0 on success, < 0 on error with errno set:
1735 * - EACCES or EPERM Write access to the directory
1736 * containing pathname was not allowed.
1737 * - EINVAL durl is NULL or smbc_init not called.
1738 * - ENOENT A directory component in pathname does not
1739 * exist.
1740 * - ENOTEMPTY directory contains entries.
1741 * - ENOMEM Insufficient kernel memory was available.
1743 * @see smbc_mkdir(), smbc_unlink()
1745 * @todo Are errno values complete and correct?
1747 int smbc_rmdir(const char *durl);
1749 /**@ingroup directory
1750 * Request directory notifications
1752 * @param dh Valid directory as returned by smbc_opendir()
1754 * @param recursive Are changes in subdirectories wanted?
1756 * @param completion_filter Bitwise-or of the SMBC_NOTIFY_CHANGE_*
1757 * events that are interesting
1759 * @param callback_timeout_ms If set to non-zero, interval in milliseconds
1760 * that "cb" will be called with 0 actions.
1761 * This gives "cb" the chance to cancel the
1762 * smbc_notify call.
1764 * @param cb Callback functions taking events. If "cb"
1765 * returns nonzero, smbc_notify will return.
1767 * @param private_data Pointer given to "cb"
1769 * @return 0 on success, -1 on error with errno set
1771 * @see smbc_opendir(), smbc_closedir()
1774 #define SMBC_NOTIFY_CHANGE_FILE_NAME 0x001
1775 #define SMBC_NOTIFY_CHANGE_DIR_NAME 0x002
1776 #define SMBC_NOTIFY_CHANGE_ATTRIBUTES 0x004
1777 #define SMBC_NOTIFY_CHANGE_SIZE 0x008
1778 #define SMBC_NOTIFY_CHANGE_LAST_WRITE 0x010
1779 #define SMBC_NOTIFY_CHANGE_LAST_ACCESS 0x020
1780 #define SMBC_NOTIFY_CHANGE_CREATION 0x040
1781 #define SMBC_NOTIFY_CHANGE_EA 0x080
1782 #define SMBC_NOTIFY_CHANGE_SECURITY 0x100
1783 #define SMBC_NOTIFY_CHANGE_STREAM_NAME 0x200
1784 #define SMBC_NOTIFY_CHANGE_STREAM_SIZE 0x400
1785 #define SMBC_NOTIFY_CHANGE_STREAM_WRITE 0x800
1787 int smbc_notify(int dh, smbc_bool recursive, uint32_t completion_filter,
1788 unsigned callback_timeout_ms,
1789 smbc_notify_callback_fn cb, void *private_data);
1791 /**@ingroup attribute
1792 * Get information about a file or directory.
1794 * @param url The smb url to get information for
1796 * @param st pointer to a buffer that will be filled with
1797 * standard Unix struct stat information.
1799 * @return 0 on success, < 0 on error with errno set:
1800 * - ENOENT A component of the path file_name does not
1801 * exist.
1802 * - EINVAL a NULL url was passed or smbc_init not called.
1803 * - EACCES Permission denied.
1804 * - ENOMEM Out of memory
1805 * - ENOTDIR The target dir, url, is not a directory.
1807 * @see Unix stat()
1810 int smbc_stat(const char *url, struct stat *st);
1813 /**@ingroup attribute
1814 * Get file information via an file descriptor.
1816 * @param fd Open file handle from smbc_open() or smbc_creat()
1818 * @param st pointer to a buffer that will be filled with
1819 * standard Unix struct stat information.
1821 * @return 0 on success, < 0 on error with errno set:
1822 * - EBADF filedes is bad.
1823 * - EACCES Permission denied.
1824 * - EBADF fd is not a valid file descriptor
1825 * - EINVAL Problems occurred in the underlying routines
1826 * or smbc_init not called.
1827 * - ENOMEM Out of memory
1829 * @see smbc_stat(), Unix stat()
1832 int smbc_fstat(int fd, struct stat *st);
1835 /**@ingroup attribute
1836 * Get file system information for a specified path.
1838 * @param url The smb url to get information for
1840 * @param st pointer to a buffer that will be filled with
1841 * standard Unix struct statvfs information.
1843 * @return 0 on success, < 0 on error with errno set:
1844 * - EBADF filedes is bad.
1845 * - EACCES Permission denied.
1846 * - EBADF fd is not a valid file descriptor
1847 * - EINVAL Problems occurred in the underlying routines
1848 * or smbc_init not called.
1849 * - ENOMEM Out of memory
1851 * @see Unix fstatvfs()
1855 smbc_statvfs(char *url,
1856 struct statvfs *st);
1858 /**@ingroup attribute
1859 * Get file system information via an file descriptor.
1861 * @param fd Open file handle from smbc_open(), smbc_creat(),
1862 * or smbc_opendir()
1864 * @param st pointer to a buffer that will be filled with
1865 * standard Unix struct statvfs information.
1867 * @return 0 on success, < 0 on error with errno set:
1868 * - EBADF filedes is bad.
1869 * - EACCES Permission denied.
1870 * - EBADF fd is not a valid file descriptor
1871 * - EINVAL Problems occurred in the underlying routines
1872 * or smbc_init not called.
1873 * - ENOMEM Out of memory
1875 * @see Unix fstatvfs()
1879 smbc_fstatvfs(int fd,
1880 struct statvfs *st);
1883 /**@ingroup attribute
1884 * Truncate a file given a file descriptor
1886 * @param fd Open file handle from smbc_open() or smbc_creat()
1888 * @param size size to truncate the file to
1890 * @return 0 on success, < 0 on error with errno set:
1891 * - EBADF filedes is bad.
1892 * - EACCES Permission denied.
1893 * - EBADF fd is not a valid file descriptor
1894 * - EINVAL Problems occurred in the underlying routines
1895 * or smbc_init not called.
1896 * - ENOMEM Out of memory
1898 * @see , Unix ftruncate()
1901 int smbc_ftruncate(int fd, off_t size);
1904 /**@ingroup attribute
1905 * Change the permissions of a file.
1907 * @param url The smb url of the file or directory to change
1908 * permissions of
1910 * @param mode The permissions to set:
1911 * - Put good explaination of permissions here!
1913 * @return 0 on success, < 0 on error with errno set:
1914 * - EPERM The effective UID does not match the owner
1915 * of the file, and is not zero
1916 * - ENOENT The file does not exist.
1917 * - ENOMEM Insufficient was available.
1918 * - ENOENT file or directory does not exist
1920 * @todo Actually implement this fuction?
1922 * @todo Are errno values complete and correct?
1924 int smbc_chmod(const char *url, mode_t mode);
1927 * @ingroup attribute
1928 * Change the last modification time on a file
1930 * @param url The smb url of the file or directory to change
1931 * the modification time of
1933 * @param tbuf An array of two timeval structures which contains,
1934 * respectively, the desired access and modification times.
1935 * NOTE: Only the tv_sec field off each timeval structure is
1936 * used. The tv_usec (microseconds) portion is ignored.
1938 * @return 0 on success, < 0 on error with errno set:
1939 * - EINVAL The client library is not properly initialized
1940 * - EPERM Permission was denied.
1943 int smbc_utimes(const char *url, struct timeval *tbuf);
1945 #ifdef HAVE_UTIME_H
1947 * @ingroup attribute
1948 * Change the last modification time on a file
1950 * @param url The smb url of the file or directory to change
1951 * the modification time of
1953 * @param utbuf A pointer to a utimebuf structure which contains the
1954 * desired access and modification times.
1956 * @return 0 on success, < 0 on error with errno set:
1957 * - EINVAL The client library is not properly initialized
1958 * - ENOMEM No memory was available for internal needs
1959 * - EPERM Permission was denied.
1962 int smbc_utime(const char *fname, struct utimbuf *utbuf);
1963 #endif
1965 /**@ingroup attribute
1966 * Set extended attributes for a file. This is used for modifying a file's
1967 * security descriptor (i.e. owner, group, and access control list)
1969 * @param url The smb url of the file or directory to set extended
1970 * attributes for.
1972 * @param name The name of an attribute to be changed. Names are of
1973 * one of the following forms:
1975 * system.nt_sec_desc.<attribute name>
1976 * system.nt_sec_desc.*
1977 * system.nt_sec_desc.*+
1979 * where <attribute name> is one of:
1981 * revision
1982 * owner
1983 * owner+
1984 * group
1985 * group+
1986 * acl:<name or sid>
1987 * acl+:<name or sid>
1989 * In the forms "system.nt_sec_desc.*" and
1990 * "system.nt_sec_desc.*+", the asterisk and plus signs are
1991 * literal, i.e. the string is provided exactly as shown, and
1992 * the value parameter should contain a complete security
1993 * descriptor with name:value pairs separated by tabs,
1994 * commas, or newlines (not spaces!).
1996 * The plus sign ('+') indicates that SIDs should be mapped
1997 * to names. Without the plus sign, SIDs are not mapped;
1998 * rather they are simply converted to a string format.
2000 * @param value The value to be assigned to the specified attribute name.
2001 * This buffer should contain only the attribute value if the
2002 * name was of the "system.nt_sec_desc.<attribute_name>"
2003 * form. If the name was of the "system.nt_sec_desc.*" form
2004 * then a complete security descriptor, with name:value pairs
2005 * separated by tabs, commas, or newlines (not spaces!),
2006 * should be provided in this value buffer. A complete
2007 * security descriptor will contain one or more entries
2008 * selected from the following:
2010 * REVISION:<revision number>
2011 * OWNER:<sid or name>
2012 * GROUP:<sid or name>
2013 * ACL:<sid or name>:<type>/<flags>/<mask>
2015 * The revision of the ACL specifies the internal Windows NT
2016 * ACL revision for the security descriptor. If not specified
2017 * it defaults to 1. Using values other than 1 may cause
2018 * strange behaviour.
2020 * The owner and group specify the owner and group sids for
2021 * the object. If the attribute name (either '*+' with a
2022 * complete security descriptor, or individual 'owner+' or
2023 * 'group+' attribute names) ended with a plus sign, the
2024 * specified name is resolved to a SID value, using the
2025 * server on which the file or directory resides. Otherwise,
2026 * the value should be provided in SID-printable format as
2027 * S-1-x-y-z, and is used directly. The <sid or name>
2028 * associated with the ACL: attribute should be provided
2029 * similarly.
2031 * @param size The number of the bytes of data in the value buffer
2033 * @param flags A bit-wise OR of zero or more of the following:
2034 * SMBC_XATTR_FLAG_CREATE -
2035 * fail if the named attribute already exists
2036 * SMBC_XATTR_FLAG_REPLACE -
2037 * fail if the attribute does not already exist
2039 * If neither flag is specified, the specified attributes
2040 * will be added or replace existing attributes of the same
2041 * name, as necessary.
2043 * @return 0 on success, < 0 on error with errno set:
2044 * - EINVAL The client library is not properly initialized
2045 * or one of the parameters is not of a correct
2046 * form
2047 * - ENOMEM No memory was available for internal needs
2048 * - EEXIST If the attribute already exists and the flag
2049 * SMBC_XATTR_FLAG_CREAT was specified
2050 * - ENOATTR If the attribute does not exist and the flag
2051 * SMBC_XATTR_FLAG_REPLACE was specified
2052 * - EPERM Permission was denied.
2053 * - ENOTSUP The referenced file system does not support
2054 * extended attributes
2056 * @note Attribute names are compared in a case-insensitive
2057 * fashion. All of the following are equivalent, although
2058 * the all-lower-case name is the preferred format:
2059 * system.nt_sec_desc.owner
2060 * SYSTEM.NT_SEC_DESC.OWNER
2061 * sYsTeM.nt_sEc_desc.owNER
2064 int smbc_setxattr(const char *url,
2065 const char *name,
2066 const void *value,
2067 size_t size,
2068 int flags);
2071 /**@ingroup attribute
2072 * Set extended attributes for a file. This is used for modifying a file's
2073 * security descriptor (i.e. owner, group, and access control list). The
2074 * POSIX function which this maps to would act on a symbolic link rather than
2075 * acting on what the symbolic link points to, but with no symbolic links in
2076 * SMB file systems, this function is functionally identical to
2077 * smbc_setxattr().
2079 * @param url The smb url of the file or directory to set extended
2080 * attributes for.
2082 * @param name The name of an attribute to be changed. Names are of
2083 * one of the following forms:
2085 * system.nt_sec_desc.<attribute name>
2086 * system.nt_sec_desc.*
2087 * system.nt_sec_desc.*+
2089 * where <attribute name> is one of:
2091 * revision
2092 * owner
2093 * owner+
2094 * group
2095 * group+
2096 * acl:<name or sid>
2097 * acl+:<name or sid>
2099 * In the forms "system.nt_sec_desc.*" and
2100 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2101 * literal, i.e. the string is provided exactly as shown, and
2102 * the value parameter should contain a complete security
2103 * descriptor with name:value pairs separated by tabs,
2104 * commas, or newlines (not spaces!).
2106 * The plus sign ('+') indicates that SIDs should be mapped
2107 * to names. Without the plus sign, SIDs are not mapped;
2108 * rather they are simply converted to a string format.
2110 * @param value The value to be assigned to the specified attribute name.
2111 * This buffer should contain only the attribute value if the
2112 * name was of the "system.nt_sec_desc.<attribute_name>"
2113 * form. If the name was of the "system.nt_sec_desc.*" form
2114 * then a complete security descriptor, with name:value pairs
2115 * separated by tabs, commas, or newlines (not spaces!),
2116 * should be provided in this value buffer. A complete
2117 * security descriptor will contain one or more entries
2118 * selected from the following:
2120 * REVISION:<revision number>
2121 * OWNER:<sid or name>
2122 * GROUP:<sid or name>
2123 * ACL:<sid or name>:<type>/<flags>/<mask>
2125 * The revision of the ACL specifies the internal Windows NT
2126 * ACL revision for the security descriptor. If not specified
2127 * it defaults to 1. Using values other than 1 may cause
2128 * strange behaviour.
2130 * The owner and group specify the owner and group sids for
2131 * the object. If the attribute name (either '*+' with a
2132 * complete security descriptor, or individual 'owner+' or
2133 * 'group+' attribute names) ended with a plus sign, the
2134 * specified name is resolved to a SID value, using the
2135 * server on which the file or directory resides. Otherwise,
2136 * the value should be provided in SID-printable format as
2137 * S-1-x-y-z, and is used directly. The <sid or name>
2138 * associated with the ACL: attribute should be provided
2139 * similarly.
2141 * @param size The number of the bytes of data in the value buffer
2143 * @param flags A bit-wise OR of zero or more of the following:
2144 * SMBC_XATTR_FLAG_CREATE -
2145 * fail if the named attribute already exists
2146 * SMBC_XATTR_FLAG_REPLACE -
2147 * fail if the attribute does not already exist
2149 * If neither flag is specified, the specified attributes
2150 * will be added or replace existing attributes of the same
2151 * name, as necessary.
2153 * @return 0 on success, < 0 on error with errno set:
2154 * - EINVAL The client library is not properly initialized
2155 * or one of the parameters is not of a correct
2156 * form
2157 * - ENOMEM No memory was available for internal needs
2158 * - EEXIST If the attribute already exists and the flag
2159 * SMBC_XATTR_FLAG_CREAT was specified
2160 * - ENOATTR If the attribute does not exist and the flag
2161 * SMBC_XATTR_FLAG_REPLACE was specified
2162 * - EPERM Permission was denied.
2163 * - ENOTSUP The referenced file system does not support
2164 * extended attributes
2166 * @note Attribute names are compared in a case-insensitive
2167 * fashion. All of the following are equivalent, although
2168 * the all-lower-case name is the preferred format:
2169 * system.nt_sec_desc.owner
2170 * SYSTEM.NT_SEC_DESC.OWNER
2171 * sYsTeM.nt_sEc_desc.owNER
2174 int smbc_lsetxattr(const char *url,
2175 const char *name,
2176 const void *value,
2177 size_t size,
2178 int flags);
2181 /**@ingroup attribute
2182 * Set extended attributes for a file. This is used for modifying a file's
2183 * security descriptor (i.e. owner, group, and access control list)
2185 * @param fd A file descriptor associated with an open file (as
2186 * previously returned by smbc_open(), to get extended
2187 * attributes for.
2189 * @param name The name of an attribute to be changed. Names are of
2190 * one of the following forms:
2192 * system.nt_sec_desc.<attribute name>
2193 * system.nt_sec_desc.*
2194 * system.nt_sec_desc.*+
2196 * where <attribute name> is one of:
2198 * revision
2199 * owner
2200 * owner+
2201 * group
2202 * group+
2203 * acl:<name or sid>
2204 * acl+:<name or sid>
2206 * In the forms "system.nt_sec_desc.*" and
2207 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2208 * literal, i.e. the string is provided exactly as shown, and
2209 * the value parameter should contain a complete security
2210 * descriptor with name:value pairs separated by tabs,
2211 * commas, or newlines (not spaces!).
2213 * The plus sign ('+') indicates that SIDs should be mapped
2214 * to names. Without the plus sign, SIDs are not mapped;
2215 * rather they are simply converted to a string format.
2217 * @param value The value to be assigned to the specified attribute name.
2218 * This buffer should contain only the attribute value if the
2219 * name was of the "system.nt_sec_desc.<attribute_name>"
2220 * form. If the name was of the "system.nt_sec_desc.*" form
2221 * then a complete security descriptor, with name:value pairs
2222 * separated by tabs, commas, or newlines (not spaces!),
2223 * should be provided in this value buffer. A complete
2224 * security descriptor will contain one or more entries
2225 * selected from the following:
2227 * REVISION:<revision number>
2228 * OWNER:<sid or name>
2229 * GROUP:<sid or name>
2230 * ACL:<sid or name>:<type>/<flags>/<mask>
2232 * The revision of the ACL specifies the internal Windows NT
2233 * ACL revision for the security descriptor. If not specified
2234 * it defaults to 1. Using values other than 1 may cause
2235 * strange behaviour.
2237 * The owner and group specify the owner and group sids for
2238 * the object. If the attribute name (either '*+' with a
2239 * complete security descriptor, or individual 'owner+' or
2240 * 'group+' attribute names) ended with a plus sign, the
2241 * specified name is resolved to a SID value, using the
2242 * server on which the file or directory resides. Otherwise,
2243 * the value should be provided in SID-printable format as
2244 * S-1-x-y-z, and is used directly. The <sid or name>
2245 * associated with the ACL: attribute should be provided
2246 * similarly.
2248 * @param size The number of the bytes of data in the value buffer
2250 * @param flags A bit-wise OR of zero or more of the following:
2251 * SMBC_XATTR_FLAG_CREATE -
2252 * fail if the named attribute already exists
2253 * SMBC_XATTR_FLAG_REPLACE -
2254 * fail if the attribute does not already exist
2256 * If neither flag is specified, the specified attributes
2257 * will be added or replace existing attributes of the same
2258 * name, as necessary.
2260 * @return 0 on success, < 0 on error with errno set:
2261 * - EINVAL The client library is not properly initialized
2262 * or one of the parameters is not of a correct
2263 * form
2264 * - ENOMEM No memory was available for internal needs
2265 * - EEXIST If the attribute already exists and the flag
2266 * SMBC_XATTR_FLAG_CREAT was specified
2267 * - ENOATTR If the attribute does not exist and the flag
2268 * SMBC_XATTR_FLAG_REPLACE was specified
2269 * - EPERM Permission was denied.
2270 * - ENOTSUP The referenced file system does not support
2271 * extended attributes
2273 * @note Attribute names are compared in a case-insensitive
2274 * fashion. All of the following are equivalent, although
2275 * the all-lower-case name is the preferred format:
2276 * system.nt_sec_desc.owner
2277 * SYSTEM.NT_SEC_DESC.OWNER
2278 * sYsTeM.nt_sEc_desc.owNER
2281 int smbc_fsetxattr(int fd,
2282 const char *name,
2283 const void *value,
2284 size_t size,
2285 int flags);
2288 /**@ingroup attribute
2289 * Get extended attributes for a file.
2291 * @param url The smb url of the file or directory to get extended
2292 * attributes for.
2294 * @param name The name of an attribute to be retrieved. Names are of
2295 * one of the following forms:
2297 * system.nt_sec_desc.<attribute name>
2298 * system.nt_sec_desc.*
2299 * system.nt_sec_desc.*+
2301 * where <attribute name> is one of:
2303 * revision
2304 * owner
2305 * owner+
2306 * group
2307 * group+
2308 * acl:<name or sid>
2309 * acl+:<name or sid>
2311 * In the forms "system.nt_sec_desc.*" and
2312 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2313 * literal, i.e. the string is provided exactly as shown, and
2314 * the value parameter will return a complete security
2315 * descriptor with name:value pairs separated by tabs,
2316 * commas, or newlines (not spaces!).
2318 * The plus sign ('+') indicates that SIDs should be mapped
2319 * to names. Without the plus sign, SIDs are not mapped;
2320 * rather they are simply converted to a string format.
2322 * @param value A pointer to a buffer in which the value of the specified
2323 * attribute will be placed (unless size is zero).
2325 * @param size The size of the buffer pointed to by value. This parameter
2326 * may also be zero, in which case the size of the buffer
2327 * required to hold the attribute value will be returned,
2328 * but nothing will be placed into the value buffer.
2330 * @return 0 on success, < 0 on error with errno set:
2331 * - EINVAL The client library is not properly initialized
2332 * or one of the parameters is not of a correct
2333 * form
2334 * - ENOMEM No memory was available for internal needs
2335 * - EEXIST If the attribute already exists and the flag
2336 * SMBC_XATTR_FLAG_CREAT was specified
2337 * - ENOATTR If the attribute does not exist and the flag
2338 * SMBC_XATTR_FLAG_REPLACE was specified
2339 * - EPERM Permission was denied.
2340 * - ENOTSUP The referenced file system does not support
2341 * extended attributes
2344 int smbc_getxattr(const char *url,
2345 const char *name,
2346 const void *value,
2347 size_t size);
2350 /**@ingroup attribute
2351 * Get extended attributes for a file. The POSIX function which this maps to
2352 * would act on a symbolic link rather than acting on what the symbolic link
2353 * points to, but with no symbolic links in SMB file systems, this function
2354 * is functionally identical to smbc_getxattr().
2356 * @param url The smb url of the file or directory to get extended
2357 * attributes for.
2359 * @param name The name of an attribute to be retrieved. Names are of
2360 * one of the following forms:
2362 * system.nt_sec_desc.<attribute name>
2363 * system.nt_sec_desc.*
2364 * system.nt_sec_desc.*+
2366 * where <attribute name> is one of:
2368 * revision
2369 * owner
2370 * owner+
2371 * group
2372 * group+
2373 * acl:<name or sid>
2374 * acl+:<name or sid>
2376 * In the forms "system.nt_sec_desc.*" and
2377 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2378 * literal, i.e. the string is provided exactly as shown, and
2379 * the value parameter will return a complete security
2380 * descriptor with name:value pairs separated by tabs,
2381 * commas, or newlines (not spaces!).
2383 * The plus sign ('+') indicates that SIDs should be mapped
2384 * to names. Without the plus sign, SIDs are not mapped;
2385 * rather they are simply converted to a string format.
2387 * @param value A pointer to a buffer in which the value of the specified
2388 * attribute will be placed (unless size is zero).
2390 * @param size The size of the buffer pointed to by value. This parameter
2391 * may also be zero, in which case the size of the buffer
2392 * required to hold the attribute value will be returned,
2393 * but nothing will be placed into the value buffer.
2395 * @return 0 on success, < 0 on error with errno set:
2396 * - EINVAL The client library is not properly initialized
2397 * or one of the parameters is not of a correct
2398 * form
2399 * - ENOMEM No memory was available for internal needs
2400 * - EEXIST If the attribute already exists and the flag
2401 * SMBC_XATTR_FLAG_CREAT was specified
2402 * - ENOATTR If the attribute does not exist and the flag
2403 * SMBC_XATTR_FLAG_REPLACE was specified
2404 * - EPERM Permission was denied.
2405 * - ENOTSUP The referenced file system does not support
2406 * extended attributes
2409 int smbc_lgetxattr(const char *url,
2410 const char *name,
2411 const void *value,
2412 size_t size);
2415 /**@ingroup attribute
2416 * Get extended attributes for a file.
2418 * @param fd A file descriptor associated with an open file (as
2419 * previously returned by smbc_open(), to get extended
2420 * attributes for.
2422 * @param name The name of an attribute to be retrieved. Names are of
2423 * one of the following forms:
2425 * system.nt_sec_desc.<attribute name>
2426 * system.nt_sec_desc.*
2427 * system.nt_sec_desc.*+
2429 * where <attribute name> is one of:
2431 * revision
2432 * owner
2433 * owner+
2434 * group
2435 * group+
2436 * acl:<name or sid>
2437 * acl+:<name or sid>
2439 * In the forms "system.nt_sec_desc.*" and
2440 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2441 * literal, i.e. the string is provided exactly as shown, and
2442 * the value parameter will return a complete security
2443 * descriptor with name:value pairs separated by tabs,
2444 * commas, or newlines (not spaces!).
2446 * The plus sign ('+') indicates that SIDs should be mapped
2447 * to names. Without the plus sign, SIDs are not mapped;
2448 * rather they are simply converted to a string format.
2450 * @param value A pointer to a buffer in which the value of the specified
2451 * attribute will be placed (unless size is zero).
2453 * @param size The size of the buffer pointed to by value. This parameter
2454 * may also be zero, in which case the size of the buffer
2455 * required to hold the attribute value will be returned,
2456 * but nothing will be placed into the value buffer.
2458 * @return 0 on success, < 0 on error with errno set:
2459 * - EINVAL The client library is not properly initialized
2460 * or one of the parameters is not of a correct
2461 * form
2462 * - ENOMEM No memory was available for internal needs
2463 * - EEXIST If the attribute already exists and the flag
2464 * SMBC_XATTR_FLAG_CREAT was specified
2465 * - ENOATTR If the attribute does not exist and the flag
2466 * SMBC_XATTR_FLAG_REPLACE was specified
2467 * - EPERM Permission was denied.
2468 * - ENOTSUP The referenced file system does not support
2469 * extended attributes
2472 int smbc_fgetxattr(int fd,
2473 const char *name,
2474 const void *value,
2475 size_t size);
2478 /**@ingroup attribute
2479 * Remove extended attributes for a file. This is used for modifying a file's
2480 * security descriptor (i.e. owner, group, and access control list)
2482 * @param url The smb url of the file or directory to remove the extended
2483 * attributes for.
2485 * @param name The name of an attribute to be removed. Names are of
2486 * one of the following forms:
2488 * system.nt_sec_desc.<attribute name>
2489 * system.nt_sec_desc.*
2490 * system.nt_sec_desc.*+
2492 * where <attribute name> is one of:
2494 * revision
2495 * owner
2496 * owner+
2497 * group
2498 * group+
2499 * acl:<name or sid>
2500 * acl+:<name or sid>
2502 * In the forms "system.nt_sec_desc.*" and
2503 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2504 * literal, i.e. the string is provided exactly as shown, and
2505 * the value parameter will return a complete security
2506 * descriptor with name:value pairs separated by tabs,
2507 * commas, or newlines (not spaces!).
2509 * The plus sign ('+') indicates that SIDs should be mapped
2510 * to names. Without the plus sign, SIDs are not mapped;
2511 * rather they are simply converted to a string format.
2513 * @return 0 on success, < 0 on error with errno set:
2514 * - EINVAL The client library is not properly initialized
2515 * - ENOMEM No memory was available for internal needs
2516 * - EPERM Permission was denied.
2517 * - ENOTSUP The referenced file system does not support
2518 * extended attributes
2521 int smbc_removexattr(const char *url,
2522 const char *name);
2525 /**@ingroup attribute
2526 * Remove extended attributes for a file. This is used for modifying a file's
2527 * security descriptor (i.e. owner, group, and access control list) The POSIX
2528 * function which this maps to would act on a symbolic link rather than acting
2529 * on what the symbolic link points to, but with no symbolic links in SMB file
2530 * systems, this function is functionally identical to smbc_removexattr().
2532 * @param url The smb url of the file or directory to remove the extended
2533 * attributes for.
2535 * @param name The name of an attribute to be removed. Names are of
2536 * one of the following forms:
2538 * system.nt_sec_desc.<attribute name>
2539 * system.nt_sec_desc.*
2540 * system.nt_sec_desc.*+
2542 * where <attribute name> is one of:
2544 * revision
2545 * owner
2546 * owner+
2547 * group
2548 * group+
2549 * acl:<name or sid>
2550 * acl+:<name or sid>
2552 * In the forms "system.nt_sec_desc.*" and
2553 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2554 * literal, i.e. the string is provided exactly as shown, and
2555 * the value parameter will return a complete security
2556 * descriptor with name:value pairs separated by tabs,
2557 * commas, or newlines (not spaces!).
2559 * The plus sign ('+') indicates that SIDs should be mapped
2560 * to names. Without the plus sign, SIDs are not mapped;
2561 * rather they are simply converted to a string format.
2563 * @return 0 on success, < 0 on error with errno set:
2564 * - EINVAL The client library is not properly initialized
2565 * - ENOMEM No memory was available for internal needs
2566 * - EPERM Permission was denied.
2567 * - ENOTSUP The referenced file system does not support
2568 * extended attributes
2571 int smbc_lremovexattr(const char *url,
2572 const char *name);
2575 /**@ingroup attribute
2576 * Remove extended attributes for a file. This is used for modifying a file's
2577 * security descriptor (i.e. owner, group, and access control list)
2579 * @param fd A file descriptor associated with an open file (as
2580 * previously returned by smbc_open(), to get extended
2581 * attributes for.
2583 * @param name The name of an attribute to be removed. Names are of
2584 * one of the following forms:
2586 * system.nt_sec_desc.<attribute name>
2587 * system.nt_sec_desc.*
2588 * system.nt_sec_desc.*+
2590 * where <attribute name> is one of:
2592 * revision
2593 * owner
2594 * owner+
2595 * group
2596 * group+
2597 * acl:<name or sid>
2598 * acl+:<name or sid>
2600 * In the forms "system.nt_sec_desc.*" and
2601 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2602 * literal, i.e. the string is provided exactly as shown, and
2603 * the value parameter will return a complete security
2604 * descriptor with name:value pairs separated by tabs,
2605 * commas, or newlines (not spaces!).
2607 * The plus sign ('+') indicates that SIDs should be mapped
2608 * to names. Without the plus sign, SIDs are not mapped;
2609 * rather they are simply converted to a string format.
2611 * @return 0 on success, < 0 on error with errno set:
2612 * - EINVAL The client library is not properly initialized
2613 * - ENOMEM No memory was available for internal needs
2614 * - EPERM Permission was denied.
2615 * - ENOTSUP The referenced file system does not support
2616 * extended attributes
2619 int smbc_fremovexattr(int fd,
2620 const char *name);
2623 /**@ingroup attribute
2624 * List the supported extended attribute names associated with a file
2626 * @param url The smb url of the file or directory to list the extended
2627 * attributes for.
2629 * @param list A pointer to a buffer in which the list of attributes for
2630 * the specified file or directory will be placed (unless
2631 * size is zero).
2633 * @param size The size of the buffer pointed to by list. This parameter
2634 * may also be zero, in which case the size of the buffer
2635 * required to hold all of the attribute names will be
2636 * returned, but nothing will be placed into the list buffer.
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
2645 * @note This function always returns all attribute names supported
2646 * by NT file systems, regardless of whether the referenced
2647 * file system supports extended attributes (e.g. a Windows
2648 * 2000 machine supports extended attributes if NTFS is used,
2649 * but not if FAT is used, and Windows 98 doesn't support
2650 * extended attributes at all. Whether this is a feature or
2651 * a bug is yet to be decided.
2653 int smbc_listxattr(const char *url,
2654 char *list,
2655 size_t size);
2657 /**@ingroup attribute
2658 * List the supported extended attribute names associated with a file The
2659 * POSIX function which this maps to would act on a symbolic link rather than
2660 * acting on what the symbolic link points to, but with no symbolic links in
2661 * SMB file systems, this function is functionally identical to
2662 * smbc_listxattr().
2664 * @param url The smb url of the file or directory to list the extended
2665 * attributes for.
2667 * @param list A pointer to a buffer in which the list of attributes for
2668 * the specified file or directory will be placed (unless
2669 * size is zero).
2671 * @param size The size of the buffer pointed to by list. This parameter
2672 * may also be zero, in which case the size of the buffer
2673 * required to hold all of the attribute names will be
2674 * returned, but nothing will be placed into the list buffer.
2676 * @return 0 on success, < 0 on error with errno set:
2677 * - EINVAL The client library is not properly initialized
2678 * - ENOMEM No memory was available for internal needs
2679 * - EPERM Permission was denied.
2680 * - ENOTSUP The referenced file system does not support
2681 * extended attributes
2683 * @note This function always returns all attribute names supported
2684 * by NT file systems, regardless of whether the referenced
2685 * file system supports extended attributes (e.g. a Windows
2686 * 2000 machine supports extended attributes if NTFS is used,
2687 * but not if FAT is used, and Windows 98 doesn't support
2688 * extended attributes at all. Whether this is a feature or
2689 * a bug is yet to be decided.
2691 int smbc_llistxattr(const char *url,
2692 char *list,
2693 size_t size);
2695 /**@ingroup attribute
2696 * List the supported extended attribute names associated with a file
2698 * @param fd A file descriptor associated with an open file (as
2699 * previously returned by smbc_open(), to get extended
2700 * attributes for.
2702 * @param list A pointer to a buffer in which the list of attributes for
2703 * the specified file or directory will be placed (unless
2704 * size is zero).
2706 * @param size The size of the buffer pointed to by list. This parameter
2707 * may also be zero, in which case the size of the buffer
2708 * required to hold all of the attribute names will be
2709 * returned, but nothing will be placed into the list buffer.
2711 * @return 0 on success, < 0 on error with errno set:
2712 * - EINVAL The client library is not properly initialized
2713 * - ENOMEM No memory was available for internal needs
2714 * - EPERM Permission was denied.
2715 * - ENOTSUP The referenced file system does not support
2716 * extended attributes
2718 * @note This function always returns all attribute names supported
2719 * by NT file systems, regardless of whether the referenced
2720 * file system supports extended attributes (e.g. a Windows
2721 * 2000 machine supports extended attributes if NTFS is used,
2722 * but not if FAT is used, and Windows 98 doesn't support
2723 * extended attributes at all. Whether this is a feature or
2724 * a bug is yet to be decided.
2726 int smbc_flistxattr(int fd,
2727 char *list,
2728 size_t size);
2730 /**@ingroup print
2731 * Print a file given the name in fname. It would be a URL ...
2733 * @param fname The URL of a file on a remote SMB server that the
2734 * caller wants printed
2736 * @param printq The URL of the print share to print the file to.
2738 * @return 0 on success, < 0 on error with errno set:
2740 * - EINVAL fname or printq was NULL or smbc_init not
2741 * not called.
2742 * and errors returned by smbc_open
2745 int smbc_print_file(const char *fname, const char *printq);
2747 /**@ingroup print
2748 * Open a print file that can be written to by other calls. This simply
2749 * does an smbc_open call after checking if there is a file name on the
2750 * URI. If not, a temporary name is added ...
2752 * @param fname The URL of the print share to print to?
2754 * @returns A file handle for the print file if successful.
2755 * Returns -1 if an error ocurred and errno has the values
2756 * - EINVAL fname was NULL or smbc_init not called.
2757 * - all errors returned by smbc_open
2760 int smbc_open_print_job(const char *fname);
2762 /**@ingroup print
2763 * List the print jobs on a print share, for the moment, pass a callback
2765 * @param purl The url of the print share to list the jobs of
2767 * @param fn Callback function the receives printjob info
2769 * @return 0 on success, < 0 on error with errno set:
2770 * - EINVAL fname was NULL or smbc_init not called
2771 * - EACCES ???
2773 int smbc_list_print_jobs(const char *purl, smbc_list_print_job_fn fn);
2775 /**@ingroup print
2776 * Delete a print job
2778 * @param purl Url of the print share
2780 * @param id The id of the job to delete
2782 * @return 0 on success, < 0 on error with errno set:
2783 * - EINVAL fname was NULL or smbc_init not called
2785 * @todo what errno values are possible here?
2787 int smbc_unlink_print_job(const char *purl, int id);
2789 /**@ingroup callback
2790 * Remove a server from the cached server list it's unused.
2792 * @param context pointer to smb context
2794 * @param srv pointer to server to remove
2796 * @return On success, 0 is returned. 1 is returned if the server could not
2797 * be removed. Also useable outside libsmbclient.
2799 int smbc_remove_unused_server(SMBCCTX * context, SMBCSRV * srv);
2801 #ifdef __cplusplus
2803 #endif
2805 /**@ingroup directory
2806 * Convert strings of %xx to their single character equivalent.
2808 * @param dest A pointer to a buffer in which the resulting decoded
2809 * string should be placed. This may be a pointer to the
2810 * same buffer as src_segment.
2812 * @param src A pointer to the buffer containing the URL to be decoded.
2813 * Any %xx sequences herein are converted to their single
2814 * character equivalent. Each 'x' must be a valid hexadecimal
2815 * digit, or that % sequence is left undecoded.
2817 * @param max_dest_len
2818 * The size of the buffer pointed to by dest_segment.
2820 * @return The number of % sequences which could not be converted
2821 * due to lack of two following hexadecimal digits.
2823 #ifdef __cplusplus
2824 extern "C" {
2825 #endif
2827 smbc_urldecode(char *dest, char * src, size_t max_dest_len);
2828 #ifdef __cplusplus
2830 #endif
2834 * Convert any characters not specifically allowed in a URL into their %xx
2835 * equivalent.
2837 * @param dest A pointer to a buffer in which the resulting encoded
2838 * string should be placed. Unlike smbc_urldecode(), this
2839 * must be a buffer unique from src.
2841 * @param src A pointer to the buffer containing the string to be encoded.
2842 * Any character not specifically allowed in a URL is converted
2843 * into its hexadecimal value and encoded as %xx.
2845 * @param max_dest_len
2846 * The size of the buffer pointed to by dest_segment.
2848 * @returns The remaining buffer length.
2850 #ifdef __cplusplus
2851 extern "C" {
2852 #endif
2854 smbc_urlencode(char * dest, char * src, int max_dest_len);
2855 #ifdef __cplusplus
2857 #endif
2860 /**@ingroup directory
2861 * Return the version of the linked Samba code, and thus the version of the
2862 * libsmbclient code.
2864 * @return The version string.
2866 #ifdef __cplusplus
2867 extern "C" {
2868 #endif
2869 const char *
2870 smbc_version(void);
2871 #ifdef __cplusplus
2873 #endif
2875 /**@ingroup misc
2876 * Set the users credentials globally so they can be used for DFS
2877 * referrals. Probably best to use this function in the smbc_get_auth_data_fn
2878 * callback.
2880 * @param workgroup Workgroup of the user.
2882 * @param user Username of user.
2884 * @param password Password of user.
2886 * @param use_kerberos Whether to use Kerberos
2888 * @param signing_state One of these strings (all equivalents on same line):
2889 * "off", "no", "false"
2890 * "on", "yes", "true", "auto"
2891 * "force", "required", "forced"
2894 void
2895 smbc_set_credentials(const char *workgroup,
2896 const char *user,
2897 const char *password,
2898 smbc_bool use_kerberos,
2899 const char *signing_state);
2902 * Wrapper around smbc_set_credentials.
2903 * Used to set correct credentials that will
2904 * be used to connect to DFS target share
2905 * in libsmbclient
2908 void
2909 smbc_set_credentials_with_fallback(SMBCCTX *ctx,
2910 const char *workgroup,
2911 const char *user,
2912 const char *password);
2916 * @ingroup threads
2918 * Initialize for threads using the Posix Threads (pthread)
2919 * implementation. This is a built-in implementation, avoiding the need to
2920 * implement the component functions of the thread interface. If this function
2921 * is used, it is not necessary to call smbc_thread_impl().
2923 * @return {void}
2925 void
2926 smbc_thread_posix(void);
2929 * @ingroup threads
2931 * Initialize for an arbitrary thread implementation. The caller should
2932 * provide, as parameters, pointers to functions to implement the requisite
2933 * low-level thread functionality. A function must be provided for each
2934 * parameter; none may be null.
2936 * If the thread implementation is POSIX Threads (pthreads), then the much
2937 * simpler smbc_thread_pthread() function may be used instead of this one.
2939 * @param create_mutex
2940 * Create a mutex. This function should expect three parameters: lockname,
2941 * pplock, and location. It should create a unique mutex for each unique
2942 * lockname it is provided, and return the mutex identifier in *pplock. The
2943 * location parameter can be used for debugging, as it contains the
2944 * compiler-provided __location__ of the call.
2946 * @param destroy_mutex
2947 * Destroy a mutex. This function should expect two parameters: plock and
2948 * location. It should destroy the mutex associated with the identifier
2949 * plock. The location parameter can be used for debugging, as it contains
2950 * the compiler-provided __location__ of the call.
2952 * @param lock_mutex
2953 * Lock a mutex. This function should expect three parameters: plock,
2954 * lock_type, and location. The mutex aassociated with identifier plock
2955 * should be locked if lock_type is 1, and unlocked if lock_type is 2. The
2956 * location parameter can be used for debugging, as it contains the
2957 * compiler-provided __location__ of the call.
2959 * @param create_tls
2960 * Create thread local storage. This function should expect three
2961 * parameters: keyname, ppkey, and location. It should allocate an
2962 * implementation-specific amount of memory and assign the pointer to that
2963 * allocated memory to *ppkey. The location parameter can be used for
2964 * debugging, as it contains the compiler-provided __location__ of the
2965 * call. This function should return 0 upon success, non-zero upon failure.
2967 * @param destroy_tls
2968 * Destroy thread local storage. This function should expect two parameters:
2969 * ppkey and location. The ppkey parameter points to a variable containing a
2970 * thread local storage key previously provided by the create_tls
2971 * function. The location parameter can be used for debugging, as it
2972 * contains the compiler-provided __location__ of the call.
2974 * @param set_tls
2975 * Set a thread local storage variable's value. This function should expect
2976 * three parameters: pkey, pval, and location. The pkey parameter is a
2977 * thread local storage key previously provided by the create_tls
2978 * function. The (void *) pval parameter contains the value to be placed in
2979 * the thread local storage variable identified by pkey. The location
2980 * parameter can be used for debugging, as it contains the compiler-provided
2981 * __location__ of the call. This function should return 0 upon success;
2982 * non-zero otherwise.
2984 * @param get_tls
2985 * Retrieve a thread local storage variable's value. This function should
2986 * expect two parameters: pkey and location. The pkey parameter is a thread
2987 * local storage key previously provided by the create_tls function, and
2988 * which has previously been used in a call to the set_tls function to
2989 * initialize a thread local storage variable. The location parameter can be
2990 * used for debugging, as it contains the compiler-provided __location__ of
2991 * the call. This function should return the (void *) value stored in the
2992 * variable identified by pkey.
2994 * @return {void}
2996 void
2997 smbc_thread_impl(
2998 /* Mutex functions. */
2999 int (*create_mutex)(const char *lockname,
3000 void **pplock,
3001 const char *location),
3002 void (*destroy_mutex)(void *plock,
3003 const char *location),
3004 int (*lock_mutex)(void *plock,
3005 int lock_type,
3006 const char *location),
3008 /* Thread local storage. */
3009 int (*create_tls)(const char *keyname,
3010 void **ppkey,
3011 const char *location),
3012 void (*destroy_tls)(void **ppkey,
3013 const char *location),
3014 int (*set_tls)(void *pkey,
3015 const void *pval,
3016 const char *location),
3017 void *(*get_tls)(void *pkey,
3018 const char *location)
3024 * @ingroup structure
3025 * Structure that contains a client context information
3026 * This structure is known as SMBCCTX
3028 * DO NOT DIRECTLY MANIPULATE THE CONTEXT STRUCTURE! The data in the context
3029 * structure should all be considered private to the library. It remains here
3030 * only for backward compatibility.
3032 * See the comments herein for use of the setter and getter functions which
3033 * should now be used for manipulating these values. New features, functions,
3034 * etc., are not added here but rather in _internal where they are not
3035 * directly visible to applications. This makes it much easier to maintain
3036 * ABI compatibility.
3038 struct _SMBCCTX
3041 * debug level
3043 * DEPRECATED:
3044 * Use smbc_getDebug() and smbc_setDebug()
3046 int debug DEPRECATED_SMBC_INTERFACE;
3049 * netbios name used for making connections
3051 * DEPRECATED:
3052 * Use smbc_getNetbiosName() and smbc_setNetbiosName()
3054 char * netbios_name DEPRECATED_SMBC_INTERFACE;
3057 * workgroup name used for making connections
3059 * DEPRECATED:
3060 * Use smbc_getWorkgroup() and smbc_setWorkgroup()
3062 char * workgroup DEPRECATED_SMBC_INTERFACE;
3065 * username used for making connections
3067 * DEPRECATED:
3068 * Use smbc_getUser() and smbc_setUser()
3070 char * user DEPRECATED_SMBC_INTERFACE;
3073 * timeout used for waiting on connections / response data (in
3074 * milliseconds)
3076 * DEPRECATED:
3077 * Use smbc_getTimeout() and smbc_setTimeout()
3079 int timeout DEPRECATED_SMBC_INTERFACE;
3082 * callable functions for files:
3083 * For usage and return values see the SMBC_* functions
3085 * DEPRECATED:
3087 * Use smbc_getFunction*() and smbc_setFunction*(), e.g.
3088 * smbc_getFunctionOpen(), smbc_setFunctionUnlink(), etc.
3090 smbc_open_fn open DEPRECATED_SMBC_INTERFACE;
3091 smbc_creat_fn creat DEPRECATED_SMBC_INTERFACE;
3092 smbc_read_fn read DEPRECATED_SMBC_INTERFACE;
3093 smbc_write_fn write DEPRECATED_SMBC_INTERFACE;
3094 smbc_unlink_fn unlink DEPRECATED_SMBC_INTERFACE;
3095 smbc_rename_fn rename DEPRECATED_SMBC_INTERFACE;
3096 smbc_lseek_fn lseek DEPRECATED_SMBC_INTERFACE;
3097 smbc_stat_fn stat DEPRECATED_SMBC_INTERFACE;
3098 smbc_fstat_fn fstat DEPRECATED_SMBC_INTERFACE;
3099 #if 0 /* internal */
3100 smbc_ftruncate_fn ftruncate_fn;
3101 #endif
3102 smbc_close_fn close_fn DEPRECATED_SMBC_INTERFACE;
3103 smbc_opendir_fn opendir DEPRECATED_SMBC_INTERFACE;
3104 smbc_closedir_fn closedir DEPRECATED_SMBC_INTERFACE;
3105 smbc_readdir_fn readdir DEPRECATED_SMBC_INTERFACE;
3106 smbc_readdirplus_fn readdirplus DEPRECATED_SMBC_INTERFACE;
3107 smbc_getdents_fn getdents DEPRECATED_SMBC_INTERFACE;
3108 smbc_mkdir_fn mkdir DEPRECATED_SMBC_INTERFACE;
3109 smbc_rmdir_fn rmdir DEPRECATED_SMBC_INTERFACE;
3110 smbc_telldir_fn telldir DEPRECATED_SMBC_INTERFACE;
3111 smbc_lseekdir_fn lseekdir DEPRECATED_SMBC_INTERFACE;
3112 smbc_fstatdir_fn fstatdir DEPRECATED_SMBC_INTERFACE;
3113 smbc_chmod_fn chmod DEPRECATED_SMBC_INTERFACE;
3114 smbc_utimes_fn utimes DEPRECATED_SMBC_INTERFACE;
3115 smbc_setxattr_fn setxattr DEPRECATED_SMBC_INTERFACE;
3116 smbc_getxattr_fn getxattr DEPRECATED_SMBC_INTERFACE;
3117 smbc_removexattr_fn removexattr DEPRECATED_SMBC_INTERFACE;
3118 smbc_listxattr_fn listxattr DEPRECATED_SMBC_INTERFACE;
3120 /* Printing-related functions */
3121 smbc_print_file_fn print_file DEPRECATED_SMBC_INTERFACE;
3122 smbc_open_print_job_fn open_print_job DEPRECATED_SMBC_INTERFACE;
3123 smbc_list_print_jobs_fn list_print_jobs DEPRECATED_SMBC_INTERFACE;
3124 smbc_unlink_print_job_fn unlink_print_job DEPRECATED_SMBC_INTERFACE;
3127 ** Callbacks
3129 * DEPRECATED:
3131 * See the comment above each field, for the getter and setter
3132 * functions that should now be used.
3134 struct _smbc_callbacks
3137 * authentication function callback: called upon auth requests
3139 * DEPRECATED:
3140 * Use smbc_getFunctionAuthData(), smbc_setFunctionAuthData()
3142 smbc_get_auth_data_fn auth_fn DEPRECATED_SMBC_INTERFACE;
3145 * check if a server is still good
3147 * DEPRECATED:
3148 * Use smbc_getFunctionCheckServer(),
3149 * smbc_setFunctionCheckServer()
3151 smbc_check_server_fn check_server_fn DEPRECATED_SMBC_INTERFACE;
3154 * remove a server if unused
3156 * DEPRECATED:
3157 * Use smbc_getFunctionRemoveUnusedServer(),
3158 * smbc_setFunctionCheckServer()
3160 smbc_remove_unused_server_fn remove_unused_server_fn DEPRECATED_SMBC_INTERFACE;
3162 /** Cache subsystem
3164 * For an example cache system see
3165 * samba/source/libsmb/libsmb_cache.c
3167 * Cache subsystem * functions follow.
3171 * server cache addition
3173 * DEPRECATED:
3174 * Use smbc_getFunctionAddCachedServer(),
3175 * smbc_setFunctionAddCachedServer()
3177 smbc_add_cached_srv_fn add_cached_srv_fn DEPRECATED_SMBC_INTERFACE;
3180 * server cache lookup
3182 * DEPRECATED:
3183 * Use smbc_getFunctionGetCachedServer(),
3184 * smbc_setFunctionGetCachedServer()
3186 smbc_get_cached_srv_fn get_cached_srv_fn DEPRECATED_SMBC_INTERFACE;
3189 * server cache removal
3191 * DEPRECATED:
3192 * Use smbc_getFunctionRemoveCachedServer(),
3193 * smbc_setFunctionRemoveCachedServer()
3195 smbc_remove_cached_srv_fn remove_cached_srv_fn DEPRECATED_SMBC_INTERFACE;
3198 * server cache purging, try to remove all cached servers
3199 * (disconnect)
3201 * DEPRECATED:
3202 * Use smbc_getFunctionPurgeCachedServers(),
3203 * smbc_setFunctionPurgeCachedServers()
3205 smbc_purge_cached_fn purge_cached_fn DEPRECATED_SMBC_INTERFACE;
3206 } callbacks;
3209 * Space where the private data of the server cache used to be
3211 * DEPRECATED:
3212 * Use smbc_getServerCacheData(), smbc_setServerCacheData()
3214 void * reserved DEPRECATED_SMBC_INTERFACE;
3217 * Very old configuration options.
3219 * DEPRECATED:
3220 * Use one of the following functions instead:
3221 * smbc_setOptionUseKerberos()
3222 * smbc_getOptionUseKerberos()
3223 * smbc_setOptionFallbackAfterKerberos()
3224 * smbc_getOptionFallbackAfterKerberos()
3225 * smbc_setOptionNoAutoAnonymousLogin()
3226 * smbc_getOptionNoAutoAnonymousLogin()
3228 int flags DEPRECATED_SMBC_INTERFACE;
3231 * user options selections that apply to this session
3233 * NEW OPTIONS ARE NOT ADDED HERE!
3235 * DEPRECATED:
3236 * To set and retrieve options, use the smbc_setOption*() and
3237 * smbc_getOption*() functions.
3239 struct _smbc_options {
3240 int browse_max_lmb_count DEPRECATED_SMBC_INTERFACE;
3241 int urlencode_readdir_entries DEPRECATED_SMBC_INTERFACE;
3242 int one_share_per_server DEPRECATED_SMBC_INTERFACE;
3243 } options DEPRECATED_SMBC_INTERFACE;
3245 /** INTERNAL DATA
3246 * do _NOT_ touch this from your program !
3248 struct SMBC_internal_data * internal;
3252 #endif /* SMBCLIENT_H_INCLUDED */