KCC: docstring for kcc.graph.InternalEdge
[Samba.git] / source3 / include / libsmbclient.h
blobfaaab2e36889a1a7d064cba18ac57d977a86ec71
1 /*=====================================================================
2 Unix SMB/Netbios implementation.
3 SMB client library API definitions
4 Copyright (C) Andrew Tridgell 1998
5 Copyright (C) Richard Sharpe 2000
6 Copyright (C) John Terpsra 2000
7 Copyright (C) Tom Jansen (Ninja ISD) 2002
8 Copyright (C) Derrell Lipman 2003-2008
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 3 of the License, or
14 (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, see <http://www.gnu.org/licenses/>.
23 =====================================================================*/
25 #ifndef SMBCLIENT_H_INCLUDED
26 #define SMBCLIENT_H_INCLUDED
28 #undef DEPRECATED_SMBC_INTERFACE
29 #if ! defined(__LIBSMBCLIENT_INTERNAL__) && defined(__GNUC__)
30 # define DEPRECATED_SMBC_INTERFACE __attribute__ ((deprecated))
31 #else
32 # define DEPRECATED_SMBC_INTERFACE
33 #endif
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
39 /*-------------------------------------------------------------------*/
40 /* The following are special comments to instruct DOXYGEN (automated
41 * documentation tool:
43 /** \defgroup libsmbclient
45 /** \defgroup structure Data Structures Type and Constants
46 * \ingroup libsmbclient
47 * Data structures, types, and constants
49 /** \defgroup callback Callback function types
50 * \ingroup libsmbclient
51 * Callback functions
53 /** \defgroup file File Functions
54 * \ingroup libsmbclient
55 * Functions used to access individual file contents
57 /** \defgroup directory Directory Functions
58 * \ingroup libsmbclient
59 * Functions used to access directory entries
61 /** \defgroup attribute Attributes Functions
62 * \ingroup libsmbclient
63 * Functions used to view or change file and directory attributes
65 /** \defgroup print Print Functions
66 * \ingroup libsmbclient
67 * Functions used to access printing functionality
69 /** \defgroup misc Miscellaneous Functions
70 * \ingroup libsmbclient
71 * Functions that don't fit in to other categories
73 /*-------------------------------------------------------------------*/
75 /* Make sure we have the following includes for now ... */
76 #include <sys/types.h>
77 #include <sys/stat.h>
78 #include <sys/statvfs.h>
79 #include <stdint.h>
80 #include <fcntl.h>
81 #include <utime.h>
83 #define SMBC_BASE_FD 10000 /* smallest file descriptor returned */
85 #define SMBC_WORKGROUP 1
86 #define SMBC_SERVER 2
87 #define SMBC_FILE_SHARE 3
88 #define SMBC_PRINTER_SHARE 4
89 #define SMBC_COMMS_SHARE 5
90 #define SMBC_IPC_SHARE 6
91 #define SMBC_DIR 7
92 #define SMBC_FILE 8
93 #define SMBC_LINK 9
95 /**@ingroup structure
96 * Structure that represents a directory entry.
99 struct smbc_dirent
101 /** Type of entity.
102 SMBC_WORKGROUP=1,
103 SMBC_SERVER=2,
104 SMBC_FILE_SHARE=3,
105 SMBC_PRINTER_SHARE=4,
106 SMBC_COMMS_SHARE=5,
107 SMBC_IPC_SHARE=6,
108 SMBC_DIR=7,
109 SMBC_FILE=8,
110 SMBC_LINK=9,*/
111 unsigned int smbc_type;
113 /** Length of this smbc_dirent in bytes
115 unsigned int dirlen;
116 /** The length of the comment string in bytes (does not include
117 * null terminator)
119 unsigned int commentlen;
120 /** Points to the null terminated comment string
122 char *comment;
123 /** The length of the name string in bytes (does not include
124 * null terminator)
126 unsigned int namelen;
127 /** Points to the null terminated name string
129 char name[1];
133 * Flags for smbc_setxattr()
134 * Specify a bitwise OR of these, or 0 to add or replace as necessary
136 #define SMBC_XATTR_FLAG_CREATE 0x1 /* fail if attr already exists */
137 #define SMBC_XATTR_FLAG_REPLACE 0x2 /* fail if attr does not exist */
141 * Mappings of the DOS mode bits, as returned by smbc_getxattr() when the
142 * attribute name "system.dos_attr.mode" (or "system.dos_attr.*" or
143 * "system.*") is specified.
145 #define SMBC_DOS_MODE_READONLY 0x01
146 #define SMBC_DOS_MODE_HIDDEN 0x02
147 #define SMBC_DOS_MODE_SYSTEM 0x04
148 #define SMBC_DOS_MODE_VOLUME_ID 0x08
149 #define SMBC_DOS_MODE_DIRECTORY 0x10
150 #define SMBC_DOS_MODE_ARCHIVE 0x20
153 * Valid values for the option "open_share_mode", when calling
154 * smbc_setOptionOpenShareMode()
156 typedef enum smbc_share_mode
158 SMBC_SHAREMODE_DENY_DOS = 0,
159 SMBC_SHAREMODE_DENY_ALL = 1,
160 SMBC_SHAREMODE_DENY_WRITE = 2,
161 SMBC_SHAREMODE_DENY_READ = 3,
162 SMBC_SHAREMODE_DENY_NONE = 4,
163 SMBC_SHAREMODE_DENY_FCB = 7
164 } smbc_share_mode;
168 * Values for option SMB Encryption Level, as set and retrieved with
169 * smbc_setOptionSmbEncryptionLevel() and smbc_getOptionSmbEncryptionLevel()
171 typedef enum smbc_smb_encrypt_level
173 SMBC_ENCRYPTLEVEL_NONE = 0,
174 SMBC_ENCRYPTLEVEL_REQUEST = 1,
175 SMBC_ENCRYPTLEVEL_REQUIRE = 2
176 } smbc_smb_encrypt_level;
180 * Capabilities set in the f_flag field of struct statvfs, from
181 * smbc_statvfs(). These may be OR-ed together to reflect a full set of
182 * available capabilities.
184 typedef enum smbc_vfs_feature
186 /* Defined by POSIX or in Linux include files (low-order bits) */
187 SMBC_VFS_FEATURE_RDONLY = (1 << 0),
189 /* Specific to libsmbclient (high-order bits) */
190 SMBC_VFS_FEATURE_DFS = (1 << 28),
191 SMBC_VFS_FEATURE_CASE_INSENSITIVE = (1 << 29),
192 SMBC_VFS_FEATURE_NO_UNIXCIFS = (1 << 30)
193 } smbc_vfs_feature;
195 typedef int smbc_bool;
198 #ifndef ENOATTR
199 # define ENOATTR ENOENT /* No such attribute */
200 #endif
205 /**@ingroup structure
206 * Structure that represents a print job.
209 #ifndef _CLIENT_H
210 struct print_job_info
212 /** numeric ID of the print job
214 unsigned short id;
216 /** represents print job priority (lower numbers mean higher priority)
218 unsigned short priority;
220 /** Size of the print job
222 size_t size;
224 /** Name of the user that owns the print job
226 char user[128];
228 /** Name of the print job. This will have no name if an anonymous print
229 * file was opened. Ie smb://server/printer
231 char name[128];
233 /** Time the print job was spooled
235 time_t t;
237 #endif /* _CLIENT_H */
240 /**@ingroup structure
241 * Server handle
243 typedef struct _SMBCSRV SMBCSRV;
245 /**@ingroup structure
246 * File or directory handle
248 typedef struct _SMBCFILE SMBCFILE;
250 /**@ingroup structure
251 * File or directory handle
253 typedef struct _SMBCCTX SMBCCTX;
257 * Flags for SMBCCTX->flags
259 * NEW CODE SHOULD NOT DIRECTLY MANIPULATE THE CONTEXT STRUCTURE.
260 * Instead, use:
261 * smbc_setOptionUseKerberos()
262 * smbc_getOptionUseKerberos()
263 * smbc_setOptionFallbackAfterKerberos()
264 * smbc_getOptionFallbackAFterKerberos()
265 * smbc_setOptionNoAutoAnonymousLogin()
266 * smbc_getOptionNoAutoAnonymousLogin()
267 * smbc_setOptionUseCCache()
268 * smbc_getOptionUseCCache()
270 # define SMB_CTX_FLAG_USE_KERBEROS (1 << 0)
271 # define SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS (1 << 1)
272 # define SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON (1 << 2)
273 # define SMB_CTX_FLAG_USE_CCACHE (1 << 3)
277 /**@ingroup callback
278 * Authentication callback function type (traditional method)
280 * Type for the the authentication function called by the library to
281 * obtain authentication credentials
283 * For kerberos support the function should just be called without
284 * prompting the user for credentials. Which means a simple 'return'
285 * should work. Take a look at examples/libsmbclient/get_auth_data_fn.h
286 * and examples/libsmbclient/testbrowse.c.
288 * @param srv Server being authenticated to
290 * @param shr Share being authenticated to
292 * @param wg Pointer to buffer containing a "hint" for the
293 * workgroup to be authenticated. Should be filled in
294 * with the correct workgroup if the hint is wrong.
296 * @param wglen The size of the workgroup buffer in bytes
298 * @param un Pointer to buffer containing a "hint" for the
299 * user name to be use for authentication. Should be
300 * filled in with the correct workgroup if the hint is
301 * wrong.
303 * @param unlen The size of the username buffer in bytes
305 * @param pw Pointer to buffer containing to which password
306 * copied
308 * @param pwlen The size of the password buffer in bytes
311 typedef void (*smbc_get_auth_data_fn)(const char *srv,
312 const char *shr,
313 char *wg, int wglen,
314 char *un, int unlen,
315 char *pw, int pwlen);
316 /**@ingroup callback
317 * Authentication callback function type (method that includes context)
319 * Type for the the authentication function called by the library to
320 * obtain authentication credentials
322 * For kerberos support the function should just be called without
323 * prompting the user for credentials. Which means a simple 'return'
324 * should work. Take a look at examples/libsmbclient/get_auth_data_fn.h
325 * and examples/libsmbclient/testbrowse.c.
327 * @param c Pointer to the smb context
329 * @param srv Server being authenticated to
331 * @param shr Share being authenticated to
333 * @param wg Pointer to buffer containing a "hint" for the
334 * workgroup to be authenticated. Should be filled in
335 * with the correct workgroup if the hint is wrong.
337 * @param wglen The size of the workgroup buffer in bytes
339 * @param un Pointer to buffer containing a "hint" for the
340 * user name to be use for authentication. Should be
341 * filled in with the correct workgroup if the hint is
342 * wrong.
344 * @param unlen The size of the username buffer in bytes
346 * @param pw Pointer to buffer containing to which password
347 * copied
349 * @param pwlen The size of the password buffer in bytes
352 typedef void (*smbc_get_auth_data_with_context_fn)(SMBCCTX *c,
353 const char *srv,
354 const char *shr,
355 char *wg, int wglen,
356 char *un, int unlen,
357 char *pw, int pwlen);
360 /**@ingroup callback
361 * Print job info callback function type.
363 * @param i pointer to print job information structure
366 typedef void (*smbc_list_print_job_fn)(struct print_job_info *i);
369 /**@ingroup callback
370 * Check if a server is still good
372 * @param c pointer to smb context
374 * @param srv pointer to server to check
376 * @return 0 when connection is good. 1 on error.
379 typedef int (*smbc_check_server_fn)(SMBCCTX * c, SMBCSRV *srv);
381 /**@ingroup callback
382 * Remove a server if unused
384 * @param c pointer to smb context
386 * @param srv pointer to server to remove
388 * @return 0 on success. 1 on failure.
391 typedef int (*smbc_remove_unused_server_fn)(SMBCCTX * c, SMBCSRV *srv);
394 /**@ingroup callback
395 * Add a server to the cache system
397 * @param c pointer to smb context
399 * @param srv pointer to server to add
401 * @param server server name
403 * @param share share name
405 * @param workgroup workgroup used to connect
407 * @param username username used to connect
409 * @return 0 on success. 1 on failure.
412 typedef int (*smbc_add_cached_srv_fn) (SMBCCTX * c, SMBCSRV *srv,
413 const char * server, const char * share,
414 const char * workgroup, const char * username);
416 /**@ingroup callback
417 * Look up a server in the cache system
419 * @param c pointer to smb context
421 * @param server server name to match
423 * @param share share name to match
425 * @param workgroup workgroup to match
427 * @param username username to match
429 * @return pointer to SMBCSRV on success. NULL on failure.
432 typedef SMBCSRV * (*smbc_get_cached_srv_fn) (SMBCCTX * c, const char * server,
433 const char * share, const char * workgroup,
434 const char * username);
436 /**@ingroup callback
437 * Check if a server is still good
439 * @param c pointer to smb context
441 * @param srv pointer to server to remove
443 * @return 0 when found and removed. 1 on failure.
446 typedef int (*smbc_remove_cached_srv_fn)(SMBCCTX * c, SMBCSRV *srv);
449 /**@ingroup callback
450 * Try to remove all servers from the cache system and disconnect
452 * @param c pointer to smb context
454 * @return 0 when found and removed. 1 on failure.
457 typedef int (*smbc_purge_cached_fn) (SMBCCTX * c);
461 /*****************************************
462 * Getters and setters for CONFIGURATION *
463 *****************************************/
465 /** Get the debug level */
467 smbc_getDebug(SMBCCTX *c);
469 /** Set the debug level */
470 void
471 smbc_setDebug(SMBCCTX *c, int debug);
473 /** Get the netbios name used for making connections */
474 char *
475 smbc_getNetbiosName(SMBCCTX *c);
477 /** Set the netbios name used for making connections */
478 void
479 smbc_setNetbiosName(SMBCCTX *c, char * netbios_name);
481 /** Get the workgroup used for making connections */
482 char *
483 smbc_getWorkgroup(SMBCCTX *c);
485 /** Set the workgroup used for making connections */
486 void smbc_setWorkgroup(SMBCCTX *c, char * workgroup);
488 /** Get the username used for making connections */
489 char *
490 smbc_getUser(SMBCCTX *c);
492 /** Set the username used for making connections */
493 void
494 smbc_setUser(SMBCCTX *c, char * user);
497 * Get the timeout used for waiting on connections and response data
498 * (in milliseconds)
501 smbc_getTimeout(SMBCCTX *c);
504 * Set the timeout used for waiting on connections and response data
505 * (in milliseconds)
507 void
508 smbc_setTimeout(SMBCCTX *c, int timeout);
512 * Get the TCP port used to connect (0 means default).
514 uint16_t
515 smbc_getPort(SMBCCTX *c);
518 * Set the TCP port used to connect (0 means default).
520 void
521 smbc_setPort(SMBCCTX *c, uint16_t port);
525 /***********************************
526 * Getters and setters for OPTIONS *
527 ***********************************/
529 /** Get whether to log to standard error instead of standard output */
530 smbc_bool
531 smbc_getOptionDebugToStderr(SMBCCTX *c);
533 /** Set whether to log to standard error instead of standard output */
534 void
535 smbc_setOptionDebugToStderr(SMBCCTX *c, smbc_bool b);
538 * Get whether to use new-style time attribute names, e.g. WRITE_TIME rather
539 * than the old-style names such as M_TIME. This allows also setting/getting
540 * CREATE_TIME which was previously unimplemented. (Note that the old C_TIME
541 * was supposed to be CHANGE_TIME but was confused and sometimes referred to
542 * CREATE_TIME.)
544 smbc_bool
545 smbc_getOptionFullTimeNames(SMBCCTX *c);
548 * Set whether to use new-style time attribute names, e.g. WRITE_TIME rather
549 * than the old-style names such as M_TIME. This allows also setting/getting
550 * CREATE_TIME which was previously unimplemented. (Note that the old C_TIME
551 * was supposed to be CHANGE_TIME but was confused and sometimes referred to
552 * CREATE_TIME.)
554 void
555 smbc_setOptionFullTimeNames(SMBCCTX *c, smbc_bool b);
558 * Get the share mode to use for files opened with SMBC_open_ctx(). The
559 * default is SMBC_SHAREMODE_DENY_NONE.
561 smbc_share_mode
562 smbc_getOptionOpenShareMode(SMBCCTX *c);
565 * Set the share mode to use for files opened with SMBC_open_ctx(). The
566 * default is SMBC_SHAREMODE_DENY_NONE.
568 void
569 smbc_setOptionOpenShareMode(SMBCCTX *c, smbc_share_mode share_mode);
571 /** Retrieve a previously saved user data handle */
572 void *
573 smbc_getOptionUserData(SMBCCTX *c);
575 /** Save a user data handle */
576 void
577 smbc_setOptionUserData(SMBCCTX *c, void *user_data);
579 /** Get the encoded value for encryption level. */
580 smbc_smb_encrypt_level
581 smbc_getOptionSmbEncryptionLevel(SMBCCTX *c);
583 /** Set the encoded value for encryption level. */
584 void
585 smbc_setOptionSmbEncryptionLevel(SMBCCTX *c, smbc_smb_encrypt_level level);
588 * Get whether to treat file names as case-sensitive if we can't determine
589 * when connecting to the remote share whether the file system is case
590 * sensitive. This defaults to FALSE since it's most likely that if we can't
591 * retrieve the file system attributes, it's a very old file system that does
592 * not support case sensitivity.
594 smbc_bool
595 smbc_getOptionCaseSensitive(SMBCCTX *c);
598 * Set whether to treat file names as case-sensitive if we can't determine
599 * when connecting to the remote share whether the file system is case
600 * sensitive. This defaults to FALSE since it's most likely that if we can't
601 * retrieve the file system attributes, it's a very old file system that does
602 * not support case sensitivity.
604 void
605 smbc_setOptionCaseSensitive(SMBCCTX *c, smbc_bool b);
609 * Get from how many local master browsers should the list of workgroups be
610 * retrieved. It can take up to 12 minutes or longer after a server becomes a
611 * local master browser, for it to have the entire browse list (the list of
612 * workgroups/domains) from an entire network. Since a client never knows
613 * which local master browser will be found first, the one which is found
614 * first and used to retrieve a browse list may have an incomplete or empty
615 * browse list. By requesting the browse list from multiple local master
616 * browsers, a more complete list can be generated. For small networks (few
617 * workgroups), it is recommended that this value be set to 0, causing the
618 * browse lists from all found local master browsers to be retrieved and
619 * merged. For networks with many workgroups, a suitable value for this
620 * variable is probably somewhere around 3. (Default: 3).
623 smbc_getOptionBrowseMaxLmbCount(SMBCCTX *c);
626 * Set from how many local master browsers should the list of workgroups be
627 * retrieved. It can take up to 12 minutes or longer after a server becomes a
628 * local master browser, for it to have the entire browse list (the list of
629 * workgroups/domains) from an entire network. Since a client never knows
630 * which local master browser will be found first, the one which is found
631 * first and used to retrieve a browse list may have an incomplete or empty
632 * browse list. By requesting the browse list from multiple local master
633 * browsers, a more complete list can be generated. For small networks (few
634 * workgroups), it is recommended that this value be set to 0, causing the
635 * browse lists from all found local master browsers to be retrieved and
636 * merged. For networks with many workgroups, a suitable value for this
637 * variable is probably somewhere around 3. (Default: 3).
639 void
640 smbc_setOptionBrowseMaxLmbCount(SMBCCTX *c, int count);
643 * Get whether to url-encode readdir entries.
645 * There is a difference in the desired return strings from
646 * smbc_readdir() depending upon whether the filenames are to
647 * be displayed to the user, or whether they are to be
648 * appended to the path name passed to smbc_opendir() to call
649 * a further smbc_ function (e.g. open the file with
650 * smbc_open()). In the former case, the filename should be
651 * in "human readable" form. In the latter case, the smbc_
652 * functions expect a URL which must be url-encoded. Those
653 * functions decode the URL. If, for example, smbc_readdir()
654 * returned a file name of "abc%20def.txt", passing a path
655 * with this file name attached to smbc_open() would cause
656 * smbc_open to attempt to open the file "abc def.txt" since
657 * the %20 is decoded into a space.
659 * Set this option to True if the names returned by
660 * smbc_readdir() should be url-encoded such that they can be
661 * passed back to another smbc_ call. Set it to False if the
662 * names returned by smbc_readdir() are to be presented to the
663 * user.
665 * For backwards compatibility, this option defaults to False.
667 smbc_bool
668 smbc_getOptionUrlEncodeReaddirEntries(SMBCCTX *c);
671 * Set whether to url-encode readdir entries.
673 * There is a difference in the desired return strings from
674 * smbc_readdir() depending upon whether the filenames are to
675 * be displayed to the user, or whether they are to be
676 * appended to the path name passed to smbc_opendir() to call
677 * a further smbc_ function (e.g. open the file with
678 * smbc_open()). In the former case, the filename should be
679 * in "human readable" form. In the latter case, the smbc_
680 * functions expect a URL which must be url-encoded. Those
681 * functions decode the URL. If, for example, smbc_readdir()
682 * returned a file name of "abc%20def.txt", passing a path
683 * with this file name attached to smbc_open() would cause
684 * smbc_open to attempt to open the file "abc def.txt" since
685 * the %20 is decoded into a space.
687 * Set this option to True if the names returned by
688 * smbc_readdir() should be url-encoded such that they can be
689 * passed back to another smbc_ call. Set it to False if the
690 * names returned by smbc_readdir() are to be presented to the
691 * user.
693 * For backwards compatibility, this option defaults to False.
695 void
696 smbc_setOptionUrlEncodeReaddirEntries(SMBCCTX *c, smbc_bool b);
699 * Get whether to use the same connection for all shares on a server.
701 * Some Windows versions appear to have a limit to the number
702 * of concurrent SESSIONs and/or TREE CONNECTions. In
703 * one-shot programs (i.e. the program runs and then quickly
704 * ends, thereby shutting down all connections), it is
705 * probably reasonable to establish a new connection for each
706 * share. In long-running applications, the limitation can be
707 * avoided by using only a single connection to each server,
708 * and issuing a new TREE CONNECT when the share is accessed.
710 smbc_bool
711 smbc_getOptionOneSharePerServer(SMBCCTX *c);
714 * Set whether to use the same connection for all shares on a server.
716 * Some Windows versions appear to have a limit to the number
717 * of concurrent SESSIONs and/or TREE CONNECTions. In
718 * one-shot programs (i.e. the program runs and then quickly
719 * ends, thereby shutting down all connections), it is
720 * probably reasonable to establish a new connection for each
721 * share. In long-running applications, the limitation can be
722 * avoided by using only a single connection to each server,
723 * and issuing a new TREE CONNECT when the share is accessed.
725 void
726 smbc_setOptionOneSharePerServer(SMBCCTX *c, smbc_bool b);
728 /** Get whether to enable use of kerberos */
729 smbc_bool
730 smbc_getOptionUseKerberos(SMBCCTX *c);
732 /** Set whether to enable use of kerberos */
733 void
734 smbc_setOptionUseKerberos(SMBCCTX *c, smbc_bool b);
736 /** Get whether to fallback after kerberos */
737 smbc_bool
738 smbc_getOptionFallbackAfterKerberos(SMBCCTX *c);
740 /** Set whether to fallback after kerberos */
741 void
742 smbc_setOptionFallbackAfterKerberos(SMBCCTX *c, smbc_bool b);
744 /** Get whether to automatically select anonymous login */
745 smbc_bool
746 smbc_getOptionNoAutoAnonymousLogin(SMBCCTX *c);
748 /** Set whether to automatically select anonymous login */
749 void
750 smbc_setOptionNoAutoAnonymousLogin(SMBCCTX *c, smbc_bool b);
752 /** Get whether to enable use of the winbind ccache */
753 smbc_bool
754 smbc_getOptionUseCCache(SMBCCTX *c);
756 /** Set whether to enable use of the winbind ccache */
757 void
758 smbc_setOptionUseCCache(SMBCCTX *c, smbc_bool b);
760 /** Get indication that the password supplied is the NT hash */
761 smbc_bool
762 smbc_getOptionUseNTHash(SMBCCTX *c);
764 /** Set indication that the password supplied is the NT hash */
765 void
766 smbc_setOptionUseNTHash(SMBCCTX *c, smbc_bool b);
770 /*************************************
771 * Getters and setters for FUNCTIONS *
772 *************************************/
774 /** Get the function for obtaining authentication data */
775 smbc_get_auth_data_fn smbc_getFunctionAuthData(SMBCCTX *c);
777 /** Set the function for obtaining authentication data */
778 void smbc_setFunctionAuthData(SMBCCTX *c, smbc_get_auth_data_fn fn);
780 /** Get the new-style authentication function which includes the context. */
781 smbc_get_auth_data_with_context_fn
782 smbc_getFunctionAuthDataWithContext(SMBCCTX *c);
784 /** Set the new-style authentication function which includes the context. */
785 void
786 smbc_setFunctionAuthDataWithContext(SMBCCTX *c,
787 smbc_get_auth_data_with_context_fn fn);
789 /** Get the function for checking if a server is still good */
790 smbc_check_server_fn smbc_getFunctionCheckServer(SMBCCTX *c);
792 /** Set the function for checking if a server is still good */
793 void smbc_setFunctionCheckServer(SMBCCTX *c, smbc_check_server_fn fn);
795 /** Get the function for removing a server if unused */
796 smbc_remove_unused_server_fn smbc_getFunctionRemoveUnusedServer(SMBCCTX *c);
798 /** Set the function for removing a server if unused */
799 void smbc_setFunctionRemoveUnusedServer(SMBCCTX *c,
800 smbc_remove_unused_server_fn fn);
802 /** Get the function for adding a cached server */
803 smbc_add_cached_srv_fn smbc_getFunctionAddCachedServer(SMBCCTX *c);
805 /** Set the function for adding a cached server */
806 void smbc_setFunctionAddCachedServer(SMBCCTX *c, smbc_add_cached_srv_fn fn);
808 /** Get the function for server cache lookup */
809 smbc_get_cached_srv_fn smbc_getFunctionGetCachedServer(SMBCCTX *c);
811 /** Set the function for server cache lookup */
812 void smbc_setFunctionGetCachedServer(SMBCCTX *c, smbc_get_cached_srv_fn fn);
814 /** Get the function for server cache removal */
815 smbc_remove_cached_srv_fn smbc_getFunctionRemoveCachedServer(SMBCCTX *c);
817 /** Set the function for server cache removal */
818 void smbc_setFunctionRemoveCachedServer(SMBCCTX *c,
819 smbc_remove_cached_srv_fn fn);
822 * Get the function for server cache purging. This function tries to
823 * remove all cached servers (e.g. on disconnect)
825 smbc_purge_cached_fn smbc_getFunctionPurgeCachedServers(SMBCCTX *c);
828 * Set the function for server cache purging. This function tries to
829 * remove all cached servers (e.g. on disconnect)
831 void smbc_setFunctionPurgeCachedServers(SMBCCTX *c,
832 smbc_purge_cached_fn fn);
834 /** Get the function to store private data of the server cache */
835 struct smbc_server_cache * smbc_getServerCacheData(SMBCCTX *c);
837 /** Set the function to store private data of the server cache */
838 void smbc_setServerCacheData(SMBCCTX *c, struct smbc_server_cache * cache);
842 /*****************************************************************
843 * Callable functions for files. *
844 * Each callable has a function signature typedef, a declaration *
845 * for the getter, and a declaration for the setter. *
846 *****************************************************************/
848 typedef SMBCFILE * (*smbc_open_fn)(SMBCCTX *c,
849 const char *fname,
850 int flags,
851 mode_t mode);
852 smbc_open_fn smbc_getFunctionOpen(SMBCCTX *c);
853 void smbc_setFunctionOpen(SMBCCTX *c, smbc_open_fn fn);
855 typedef SMBCFILE * (*smbc_creat_fn)(SMBCCTX *c,
856 const char *path,
857 mode_t mode);
858 smbc_creat_fn smbc_getFunctionCreat(SMBCCTX *c);
859 void smbc_setFunctionCreat(SMBCCTX *c, smbc_creat_fn);
861 typedef ssize_t (*smbc_read_fn)(SMBCCTX *c,
862 SMBCFILE *file,
863 void *buf,
864 size_t count);
865 smbc_read_fn smbc_getFunctionRead(SMBCCTX *c);
866 void smbc_setFunctionRead(SMBCCTX *c, smbc_read_fn fn);
868 typedef ssize_t (*smbc_write_fn)(SMBCCTX *c,
869 SMBCFILE *file,
870 const void *buf,
871 size_t count);
872 smbc_write_fn smbc_getFunctionWrite(SMBCCTX *c);
873 void smbc_setFunctionWrite(SMBCCTX *c, smbc_write_fn fn);
875 typedef off_t (*smbc_splice_fn)(SMBCCTX *c,
876 SMBCFILE *srcfile,
877 SMBCFILE *dstfile,
878 off_t count,
879 int (*splice_cb)(off_t n, void *priv),
880 void *priv);
881 smbc_splice_fn smbc_getFunctionSplice(SMBCCTX *c);
882 void smbc_setFunctionSplice(SMBCCTX *c, smbc_splice_fn fn);
884 typedef int (*smbc_unlink_fn)(SMBCCTX *c,
885 const char *fname);
886 smbc_unlink_fn smbc_getFunctionUnlink(SMBCCTX *c);
887 void smbc_setFunctionUnlink(SMBCCTX *c, smbc_unlink_fn fn);
889 typedef int (*smbc_rename_fn)(SMBCCTX *ocontext,
890 const char *oname,
891 SMBCCTX *ncontext,
892 const char *nname);
893 smbc_rename_fn smbc_getFunctionRename(SMBCCTX *c);
894 void smbc_setFunctionRename(SMBCCTX *c, smbc_rename_fn fn);
896 typedef off_t (*smbc_lseek_fn)(SMBCCTX *c,
897 SMBCFILE * file,
898 off_t offset,
899 int whence);
900 smbc_lseek_fn smbc_getFunctionLseek(SMBCCTX *c);
901 void smbc_setFunctionLseek(SMBCCTX *c, smbc_lseek_fn fn);
903 typedef int (*smbc_stat_fn)(SMBCCTX *c,
904 const char *fname,
905 struct stat *st);
906 smbc_stat_fn smbc_getFunctionStat(SMBCCTX *c);
907 void smbc_setFunctionStat(SMBCCTX *c, smbc_stat_fn fn);
909 typedef int (*smbc_fstat_fn)(SMBCCTX *c,
910 SMBCFILE *file,
911 struct stat *st);
912 smbc_fstat_fn smbc_getFunctionFstat(SMBCCTX *c);
913 void smbc_setFunctionFstat(SMBCCTX *c, smbc_fstat_fn fn);
915 typedef int (*smbc_statvfs_fn)(SMBCCTX *c,
916 char *path,
917 struct statvfs *st);
918 smbc_statvfs_fn smbc_getFunctionStatVFS(SMBCCTX *c);
919 void smbc_setFunctionStatVFS(SMBCCTX *c, smbc_statvfs_fn fn);
921 typedef int (*smbc_fstatvfs_fn)(SMBCCTX *c,
922 SMBCFILE *file,
923 struct statvfs *st);
924 smbc_fstatvfs_fn smbc_getFunctionFstatVFS(SMBCCTX *c);
925 void smbc_setFunctionFstatVFS(SMBCCTX *c, smbc_fstatvfs_fn fn);
927 typedef int (*smbc_ftruncate_fn)(SMBCCTX *c,
928 SMBCFILE *f,
929 off_t size);
930 smbc_ftruncate_fn smbc_getFunctionFtruncate(SMBCCTX *c);
931 void smbc_setFunctionFtruncate(SMBCCTX *c, smbc_ftruncate_fn fn);
933 typedef int (*smbc_close_fn)(SMBCCTX *c,
934 SMBCFILE *file);
935 smbc_close_fn smbc_getFunctionClose(SMBCCTX *c);
936 void smbc_setFunctionClose(SMBCCTX *c, smbc_close_fn fn);
940 /*****************************************************************
941 * Callable functions for directories. *
942 * Each callable has a function signature typedef, a declaration *
943 * for the getter, and a declaration for the setter. *
944 *****************************************************************/
946 typedef SMBCFILE * (*smbc_opendir_fn)(SMBCCTX *c,
947 const char *fname);
948 smbc_opendir_fn smbc_getFunctionOpendir(SMBCCTX *c);
949 void smbc_setFunctionOpendir(SMBCCTX *c, smbc_opendir_fn fn);
951 typedef int (*smbc_closedir_fn)(SMBCCTX *c,
952 SMBCFILE *dir);
953 smbc_closedir_fn smbc_getFunctionClosedir(SMBCCTX *c);
954 void smbc_setFunctionClosedir(SMBCCTX *c, smbc_closedir_fn fn);
956 typedef struct smbc_dirent * (*smbc_readdir_fn)(SMBCCTX *c,
957 SMBCFILE *dir);
958 smbc_readdir_fn smbc_getFunctionReaddir(SMBCCTX *c);
959 void smbc_setFunctionReaddir(SMBCCTX *c, smbc_readdir_fn fn);
961 typedef int (*smbc_getdents_fn)(SMBCCTX *c,
962 SMBCFILE *dir,
963 struct smbc_dirent *dirp,
964 int count);
965 smbc_getdents_fn smbc_getFunctionGetdents(SMBCCTX *c);
966 void smbc_setFunctionGetdents(SMBCCTX *c, smbc_getdents_fn fn);
968 typedef int (*smbc_mkdir_fn)(SMBCCTX *c,
969 const char *fname,
970 mode_t mode);
971 smbc_mkdir_fn smbc_getFunctionMkdir(SMBCCTX *c);
972 void smbc_setFunctionMkdir(SMBCCTX *c, smbc_mkdir_fn fn);
974 typedef int (*smbc_rmdir_fn)(SMBCCTX *c,
975 const char *fname);
976 smbc_rmdir_fn smbc_getFunctionRmdir(SMBCCTX *c);
977 void smbc_setFunctionRmdir(SMBCCTX *c, smbc_rmdir_fn fn);
979 typedef off_t (*smbc_telldir_fn)(SMBCCTX *c,
980 SMBCFILE *dir);
981 smbc_telldir_fn smbc_getFunctionTelldir(SMBCCTX *c);
982 void smbc_setFunctionTelldir(SMBCCTX *c, smbc_telldir_fn fn);
984 typedef int (*smbc_lseekdir_fn)(SMBCCTX *c,
985 SMBCFILE *dir,
986 off_t offset);
987 smbc_lseekdir_fn smbc_getFunctionLseekdir(SMBCCTX *c);
988 void smbc_setFunctionLseekdir(SMBCCTX *c, smbc_lseekdir_fn fn);
990 typedef int (*smbc_fstatdir_fn)(SMBCCTX *c,
991 SMBCFILE *dir,
992 struct stat *st);
993 smbc_fstatdir_fn smbc_getFunctionFstatdir(SMBCCTX *c);
994 void smbc_setFunctionFstatdir(SMBCCTX *c, smbc_fstatdir_fn fn);
998 /*****************************************************************
999 * Callable functions applicable to both files and directories. *
1000 * Each callable has a function signature typedef, a declaration *
1001 * for the getter, and a declaration for the setter. *
1002 *****************************************************************/
1004 typedef int (*smbc_chmod_fn)(SMBCCTX *c,
1005 const char *fname,
1006 mode_t mode);
1007 smbc_chmod_fn smbc_getFunctionChmod(SMBCCTX *c);
1008 void smbc_setFunctionChmod(SMBCCTX *c, smbc_chmod_fn fn);
1010 typedef int (*smbc_utimes_fn)(SMBCCTX *c,
1011 const char *fname,
1012 struct timeval *tbuf);
1013 smbc_utimes_fn smbc_getFunctionUtimes(SMBCCTX *c);
1014 void smbc_setFunctionUtimes(SMBCCTX *c, smbc_utimes_fn fn);
1016 typedef int (*smbc_setxattr_fn)(SMBCCTX *context,
1017 const char *fname,
1018 const char *name,
1019 const void *value,
1020 size_t size,
1021 int flags);
1022 smbc_setxattr_fn smbc_getFunctionSetxattr(SMBCCTX *c);
1023 void smbc_setFunctionSetxattr(SMBCCTX *c, smbc_setxattr_fn fn);
1025 typedef int (*smbc_getxattr_fn)(SMBCCTX *context,
1026 const char *fname,
1027 const char *name,
1028 const void *value,
1029 size_t size);
1030 smbc_getxattr_fn smbc_getFunctionGetxattr(SMBCCTX *c);
1031 void smbc_setFunctionGetxattr(SMBCCTX *c, smbc_getxattr_fn fn);
1033 typedef int (*smbc_removexattr_fn)(SMBCCTX *context,
1034 const char *fname,
1035 const char *name);
1036 smbc_removexattr_fn smbc_getFunctionRemovexattr(SMBCCTX *c);
1037 void smbc_setFunctionRemovexattr(SMBCCTX *c, smbc_removexattr_fn fn);
1039 typedef int (*smbc_listxattr_fn)(SMBCCTX *context,
1040 const char *fname,
1041 char *list,
1042 size_t size);
1043 smbc_listxattr_fn smbc_getFunctionListxattr(SMBCCTX *c);
1044 void smbc_setFunctionListxattr(SMBCCTX *c, smbc_listxattr_fn fn);
1048 /*****************************************************************
1049 * Callable functions for printing. *
1050 * Each callable has a function signature typedef, a declaration *
1051 * for the getter, and a declaration for the setter. *
1052 *****************************************************************/
1054 typedef int (*smbc_print_file_fn)(SMBCCTX *c_file,
1055 const char *fname,
1056 SMBCCTX *c_print,
1057 const char *printq);
1058 smbc_print_file_fn smbc_getFunctionPrintFile(SMBCCTX *c);
1059 void smbc_setFunctionPrintFile(SMBCCTX *c, smbc_print_file_fn fn);
1061 typedef SMBCFILE * (*smbc_open_print_job_fn)(SMBCCTX *c,
1062 const char *fname);
1063 smbc_open_print_job_fn smbc_getFunctionOpenPrintJob(SMBCCTX *c);
1064 void smbc_setFunctionOpenPrintJob(SMBCCTX *c,
1065 smbc_open_print_job_fn fn);
1067 typedef int (*smbc_list_print_jobs_fn)(SMBCCTX *c,
1068 const char *fname,
1069 smbc_list_print_job_fn fn);
1070 smbc_list_print_jobs_fn smbc_getFunctionListPrintJobs(SMBCCTX *c);
1071 void smbc_setFunctionListPrintJobs(SMBCCTX *c,
1072 smbc_list_print_jobs_fn fn);
1074 typedef int (*smbc_unlink_print_job_fn)(SMBCCTX *c,
1075 const char *fname,
1076 int id);
1077 smbc_unlink_print_job_fn smbc_getFunctionUnlinkPrintJob(SMBCCTX *c);
1078 void smbc_setFunctionUnlinkPrintJob(SMBCCTX *c,
1079 smbc_unlink_print_job_fn fn);
1082 /**@ingroup misc
1083 * Create a new SBMCCTX (a context).
1085 * Must be called before the context is passed to smbc_context_init()
1087 * @return The given SMBCCTX pointer on success, NULL on error with errno set:
1088 * - ENOMEM Out of memory
1090 * @see smbc_free_context(), smbc_init_context()
1092 * @note Do not forget to smbc_init_context() the returned SMBCCTX pointer !
1094 SMBCCTX * smbc_new_context(void);
1096 /**@ingroup misc
1097 * Delete a SBMCCTX (a context) acquired from smbc_new_context().
1099 * The context will be deleted if possible.
1101 * @param context A pointer to a SMBCCTX obtained from smbc_new_context()
1103 * @param shutdown_ctx If 1, all connections and files will be closed even if they are busy.
1106 * @return Returns 0 on succes. Returns 1 on failure with errno set:
1107 * - EBUSY Server connections are still used, Files are open or cache
1108 * could not be purged
1109 * - EBADF context == NULL
1111 * @see smbc_new_context()
1113 * @note It is advised to clean up all the contexts with shutdown_ctx set to 1
1114 * just before exit()'ing. When shutdown_ctx is 0, this function can be
1115 * use in periodical cleanup functions for example.
1117 int smbc_free_context(SMBCCTX * context, int shutdown_ctx);
1120 /**@ingroup misc
1122 * @deprecated. Use smbc_setOption*() functions instead.
1124 void
1125 smbc_option_set(SMBCCTX *context,
1126 char *option_name,
1127 ... /* option_value */);
1130 * @deprecated. Use smbc_getOption*() functions instead.
1132 void *
1133 smbc_option_get(SMBCCTX *context,
1134 char *option_name);
1136 /**@ingroup misc
1137 * Initialize a SBMCCTX (a context).
1139 * Must be called before using any SMBCCTX API function
1141 * @param context A pointer to a SMBCCTX obtained from smbc_new_context()
1143 * @return A pointer to the given SMBCCTX on success,
1144 * NULL on error with errno set:
1145 * - EBADF NULL context given
1146 * - ENOMEM Out of memory
1147 * - ENOENT The smb.conf file would not load
1149 * @see smbc_new_context()
1151 * @note my_context = smbc_init_context(smbc_new_context())
1152 * is perfectly safe, but it might leak memory on
1153 * smbc_context_init() failure. Avoid this.
1154 * You'll have to call smbc_free_context() yourself
1155 * on failure.
1158 SMBCCTX * smbc_init_context(SMBCCTX * context);
1160 /**@ingroup misc
1161 * Initialize the samba client library.
1163 * Must be called before using any of the smbclient API function
1165 * @param fn The function that will be called to obtaion
1166 * authentication credentials.
1168 * @param debug Allows caller to set the debug level. Can be
1169 * changed in smb.conf file. Allows caller to set
1170 * debugging if no smb.conf.
1172 * @return 0 on success, < 0 on error with errno set:
1173 * - ENOMEM Out of memory
1174 * - ENOENT The smb.conf file would not load
1178 int smbc_init(smbc_get_auth_data_fn fn, int debug);
1180 /**@ingroup misc
1181 * Set or retrieve the compatibility library's context pointer
1183 * @param context New context to use, or NULL. If a new context is provided,
1184 * it must have allocated with smbc_new_context() and
1185 * initialized with smbc_init_context(), followed, optionally,
1186 * by some manual changes to some of the non-internal fields.
1188 * @return The old context.
1190 * @see smbc_new_context(), smbc_init_context(), smbc_init()
1192 * @note This function may be called prior to smbc_init() to force
1193 * use of the next context without any internal calls to
1194 * smbc_new_context() or smbc_init_context(). It may also
1195 * be called after smbc_init() has already called those two
1196 * functions, to replace the existing context with a new one.
1197 * Care should be taken, in this latter case, to ensure that
1198 * the server cache and any data allocated by the
1199 * authentication functions have been freed, if necessary.
1202 SMBCCTX * smbc_set_context(SMBCCTX * new_context);
1204 /**@ingroup file
1205 * Open a file on an SMB server.
1207 * @param furl The smb url of the file to be opened.
1209 * @param flags Is one of O_RDONLY, O_WRONLY or O_RDWR which
1210 * request opening the file read-only,write-only
1211 * or read/write. flags may also be bitwise-or'd with
1212 * one or more of the following:
1213 * O_CREAT - If the file does not exist it will be
1214 * created.
1215 * O_EXCL - When used with O_CREAT, if the file
1216 * already exists it is an error and the open will
1217 * fail.
1218 * O_TRUNC - If the file already exists it will be
1219 * truncated.
1220 * O_APPEND The file is opened in append mode
1222 * @param mode mode specifies the permissions to use if a new
1223 * file is created. It is modified by the
1224 * process's umask in the usual way: the permissions
1225 * of the created file are (mode & ~umask)
1227 * Not currently use, but there for future use.
1228 * We will map this to SYSTEM, HIDDEN, etc bits
1229 * that reverses the mapping that smbc_fstat does.
1231 * @return Valid file handle, < 0 on error with errno set:
1232 * - ENOMEM Out of memory
1233 * - EINVAL if an invalid parameter passed, like no
1234 * file, or smbc_init not called.
1235 * - EEXIST pathname already exists and O_CREAT and
1236 * O_EXCL were used.
1237 * - EISDIR pathname refers to a directory and
1238 * the access requested involved writing.
1239 * - EACCES The requested access to the file is not
1240 * allowed
1241 * - ENODEV The requested share does not exist
1242 * - ENOTDIR A file on the path is not a directory
1243 * - ENOENT A directory component in pathname does
1244 * not exist.
1246 * @see smbc_creat()
1248 * @note This call uses an underlying routine that may create
1249 * a new connection to the server specified in the URL.
1250 * If the credentials supplied in the URL, or via the
1251 * auth_fn in the smbc_init call, fail, this call will
1252 * try again with an empty username and password. This
1253 * often gets mapped to the guest account on some machines.
1256 int smbc_open(const char *furl, int flags, mode_t mode);
1258 /**@ingroup file
1259 * Create a file on an SMB server.
1261 * Same as calling smbc_open() with flags = O_CREAT|O_WRONLY|O_TRUNC
1263 * @param furl The smb url of the file to be created
1265 * @param mode mode specifies the permissions to use if a new
1266 * file is created. It is modified by the
1267 * process's umask in the usual way: the permissions
1268 * of the created file are (mode & ~umask)
1270 * NOTE, the above is not true. We are dealing with
1271 * an SMB server, which has no concept of a umask!
1273 * @return Valid file handle, < 0 on error with errno set:
1274 * - ENOMEM Out of memory
1275 * - EINVAL if an invalid parameter passed, like no
1276 * file, or smbc_init not called.
1277 * - EEXIST pathname already exists and O_CREAT and
1278 * O_EXCL were used.
1279 * - EISDIR pathname refers to a directory and
1280 * the access requested involved writing.
1281 * - EACCES The requested access to the file is not
1282 * allowed
1283 * - ENOENT A directory component in pathname does
1284 * not exist.
1285 * - ENODEV The requested share does not exist.
1286 * @see smbc_open()
1290 int smbc_creat(const char *furl, mode_t mode);
1292 /**@ingroup file
1293 * Read from a file using an opened file handle.
1295 * @param fd Open file handle from smbc_open() or smbc_creat()
1297 * @param buf Pointer to buffer to receive read data
1299 * @param bufsize Size of buf in bytes
1301 * @return Number of bytes read;
1302 * 0 upon EOF;
1303 * < 0 on error, with errno set:
1304 * - EISDIR fd refers to a directory
1305 * - EBADF fd is not a valid file descriptor or
1306 * is not open for reading.
1307 * - EINVAL fd is attached to an object which is
1308 * unsuitable for reading, or no buffer passed or
1309 * smbc_init not called.
1311 * @see smbc_open(), smbc_write()
1314 ssize_t smbc_read(int fd, void *buf, size_t bufsize);
1317 /**@ingroup file
1318 * Write to a file using an opened file handle.
1320 * @param fd Open file handle from smbc_open() or smbc_creat()
1322 * @param buf Pointer to buffer to recieve read data
1324 * @param bufsize Size of buf in bytes
1326 * @return Number of bytes written, < 0 on error with errno set:
1327 * - EISDIR fd refers to a directory.
1328 * - EBADF fd is not a valid file descriptor or
1329 * is not open for reading.
1330 * - EINVAL fd is attached to an object which is
1331 * unsuitable for reading, or no buffer passed or
1332 * smbc_init not called.
1334 * @see smbc_open(), smbc_read()
1337 ssize_t smbc_write(int fd, const void *buf, size_t bufsize);
1340 /**@ingroup file
1341 * Seek to a specific location in a file.
1343 * @param fd Open file handle from smbc_open() or smbc_creat()
1345 * @param offset Offset in bytes from whence
1347 * @param whence A location in the file:
1348 * - SEEK_SET The offset is set to offset bytes from
1349 * the beginning of the file
1350 * - SEEK_CUR The offset is set to current location
1351 * plus offset bytes.
1352 * - SEEK_END The offset is set to the size of the
1353 * file plus offset bytes.
1355 * @return Upon successful completion, lseek returns the
1356 * resulting offset location as measured in bytes
1357 * from the beginning of the file. Otherwise, a value
1358 * of (off_t)-1 is returned and errno is set to
1359 * indicate the error:
1360 * - EBADF Fildes is not an open file descriptor.
1361 * - EINVAL Whence is not a proper value or smbc_init
1362 * not called.
1364 * @todo Are all the whence values really supported?
1366 * @todo Are errno values complete and correct?
1368 off_t smbc_lseek(int fd, off_t offset, int whence);
1371 /**@ingroup file
1372 * Close an open file handle.
1374 * @param fd The file handle to close
1376 * @return 0 on success, < 0 on error with errno set:
1377 * - EBADF fd isn't a valid open file descriptor
1378 * - EINVAL smbc_init() failed or has not been called
1380 * @see smbc_open(), smbc_creat()
1382 int smbc_close(int fd);
1385 /**@ingroup directory
1386 * Unlink (delete) a file or directory.
1388 * @param furl The smb url of the file to delete
1390 * @return 0 on success, < 0 on error with errno set:
1391 * - EACCES or EPERM Write access to the directory
1392 * containing pathname is not allowed or one
1393 * of the directories in pathname did not allow
1394 * search (execute) permission
1395 * - ENOENT A directory component in pathname does
1396 * not exist
1397 * - EINVAL NULL was passed in the file param or
1398 * smbc_init not called.
1399 * - EACCES You do not have access to the file
1400 * - ENOMEM Insufficient kernel memory was available
1402 * @see smbc_rmdir()s
1404 * @todo Are errno values complete and correct?
1406 int smbc_unlink(const char *furl);
1409 /**@ingroup directory
1410 * Rename or move a file or directory.
1412 * @param ourl The original smb url (source url) of file or
1413 * directory to be moved
1415 * @param nurl The new smb url (destination url) of the file
1416 * or directory after the move. Currently nurl must
1417 * be on the same share as ourl.
1419 * @return 0 on success, < 0 on error with errno set:
1420 * - EISDIR nurl is an existing directory, but ourl is
1421 * not a directory.
1422 * - EEXIST nurl is a non-empty directory,
1423 * i.e., contains entries other than "." and ".."
1424 * - EINVAL The new url contained a path prefix
1425 * of the old, or, more generally, an attempt was
1426 * made to make a directory a subdirectory of itself
1427 * or smbc_init not called.
1428 * - ENOTDIR A component used as a directory in ourl
1429 * or nurl path is not, in fact, a directory. Or,
1430 * ourl is a directory, and newpath exists but is not
1431 * a directory.
1432 * - EACCES or EPERM Write access to the directory
1433 * containing ourl or nurl is not allowed for the
1434 * process's effective uid, or one of the
1435 * directories in ourl or nurl did not allow search
1436 * (execute) permission, or ourl was a directory
1437 * and did not allow write permission.
1438 * - ENOENT A directory component in ourl or nurl
1439 * does not exist.
1440 * - EXDEV Rename across shares not supported.
1441 * - ENOMEM Insufficient kernel memory was available.
1442 * - EEXIST The target file, nurl, already exists.
1445 * @todo Are we going to support copying when urls are not on the same
1446 * share? I say no... NOTE. I agree for the moment.
1449 int smbc_rename(const char *ourl, const char *nurl);
1452 /**@ingroup directory
1453 * Open a directory used to obtain directory entries.
1455 * @param durl The smb url of the directory to open
1457 * @return Valid directory handle. < 0 on error with errno set:
1458 * - EACCES Permission denied.
1459 * - EINVAL A NULL file/URL was passed, or the URL would
1460 * not parse, or was of incorrect form or smbc_init not
1461 * called.
1462 * - ENOENT durl does not exist, or name is an
1463 * - ENOMEM Insufficient memory to complete the
1464 * operation.
1465 * - ENOTDIR name is not a directory.
1466 * - EPERM the workgroup could not be found.
1467 * - ENODEV the workgroup or server could not be found.
1469 * @see smbc_getdents(), smbc_readdir(), smbc_closedir()
1472 int smbc_opendir(const char *durl);
1475 /**@ingroup directory
1476 * Close a directory handle opened by smbc_opendir().
1478 * @param dh Directory handle to close
1480 * @return 0 on success, < 0 on error with errno set:
1481 * - EBADF dh is an invalid directory handle
1483 * @see smbc_opendir()
1485 int smbc_closedir(int dh);
1488 /**@ingroup directory
1489 * Get multiple directory entries.
1491 * smbc_getdents() reads as many dirent structures from the an open
1492 * directory handle into a specified memory area as will fit.
1494 * @param dh Valid directory as returned by smbc_opendir()
1496 * @param dirp pointer to buffer that will receive the directory
1497 * entries.
1499 * @param count The size of the dirp buffer in bytes
1501 * @returns If any dirents returned, return will indicate the
1502 * total size. If there were no more dirents available,
1503 * 0 is returned. < 0 indicates an error.
1504 * - EBADF Invalid directory handle
1505 * - EINVAL Result buffer is too small or smbc_init
1506 * not called.
1507 * - ENOENT No such directory.
1508 * @see , smbc_dirent, smbc_readdir(), smbc_open()
1510 * @todo Are errno values complete and correct?
1512 * @todo Add example code so people know how to parse buffers.
1514 int smbc_getdents(unsigned int dh, struct smbc_dirent *dirp, int count);
1517 /**@ingroup directory
1518 * Get a single directory entry.
1520 * @param dh Valid directory as returned by smbc_opendir()
1522 * @return A pointer to a smbc_dirent structure, or NULL if an
1523 * error occurs or end-of-directory is reached:
1524 * - EBADF Invalid directory handle
1525 * - EINVAL smbc_init() failed or has not been called
1527 * @see smbc_dirent, smbc_getdents(), smbc_open()
1529 struct smbc_dirent* smbc_readdir(unsigned int dh);
1532 /**@ingroup directory
1533 * Get the current directory offset.
1535 * smbc_telldir() may be used in conjunction with smbc_readdir() and
1536 * smbc_lseekdir().
1538 * @param dh Valid directory as returned by smbc_opendir()
1540 * @return The current location in the directory stream or -1
1541 * if an error occur. The current location is not
1542 * an offset. Becuase of the implementation, it is a
1543 * handle that allows the library to find the entry
1544 * later.
1545 * - EBADF dh is not a valid directory handle
1546 * - EINVAL smbc_init() failed or has not been called
1547 * - ENOTDIR if dh is not a directory
1549 * @see smbc_readdir()
1552 off_t smbc_telldir(int dh);
1555 /**@ingroup directory
1556 * lseek on directories.
1558 * smbc_lseekdir() may be used in conjunction with smbc_readdir() and
1559 * smbc_telldir(). (rewind by smbc_lseekdir(fd, NULL))
1561 * @param fd Valid directory as returned by smbc_opendir()
1563 * @param offset The offset (as returned by smbc_telldir). Can be
1564 * NULL, in which case we will rewind
1566 * @return 0 on success, -1 on failure
1567 * - EBADF dh is not a valid directory handle
1568 * - ENOTDIR if dh is not a directory
1569 * - EINVAL offset did not refer to a valid dirent or
1570 * smbc_init not called.
1572 * @see smbc_telldir()
1575 * @todo In what does the reture and errno values mean?
1577 int smbc_lseekdir(int fd, off_t offset);
1579 /**@ingroup directory
1580 * Create a directory.
1582 * @param durl The url of the directory to create
1584 * @param mode Specifies the permissions to use. It is modified
1585 * by the process's umask in the usual way: the
1586 * permissions of the created file are (mode & ~umask).
1588 * @return 0 on success, < 0 on error with errno set:
1589 * - EEXIST directory url already exists
1590 * - EACCES The parent directory does not allow write
1591 * permission to the process, or one of the directories
1592 * - ENOENT A directory component in pathname does not
1593 * exist.
1594 * - EINVAL NULL durl passed or smbc_init not called.
1595 * - ENOMEM Insufficient memory was available.
1597 * @see smbc_rmdir()
1600 int smbc_mkdir(const char *durl, mode_t mode);
1603 /**@ingroup directory
1604 * Remove a directory.
1606 * @param durl The smb url of the directory to remove
1608 * @return 0 on success, < 0 on error with errno set:
1609 * - EACCES or EPERM Write access to the directory
1610 * containing pathname was not allowed.
1611 * - EINVAL durl is NULL or smbc_init not called.
1612 * - ENOENT A directory component in pathname does not
1613 * exist.
1614 * - ENOTEMPTY directory contains entries.
1615 * - ENOMEM Insufficient kernel memory was available.
1617 * @see smbc_mkdir(), smbc_unlink()
1619 * @todo Are errno values complete and correct?
1621 int smbc_rmdir(const char *durl);
1624 /**@ingroup attribute
1625 * Get information about a file or directory.
1627 * @param url The smb url to get information for
1629 * @param st pointer to a buffer that will be filled with
1630 * standard Unix struct stat information.
1632 * @return 0 on success, < 0 on error with errno set:
1633 * - ENOENT A component of the path file_name does not
1634 * exist.
1635 * - EINVAL a NULL url was passed or smbc_init not called.
1636 * - EACCES Permission denied.
1637 * - ENOMEM Out of memory
1638 * - ENOTDIR The target dir, url, is not a directory.
1640 * @see Unix stat()
1643 int smbc_stat(const char *url, struct stat *st);
1646 /**@ingroup attribute
1647 * Get file information via an file descriptor.
1649 * @param fd Open file handle from smbc_open() or smbc_creat()
1651 * @param st pointer to a buffer that will be filled with
1652 * standard Unix struct stat information.
1654 * @return 0 on success, < 0 on error with errno set:
1655 * - EBADF filedes is bad.
1656 * - EACCES Permission denied.
1657 * - EBADF fd is not a valid file descriptor
1658 * - EINVAL Problems occurred in the underlying routines
1659 * or smbc_init not called.
1660 * - ENOMEM Out of memory
1662 * @see smbc_stat(), Unix stat()
1665 int smbc_fstat(int fd, struct stat *st);
1668 /**@ingroup attribute
1669 * Get file system information for a specified path.
1671 * @param url The smb url to get information for
1673 * @param st pointer to a buffer that will be filled with
1674 * standard Unix struct statvfs information.
1676 * @return 0 on success, < 0 on error with errno set:
1677 * - EBADF filedes is bad.
1678 * - EACCES Permission denied.
1679 * - EBADF fd is not a valid file descriptor
1680 * - EINVAL Problems occurred in the underlying routines
1681 * or smbc_init not called.
1682 * - ENOMEM Out of memory
1684 * @see Unix fstatvfs()
1688 smbc_statvfs(char *url,
1689 struct statvfs *st);
1691 /**@ingroup attribute
1692 * Get file system information via an file descriptor.
1694 * @param fd Open file handle from smbc_open(), smbc_creat(),
1695 * or smbc_opendir()
1697 * @param st pointer to a buffer that will be filled with
1698 * standard Unix struct statvfs information.
1700 * @return 0 on success, < 0 on error with errno set:
1701 * - EBADF filedes is bad.
1702 * - EACCES Permission denied.
1703 * - EBADF fd is not a valid file descriptor
1704 * - EINVAL Problems occurred in the underlying routines
1705 * or smbc_init not called.
1706 * - ENOMEM Out of memory
1708 * @see Unix fstatvfs()
1712 smbc_fstatvfs(int fd,
1713 struct statvfs *st);
1716 /**@ingroup attribute
1717 * Truncate a file given a file descriptor
1719 * @param fd Open file handle from smbc_open() or smbc_creat()
1721 * @param size size to truncate the file to
1723 * @return 0 on success, < 0 on error with errno set:
1724 * - EBADF filedes is bad.
1725 * - EACCES Permission denied.
1726 * - EBADF fd is not a valid file descriptor
1727 * - EINVAL Problems occurred in the underlying routines
1728 * or smbc_init not called.
1729 * - ENOMEM Out of memory
1731 * @see , Unix ftruncate()
1734 int smbc_ftruncate(int fd, off_t size);
1737 /**@ingroup attribute
1738 * Change the permissions of a file.
1740 * @param url The smb url of the file or directory to change
1741 * permissions of
1743 * @param mode The permissions to set:
1744 * - Put good explaination of permissions here!
1746 * @return 0 on success, < 0 on error with errno set:
1747 * - EPERM The effective UID does not match the owner
1748 * of the file, and is not zero
1749 * - ENOENT The file does not exist.
1750 * - ENOMEM Insufficient was available.
1751 * - ENOENT file or directory does not exist
1753 * @todo Actually implement this fuction?
1755 * @todo Are errno values complete and correct?
1757 int smbc_chmod(const char *url, mode_t mode);
1760 * @ingroup attribute
1761 * Change the last modification time on a file
1763 * @param url The smb url of the file or directory to change
1764 * the modification time of
1766 * @param tbuf An array of two timeval structures which contains,
1767 * respectively, the desired access and modification times.
1768 * NOTE: Only the tv_sec field off each timeval structure is
1769 * used. The tv_usec (microseconds) portion is ignored.
1771 * @return 0 on success, < 0 on error with errno set:
1772 * - EINVAL The client library is not properly initialized
1773 * - EPERM Permission was denied.
1776 int smbc_utimes(const char *url, struct timeval *tbuf);
1778 #ifdef HAVE_UTIME_H
1780 * @ingroup attribute
1781 * Change the last modification time on a file
1783 * @param url The smb url of the file or directory to change
1784 * the modification time of
1786 * @param utbuf A pointer to a utimebuf structure which contains the
1787 * desired access and modification times.
1789 * @return 0 on success, < 0 on error with errno set:
1790 * - EINVAL The client library is not properly initialized
1791 * - ENOMEM No memory was available for internal needs
1792 * - EPERM Permission was denied.
1795 int smbc_utime(const char *fname, struct utimbuf *utbuf);
1796 #endif
1798 /**@ingroup attribute
1799 * Set extended attributes for a file. This is used for modifying a file's
1800 * security descriptor (i.e. owner, group, and access control list)
1802 * @param url The smb url of the file or directory to set extended
1803 * attributes for.
1805 * @param name The name of an attribute to be changed. Names are of
1806 * one of the following forms:
1808 * system.nt_sec_desc.<attribute name>
1809 * system.nt_sec_desc.*
1810 * system.nt_sec_desc.*+
1812 * where <attribute name> is one of:
1814 * revision
1815 * owner
1816 * owner+
1817 * group
1818 * group+
1819 * acl:<name or sid>
1820 * acl+:<name or sid>
1822 * In the forms "system.nt_sec_desc.*" and
1823 * "system.nt_sec_desc.*+", the asterisk and plus signs are
1824 * literal, i.e. the string is provided exactly as shown, and
1825 * the value parameter should contain a complete security
1826 * descriptor with name:value pairs separated by tabs,
1827 * commas, or newlines (not spaces!).
1829 * The plus sign ('+') indicates that SIDs should be mapped
1830 * to names. Without the plus sign, SIDs are not mapped;
1831 * rather they are simply converted to a string format.
1833 * @param value The value to be assigned to the specified attribute name.
1834 * This buffer should contain only the attribute value if the
1835 * name was of the "system.nt_sec_desc.<attribute_name>"
1836 * form. If the name was of the "system.nt_sec_desc.*" form
1837 * then a complete security descriptor, with name:value pairs
1838 * separated by tabs, commas, or newlines (not spaces!),
1839 * should be provided in this value buffer. A complete
1840 * security descriptor will contain one or more entries
1841 * selected from the following:
1843 * REVISION:<revision number>
1844 * OWNER:<sid or name>
1845 * GROUP:<sid or name>
1846 * ACL:<sid or name>:<type>/<flags>/<mask>
1848 * The revision of the ACL specifies the internal Windows NT
1849 * ACL revision for the security descriptor. If not specified
1850 * it defaults to 1. Using values other than 1 may cause
1851 * strange behaviour.
1853 * The owner and group specify the owner and group sids for
1854 * the object. If the attribute name (either '*+' with a
1855 * complete security descriptor, or individual 'owner+' or
1856 * 'group+' attribute names) ended with a plus sign, the
1857 * specified name is resolved to a SID value, using the
1858 * server on which the file or directory resides. Otherwise,
1859 * the value should be provided in SID-printable format as
1860 * S-1-x-y-z, and is used directly. The <sid or name>
1861 * associated with the ACL: attribute should be provided
1862 * similarly.
1864 * @param size The number of the bytes of data in the value buffer
1866 * @param flags A bit-wise OR of zero or more of the following:
1867 * SMBC_XATTR_FLAG_CREATE -
1868 * fail if the named attribute already exists
1869 * SMBC_XATTR_FLAG_REPLACE -
1870 * fail if the attribute does not already exist
1872 * If neither flag is specified, the specified attributes
1873 * will be added or replace existing attributes of the same
1874 * name, as necessary.
1876 * @return 0 on success, < 0 on error with errno set:
1877 * - EINVAL The client library is not properly initialized
1878 * or one of the parameters is not of a correct
1879 * form
1880 * - ENOMEM No memory was available for internal needs
1881 * - EEXIST If the attribute already exists and the flag
1882 * SMBC_XATTR_FLAG_CREAT was specified
1883 * - ENOATTR If the attribute does not exist and the flag
1884 * SMBC_XATTR_FLAG_REPLACE was specified
1885 * - EPERM Permission was denied.
1886 * - ENOTSUP The referenced file system does not support
1887 * extended attributes
1889 * @note Attribute names are compared in a case-insensitive
1890 * fashion. All of the following are equivalent, although
1891 * the all-lower-case name is the preferred format:
1892 * system.nt_sec_desc.owner
1893 * SYSTEM.NT_SEC_DESC.OWNER
1894 * sYsTeM.nt_sEc_desc.owNER
1897 int smbc_setxattr(const char *url,
1898 const char *name,
1899 const void *value,
1900 size_t size,
1901 int flags);
1904 /**@ingroup attribute
1905 * Set extended attributes for a file. This is used for modifying a file's
1906 * security descriptor (i.e. owner, group, and access control list). The
1907 * POSIX function which this maps to would act on a symbolic link rather than
1908 * acting on what the symbolic link points to, but with no symbolic links in
1909 * SMB file systems, this function is functionally identical to
1910 * smbc_setxattr().
1912 * @param url The smb url of the file or directory to set extended
1913 * attributes for.
1915 * @param name The name of an attribute to be changed. Names are of
1916 * one of the following forms:
1918 * system.nt_sec_desc.<attribute name>
1919 * system.nt_sec_desc.*
1920 * system.nt_sec_desc.*+
1922 * where <attribute name> is one of:
1924 * revision
1925 * owner
1926 * owner+
1927 * group
1928 * group+
1929 * acl:<name or sid>
1930 * acl+:<name or sid>
1932 * In the forms "system.nt_sec_desc.*" and
1933 * "system.nt_sec_desc.*+", the asterisk and plus signs are
1934 * literal, i.e. the string is provided exactly as shown, and
1935 * the value parameter should contain a complete security
1936 * descriptor with name:value pairs separated by tabs,
1937 * commas, or newlines (not spaces!).
1939 * The plus sign ('+') indicates that SIDs should be mapped
1940 * to names. Without the plus sign, SIDs are not mapped;
1941 * rather they are simply converted to a string format.
1943 * @param value The value to be assigned to the specified attribute name.
1944 * This buffer should contain only the attribute value if the
1945 * name was of the "system.nt_sec_desc.<attribute_name>"
1946 * form. If the name was of the "system.nt_sec_desc.*" form
1947 * then a complete security descriptor, with name:value pairs
1948 * separated by tabs, commas, or newlines (not spaces!),
1949 * should be provided in this value buffer. A complete
1950 * security descriptor will contain one or more entries
1951 * selected from the following:
1953 * REVISION:<revision number>
1954 * OWNER:<sid or name>
1955 * GROUP:<sid or name>
1956 * ACL:<sid or name>:<type>/<flags>/<mask>
1958 * The revision of the ACL specifies the internal Windows NT
1959 * ACL revision for the security descriptor. If not specified
1960 * it defaults to 1. Using values other than 1 may cause
1961 * strange behaviour.
1963 * The owner and group specify the owner and group sids for
1964 * the object. If the attribute name (either '*+' with a
1965 * complete security descriptor, or individual 'owner+' or
1966 * 'group+' attribute names) ended with a plus sign, the
1967 * specified name is resolved to a SID value, using the
1968 * server on which the file or directory resides. Otherwise,
1969 * the value should be provided in SID-printable format as
1970 * S-1-x-y-z, and is used directly. The <sid or name>
1971 * associated with the ACL: attribute should be provided
1972 * similarly.
1974 * @param size The number of the bytes of data in the value buffer
1976 * @param flags A bit-wise OR of zero or more of the following:
1977 * SMBC_XATTR_FLAG_CREATE -
1978 * fail if the named attribute already exists
1979 * SMBC_XATTR_FLAG_REPLACE -
1980 * fail if the attribute does not already exist
1982 * If neither flag is specified, the specified attributes
1983 * will be added or replace existing attributes of the same
1984 * name, as necessary.
1986 * @return 0 on success, < 0 on error with errno set:
1987 * - EINVAL The client library is not properly initialized
1988 * or one of the parameters is not of a correct
1989 * form
1990 * - ENOMEM No memory was available for internal needs
1991 * - EEXIST If the attribute already exists and the flag
1992 * SMBC_XATTR_FLAG_CREAT was specified
1993 * - ENOATTR If the attribute does not exist and the flag
1994 * SMBC_XATTR_FLAG_REPLACE was specified
1995 * - EPERM Permission was denied.
1996 * - ENOTSUP The referenced file system does not support
1997 * extended attributes
1999 * @note Attribute names are compared in a case-insensitive
2000 * fashion. All of the following are equivalent, although
2001 * the all-lower-case name is the preferred format:
2002 * system.nt_sec_desc.owner
2003 * SYSTEM.NT_SEC_DESC.OWNER
2004 * sYsTeM.nt_sEc_desc.owNER
2007 int smbc_lsetxattr(const char *url,
2008 const char *name,
2009 const void *value,
2010 size_t size,
2011 int flags);
2014 /**@ingroup attribute
2015 * Set extended attributes for a file. This is used for modifying a file's
2016 * security descriptor (i.e. owner, group, and access control list)
2018 * @param fd A file descriptor associated with an open file (as
2019 * previously returned by smbc_open(), to get extended
2020 * attributes for.
2022 * @param name The name of an attribute to be changed. Names are of
2023 * one of the following forms:
2025 * system.nt_sec_desc.<attribute name>
2026 * system.nt_sec_desc.*
2027 * system.nt_sec_desc.*+
2029 * where <attribute name> is one of:
2031 * revision
2032 * owner
2033 * owner+
2034 * group
2035 * group+
2036 * acl:<name or sid>
2037 * acl+:<name or sid>
2039 * In the forms "system.nt_sec_desc.*" and
2040 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2041 * literal, i.e. the string is provided exactly as shown, and
2042 * the value parameter should contain a complete security
2043 * descriptor with name:value pairs separated by tabs,
2044 * commas, or newlines (not spaces!).
2046 * The plus sign ('+') indicates that SIDs should be mapped
2047 * to names. Without the plus sign, SIDs are not mapped;
2048 * rather they are simply converted to a string format.
2050 * @param value The value to be assigned to the specified attribute name.
2051 * This buffer should contain only the attribute value if the
2052 * name was of the "system.nt_sec_desc.<attribute_name>"
2053 * form. If the name was of the "system.nt_sec_desc.*" form
2054 * then a complete security descriptor, with name:value pairs
2055 * separated by tabs, commas, or newlines (not spaces!),
2056 * should be provided in this value buffer. A complete
2057 * security descriptor will contain one or more entries
2058 * selected from the following:
2060 * REVISION:<revision number>
2061 * OWNER:<sid or name>
2062 * GROUP:<sid or name>
2063 * ACL:<sid or name>:<type>/<flags>/<mask>
2065 * The revision of the ACL specifies the internal Windows NT
2066 * ACL revision for the security descriptor. If not specified
2067 * it defaults to 1. Using values other than 1 may cause
2068 * strange behaviour.
2070 * The owner and group specify the owner and group sids for
2071 * the object. If the attribute name (either '*+' with a
2072 * complete security descriptor, or individual 'owner+' or
2073 * 'group+' attribute names) ended with a plus sign, the
2074 * specified name is resolved to a SID value, using the
2075 * server on which the file or directory resides. Otherwise,
2076 * the value should be provided in SID-printable format as
2077 * S-1-x-y-z, and is used directly. The <sid or name>
2078 * associated with the ACL: attribute should be provided
2079 * similarly.
2081 * @param size The number of the bytes of data in the value buffer
2083 * @param flags A bit-wise OR of zero or more of the following:
2084 * SMBC_XATTR_FLAG_CREATE -
2085 * fail if the named attribute already exists
2086 * SMBC_XATTR_FLAG_REPLACE -
2087 * fail if the attribute does not already exist
2089 * If neither flag is specified, the specified attributes
2090 * will be added or replace existing attributes of the same
2091 * name, as necessary.
2093 * @return 0 on success, < 0 on error with errno set:
2094 * - EINVAL The client library is not properly initialized
2095 * or one of the parameters is not of a correct
2096 * form
2097 * - ENOMEM No memory was available for internal needs
2098 * - EEXIST If the attribute already exists and the flag
2099 * SMBC_XATTR_FLAG_CREAT was specified
2100 * - ENOATTR If the attribute does not exist and the flag
2101 * SMBC_XATTR_FLAG_REPLACE was specified
2102 * - EPERM Permission was denied.
2103 * - ENOTSUP The referenced file system does not support
2104 * extended attributes
2106 * @note Attribute names are compared in a case-insensitive
2107 * fashion. All of the following are equivalent, although
2108 * the all-lower-case name is the preferred format:
2109 * system.nt_sec_desc.owner
2110 * SYSTEM.NT_SEC_DESC.OWNER
2111 * sYsTeM.nt_sEc_desc.owNER
2114 int smbc_fsetxattr(int fd,
2115 const char *name,
2116 const void *value,
2117 size_t size,
2118 int flags);
2121 /**@ingroup attribute
2122 * Get extended attributes for a file.
2124 * @param url The smb url of the file or directory to get extended
2125 * attributes for.
2127 * @param name The name of an attribute to be retrieved. Names are of
2128 * one of the following forms:
2130 * system.nt_sec_desc.<attribute name>
2131 * system.nt_sec_desc.*
2132 * system.nt_sec_desc.*+
2134 * where <attribute name> is one of:
2136 * revision
2137 * owner
2138 * owner+
2139 * group
2140 * group+
2141 * acl:<name or sid>
2142 * acl+:<name or sid>
2144 * In the forms "system.nt_sec_desc.*" and
2145 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2146 * literal, i.e. the string is provided exactly as shown, and
2147 * the value parameter will return a complete security
2148 * descriptor with name:value pairs separated by tabs,
2149 * commas, or newlines (not spaces!).
2151 * The plus sign ('+') indicates that SIDs should be mapped
2152 * to names. Without the plus sign, SIDs are not mapped;
2153 * rather they are simply converted to a string format.
2155 * @param value A pointer to a buffer in which the value of the specified
2156 * attribute will be placed (unless size is zero).
2158 * @param size The size of the buffer pointed to by value. This parameter
2159 * may also be zero, in which case the size of the buffer
2160 * required to hold the attribute value will be returned,
2161 * but nothing will be placed into the value buffer.
2163 * @return 0 on success, < 0 on error with errno set:
2164 * - EINVAL The client library is not properly initialized
2165 * or one of the parameters is not of a correct
2166 * form
2167 * - ENOMEM No memory was available for internal needs
2168 * - EEXIST If the attribute already exists and the flag
2169 * SMBC_XATTR_FLAG_CREAT was specified
2170 * - ENOATTR If the attribute does not exist and the flag
2171 * SMBC_XATTR_FLAG_REPLACE was specified
2172 * - EPERM Permission was denied.
2173 * - ENOTSUP The referenced file system does not support
2174 * extended attributes
2177 int smbc_getxattr(const char *url,
2178 const char *name,
2179 const void *value,
2180 size_t size);
2183 /**@ingroup attribute
2184 * Get extended attributes for a file. The POSIX function which this maps to
2185 * would act on a symbolic link rather than acting on what the symbolic link
2186 * points to, but with no symbolic links in SMB file systems, this function
2187 * is functionally identical to smbc_getxattr().
2189 * @param url The smb url of the file or directory to get extended
2190 * attributes for.
2192 * @param name The name of an attribute to be retrieved. Names are of
2193 * one of the following forms:
2195 * system.nt_sec_desc.<attribute name>
2196 * system.nt_sec_desc.*
2197 * system.nt_sec_desc.*+
2199 * where <attribute name> is one of:
2201 * revision
2202 * owner
2203 * owner+
2204 * group
2205 * group+
2206 * acl:<name or sid>
2207 * acl+:<name or sid>
2209 * In the forms "system.nt_sec_desc.*" and
2210 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2211 * literal, i.e. the string is provided exactly as shown, and
2212 * the value parameter will return a complete security
2213 * descriptor with name:value pairs separated by tabs,
2214 * commas, or newlines (not spaces!).
2216 * The plus sign ('+') indicates that SIDs should be mapped
2217 * to names. Without the plus sign, SIDs are not mapped;
2218 * rather they are simply converted to a string format.
2220 * @param value A pointer to a buffer in which the value of the specified
2221 * attribute will be placed (unless size is zero).
2223 * @param size The size of the buffer pointed to by value. This parameter
2224 * may also be zero, in which case the size of the buffer
2225 * required to hold the attribute value will be returned,
2226 * but nothing will be placed into the value buffer.
2228 * @return 0 on success, < 0 on error with errno set:
2229 * - EINVAL The client library is not properly initialized
2230 * or one of the parameters is not of a correct
2231 * form
2232 * - ENOMEM No memory was available for internal needs
2233 * - EEXIST If the attribute already exists and the flag
2234 * SMBC_XATTR_FLAG_CREAT was specified
2235 * - ENOATTR If the attribute does not exist and the flag
2236 * SMBC_XATTR_FLAG_REPLACE was specified
2237 * - EPERM Permission was denied.
2238 * - ENOTSUP The referenced file system does not support
2239 * extended attributes
2242 int smbc_lgetxattr(const char *url,
2243 const char *name,
2244 const void *value,
2245 size_t size);
2248 /**@ingroup attribute
2249 * Get extended attributes for a file.
2251 * @param fd A file descriptor associated with an open file (as
2252 * previously returned by smbc_open(), to get extended
2253 * attributes for.
2255 * @param name The name of an attribute to be retrieved. Names are of
2256 * one of the following forms:
2258 * system.nt_sec_desc.<attribute name>
2259 * system.nt_sec_desc.*
2260 * system.nt_sec_desc.*+
2262 * where <attribute name> is one of:
2264 * revision
2265 * owner
2266 * owner+
2267 * group
2268 * group+
2269 * acl:<name or sid>
2270 * acl+:<name or sid>
2272 * In the forms "system.nt_sec_desc.*" and
2273 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2274 * literal, i.e. the string is provided exactly as shown, and
2275 * the value parameter will return a complete security
2276 * descriptor with name:value pairs separated by tabs,
2277 * commas, or newlines (not spaces!).
2279 * The plus sign ('+') indicates that SIDs should be mapped
2280 * to names. Without the plus sign, SIDs are not mapped;
2281 * rather they are simply converted to a string format.
2283 * @param value A pointer to a buffer in which the value of the specified
2284 * attribute will be placed (unless size is zero).
2286 * @param size The size of the buffer pointed to by value. This parameter
2287 * may also be zero, in which case the size of the buffer
2288 * required to hold the attribute value will be returned,
2289 * but nothing will be placed into the value buffer.
2291 * @return 0 on success, < 0 on error with errno set:
2292 * - EINVAL The client library is not properly initialized
2293 * or one of the parameters is not of a correct
2294 * form
2295 * - ENOMEM No memory was available for internal needs
2296 * - EEXIST If the attribute already exists and the flag
2297 * SMBC_XATTR_FLAG_CREAT was specified
2298 * - ENOATTR If the attribute does not exist and the flag
2299 * SMBC_XATTR_FLAG_REPLACE was specified
2300 * - EPERM Permission was denied.
2301 * - ENOTSUP The referenced file system does not support
2302 * extended attributes
2305 int smbc_fgetxattr(int fd,
2306 const char *name,
2307 const void *value,
2308 size_t size);
2311 /**@ingroup attribute
2312 * Remove extended attributes for a file. This is used for modifying a file's
2313 * security descriptor (i.e. owner, group, and access control list)
2315 * @param url The smb url of the file or directory to remove the extended
2316 * attributes for.
2318 * @param name The name of an attribute to be removed. Names are of
2319 * one of the following forms:
2321 * system.nt_sec_desc.<attribute name>
2322 * system.nt_sec_desc.*
2323 * system.nt_sec_desc.*+
2325 * where <attribute name> is one of:
2327 * revision
2328 * owner
2329 * owner+
2330 * group
2331 * group+
2332 * acl:<name or sid>
2333 * acl+:<name or sid>
2335 * In the forms "system.nt_sec_desc.*" and
2336 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2337 * literal, i.e. the string is provided exactly as shown, and
2338 * the value parameter will return a complete security
2339 * descriptor with name:value pairs separated by tabs,
2340 * commas, or newlines (not spaces!).
2342 * The plus sign ('+') indicates that SIDs should be mapped
2343 * to names. Without the plus sign, SIDs are not mapped;
2344 * rather they are simply converted to a string format.
2346 * @return 0 on success, < 0 on error with errno set:
2347 * - EINVAL The client library is not properly initialized
2348 * - ENOMEM No memory was available for internal needs
2349 * - EPERM Permission was denied.
2350 * - ENOTSUP The referenced file system does not support
2351 * extended attributes
2354 int smbc_removexattr(const char *url,
2355 const char *name);
2358 /**@ingroup attribute
2359 * Remove extended attributes for a file. This is used for modifying a file's
2360 * security descriptor (i.e. owner, group, and access control list) The POSIX
2361 * function which this maps to would act on a symbolic link rather than acting
2362 * on what the symbolic link points to, but with no symbolic links in SMB file
2363 * systems, this function is functionally identical to smbc_removexattr().
2365 * @param url The smb url of the file or directory to remove the extended
2366 * attributes for.
2368 * @param name The name of an attribute to be removed. Names are of
2369 * one of the following forms:
2371 * system.nt_sec_desc.<attribute name>
2372 * system.nt_sec_desc.*
2373 * system.nt_sec_desc.*+
2375 * where <attribute name> is one of:
2377 * revision
2378 * owner
2379 * owner+
2380 * group
2381 * group+
2382 * acl:<name or sid>
2383 * acl+:<name or sid>
2385 * In the forms "system.nt_sec_desc.*" and
2386 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2387 * literal, i.e. the string is provided exactly as shown, and
2388 * the value parameter will return a complete security
2389 * descriptor with name:value pairs separated by tabs,
2390 * commas, or newlines (not spaces!).
2392 * The plus sign ('+') indicates that SIDs should be mapped
2393 * to names. Without the plus sign, SIDs are not mapped;
2394 * rather they are simply converted to a string format.
2396 * @return 0 on success, < 0 on error with errno set:
2397 * - EINVAL The client library is not properly initialized
2398 * - ENOMEM No memory was available for internal needs
2399 * - EPERM Permission was denied.
2400 * - ENOTSUP The referenced file system does not support
2401 * extended attributes
2404 int smbc_lremovexattr(const char *url,
2405 const char *name);
2408 /**@ingroup attribute
2409 * Remove extended attributes for a file. This is used for modifying a file's
2410 * security descriptor (i.e. owner, group, and access control list)
2412 * @param fd A file descriptor associated with an open file (as
2413 * previously returned by smbc_open(), to get extended
2414 * attributes for.
2416 * @param name The name of an attribute to be removed. Names are of
2417 * one of the following forms:
2419 * system.nt_sec_desc.<attribute name>
2420 * system.nt_sec_desc.*
2421 * system.nt_sec_desc.*+
2423 * where <attribute name> is one of:
2425 * revision
2426 * owner
2427 * owner+
2428 * group
2429 * group+
2430 * acl:<name or sid>
2431 * acl+:<name or sid>
2433 * In the forms "system.nt_sec_desc.*" and
2434 * "system.nt_sec_desc.*+", the asterisk and plus signs are
2435 * literal, i.e. the string is provided exactly as shown, and
2436 * the value parameter will return a complete security
2437 * descriptor with name:value pairs separated by tabs,
2438 * commas, or newlines (not spaces!).
2440 * The plus sign ('+') indicates that SIDs should be mapped
2441 * to names. Without the plus sign, SIDs are not mapped;
2442 * rather they are simply converted to a string format.
2444 * @return 0 on success, < 0 on error with errno set:
2445 * - EINVAL The client library is not properly initialized
2446 * - ENOMEM No memory was available for internal needs
2447 * - EPERM Permission was denied.
2448 * - ENOTSUP The referenced file system does not support
2449 * extended attributes
2452 int smbc_fremovexattr(int fd,
2453 const char *name);
2456 /**@ingroup attribute
2457 * List the supported extended attribute names associated with a file
2459 * @param url The smb url of the file or directory to list the extended
2460 * attributes for.
2462 * @param list A pointer to a buffer in which the list of attributes for
2463 * the specified file or directory will be placed (unless
2464 * size is zero).
2466 * @param size The size of the buffer pointed to by list. This parameter
2467 * may also be zero, in which case the size of the buffer
2468 * required to hold all of the attribute names will be
2469 * returned, but nothing will be placed into the list buffer.
2471 * @return 0 on success, < 0 on error with errno set:
2472 * - EINVAL The client library is not properly initialized
2473 * - ENOMEM No memory was available for internal needs
2474 * - EPERM Permission was denied.
2475 * - ENOTSUP The referenced file system does not support
2476 * extended attributes
2478 * @note This function always returns all attribute names supported
2479 * by NT file systems, regardless of whether the referenced
2480 * file system supports extended attributes (e.g. a Windows
2481 * 2000 machine supports extended attributes if NTFS is used,
2482 * but not if FAT is used, and Windows 98 doesn't support
2483 * extended attributes at all. Whether this is a feature or
2484 * a bug is yet to be decided.
2486 int smbc_listxattr(const char *url,
2487 char *list,
2488 size_t size);
2490 /**@ingroup attribute
2491 * List the supported extended attribute names associated with a file The
2492 * POSIX function which this maps to would act on a symbolic link rather than
2493 * acting on what the symbolic link points to, but with no symbolic links in
2494 * SMB file systems, this function is functionally identical to
2495 * smbc_listxattr().
2497 * @param url The smb url of the file or directory to list the extended
2498 * attributes for.
2500 * @param list A pointer to a buffer in which the list of attributes for
2501 * the specified file or directory will be placed (unless
2502 * size is zero).
2504 * @param size The size of the buffer pointed to by list. This parameter
2505 * may also be zero, in which case the size of the buffer
2506 * required to hold all of the attribute names will be
2507 * returned, but nothing will be placed into the list buffer.
2509 * @return 0 on success, < 0 on error with errno set:
2510 * - EINVAL The client library is not properly initialized
2511 * - ENOMEM No memory was available for internal needs
2512 * - EPERM Permission was denied.
2513 * - ENOTSUP The referenced file system does not support
2514 * extended attributes
2516 * @note This function always returns all attribute names supported
2517 * by NT file systems, regardless of wether the referenced
2518 * file system supports extended attributes (e.g. a Windows
2519 * 2000 machine supports extended attributes if NTFS is used,
2520 * but not if FAT is used, and Windows 98 doesn't support
2521 * extended attributes at all. Whether this is a feature or
2522 * a bug is yet to be decided.
2524 int smbc_llistxattr(const char *url,
2525 char *list,
2526 size_t size);
2528 /**@ingroup attribute
2529 * List the supported extended attribute names associated with a file
2531 * @param fd A file descriptor associated with an open file (as
2532 * previously returned by smbc_open(), to get extended
2533 * attributes for.
2535 * @param list A pointer to a buffer in which the list of attributes for
2536 * the specified file or directory will be placed (unless
2537 * size is zero).
2539 * @param size The size of the buffer pointed to by list. This parameter
2540 * may also be zero, in which case the size of the buffer
2541 * required to hold all of the attribute names will be
2542 * returned, but nothing will be placed into the list buffer.
2544 * @return 0 on success, < 0 on error with errno set:
2545 * - EINVAL The client library is not properly initialized
2546 * - ENOMEM No memory was available for internal needs
2547 * - EPERM Permission was denied.
2548 * - ENOTSUP The referenced file system does not support
2549 * extended attributes
2551 * @note This function always returns all attribute names supported
2552 * by NT file systems, regardless of wether the referenced
2553 * file system supports extended attributes (e.g. a Windows
2554 * 2000 machine supports extended attributes if NTFS is used,
2555 * but not if FAT is used, and Windows 98 doesn't support
2556 * extended attributes at all. Whether this is a feature or
2557 * a bug is yet to be decided.
2559 int smbc_flistxattr(int fd,
2560 char *list,
2561 size_t size);
2563 /**@ingroup print
2564 * Print a file given the name in fname. It would be a URL ...
2566 * @param fname The URL of a file on a remote SMB server that the
2567 * caller wants printed
2569 * @param printq The URL of the print share to print the file to.
2571 * @return 0 on success, < 0 on error with errno set:
2573 * - EINVAL fname or printq was NULL or smbc_init not
2574 * not called.
2575 * and errors returned by smbc_open
2578 int smbc_print_file(const char *fname, const char *printq);
2580 /**@ingroup print
2581 * Open a print file that can be written to by other calls. This simply
2582 * does an smbc_open call after checking if there is a file name on the
2583 * URI. If not, a temporary name is added ...
2585 * @param fname The URL of the print share to print to?
2587 * @returns A file handle for the print file if successful.
2588 * Returns -1 if an error ocurred and errno has the values
2589 * - EINVAL fname was NULL or smbc_init not called.
2590 * - all errors returned by smbc_open
2593 int smbc_open_print_job(const char *fname);
2595 /**@ingroup print
2596 * List the print jobs on a print share, for the moment, pass a callback
2598 * @param purl The url of the print share to list the jobs of
2600 * @param fn Callback function the receives printjob info
2602 * @return 0 on success, < 0 on error with errno set:
2603 * - EINVAL fname was NULL or smbc_init not called
2604 * - EACCES ???
2606 int smbc_list_print_jobs(const char *purl, smbc_list_print_job_fn fn);
2608 /**@ingroup print
2609 * Delete a print job
2611 * @param purl Url of the print share
2613 * @param id The id of the job to delete
2615 * @return 0 on success, < 0 on error with errno set:
2616 * - EINVAL fname was NULL or smbc_init not called
2618 * @todo what errno values are possible here?
2620 int smbc_unlink_print_job(const char *purl, int id);
2622 /**@ingroup callback
2623 * Remove a server from the cached server list it's unused.
2625 * @param context pointer to smb context
2627 * @param srv pointer to server to remove
2629 * @return On success, 0 is returned. 1 is returned if the server could not
2630 * be removed. Also useable outside libsmbclient.
2632 int smbc_remove_unused_server(SMBCCTX * context, SMBCSRV * srv);
2634 #ifdef __cplusplus
2636 #endif
2638 /**@ingroup directory
2639 * Convert strings of %xx to their single character equivalent.
2641 * @param dest A pointer to a buffer in which the resulting decoded
2642 * string should be placed. This may be a pointer to the
2643 * same buffer as src_segment.
2645 * @param src A pointer to the buffer containing the URL to be decoded.
2646 * Any %xx sequences herein are converted to their single
2647 * character equivalent. Each 'x' must be a valid hexadecimal
2648 * digit, or that % sequence is left undecoded.
2650 * @param max_dest_len
2651 * The size of the buffer pointed to by dest_segment.
2653 * @return The number of % sequences which could not be converted
2654 * due to lack of two following hexadecimal digits.
2656 #ifdef __cplusplus
2657 extern "C" {
2658 #endif
2660 smbc_urldecode(char *dest, char * src, size_t max_dest_len);
2661 #ifdef __cplusplus
2663 #endif
2667 * Convert any characters not specifically allowed in a URL into their %xx
2668 * equivalent.
2670 * @param dest A pointer to a buffer in which the resulting encoded
2671 * string should be placed. Unlike smbc_urldecode(), this
2672 * must be a buffer unique from src.
2674 * @param src A pointer to the buffer containing the string to be encoded.
2675 * Any character not specifically allowed in a URL is converted
2676 * into its hexadecimal value and encoded as %xx.
2678 * @param max_dest_len
2679 * The size of the buffer pointed to by dest_segment.
2681 * @returns The remaining buffer length.
2683 #ifdef __cplusplus
2684 extern "C" {
2685 #endif
2687 smbc_urlencode(char * dest, char * src, int max_dest_len);
2688 #ifdef __cplusplus
2690 #endif
2693 /**@ingroup directory
2694 * Return the version of the linked Samba code, and thus the version of the
2695 * libsmbclient code.
2697 * @return The version string.
2699 #ifdef __cplusplus
2700 extern "C" {
2701 #endif
2702 const char *
2703 smbc_version(void);
2704 #ifdef __cplusplus
2706 #endif
2708 /**@ingroup misc
2709 * Set the users credentials globally so they can be used for DFS
2710 * referrals. Probably best to use this function in the smbc_get_auth_data_fn
2711 * callback.
2713 * @param workgroup Workgroup of the user.
2715 * @param user Username of user.
2717 * @param password Password of user.
2719 * @param use_kerberos Whether to use Kerberos
2721 * @param signing_state One of these strings (all equivalents on same line):
2722 * "off", "no", "false"
2723 * "on", "yes", "true", "auto"
2724 * "force", "required", "forced"
2727 void
2728 smbc_set_credentials(const char *workgroup,
2729 const char *user,
2730 const char *password,
2731 smbc_bool use_kerberos,
2732 const char *signing_state);
2735 * Wrapper around smbc_set_credentials.
2736 * Used to set correct credentials that will
2737 * be used to connect to DFS target share
2738 * in libsmbclient
2741 void
2742 smbc_set_credentials_with_fallback(SMBCCTX *ctx,
2743 const char *workgroup,
2744 const char *user,
2745 const char *password);
2749 * @ingroup threads
2751 * Initialize for threads using the Posix Threads (pthread)
2752 * implementation. This is a built-in implementation, avoiding the need to
2753 * implement the component functions of the thread interface. If this function
2754 * is used, it is not necessary to call smbc_thread_impl().
2756 * @return {void}
2758 void
2759 smbc_thread_posix(void);
2762 * @ingroup threads
2764 * Initialize for an arbitrary thread implementation. The caller should
2765 * provide, as parameters, pointers to functions to implement the requisite
2766 * low-level thread functionality. A function must be provided for each
2767 * parameter; none may be null.
2769 * If the thread implementation is POSIX Threads (pthreads), then the much
2770 * simpler smbc_thread_pthread() function may be used instead of this one.
2772 * @param create_mutex
2773 * Create a mutex. This function should expect three parameters: lockname,
2774 * pplock, and location. It should create a unique mutex for each unique
2775 * lockname it is provided, and return the mutex identifier in *pplock. The
2776 * location parameter can be used for debugging, as it contains the
2777 * compiler-provided __location__ of the call.
2779 * @param destroy_mutex
2780 * Destroy a mutex. This function should expect two parameters: plock and
2781 * location. It should destroy the mutex associated with the identifier
2782 * plock. The location parameter can be used for debugging, as it contains
2783 * the compiler-provided __location__ of the call.
2785 * @param lock_mutex
2786 * Lock a mutex. This function should expect three parameters: plock,
2787 * lock_type, and location. The mutex aassociated with identifier plock
2788 * should be locked if lock_type is 1, and unlocked if lock_type is 2. The
2789 * location parameter can be used for debugging, as it contains the
2790 * compiler-provided __location__ of the call.
2792 * @param create_tls
2793 * Create thread local storage. This function should expect three
2794 * parameters: keyname, ppkey, and location. It should allocate an
2795 * implementation-specific amount of memory and assign the pointer to that
2796 * allocated memory to *ppkey. The location parameter can be used for
2797 * debugging, as it contains the compiler-provided __location__ of the
2798 * call. This function should return 0 upon success, non-zero upon failure.
2800 * @param destroy_tls
2801 * Destroy thread local storage. This function should expect two parameters:
2802 * ppkey and location. The ppkey parameter points to a variable containing a
2803 * thread local storage key previously provided by the create_tls
2804 * function. The location parameter can be used for debugging, as it
2805 * contains the compiler-provided __location__ of the call.
2807 * @param set_tls
2808 * Set a thread local storage variable's value. This function should expect
2809 * three parameters: pkey, pval, and location. The pkey parameter is a
2810 * thread local storage key previously provided by the create_tls
2811 * function. The (void *) pval parameter contains the value to be placed in
2812 * the thread local storage variable identified by pkey. The location
2813 * parameter can be used for debugging, as it contains the compiler-provided
2814 * __location__ of the call. This function should return 0 upon success;
2815 * non-zero otherwise.
2817 * @param get_tls
2818 * Retrieve a thread local storage variable's value. This function should
2819 * expect two parameters: pkey and location. The pkey parameter is a thread
2820 * local storage key previously provided by the create_tls function, and
2821 * which has previously been used in a call to the set_tls function to
2822 * initialize a thread local storage variable. The location parameter can be
2823 * used for debugging, as it contains the compiler-provided __location__ of
2824 * the call. This function should return the (void *) value stored in the
2825 * variable identified by pkey.
2827 * @return {void}
2829 void
2830 smbc_thread_impl(
2831 /* Mutex functions. */
2832 int (*create_mutex)(const char *lockname,
2833 void **pplock,
2834 const char *location),
2835 void (*destroy_mutex)(void *plock,
2836 const char *location),
2837 int (*lock_mutex)(void *plock,
2838 int lock_type,
2839 const char *location),
2841 /* Thread local storage. */
2842 int (*create_tls)(const char *keyname,
2843 void **ppkey,
2844 const char *location),
2845 void (*destroy_tls)(void **ppkey,
2846 const char *location),
2847 int (*set_tls)(void *pkey,
2848 const void *pval,
2849 const char *location),
2850 void *(*get_tls)(void *pkey,
2851 const char *location)
2857 * @ingroup structure
2858 * Structure that contains a client context information
2859 * This structure is known as SMBCCTX
2861 * DO NOT DIRECTLY MANIPULATE THE CONTEXT STRUCTURE! The data in the context
2862 * structure should all be considered private to the library. It remains here
2863 * only for backward compatibility.
2865 * See the comments herein for use of the setter and getter functions which
2866 * should now be used for manipulating these values. New features, functions,
2867 * etc., are not added here but rather in _internal where they are not
2868 * directly visible to applications. This makes it much easier to maintain
2869 * ABI compatibility.
2871 struct _SMBCCTX
2874 * debug level
2876 * DEPRECATED:
2877 * Use smbc_getDebug() and smbc_setDebug()
2879 int debug DEPRECATED_SMBC_INTERFACE;
2882 * netbios name used for making connections
2884 * DEPRECATED:
2885 * Use smbc_getNetbiosName() and smbc_setNetbiosName()
2887 char * netbios_name DEPRECATED_SMBC_INTERFACE;
2890 * workgroup name used for making connections
2892 * DEPRECATED:
2893 * Use smbc_getWorkgroup() and smbc_setWorkgroup()
2895 char * workgroup DEPRECATED_SMBC_INTERFACE;
2898 * username used for making connections
2900 * DEPRECATED:
2901 * Use smbc_getUser() and smbc_setUser()
2903 char * user DEPRECATED_SMBC_INTERFACE;
2906 * timeout used for waiting on connections / response data (in
2907 * milliseconds)
2909 * DEPRECATED:
2910 * Use smbc_getTimeout() and smbc_setTimeout()
2912 int timeout DEPRECATED_SMBC_INTERFACE;
2915 * callable functions for files:
2916 * For usage and return values see the SMBC_* functions
2918 * DEPRECATED:
2920 * Use smbc_getFunction*() and smbc_setFunction*(), e.g.
2921 * smbc_getFunctionOpen(), smbc_setFunctionUnlink(), etc.
2923 smbc_open_fn open DEPRECATED_SMBC_INTERFACE;
2924 smbc_creat_fn creat DEPRECATED_SMBC_INTERFACE;
2925 smbc_read_fn read DEPRECATED_SMBC_INTERFACE;
2926 smbc_write_fn write DEPRECATED_SMBC_INTERFACE;
2927 smbc_unlink_fn unlink DEPRECATED_SMBC_INTERFACE;
2928 smbc_rename_fn rename DEPRECATED_SMBC_INTERFACE;
2929 smbc_lseek_fn lseek DEPRECATED_SMBC_INTERFACE;
2930 smbc_stat_fn stat DEPRECATED_SMBC_INTERFACE;
2931 smbc_fstat_fn fstat DEPRECATED_SMBC_INTERFACE;
2932 #if 0 /* internal */
2933 smbc_ftruncate_fn ftruncate_fn;
2934 #endif
2935 smbc_close_fn close_fn DEPRECATED_SMBC_INTERFACE;
2936 smbc_opendir_fn opendir DEPRECATED_SMBC_INTERFACE;
2937 smbc_closedir_fn closedir DEPRECATED_SMBC_INTERFACE;
2938 smbc_readdir_fn readdir DEPRECATED_SMBC_INTERFACE;
2939 smbc_getdents_fn getdents DEPRECATED_SMBC_INTERFACE;
2940 smbc_mkdir_fn mkdir DEPRECATED_SMBC_INTERFACE;
2941 smbc_rmdir_fn rmdir DEPRECATED_SMBC_INTERFACE;
2942 smbc_telldir_fn telldir DEPRECATED_SMBC_INTERFACE;
2943 smbc_lseekdir_fn lseekdir DEPRECATED_SMBC_INTERFACE;
2944 smbc_fstatdir_fn fstatdir DEPRECATED_SMBC_INTERFACE;
2945 smbc_chmod_fn chmod DEPRECATED_SMBC_INTERFACE;
2946 smbc_utimes_fn utimes DEPRECATED_SMBC_INTERFACE;
2947 smbc_setxattr_fn setxattr DEPRECATED_SMBC_INTERFACE;
2948 smbc_getxattr_fn getxattr DEPRECATED_SMBC_INTERFACE;
2949 smbc_removexattr_fn removexattr DEPRECATED_SMBC_INTERFACE;
2950 smbc_listxattr_fn listxattr DEPRECATED_SMBC_INTERFACE;
2952 /* Printing-related functions */
2953 smbc_print_file_fn print_file DEPRECATED_SMBC_INTERFACE;
2954 smbc_open_print_job_fn open_print_job DEPRECATED_SMBC_INTERFACE;
2955 smbc_list_print_jobs_fn list_print_jobs DEPRECATED_SMBC_INTERFACE;
2956 smbc_unlink_print_job_fn unlink_print_job DEPRECATED_SMBC_INTERFACE;
2959 ** Callbacks
2961 * DEPRECATED:
2963 * See the comment above each field, for the getter and setter
2964 * functions that should now be used.
2966 struct _smbc_callbacks
2969 * authentication function callback: called upon auth requests
2971 * DEPRECATED:
2972 * Use smbc_getFunctionAuthData(), smbc_setFunctionAuthData()
2974 smbc_get_auth_data_fn auth_fn DEPRECATED_SMBC_INTERFACE;
2977 * check if a server is still good
2979 * DEPRECATED:
2980 * Use smbc_getFunctionCheckServer(),
2981 * smbc_setFunctionCheckServer()
2983 smbc_check_server_fn check_server_fn DEPRECATED_SMBC_INTERFACE;
2986 * remove a server if unused
2988 * DEPRECATED:
2989 * Use smbc_getFunctionRemoveUnusedServer(),
2990 * smbc_setFunctionCheckServer()
2992 smbc_remove_unused_server_fn remove_unused_server_fn DEPRECATED_SMBC_INTERFACE;
2994 /** Cache subsystem
2996 * For an example cache system see
2997 * samba/source/libsmb/libsmb_cache.c
2999 * Cache subsystem * functions follow.
3003 * server cache addition
3005 * DEPRECATED:
3006 * Use smbc_getFunctionAddCachedServer(),
3007 * smbc_setFunctionAddCachedServer()
3009 smbc_add_cached_srv_fn add_cached_srv_fn DEPRECATED_SMBC_INTERFACE;
3012 * server cache lookup
3014 * DEPRECATED:
3015 * Use smbc_getFunctionGetCachedServer(),
3016 * smbc_setFunctionGetCachedServer()
3018 smbc_get_cached_srv_fn get_cached_srv_fn DEPRECATED_SMBC_INTERFACE;
3021 * server cache removal
3023 * DEPRECATED:
3024 * Use smbc_getFunctionRemoveCachedServer(),
3025 * smbc_setFunctionRemoveCachedServer()
3027 smbc_remove_cached_srv_fn remove_cached_srv_fn DEPRECATED_SMBC_INTERFACE;
3030 * server cache purging, try to remove all cached servers
3031 * (disconnect)
3033 * DEPRECATED:
3034 * Use smbc_getFunctionPurgeCachedServers(),
3035 * smbc_setFunctionPurgeCachedServers()
3037 smbc_purge_cached_fn purge_cached_fn DEPRECATED_SMBC_INTERFACE;
3038 } callbacks;
3041 * Space where the private data of the server cache used to be
3043 * DEPRECATED:
3044 * Use smbc_getServerCacheData(), smbc_setServerCacheData()
3046 void * reserved DEPRECATED_SMBC_INTERFACE;
3049 * Very old configuration options.
3051 * DEPRECATED:
3052 * Use one of the following functions instead:
3053 * smbc_setOptionUseKerberos()
3054 * smbc_getOptionUseKerberos()
3055 * smbc_setOptionFallbackAfterKerberos()
3056 * smbc_getOptionFallbackAfterKerberos()
3057 * smbc_setOptionNoAutoAnonymousLogin()
3058 * smbc_getOptionNoAutoAnonymousLogin()
3060 int flags DEPRECATED_SMBC_INTERFACE;
3063 * user options selections that apply to this session
3065 * NEW OPTIONS ARE NOT ADDED HERE!
3067 * DEPRECATED:
3068 * To set and retrieve options, use the smbc_setOption*() and
3069 * smbc_getOption*() functions.
3071 struct _smbc_options {
3072 int browse_max_lmb_count DEPRECATED_SMBC_INTERFACE;
3073 int urlencode_readdir_entries DEPRECATED_SMBC_INTERFACE;
3074 int one_share_per_server DEPRECATED_SMBC_INTERFACE;
3075 } options DEPRECATED_SMBC_INTERFACE;
3077 /** INTERNAL DATA
3078 * do _NOT_ touch this from your program !
3080 struct SMBC_internal_data * internal;
3084 #endif /* SMBCLIENT_H_INCLUDED */