Resync with broadcom drivers 5.100.138.20 and utilities.
[tomato.git] / release / src-rt / include / libsmbclient.h
blob81df7f58654f891afc2d59ee2ddf237133c97377
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 <fcntl.h>
80 #include <utime.h>
82 #define SMBC_BASE_FD 10000 /* smallest file descriptor returned */
84 #define SMBC_WORKGROUP 1
85 #define SMBC_SERVER 2
86 #define SMBC_FILE_SHARE 3
87 #define SMBC_PRINTER_SHARE 4
88 #define SMBC_COMMS_SHARE 5
89 #define SMBC_IPC_SHARE 6
90 #define SMBC_DIR 7
91 #define SMBC_FILE 8
92 #define SMBC_LINK 9
94 /**@ingroup structure
95 * Structure that represents a directory entry.
98 struct smbc_dirent
100 /** Type of entity.
101 SMBC_WORKGROUP=1,
102 SMBC_SERVER=2,
103 SMBC_FILE_SHARE=3,
104 SMBC_PRINTER_SHARE=4,
105 SMBC_COMMS_SHARE=5,
106 SMBC_IPC_SHARE=6,
107 SMBC_DIR=7,
108 SMBC_FILE=8,
109 SMBC_LINK=9,*/
110 unsigned int smbc_type;
112 /** Length of this smbc_dirent in bytes
114 unsigned int dirlen;
115 /** The length of the comment string in bytes (does not include
116 * null terminator)
118 unsigned int commentlen;
119 /** Points to the null terminated comment string
121 char *comment;
122 /** The length of the name string in bytes (does not include
123 * null terminator)
125 unsigned int namelen;
126 /** Points to the null terminated name string
128 char name[1];
132 * Flags for smbc_setxattr()
133 * Specify a bitwise OR of these, or 0 to add or replace as necessary
135 #define SMBC_XATTR_FLAG_CREATE 0x1 /* fail if attr already exists */
136 #define SMBC_XATTR_FLAG_REPLACE 0x2 /* fail if attr does not exist */
140 * Mappings of the DOS mode bits, as returned by smbc_getxattr() when the
141 * attribute name "system.dos_attr.mode" (or "system.dos_attr.*" or
142 * "system.*") is specified.
144 #define SMBC_DOS_MODE_READONLY 0x01
145 #define SMBC_DOS_MODE_HIDDEN 0x02
146 #define SMBC_DOS_MODE_SYSTEM 0x04
147 #define SMBC_DOS_MODE_VOLUME_ID 0x08
148 #define SMBC_DOS_MODE_DIRECTORY 0x10
149 #define SMBC_DOS_MODE_ARCHIVE 0x20
152 * Valid values for the option "open_share_mode", when calling
153 * smbc_setOptionOpenShareMode()
155 typedef enum smbc_share_mode
157 SMBC_SHAREMODE_DENY_DOS = 0,
158 SMBC_SHAREMODE_DENY_ALL = 1,
159 SMBC_SHAREMODE_DENY_WRITE = 2,
160 SMBC_SHAREMODE_DENY_READ = 3,
161 SMBC_SHAREMODE_DENY_NONE = 4,
162 SMBC_SHAREMODE_DENY_FCB = 7
163 } smbc_share_mode;
167 * Values for option SMB Encryption Level, as set and retrieved with
168 * smbc_setOptionSmbEncryptionLevel() and smbc_getOptionSmbEncryptionLevel()
170 typedef enum smbc_smb_encrypt_level
172 SMBC_ENCRYPTLEVEL_NONE = 0,
173 SMBC_ENCRYPTLEVEL_REQUEST = 1,
174 SMBC_ENCRYPTLEVEL_REQUIRE = 2
175 } smbc_smb_encrypt_level;
179 * Capabilities set in the f_flag field of struct statvfs, from
180 * smbc_statvfs(). These may be OR-ed together to reflect a full set of
181 * available capabilities.
183 typedef enum smbc_vfs_feature
185 /* Defined by POSIX or in Linux include files (low-order bits) */
186 SMBC_VFS_FEATURE_RDONLY = (1 << 0),
188 /* Specific to libsmbclient (high-order bits) */
189 SMBC_VFS_FEATURE_DFS = (1 << 28),
190 SMBC_VFS_FEATURE_CASE_INSENSITIVE = (1 << 29),
191 SMBC_VFS_FEATURE_NO_UNIXCIFS = (1 << 30)
192 } smbc_vfs_feature;
194 typedef int smbc_bool;
197 #ifndef ENOATTR
198 # define ENOATTR ENOENT /* No such attribute */
199 #endif
204 /**@ingroup structure
205 * Structure that represents a print job.
208 #ifndef _CLIENT_H
209 struct print_job_info
211 /** numeric ID of the print job
213 unsigned short id;
215 /** represents print job priority (lower numbers mean higher priority)
217 unsigned short priority;
219 /** Size of the print job
221 size_t size;
223 /** Name of the user that owns the print job
225 char user[128];
227 /** Name of the print job. This will have no name if an anonymous print
228 * file was opened. Ie smb://server/printer
230 char name[128];
232 /** Time the print job was spooled
234 time_t t;
237 typedef struct file_info {
238 struct cli_state *cli;
239 uint64_t size;
240 uint16_t mode;
241 uid_t uid;
242 gid_t gid;
243 /* these times are normally kept in GMT */
244 struct timespec mtime_ts;
245 struct timespec atime_ts;
246 struct timespec ctime_ts;
247 char *name;
248 char short_name[13*3]; /* the *3 is to cope with multi-byte */
249 } file_info;
251 #endif /* _CLIENT_H */
254 /**@ingroup structure
255 * Server handle
257 typedef struct _SMBCSRV SMBCSRV;
259 /**@ingroup structure
260 * File or directory handle
262 typedef struct _SMBCFILE SMBCFILE;
264 /**@ingroup structure
265 * File or directory handle
267 typedef struct _SMBCCTX SMBCCTX;
271 * Flags for SMBCCTX->flags
273 * NEW CODE SHOULD NOT DIRECTLY MANIPULATE THE CONTEXT STRUCTURE.
274 * Instead, use:
275 * smbc_setOptionUseKerberos()
276 * smbc_getOptionUseKerberos()
277 * smbc_setOptionFallbackAfterKerberos()
278 * smbc_getOptionFallbackAFterKerberos()
279 * smbc_setOptionNoAutoAnonymousLogin()
280 * smbc_getOptionNoAutoAnonymousLogin()
281 * smbc_setOptionUseCCache()
282 * smbc_getOptionUseCCache()
284 # define SMB_CTX_FLAG_USE_KERBEROS (1 << 0)
285 # define SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS (1 << 1)
286 # define SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON (1 << 2)
287 # define SMB_CTX_FLAG_USE_CCACHE (1 << 3)
291 /**@ingroup callback
292 * Authentication callback function type (traditional method)
294 * Type for the the authentication function called by the library to
295 * obtain authentication credentals
297 * For kerberos support the function should just be called without
298 * prompting the user for credentials. Which means a simple 'return'
299 * should work. Take a look at examples/libsmbclient/get_auth_data_fn.h
300 * and examples/libsmbclient/testbrowse.c.
302 * @param srv Server being authenticated to
304 * @param shr Share being authenticated to
306 * @param wg Pointer to buffer containing a "hint" for the
307 * workgroup to be authenticated. Should be filled in
308 * with the correct workgroup if the hint is wrong.
310 * @param wglen The size of the workgroup buffer in bytes
312 * @param un Pointer to buffer containing a "hint" for the
313 * user name to be use for authentication. Should be
314 * filled in with the correct workgroup if the hint is
315 * wrong.
317 * @param unlen The size of the username buffer in bytes
319 * @param pw Pointer to buffer containing to which password
320 * copied
322 * @param pwlen The size of the password buffer in bytes
325 typedef void (*smbc_get_auth_data_fn)(const char *srv,
326 const char *shr,
327 char *wg, int wglen,
328 char *un, int unlen,
329 char *pw, int pwlen);
330 /**@ingroup callback
331 * Authentication callback function type (method that includes context)
333 * Type for the the authentication function called by the library to
334 * obtain authentication credentals
336 * For kerberos support the function should just be called without
337 * prompting the user for credentials. Which means a simple 'return'
338 * should work. Take a look at examples/libsmbclient/get_auth_data_fn.h
339 * and examples/libsmbclient/testbrowse.c.
341 * @param c Pointer to the smb context
343 * @param srv Server being authenticated to
345 * @param shr Share being authenticated to
347 * @param wg Pointer to buffer containing a "hint" for the
348 * workgroup to be authenticated. Should be filled in
349 * with the correct workgroup if the hint is wrong.
351 * @param wglen The size of the workgroup buffer in bytes
353 * @param un Pointer to buffer containing a "hint" for the
354 * user name to be use for authentication. Should be
355 * filled in with the correct workgroup if the hint is
356 * wrong.
358 * @param unlen The size of the username buffer in bytes
360 * @param pw Pointer to buffer containing to which password
361 * copied
363 * @param pwlen The size of the password buffer in bytes
366 typedef void (*smbc_get_auth_data_with_context_fn)(SMBCCTX *c,
367 const char *srv,
368 const char *shr,
369 char *wg, int wglen,
370 char *un, int unlen,
371 char *pw, int pwlen);
374 /**@ingroup callback
375 * Print job info callback function type.
377 * @param i pointer to print job information structure
380 typedef void (*smbc_list_print_job_fn)(struct print_job_info *i);
383 /**@ingroup callback
384 * Check if a server is still good
386 * @param c pointer to smb context
388 * @param srv pointer to server to check
390 * @return 0 when connection is good. 1 on error.
393 typedef int (*smbc_check_server_fn)(SMBCCTX * c, SMBCSRV *srv);
395 /**@ingroup callback
396 * Remove a server if unused
398 * @param c pointer to smb context
400 * @param srv pointer to server to remove
402 * @return 0 on success. 1 on failure.
405 typedef int (*smbc_remove_unused_server_fn)(SMBCCTX * c, SMBCSRV *srv);
408 /**@ingroup callback
409 * Add a server to the cache system
411 * @param c pointer to smb context
413 * @param srv pointer to server to add
415 * @param server server name
417 * @param share share name
419 * @param workgroup workgroup used to connect
421 * @param username username used to connect
423 * @return 0 on success. 1 on failure.
426 typedef int (*smbc_add_cached_srv_fn) (SMBCCTX * c, SMBCSRV *srv,
427 const char * server, const char * share,
428 const char * workgroup, const char * username);
430 /**@ingroup callback
431 * Look up a server in the cache system
433 * @param c pointer to smb context
435 * @param server server name to match
437 * @param share share name to match
439 * @param workgroup workgroup to match
441 * @param username username to match
443 * @return pointer to SMBCSRV on success. NULL on failure.
446 typedef SMBCSRV * (*smbc_get_cached_srv_fn) (SMBCCTX * c, const char * server,
447 const char * share, const char * workgroup,
448 const char * username);
450 /**@ingroup callback
451 * Check if a server is still good
453 * @param c pointer to smb context
455 * @param srv pointer to server to remove
457 * @return 0 when found and removed. 1 on failure.
460 typedef int (*smbc_remove_cached_srv_fn)(SMBCCTX * c, SMBCSRV *srv);
463 /**@ingroup callback
464 * Try to remove all servers from the cache system and disconnect
466 * @param c pointer to smb context
468 * @return 0 when found and removed. 1 on failure.
471 typedef int (*smbc_purge_cached_fn) (SMBCCTX * c);
475 /*****************************************
476 * Getters and setters for CONFIGURATION *
477 *****************************************/
479 /** Get the debug level */
481 smbc_getDebug(SMBCCTX *c);
483 /** Set the debug level */
484 void
485 smbc_setDebug(SMBCCTX *c, int debug);
487 /** Get the netbios name used for making connections */
488 char *
489 smbc_getNetbiosName(SMBCCTX *c);
491 /** Set the netbios name used for making connections */
492 void
493 smbc_setNetbiosName(SMBCCTX *c, char * netbios_name);
495 /** Get the workgroup used for making connections */
496 char *
497 smbc_getWorkgroup(SMBCCTX *c);
499 /** Set the workgroup used for making connections */
500 void smbc_setWorkgroup(SMBCCTX *c, char * workgroup);
502 /** Get the username used for making connections */
503 char *
504 smbc_getUser(SMBCCTX *c);
506 /** Set the username used for making connections */
507 void
508 smbc_setUser(SMBCCTX *c, char * user);
511 * Get the timeout used for waiting on connections and response data
512 * (in milliseconds)
515 smbc_getTimeout(SMBCCTX *c);
518 * Set the timeout used for waiting on connections and response data
519 * (in milliseconds)
521 void
522 smbc_setTimeout(SMBCCTX *c, int timeout);
526 /***********************************
527 * Getters and setters for OPTIONS *
528 ***********************************/
530 /** Get whether to log to standard error instead of standard output */
531 smbc_bool
532 smbc_getOptionDebugToStderr(SMBCCTX *c);
534 /** Set whether to log to standard error instead of standard output */
535 void
536 smbc_setOptionDebugToStderr(SMBCCTX *c, smbc_bool b);
539 * Get whether to use new-style time attribute names, e.g. WRITE_TIME rather
540 * than the old-style names such as M_TIME. This allows also setting/getting
541 * CREATE_TIME which was previously unimplemented. (Note that the old C_TIME
542 * was supposed to be CHANGE_TIME but was confused and sometimes referred to
543 * CREATE_TIME.)
545 smbc_bool
546 smbc_getOptionFullTimeNames(SMBCCTX *c);
549 * Set whether to use new-style time attribute names, e.g. WRITE_TIME rather
550 * than the old-style names such as M_TIME. This allows also setting/getting
551 * CREATE_TIME which was previously unimplemented. (Note that the old C_TIME
552 * was supposed to be CHANGE_TIME but was confused and sometimes referred to
553 * CREATE_TIME.)
555 void
556 smbc_setOptionFullTimeNames(SMBCCTX *c, smbc_bool b);
559 * Get the share mode to use for files opened with SMBC_open_ctx(). The
560 * default is SMBC_SHAREMODE_DENY_NONE.
562 smbc_share_mode
563 smbc_getOptionOpenShareMode(SMBCCTX *c);
566 * Set the share mode to use for files opened with SMBC_open_ctx(). The
567 * default is SMBC_SHAREMODE_DENY_NONE.
569 void
570 smbc_setOptionOpenShareMode(SMBCCTX *c, smbc_share_mode share_mode);
572 /** Retrieve a previously saved user data handle */
573 void *
574 smbc_getOptionUserData(SMBCCTX *c);
576 /** Save a user data handle */
577 void
578 smbc_setOptionUserData(SMBCCTX *c, void *user_data);
580 /** Get the encoded value for encryption level. */
581 smbc_smb_encrypt_level
582 smbc_getOptionSmbEncryptionLevel(SMBCCTX *c);
584 /** Set the encoded value for encryption level. */
585 void
586 smbc_setOptionSmbEncryptionLevel(SMBCCTX *c, smbc_smb_encrypt_level level);
589 * Get whether to treat file names as case-sensitive if we can't determine
590 * when connecting to the remote share whether the file system is case
591 * sensitive. This defaults to FALSE since it's most likely that if we can't
592 * retrieve the file system attributes, it's a very old file system that does
593 * not support case sensitivity.
595 smbc_bool
596 smbc_getOptionCaseSensitive(SMBCCTX *c);
599 * Set whether to treat file names as case-sensitive if we can't determine
600 * when connecting to the remote share whether the file system is case
601 * sensitive. This defaults to FALSE since it's most likely that if we can't
602 * retrieve the file system attributes, it's a very old file system that does
603 * not support case sensitivity.
605 void
606 smbc_setOptionCaseSensitive(SMBCCTX *c, smbc_bool b);
610 * Get from how many local master browsers should the list of workgroups be
611 * retrieved. It can take up to 12 minutes or longer after a server becomes a
612 * local master browser, for it to have the entire browse list (the list of
613 * workgroups/domains) from an entire network. Since a client never knows
614 * which local master browser will be found first, the one which is found
615 * first and used to retrieve a browse list may have an incomplete or empty
616 * browse list. By requesting the browse list from multiple local master
617 * browsers, a more complete list can be generated. For small networks (few
618 * workgroups), it is recommended that this value be set to 0, causing the
619 * browse lists from all found local master browsers to be retrieved and
620 * merged. For networks with many workgroups, a suitable value for this
621 * variable is probably somewhere around 3. (Default: 3).
624 smbc_getOptionBrowseMaxLmbCount(SMBCCTX *c);
627 * Set from how many local master browsers should the list of workgroups be
628 * retrieved. It can take up to 12 minutes or longer after a server becomes a
629 * local master browser, for it to have the entire browse list (the list of
630 * workgroups/domains) from an entire network. Since a client never knows
631 * which local master browser will be found first, the one which is found
632 * first and used to retrieve a browse list may have an incomplete or empty
633 * browse list. By requesting the browse list from multiple local master
634 * browsers, a more complete list can be generated. For small networks (few
635 * workgroups), it is recommended that this value be set to 0, causing the
636 * browse lists from all found local master browsers to be retrieved and
637 * merged. For networks with many workgroups, a suitable value for this
638 * variable is probably somewhere around 3. (Default: 3).
640 void
641 smbc_setOptionBrowseMaxLmbCount(SMBCCTX *c, int count);
644 * Get whether to url-encode readdir entries.
646 * There is a difference in the desired return strings from
647 * smbc_readdir() depending upon whether the filenames are to
648 * be displayed to the user, or whether they are to be
649 * appended to the path name passed to smbc_opendir() to call
650 * a further smbc_ function (e.g. open the file with
651 * smbc_open()). In the former case, the filename should be
652 * in "human readable" form. In the latter case, the smbc_
653 * functions expect a URL which must be url-encoded. Those
654 * functions decode the URL. If, for example, smbc_readdir()
655 * returned a file name of "abc%20def.txt", passing a path
656 * with this file name attached to smbc_open() would cause
657 * smbc_open to attempt to open the file "abc def.txt" since
658 * the %20 is decoded into a space.
660 * Set this option to True if the names returned by
661 * smbc_readdir() should be url-encoded such that they can be
662 * passed back to another smbc_ call. Set it to False if the
663 * names returned by smbc_readdir() are to be presented to the
664 * user.
666 * For backwards compatibility, this option defaults to False.
668 smbc_bool
669 smbc_getOptionUrlEncodeReaddirEntries(SMBCCTX *c);
672 * Set whether to url-encode readdir entries.
674 * There is a difference in the desired return strings from
675 * smbc_readdir() depending upon whether the filenames are to
676 * be displayed to the user, or whether they are to be
677 * appended to the path name passed to smbc_opendir() to call
678 * a further smbc_ function (e.g. open the file with
679 * smbc_open()). In the former case, the filename should be
680 * in "human readable" form. In the latter case, the smbc_
681 * functions expect a URL which must be url-encoded. Those
682 * functions decode the URL. If, for example, smbc_readdir()
683 * returned a file name of "abc%20def.txt", passing a path
684 * with this file name attached to smbc_open() would cause
685 * smbc_open to attempt to open the file "abc def.txt" since
686 * the %20 is decoded into a space.
688 * Set this option to True if the names returned by
689 * smbc_readdir() should be url-encoded such that they can be
690 * passed back to another smbc_ call. Set it to False if the
691 * names returned by smbc_readdir() are to be presented to the
692 * user.
694 * For backwards compatibility, this option defaults to False.
696 void
697 smbc_setOptionUrlEncodeReaddirEntries(SMBCCTX *c, smbc_bool b);
700 * Get whether to use the same connection for all shares on a server.
702 * Some Windows versions appear to have a limit to the number
703 * of concurrent SESSIONs and/or TREE CONNECTions. In
704 * one-shot programs (i.e. the program runs and then quickly
705 * ends, thereby shutting down all connections), it is
706 * probably reasonable to establish a new connection for each
707 * share. In long-running applications, the limitation can be
708 * avoided by using only a single connection to each server,
709 * and issuing a new TREE CONNECT when the share is accessed.
711 smbc_bool
712 smbc_getOptionOneSharePerServer(SMBCCTX *c);
715 * Set whether to use the same connection for all shares on a server.
717 * Some Windows versions appear to have a limit to the number
718 * of concurrent SESSIONs and/or TREE CONNECTions. In
719 * one-shot programs (i.e. the program runs and then quickly
720 * ends, thereby shutting down all connections), it is
721 * probably reasonable to establish a new connection for each
722 * share. In long-running applications, the limitation can be
723 * avoided by using only a single connection to each server,
724 * and issuing a new TREE CONNECT when the share is accessed.
726 void
727 smbc_setOptionOneSharePerServer(SMBCCTX *c, smbc_bool b);
729 /** Get whether to enable use of kerberos */
730 smbc_bool
731 smbc_getOptionUseKerberos(SMBCCTX *c);
733 /** Set whether to enable use of kerberos */
734 void
735 smbc_setOptionUseKerberos(SMBCCTX *c, smbc_bool b);
737 /** Get whether to fallback after kerberos */
738 smbc_bool
739 smbc_getOptionFallbackAfterKerberos(SMBCCTX *c);
741 /** Set whether to fallback after kerberos */
742 void
743 smbc_setOptionFallbackAfterKerberos(SMBCCTX *c, smbc_bool b);
745 /** Get whether to automatically select anonymous login */
746 smbc_bool
747 smbc_getOptionNoAutoAnonymousLogin(SMBCCTX *c);
749 /** Set whether to automatically select anonymous login */
750 void
751 smbc_setOptionNoAutoAnonymousLogin(SMBCCTX *c, smbc_bool b);
753 /** Get whether to enable use of the winbind ccache */
754 smbc_bool
755 smbc_getOptionUseCCache(SMBCCTX *c);
757 /** Set whether to enable use of the winbind ccache */
758 void
759 smbc_setOptionUseCCache(SMBCCTX *c, smbc_bool b);
763 /*************************************
764 * Getters and setters for FUNCTIONS *
765 *************************************/
767 /** Get the function for obtaining authentication data */
768 smbc_get_auth_data_fn smbc_getFunctionAuthData(SMBCCTX *c);
770 /** Set the function for obtaining authentication data */
771 void smbc_setFunctionAuthData(SMBCCTX *c, smbc_get_auth_data_fn fn);
773 /** Get the new-style authentication function which includes the context. */
774 smbc_get_auth_data_with_context_fn
775 smbc_getFunctionAuthDataWithContext(SMBCCTX *c);
777 /** Set the new-style authentication function which includes the context. */
778 void
779 smbc_setFunctionAuthDataWithContext(SMBCCTX *c,
780 smbc_get_auth_data_with_context_fn fn);
782 /** Get the function for checking if a server is still good */
783 smbc_check_server_fn smbc_getFunctionCheckServer(SMBCCTX *c);
785 /** Set the function for checking if a server is still good */
786 void smbc_setFunctionCheckServer(SMBCCTX *c, smbc_check_server_fn fn);
788 /** Get the function for removing a server if unused */
789 smbc_remove_unused_server_fn smbc_getFunctionRemoveUnusedServer(SMBCCTX *c);
791 /** Set the function for removing a server if unused */
792 void smbc_setFunctionRemoveUnusedServer(SMBCCTX *c,
793 smbc_remove_unused_server_fn fn);
795 /** Get the function for adding a cached server */
796 smbc_add_cached_srv_fn smbc_getFunctionAddCachedServer(SMBCCTX *c);
798 /** Set the function for adding a cached server */
799 void smbc_setFunctionAddCachedServer(SMBCCTX *c, smbc_add_cached_srv_fn fn);
801 /** Get the function for server cache lookup */
802 smbc_get_cached_srv_fn smbc_getFunctionGetCachedServer(SMBCCTX *c);
804 /** Set the function for server cache lookup */
805 void smbc_setFunctionGetCachedServer(SMBCCTX *c, smbc_get_cached_srv_fn fn);
807 /** Get the function for server cache removal */
808 smbc_remove_cached_srv_fn smbc_getFunctionRemoveCachedServer(SMBCCTX *c);
810 /** Set the function for server cache removal */
811 void smbc_setFunctionRemoveCachedServer(SMBCCTX *c,
812 smbc_remove_cached_srv_fn fn);
815 * Get the function for server cache purging. This function tries to
816 * remove all cached servers (e.g. on disconnect)
818 smbc_purge_cached_fn smbc_getFunctionPurgeCachedServers(SMBCCTX *c);
821 * Set the function for server cache purging. This function tries to
822 * remove all cached servers (e.g. on disconnect)
824 void smbc_setFunctionPurgeCachedServers(SMBCCTX *c,
825 smbc_purge_cached_fn fn);
827 /** Get the function to store private data of the server cache */
828 struct smbc_server_cache * smbc_getServerCacheData(SMBCCTX *c);
830 /** Set the function to store private data of the server cache */
831 void smbc_setServerCacheData(SMBCCTX *c, struct smbc_server_cache * cache);
835 /*****************************************************************
836 * Callable functions for files. *
837 * Each callable has a function signature typedef, a declaration *
838 * for the getter, and a declaration for the setter. *
839 *****************************************************************/
841 typedef SMBCFILE * (*smbc_open_fn)(SMBCCTX *c,
842 const char *fname,
843 int flags,
844 mode_t mode);
845 smbc_open_fn smbc_getFunctionOpen(SMBCCTX *c);
846 void smbc_setFunctionOpen(SMBCCTX *c, smbc_open_fn fn);
848 typedef SMBCFILE * (*smbc_creat_fn)(SMBCCTX *c,
849 const char *path,
850 mode_t mode);
851 smbc_creat_fn smbc_getFunctionCreat(SMBCCTX *c);
852 void smbc_setFunctionCreat(SMBCCTX *c, smbc_creat_fn);
854 typedef ssize_t (*smbc_read_fn)(SMBCCTX *c,
855 SMBCFILE *file,
856 void *buf,
857 size_t count);
858 smbc_read_fn smbc_getFunctionRead(SMBCCTX *c);
859 void smbc_setFunctionRead(SMBCCTX *c, smbc_read_fn fn);
861 typedef ssize_t (*smbc_write_fn)(SMBCCTX *c,
862 SMBCFILE *file,
863 const void *buf,
864 size_t count);
865 smbc_write_fn smbc_getFunctionWrite(SMBCCTX *c);
866 void smbc_setFunctionWrite(SMBCCTX *c, smbc_write_fn fn);
868 typedef int (*smbc_unlink_fn)(SMBCCTX *c,
869 const char *fname);
870 smbc_unlink_fn smbc_getFunctionUnlink(SMBCCTX *c);
871 void smbc_setFunctionUnlink(SMBCCTX *c, smbc_unlink_fn fn);
873 typedef int (*smbc_rename_fn)(SMBCCTX *ocontext,
874 const char *oname,
875 SMBCCTX *ncontext,
876 const char *nname);
877 smbc_rename_fn smbc_getFunctionRename(SMBCCTX *c);
878 void smbc_setFunctionRename(SMBCCTX *c, smbc_rename_fn fn);
880 typedef off_t (*smbc_lseek_fn)(SMBCCTX *c,
881 SMBCFILE * file,
882 off_t offset,
883 int whence);
884 smbc_lseek_fn smbc_getFunctionLseek(SMBCCTX *c);
885 void smbc_setFunctionLseek(SMBCCTX *c, smbc_lseek_fn fn);
887 typedef int (*smbc_stat_fn)(SMBCCTX *c,
888 const char *fname,
889 struct stat *st);
890 smbc_stat_fn smbc_getFunctionStat(SMBCCTX *c);
891 void smbc_setFunctionStat(SMBCCTX *c, smbc_stat_fn fn);
893 typedef int (*smbc_fstat_fn)(SMBCCTX *c,
894 SMBCFILE *file,
895 struct stat *st);
896 smbc_fstat_fn smbc_getFunctionFstat(SMBCCTX *c);
897 void smbc_setFunctionFstat(SMBCCTX *c, smbc_fstat_fn fn);
899 typedef int (*smbc_statvfs_fn)(SMBCCTX *c,
900 char *path,
901 struct statvfs *st);
902 smbc_statvfs_fn smbc_getFunctionStatVFS(SMBCCTX *c);
903 void smbc_setFunctionStatVFS(SMBCCTX *c, smbc_statvfs_fn fn);
905 typedef int (*smbc_fstatvfs_fn)(SMBCCTX *c,
906 SMBCFILE *file,
907 struct statvfs *st);
908 smbc_fstatvfs_fn smbc_getFunctionFstatVFS(SMBCCTX *c);
909 void smbc_setFunctionFstatVFS(SMBCCTX *c, smbc_fstatvfs_fn fn);
911 typedef int (*smbc_ftruncate_fn)(SMBCCTX *c,
912 SMBCFILE *f,
913 off_t size);
914 smbc_ftruncate_fn smbc_getFunctionFtruncate(SMBCCTX *c);
915 void smbc_setFunctionFtruncate(SMBCCTX *c, smbc_ftruncate_fn fn);
917 typedef int (*smbc_close_fn)(SMBCCTX *c,
918 SMBCFILE *file);
919 smbc_close_fn smbc_getFunctionClose(SMBCCTX *c);
920 void smbc_setFunctionClose(SMBCCTX *c, smbc_close_fn fn);
924 /*****************************************************************
925 * Callable functions for directories. *
926 * Each callable has a function signature typedef, a declaration *
927 * for the getter, and a declaration for the setter. *
928 *****************************************************************/
930 typedef SMBCFILE * (*smbc_opendir_fn)(SMBCCTX *c,
931 const char *fname);
932 smbc_opendir_fn smbc_getFunctionOpendir(SMBCCTX *c);
933 void smbc_setFunctionOpendir(SMBCCTX *c, smbc_opendir_fn fn);
935 typedef int (*smbc_closedir_fn)(SMBCCTX *c,
936 SMBCFILE *dir);
937 smbc_closedir_fn smbc_getFunctionClosedir(SMBCCTX *c);
938 void smbc_setFunctionClosedir(SMBCCTX *c, smbc_closedir_fn fn);
940 typedef struct smbc_dirent * (*smbc_readdir_fn)(SMBCCTX *c,
941 SMBCFILE *dir);
942 smbc_readdir_fn smbc_getFunctionReaddir(SMBCCTX *c);
943 void smbc_setFunctionReaddir(SMBCCTX *c, smbc_readdir_fn fn);
945 typedef int (*smbc_getdents_fn)(SMBCCTX *c,
946 SMBCFILE *dir,
947 struct smbc_dirent *dirp,
948 int count);
949 smbc_getdents_fn smbc_getFunctionGetdents(SMBCCTX *c);
950 void smbc_setFunctionGetdents(SMBCCTX *c, smbc_getdents_fn fn);
952 typedef int (*smbc_mkdir_fn)(SMBCCTX *c,
953 const char *fname,
954 mode_t mode);
955 smbc_mkdir_fn smbc_getFunctionMkdir(SMBCCTX *c);
956 void smbc_setFunctionMkdir(SMBCCTX *c, smbc_mkdir_fn fn);
958 typedef int (*smbc_rmdir_fn)(SMBCCTX *c,
959 const char *fname);
960 smbc_rmdir_fn smbc_getFunctionRmdir(SMBCCTX *c);
961 void smbc_setFunctionRmdir(SMBCCTX *c, smbc_rmdir_fn fn);
963 typedef off_t (*smbc_telldir_fn)(SMBCCTX *c,
964 SMBCFILE *dir);
965 smbc_telldir_fn smbc_getFunctionTelldir(SMBCCTX *c);
966 void smbc_setFunctionTelldir(SMBCCTX *c, smbc_telldir_fn fn);
968 typedef int (*smbc_lseekdir_fn)(SMBCCTX *c,
969 SMBCFILE *dir,
970 off_t offset);
971 smbc_lseekdir_fn smbc_getFunctionLseekdir(SMBCCTX *c);
972 void smbc_setFunctionLseekdir(SMBCCTX *c, smbc_lseekdir_fn fn);
974 typedef int (*smbc_fstatdir_fn)(SMBCCTX *c,
975 SMBCFILE *dir,
976 struct stat *st);
977 smbc_fstatdir_fn smbc_getFunctionFstatdir(SMBCCTX *c);
978 void smbc_setFunctionFstatdir(SMBCCTX *c, smbc_fstatdir_fn fn);
982 /*****************************************************************
983 * Callable functions applicable to both files and directories. *
984 * Each callable has a function signature typedef, a declaration *
985 * for the getter, and a declaration for the setter. *
986 *****************************************************************/
988 typedef int (*smbc_chmod_fn)(SMBCCTX *c,
989 const char *fname,
990 mode_t mode);
991 smbc_chmod_fn smbc_getFunctionChmod(SMBCCTX *c);
992 void smbc_setFunctionChmod(SMBCCTX *c, smbc_chmod_fn fn);
994 typedef int (*smbc_utimes_fn)(SMBCCTX *c,
995 const char *fname,
996 struct timeval *tbuf);
997 smbc_utimes_fn smbc_getFunctionUtimes(SMBCCTX *c);
998 void smbc_setFunctionUtimes(SMBCCTX *c, smbc_utimes_fn fn);
1000 typedef int (*smbc_setxattr_fn)(SMBCCTX *context,
1001 const char *fname,
1002 const char *name,
1003 const void *value,
1004 size_t size,
1005 int flags);
1006 smbc_setxattr_fn smbc_getFunctionSetxattr(SMBCCTX *c);
1007 void smbc_setFunctionSetxattr(SMBCCTX *c, smbc_setxattr_fn fn);
1009 typedef int (*smbc_getxattr_fn)(SMBCCTX *context,
1010 const char *fname,
1011 const char *name,
1012 const void *value,
1013 size_t size);
1014 smbc_getxattr_fn smbc_getFunctionGetxattr(SMBCCTX *c);
1015 void smbc_setFunctionGetxattr(SMBCCTX *c, smbc_getxattr_fn fn);
1017 typedef int (*smbc_removexattr_fn)(SMBCCTX *context,
1018 const char *fname,
1019 const char *name);
1020 smbc_removexattr_fn smbc_getFunctionRemovexattr(SMBCCTX *c);
1021 void smbc_setFunctionRemovexattr(SMBCCTX *c, smbc_removexattr_fn fn);
1023 typedef int (*smbc_listxattr_fn)(SMBCCTX *context,
1024 const char *fname,
1025 char *list,
1026 size_t size);
1027 smbc_listxattr_fn smbc_getFunctionListxattr(SMBCCTX *c);
1028 void smbc_setFunctionListxattr(SMBCCTX *c, smbc_listxattr_fn fn);
1032 /*****************************************************************
1033 * Callable functions for printing. *
1034 * Each callable has a function signature typedef, a declaration *
1035 * for the getter, and a declaration for the setter. *
1036 *****************************************************************/
1038 typedef int (*smbc_print_file_fn)(SMBCCTX *c_file,
1039 const char *fname,
1040 SMBCCTX *c_print,
1041 const char *printq);
1042 smbc_print_file_fn smbc_getFunctionPrintFile(SMBCCTX *c);
1043 void smbc_setFunctionPrintFile(SMBCCTX *c, smbc_print_file_fn fn);
1045 typedef SMBCFILE * (*smbc_open_print_job_fn)(SMBCCTX *c,
1046 const char *fname);
1047 smbc_open_print_job_fn smbc_getFunctionOpenPrintJob(SMBCCTX *c);
1048 void smbc_setFunctionOpenPrintJob(SMBCCTX *c,
1049 smbc_open_print_job_fn fn);
1051 typedef int (*smbc_list_print_jobs_fn)(SMBCCTX *c,
1052 const char *fname,
1053 smbc_list_print_job_fn fn);
1054 smbc_list_print_jobs_fn smbc_getFunctionListPrintJobs(SMBCCTX *c);
1055 void smbc_setFunctionListPrintJobs(SMBCCTX *c,
1056 smbc_list_print_jobs_fn fn);
1058 typedef int (*smbc_unlink_print_job_fn)(SMBCCTX *c,
1059 const char *fname,
1060 int id);
1061 smbc_unlink_print_job_fn smbc_getFunctionUnlinkPrintJob(SMBCCTX *c);
1062 void smbc_setFunctionUnlinkPrintJob(SMBCCTX *c,
1063 smbc_unlink_print_job_fn fn);
1066 /**@ingroup misc
1067 * Create a new SBMCCTX (a context).
1069 * Must be called before the context is passed to smbc_context_init()
1071 * @return The given SMBCCTX pointer on success, NULL on error with errno set:
1072 * - ENOMEM Out of memory
1074 * @see smbc_free_context(), smbc_init_context()
1076 * @note Do not forget to smbc_init_context() the returned SMBCCTX pointer !
1078 SMBCCTX * smbc_new_context(void);
1080 /**@ingroup misc
1081 * Delete a SBMCCTX (a context) acquired from smbc_new_context().
1083 * The context will be deleted if possible.
1085 * @param context A pointer to a SMBCCTX obtained from smbc_new_context()
1087 * @param shutdown_ctx If 1, all connections and files will be closed even if they are busy.
1090 * @return Returns 0 on succes. Returns 1 on failure with errno set:
1091 * - EBUSY Server connections are still used, Files are open or cache
1092 * could not be purged
1093 * - EBADF context == NULL
1095 * @see smbc_new_context()
1097 * @note It is advised to clean up all the contexts with shutdown_ctx set to 1
1098 * just before exit()'ing. When shutdown_ctx is 0, this function can be
1099 * use in periodical cleanup functions for example.
1101 int smbc_free_context(SMBCCTX * context, int shutdown_ctx);
1104 /**@ingroup misc
1106 * @deprecated. Use smbc_setOption*() functions instead.
1108 void
1109 smbc_option_set(SMBCCTX *context,
1110 char *option_name,
1111 ... /* option_value */);
1114 * @deprecated. Use smbc_getOption*() functions instead.
1116 void *
1117 smbc_option_get(SMBCCTX *context,
1118 char *option_name);
1120 /**@ingroup misc
1121 * Initialize a SBMCCTX (a context).
1123 * Must be called before using any SMBCCTX API function
1125 * @param context A pointer to a SMBCCTX obtained from smbc_new_context()
1127 * @return A pointer to the given SMBCCTX on success,
1128 * NULL on error with errno set:
1129 * - EBADF NULL context given
1130 * - ENOMEM Out of memory
1131 * - ENOENT The smb.conf file would not load
1133 * @see smbc_new_context()
1135 * @note my_context = smbc_init_context(smbc_new_context())
1136 * is perfectly safe, but it might leak memory on
1137 * smbc_context_init() failure. Avoid this.
1138 * You'll have to call smbc_free_context() yourself
1139 * on failure.
1142 SMBCCTX * smbc_init_context(SMBCCTX * context);
1144 /**@ingroup misc
1145 * Initialize the samba client library.
1147 * Must be called before using any of the smbclient API function
1149 * @param fn The function that will be called to obtaion
1150 * authentication credentials.
1152 * @param debug Allows caller to set the debug level. Can be
1153 * changed in smb.conf file. Allows caller to set
1154 * debugging if no smb.conf.
1156 * @return 0 on success, < 0 on error with errno set:
1157 * - ENOMEM Out of memory
1158 * - ENOENT The smb.conf file would not load
1162 int smbc_init(smbc_get_auth_data_fn fn, int debug);
1164 /**@ingroup misc
1165 * Set or retrieve the compatibility library's context pointer
1167 * @param context New context to use, or NULL. If a new context is provided,
1168 * it must have allocated with smbc_new_context() and
1169 * initialized with smbc_init_context(), followed, optionally,
1170 * by some manual changes to some of the non-internal fields.
1172 * @return The old context.
1174 * @see smbc_new_context(), smbc_init_context(), smbc_init()
1176 * @note This function may be called prior to smbc_init() to force
1177 * use of the next context without any internal calls to
1178 * smbc_new_context() or smbc_init_context(). It may also
1179 * be called after smbc_init() has already called those two
1180 * functions, to replace the existing context with a new one.
1181 * Care should be taken, in this latter case, to ensure that
1182 * the server cache and any data allocated by the
1183 * authentication functions have been freed, if necessary.
1186 SMBCCTX * smbc_set_context(SMBCCTX * new_context);
1188 /**@ingroup file
1189 * Open a file on an SMB server.
1191 * @param furl The smb url of the file to be opened.
1193 * @param flags Is one of O_RDONLY, O_WRONLY or O_RDWR which
1194 * request opening the file read-only,write-only
1195 * or read/write. flags may also be bitwise-or'd with
1196 * one or more of the following:
1197 * O_CREAT - If the file does not exist it will be
1198 * created.
1199 * O_EXCL - When used with O_CREAT, if the file
1200 * already exists it is an error and the open will
1201 * fail.
1202 * O_TRUNC - If the file already exists it will be
1203 * truncated.
1204 * O_APPEND The file is opened in append mode
1206 * @param mode mode specifies the permissions to use if a new
1207 * file is created. It is modified by the
1208 * process's umask in the usual way: the permissions
1209 * of the created file are (mode & ~umask)
1211 * Not currently use, but there for future use.
1212 * We will map this to SYSTEM, HIDDEN, etc bits
1213 * that reverses the mapping that smbc_fstat does.
1215 * @return Valid file handle, < 0 on error with errno set:
1216 * - ENOMEM Out of memory
1217 * - EINVAL if an invalid parameter passed, like no
1218 * file, or smbc_init not called.
1219 * - EEXIST pathname already exists and O_CREAT and
1220 * O_EXCL were used.
1221 * - EISDIR pathname refers to a directory and
1222 * the access requested involved writing.
1223 * - EACCES The requested access to the file is not
1224 * allowed
1225 * - ENODEV The requested share does not exist
1226 * - ENOTDIR A file on the path is not a directory
1227 * - ENOENT A directory component in pathname does
1228 * not exist.
1230 * @see smbc_creat()
1232 * @note This call uses an underlying routine that may create
1233 * a new connection to the server specified in the URL.
1234 * If the credentials supplied in the URL, or via the
1235 * auth_fn in the smbc_init call, fail, this call will
1236 * try again with an empty username and password. This
1237 * often gets mapped to the guest account on some machines.
1240 int smbc_open(const char *furl, int flags, mode_t mode);
1242 /**@ingroup file
1243 * Create a file on an SMB server.
1245 * Same as calling smbc_open() with flags = O_CREAT|O_WRONLY|O_TRUNC
1247 * @param furl The smb url of the file to be created
1249 * @param mode mode specifies the permissions to use if a new
1250 * file is created. It is modified by the
1251 * process's umask in the usual way: the permissions
1252 * of the created file are (mode & ~umask)
1254 * NOTE, the above is not true. We are dealing with
1255 * an SMB server, which has no concept of a umask!
1257 * @return Valid file handle, < 0 on error with errno set:
1258 * - ENOMEM Out of memory
1259 * - EINVAL if an invalid parameter passed, like no
1260 * file, or smbc_init not called.
1261 * - EEXIST pathname already exists and O_CREAT and
1262 * O_EXCL were used.
1263 * - EISDIR pathname refers to a directory and
1264 * the access requested involved writing.
1265 * - EACCES The requested access to the file is not
1266 * allowed
1267 * - ENOENT A directory component in pathname does
1268 * not exist.
1269 * - ENODEV The requested share does not exist.
1270 * @see smbc_open()
1274 int smbc_creat(const char *furl, mode_t mode);
1276 /**@ingroup file
1277 * Read from a file using an opened file handle.
1279 * @param fd Open file handle from smbc_open() or smbc_creat()
1281 * @param buf Pointer to buffer to recieve read data
1283 * @param bufsize Size of buf in bytes
1285 * @return Number of bytes read;
1286 * 0 upon EOF;
1287 * < 0 on error, with errno set:
1288 * - EISDIR fd refers to a directory
1289 * - EBADF fd is not a valid file descriptor or
1290 * is not open for reading.
1291 * - EINVAL fd is attached to an object which is
1292 * unsuitable for reading, or no buffer passed or
1293 * smbc_init not called.
1295 * @see smbc_open(), smbc_write()
1298 ssize_t smbc_read(int fd, void *buf, size_t bufsize);
1301 /**@ingroup file
1302 * Write to a file using an opened file handle.
1304 * @param fd Open file handle from smbc_open() or smbc_creat()
1306 * @param buf Pointer to buffer to recieve read data
1308 * @param bufsize Size of buf in bytes
1310 * @return Number of bytes written, < 0 on error with errno set:
1311 * - EISDIR fd refers to a directory.
1312 * - EBADF fd is not a valid file descriptor or
1313 * is not open for reading.
1314 * - EINVAL fd is attached to an object which is
1315 * unsuitable for reading, or no buffer passed or
1316 * smbc_init not called.
1318 * @see smbc_open(), smbc_read()
1321 ssize_t smbc_write(int fd, const void *buf, size_t bufsize);
1324 /**@ingroup file
1325 * Seek to a specific location in a file.
1327 * @param fd Open file handle from smbc_open() or smbc_creat()
1329 * @param offset Offset in bytes from whence
1331 * @param whence A location in the file:
1332 * - SEEK_SET The offset is set to offset bytes from
1333 * the beginning of the file
1334 * - SEEK_CUR The offset is set to current location
1335 * plus offset bytes.
1336 * - SEEK_END The offset is set to the size of the
1337 * file plus offset bytes.
1339 * @return Upon successful completion, lseek returns the
1340 * resulting offset location as measured in bytes
1341 * from the beginning of the file. Otherwise, a value
1342 * of (off_t)-1 is returned and errno is set to
1343 * indicate the error:
1344 * - EBADF Fildes is not an open file descriptor.
1345 * - EINVAL Whence is not a proper value or smbc_init
1346 * not called.
1348 * @todo Are all the whence values really supported?
1350 * @todo Are errno values complete and correct?
1352 off_t smbc_lseek(int fd, off_t offset, int whence);
1355 /**@ingroup file
1356 * Close an open file handle.
1358 * @param fd The file handle to close
1360 * @return 0 on success, < 0 on error with errno set:
1361 * - EBADF fd isn't a valid open file descriptor
1362 * - EINVAL smbc_init() failed or has not been called
1364 * @see smbc_open(), smbc_creat()
1366 int smbc_close(int fd);
1369 /**@ingroup directory
1370 * Unlink (delete) a file or directory.
1372 * @param furl The smb url of the file to delete
1374 * @return 0 on success, < 0 on error with errno set:
1375 * - EACCES or EPERM Write access to the directory
1376 * containing pathname is not allowed or one
1377 * of the directories in pathname did not allow
1378 * search (execute) permission
1379 * - ENOENT A directory component in pathname does
1380 * not exist
1381 * - EINVAL NULL was passed in the file param or
1382 * smbc_init not called.
1383 * - EACCES You do not have access to the file
1384 * - ENOMEM Insufficient kernel memory was available
1386 * @see smbc_rmdir()s
1388 * @todo Are errno values complete and correct?
1390 int smbc_unlink(const char *furl);
1393 /**@ingroup directory
1394 * Rename or move a file or directory.
1396 * @param ourl The original smb url (source url) of file or
1397 * directory to be moved
1399 * @param nurl The new smb url (destination url) of the file
1400 * or directory after the move. Currently nurl must
1401 * be on the same share as ourl.
1403 * @return 0 on success, < 0 on error with errno set:
1404 * - EISDIR nurl is an existing directory, but ourl is
1405 * not a directory.
1406 * - EEXIST nurl is a non-empty directory,
1407 * i.e., contains entries other than "." and ".."
1408 * - EINVAL The new url contained a path prefix
1409 * of the old, or, more generally, an attempt was
1410 * made to make a directory a subdirectory of itself
1411 * or smbc_init not called.
1412 * - ENOTDIR A component used as a directory in ourl
1413 * or nurl path is not, in fact, a directory. Or,
1414 * ourl is a directory, and newpath exists but is not
1415 * a directory.
1416 * - EACCES or EPERM Write access to the directory
1417 * containing ourl or nurl is not allowed for the
1418 * process's effective uid, or one of the
1419 * directories in ourl or nurl did not allow search
1420 * (execute) permission, or ourl was a directory
1421 * and did not allow write permission.
1422 * - ENOENT A directory component in ourl or nurl
1423 * does not exist.
1424 * - EXDEV Rename across shares not supported.
1425 * - ENOMEM Insufficient kernel memory was available.
1426 * - EEXIST The target file, nurl, already exists.
1429 * @todo Are we going to support copying when urls are not on the same
1430 * share? I say no... NOTE. I agree for the moment.
1433 int smbc_rename(const char *ourl, const char *nurl);
1436 /**@ingroup directory
1437 * Open a directory used to obtain directory entries.
1439 * @param durl The smb url of the directory to open
1441 * @return Valid directory handle. < 0 on error with errno set:
1442 * - EACCES Permission denied.
1443 * - EINVAL A NULL file/URL was passed, or the URL would
1444 * not parse, or was of incorrect form or smbc_init not
1445 * called.
1446 * - ENOENT durl does not exist, or name is an
1447 * - ENOMEM Insufficient memory to complete the
1448 * operation.
1449 * - ENOTDIR name is not a directory.
1450 * - EPERM the workgroup could not be found.
1451 * - ENODEV the workgroup or server could not be found.
1453 * @see smbc_getdents(), smbc_readdir(), smbc_closedir()
1456 int smbc_opendir(const char *durl);
1459 /**@ingroup directory
1460 * Close a directory handle opened by smbc_opendir().
1462 * @param dh Directory handle to close
1464 * @return 0 on success, < 0 on error with errno set:
1465 * - EBADF dh is an invalid directory handle
1467 * @see smbc_opendir()
1469 int smbc_closedir(int dh);
1472 /**@ingroup directory
1473 * Get multiple directory entries.
1475 * smbc_getdents() reads as many dirent structures from the an open
1476 * directory handle into a specified memory area as will fit.
1478 * @param dh Valid directory as returned by smbc_opendir()
1480 * @param dirp pointer to buffer that will receive the directory
1481 * entries.
1483 * @param count The size of the dirp buffer in bytes
1485 * @returns If any dirents returned, return will indicate the
1486 * total size. If there were no more dirents available,
1487 * 0 is returned. < 0 indicates an error.
1488 * - EBADF Invalid directory handle
1489 * - EINVAL Result buffer is too small or smbc_init
1490 * not called.
1491 * - ENOENT No such directory.
1492 * @see , smbc_dirent, smbc_readdir(), smbc_open()
1494 * @todo Are errno values complete and correct?
1496 * @todo Add example code so people know how to parse buffers.
1498 int smbc_getdents(unsigned int dh, struct smbc_dirent *dirp, int count);
1501 /**@ingroup directory
1502 * Get a single directory entry.
1504 * @param dh Valid directory as returned by smbc_opendir()
1506 * @return A pointer to a smbc_dirent structure, or NULL if an
1507 * error occurs or end-of-directory is reached:
1508 * - EBADF Invalid directory handle
1509 * - EINVAL smbc_init() failed or has not been called
1511 * @see smbc_dirent, smbc_getdents(), smbc_open()
1513 struct smbc_dirent* smbc_readdir(unsigned int dh);
1516 /**@ingroup directory
1517 * Get the current directory offset.
1519 * smbc_telldir() may be used in conjunction with smbc_readdir() and
1520 * smbc_lseekdir().
1522 * @param dh Valid directory as returned by smbc_opendir()
1524 * @return The current location in the directory stream or -1
1525 * if an error occur. The current location is not
1526 * an offset. Becuase of the implementation, it is a
1527 * handle that allows the library to find the entry
1528 * later.
1529 * - EBADF dh is not a valid directory handle
1530 * - EINVAL smbc_init() failed or has not been called
1531 * - ENOTDIR if dh is not a directory
1533 * @see smbc_readdir()
1536 off_t smbc_telldir(int dh);
1539 /**@ingroup directory
1540 * lseek on directories.
1542 * smbc_lseekdir() may be used in conjunction with smbc_readdir() and
1543 * smbc_telldir(). (rewind by smbc_lseekdir(fd, NULL))
1545 * @param fd Valid directory as returned by smbc_opendir()
1547 * @param offset The offset (as returned by smbc_telldir). Can be
1548 * NULL, in which case we will rewind
1550 * @return 0 on success, -1 on failure
1551 * - EBADF dh is not a valid directory handle
1552 * - ENOTDIR if dh is not a directory
1553 * - EINVAL offset did not refer to a valid dirent or
1554 * smbc_init not called.
1556 * @see smbc_telldir()
1559 * @todo In what does the reture and errno values mean?
1561 int smbc_lseekdir(int fd, off_t offset);
1563 /**@ingroup directory
1564 * Create a directory.
1566 * @param durl The url of the directory to create
1568 * @param mode Specifies the permissions to use. It is modified
1569 * by the process's umask in the usual way: the
1570 * permissions of the created file are (mode & ~umask).
1572 * @return 0 on success, < 0 on error with errno set:
1573 * - EEXIST directory url already exists
1574 * - EACCES The parent directory does not allow write
1575 * permission to the process, or one of the directories
1576 * - ENOENT A directory component in pathname does not
1577 * exist.
1578 * - EINVAL NULL durl passed or smbc_init not called.
1579 * - ENOMEM Insufficient memory was available.
1581 * @see smbc_rmdir()
1584 int smbc_mkdir(const char *durl, mode_t mode);
1587 /**@ingroup directory
1588 * Remove a directory.
1590 * @param durl The smb url of the directory to remove
1592 * @return 0 on success, < 0 on error with errno set:
1593 * - EACCES or EPERM Write access to the directory
1594 * containing pathname was not allowed.
1595 * - EINVAL durl is NULL or smbc_init not called.
1596 * - ENOENT A directory component in pathname does not
1597 * exist.
1598 * - ENOTEMPTY directory contains entries.
1599 * - ENOMEM Insufficient kernel memory was available.
1601 * @see smbc_mkdir(), smbc_unlink()
1603 * @todo Are errno values complete and correct?
1605 int smbc_rmdir(const char *durl);
1608 /**@ingroup attribute
1609 * Get information about a file or directory.
1611 * @param url The smb url to get information for
1613 * @param st pointer to a buffer that will be filled with
1614 * standard Unix struct stat information.
1616 * @return 0 on success, < 0 on error with errno set:
1617 * - ENOENT A component of the path file_name does not
1618 * exist.
1619 * - EINVAL a NULL url was passed or smbc_init not called.
1620 * - EACCES Permission denied.
1621 * - ENOMEM Out of memory
1622 * - ENOTDIR The target dir, url, is not a directory.
1624 * @see Unix stat()
1627 int smbc_stat(const char *url, struct stat *st);
1630 /**@ingroup attribute
1631 * Get file information via an file descriptor.
1633 * @param fd Open file handle from smbc_open() or smbc_creat()
1635 * @param st pointer to a buffer that will be filled with
1636 * standard Unix struct stat information.
1638 * @return 0 on success, < 0 on error with errno set:
1639 * - EBADF filedes is bad.
1640 * - EACCES Permission denied.
1641 * - EBADF fd is not a valid file descriptor
1642 * - EINVAL Problems occurred in the underlying routines
1643 * or smbc_init not called.
1644 * - ENOMEM Out of memory
1646 * @see smbc_stat(), Unix stat()
1649 int smbc_fstat(int fd, struct stat *st);
1652 /**@ingroup attribute
1653 * Get file system information for a specified path.
1655 * @param url The smb url to get information for
1657 * @param st pointer to a buffer that will be filled with
1658 * standard Unix struct statvfs information.
1660 * @return 0 on success, < 0 on error with errno set:
1661 * - EBADF filedes is bad.
1662 * - EACCES Permission denied.
1663 * - EBADF fd is not a valid file descriptor
1664 * - EINVAL Problems occurred in the underlying routines
1665 * or smbc_init not called.
1666 * - ENOMEM Out of memory
1668 * @see Unix fstatvfs()
1672 smbc_statvfs(char *url,
1673 struct statvfs *st);
1675 /**@ingroup attribute
1676 * Get file system information via an file descriptor.
1678 * @param fd Open file handle from smbc_open(), smbc_creat(),
1679 * or smbc_opendir()
1681 * @param st pointer to a buffer that will be filled with
1682 * standard Unix struct statvfs information.
1684 * @return 0 on success, < 0 on error with errno set:
1685 * - EBADF filedes is bad.
1686 * - EACCES Permission denied.
1687 * - EBADF fd is not a valid file descriptor
1688 * - EINVAL Problems occurred in the underlying routines
1689 * or smbc_init not called.
1690 * - ENOMEM Out of memory
1692 * @see Unix fstatvfs()
1696 smbc_fstatvfs(int fd,
1697 struct statvfs *st);
1700 /**@ingroup attribute
1701 * Truncate a file given a file descriptor
1703 * @param fd Open file handle from smbc_open() or smbc_creat()
1705 * @param size size to truncate the file to
1707 * @return 0 on success, < 0 on error with errno set:
1708 * - EBADF filedes is bad.
1709 * - EACCES Permission denied.
1710 * - EBADF fd is not a valid file descriptor
1711 * - EINVAL Problems occurred in the underlying routines
1712 * or smbc_init not called.
1713 * - ENOMEM Out of memory
1715 * @see , Unix ftruncate()
1718 int smbc_ftruncate(int fd, off_t size);
1721 /**@ingroup attribute
1722 * Change the permissions of a file.
1724 * @param url The smb url of the file or directory to change
1725 * permissions of
1727 * @param mode The permissions to set:
1728 * - Put good explaination of permissions here!
1730 * @return 0 on success, < 0 on error with errno set:
1731 * - EPERM The effective UID does not match the owner
1732 * of the file, and is not zero
1733 * - ENOENT The file does not exist.
1734 * - ENOMEM Insufficient was available.
1735 * - ENOENT file or directory does not exist
1737 * @todo Actually implement this fuction?
1739 * @todo Are errno values complete and correct?
1741 int smbc_chmod(const char *url, mode_t mode);
1744 * @ingroup attribute
1745 * Change the last modification time on a file
1747 * @param url The smb url of the file or directory to change
1748 * the modification time of
1750 * @param tbuf An array of two timeval structures which contains,
1751 * respectively, the desired access and modification times.
1752 * NOTE: Only the tv_sec field off each timeval structure is
1753 * used. The tv_usec (microseconds) portion is ignored.
1755 * @return 0 on success, < 0 on error with errno set:
1756 * - EINVAL The client library is not properly initialized
1757 * - EPERM Permission was denied.
1760 int smbc_utimes(const char *url, struct timeval *tbuf);
1762 #ifdef HAVE_UTIME_H
1764 * @ingroup attribute
1765 * Change the last modification time on a file
1767 * @param url The smb url of the file or directory to change
1768 * the modification time of
1770 * @param utbuf A pointer to a utimebuf structure which contains the
1771 * desired access and modification times.
1773 * @return 0 on success, < 0 on error with errno set:
1774 * - EINVAL The client library is not properly initialized
1775 * - ENOMEM No memory was available for internal needs
1776 * - EPERM Permission was denied.
1779 int smbc_utime(const char *fname, struct utimbuf *utbuf);
1780 #endif
1782 /**@ingroup attribute
1783 * Set extended attributes for a file. This is used for modifying a file's
1784 * security descriptor (i.e. owner, group, and access control list)
1786 * @param url The smb url of the file or directory to set extended
1787 * attributes for.
1789 * @param name The name of an attribute to be changed. Names are of
1790 * one of the following forms:
1792 * system.nt_sec_desc.<attribute name>
1793 * system.nt_sec_desc.*
1794 * system.nt_sec_desc.*+
1796 * where <attribute name> is one of:
1798 * revision
1799 * owner
1800 * owner+
1801 * group
1802 * group+
1803 * acl:<name or sid>
1804 * acl+:<name or sid>
1806 * In the forms "system.nt_sec_desc.*" and
1807 * "system.nt_sec_desc.*+", the asterisk and plus signs are
1808 * literal, i.e. the string is provided exactly as shown, and
1809 * the value parameter should contain a complete security
1810 * descriptor with name:value pairs separated by tabs,
1811 * commas, or newlines (not spaces!).
1813 * The plus sign ('+') indicates that SIDs should be mapped
1814 * to names. Without the plus sign, SIDs are not mapped;
1815 * rather they are simply converted to a string format.
1817 * @param value The value to be assigned to the specified attribute name.
1818 * This buffer should contain only the attribute value if the
1819 * name was of the "system.nt_sec_desc.<attribute_name>"
1820 * form. If the name was of the "system.nt_sec_desc.*" form
1821 * then a complete security descriptor, with name:value pairs
1822 * separated by tabs, commas, or newlines (not spaces!),
1823 * should be provided in this value buffer. A complete
1824 * security descriptor will contain one or more entries
1825 * selected from the following:
1827 * REVISION:<revision number>
1828 * OWNER:<sid or name>
1829 * GROUP:<sid or name>
1830 * ACL:<sid or name>:<type>/<flags>/<mask>
1832 * The revision of the ACL specifies the internal Windows NT
1833 * ACL revision for the security descriptor. If not specified
1834 * it defaults to 1. Using values other than 1 may cause
1835 * strange behaviour.
1837 * The owner and group specify the owner and group sids for
1838 * the object. If the attribute name (either '*+' with a
1839 * complete security descriptor, or individual 'owner+' or
1840 * 'group+' attribute names) ended with a plus sign, the
1841 * specified name is resolved to a SID value, using the
1842 * server on which the file or directory resides. Otherwise,
1843 * the value should be provided in SID-printable format as
1844 * S-1-x-y-z, and is used directly. The <sid or name>
1845 * associated with the ACL: attribute should be provided
1846 * similarly.
1848 * @param size The number of the bytes of data in the value buffer
1850 * @param flags A bit-wise OR of zero or more of the following:
1851 * SMBC_XATTR_FLAG_CREATE -
1852 * fail if the named attribute already exists
1853 * SMBC_XATTR_FLAG_REPLACE -
1854 * fail if the attribute does not already exist
1856 * If neither flag is specified, the specified attributes
1857 * will be added or replace existing attributes of the same
1858 * name, as necessary.
1860 * @return 0 on success, < 0 on error with errno set:
1861 * - EINVAL The client library is not properly initialized
1862 * or one of the parameters is not of a correct
1863 * form
1864 * - ENOMEM No memory was available for internal needs
1865 * - EEXIST If the attribute already exists and the flag
1866 * SMBC_XATTR_FLAG_CREAT was specified
1867 * - ENOATTR If the attribute does not exist and the flag
1868 * SMBC_XATTR_FLAG_REPLACE was specified
1869 * - EPERM Permission was denied.
1870 * - ENOTSUP The referenced file system does not support
1871 * extended attributes
1873 * @note Attribute names are compared in a case-insensitive
1874 * fashion. All of the following are equivalent, although
1875 * the all-lower-case name is the preferred format:
1876 * system.nt_sec_desc.owner
1877 * SYSTEM.NT_SEC_DESC.OWNER
1878 * sYsTeM.nt_sEc_desc.owNER
1881 int smbc_setxattr(const char *url,
1882 const char *name,
1883 const void *value,
1884 size_t size,
1885 int flags);
1888 /**@ingroup attribute
1889 * Set extended attributes for a file. This is used for modifying a file's
1890 * security descriptor (i.e. owner, group, and access control list). The
1891 * POSIX function which this maps to would act on a symbolic link rather than
1892 * acting on what the symbolic link points to, but with no symbolic links in
1893 * SMB file systems, this function is functionally identical to
1894 * smbc_setxattr().
1896 * @param url The smb url of the file or directory to set extended
1897 * attributes for.
1899 * @param name The name of an attribute to be changed. Names are of
1900 * one of the following forms:
1902 * system.nt_sec_desc.<attribute name>
1903 * system.nt_sec_desc.*
1904 * system.nt_sec_desc.*+
1906 * where <attribute name> is one of:
1908 * revision
1909 * owner
1910 * owner+
1911 * group
1912 * group+
1913 * acl:<name or sid>
1914 * acl+:<name or sid>
1916 * In the forms "system.nt_sec_desc.*" and
1917 * "system.nt_sec_desc.*+", the asterisk and plus signs are
1918 * literal, i.e. the string is provided exactly as shown, and
1919 * the value parameter should contain a complete security
1920 * descriptor with name:value pairs separated by tabs,
1921 * commas, or newlines (not spaces!).
1923 * The plus sign ('+') indicates that SIDs should be mapped
1924 * to names. Without the plus sign, SIDs are not mapped;
1925 * rather they are simply converted to a string format.
1927 * @param value The value to be assigned to the specified attribute name.
1928 * This buffer should contain only the attribute value if the
1929 * name was of the "system.nt_sec_desc.<attribute_name>"
1930 * form. If the name was of the "system.nt_sec_desc.*" form
1931 * then a complete security descriptor, with name:value pairs
1932 * separated by tabs, commas, or newlines (not spaces!),
1933 * should be provided in this value buffer. A complete
1934 * security descriptor will contain one or more entries
1935 * selected from the following:
1937 * REVISION:<revision number>
1938 * OWNER:<sid or name>
1939 * GROUP:<sid or name>
1940 * ACL:<sid or name>:<type>/<flags>/<mask>
1942 * The revision of the ACL specifies the internal Windows NT
1943 * ACL revision for the security descriptor. If not specified
1944 * it defaults to 1. Using values other than 1 may cause
1945 * strange behaviour.
1947 * The owner and group specify the owner and group sids for
1948 * the object. If the attribute name (either '*+' with a
1949 * complete security descriptor, or individual 'owner+' or
1950 * 'group+' attribute names) ended with a plus sign, the
1951 * specified name is resolved to a SID value, using the
1952 * server on which the file or directory resides. Otherwise,
1953 * the value should be provided in SID-printable format as
1954 * S-1-x-y-z, and is used directly. The <sid or name>
1955 * associated with the ACL: attribute should be provided
1956 * similarly.
1958 * @param size The number of the bytes of data in the value buffer
1960 * @param flags A bit-wise OR of zero or more of the following:
1961 * SMBC_XATTR_FLAG_CREATE -
1962 * fail if the named attribute already exists
1963 * SMBC_XATTR_FLAG_REPLACE -
1964 * fail if the attribute does not already exist
1966 * If neither flag is specified, the specified attributes
1967 * will be added or replace existing attributes of the same
1968 * name, as necessary.
1970 * @return 0 on success, < 0 on error with errno set:
1971 * - EINVAL The client library is not properly initialized
1972 * or one of the parameters is not of a correct
1973 * form
1974 * - ENOMEM No memory was available for internal needs
1975 * - EEXIST If the attribute already exists and the flag
1976 * SMBC_XATTR_FLAG_CREAT was specified
1977 * - ENOATTR If the attribute does not exist and the flag
1978 * SMBC_XATTR_FLAG_REPLACE was specified
1979 * - EPERM Permission was denied.
1980 * - ENOTSUP The referenced file system does not support
1981 * extended attributes
1983 * @note Attribute names are compared in a case-insensitive
1984 * fashion. All of the following are equivalent, although
1985 * the all-lower-case name is the preferred format:
1986 * system.nt_sec_desc.owner
1987 * SYSTEM.NT_SEC_DESC.OWNER
1988 * sYsTeM.nt_sEc_desc.owNER
1991 int smbc_lsetxattr(const char *url,
1992 const char *name,
1993 const void *value,
1994 size_t size,
1995 int flags);
1998 /**@ingroup attribute
1999 * Set extended attributes for a file. This is used for modifying a file's
2000 * security descriptor (i.e. owner, group, and access control list)
2002 * @param fd A file descriptor associated with an open file (as
2003 * previously returned by smbc_open(), to get extended
2004 * attributes for.
2006 * @param name The name of an attribute to be changed. Names are of
2007 * one of the following forms:
2009 * system.nt_sec_desc.<attribute name>
2010 * system.nt_sec_desc.*
2011 * system.nt_sec_desc.*+
2013 * where <attribute name> is one of:
2015 * revision
2016 * owner
2017 * owner+
2018 * group
2019 * group+
2020 * acl:<name or sid>
2021 * acl+:<name or sid>
2023 * In the forms "system.nt_sec_desc.*" and
2024 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2025 * literal, i.e. the string is provided exactly as shown, and
2026 * the value parameter should contain a complete security
2027 * descriptor with name:value pairs separated by tabs,
2028 * commas, or newlines (not spaces!).
2030 * The plus sign ('+') indicates that SIDs should be mapped
2031 * to names. Without the plus sign, SIDs are not mapped;
2032 * rather they are simply converted to a string format.
2034 * @param value The value to be assigned to the specified attribute name.
2035 * This buffer should contain only the attribute value if the
2036 * name was of the "system.nt_sec_desc.<attribute_name>"
2037 * form. If the name was of the "system.nt_sec_desc.*" form
2038 * then a complete security descriptor, with name:value pairs
2039 * separated by tabs, commas, or newlines (not spaces!),
2040 * should be provided in this value buffer. A complete
2041 * security descriptor will contain one or more entries
2042 * selected from the following:
2044 * REVISION:<revision number>
2045 * OWNER:<sid or name>
2046 * GROUP:<sid or name>
2047 * ACL:<sid or name>:<type>/<flags>/<mask>
2049 * The revision of the ACL specifies the internal Windows NT
2050 * ACL revision for the security descriptor. If not specified
2051 * it defaults to 1. Using values other than 1 may cause
2052 * strange behaviour.
2054 * The owner and group specify the owner and group sids for
2055 * the object. If the attribute name (either '*+' with a
2056 * complete security descriptor, or individual 'owner+' or
2057 * 'group+' attribute names) ended with a plus sign, the
2058 * specified name is resolved to a SID value, using the
2059 * server on which the file or directory resides. Otherwise,
2060 * the value should be provided in SID-printable format as
2061 * S-1-x-y-z, and is used directly. The <sid or name>
2062 * associated with the ACL: attribute should be provided
2063 * similarly.
2065 * @param size The number of the bytes of data in the value buffer
2067 * @param flags A bit-wise OR of zero or more of the following:
2068 * SMBC_XATTR_FLAG_CREATE -
2069 * fail if the named attribute already exists
2070 * SMBC_XATTR_FLAG_REPLACE -
2071 * fail if the attribute does not already exist
2073 * If neither flag is specified, the specified attributes
2074 * will be added or replace existing attributes of the same
2075 * name, as necessary.
2077 * @return 0 on success, < 0 on error with errno set:
2078 * - EINVAL The client library is not properly initialized
2079 * or one of the parameters is not of a correct
2080 * form
2081 * - ENOMEM No memory was available for internal needs
2082 * - EEXIST If the attribute already exists and the flag
2083 * SMBC_XATTR_FLAG_CREAT was specified
2084 * - ENOATTR If the attribute does not exist and the flag
2085 * SMBC_XATTR_FLAG_REPLACE was specified
2086 * - EPERM Permission was denied.
2087 * - ENOTSUP The referenced file system does not support
2088 * extended attributes
2090 * @note Attribute names are compared in a case-insensitive
2091 * fashion. All of the following are equivalent, although
2092 * the all-lower-case name is the preferred format:
2093 * system.nt_sec_desc.owner
2094 * SYSTEM.NT_SEC_DESC.OWNER
2095 * sYsTeM.nt_sEc_desc.owNER
2098 int smbc_fsetxattr(int fd,
2099 const char *name,
2100 const void *value,
2101 size_t size,
2102 int flags);
2105 /**@ingroup attribute
2106 * Get extended attributes for a file.
2108 * @param url The smb url of the file or directory to get extended
2109 * attributes for.
2111 * @param name The name of an attribute to be retrieved. Names are of
2112 * one of the following forms:
2114 * system.nt_sec_desc.<attribute name>
2115 * system.nt_sec_desc.*
2116 * system.nt_sec_desc.*+
2118 * where <attribute name> is one of:
2120 * revision
2121 * owner
2122 * owner+
2123 * group
2124 * group+
2125 * acl:<name or sid>
2126 * acl+:<name or sid>
2128 * In the forms "system.nt_sec_desc.*" and
2129 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2130 * literal, i.e. the string is provided exactly as shown, and
2131 * the value parameter will return a complete security
2132 * descriptor with name:value pairs separated by tabs,
2133 * commas, or newlines (not spaces!).
2135 * The plus sign ('+') indicates that SIDs should be mapped
2136 * to names. Without the plus sign, SIDs are not mapped;
2137 * rather they are simply converted to a string format.
2139 * @param value A pointer to a buffer in which the value of the specified
2140 * attribute will be placed (unless size is zero).
2142 * @param size The size of the buffer pointed to by value. This parameter
2143 * may also be zero, in which case the size of the buffer
2144 * required to hold the attribute value will be returned,
2145 * but nothing will be placed into the value buffer.
2147 * @return 0 on success, < 0 on error with errno set:
2148 * - EINVAL The client library is not properly initialized
2149 * or one of the parameters is not of a correct
2150 * form
2151 * - ENOMEM No memory was available for internal needs
2152 * - EEXIST If the attribute already exists and the flag
2153 * SMBC_XATTR_FLAG_CREAT was specified
2154 * - ENOATTR If the attribute does not exist and the flag
2155 * SMBC_XATTR_FLAG_REPLACE was specified
2156 * - EPERM Permission was denied.
2157 * - ENOTSUP The referenced file system does not support
2158 * extended attributes
2161 int smbc_getxattr(const char *url,
2162 const char *name,
2163 const void *value,
2164 size_t size);
2167 /**@ingroup attribute
2168 * Get extended attributes for a file. The POSIX function which this maps to
2169 * would act on a symbolic link rather than acting on what the symbolic link
2170 * points to, but with no symbolic links in SMB file systems, this function
2171 * is functionally identical to smbc_getxattr().
2173 * @param url The smb url of the file or directory to get extended
2174 * attributes for.
2176 * @param name The name of an attribute to be retrieved. Names are of
2177 * one of the following forms:
2179 * system.nt_sec_desc.<attribute name>
2180 * system.nt_sec_desc.*
2181 * system.nt_sec_desc.*+
2183 * where <attribute name> is one of:
2185 * revision
2186 * owner
2187 * owner+
2188 * group
2189 * group+
2190 * acl:<name or sid>
2191 * acl+:<name or sid>
2193 * In the forms "system.nt_sec_desc.*" and
2194 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2195 * literal, i.e. the string is provided exactly as shown, and
2196 * the value parameter will return a complete security
2197 * descriptor with name:value pairs separated by tabs,
2198 * commas, or newlines (not spaces!).
2200 * The plus sign ('+') indicates that SIDs should be mapped
2201 * to names. Without the plus sign, SIDs are not mapped;
2202 * rather they are simply converted to a string format.
2204 * @param value A pointer to a buffer in which the value of the specified
2205 * attribute will be placed (unless size is zero).
2207 * @param size The size of the buffer pointed to by value. This parameter
2208 * may also be zero, in which case the size of the buffer
2209 * required to hold the attribute value will be returned,
2210 * but nothing will be placed into the value buffer.
2212 * @return 0 on success, < 0 on error with errno set:
2213 * - EINVAL The client library is not properly initialized
2214 * or one of the parameters is not of a correct
2215 * form
2216 * - ENOMEM No memory was available for internal needs
2217 * - EEXIST If the attribute already exists and the flag
2218 * SMBC_XATTR_FLAG_CREAT was specified
2219 * - ENOATTR If the attribute does not exist and the flag
2220 * SMBC_XATTR_FLAG_REPLACE was specified
2221 * - EPERM Permission was denied.
2222 * - ENOTSUP The referenced file system does not support
2223 * extended attributes
2226 int smbc_lgetxattr(const char *url,
2227 const char *name,
2228 const void *value,
2229 size_t size);
2232 /**@ingroup attribute
2233 * Get extended attributes for a file.
2235 * @param fd A file descriptor associated with an open file (as
2236 * previously returned by smbc_open(), to get extended
2237 * attributes for.
2239 * @param name The name of an attribute to be retrieved. Names are of
2240 * one of the following forms:
2242 * system.nt_sec_desc.<attribute name>
2243 * system.nt_sec_desc.*
2244 * system.nt_sec_desc.*+
2246 * where <attribute name> is one of:
2248 * revision
2249 * owner
2250 * owner+
2251 * group
2252 * group+
2253 * acl:<name or sid>
2254 * acl+:<name or sid>
2256 * In the forms "system.nt_sec_desc.*" and
2257 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2258 * literal, i.e. the string is provided exactly as shown, and
2259 * the value parameter will return a complete security
2260 * descriptor with name:value pairs separated by tabs,
2261 * commas, or newlines (not spaces!).
2263 * The plus sign ('+') indicates that SIDs should be mapped
2264 * to names. Without the plus sign, SIDs are not mapped;
2265 * rather they are simply converted to a string format.
2267 * @param value A pointer to a buffer in which the value of the specified
2268 * attribute will be placed (unless size is zero).
2270 * @param size The size of the buffer pointed to by value. This parameter
2271 * may also be zero, in which case the size of the buffer
2272 * required to hold the attribute value will be returned,
2273 * but nothing will be placed into the value buffer.
2275 * @return 0 on success, < 0 on error with errno set:
2276 * - EINVAL The client library is not properly initialized
2277 * or one of the parameters is not of a correct
2278 * form
2279 * - ENOMEM No memory was available for internal needs
2280 * - EEXIST If the attribute already exists and the flag
2281 * SMBC_XATTR_FLAG_CREAT was specified
2282 * - ENOATTR If the attribute does not exist and the flag
2283 * SMBC_XATTR_FLAG_REPLACE was specified
2284 * - EPERM Permission was denied.
2285 * - ENOTSUP The referenced file system does not support
2286 * extended attributes
2289 int smbc_fgetxattr(int fd,
2290 const char *name,
2291 const void *value,
2292 size_t size);
2295 /**@ingroup attribute
2296 * Remove extended attributes for a file. This is used for modifying a file's
2297 * security descriptor (i.e. owner, group, and access control list)
2299 * @param url The smb url of the file or directory to remove the extended
2300 * attributes for.
2302 * @param name The name of an attribute to be removed. Names are of
2303 * one of the following forms:
2305 * system.nt_sec_desc.<attribute name>
2306 * system.nt_sec_desc.*
2307 * system.nt_sec_desc.*+
2309 * where <attribute name> is one of:
2311 * revision
2312 * owner
2313 * owner+
2314 * group
2315 * group+
2316 * acl:<name or sid>
2317 * acl+:<name or sid>
2319 * In the forms "system.nt_sec_desc.*" and
2320 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2321 * literal, i.e. the string is provided exactly as shown, and
2322 * the value parameter will return a complete security
2323 * descriptor with name:value pairs separated by tabs,
2324 * commas, or newlines (not spaces!).
2326 * The plus sign ('+') indicates that SIDs should be mapped
2327 * to names. Without the plus sign, SIDs are not mapped;
2328 * rather they are simply converted to a string format.
2330 * @return 0 on success, < 0 on error with errno set:
2331 * - EINVAL The client library is not properly initialized
2332 * - ENOMEM No memory was available for internal needs
2333 * - EPERM Permission was denied.
2334 * - ENOTSUP The referenced file system does not support
2335 * extended attributes
2338 int smbc_removexattr(const char *url,
2339 const char *name);
2342 /**@ingroup attribute
2343 * Remove extended attributes for a file. This is used for modifying a file's
2344 * security descriptor (i.e. owner, group, and access control list) The POSIX
2345 * function which this maps to would act on a symbolic link rather than acting
2346 * on what the symbolic link points to, but with no symbolic links in SMB file
2347 * systems, this function is functionally identical to smbc_removexattr().
2349 * @param url The smb url of the file or directory to remove the extended
2350 * attributes for.
2352 * @param name The name of an attribute to be removed. Names are of
2353 * one of the following forms:
2355 * system.nt_sec_desc.<attribute name>
2356 * system.nt_sec_desc.*
2357 * system.nt_sec_desc.*+
2359 * where <attribute name> is one of:
2361 * revision
2362 * owner
2363 * owner+
2364 * group
2365 * group+
2366 * acl:<name or sid>
2367 * acl+:<name or sid>
2369 * In the forms "system.nt_sec_desc.*" and
2370 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2371 * literal, i.e. the string is provided exactly as shown, and
2372 * the value parameter will return a complete security
2373 * descriptor with name:value pairs separated by tabs,
2374 * commas, or newlines (not spaces!).
2376 * The plus sign ('+') indicates that SIDs should be mapped
2377 * to names. Without the plus sign, SIDs are not mapped;
2378 * rather they are simply converted to a string format.
2380 * @return 0 on success, < 0 on error with errno set:
2381 * - EINVAL The client library is not properly initialized
2382 * - ENOMEM No memory was available for internal needs
2383 * - EPERM Permission was denied.
2384 * - ENOTSUP The referenced file system does not support
2385 * extended attributes
2388 int smbc_lremovexattr(const char *url,
2389 const char *name);
2392 /**@ingroup attribute
2393 * Remove extended attributes for a file. This is used for modifying a file's
2394 * security descriptor (i.e. owner, group, and access control list)
2396 * @param fd A file descriptor associated with an open file (as
2397 * previously returned by smbc_open(), to get extended
2398 * attributes for.
2400 * @param name The name of an attribute to be removed. Names are of
2401 * one of the following forms:
2403 * system.nt_sec_desc.<attribute name>
2404 * system.nt_sec_desc.*
2405 * system.nt_sec_desc.*+
2407 * where <attribute name> is one of:
2409 * revision
2410 * owner
2411 * owner+
2412 * group
2413 * group+
2414 * acl:<name or sid>
2415 * acl+:<name or sid>
2417 * In the forms "system.nt_sec_desc.*" and
2418 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2419 * literal, i.e. the string is provided exactly as shown, and
2420 * the value parameter will return a complete security
2421 * descriptor with name:value pairs separated by tabs,
2422 * commas, or newlines (not spaces!).
2424 * The plus sign ('+') indicates that SIDs should be mapped
2425 * to names. Without the plus sign, SIDs are not mapped;
2426 * rather they are simply converted to a string format.
2428 * @return 0 on success, < 0 on error with errno set:
2429 * - EINVAL The client library is not properly initialized
2430 * - ENOMEM No memory was available for internal needs
2431 * - EPERM Permission was denied.
2432 * - ENOTSUP The referenced file system does not support
2433 * extended attributes
2436 int smbc_fremovexattr(int fd,
2437 const char *name);
2440 /**@ingroup attribute
2441 * List the supported extended attribute names associated with a file
2443 * @param url The smb url of the file or directory to list the extended
2444 * attributes for.
2446 * @param list A pointer to a buffer in which the list of attributes for
2447 * the specified file or directory will be placed (unless
2448 * size is zero).
2450 * @param size The size of the buffer pointed to by list. This parameter
2451 * may also be zero, in which case the size of the buffer
2452 * required to hold all of the attribute names will be
2453 * returned, but nothing will be placed into the list buffer.
2455 * @return 0 on success, < 0 on error with errno set:
2456 * - EINVAL The client library is not properly initialized
2457 * - ENOMEM No memory was available for internal needs
2458 * - EPERM Permission was denied.
2459 * - ENOTSUP The referenced file system does not support
2460 * extended attributes
2462 * @note This function always returns all attribute names supported
2463 * by NT file systems, regardless of whether the referenced
2464 * file system supports extended attributes (e.g. a Windows
2465 * 2000 machine supports extended attributes if NTFS is used,
2466 * but not if FAT is used, and Windows 98 doesn't support
2467 * extended attributes at all. Whether this is a feature or
2468 * a bug is yet to be decided.
2470 int smbc_listxattr(const char *url,
2471 char *list,
2472 size_t size);
2474 /**@ingroup attribute
2475 * List the supported extended attribute names associated with a file The
2476 * POSIX function which this maps to would act on a symbolic link rather than
2477 * acting on what the symbolic link points to, but with no symbolic links in
2478 * SMB file systems, this function is functionally identical to
2479 * smbc_listxattr().
2481 * @param url The smb url of the file or directory to list the extended
2482 * attributes for.
2484 * @param list A pointer to a buffer in which the list of attributes for
2485 * the specified file or directory will be placed (unless
2486 * size is zero).
2488 * @param size The size of the buffer pointed to by list. This parameter
2489 * may also be zero, in which case the size of the buffer
2490 * required to hold all of the attribute names will be
2491 * returned, but nothing will be placed into the list buffer.
2493 * @return 0 on success, < 0 on error with errno set:
2494 * - EINVAL The client library is not properly initialized
2495 * - ENOMEM No memory was available for internal needs
2496 * - EPERM Permission was denied.
2497 * - ENOTSUP The referenced file system does not support
2498 * extended attributes
2500 * @note This function always returns all attribute names supported
2501 * by NT file systems, regardless of wether the referenced
2502 * file system supports extended attributes (e.g. a Windows
2503 * 2000 machine supports extended attributes if NTFS is used,
2504 * but not if FAT is used, and Windows 98 doesn't support
2505 * extended attributes at all. Whether this is a feature or
2506 * a bug is yet to be decided.
2508 int smbc_llistxattr(const char *url,
2509 char *list,
2510 size_t size);
2512 /**@ingroup attribute
2513 * List the supported extended attribute names associated with a file
2515 * @param fd A file descriptor associated with an open file (as
2516 * previously returned by smbc_open(), to get extended
2517 * attributes for.
2519 * @param list A pointer to a buffer in which the list of attributes for
2520 * the specified file or directory will be placed (unless
2521 * size is zero).
2523 * @param size The size of the buffer pointed to by list. This parameter
2524 * may also be zero, in which case the size of the buffer
2525 * required to hold all of the attribute names will be
2526 * returned, but nothing will be placed into the list buffer.
2528 * @return 0 on success, < 0 on error with errno set:
2529 * - EINVAL The client library is not properly initialized
2530 * - ENOMEM No memory was available for internal needs
2531 * - EPERM Permission was denied.
2532 * - ENOTSUP The referenced file system does not support
2533 * extended attributes
2535 * @note This function always returns all attribute names supported
2536 * by NT file systems, regardless of wether the referenced
2537 * file system supports extended attributes (e.g. a Windows
2538 * 2000 machine supports extended attributes if NTFS is used,
2539 * but not if FAT is used, and Windows 98 doesn't support
2540 * extended attributes at all. Whether this is a feature or
2541 * a bug is yet to be decided.
2543 int smbc_flistxattr(int fd,
2544 char *list,
2545 size_t size);
2547 /**@ingroup print
2548 * Print a file given the name in fname. It would be a URL ...
2550 * @param fname The URL of a file on a remote SMB server that the
2551 * caller wants printed
2553 * @param printq The URL of the print share to print the file to.
2555 * @return 0 on success, < 0 on error with errno set:
2557 * - EINVAL fname or printq was NULL or smbc_init not
2558 * not called.
2559 * and errors returned by smbc_open
2562 int smbc_print_file(const char *fname, const char *printq);
2564 /**@ingroup print
2565 * Open a print file that can be written to by other calls. This simply
2566 * does an smbc_open call after checking if there is a file name on the
2567 * URI. If not, a temporary name is added ...
2569 * @param fname The URL of the print share to print to?
2571 * @returns A file handle for the print file if successful.
2572 * Returns -1 if an error ocurred and errno has the values
2573 * - EINVAL fname was NULL or smbc_init not called.
2574 * - all errors returned by smbc_open
2577 int smbc_open_print_job(const char *fname);
2579 /**@ingroup print
2580 * List the print jobs on a print share, for the moment, pass a callback
2582 * @param purl The url of the print share to list the jobs of
2584 * @param fn Callback function the receives printjob info
2586 * @return 0 on success, < 0 on error with errno set:
2587 * - EINVAL fname was NULL or smbc_init not called
2588 * - EACCES ???
2590 int smbc_list_print_jobs(const char *purl, smbc_list_print_job_fn fn);
2592 /**@ingroup print
2593 * Delete a print job
2595 * @param purl Url of the print share
2597 * @param id The id of the job to delete
2599 * @return 0 on success, < 0 on error with errno set:
2600 * - EINVAL fname was NULL or smbc_init not called
2602 * @todo what errno values are possible here?
2604 int smbc_unlink_print_job(const char *purl, int id);
2606 /**@ingroup callback
2607 * Remove a server from the cached server list it's unused.
2609 * @param context pointer to smb context
2611 * @param srv pointer to server to remove
2613 * @return On success, 0 is returned. 1 is returned if the server could not
2614 * be removed. Also useable outside libsmbclient.
2616 int smbc_remove_unused_server(SMBCCTX * context, SMBCSRV * srv);
2618 int smbc_parse_path(const char *purl, char *pWorkgroup, char *pServer, char *pShare, char *pPath);
2619 int smbc_check_connectivity(char *puri);
2620 int smbc_server_check_creds(
2621 const char *server,
2622 const char *share,
2623 char *workgroup,
2624 char *username,
2625 char *password);
2626 #ifdef __cplusplus
2628 #endif
2630 /**@ingroup directory
2631 * Convert strings of %xx to their single character equivalent.
2633 * @param dest A pointer to a buffer in which the resulting decoded
2634 * string should be placed. This may be a pointer to the
2635 * same buffer as src_segment.
2637 * @param src A pointer to the buffer containing the URL to be decoded.
2638 * Any %xx sequences herein are converted to their single
2639 * character equivalent. Each 'x' must be a valid hexadecimal
2640 * digit, or that % sequence is left undecoded.
2642 * @param max_dest_len
2643 * The size of the buffer pointed to by dest_segment.
2645 * @return The number of % sequences which could not be converted
2646 * due to lack of two following hexadecimal digits.
2648 #ifdef __cplusplus
2649 extern "C" {
2650 #endif
2652 smbc_urldecode(char *dest, char * src, size_t max_dest_len);
2653 #ifdef __cplusplus
2655 #endif
2659 * Convert any characters not specifically allowed in a URL into their %xx
2660 * equivalent.
2662 * @param dest A pointer to a buffer in which the resulting encoded
2663 * string should be placed. Unlike smbc_urldecode(), this
2664 * must be a buffer unique from src.
2666 * @param src A pointer to the buffer containing the string to be encoded.
2667 * Any character not specifically allowed in a URL is converted
2668 * into its hexadecimal value and encoded as %xx.
2670 * @param max_dest_len
2671 * The size of the buffer pointed to by dest_segment.
2673 * @returns The remaining buffer length.
2675 #ifdef __cplusplus
2676 extern "C" {
2677 #endif
2679 smbc_urlencode(char * dest, char * src, int max_dest_len);
2680 #ifdef __cplusplus
2682 #endif
2685 /**@ingroup directory
2686 * Return the version of the linked Samba code, and thus the version of the
2687 * libsmbclient code.
2689 * @return The version string.
2691 #ifdef __cplusplus
2692 extern "C" {
2693 #endif
2694 const char *
2695 smbc_version(void);
2696 #ifdef __cplusplus
2698 #endif
2700 /**@ingroup misc
2701 * Set the users credentials globally so they can be used for DFS
2702 * referrals. Probably best to use this function in the smbc_get_auth_data_fn
2703 * callback.
2705 * @param workgroup Workgroup of the user.
2707 * @param user Username of user.
2709 * @param password Password of user.
2711 * @param use_kerberos Whether to use Kerberos
2713 * @param signing_state One of these strings (all equivalents on same line):
2714 * "off", "no", "false"
2715 * "on", "yes", "true", "auto"
2716 * "force", "required", "forced"
2719 void
2720 smbc_set_credentials(const char *workgroup,
2721 const char *user,
2722 const char *password,
2723 smbc_bool use_kerberos,
2724 const char *signing_state);
2727 * Wrapper around smbc_set_credentials.
2728 * Used to set correct credentials that will
2729 * be used to connect to DFS target share
2730 * in libsmbclient
2733 void
2734 smbc_set_credentials_with_fallback(SMBCCTX *ctx,
2735 const char *workgroup,
2736 const char *user,
2737 const char *password);
2741 * @ingroup threads
2743 * Initialize for threads using the Posix Threads (pthread)
2744 * implementation. This is a built-in implementation, avoiding the need to
2745 * implement the component functions of the thread interface. If this function
2746 * is used, it is not necessary to call smbc_thread_impl().
2748 * @return {void}
2750 void
2751 smbc_thread_posix(void);
2754 * @ingroup threads
2756 * Initialize for an arbitrary thread implementation. The caller should
2757 * provide, as parameters, pointers to functions to implement the requisite
2758 * low-level thread functionality. A function must be provided for each
2759 * parameter; none may be null.
2761 * If the thread implementation is POSIX Threads (pthreads), then the much
2762 * simpler smbc_thread_pthread() function may be used instead of this one.
2764 * @param create_mutex
2765 * Create a mutex. This function should expect three parameters: lockname,
2766 * pplock, and location. It should create a unique mutex for each unique
2767 * lockname it is provided, and return the mutex identifier in *pplock. The
2768 * location parameter can be used for debugging, as it contains the
2769 * compiler-provided __location__ of the call.
2771 * @param destroy_mutex
2772 * Destroy a mutex. This function should expect two parameters: plock and
2773 * location. It should destroy the mutex associated with the identifier
2774 * plock. The location parameter can be used for debugging, as it contains
2775 * the compiler-provided __location__ of the call.
2777 * @param lock_mutex
2778 * Lock a mutex. This function should expect three parameters: plock,
2779 * lock_type, and location. The mutex aassociated with identifier plock
2780 * should be locked if lock_type is 1, and unlocked if lock_type is 2. The
2781 * location parameter can be used for debugging, as it contains the
2782 * compiler-provided __location__ of the call.
2784 * @param create_tls
2785 * Create thread local storage. This function should expect three
2786 * parameters: keyname, ppkey, and location. It should allocate an
2787 * implementation-specific amount of memory and assign the pointer to that
2788 * allocated memory to *ppkey. The location parameter can be used for
2789 * debugging, as it contains the compiler-provided __location__ of the
2790 * call. This function should return 0 upon success, non-zero upon failure.
2792 * @param destroy_tls
2793 * Destroy thread local storage. This function should expect two parameters:
2794 * ppkey and location. The ppkey parameter points to a variable containing a
2795 * thread local storage key previously provided by the create_tls
2796 * function. The location parameter can be used for debugging, as it
2797 * contains the compiler-provided __location__ of the call.
2799 * @param set_tls
2800 * Set a thread local storage variable's value. This function should expect
2801 * three parameters: pkey, pval, and location. The pkey parameter is a
2802 * thread local storage key previously provided by the create_tls
2803 * function. The (void *) pval parameter contains the value to be placed in
2804 * the thread local storage variable identified by pkey. The location
2805 * parameter can be used for debugging, as it contains the compiler-provided
2806 * __location__ of the call. This function should return 0 upon success;
2807 * non-zero otherwise.
2809 * @param get_tls
2810 * Retrieve a thread local storage variable's value. This function should
2811 * expect two parameters: pkey and location. The pkey parameter is a thread
2812 * local storage key previously provided by the create_tls function, and
2813 * which has previously been used in a call to the set_tls function to
2814 * initialize a thread local storage variable. The location parameter can be
2815 * used for debugging, as it contains the compiler-provided __location__ of
2816 * the call. This function should return the (void *) value stored in the
2817 * variable identified by pkey.
2819 * @return {void}
2821 void
2822 smbc_thread_impl(
2823 /* Mutex functions. */
2824 int (*create_mutex)(const char *lockname,
2825 void **pplock,
2826 const char *location),
2827 void (*destroy_mutex)(void *plock,
2828 const char *location),
2829 int (*lock_mutex)(void *plock,
2830 int lock_type,
2831 const char *location),
2833 /* Thread local storage. */
2834 int (*create_tls)(const char *keyname,
2835 void **ppkey,
2836 const char *location),
2837 void (*destroy_tls)(void **ppkey,
2838 const char *location),
2839 int (*set_tls)(void *pkey,
2840 const void *pval,
2841 const char *location),
2842 void *(*get_tls)(void *pkey,
2843 const char *location)
2849 * @ingroup structure
2850 * Structure that contains a client context information
2851 * This structure is known as SMBCCTX
2853 * DO NOT DIRECTLY MANIPULATE THE CONTEXT STRUCTURE! The data in the context
2854 * structure should all be considered private to the library. It remains here
2855 * only for backward compatibility.
2857 * See the comments herein for use of the setter and getter functions which
2858 * should now be used for manipulating these values. New features, functions,
2859 * etc., are not added here but rather in _internal where they are not
2860 * directly visible to applications. This makes it much easier to maintain
2861 * ABI compatibility.
2863 struct _SMBCCTX
2866 * debug level
2868 * DEPRECATED:
2869 * Use smbc_getDebug() and smbc_setDebug()
2871 int debug DEPRECATED_SMBC_INTERFACE;
2874 * netbios name used for making connections
2876 * DEPRECATED:
2877 * Use smbc_getNetbiosName() and smbc_setNetbiosName()
2879 char * netbios_name DEPRECATED_SMBC_INTERFACE;
2882 * workgroup name used for making connections
2884 * DEPRECATED:
2885 * Use smbc_getWorkgroup() and smbc_setWorkgroup()
2887 char * workgroup DEPRECATED_SMBC_INTERFACE;
2890 * username used for making connections
2892 * DEPRECATED:
2893 * Use smbc_getUser() and smbc_setUser()
2895 char * user DEPRECATED_SMBC_INTERFACE;
2898 * timeout used for waiting on connections / response data (in
2899 * milliseconds)
2901 * DEPRECATED:
2902 * Use smbc_getTimeout() and smbc_setTimeout()
2904 int timeout DEPRECATED_SMBC_INTERFACE;
2907 * callable functions for files:
2908 * For usage and return values see the SMBC_* functions
2910 * DEPRECATED:
2912 * Use smbc_getFunction*() and smbc_setFunction*(), e.g.
2913 * smbc_getFunctionOpen(), smbc_setFunctionUnlink(), etc.
2915 smbc_open_fn open DEPRECATED_SMBC_INTERFACE;
2916 smbc_creat_fn creat DEPRECATED_SMBC_INTERFACE;
2917 smbc_read_fn read DEPRECATED_SMBC_INTERFACE;
2918 smbc_write_fn write DEPRECATED_SMBC_INTERFACE;
2919 smbc_unlink_fn unlink DEPRECATED_SMBC_INTERFACE;
2920 smbc_rename_fn rename DEPRECATED_SMBC_INTERFACE;
2921 smbc_lseek_fn lseek DEPRECATED_SMBC_INTERFACE;
2922 smbc_stat_fn stat DEPRECATED_SMBC_INTERFACE;
2923 smbc_fstat_fn fstat DEPRECATED_SMBC_INTERFACE;
2924 #if 0 /* internal */
2925 smbc_ftruncate_fn ftruncate_fn;
2926 #endif
2927 smbc_close_fn close_fn DEPRECATED_SMBC_INTERFACE;
2928 smbc_opendir_fn opendir DEPRECATED_SMBC_INTERFACE;
2929 smbc_closedir_fn closedir DEPRECATED_SMBC_INTERFACE;
2930 smbc_readdir_fn readdir DEPRECATED_SMBC_INTERFACE;
2931 smbc_getdents_fn getdents DEPRECATED_SMBC_INTERFACE;
2932 smbc_mkdir_fn mkdir DEPRECATED_SMBC_INTERFACE;
2933 smbc_rmdir_fn rmdir DEPRECATED_SMBC_INTERFACE;
2934 smbc_telldir_fn telldir DEPRECATED_SMBC_INTERFACE;
2935 smbc_lseekdir_fn lseekdir DEPRECATED_SMBC_INTERFACE;
2936 smbc_fstatdir_fn fstatdir DEPRECATED_SMBC_INTERFACE;
2937 smbc_chmod_fn chmod DEPRECATED_SMBC_INTERFACE;
2938 smbc_utimes_fn utimes DEPRECATED_SMBC_INTERFACE;
2939 smbc_setxattr_fn setxattr DEPRECATED_SMBC_INTERFACE;
2940 smbc_getxattr_fn getxattr DEPRECATED_SMBC_INTERFACE;
2941 smbc_removexattr_fn removexattr DEPRECATED_SMBC_INTERFACE;
2942 smbc_listxattr_fn listxattr DEPRECATED_SMBC_INTERFACE;
2944 /* Printing-related functions */
2945 smbc_print_file_fn print_file DEPRECATED_SMBC_INTERFACE;
2946 smbc_open_print_job_fn open_print_job DEPRECATED_SMBC_INTERFACE;
2947 smbc_list_print_jobs_fn list_print_jobs DEPRECATED_SMBC_INTERFACE;
2948 smbc_unlink_print_job_fn unlink_print_job DEPRECATED_SMBC_INTERFACE;
2951 ** Callbacks
2953 * DEPRECATED:
2955 * See the comment above each field, for the getter and setter
2956 * functions that should now be used.
2958 struct _smbc_callbacks
2961 * authentication function callback: called upon auth requests
2963 * DEPRECATED:
2964 * Use smbc_getFunctionAuthData(), smbc_setFunctionAuthData()
2966 smbc_get_auth_data_fn auth_fn DEPRECATED_SMBC_INTERFACE;
2969 * check if a server is still good
2971 * DEPRECATED:
2972 * Use smbc_getFunctionCheckServer(),
2973 * smbc_setFunctionCheckServer()
2975 smbc_check_server_fn check_server_fn DEPRECATED_SMBC_INTERFACE;
2978 * remove a server if unused
2980 * DEPRECATED:
2981 * Use smbc_getFunctionRemoveUnusedServer(),
2982 * smbc_setFunctionCheckServer()
2984 smbc_remove_unused_server_fn remove_unused_server_fn DEPRECATED_SMBC_INTERFACE;
2986 /** Cache subsystem
2988 * For an example cache system see
2989 * samba/source/libsmb/libsmb_cache.c
2991 * Cache subsystem * functions follow.
2995 * server cache addition
2997 * DEPRECATED:
2998 * Use smbc_getFunctionAddCachedServer(),
2999 * smbc_setFunctionAddCachedServer()
3001 smbc_add_cached_srv_fn add_cached_srv_fn DEPRECATED_SMBC_INTERFACE;
3004 * server cache lookup
3006 * DEPRECATED:
3007 * Use smbc_getFunctionGetCachedServer(),
3008 * smbc_setFunctionGetCachedServer()
3010 smbc_get_cached_srv_fn get_cached_srv_fn DEPRECATED_SMBC_INTERFACE;
3013 * server cache removal
3015 * DEPRECATED:
3016 * Use smbc_getFunctionRemoveCachedServer(),
3017 * smbc_setFunctionRemoveCachedServer()
3019 smbc_remove_cached_srv_fn remove_cached_srv_fn DEPRECATED_SMBC_INTERFACE;
3022 * server cache purging, try to remove all cached servers
3023 * (disconnect)
3025 * DEPRECATED:
3026 * Use smbc_getFunctionPurgeCachedServers(),
3027 * smbc_setFunctionPurgeCachedServers()
3029 smbc_purge_cached_fn purge_cached_fn DEPRECATED_SMBC_INTERFACE;
3030 } callbacks;
3033 * Space where the private data of the server cache used to be
3035 * DEPRECATED:
3036 * Use smbc_getServerCacheData(), smbc_setServerCacheData()
3038 void * reserved DEPRECATED_SMBC_INTERFACE;
3041 * Very old configuration options.
3043 * DEPRECATED:
3044 * Use one of the following functions instead:
3045 * smbc_setOptionUseKerberos()
3046 * smbc_getOptionUseKerberos()
3047 * smbc_setOptionFallbackAfterKerberos()
3048 * smbc_getOptionFallbackAfterKerberos()
3049 * smbc_setOptionNoAutoAnonymousLogin()
3050 * smbc_getOptionNoAutoAnonymousLogin()
3052 int flags DEPRECATED_SMBC_INTERFACE;
3055 * user options selections that apply to this session
3057 * NEW OPTIONS ARE NOT ADDED HERE!
3059 * DEPRECATED:
3060 * To set and retrieve options, use the smbc_setOption*() and
3061 * smbc_getOption*() functions.
3063 struct _smbc_options {
3064 int browse_max_lmb_count DEPRECATED_SMBC_INTERFACE;
3065 int urlencode_readdir_entries DEPRECATED_SMBC_INTERFACE;
3066 int one_share_per_server DEPRECATED_SMBC_INTERFACE;
3067 } options DEPRECATED_SMBC_INTERFACE;
3069 /** INTERNAL DATA
3070 * do _NOT_ touch this from your program !
3072 struct SMBC_internal_data * internal;
3075 #if 1
3076 /*============================================================*/
3077 //#ifdef LIGHTTPD_INCLUDE
3078 //#ifdef HAVE_LIBSMBCLIENT_H
3079 #if defined(LIGHTTPD_INCLUDE)||defined(HAVE_LIBSMBCLIENT_H)
3081 #define HAVE_IMMEDIATE_STRUCTURES
3082 #if defined(HAVE_IMMEDIATE_STRUCTURES)
3083 typedef struct {uint32_t v;} NTSTATUS;
3084 #define NT_STATUS(x) ((NTSTATUS) { x })
3085 #define NT_STATUS_V(x) ((x).v)
3086 #else
3087 typedef uint32_t NTSTATUS;
3088 #define NT_STATUS(x) (x)
3089 #define NT_STATUS_V(x) (x)
3090 #endif
3092 #define NT_STATUS_OK NT_STATUS(0x0000)
3093 #define NT_STATUS_ACCESS_DENIED NT_STATUS(0xC0000000 | 0x0022)
3094 #define NT_STATUS_LOGON_FAILURE NT_STATUS(0xC0000000 | 0x006d)
3095 #endif
3097 typedef struct smb_file_s {
3098 int fnum;
3099 int offset;
3100 int whence;
3101 char *fname;
3102 }smb_file_t;
3105 #ifdef __cplusplus
3106 extern "C" {
3107 #endif
3108 struct cli_state *smbc_cli_initialize();
3109 uint32_t smbc_cli_connect(struct cli_state *cli, const char *desthost, int port);
3110 void smbc_cli_shutdown(struct cli_state *cli);
3111 int smbc_cli_get_smb_secblob(struct cli_state *cli, unsigned char *blob);
3112 uint32_t smbc_cli_get_smb_challenge(struct cli_state *cli, char *blob);
3113 uint32_t smbc_cli_send_negprot(struct cli_state *cli);
3114 uint32_t smbc_cli_send_negprot_done(struct cli_state *cli);
3115 int smbc_cli_get_protocol(struct cli_state *cli);
3116 int smbc_cli_get_socket(struct cli_state *cli);
3117 uint32_t smbc_cli_get_capabilities(struct cli_state *cli);
3118 uint32_t smbc_cli_tree_connect(struct cli_state *cli, char *fname);
3119 int smbc_cli_parse_path(const char *fname,
3120 char *pWorkgroup,
3121 char *pServer,
3122 char *pShare,
3123 char *pPath);
3124 int smbc_cli_stat(struct cli_state *cli, const char *fname, struct stat *st);
3125 SMBCFILE *smbc_cli_opendir2(const char *fname);
3126 SMBCFILE *smbc_cli_opendir(struct cli_state *cli, const char *fname);
3127 SMBCFILE *smbc_cli_open_share(struct cli_state *cli, const char *fname);
3128 uint32_t smbc_cli_rmdir(struct cli_state *cli, const char *dname);
3129 uint32_t smbc_cli_mkdir(struct cli_state *cli, const char *fname);
3130 uint32_t smbc_cli_rename(struct cli_state *cli, char *src, char *dst);
3131 struct smbc_dirent *smbc_cli_readdir(SMBCFILE *dir);
3132 int smbc_cli_closedir(SMBCFILE *dir);
3133 int smbc_cli_list(struct cli_state *cli,const char *mask, unsigned short attribute,
3134 void (*fn)(const char *, file_info *, const char *, void *), void *state);
3135 void* smbc_cli_ntlmssp_state_alloc();
3136 void smbc_cli_ntlmssp_state_free(void *state);
3137 int smbc_cli_send_session_setup_nego(struct cli_state *cli, void *state, char *ntlm_msg, int ntlm_len);
3138 uint32_t smbc_cli_session_setup_ntlmssp_nego(struct cli_state *cli, void *state, char *ntlm_msg, int ntlm_msg_len);
3139 uint32_t smbc_cli_session_setup_ntlmssp_auth(struct cli_state *cli, void *state, char *ntlm_msg, int ntlm_msg_len);
3140 uint32_t smbc_cli_session_setup_lanman2(struct cli_state *cli, char *ntlm_msg, int ntlm_msg_len);
3141 smb_file_t *smbc_cli_ntcreate(struct cli_state *cli, char *fname,
3142 uint32_t desired_access,
3143 uint32_t create_disposition,
3144 uint32_t create_options);
3146 uint32_t smbc_cli_get(struct cli_state *cli, char *pathname,
3147 NTSTATUS (*sink)(char *buf, size_t n, void *priv),
3148 void *priv);
3149 uint32_t smbc_cli_put(struct cli_state *cli, char *rname, int reput,
3150 size_t (*push_source)(uint8_t *buf, size_t n, void *priv),
3151 void *priv);
3152 smb_file_t* smbc_cli_open(struct cli_state *cli, char *rname, int flags);
3153 uint32_t smbc_cli_lseek(struct cli_state *cli, smb_file_t *smbf, off_t offset, int whence);
3154 size_t smbc_cli_write(struct cli_state *cli, smb_file_t *smbf, uint16_t write_mode, const char *buf, size_t size);
3155 size_t smbc_cli_read(struct cli_state *cli, smb_file_t *smbf, char *buf, size_t size);
3156 uint32_t smbc_cli_close(struct cli_state *cli, smb_file_t *smbf);
3157 uint32_t smbc_cli_unlink(struct cli_state *cli, const char *fname, uint16_t mayhave_attrs);
3158 void *smbc_cli_nmb_lookup( void *priv );
3159 void smbc_cli_nmb_terminate(int term);
3161 //- Jerry add
3162 const char* smbc_nmblookup(const char* ip);
3163 #ifdef __cplusplus
3165 #endif
3168 #endif //#if 0
3170 #endif /* SMBCLIENT_H_INCLUDED */