libnet: Add NULL checks to py_net_finddc
[Samba.git] / source3 / include / libsmbclient.h
blob38ba451a548f3d71ddba61fff20245f384d5177b
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];
133 * Logging callback function
135 typedef void (*smbc_debug_callback_fn)(void *private_ptr, int level, const char *msg);
138 * Flags for smbc_setxattr()
139 * Specify a bitwise OR of these, or 0 to add or replace as necessary
141 #define SMBC_XATTR_FLAG_CREATE 0x1 /* fail if attr already exists */
142 #define SMBC_XATTR_FLAG_REPLACE 0x2 /* fail if attr does not exist */
146 * Mappings of the DOS mode bits, as returned by smbc_getxattr() when the
147 * attribute name "system.dos_attr.mode" (or "system.dos_attr.*" or
148 * "system.*") is specified.
150 #define SMBC_DOS_MODE_READONLY 0x01
151 #define SMBC_DOS_MODE_HIDDEN 0x02
152 #define SMBC_DOS_MODE_SYSTEM 0x04
153 #define SMBC_DOS_MODE_VOLUME_ID 0x08
154 #define SMBC_DOS_MODE_DIRECTORY 0x10
155 #define SMBC_DOS_MODE_ARCHIVE 0x20
158 * Valid values for the option "open_share_mode", when calling
159 * smbc_setOptionOpenShareMode()
161 typedef enum smbc_share_mode
163 SMBC_SHAREMODE_DENY_DOS = 0,
164 SMBC_SHAREMODE_DENY_ALL = 1,
165 SMBC_SHAREMODE_DENY_WRITE = 2,
166 SMBC_SHAREMODE_DENY_READ = 3,
167 SMBC_SHAREMODE_DENY_NONE = 4,
168 SMBC_SHAREMODE_DENY_FCB = 7
169 } smbc_share_mode;
173 * Values for option SMB Encryption Level, as set and retrieved with
174 * smbc_setOptionSmbEncryptionLevel() and smbc_getOptionSmbEncryptionLevel()
176 typedef enum smbc_smb_encrypt_level
178 SMBC_ENCRYPTLEVEL_NONE = 0,
179 SMBC_ENCRYPTLEVEL_REQUEST = 1,
180 SMBC_ENCRYPTLEVEL_REQUIRE = 2
181 } smbc_smb_encrypt_level;
185 * Capabilities set in the f_flag field of struct statvfs, from
186 * smbc_statvfs(). These may be OR-ed together to reflect a full set of
187 * available capabilities.
189 typedef enum smbc_vfs_feature
191 /* Defined by POSIX or in Linux include files (low-order bits) */
192 SMBC_VFS_FEATURE_RDONLY = (1 << 0),
194 /* Specific to libsmbclient (high-order bits) */
195 SMBC_VFS_FEATURE_DFS = (1 << 28),
196 SMBC_VFS_FEATURE_CASE_INSENSITIVE = (1 << 29),
197 SMBC_VFS_FEATURE_NO_UNIXCIFS = (1 << 30)
198 } smbc_vfs_feature;
200 typedef int smbc_bool;
203 #ifndef ENOATTR
204 # define ENOATTR ENOENT /* No such attribute */
205 #endif
210 /**@ingroup structure
211 * Structure that represents a print job.
214 #ifndef _CLIENT_H
215 struct print_job_info
217 /** numeric ID of the print job
219 unsigned short id;
221 /** represents print job priority (lower numbers mean higher priority)
223 unsigned short priority;
225 /** Size of the print job
227 size_t size;
229 /** Name of the user that owns the print job
231 char user[128];
233 /** Name of the print job. This will have no name if an anonymous print
234 * file was opened. Ie smb://server/printer
236 char name[128];
238 /** Time the print job was spooled
240 time_t t;
242 #endif /* _CLIENT_H */
245 /**@ingroup structure
246 * Server handle
248 typedef struct _SMBCSRV SMBCSRV;
250 /**@ingroup structure
251 * File or directory handle
253 typedef struct _SMBCFILE SMBCFILE;
255 /**@ingroup structure
256 * File or directory handle
258 typedef struct _SMBCCTX SMBCCTX;
262 * Flags for SMBCCTX->flags
264 * NEW CODE SHOULD NOT DIRECTLY MANIPULATE THE CONTEXT STRUCTURE.
265 * Instead, use:
266 * smbc_setOptionUseKerberos()
267 * smbc_getOptionUseKerberos()
268 * smbc_setOptionFallbackAfterKerberos()
269 * smbc_getOptionFallbackAFterKerberos()
270 * smbc_setOptionNoAutoAnonymousLogin()
271 * smbc_getOptionNoAutoAnonymousLogin()
272 * smbc_setOptionUseCCache()
273 * smbc_getOptionUseCCache()
275 # define SMB_CTX_FLAG_USE_KERBEROS (1 << 0)
276 # define SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS (1 << 1)
277 # define SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON (1 << 2)
278 # define SMB_CTX_FLAG_USE_CCACHE (1 << 3)
282 /**@ingroup callback
283 * Authentication callback function type (traditional method)
285 * Type for the the authentication function called by the library to
286 * obtain authentication credentials
288 * For kerberos support the function should just be called without
289 * prompting the user for credentials. Which means a simple 'return'
290 * should work. Take a look at examples/libsmbclient/get_auth_data_fn.h
291 * and examples/libsmbclient/testbrowse.c.
293 * @param srv Server being authenticated to
295 * @param shr Share being authenticated to
297 * @param wg Pointer to buffer containing a "hint" for the
298 * workgroup to be authenticated. Should be filled in
299 * with the correct workgroup if the hint is wrong.
301 * @param wglen The size of the workgroup buffer in bytes
303 * @param un Pointer to buffer containing a "hint" for the
304 * user name to be use for authentication. Should be
305 * filled in with the correct workgroup if the hint is
306 * wrong.
308 * @param unlen The size of the username buffer in bytes
310 * @param pw Pointer to buffer containing to which password
311 * copied
313 * @param pwlen The size of the password buffer in bytes
316 typedef void (*smbc_get_auth_data_fn)(const char *srv,
317 const char *shr,
318 char *wg, int wglen,
319 char *un, int unlen,
320 char *pw, int pwlen);
321 /**@ingroup callback
322 * Authentication callback function type (method that includes context)
324 * Type for the the authentication function called by the library to
325 * obtain authentication credentials
327 * For kerberos support the function should just be called without
328 * prompting the user for credentials. Which means a simple 'return'
329 * should work. Take a look at examples/libsmbclient/get_auth_data_fn.h
330 * and examples/libsmbclient/testbrowse.c.
332 * @param c Pointer to the smb context
334 * @param srv Server being authenticated to
336 * @param shr Share being authenticated to
338 * @param wg Pointer to buffer containing a "hint" for the
339 * workgroup to be authenticated. Should be filled in
340 * with the correct workgroup if the hint is wrong.
342 * @param wglen The size of the workgroup buffer in bytes
344 * @param un Pointer to buffer containing a "hint" for the
345 * user name to be use for authentication. Should be
346 * filled in with the correct workgroup if the hint is
347 * wrong.
349 * @param unlen The size of the username buffer in bytes
351 * @param pw Pointer to buffer containing to which password
352 * copied
354 * @param pwlen The size of the password buffer in bytes
357 typedef void (*smbc_get_auth_data_with_context_fn)(SMBCCTX *c,
358 const char *srv,
359 const char *shr,
360 char *wg, int wglen,
361 char *un, int unlen,
362 char *pw, int pwlen);
365 /**@ingroup callback
366 * Print job info callback function type.
368 * @param i pointer to print job information structure
371 typedef void (*smbc_list_print_job_fn)(struct print_job_info *i);
374 /**@ingroup callback
375 * Check if a server is still good
377 * @param c pointer to smb context
379 * @param srv pointer to server to check
381 * @return 0 when connection is good. 1 on error.
384 typedef int (*smbc_check_server_fn)(SMBCCTX * c, SMBCSRV *srv);
386 /**@ingroup callback
387 * Remove a server if unused
389 * @param c pointer to smb context
391 * @param srv pointer to server to remove
393 * @return 0 on success. 1 on failure.
396 typedef int (*smbc_remove_unused_server_fn)(SMBCCTX * c, SMBCSRV *srv);
399 /**@ingroup callback
400 * Add a server to the cache system
402 * @param c pointer to smb context
404 * @param srv pointer to server to add
406 * @param server server name
408 * @param share share name
410 * @param workgroup workgroup used to connect
412 * @param username username used to connect
414 * @return 0 on success. 1 on failure.
417 typedef int (*smbc_add_cached_srv_fn) (SMBCCTX * c, SMBCSRV *srv,
418 const char * server, const char * share,
419 const char * workgroup, const char * username);
421 /**@ingroup callback
422 * Look up a server in the cache system
424 * @param c pointer to smb context
426 * @param server server name to match
428 * @param share share name to match
430 * @param workgroup workgroup to match
432 * @param username username to match
434 * @return pointer to SMBCSRV on success. NULL on failure.
437 typedef SMBCSRV * (*smbc_get_cached_srv_fn) (SMBCCTX * c, const char * server,
438 const char * share, const char * workgroup,
439 const char * username);
441 /**@ingroup callback
442 * Check if a server is still good
444 * @param c pointer to smb context
446 * @param srv pointer to server to remove
448 * @return 0 when found and removed. 1 on failure.
451 typedef int (*smbc_remove_cached_srv_fn)(SMBCCTX * c, SMBCSRV *srv);
454 /**@ingroup callback
455 * Try to remove all servers from the cache system and disconnect
457 * @param c pointer to smb context
459 * @return 0 when found and removed. 1 on failure.
462 typedef int (*smbc_purge_cached_fn) (SMBCCTX * c);
466 /*****************************************
467 * Getters and setters for CONFIGURATION *
468 *****************************************/
470 /** Get the debug level */
472 smbc_getDebug(SMBCCTX *c);
474 /** Set the debug level */
475 void
476 smbc_setDebug(SMBCCTX *c, int debug);
479 * set log callback function to capture logs from libsmbclient, this
480 * is applied at global level
482 void
483 smbc_setLogCallback(SMBCCTX *c, void *private_ptr,
484 smbc_debug_callback_fn fn);
486 /** Get the netbios name used for making connections */
487 char *
488 smbc_getNetbiosName(SMBCCTX *c);
490 /** Set the netbios name used for making connections */
491 void
492 smbc_setNetbiosName(SMBCCTX *c, char * netbios_name);
494 /** Get the workgroup used for making connections */
495 char *
496 smbc_getWorkgroup(SMBCCTX *c);
498 /** Set the workgroup used for making connections */
499 void smbc_setWorkgroup(SMBCCTX *c, char * workgroup);
501 /** Get the username used for making connections */
502 char *
503 smbc_getUser(SMBCCTX *c);
505 /** Set the username used for making connections */
506 void
507 smbc_setUser(SMBCCTX *c, const char *user);
510 * Get the timeout used for waiting on connections and response data
511 * (in milliseconds)
514 smbc_getTimeout(SMBCCTX *c);
517 * Set the timeout used for waiting on connections and response data
518 * (in milliseconds)
520 void
521 smbc_setTimeout(SMBCCTX *c, int timeout);
525 * Get the TCP port used to connect (0 means default).
527 uint16_t
528 smbc_getPort(SMBCCTX *c);
531 * Set the TCP port used to connect (0 means default).
533 void
534 smbc_setPort(SMBCCTX *c, uint16_t port);
538 /***********************************
539 * Getters and setters for OPTIONS *
540 ***********************************/
542 /** Get whether to log to standard error instead of standard output */
543 smbc_bool
544 smbc_getOptionDebugToStderr(SMBCCTX *c);
546 /** Set whether to log to standard error instead of standard output */
547 void
548 smbc_setOptionDebugToStderr(SMBCCTX *c, smbc_bool b);
551 * Get whether to use new-style time attribute names, e.g. WRITE_TIME rather
552 * than the old-style names such as M_TIME. This allows also setting/getting
553 * CREATE_TIME which was previously unimplemented. (Note that the old C_TIME
554 * was supposed to be CHANGE_TIME but was confused and sometimes referred to
555 * CREATE_TIME.)
557 smbc_bool
558 smbc_getOptionFullTimeNames(SMBCCTX *c);
561 * Set whether to use new-style time attribute names, e.g. WRITE_TIME rather
562 * than the old-style names such as M_TIME. This allows also setting/getting
563 * CREATE_TIME which was previously unimplemented. (Note that the old C_TIME
564 * was supposed to be CHANGE_TIME but was confused and sometimes referred to
565 * CREATE_TIME.)
567 void
568 smbc_setOptionFullTimeNames(SMBCCTX *c, smbc_bool b);
571 * Get the share mode to use for files opened with SMBC_open_ctx(). The
572 * default is SMBC_SHAREMODE_DENY_NONE.
574 smbc_share_mode
575 smbc_getOptionOpenShareMode(SMBCCTX *c);
578 * Set the share mode to use for files opened with SMBC_open_ctx(). The
579 * default is SMBC_SHAREMODE_DENY_NONE.
581 void
582 smbc_setOptionOpenShareMode(SMBCCTX *c, smbc_share_mode share_mode);
584 /** Retrieve a previously saved user data handle */
585 void *
586 smbc_getOptionUserData(SMBCCTX *c);
588 /** Save a user data handle */
589 void
590 smbc_setOptionUserData(SMBCCTX *c, void *user_data);
592 /** Get the encoded value for encryption level. */
593 smbc_smb_encrypt_level
594 smbc_getOptionSmbEncryptionLevel(SMBCCTX *c);
596 /** Set the encoded value for encryption level. */
597 void
598 smbc_setOptionSmbEncryptionLevel(SMBCCTX *c, smbc_smb_encrypt_level level);
601 * Get whether to treat file names as case-sensitive if we can't determine
602 * when connecting to the remote share whether the file system is case
603 * sensitive. This defaults to FALSE since it's most likely that if we can't
604 * retrieve the file system attributes, it's a very old file system that does
605 * not support case sensitivity.
607 smbc_bool
608 smbc_getOptionCaseSensitive(SMBCCTX *c);
611 * Set whether to treat file names as case-sensitive if we can't determine
612 * when connecting to the remote share whether the file system is case
613 * sensitive. This defaults to FALSE since it's most likely that if we can't
614 * retrieve the file system attributes, it's a very old file system that does
615 * not support case sensitivity.
617 void
618 smbc_setOptionCaseSensitive(SMBCCTX *c, smbc_bool b);
622 * Get from how many local master browsers should the list of workgroups be
623 * retrieved. It can take up to 12 minutes or longer after a server becomes a
624 * local master browser, for it to have the entire browse list (the list of
625 * workgroups/domains) from an entire network. Since a client never knows
626 * which local master browser will be found first, the one which is found
627 * first and used to retrieve a browse list may have an incomplete or empty
628 * browse list. By requesting the browse list from multiple local master
629 * browsers, a more complete list can be generated. For small networks (few
630 * workgroups), it is recommended that this value be set to 0, causing the
631 * browse lists from all found local master browsers to be retrieved and
632 * merged. For networks with many workgroups, a suitable value for this
633 * variable is probably somewhere around 3. (Default: 3).
636 smbc_getOptionBrowseMaxLmbCount(SMBCCTX *c);
639 * Set from how many local master browsers should the list of workgroups be
640 * retrieved. It can take up to 12 minutes or longer after a server becomes a
641 * local master browser, for it to have the entire browse list (the list of
642 * workgroups/domains) from an entire network. Since a client never knows
643 * which local master browser will be found first, the one which is found
644 * first and used to retrieve a browse list may have an incomplete or empty
645 * browse list. By requesting the browse list from multiple local master
646 * browsers, a more complete list can be generated. For small networks (few
647 * workgroups), it is recommended that this value be set to 0, causing the
648 * browse lists from all found local master browsers to be retrieved and
649 * merged. For networks with many workgroups, a suitable value for this
650 * variable is probably somewhere around 3. (Default: 3).
652 void
653 smbc_setOptionBrowseMaxLmbCount(SMBCCTX *c, int count);
656 * Get whether to url-encode readdir entries.
658 * There is a difference in the desired return strings from
659 * smbc_readdir() depending upon whether the filenames are to
660 * be displayed to the user, or whether they are to be
661 * appended to the path name passed to smbc_opendir() to call
662 * a further smbc_ function (e.g. open the file with
663 * smbc_open()). In the former case, the filename should be
664 * in "human readable" form. In the latter case, the smbc_
665 * functions expect a URL which must be url-encoded. Those
666 * functions decode the URL. If, for example, smbc_readdir()
667 * returned a file name of "abc%20def.txt", passing a path
668 * with this file name attached to smbc_open() would cause
669 * smbc_open to attempt to open the file "abc def.txt" since
670 * the %20 is decoded into a space.
672 * Set this option to True if the names returned by
673 * smbc_readdir() should be url-encoded such that they can be
674 * passed back to another smbc_ call. Set it to False if the
675 * names returned by smbc_readdir() are to be presented to the
676 * user.
678 * For backwards compatibility, this option defaults to False.
680 smbc_bool
681 smbc_getOptionUrlEncodeReaddirEntries(SMBCCTX *c);
684 * Set whether to url-encode readdir entries.
686 * There is a difference in the desired return strings from
687 * smbc_readdir() depending upon whether the filenames are to
688 * be displayed to the user, or whether they are to be
689 * appended to the path name passed to smbc_opendir() to call
690 * a further smbc_ function (e.g. open the file with
691 * smbc_open()). In the former case, the filename should be
692 * in "human readable" form. In the latter case, the smbc_
693 * functions expect a URL which must be url-encoded. Those
694 * functions decode the URL. If, for example, smbc_readdir()
695 * returned a file name of "abc%20def.txt", passing a path
696 * with this file name attached to smbc_open() would cause
697 * smbc_open to attempt to open the file "abc def.txt" since
698 * the %20 is decoded into a space.
700 * Set this option to True if the names returned by
701 * smbc_readdir() should be url-encoded such that they can be
702 * passed back to another smbc_ call. Set it to False if the
703 * names returned by smbc_readdir() are to be presented to the
704 * user.
706 * For backwards compatibility, this option defaults to False.
708 void
709 smbc_setOptionUrlEncodeReaddirEntries(SMBCCTX *c, smbc_bool b);
712 * Get whether to use the same connection for all shares on a server.
714 * Some Windows versions appear to have a limit to the number
715 * of concurrent SESSIONs and/or TREE CONNECTions. In
716 * one-shot programs (i.e. the program runs and then quickly
717 * ends, thereby shutting down all connections), it is
718 * probably reasonable to establish a new connection for each
719 * share. In long-running applications, the limitation can be
720 * avoided by using only a single connection to each server,
721 * and issuing a new TREE CONNECT when the share is accessed.
723 smbc_bool
724 smbc_getOptionOneSharePerServer(SMBCCTX *c);
727 * Set whether to use the same connection for all shares on a server.
729 * Some Windows versions appear to have a limit to the number
730 * of concurrent SESSIONs and/or TREE CONNECTions. In
731 * one-shot programs (i.e. the program runs and then quickly
732 * ends, thereby shutting down all connections), it is
733 * probably reasonable to establish a new connection for each
734 * share. In long-running applications, the limitation can be
735 * avoided by using only a single connection to each server,
736 * and issuing a new TREE CONNECT when the share is accessed.
738 void
739 smbc_setOptionOneSharePerServer(SMBCCTX *c, smbc_bool b);
741 /** Get whether to enable use of kerberos */
742 smbc_bool
743 smbc_getOptionUseKerberos(SMBCCTX *c);
745 /** Set whether to enable use of kerberos */
746 void
747 smbc_setOptionUseKerberos(SMBCCTX *c, smbc_bool b);
749 /** Get whether to fallback after kerberos */
750 smbc_bool
751 smbc_getOptionFallbackAfterKerberos(SMBCCTX *c);
753 /** Set whether to fallback after kerberos */
754 void
755 smbc_setOptionFallbackAfterKerberos(SMBCCTX *c, smbc_bool b);
757 /** Get whether to automatically select anonymous login */
758 smbc_bool
759 smbc_getOptionNoAutoAnonymousLogin(SMBCCTX *c);
761 /** Set whether to automatically select anonymous login */
762 void
763 smbc_setOptionNoAutoAnonymousLogin(SMBCCTX *c, smbc_bool b);
765 /** Get whether to enable use of the winbind ccache */
766 smbc_bool
767 smbc_getOptionUseCCache(SMBCCTX *c);
769 /** Set whether to enable use of the winbind ccache */
770 void
771 smbc_setOptionUseCCache(SMBCCTX *c, smbc_bool b);
773 /** Get indication that the password supplied is the NT hash */
774 smbc_bool
775 smbc_getOptionUseNTHash(SMBCCTX *c);
777 /** Set indication that the password supplied is the NT hash */
778 void
779 smbc_setOptionUseNTHash(SMBCCTX *c, smbc_bool b);
783 /*************************************
784 * Getters and setters for FUNCTIONS *
785 *************************************/
787 /** Get the function for obtaining authentication data */
788 smbc_get_auth_data_fn smbc_getFunctionAuthData(SMBCCTX *c);
790 /** Set the function for obtaining authentication data */
791 void smbc_setFunctionAuthData(SMBCCTX *c, smbc_get_auth_data_fn fn);
793 /** Get the new-style authentication function which includes the context. */
794 smbc_get_auth_data_with_context_fn
795 smbc_getFunctionAuthDataWithContext(SMBCCTX *c);
797 /** Set the new-style authentication function which includes the context. */
798 void
799 smbc_setFunctionAuthDataWithContext(SMBCCTX *c,
800 smbc_get_auth_data_with_context_fn fn);
802 /** Get the function for checking if a server is still good */
803 smbc_check_server_fn smbc_getFunctionCheckServer(SMBCCTX *c);
805 /** Set the function for checking if a server is still good */
806 void smbc_setFunctionCheckServer(SMBCCTX *c, smbc_check_server_fn fn);
808 /** Get the function for removing a server if unused */
809 smbc_remove_unused_server_fn smbc_getFunctionRemoveUnusedServer(SMBCCTX *c);
811 /** Set the function for removing a server if unused */
812 void smbc_setFunctionRemoveUnusedServer(SMBCCTX *c,
813 smbc_remove_unused_server_fn fn);
815 /** Get the function for adding a cached server */
816 smbc_add_cached_srv_fn smbc_getFunctionAddCachedServer(SMBCCTX *c);
818 /** Set the function for adding a cached server */
819 void smbc_setFunctionAddCachedServer(SMBCCTX *c, smbc_add_cached_srv_fn fn);
821 /** Get the function for server cache lookup */
822 smbc_get_cached_srv_fn smbc_getFunctionGetCachedServer(SMBCCTX *c);
824 /** Set the function for server cache lookup */
825 void smbc_setFunctionGetCachedServer(SMBCCTX *c, smbc_get_cached_srv_fn fn);
827 /** Get the function for server cache removal */
828 smbc_remove_cached_srv_fn smbc_getFunctionRemoveCachedServer(SMBCCTX *c);
830 /** Set the function for server cache removal */
831 void smbc_setFunctionRemoveCachedServer(SMBCCTX *c,
832 smbc_remove_cached_srv_fn fn);
835 * Get the function for server cache purging. This function tries to
836 * remove all cached servers (e.g. on disconnect)
838 smbc_purge_cached_fn smbc_getFunctionPurgeCachedServers(SMBCCTX *c);
841 * Set the function for server cache purging. This function tries to
842 * remove all cached servers (e.g. on disconnect)
844 void smbc_setFunctionPurgeCachedServers(SMBCCTX *c,
845 smbc_purge_cached_fn fn);
847 /** Get the function to store private data of the server cache */
848 struct smbc_server_cache * smbc_getServerCacheData(SMBCCTX *c);
850 /** Set the function to store private data of the server cache */
851 void smbc_setServerCacheData(SMBCCTX *c, struct smbc_server_cache * cache);
855 /*****************************************************************
856 * Callable functions for files. *
857 * Each callable has a function signature typedef, a declaration *
858 * for the getter, and a declaration for the setter. *
859 *****************************************************************/
861 typedef SMBCFILE * (*smbc_open_fn)(SMBCCTX *c,
862 const char *fname,
863 int flags,
864 mode_t mode);
865 smbc_open_fn smbc_getFunctionOpen(SMBCCTX *c);
866 void smbc_setFunctionOpen(SMBCCTX *c, smbc_open_fn fn);
868 typedef SMBCFILE * (*smbc_creat_fn)(SMBCCTX *c,
869 const char *path,
870 mode_t mode);
871 smbc_creat_fn smbc_getFunctionCreat(SMBCCTX *c);
872 void smbc_setFunctionCreat(SMBCCTX *c, smbc_creat_fn);
874 typedef ssize_t (*smbc_read_fn)(SMBCCTX *c,
875 SMBCFILE *file,
876 void *buf,
877 size_t count);
878 smbc_read_fn smbc_getFunctionRead(SMBCCTX *c);
879 void smbc_setFunctionRead(SMBCCTX *c, smbc_read_fn fn);
881 typedef ssize_t (*smbc_write_fn)(SMBCCTX *c,
882 SMBCFILE *file,
883 const void *buf,
884 size_t count);
885 smbc_write_fn smbc_getFunctionWrite(SMBCCTX *c);
886 void smbc_setFunctionWrite(SMBCCTX *c, smbc_write_fn fn);
888 typedef off_t (*smbc_splice_fn)(SMBCCTX *c,
889 SMBCFILE *srcfile,
890 SMBCFILE *dstfile,
891 off_t count,
892 int (*splice_cb)(off_t n, void *priv),
893 void *priv);
894 smbc_splice_fn smbc_getFunctionSplice(SMBCCTX *c);
895 void smbc_setFunctionSplice(SMBCCTX *c, smbc_splice_fn fn);
897 typedef int (*smbc_unlink_fn)(SMBCCTX *c,
898 const char *fname);
899 smbc_unlink_fn smbc_getFunctionUnlink(SMBCCTX *c);
900 void smbc_setFunctionUnlink(SMBCCTX *c, smbc_unlink_fn fn);
902 typedef int (*smbc_rename_fn)(SMBCCTX *ocontext,
903 const char *oname,
904 SMBCCTX *ncontext,
905 const char *nname);
906 smbc_rename_fn smbc_getFunctionRename(SMBCCTX *c);
907 void smbc_setFunctionRename(SMBCCTX *c, smbc_rename_fn fn);
909 typedef off_t (*smbc_lseek_fn)(SMBCCTX *c,
910 SMBCFILE * file,
911 off_t offset,
912 int whence);
913 smbc_lseek_fn smbc_getFunctionLseek(SMBCCTX *c);
914 void smbc_setFunctionLseek(SMBCCTX *c, smbc_lseek_fn fn);
916 typedef int (*smbc_stat_fn)(SMBCCTX *c,
917 const char *fname,
918 struct stat *st);
919 smbc_stat_fn smbc_getFunctionStat(SMBCCTX *c);
920 void smbc_setFunctionStat(SMBCCTX *c, smbc_stat_fn fn);
922 typedef int (*smbc_fstat_fn)(SMBCCTX *c,
923 SMBCFILE *file,
924 struct stat *st);
925 smbc_fstat_fn smbc_getFunctionFstat(SMBCCTX *c);
926 void smbc_setFunctionFstat(SMBCCTX *c, smbc_fstat_fn fn);
928 typedef int (*smbc_statvfs_fn)(SMBCCTX *c,
929 char *path,
930 struct statvfs *st);
931 smbc_statvfs_fn smbc_getFunctionStatVFS(SMBCCTX *c);
932 void smbc_setFunctionStatVFS(SMBCCTX *c, smbc_statvfs_fn fn);
934 typedef int (*smbc_fstatvfs_fn)(SMBCCTX *c,
935 SMBCFILE *file,
936 struct statvfs *st);
937 smbc_fstatvfs_fn smbc_getFunctionFstatVFS(SMBCCTX *c);
938 void smbc_setFunctionFstatVFS(SMBCCTX *c, smbc_fstatvfs_fn fn);
940 typedef int (*smbc_ftruncate_fn)(SMBCCTX *c,
941 SMBCFILE *f,
942 off_t size);
943 smbc_ftruncate_fn smbc_getFunctionFtruncate(SMBCCTX *c);
944 void smbc_setFunctionFtruncate(SMBCCTX *c, smbc_ftruncate_fn fn);
946 typedef int (*smbc_close_fn)(SMBCCTX *c,
947 SMBCFILE *file);
948 smbc_close_fn smbc_getFunctionClose(SMBCCTX *c);
949 void smbc_setFunctionClose(SMBCCTX *c, smbc_close_fn fn);
953 /*****************************************************************
954 * Callable functions for directories. *
955 * Each callable has a function signature typedef, a declaration *
956 * for the getter, and a declaration for the setter. *
957 *****************************************************************/
959 typedef SMBCFILE * (*smbc_opendir_fn)(SMBCCTX *c,
960 const char *fname);
961 smbc_opendir_fn smbc_getFunctionOpendir(SMBCCTX *c);
962 void smbc_setFunctionOpendir(SMBCCTX *c, smbc_opendir_fn fn);
964 typedef int (*smbc_closedir_fn)(SMBCCTX *c,
965 SMBCFILE *dir);
966 smbc_closedir_fn smbc_getFunctionClosedir(SMBCCTX *c);
967 void smbc_setFunctionClosedir(SMBCCTX *c, smbc_closedir_fn fn);
969 typedef struct smbc_dirent * (*smbc_readdir_fn)(SMBCCTX *c,
970 SMBCFILE *dir);
971 smbc_readdir_fn smbc_getFunctionReaddir(SMBCCTX *c);
972 void smbc_setFunctionReaddir(SMBCCTX *c, smbc_readdir_fn fn);
974 typedef int (*smbc_getdents_fn)(SMBCCTX *c,
975 SMBCFILE *dir,
976 struct smbc_dirent *dirp,
977 int count);
978 smbc_getdents_fn smbc_getFunctionGetdents(SMBCCTX *c);
979 void smbc_setFunctionGetdents(SMBCCTX *c, smbc_getdents_fn fn);
981 typedef int (*smbc_mkdir_fn)(SMBCCTX *c,
982 const char *fname,
983 mode_t mode);
984 smbc_mkdir_fn smbc_getFunctionMkdir(SMBCCTX *c);
985 void smbc_setFunctionMkdir(SMBCCTX *c, smbc_mkdir_fn fn);
987 typedef int (*smbc_rmdir_fn)(SMBCCTX *c,
988 const char *fname);
989 smbc_rmdir_fn smbc_getFunctionRmdir(SMBCCTX *c);
990 void smbc_setFunctionRmdir(SMBCCTX *c, smbc_rmdir_fn fn);
992 typedef off_t (*smbc_telldir_fn)(SMBCCTX *c,
993 SMBCFILE *dir);
994 smbc_telldir_fn smbc_getFunctionTelldir(SMBCCTX *c);
995 void smbc_setFunctionTelldir(SMBCCTX *c, smbc_telldir_fn fn);
997 typedef int (*smbc_lseekdir_fn)(SMBCCTX *c,
998 SMBCFILE *dir,
999 off_t offset);
1000 smbc_lseekdir_fn smbc_getFunctionLseekdir(SMBCCTX *c);
1001 void smbc_setFunctionLseekdir(SMBCCTX *c, smbc_lseekdir_fn fn);
1003 typedef int (*smbc_fstatdir_fn)(SMBCCTX *c,
1004 SMBCFILE *dir,
1005 struct stat *st);
1006 smbc_fstatdir_fn smbc_getFunctionFstatdir(SMBCCTX *c);
1007 void smbc_setFunctionFstatdir(SMBCCTX *c, smbc_fstatdir_fn fn);
1009 #define SMBC_NOTIFY_ACTION_ADDED 1
1010 #define SMBC_NOTIFY_ACTION_REMOVED 2
1011 #define SMBC_NOTIFY_ACTION_MODIFIED 3
1012 #define SMBC_NOTIFY_ACTION_OLD_NAME 4
1013 #define SMBC_NOTIFY_ACTION_NEW_NAME 5
1014 #define SMBC_NOTIFY_ACTION_ADDED_STREAM 6
1015 #define SMBC_NOTIFY_ACTION_REMOVED_STREAM 7
1016 #define SMBC_NOTIFY_ACTION_MODIFIED_STREAM 8
1018 struct smbc_notify_callback_action {
1019 uint32_t action;
1020 const char *filename;
1023 typedef int (*smbc_notify_callback_fn)(
1024 const struct smbc_notify_callback_action *actions,
1025 size_t num_actions, void *private_data);
1027 typedef int (*smbc_notify_fn)(SMBCCTX *c, SMBCFILE *dir, smbc_bool recursive,
1028 uint32_t completion_filter,
1029 unsigned callback_timeout_ms,
1030 smbc_notify_callback_fn cb, void *private_data);
1031 smbc_notify_fn smbc_getFunctionNotify(SMBCCTX *c);
1032 void smbc_setFunctionNotify(SMBCCTX *c, smbc_notify_fn fn);
1035 /*****************************************************************
1036 * Callable functions applicable to both files and directories. *
1037 * Each callable has a function signature typedef, a declaration *
1038 * for the getter, and a declaration for the setter. *
1039 *****************************************************************/
1041 typedef int (*smbc_chmod_fn)(SMBCCTX *c,
1042 const char *fname,
1043 mode_t mode);
1044 smbc_chmod_fn smbc_getFunctionChmod(SMBCCTX *c);
1045 void smbc_setFunctionChmod(SMBCCTX *c, smbc_chmod_fn fn);
1047 typedef int (*smbc_utimes_fn)(SMBCCTX *c,
1048 const char *fname,
1049 struct timeval *tbuf);
1050 smbc_utimes_fn smbc_getFunctionUtimes(SMBCCTX *c);
1051 void smbc_setFunctionUtimes(SMBCCTX *c, smbc_utimes_fn fn);
1053 typedef int (*smbc_setxattr_fn)(SMBCCTX *context,
1054 const char *fname,
1055 const char *name,
1056 const void *value,
1057 size_t size,
1058 int flags);
1059 smbc_setxattr_fn smbc_getFunctionSetxattr(SMBCCTX *c);
1060 void smbc_setFunctionSetxattr(SMBCCTX *c, smbc_setxattr_fn fn);
1062 typedef int (*smbc_getxattr_fn)(SMBCCTX *context,
1063 const char *fname,
1064 const char *name,
1065 const void *value,
1066 size_t size);
1067 smbc_getxattr_fn smbc_getFunctionGetxattr(SMBCCTX *c);
1068 void smbc_setFunctionGetxattr(SMBCCTX *c, smbc_getxattr_fn fn);
1070 typedef int (*smbc_removexattr_fn)(SMBCCTX *context,
1071 const char *fname,
1072 const char *name);
1073 smbc_removexattr_fn smbc_getFunctionRemovexattr(SMBCCTX *c);
1074 void smbc_setFunctionRemovexattr(SMBCCTX *c, smbc_removexattr_fn fn);
1076 typedef int (*smbc_listxattr_fn)(SMBCCTX *context,
1077 const char *fname,
1078 char *list,
1079 size_t size);
1080 smbc_listxattr_fn smbc_getFunctionListxattr(SMBCCTX *c);
1081 void smbc_setFunctionListxattr(SMBCCTX *c, smbc_listxattr_fn fn);
1085 /*****************************************************************
1086 * Callable functions for printing. *
1087 * Each callable has a function signature typedef, a declaration *
1088 * for the getter, and a declaration for the setter. *
1089 *****************************************************************/
1091 typedef int (*smbc_print_file_fn)(SMBCCTX *c_file,
1092 const char *fname,
1093 SMBCCTX *c_print,
1094 const char *printq);
1095 smbc_print_file_fn smbc_getFunctionPrintFile(SMBCCTX *c);
1096 void smbc_setFunctionPrintFile(SMBCCTX *c, smbc_print_file_fn fn);
1098 typedef SMBCFILE * (*smbc_open_print_job_fn)(SMBCCTX *c,
1099 const char *fname);
1100 smbc_open_print_job_fn smbc_getFunctionOpenPrintJob(SMBCCTX *c);
1101 void smbc_setFunctionOpenPrintJob(SMBCCTX *c,
1102 smbc_open_print_job_fn fn);
1104 typedef int (*smbc_list_print_jobs_fn)(SMBCCTX *c,
1105 const char *fname,
1106 smbc_list_print_job_fn fn);
1107 smbc_list_print_jobs_fn smbc_getFunctionListPrintJobs(SMBCCTX *c);
1108 void smbc_setFunctionListPrintJobs(SMBCCTX *c,
1109 smbc_list_print_jobs_fn fn);
1111 typedef int (*smbc_unlink_print_job_fn)(SMBCCTX *c,
1112 const char *fname,
1113 int id);
1114 smbc_unlink_print_job_fn smbc_getFunctionUnlinkPrintJob(SMBCCTX *c);
1115 void smbc_setFunctionUnlinkPrintJob(SMBCCTX *c,
1116 smbc_unlink_print_job_fn fn);
1119 /**@ingroup misc
1120 * Create a new SBMCCTX (a context).
1122 * Must be called before the context is passed to smbc_context_init()
1124 * @return The given SMBCCTX pointer on success, NULL on error with errno set:
1125 * - ENOMEM Out of memory
1127 * @see smbc_free_context(), smbc_init_context()
1129 * @note Do not forget to smbc_init_context() the returned SMBCCTX pointer !
1131 SMBCCTX * smbc_new_context(void);
1133 /**@ingroup misc
1134 * Delete a SBMCCTX (a context) acquired from smbc_new_context().
1136 * The context will be deleted if possible.
1138 * @param context A pointer to a SMBCCTX obtained from smbc_new_context()
1140 * @param shutdown_ctx If 1, all connections and files will be closed even if they are busy.
1143 * @return Returns 0 on succes. Returns 1 on failure with errno set:
1144 * - EBUSY Server connections are still used, Files are open or cache
1145 * could not be purged
1146 * - EBADF context == NULL
1148 * @see smbc_new_context()
1150 * @note It is advised to clean up all the contexts with shutdown_ctx set to 1
1151 * just before exit()'ing. When shutdown_ctx is 0, this function can be
1152 * use in periodical cleanup functions for example.
1154 int smbc_free_context(SMBCCTX * context, int shutdown_ctx);
1157 /**@ingroup misc
1159 * @deprecated. Use smbc_setOption*() functions instead.
1161 void
1162 smbc_option_set(SMBCCTX *context,
1163 char *option_name,
1164 ... /* option_value */);
1167 * @deprecated. Use smbc_getOption*() functions instead.
1169 void *
1170 smbc_option_get(SMBCCTX *context,
1171 char *option_name);
1173 /**@ingroup misc
1174 * Initialize a SBMCCTX (a context).
1176 * Must be called before using any SMBCCTX API function
1178 * @param context A pointer to a SMBCCTX obtained from smbc_new_context()
1180 * @return A pointer to the given SMBCCTX on success,
1181 * NULL on error with errno set:
1182 * - EBADF NULL context given
1183 * - ENOMEM Out of memory
1184 * - ENOENT The smb.conf file would not load
1186 * @see smbc_new_context()
1188 * @note my_context = smbc_init_context(smbc_new_context())
1189 * is perfectly safe, but it might leak memory on
1190 * smbc_context_init() failure. Avoid this.
1191 * You'll have to call smbc_free_context() yourself
1192 * on failure.
1195 SMBCCTX * smbc_init_context(SMBCCTX * context);
1197 /**@ingroup misc
1198 * Initialize the samba client library.
1200 * Must be called before using any of the smbclient API function
1202 * @param fn The function that will be called to obtaion
1203 * authentication credentials.
1205 * @param debug Allows caller to set the debug level. Can be
1206 * changed in smb.conf file. Allows caller to set
1207 * debugging if no smb.conf.
1209 * @return 0 on success, < 0 on error with errno set:
1210 * - ENOMEM Out of memory
1211 * - ENOENT The smb.conf file would not load
1215 int smbc_init(smbc_get_auth_data_fn fn, int debug);
1217 /**@ingroup misc
1218 * Set or retrieve the compatibility library's context pointer
1220 * @param context New context to use, or NULL. If a new context is provided,
1221 * it must have allocated with smbc_new_context() and
1222 * initialized with smbc_init_context(), followed, optionally,
1223 * by some manual changes to some of the non-internal fields.
1225 * @return The old context.
1227 * @see smbc_new_context(), smbc_init_context(), smbc_init()
1229 * @note This function may be called prior to smbc_init() to force
1230 * use of the next context without any internal calls to
1231 * smbc_new_context() or smbc_init_context(). It may also
1232 * be called after smbc_init() has already called those two
1233 * functions, to replace the existing context with a new one.
1234 * Care should be taken, in this latter case, to ensure that
1235 * the server cache and any data allocated by the
1236 * authentication functions have been freed, if necessary.
1239 SMBCCTX * smbc_set_context(SMBCCTX * new_context);
1241 /**@ingroup file
1242 * Open a file on an SMB server.
1244 * @param furl The smb url of the file to be opened.
1246 * @param flags Is one of O_RDONLY, O_WRONLY or O_RDWR which
1247 * request opening the file read-only,write-only
1248 * or read/write. flags may also be bitwise-or'd with
1249 * one or more of the following:
1250 * O_CREAT - If the file does not exist it will be
1251 * created.
1252 * O_EXCL - When used with O_CREAT, if the file
1253 * already exists it is an error and the open will
1254 * fail.
1255 * O_TRUNC - If the file already exists it will be
1256 * truncated.
1257 * O_APPEND The file is opened in append mode
1259 * @param mode mode specifies the permissions to use if a new
1260 * file is created. It is modified by the
1261 * process's umask in the usual way: the permissions
1262 * of the created file are (mode & ~umask)
1264 * Not currently use, but there for future use.
1265 * We will map this to SYSTEM, HIDDEN, etc bits
1266 * that reverses the mapping that smbc_fstat does.
1268 * @return Valid file handle, < 0 on error with errno set:
1269 * - ENOMEM Out of memory
1270 * - EINVAL if an invalid parameter passed, like no
1271 * file, or smbc_init not called.
1272 * - EEXIST pathname already exists and O_CREAT and
1273 * O_EXCL were used.
1274 * - EISDIR pathname refers to a directory and
1275 * the access requested involved writing.
1276 * - EACCES The requested access to the file is not
1277 * allowed
1278 * - ENODEV The requested share does not exist
1279 * - ENOTDIR A file on the path is not a directory
1280 * - ENOENT A directory component in pathname does
1281 * not exist.
1283 * @see smbc_creat()
1285 * @note This call uses an underlying routine that may create
1286 * a new connection to the server specified in the URL.
1287 * If the credentials supplied in the URL, or via the
1288 * auth_fn in the smbc_init call, fail, this call will
1289 * try again with an empty username and password. This
1290 * often gets mapped to the guest account on some machines.
1293 int smbc_open(const char *furl, int flags, mode_t mode);
1295 /**@ingroup file
1296 * Create a file on an SMB server.
1298 * Same as calling smbc_open() with flags = O_CREAT|O_WRONLY|O_TRUNC
1300 * @param furl The smb url of the file to be created
1302 * @param mode mode specifies the permissions to use if a new
1303 * file is created. It is modified by the
1304 * process's umask in the usual way: the permissions
1305 * of the created file are (mode & ~umask)
1307 * NOTE, the above is not true. We are dealing with
1308 * an SMB server, which has no concept of a umask!
1310 * @return Valid file handle, < 0 on error with errno set:
1311 * - ENOMEM Out of memory
1312 * - EINVAL if an invalid parameter passed, like no
1313 * file, or smbc_init not called.
1314 * - EEXIST pathname already exists and O_CREAT and
1315 * O_EXCL were used.
1316 * - EISDIR pathname refers to a directory and
1317 * the access requested involved writing.
1318 * - EACCES The requested access to the file is not
1319 * allowed
1320 * - ENOENT A directory component in pathname does
1321 * not exist.
1322 * - ENODEV The requested share does not exist.
1323 * @see smbc_open()
1327 int smbc_creat(const char *furl, mode_t mode);
1329 /**@ingroup file
1330 * Read from a file using an opened file handle.
1332 * @param fd Open file handle from smbc_open() or smbc_creat()
1334 * @param buf Pointer to buffer to receive read data
1336 * @param bufsize Size of buf in bytes
1338 * @return Number of bytes read;
1339 * 0 upon EOF;
1340 * < 0 on error, with errno set:
1341 * - EISDIR fd refers to a directory
1342 * - EBADF fd is not a valid file descriptor or
1343 * is not open for reading.
1344 * - EINVAL fd is attached to an object which is
1345 * unsuitable for reading, or no buffer passed or
1346 * smbc_init not called.
1348 * @see smbc_open(), smbc_write()
1351 ssize_t smbc_read(int fd, void *buf, size_t bufsize);
1354 /**@ingroup file
1355 * Write to a file using an opened file handle.
1357 * @param fd Open file handle from smbc_open() or smbc_creat()
1359 * @param buf Pointer to buffer to recieve read data
1361 * @param bufsize Size of buf in bytes
1363 * @return Number of bytes written, < 0 on error with errno set:
1364 * - EISDIR fd refers to a directory.
1365 * - EBADF fd is not a valid file descriptor or
1366 * is not open for reading.
1367 * - EINVAL fd is attached to an object which is
1368 * unsuitable for reading, or no buffer passed or
1369 * smbc_init not called.
1371 * @see smbc_open(), smbc_read()
1374 ssize_t smbc_write(int fd, const void *buf, size_t bufsize);
1377 /**@ingroup file
1378 * Seek to a specific location in a file.
1380 * @param fd Open file handle from smbc_open() or smbc_creat()
1382 * @param offset Offset in bytes from whence
1384 * @param whence A location in the file:
1385 * - SEEK_SET The offset is set to offset bytes from
1386 * the beginning of the file
1387 * - SEEK_CUR The offset is set to current location
1388 * plus offset bytes.
1389 * - SEEK_END The offset is set to the size of the
1390 * file plus offset bytes.
1392 * @return Upon successful completion, lseek returns the
1393 * resulting offset location as measured in bytes
1394 * from the beginning of the file. Otherwise, a value
1395 * of (off_t)-1 is returned and errno is set to
1396 * indicate the error:
1397 * - EBADF Fildes is not an open file descriptor.
1398 * - EINVAL Whence is not a proper value or smbc_init
1399 * not called.
1401 * @todo Are all the whence values really supported?
1403 * @todo Are errno values complete and correct?
1405 off_t smbc_lseek(int fd, off_t offset, int whence);
1408 /**@ingroup file
1409 * Close an open file handle.
1411 * @param fd The file handle to close
1413 * @return 0 on success, < 0 on error with errno set:
1414 * - EBADF fd isn't a valid open file descriptor
1415 * - EINVAL smbc_init() failed or has not been called
1417 * @see smbc_open(), smbc_creat()
1419 int smbc_close(int fd);
1422 /**@ingroup directory
1423 * Unlink (delete) a file or directory.
1425 * @param furl The smb url of the file to delete
1427 * @return 0 on success, < 0 on error with errno set:
1428 * - EACCES or EPERM Write access to the directory
1429 * containing pathname is not allowed or one
1430 * of the directories in pathname did not allow
1431 * search (execute) permission
1432 * - ENOENT A directory component in pathname does
1433 * not exist
1434 * - EINVAL NULL was passed in the file param or
1435 * smbc_init not called.
1436 * - EACCES You do not have access to the file
1437 * - ENOMEM Insufficient kernel memory was available
1439 * @see smbc_rmdir()s
1441 * @todo Are errno values complete and correct?
1443 int smbc_unlink(const char *furl);
1446 /**@ingroup directory
1447 * Rename or move a file or directory.
1449 * @param ourl The original smb url (source url) of file or
1450 * directory to be moved
1452 * @param nurl The new smb url (destination url) of the file
1453 * or directory after the move. Currently nurl must
1454 * be on the same share as ourl.
1456 * @return 0 on success, < 0 on error with errno set:
1457 * - EISDIR nurl is an existing directory, but ourl is
1458 * not a directory.
1459 * - EEXIST nurl is a non-empty directory,
1460 * i.e., contains entries other than "." and ".."
1461 * - EINVAL The new url contained a path prefix
1462 * of the old, or, more generally, an attempt was
1463 * made to make a directory a subdirectory of itself
1464 * or smbc_init not called.
1465 * - ENOTDIR A component used as a directory in ourl
1466 * or nurl path is not, in fact, a directory. Or,
1467 * ourl is a directory, and newpath exists but is not
1468 * a directory.
1469 * - EACCES or EPERM Write access to the directory
1470 * containing ourl or nurl is not allowed for the
1471 * process's effective uid, or one of the
1472 * directories in ourl or nurl did not allow search
1473 * (execute) permission, or ourl was a directory
1474 * and did not allow write permission.
1475 * - ENOENT A directory component in ourl or nurl
1476 * does not exist.
1477 * - EXDEV Rename across shares not supported.
1478 * - ENOMEM Insufficient kernel memory was available.
1479 * - EEXIST The target file, nurl, already exists.
1482 * @todo Are we going to support copying when urls are not on the same
1483 * share? I say no... NOTE. I agree for the moment.
1486 int smbc_rename(const char *ourl, const char *nurl);
1489 /**@ingroup directory
1490 * Open a directory used to obtain directory entries.
1492 * @param durl The smb url of the directory to open
1494 * @return Valid directory handle. < 0 on error with errno set:
1495 * - EACCES Permission denied.
1496 * - EINVAL A NULL file/URL was passed, or the URL would
1497 * not parse, or was of incorrect form or smbc_init not
1498 * called.
1499 * - ENOENT durl does not exist, or name is an
1500 * - ENOMEM Insufficient memory to complete the
1501 * operation.
1502 * - ENOTDIR name is not a directory.
1503 * - EPERM the workgroup could not be found.
1504 * - ENODEV the workgroup or server could not be found.
1506 * @see smbc_getdents(), smbc_readdir(), smbc_closedir()
1509 int smbc_opendir(const char *durl);
1512 /**@ingroup directory
1513 * Close a directory handle opened by smbc_opendir().
1515 * @param dh Directory handle to close
1517 * @return 0 on success, < 0 on error with errno set:
1518 * - EBADF dh is an invalid directory handle
1520 * @see smbc_opendir()
1522 int smbc_closedir(int dh);
1525 /**@ingroup directory
1526 * Get multiple directory entries.
1528 * smbc_getdents() reads as many dirent structures from the an open
1529 * directory handle into a specified memory area as will fit.
1531 * @param dh Valid directory as returned by smbc_opendir()
1533 * @param dirp pointer to buffer that will receive the directory
1534 * entries.
1536 * @param count The size of the dirp buffer in bytes
1538 * @returns If any dirents returned, return will indicate the
1539 * total size. If there were no more dirents available,
1540 * 0 is returned. < 0 indicates an error.
1541 * - EBADF Invalid directory handle
1542 * - EINVAL Result buffer is too small or smbc_init
1543 * not called.
1544 * - ENOENT No such directory.
1545 * @see , smbc_dirent, smbc_readdir(), smbc_open()
1547 * @todo Are errno values complete and correct?
1549 * @todo Add example code so people know how to parse buffers.
1551 int smbc_getdents(unsigned int dh, struct smbc_dirent *dirp, int count);
1554 /**@ingroup directory
1555 * Get a single directory entry.
1557 * @param dh Valid directory as returned by smbc_opendir()
1559 * @return A pointer to a smbc_dirent structure, or NULL if an
1560 * error occurs or end-of-directory is reached:
1561 * - EBADF Invalid directory handle
1562 * - EINVAL smbc_init() failed or has not been called
1564 * @see smbc_dirent, smbc_getdents(), smbc_open()
1566 struct smbc_dirent* smbc_readdir(unsigned int dh);
1569 /**@ingroup directory
1570 * Get the current directory offset.
1572 * smbc_telldir() may be used in conjunction with smbc_readdir() and
1573 * smbc_lseekdir().
1575 * @param dh Valid directory as returned by smbc_opendir()
1577 * @return The current location in the directory stream or -1
1578 * if an error occur. The current location is not
1579 * an offset. Becuase of the implementation, it is a
1580 * handle that allows the library to find the entry
1581 * later.
1582 * - EBADF dh is not a valid directory handle
1583 * - EINVAL smbc_init() failed or has not been called
1584 * - ENOTDIR if dh is not a directory
1586 * @see smbc_readdir()
1589 off_t smbc_telldir(int dh);
1592 /**@ingroup directory
1593 * lseek on directories.
1595 * smbc_lseekdir() may be used in conjunction with smbc_readdir() and
1596 * smbc_telldir(). (rewind by smbc_lseekdir(fd, NULL))
1598 * @param fd Valid directory as returned by smbc_opendir()
1600 * @param offset The offset (as returned by smbc_telldir). Can be
1601 * NULL, in which case we will rewind
1603 * @return 0 on success, -1 on failure
1604 * - EBADF dh is not a valid directory handle
1605 * - ENOTDIR if dh is not a directory
1606 * - EINVAL offset did not refer to a valid dirent or
1607 * smbc_init not called.
1609 * @see smbc_telldir()
1612 * @todo In what does the reture and errno values mean?
1614 int smbc_lseekdir(int fd, off_t offset);
1616 /**@ingroup directory
1617 * Create a directory.
1619 * @param durl The url of the directory to create
1621 * @param mode Specifies the permissions to use. It is modified
1622 * by the process's umask in the usual way: the
1623 * permissions of the created file are (mode & ~umask).
1625 * @return 0 on success, < 0 on error with errno set:
1626 * - EEXIST directory url already exists
1627 * - EACCES The parent directory does not allow write
1628 * permission to the process, or one of the directories
1629 * - ENOENT A directory component in pathname does not
1630 * exist.
1631 * - EINVAL NULL durl passed or smbc_init not called.
1632 * - ENOMEM Insufficient memory was available.
1634 * @see smbc_rmdir()
1637 int smbc_mkdir(const char *durl, mode_t mode);
1640 /**@ingroup directory
1641 * Remove a directory.
1643 * @param durl The smb url of the directory to remove
1645 * @return 0 on success, < 0 on error with errno set:
1646 * - EACCES or EPERM Write access to the directory
1647 * containing pathname was not allowed.
1648 * - EINVAL durl is NULL or smbc_init not called.
1649 * - ENOENT A directory component in pathname does not
1650 * exist.
1651 * - ENOTEMPTY directory contains entries.
1652 * - ENOMEM Insufficient kernel memory was available.
1654 * @see smbc_mkdir(), smbc_unlink()
1656 * @todo Are errno values complete and correct?
1658 int smbc_rmdir(const char *durl);
1660 /**@ingroup directory
1661 * Request directory notifications
1663 * @param dh Valid directory as returned by smbc_opendir()
1665 * @param recursive Are changes in subdirectories wanted?
1667 * @param completion_filter Bitwise-or of the SMBC_NOTIFY_CHANGE_*
1668 * events that are interesting
1670 * @param callback_timeout_ms If set to non-zero, interval in milliseconds
1671 * that "cb" will be called with 0 actions.
1672 * This gives "cb" the chance to cancel the
1673 * smbc_notify call.
1675 * @param cb Callback functions taking events. If "cb"
1676 * returns nonzero, smbc_notify will return.
1678 * @param private_data Pointer given to "cb"
1680 * @return 0 on success, -1 on error with errno set
1682 * @see smbc_opendir(), smbc_closedir()
1685 #define SMBC_NOTIFY_CHANGE_FILE_NAME 0x001
1686 #define SMBC_NOTIFY_CHANGE_DIR_NAME 0x002
1687 #define SMBC_NOTIFY_CHANGE_ATTRIBUTES 0x004
1688 #define SMBC_NOTIFY_CHANGE_SIZE 0x008
1689 #define SMBC_NOTIFY_CHANGE_LAST_WRITE 0x010
1690 #define SMBC_NOTIFY_CHANGE_LAST_ACCESS 0x020
1691 #define SMBC_NOTIFY_CHANGE_CREATION 0x040
1692 #define SMBC_NOTIFY_CHANGE_EA 0x080
1693 #define SMBC_NOTIFY_CHANGE_SECURITY 0x100
1694 #define SMBC_NOTIFY_CHANGE_STREAM_NAME 0x200
1695 #define SMBC_NOTIFY_CHANGE_STREAM_SIZE 0x400
1696 #define SMBC_NOTIFY_CHANGE_STREAM_WRITE 0x800
1698 int smbc_notify(int dh, smbc_bool recursive, uint32_t completion_filter,
1699 unsigned callback_timeout_ms,
1700 smbc_notify_callback_fn cb, void *private_data);
1702 /**@ingroup attribute
1703 * Get information about a file or directory.
1705 * @param url The smb url to get information for
1707 * @param st pointer to a buffer that will be filled with
1708 * standard Unix struct stat information.
1710 * @return 0 on success, < 0 on error with errno set:
1711 * - ENOENT A component of the path file_name does not
1712 * exist.
1713 * - EINVAL a NULL url was passed or smbc_init not called.
1714 * - EACCES Permission denied.
1715 * - ENOMEM Out of memory
1716 * - ENOTDIR The target dir, url, is not a directory.
1718 * @see Unix stat()
1721 int smbc_stat(const char *url, struct stat *st);
1724 /**@ingroup attribute
1725 * Get file information via an file descriptor.
1727 * @param fd Open file handle from smbc_open() or smbc_creat()
1729 * @param st pointer to a buffer that will be filled with
1730 * standard Unix struct stat information.
1732 * @return 0 on success, < 0 on error with errno set:
1733 * - EBADF filedes is bad.
1734 * - EACCES Permission denied.
1735 * - EBADF fd is not a valid file descriptor
1736 * - EINVAL Problems occurred in the underlying routines
1737 * or smbc_init not called.
1738 * - ENOMEM Out of memory
1740 * @see smbc_stat(), Unix stat()
1743 int smbc_fstat(int fd, struct stat *st);
1746 /**@ingroup attribute
1747 * Get file system information for a specified path.
1749 * @param url The smb url to get information for
1751 * @param st pointer to a buffer that will be filled with
1752 * standard Unix struct statvfs information.
1754 * @return 0 on success, < 0 on error with errno set:
1755 * - EBADF filedes is bad.
1756 * - EACCES Permission denied.
1757 * - EBADF fd is not a valid file descriptor
1758 * - EINVAL Problems occurred in the underlying routines
1759 * or smbc_init not called.
1760 * - ENOMEM Out of memory
1762 * @see Unix fstatvfs()
1766 smbc_statvfs(char *url,
1767 struct statvfs *st);
1769 /**@ingroup attribute
1770 * Get file system information via an file descriptor.
1772 * @param fd Open file handle from smbc_open(), smbc_creat(),
1773 * or smbc_opendir()
1775 * @param st pointer to a buffer that will be filled with
1776 * standard Unix struct statvfs information.
1778 * @return 0 on success, < 0 on error with errno set:
1779 * - EBADF filedes is bad.
1780 * - EACCES Permission denied.
1781 * - EBADF fd is not a valid file descriptor
1782 * - EINVAL Problems occurred in the underlying routines
1783 * or smbc_init not called.
1784 * - ENOMEM Out of memory
1786 * @see Unix fstatvfs()
1790 smbc_fstatvfs(int fd,
1791 struct statvfs *st);
1794 /**@ingroup attribute
1795 * Truncate a file given a file descriptor
1797 * @param fd Open file handle from smbc_open() or smbc_creat()
1799 * @param size size to truncate the file to
1801 * @return 0 on success, < 0 on error with errno set:
1802 * - EBADF filedes is bad.
1803 * - EACCES Permission denied.
1804 * - EBADF fd is not a valid file descriptor
1805 * - EINVAL Problems occurred in the underlying routines
1806 * or smbc_init not called.
1807 * - ENOMEM Out of memory
1809 * @see , Unix ftruncate()
1812 int smbc_ftruncate(int fd, off_t size);
1815 /**@ingroup attribute
1816 * Change the permissions of a file.
1818 * @param url The smb url of the file or directory to change
1819 * permissions of
1821 * @param mode The permissions to set:
1822 * - Put good explaination of permissions here!
1824 * @return 0 on success, < 0 on error with errno set:
1825 * - EPERM The effective UID does not match the owner
1826 * of the file, and is not zero
1827 * - ENOENT The file does not exist.
1828 * - ENOMEM Insufficient was available.
1829 * - ENOENT file or directory does not exist
1831 * @todo Actually implement this fuction?
1833 * @todo Are errno values complete and correct?
1835 int smbc_chmod(const char *url, mode_t mode);
1838 * @ingroup attribute
1839 * Change the last modification time on a file
1841 * @param url The smb url of the file or directory to change
1842 * the modification time of
1844 * @param tbuf An array of two timeval structures which contains,
1845 * respectively, the desired access and modification times.
1846 * NOTE: Only the tv_sec field off each timeval structure is
1847 * used. The tv_usec (microseconds) portion is ignored.
1849 * @return 0 on success, < 0 on error with errno set:
1850 * - EINVAL The client library is not properly initialized
1851 * - EPERM Permission was denied.
1854 int smbc_utimes(const char *url, struct timeval *tbuf);
1856 #ifdef HAVE_UTIME_H
1858 * @ingroup attribute
1859 * Change the last modification time on a file
1861 * @param url The smb url of the file or directory to change
1862 * the modification time of
1864 * @param utbuf A pointer to a utimebuf structure which contains the
1865 * desired access and modification times.
1867 * @return 0 on success, < 0 on error with errno set:
1868 * - EINVAL The client library is not properly initialized
1869 * - ENOMEM No memory was available for internal needs
1870 * - EPERM Permission was denied.
1873 int smbc_utime(const char *fname, struct utimbuf *utbuf);
1874 #endif
1876 /**@ingroup attribute
1877 * Set extended attributes for a file. This is used for modifying a file's
1878 * security descriptor (i.e. owner, group, and access control list)
1880 * @param url The smb url of the file or directory to set extended
1881 * attributes for.
1883 * @param name The name of an attribute to be changed. Names are of
1884 * one of the following forms:
1886 * system.nt_sec_desc.<attribute name>
1887 * system.nt_sec_desc.*
1888 * system.nt_sec_desc.*+
1890 * where <attribute name> is one of:
1892 * revision
1893 * owner
1894 * owner+
1895 * group
1896 * group+
1897 * acl:<name or sid>
1898 * acl+:<name or sid>
1900 * In the forms "system.nt_sec_desc.*" and
1901 * "system.nt_sec_desc.*+", the asterisk and plus signs are
1902 * literal, i.e. the string is provided exactly as shown, and
1903 * the value parameter should contain a complete security
1904 * descriptor with name:value pairs separated by tabs,
1905 * commas, or newlines (not spaces!).
1907 * The plus sign ('+') indicates that SIDs should be mapped
1908 * to names. Without the plus sign, SIDs are not mapped;
1909 * rather they are simply converted to a string format.
1911 * @param value The value to be assigned to the specified attribute name.
1912 * This buffer should contain only the attribute value if the
1913 * name was of the "system.nt_sec_desc.<attribute_name>"
1914 * form. If the name was of the "system.nt_sec_desc.*" form
1915 * then a complete security descriptor, with name:value pairs
1916 * separated by tabs, commas, or newlines (not spaces!),
1917 * should be provided in this value buffer. A complete
1918 * security descriptor will contain one or more entries
1919 * selected from the following:
1921 * REVISION:<revision number>
1922 * OWNER:<sid or name>
1923 * GROUP:<sid or name>
1924 * ACL:<sid or name>:<type>/<flags>/<mask>
1926 * The revision of the ACL specifies the internal Windows NT
1927 * ACL revision for the security descriptor. If not specified
1928 * it defaults to 1. Using values other than 1 may cause
1929 * strange behaviour.
1931 * The owner and group specify the owner and group sids for
1932 * the object. If the attribute name (either '*+' with a
1933 * complete security descriptor, or individual 'owner+' or
1934 * 'group+' attribute names) ended with a plus sign, the
1935 * specified name is resolved to a SID value, using the
1936 * server on which the file or directory resides. Otherwise,
1937 * the value should be provided in SID-printable format as
1938 * S-1-x-y-z, and is used directly. The <sid or name>
1939 * associated with the ACL: attribute should be provided
1940 * similarly.
1942 * @param size The number of the bytes of data in the value buffer
1944 * @param flags A bit-wise OR of zero or more of the following:
1945 * SMBC_XATTR_FLAG_CREATE -
1946 * fail if the named attribute already exists
1947 * SMBC_XATTR_FLAG_REPLACE -
1948 * fail if the attribute does not already exist
1950 * If neither flag is specified, the specified attributes
1951 * will be added or replace existing attributes of the same
1952 * name, as necessary.
1954 * @return 0 on success, < 0 on error with errno set:
1955 * - EINVAL The client library is not properly initialized
1956 * or one of the parameters is not of a correct
1957 * form
1958 * - ENOMEM No memory was available for internal needs
1959 * - EEXIST If the attribute already exists and the flag
1960 * SMBC_XATTR_FLAG_CREAT was specified
1961 * - ENOATTR If the attribute does not exist and the flag
1962 * SMBC_XATTR_FLAG_REPLACE was specified
1963 * - EPERM Permission was denied.
1964 * - ENOTSUP The referenced file system does not support
1965 * extended attributes
1967 * @note Attribute names are compared in a case-insensitive
1968 * fashion. All of the following are equivalent, although
1969 * the all-lower-case name is the preferred format:
1970 * system.nt_sec_desc.owner
1971 * SYSTEM.NT_SEC_DESC.OWNER
1972 * sYsTeM.nt_sEc_desc.owNER
1975 int smbc_setxattr(const char *url,
1976 const char *name,
1977 const void *value,
1978 size_t size,
1979 int flags);
1982 /**@ingroup attribute
1983 * Set extended attributes for a file. This is used for modifying a file's
1984 * security descriptor (i.e. owner, group, and access control list). The
1985 * POSIX function which this maps to would act on a symbolic link rather than
1986 * acting on what the symbolic link points to, but with no symbolic links in
1987 * SMB file systems, this function is functionally identical to
1988 * smbc_setxattr().
1990 * @param url The smb url of the file or directory to set extended
1991 * attributes for.
1993 * @param name The name of an attribute to be changed. Names are of
1994 * one of the following forms:
1996 * system.nt_sec_desc.<attribute name>
1997 * system.nt_sec_desc.*
1998 * system.nt_sec_desc.*+
2000 * where <attribute name> is one of:
2002 * revision
2003 * owner
2004 * owner+
2005 * group
2006 * group+
2007 * acl:<name or sid>
2008 * acl+:<name or sid>
2010 * In the forms "system.nt_sec_desc.*" and
2011 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2012 * literal, i.e. the string is provided exactly as shown, and
2013 * the value parameter should contain a complete security
2014 * descriptor with name:value pairs separated by tabs,
2015 * commas, or newlines (not spaces!).
2017 * The plus sign ('+') indicates that SIDs should be mapped
2018 * to names. Without the plus sign, SIDs are not mapped;
2019 * rather they are simply converted to a string format.
2021 * @param value The value to be assigned to the specified attribute name.
2022 * This buffer should contain only the attribute value if the
2023 * name was of the "system.nt_sec_desc.<attribute_name>"
2024 * form. If the name was of the "system.nt_sec_desc.*" form
2025 * then a complete security descriptor, with name:value pairs
2026 * separated by tabs, commas, or newlines (not spaces!),
2027 * should be provided in this value buffer. A complete
2028 * security descriptor will contain one or more entries
2029 * selected from the following:
2031 * REVISION:<revision number>
2032 * OWNER:<sid or name>
2033 * GROUP:<sid or name>
2034 * ACL:<sid or name>:<type>/<flags>/<mask>
2036 * The revision of the ACL specifies the internal Windows NT
2037 * ACL revision for the security descriptor. If not specified
2038 * it defaults to 1. Using values other than 1 may cause
2039 * strange behaviour.
2041 * The owner and group specify the owner and group sids for
2042 * the object. If the attribute name (either '*+' with a
2043 * complete security descriptor, or individual 'owner+' or
2044 * 'group+' attribute names) ended with a plus sign, the
2045 * specified name is resolved to a SID value, using the
2046 * server on which the file or directory resides. Otherwise,
2047 * the value should be provided in SID-printable format as
2048 * S-1-x-y-z, and is used directly. The <sid or name>
2049 * associated with the ACL: attribute should be provided
2050 * similarly.
2052 * @param size The number of the bytes of data in the value buffer
2054 * @param flags A bit-wise OR of zero or more of the following:
2055 * SMBC_XATTR_FLAG_CREATE -
2056 * fail if the named attribute already exists
2057 * SMBC_XATTR_FLAG_REPLACE -
2058 * fail if the attribute does not already exist
2060 * If neither flag is specified, the specified attributes
2061 * will be added or replace existing attributes of the same
2062 * name, as necessary.
2064 * @return 0 on success, < 0 on error with errno set:
2065 * - EINVAL The client library is not properly initialized
2066 * or one of the parameters is not of a correct
2067 * form
2068 * - ENOMEM No memory was available for internal needs
2069 * - EEXIST If the attribute already exists and the flag
2070 * SMBC_XATTR_FLAG_CREAT was specified
2071 * - ENOATTR If the attribute does not exist and the flag
2072 * SMBC_XATTR_FLAG_REPLACE was specified
2073 * - EPERM Permission was denied.
2074 * - ENOTSUP The referenced file system does not support
2075 * extended attributes
2077 * @note Attribute names are compared in a case-insensitive
2078 * fashion. All of the following are equivalent, although
2079 * the all-lower-case name is the preferred format:
2080 * system.nt_sec_desc.owner
2081 * SYSTEM.NT_SEC_DESC.OWNER
2082 * sYsTeM.nt_sEc_desc.owNER
2085 int smbc_lsetxattr(const char *url,
2086 const char *name,
2087 const void *value,
2088 size_t size,
2089 int flags);
2092 /**@ingroup attribute
2093 * Set extended attributes for a file. This is used for modifying a file's
2094 * security descriptor (i.e. owner, group, and access control list)
2096 * @param fd A file descriptor associated with an open file (as
2097 * previously returned by smbc_open(), to get extended
2098 * attributes for.
2100 * @param name The name of an attribute to be changed. Names are of
2101 * one of the following forms:
2103 * system.nt_sec_desc.<attribute name>
2104 * system.nt_sec_desc.*
2105 * system.nt_sec_desc.*+
2107 * where <attribute name> is one of:
2109 * revision
2110 * owner
2111 * owner+
2112 * group
2113 * group+
2114 * acl:<name or sid>
2115 * acl+:<name or sid>
2117 * In the forms "system.nt_sec_desc.*" and
2118 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2119 * literal, i.e. the string is provided exactly as shown, and
2120 * the value parameter should contain a complete security
2121 * descriptor with name:value pairs separated by tabs,
2122 * commas, or newlines (not spaces!).
2124 * The plus sign ('+') indicates that SIDs should be mapped
2125 * to names. Without the plus sign, SIDs are not mapped;
2126 * rather they are simply converted to a string format.
2128 * @param value The value to be assigned to the specified attribute name.
2129 * This buffer should contain only the attribute value if the
2130 * name was of the "system.nt_sec_desc.<attribute_name>"
2131 * form. If the name was of the "system.nt_sec_desc.*" form
2132 * then a complete security descriptor, with name:value pairs
2133 * separated by tabs, commas, or newlines (not spaces!),
2134 * should be provided in this value buffer. A complete
2135 * security descriptor will contain one or more entries
2136 * selected from the following:
2138 * REVISION:<revision number>
2139 * OWNER:<sid or name>
2140 * GROUP:<sid or name>
2141 * ACL:<sid or name>:<type>/<flags>/<mask>
2143 * The revision of the ACL specifies the internal Windows NT
2144 * ACL revision for the security descriptor. If not specified
2145 * it defaults to 1. Using values other than 1 may cause
2146 * strange behaviour.
2148 * The owner and group specify the owner and group sids for
2149 * the object. If the attribute name (either '*+' with a
2150 * complete security descriptor, or individual 'owner+' or
2151 * 'group+' attribute names) ended with a plus sign, the
2152 * specified name is resolved to a SID value, using the
2153 * server on which the file or directory resides. Otherwise,
2154 * the value should be provided in SID-printable format as
2155 * S-1-x-y-z, and is used directly. The <sid or name>
2156 * associated with the ACL: attribute should be provided
2157 * similarly.
2159 * @param size The number of the bytes of data in the value buffer
2161 * @param flags A bit-wise OR of zero or more of the following:
2162 * SMBC_XATTR_FLAG_CREATE -
2163 * fail if the named attribute already exists
2164 * SMBC_XATTR_FLAG_REPLACE -
2165 * fail if the attribute does not already exist
2167 * If neither flag is specified, the specified attributes
2168 * will be added or replace existing attributes of the same
2169 * name, as necessary.
2171 * @return 0 on success, < 0 on error with errno set:
2172 * - EINVAL The client library is not properly initialized
2173 * or one of the parameters is not of a correct
2174 * form
2175 * - ENOMEM No memory was available for internal needs
2176 * - EEXIST If the attribute already exists and the flag
2177 * SMBC_XATTR_FLAG_CREAT was specified
2178 * - ENOATTR If the attribute does not exist and the flag
2179 * SMBC_XATTR_FLAG_REPLACE was specified
2180 * - EPERM Permission was denied.
2181 * - ENOTSUP The referenced file system does not support
2182 * extended attributes
2184 * @note Attribute names are compared in a case-insensitive
2185 * fashion. All of the following are equivalent, although
2186 * the all-lower-case name is the preferred format:
2187 * system.nt_sec_desc.owner
2188 * SYSTEM.NT_SEC_DESC.OWNER
2189 * sYsTeM.nt_sEc_desc.owNER
2192 int smbc_fsetxattr(int fd,
2193 const char *name,
2194 const void *value,
2195 size_t size,
2196 int flags);
2199 /**@ingroup attribute
2200 * Get extended attributes for a file.
2202 * @param url The smb url of the file or directory to get extended
2203 * attributes for.
2205 * @param name The name of an attribute to be retrieved. Names are of
2206 * one of the following forms:
2208 * system.nt_sec_desc.<attribute name>
2209 * system.nt_sec_desc.*
2210 * system.nt_sec_desc.*+
2212 * where <attribute name> is one of:
2214 * revision
2215 * owner
2216 * owner+
2217 * group
2218 * group+
2219 * acl:<name or sid>
2220 * acl+:<name or sid>
2222 * In the forms "system.nt_sec_desc.*" and
2223 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2224 * literal, i.e. the string is provided exactly as shown, and
2225 * the value parameter will return a complete security
2226 * descriptor with name:value pairs separated by tabs,
2227 * commas, or newlines (not spaces!).
2229 * The plus sign ('+') indicates that SIDs should be mapped
2230 * to names. Without the plus sign, SIDs are not mapped;
2231 * rather they are simply converted to a string format.
2233 * @param value A pointer to a buffer in which the value of the specified
2234 * attribute will be placed (unless size is zero).
2236 * @param size The size of the buffer pointed to by value. This parameter
2237 * may also be zero, in which case the size of the buffer
2238 * required to hold the attribute value will be returned,
2239 * but nothing will be placed into the value buffer.
2241 * @return 0 on success, < 0 on error with errno set:
2242 * - EINVAL The client library is not properly initialized
2243 * or one of the parameters is not of a correct
2244 * form
2245 * - ENOMEM No memory was available for internal needs
2246 * - EEXIST If the attribute already exists and the flag
2247 * SMBC_XATTR_FLAG_CREAT was specified
2248 * - ENOATTR If the attribute does not exist and the flag
2249 * SMBC_XATTR_FLAG_REPLACE was specified
2250 * - EPERM Permission was denied.
2251 * - ENOTSUP The referenced file system does not support
2252 * extended attributes
2255 int smbc_getxattr(const char *url,
2256 const char *name,
2257 const void *value,
2258 size_t size);
2261 /**@ingroup attribute
2262 * Get extended attributes for a file. The POSIX function which this maps to
2263 * would act on a symbolic link rather than acting on what the symbolic link
2264 * points to, but with no symbolic links in SMB file systems, this function
2265 * is functionally identical to smbc_getxattr().
2267 * @param url The smb url of the file or directory to get extended
2268 * attributes for.
2270 * @param name The name of an attribute to be retrieved. Names are of
2271 * one of the following forms:
2273 * system.nt_sec_desc.<attribute name>
2274 * system.nt_sec_desc.*
2275 * system.nt_sec_desc.*+
2277 * where <attribute name> is one of:
2279 * revision
2280 * owner
2281 * owner+
2282 * group
2283 * group+
2284 * acl:<name or sid>
2285 * acl+:<name or sid>
2287 * In the forms "system.nt_sec_desc.*" and
2288 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2289 * literal, i.e. the string is provided exactly as shown, and
2290 * the value parameter will return a complete security
2291 * descriptor with name:value pairs separated by tabs,
2292 * commas, or newlines (not spaces!).
2294 * The plus sign ('+') indicates that SIDs should be mapped
2295 * to names. Without the plus sign, SIDs are not mapped;
2296 * rather they are simply converted to a string format.
2298 * @param value A pointer to a buffer in which the value of the specified
2299 * attribute will be placed (unless size is zero).
2301 * @param size The size of the buffer pointed to by value. This parameter
2302 * may also be zero, in which case the size of the buffer
2303 * required to hold the attribute value will be returned,
2304 * but nothing will be placed into the value buffer.
2306 * @return 0 on success, < 0 on error with errno set:
2307 * - EINVAL The client library is not properly initialized
2308 * or one of the parameters is not of a correct
2309 * form
2310 * - ENOMEM No memory was available for internal needs
2311 * - EEXIST If the attribute already exists and the flag
2312 * SMBC_XATTR_FLAG_CREAT was specified
2313 * - ENOATTR If the attribute does not exist and the flag
2314 * SMBC_XATTR_FLAG_REPLACE was specified
2315 * - EPERM Permission was denied.
2316 * - ENOTSUP The referenced file system does not support
2317 * extended attributes
2320 int smbc_lgetxattr(const char *url,
2321 const char *name,
2322 const void *value,
2323 size_t size);
2326 /**@ingroup attribute
2327 * Get extended attributes for a file.
2329 * @param fd A file descriptor associated with an open file (as
2330 * previously returned by smbc_open(), to get extended
2331 * attributes for.
2333 * @param name The name of an attribute to be retrieved. Names are of
2334 * one of the following forms:
2336 * system.nt_sec_desc.<attribute name>
2337 * system.nt_sec_desc.*
2338 * system.nt_sec_desc.*+
2340 * where <attribute name> is one of:
2342 * revision
2343 * owner
2344 * owner+
2345 * group
2346 * group+
2347 * acl:<name or sid>
2348 * acl+:<name or sid>
2350 * In the forms "system.nt_sec_desc.*" and
2351 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2352 * literal, i.e. the string is provided exactly as shown, and
2353 * the value parameter will return a complete security
2354 * descriptor with name:value pairs separated by tabs,
2355 * commas, or newlines (not spaces!).
2357 * The plus sign ('+') indicates that SIDs should be mapped
2358 * to names. Without the plus sign, SIDs are not mapped;
2359 * rather they are simply converted to a string format.
2361 * @param value A pointer to a buffer in which the value of the specified
2362 * attribute will be placed (unless size is zero).
2364 * @param size The size of the buffer pointed to by value. This parameter
2365 * may also be zero, in which case the size of the buffer
2366 * required to hold the attribute value will be returned,
2367 * but nothing will be placed into the value buffer.
2369 * @return 0 on success, < 0 on error with errno set:
2370 * - EINVAL The client library is not properly initialized
2371 * or one of the parameters is not of a correct
2372 * form
2373 * - ENOMEM No memory was available for internal needs
2374 * - EEXIST If the attribute already exists and the flag
2375 * SMBC_XATTR_FLAG_CREAT was specified
2376 * - ENOATTR If the attribute does not exist and the flag
2377 * SMBC_XATTR_FLAG_REPLACE was specified
2378 * - EPERM Permission was denied.
2379 * - ENOTSUP The referenced file system does not support
2380 * extended attributes
2383 int smbc_fgetxattr(int fd,
2384 const char *name,
2385 const void *value,
2386 size_t size);
2389 /**@ingroup attribute
2390 * Remove extended attributes for a file. This is used for modifying a file's
2391 * security descriptor (i.e. owner, group, and access control list)
2393 * @param url The smb url of the file or directory to remove the extended
2394 * attributes for.
2396 * @param name The name of an attribute to be removed. Names are of
2397 * one of the following forms:
2399 * system.nt_sec_desc.<attribute name>
2400 * system.nt_sec_desc.*
2401 * system.nt_sec_desc.*+
2403 * where <attribute name> is one of:
2405 * revision
2406 * owner
2407 * owner+
2408 * group
2409 * group+
2410 * acl:<name or sid>
2411 * acl+:<name or sid>
2413 * In the forms "system.nt_sec_desc.*" and
2414 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2415 * literal, i.e. the string is provided exactly as shown, and
2416 * the value parameter will return a complete security
2417 * descriptor with name:value pairs separated by tabs,
2418 * commas, or newlines (not spaces!).
2420 * The plus sign ('+') indicates that SIDs should be mapped
2421 * to names. Without the plus sign, SIDs are not mapped;
2422 * rather they are simply converted to a string format.
2424 * @return 0 on success, < 0 on error with errno set:
2425 * - EINVAL The client library is not properly initialized
2426 * - ENOMEM No memory was available for internal needs
2427 * - EPERM Permission was denied.
2428 * - ENOTSUP The referenced file system does not support
2429 * extended attributes
2432 int smbc_removexattr(const char *url,
2433 const char *name);
2436 /**@ingroup attribute
2437 * Remove extended attributes for a file. This is used for modifying a file's
2438 * security descriptor (i.e. owner, group, and access control list) The POSIX
2439 * function which this maps to would act on a symbolic link rather than acting
2440 * on what the symbolic link points to, but with no symbolic links in SMB file
2441 * systems, this function is functionally identical to smbc_removexattr().
2443 * @param url The smb url of the file or directory to remove the extended
2444 * attributes for.
2446 * @param name The name of an attribute to be removed. Names are of
2447 * one of the following forms:
2449 * system.nt_sec_desc.<attribute name>
2450 * system.nt_sec_desc.*
2451 * system.nt_sec_desc.*+
2453 * where <attribute name> is one of:
2455 * revision
2456 * owner
2457 * owner+
2458 * group
2459 * group+
2460 * acl:<name or sid>
2461 * acl+:<name or sid>
2463 * In the forms "system.nt_sec_desc.*" and
2464 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2465 * literal, i.e. the string is provided exactly as shown, and
2466 * the value parameter will return a complete security
2467 * descriptor with name:value pairs separated by tabs,
2468 * commas, or newlines (not spaces!).
2470 * The plus sign ('+') indicates that SIDs should be mapped
2471 * to names. Without the plus sign, SIDs are not mapped;
2472 * rather they are simply converted to a string format.
2474 * @return 0 on success, < 0 on error with errno set:
2475 * - EINVAL The client library is not properly initialized
2476 * - ENOMEM No memory was available for internal needs
2477 * - EPERM Permission was denied.
2478 * - ENOTSUP The referenced file system does not support
2479 * extended attributes
2482 int smbc_lremovexattr(const char *url,
2483 const char *name);
2486 /**@ingroup attribute
2487 * Remove extended attributes for a file. This is used for modifying a file's
2488 * security descriptor (i.e. owner, group, and access control list)
2490 * @param fd A file descriptor associated with an open file (as
2491 * previously returned by smbc_open(), to get extended
2492 * attributes for.
2494 * @param name The name of an attribute to be removed. Names are of
2495 * one of the following forms:
2497 * system.nt_sec_desc.<attribute name>
2498 * system.nt_sec_desc.*
2499 * system.nt_sec_desc.*+
2501 * where <attribute name> is one of:
2503 * revision
2504 * owner
2505 * owner+
2506 * group
2507 * group+
2508 * acl:<name or sid>
2509 * acl+:<name or sid>
2511 * In the forms "system.nt_sec_desc.*" and
2512 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2513 * literal, i.e. the string is provided exactly as shown, and
2514 * the value parameter will return a complete security
2515 * descriptor with name:value pairs separated by tabs,
2516 * commas, or newlines (not spaces!).
2518 * The plus sign ('+') indicates that SIDs should be mapped
2519 * to names. Without the plus sign, SIDs are not mapped;
2520 * rather they are simply converted to a string format.
2522 * @return 0 on success, < 0 on error with errno set:
2523 * - EINVAL The client library is not properly initialized
2524 * - ENOMEM No memory was available for internal needs
2525 * - EPERM Permission was denied.
2526 * - ENOTSUP The referenced file system does not support
2527 * extended attributes
2530 int smbc_fremovexattr(int fd,
2531 const char *name);
2534 /**@ingroup attribute
2535 * List the supported extended attribute names associated with a file
2537 * @param url The smb url of the file or directory to list the extended
2538 * attributes for.
2540 * @param list A pointer to a buffer in which the list of attributes for
2541 * the specified file or directory will be placed (unless
2542 * size is zero).
2544 * @param size The size of the buffer pointed to by list. This parameter
2545 * may also be zero, in which case the size of the buffer
2546 * required to hold all of the attribute names will be
2547 * returned, but nothing will be placed into the list buffer.
2549 * @return 0 on success, < 0 on error with errno set:
2550 * - EINVAL The client library is not properly initialized
2551 * - ENOMEM No memory was available for internal needs
2552 * - EPERM Permission was denied.
2553 * - ENOTSUP The referenced file system does not support
2554 * extended attributes
2556 * @note This function always returns all attribute names supported
2557 * by NT file systems, regardless of whether the referenced
2558 * file system supports extended attributes (e.g. a Windows
2559 * 2000 machine supports extended attributes if NTFS is used,
2560 * but not if FAT is used, and Windows 98 doesn't support
2561 * extended attributes at all. Whether this is a feature or
2562 * a bug is yet to be decided.
2564 int smbc_listxattr(const char *url,
2565 char *list,
2566 size_t size);
2568 /**@ingroup attribute
2569 * List the supported extended attribute names associated with a file The
2570 * POSIX function which this maps to would act on a symbolic link rather than
2571 * acting on what the symbolic link points to, but with no symbolic links in
2572 * SMB file systems, this function is functionally identical to
2573 * smbc_listxattr().
2575 * @param url The smb url of the file or directory to list the extended
2576 * attributes for.
2578 * @param list A pointer to a buffer in which the list of attributes for
2579 * the specified file or directory will be placed (unless
2580 * size is zero).
2582 * @param size The size of the buffer pointed to by list. This parameter
2583 * may also be zero, in which case the size of the buffer
2584 * required to hold all of the attribute names will be
2585 * returned, but nothing will be placed into the list buffer.
2587 * @return 0 on success, < 0 on error with errno set:
2588 * - EINVAL The client library is not properly initialized
2589 * - ENOMEM No memory was available for internal needs
2590 * - EPERM Permission was denied.
2591 * - ENOTSUP The referenced file system does not support
2592 * extended attributes
2594 * @note This function always returns all attribute names supported
2595 * by NT file systems, regardless of wether the referenced
2596 * file system supports extended attributes (e.g. a Windows
2597 * 2000 machine supports extended attributes if NTFS is used,
2598 * but not if FAT is used, and Windows 98 doesn't support
2599 * extended attributes at all. Whether this is a feature or
2600 * a bug is yet to be decided.
2602 int smbc_llistxattr(const char *url,
2603 char *list,
2604 size_t size);
2606 /**@ingroup attribute
2607 * List the supported extended attribute names associated with a file
2609 * @param fd A file descriptor associated with an open file (as
2610 * previously returned by smbc_open(), to get extended
2611 * attributes for.
2613 * @param list A pointer to a buffer in which the list of attributes for
2614 * the specified file or directory will be placed (unless
2615 * size is zero).
2617 * @param size The size of the buffer pointed to by list. This parameter
2618 * may also be zero, in which case the size of the buffer
2619 * required to hold all of the attribute names will be
2620 * returned, but nothing will be placed into the list buffer.
2622 * @return 0 on success, < 0 on error with errno set:
2623 * - EINVAL The client library is not properly initialized
2624 * - ENOMEM No memory was available for internal needs
2625 * - EPERM Permission was denied.
2626 * - ENOTSUP The referenced file system does not support
2627 * extended attributes
2629 * @note This function always returns all attribute names supported
2630 * by NT file systems, regardless of wether the referenced
2631 * file system supports extended attributes (e.g. a Windows
2632 * 2000 machine supports extended attributes if NTFS is used,
2633 * but not if FAT is used, and Windows 98 doesn't support
2634 * extended attributes at all. Whether this is a feature or
2635 * a bug is yet to be decided.
2637 int smbc_flistxattr(int fd,
2638 char *list,
2639 size_t size);
2641 /**@ingroup print
2642 * Print a file given the name in fname. It would be a URL ...
2644 * @param fname The URL of a file on a remote SMB server that the
2645 * caller wants printed
2647 * @param printq The URL of the print share to print the file to.
2649 * @return 0 on success, < 0 on error with errno set:
2651 * - EINVAL fname or printq was NULL or smbc_init not
2652 * not called.
2653 * and errors returned by smbc_open
2656 int smbc_print_file(const char *fname, const char *printq);
2658 /**@ingroup print
2659 * Open a print file that can be written to by other calls. This simply
2660 * does an smbc_open call after checking if there is a file name on the
2661 * URI. If not, a temporary name is added ...
2663 * @param fname The URL of the print share to print to?
2665 * @returns A file handle for the print file if successful.
2666 * Returns -1 if an error ocurred and errno has the values
2667 * - EINVAL fname was NULL or smbc_init not called.
2668 * - all errors returned by smbc_open
2671 int smbc_open_print_job(const char *fname);
2673 /**@ingroup print
2674 * List the print jobs on a print share, for the moment, pass a callback
2676 * @param purl The url of the print share to list the jobs of
2678 * @param fn Callback function the receives printjob info
2680 * @return 0 on success, < 0 on error with errno set:
2681 * - EINVAL fname was NULL or smbc_init not called
2682 * - EACCES ???
2684 int smbc_list_print_jobs(const char *purl, smbc_list_print_job_fn fn);
2686 /**@ingroup print
2687 * Delete a print job
2689 * @param purl Url of the print share
2691 * @param id The id of the job to delete
2693 * @return 0 on success, < 0 on error with errno set:
2694 * - EINVAL fname was NULL or smbc_init not called
2696 * @todo what errno values are possible here?
2698 int smbc_unlink_print_job(const char *purl, int id);
2700 /**@ingroup callback
2701 * Remove a server from the cached server list it's unused.
2703 * @param context pointer to smb context
2705 * @param srv pointer to server to remove
2707 * @return On success, 0 is returned. 1 is returned if the server could not
2708 * be removed. Also useable outside libsmbclient.
2710 int smbc_remove_unused_server(SMBCCTX * context, SMBCSRV * srv);
2712 #ifdef __cplusplus
2714 #endif
2716 /**@ingroup directory
2717 * Convert strings of %xx to their single character equivalent.
2719 * @param dest A pointer to a buffer in which the resulting decoded
2720 * string should be placed. This may be a pointer to the
2721 * same buffer as src_segment.
2723 * @param src A pointer to the buffer containing the URL to be decoded.
2724 * Any %xx sequences herein are converted to their single
2725 * character equivalent. Each 'x' must be a valid hexadecimal
2726 * digit, or that % sequence is left undecoded.
2728 * @param max_dest_len
2729 * The size of the buffer pointed to by dest_segment.
2731 * @return The number of % sequences which could not be converted
2732 * due to lack of two following hexadecimal digits.
2734 #ifdef __cplusplus
2735 extern "C" {
2736 #endif
2738 smbc_urldecode(char *dest, char * src, size_t max_dest_len);
2739 #ifdef __cplusplus
2741 #endif
2745 * Convert any characters not specifically allowed in a URL into their %xx
2746 * equivalent.
2748 * @param dest A pointer to a buffer in which the resulting encoded
2749 * string should be placed. Unlike smbc_urldecode(), this
2750 * must be a buffer unique from src.
2752 * @param src A pointer to the buffer containing the string to be encoded.
2753 * Any character not specifically allowed in a URL is converted
2754 * into its hexadecimal value and encoded as %xx.
2756 * @param max_dest_len
2757 * The size of the buffer pointed to by dest_segment.
2759 * @returns The remaining buffer length.
2761 #ifdef __cplusplus
2762 extern "C" {
2763 #endif
2765 smbc_urlencode(char * dest, char * src, int max_dest_len);
2766 #ifdef __cplusplus
2768 #endif
2771 /**@ingroup directory
2772 * Return the version of the linked Samba code, and thus the version of the
2773 * libsmbclient code.
2775 * @return The version string.
2777 #ifdef __cplusplus
2778 extern "C" {
2779 #endif
2780 const char *
2781 smbc_version(void);
2782 #ifdef __cplusplus
2784 #endif
2786 /**@ingroup misc
2787 * Set the users credentials globally so they can be used for DFS
2788 * referrals. Probably best to use this function in the smbc_get_auth_data_fn
2789 * callback.
2791 * @param workgroup Workgroup of the user.
2793 * @param user Username of user.
2795 * @param password Password of user.
2797 * @param use_kerberos Whether to use Kerberos
2799 * @param signing_state One of these strings (all equivalents on same line):
2800 * "off", "no", "false"
2801 * "on", "yes", "true", "auto"
2802 * "force", "required", "forced"
2805 void
2806 smbc_set_credentials(const char *workgroup,
2807 const char *user,
2808 const char *password,
2809 smbc_bool use_kerberos,
2810 const char *signing_state);
2813 * Wrapper around smbc_set_credentials.
2814 * Used to set correct credentials that will
2815 * be used to connect to DFS target share
2816 * in libsmbclient
2819 void
2820 smbc_set_credentials_with_fallback(SMBCCTX *ctx,
2821 const char *workgroup,
2822 const char *user,
2823 const char *password);
2827 * @ingroup threads
2829 * Initialize for threads using the Posix Threads (pthread)
2830 * implementation. This is a built-in implementation, avoiding the need to
2831 * implement the component functions of the thread interface. If this function
2832 * is used, it is not necessary to call smbc_thread_impl().
2834 * @return {void}
2836 void
2837 smbc_thread_posix(void);
2840 * @ingroup threads
2842 * Initialize for an arbitrary thread implementation. The caller should
2843 * provide, as parameters, pointers to functions to implement the requisite
2844 * low-level thread functionality. A function must be provided for each
2845 * parameter; none may be null.
2847 * If the thread implementation is POSIX Threads (pthreads), then the much
2848 * simpler smbc_thread_pthread() function may be used instead of this one.
2850 * @param create_mutex
2851 * Create a mutex. This function should expect three parameters: lockname,
2852 * pplock, and location. It should create a unique mutex for each unique
2853 * lockname it is provided, and return the mutex identifier in *pplock. The
2854 * location parameter can be used for debugging, as it contains the
2855 * compiler-provided __location__ of the call.
2857 * @param destroy_mutex
2858 * Destroy a mutex. This function should expect two parameters: plock and
2859 * location. It should destroy the mutex associated with the identifier
2860 * plock. The location parameter can be used for debugging, as it contains
2861 * the compiler-provided __location__ of the call.
2863 * @param lock_mutex
2864 * Lock a mutex. This function should expect three parameters: plock,
2865 * lock_type, and location. The mutex aassociated with identifier plock
2866 * should be locked if lock_type is 1, and unlocked if lock_type is 2. The
2867 * location parameter can be used for debugging, as it contains the
2868 * compiler-provided __location__ of the call.
2870 * @param create_tls
2871 * Create thread local storage. This function should expect three
2872 * parameters: keyname, ppkey, and location. It should allocate an
2873 * implementation-specific amount of memory and assign the pointer to that
2874 * allocated memory to *ppkey. The location parameter can be used for
2875 * debugging, as it contains the compiler-provided __location__ of the
2876 * call. This function should return 0 upon success, non-zero upon failure.
2878 * @param destroy_tls
2879 * Destroy thread local storage. This function should expect two parameters:
2880 * ppkey and location. The ppkey parameter points to a variable containing a
2881 * thread local storage key previously provided by the create_tls
2882 * function. The location parameter can be used for debugging, as it
2883 * contains the compiler-provided __location__ of the call.
2885 * @param set_tls
2886 * Set a thread local storage variable's value. This function should expect
2887 * three parameters: pkey, pval, and location. The pkey parameter is a
2888 * thread local storage key previously provided by the create_tls
2889 * function. The (void *) pval parameter contains the value to be placed in
2890 * the thread local storage variable identified by pkey. The location
2891 * parameter can be used for debugging, as it contains the compiler-provided
2892 * __location__ of the call. This function should return 0 upon success;
2893 * non-zero otherwise.
2895 * @param get_tls
2896 * Retrieve a thread local storage variable's value. This function should
2897 * expect two parameters: pkey and location. The pkey parameter is a thread
2898 * local storage key previously provided by the create_tls function, and
2899 * which has previously been used in a call to the set_tls function to
2900 * initialize a thread local storage variable. The location parameter can be
2901 * used for debugging, as it contains the compiler-provided __location__ of
2902 * the call. This function should return the (void *) value stored in the
2903 * variable identified by pkey.
2905 * @return {void}
2907 void
2908 smbc_thread_impl(
2909 /* Mutex functions. */
2910 int (*create_mutex)(const char *lockname,
2911 void **pplock,
2912 const char *location),
2913 void (*destroy_mutex)(void *plock,
2914 const char *location),
2915 int (*lock_mutex)(void *plock,
2916 int lock_type,
2917 const char *location),
2919 /* Thread local storage. */
2920 int (*create_tls)(const char *keyname,
2921 void **ppkey,
2922 const char *location),
2923 void (*destroy_tls)(void **ppkey,
2924 const char *location),
2925 int (*set_tls)(void *pkey,
2926 const void *pval,
2927 const char *location),
2928 void *(*get_tls)(void *pkey,
2929 const char *location)
2935 * @ingroup structure
2936 * Structure that contains a client context information
2937 * This structure is known as SMBCCTX
2939 * DO NOT DIRECTLY MANIPULATE THE CONTEXT STRUCTURE! The data in the context
2940 * structure should all be considered private to the library. It remains here
2941 * only for backward compatibility.
2943 * See the comments herein for use of the setter and getter functions which
2944 * should now be used for manipulating these values. New features, functions,
2945 * etc., are not added here but rather in _internal where they are not
2946 * directly visible to applications. This makes it much easier to maintain
2947 * ABI compatibility.
2949 struct _SMBCCTX
2952 * debug level
2954 * DEPRECATED:
2955 * Use smbc_getDebug() and smbc_setDebug()
2957 int debug DEPRECATED_SMBC_INTERFACE;
2960 * netbios name used for making connections
2962 * DEPRECATED:
2963 * Use smbc_getNetbiosName() and smbc_setNetbiosName()
2965 char * netbios_name DEPRECATED_SMBC_INTERFACE;
2968 * workgroup name used for making connections
2970 * DEPRECATED:
2971 * Use smbc_getWorkgroup() and smbc_setWorkgroup()
2973 char * workgroup DEPRECATED_SMBC_INTERFACE;
2976 * username used for making connections
2978 * DEPRECATED:
2979 * Use smbc_getUser() and smbc_setUser()
2981 char * user DEPRECATED_SMBC_INTERFACE;
2984 * timeout used for waiting on connections / response data (in
2985 * milliseconds)
2987 * DEPRECATED:
2988 * Use smbc_getTimeout() and smbc_setTimeout()
2990 int timeout DEPRECATED_SMBC_INTERFACE;
2993 * callable functions for files:
2994 * For usage and return values see the SMBC_* functions
2996 * DEPRECATED:
2998 * Use smbc_getFunction*() and smbc_setFunction*(), e.g.
2999 * smbc_getFunctionOpen(), smbc_setFunctionUnlink(), etc.
3001 smbc_open_fn open DEPRECATED_SMBC_INTERFACE;
3002 smbc_creat_fn creat DEPRECATED_SMBC_INTERFACE;
3003 smbc_read_fn read DEPRECATED_SMBC_INTERFACE;
3004 smbc_write_fn write DEPRECATED_SMBC_INTERFACE;
3005 smbc_unlink_fn unlink DEPRECATED_SMBC_INTERFACE;
3006 smbc_rename_fn rename DEPRECATED_SMBC_INTERFACE;
3007 smbc_lseek_fn lseek DEPRECATED_SMBC_INTERFACE;
3008 smbc_stat_fn stat DEPRECATED_SMBC_INTERFACE;
3009 smbc_fstat_fn fstat DEPRECATED_SMBC_INTERFACE;
3010 #if 0 /* internal */
3011 smbc_ftruncate_fn ftruncate_fn;
3012 #endif
3013 smbc_close_fn close_fn DEPRECATED_SMBC_INTERFACE;
3014 smbc_opendir_fn opendir DEPRECATED_SMBC_INTERFACE;
3015 smbc_closedir_fn closedir DEPRECATED_SMBC_INTERFACE;
3016 smbc_readdir_fn readdir DEPRECATED_SMBC_INTERFACE;
3017 smbc_getdents_fn getdents DEPRECATED_SMBC_INTERFACE;
3018 smbc_mkdir_fn mkdir DEPRECATED_SMBC_INTERFACE;
3019 smbc_rmdir_fn rmdir DEPRECATED_SMBC_INTERFACE;
3020 smbc_telldir_fn telldir DEPRECATED_SMBC_INTERFACE;
3021 smbc_lseekdir_fn lseekdir DEPRECATED_SMBC_INTERFACE;
3022 smbc_fstatdir_fn fstatdir DEPRECATED_SMBC_INTERFACE;
3023 smbc_chmod_fn chmod DEPRECATED_SMBC_INTERFACE;
3024 smbc_utimes_fn utimes DEPRECATED_SMBC_INTERFACE;
3025 smbc_setxattr_fn setxattr DEPRECATED_SMBC_INTERFACE;
3026 smbc_getxattr_fn getxattr DEPRECATED_SMBC_INTERFACE;
3027 smbc_removexattr_fn removexattr DEPRECATED_SMBC_INTERFACE;
3028 smbc_listxattr_fn listxattr DEPRECATED_SMBC_INTERFACE;
3030 /* Printing-related functions */
3031 smbc_print_file_fn print_file DEPRECATED_SMBC_INTERFACE;
3032 smbc_open_print_job_fn open_print_job DEPRECATED_SMBC_INTERFACE;
3033 smbc_list_print_jobs_fn list_print_jobs DEPRECATED_SMBC_INTERFACE;
3034 smbc_unlink_print_job_fn unlink_print_job DEPRECATED_SMBC_INTERFACE;
3037 ** Callbacks
3039 * DEPRECATED:
3041 * See the comment above each field, for the getter and setter
3042 * functions that should now be used.
3044 struct _smbc_callbacks
3047 * authentication function callback: called upon auth requests
3049 * DEPRECATED:
3050 * Use smbc_getFunctionAuthData(), smbc_setFunctionAuthData()
3052 smbc_get_auth_data_fn auth_fn DEPRECATED_SMBC_INTERFACE;
3055 * check if a server is still good
3057 * DEPRECATED:
3058 * Use smbc_getFunctionCheckServer(),
3059 * smbc_setFunctionCheckServer()
3061 smbc_check_server_fn check_server_fn DEPRECATED_SMBC_INTERFACE;
3064 * remove a server if unused
3066 * DEPRECATED:
3067 * Use smbc_getFunctionRemoveUnusedServer(),
3068 * smbc_setFunctionCheckServer()
3070 smbc_remove_unused_server_fn remove_unused_server_fn DEPRECATED_SMBC_INTERFACE;
3072 /** Cache subsystem
3074 * For an example cache system see
3075 * samba/source/libsmb/libsmb_cache.c
3077 * Cache subsystem * functions follow.
3081 * server cache addition
3083 * DEPRECATED:
3084 * Use smbc_getFunctionAddCachedServer(),
3085 * smbc_setFunctionAddCachedServer()
3087 smbc_add_cached_srv_fn add_cached_srv_fn DEPRECATED_SMBC_INTERFACE;
3090 * server cache lookup
3092 * DEPRECATED:
3093 * Use smbc_getFunctionGetCachedServer(),
3094 * smbc_setFunctionGetCachedServer()
3096 smbc_get_cached_srv_fn get_cached_srv_fn DEPRECATED_SMBC_INTERFACE;
3099 * server cache removal
3101 * DEPRECATED:
3102 * Use smbc_getFunctionRemoveCachedServer(),
3103 * smbc_setFunctionRemoveCachedServer()
3105 smbc_remove_cached_srv_fn remove_cached_srv_fn DEPRECATED_SMBC_INTERFACE;
3108 * server cache purging, try to remove all cached servers
3109 * (disconnect)
3111 * DEPRECATED:
3112 * Use smbc_getFunctionPurgeCachedServers(),
3113 * smbc_setFunctionPurgeCachedServers()
3115 smbc_purge_cached_fn purge_cached_fn DEPRECATED_SMBC_INTERFACE;
3116 } callbacks;
3119 * Space where the private data of the server cache used to be
3121 * DEPRECATED:
3122 * Use smbc_getServerCacheData(), smbc_setServerCacheData()
3124 void * reserved DEPRECATED_SMBC_INTERFACE;
3127 * Very old configuration options.
3129 * DEPRECATED:
3130 * Use one of the following functions instead:
3131 * smbc_setOptionUseKerberos()
3132 * smbc_getOptionUseKerberos()
3133 * smbc_setOptionFallbackAfterKerberos()
3134 * smbc_getOptionFallbackAfterKerberos()
3135 * smbc_setOptionNoAutoAnonymousLogin()
3136 * smbc_getOptionNoAutoAnonymousLogin()
3138 int flags DEPRECATED_SMBC_INTERFACE;
3141 * user options selections that apply to this session
3143 * NEW OPTIONS ARE NOT ADDED HERE!
3145 * DEPRECATED:
3146 * To set and retrieve options, use the smbc_setOption*() and
3147 * smbc_getOption*() functions.
3149 struct _smbc_options {
3150 int browse_max_lmb_count DEPRECATED_SMBC_INTERFACE;
3151 int urlencode_readdir_entries DEPRECATED_SMBC_INTERFACE;
3152 int one_share_per_server DEPRECATED_SMBC_INTERFACE;
3153 } options DEPRECATED_SMBC_INTERFACE;
3155 /** INTERNAL DATA
3156 * do _NOT_ touch this from your program !
3158 struct SMBC_internal_data * internal;
3162 #endif /* SMBCLIENT_H_INCLUDED */