#include <sys/statvfs.h>
#include <stdint.h>
#include <fcntl.h>
+#include <time.h>
#include <utime.h>
#define SMBC_BASE_FD 10000 /* smallest file descriptor returned */
*/
typedef enum smbc_smb_encrypt_level
{
+ SMBC_ENCRYPTLEVEL_DEFAULT = -1,
SMBC_ENCRYPTLEVEL_NONE = 0,
SMBC_ENCRYPTLEVEL_REQUEST = 1,
SMBC_ENCRYPTLEVEL_REQUIRE = 2
const char * username);
/**@ingroup callback
- * Check if a server is still good
+ * Remove a cached server
*
* @param c pointer to smb context
*
smbc_setConfiguration(SMBCCTX *c, const char *file);
/** Get the netbios name used for making connections */
-char *
+const char *
smbc_getNetbiosName(SMBCCTX *c);
/** Set the netbios name used for making connections */
void
-smbc_setNetbiosName(SMBCCTX *c, char * netbios_name);
+smbc_setNetbiosName(SMBCCTX *c, const char *netbios_name);
/** Get the workgroup used for making connections */
-char *
+const char *
smbc_getWorkgroup(SMBCCTX *c);
/** Set the workgroup used for making connections */
-void smbc_setWorkgroup(SMBCCTX *c, char * workgroup);
+void smbc_setWorkgroup(SMBCCTX *c, const char *workgroup);
/** Get the username used for making connections */
-char *
+const char *
smbc_getUser(SMBCCTX *c);
/** Set the username used for making connections */
void
smbc_setPort(SMBCCTX *c, uint16_t port);
+/** Get whether to enable POSIX extensions if available */
+smbc_bool
+smbc_getOptionPosixExtensions(SMBCCTX *c);
+/** Set whether to enable POSIX extensions if available */
+void
+smbc_setOptionPosixExtensions(SMBCCTX *c, smbc_bool b);
/***********************************
* Getters and setters for OPTIONS *
void
smbc_setOptionUseNTHash(SMBCCTX *c, smbc_bool b);
-
+/**
+ * @brief Set the 'client min protocol' and the 'client max protocol'.
+ *
+ * IMPORTANT: This overrides the values 'client min protocol' and 'client max
+ * protocol' set in the smb.conf file!
+ *
+ * @param[in] c The smbc context to use.
+ *
+ * @param[in] min_proto The minimal protocol to use or NULL for leaving it
+ * untouched.
+ *
+ * @param[in] max_proto The maximum protocol to use or NULL for leaving it
+ * untouched.
+ *
+ * @returns true for success, false otherwise
+ */
+smbc_bool
+smbc_setOptionProtocols(SMBCCTX *c, const char *min_proto, const char *max_proto);
/*************************************
* Getters and setters for FUNCTIONS *
smbc_readdirplus_fn smbc_getFunctionReaddirPlus(SMBCCTX *c);
void smbc_setFunctionReaddirPlus(SMBCCTX *c, smbc_readdirplus_fn fn);
+typedef const struct libsmb_file_info * (*smbc_readdirplus2_fn)(SMBCCTX *c,
+ SMBCFILE *dir,
+ struct stat *st);
+smbc_readdirplus2_fn smbc_getFunctionReaddirPlus2(SMBCCTX *c);
+void smbc_setFunctionReaddirPlus2(SMBCCTX *c, smbc_readdirplus2_fn fn);
+
typedef int (*smbc_getdents_fn)(SMBCCTX *c,
SMBCFILE *dir,
struct smbc_dirent *dirp,
* @param shutdown_ctx If 1, all connections and files will be closed even if they are busy.
*
*
- * @return Returns 0 on succes. Returns 1 on failure with errno set:
+ * @return Returns 0 on success. Returns 1 on failure with errno set:
* - EBUSY Server connections are still used, Files are open or cache
* could not be purged
* - EBADF context == NULL
/**@ingroup misc
* Initialize the samba client library.
*
- * Must be called before using any of the smbclient API function
- *
- * @param fn The function that will be called to obtaion
- * authentication credentials.
- *
- * @param debug Allows caller to set the debug level. Can be
- * changed in smb.conf file. Allows caller to set
- * debugging if no smb.conf.
- *
- * @return 0 on success, < 0 on error with errno set:
- * - ENOMEM Out of memory
- * - ENOENT The smb.conf file would not load
- *
+ * @deprecated use smbc_init_context()
+ * @see smbc_init_context()
*/
-
+DEPRECATED_SMBC_INTERFACE
int smbc_init(smbc_get_auth_data_fn fn, int debug);
/**@ingroup misc
*
* @param fd Open file handle from smbc_open() or smbc_creat()
*
- * @param buf Pointer to buffer to recieve read data
+ * @param buf Pointer to buffer to receive read data
*
* @param bufsize Size of buf in bytes
*
struct smbc_dirent* smbc_readdir(unsigned int dh);
/**@ingroup directory
- * Works similar as smbc_readdir but returns more information about file.
+ * Works similar as smbc_readdir() but returns more information about file.
*
* @param dh Valid directory as returned by smbc_opendir()
*
*/
const struct libsmb_file_info *smbc_readdirplus(unsigned int dh);
+/**@ingroup directory
+ * Works similar as smbc_readdirplus() as well as fills up stat structure if
+ * provided.
+ *
+ * @param dh Valid directory as returned by smbc_opendir()
+ *
+ * @param stat Pointer to stat structure which will receive the
+ * information. If this pointer is null the call
+ * is identical to smbc_readdirplus.
+ *
+ * @return A const pointer to a libsmb_file_info structure,
+ * or NULL if an error occurs or end-of-directory is reached:
+ * - EBADF Invalid directory handle
+ * - EINVAL smbc_init() failed or has not been called
+ *
+ * @see smbc_open(), smbc_readdir(), smbc_readdirplus2()
+ */
+const struct libsmb_file_info *smbc_readdirplus2(unsigned int dh,
+ struct stat *st);
/**@ingroup directory
* Get the current directory offset.
*
* @return The current location in the directory stream or -1
* if an error occur. The current location is not
- * an offset. Becuase of the implementation, it is a
+ * an offset. Because of the implementation, it is a
* handle that allows the library to find the entry
* later.
* - EBADF dh is not a valid directory handle
* @see smbc_telldir()
*
*
- * @todo In what does the reture and errno values mean?
+ * @todo In what does the return and errno values mean?
*/
int smbc_lseekdir(int fd, off_t offset);
* permissions of
*
* @param mode The permissions to set:
- * - Put good explaination of permissions here!
+ * - Put good explanation of permissions here!
*
* @return 0 on success, < 0 on error with errno set:
* - EPERM The effective UID does not match the owner
* - ENOMEM Insufficient was available.
* - ENOENT file or directory does not exist
*
- * @todo Actually implement this fuction?
+ * @todo Actually implement this function?
*
* @todo Are errno values complete and correct?
*/
* required to hold the attribute value will be returned,
* but nothing will be placed into the value buffer.
*
- * @return 0 on success, < 0 on error with errno set:
+ * @return size on success, < 0 on error with errno set:
* - EINVAL The client library is not properly initialized
* or one of the parameters is not of a correct
* form
* extended attributes
*
* @note This function always returns all attribute names supported
- * by NT file systems, regardless of wether the referenced
+ * by NT file systems, regardless of whether the referenced
* file system supports extended attributes (e.g. a Windows
* 2000 machine supports extended attributes if NTFS is used,
* but not if FAT is used, and Windows 98 doesn't support
* extended attributes
*
* @note This function always returns all attribute names supported
- * by NT file systems, regardless of wether the referenced
+ * by NT file systems, regardless of whether the referenced
* file system supports extended attributes (e.g. a Windows
* 2000 machine supports extended attributes if NTFS is used,
* but not if FAT is used, and Windows 98 doesn't support
* @param fname The URL of the print share to print to?
*
* @returns A file handle for the print file if successful.
- * Returns -1 if an error ocurred and errno has the values
+ * Returns -1 if an error occurred and errno has the values
* - EINVAL fname was NULL or smbc_init not called.
* - all errors returned by smbc_open
*
* @param srv pointer to server to remove
*
* @return On success, 0 is returned. 1 is returned if the server could not
- * be removed. Also useable outside libsmbclient.
+ * be removed. Also usable outside libsmbclient.
*/
int smbc_remove_unused_server(SMBCCTX * context, SMBCSRV * srv);
#endif
/**@ingroup misc
- * Set the users credentials globally so they can be used for DFS
- * referrals. Probably best to use this function in the smbc_get_auth_data_fn
- * callback.
- *
- * @param workgroup Workgroup of the user.
- *
- * @param user Username of user.
- *
- * @param password Password of user.
+ * @deprecated This interface has been deprecated use
+ * smbc_set_credentials_with_fallback() instead.
*
- * @param use_kerberos Whether to use Kerberos
- *
- * @param signing_state One of these strings (all equivalents on same line):
- * "off", "no", "false"
- * "on", "yes", "true", "auto"
- * "force", "required", "forced"
+ * @see smbc_set_credentials_with_fallback()
*/
-
+DEPRECATED_SMBC_INTERFACE
void
smbc_set_credentials(const char *workgroup,
const char *user,
smbc_bool use_kerberos,
const char *signing_state);
-/*
- * Wrapper around smbc_set_credentials.
- * Used to set correct credentials that will
- * be used to connect to DFS target share
- * in libsmbclient
+/**@ingroup misc
+ *
+ * Set the users credentials globally so they can be used for DFS
+ * referrals. Probably best to use this function in the smbc_get_auth_data_fn
+ * callback.
+ *
+ * @param ctx The smb context.
+ *
+ * @param workgroup Workgroup of the user.
+ *
+ * @param user Username of user.
+ *
+ * @param password Password of user.
*/
-
void
smbc_set_credentials_with_fallback(SMBCCTX *ctx,
const char *workgroup,
*
* @param lock_mutex
* Lock a mutex. This function should expect three parameters: plock,
- * lock_type, and location. The mutex aassociated with identifier plock
+ * lock_type, and location. The mutex associated with identifier plock
* should be locked if lock_type is 1, and unlocked if lock_type is 2. The
* location parameter can be used for debugging, as it contains the
* compiler-provided __location__ of the call.
smbc_closedir_fn closedir DEPRECATED_SMBC_INTERFACE;
smbc_readdir_fn readdir DEPRECATED_SMBC_INTERFACE;
smbc_readdirplus_fn readdirplus DEPRECATED_SMBC_INTERFACE;
+ smbc_readdirplus2_fn readdirplus2 DEPRECATED_SMBC_INTERFACE;
smbc_getdents_fn getdents DEPRECATED_SMBC_INTERFACE;
smbc_mkdir_fn mkdir DEPRECATED_SMBC_INTERFACE;
smbc_rmdir_fn rmdir DEPRECATED_SMBC_INTERFACE;