Make char* parameters const
[samba.git] / source / include / libsmbclient.h
index 2e38944d657836cd61b213832c8c23f680686367..869aeb6a032336512c101f528e61f07041cc95c5 100644 (file)
@@ -75,6 +75,7 @@ extern "C" {
 /* Make sure we have the following includes for now ... */
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/statvfs.h>
 #include <fcntl.h>
 #include <utime.h>
 
@@ -174,6 +175,22 @@ typedef enum smbc_smb_encrypt_level
 } smbc_smb_encrypt_level;
 
 
+/**
+ * Capabilities set in the f_flag field of struct statvfs, from
+ * smbc_statvfs(). These may be OR-ed together to reflect a full set of
+ * available capabilities.
+ */
+typedef enum smbc_vfs_feature
+{
+    /* Defined by POSIX or in Linux include files (low-order bits) */
+    SMBC_VFS_FEATURE_RDONLY         = (1 << 0),
+
+    /* Specific to libsmbclient (high-order bits) */
+    SMBC_VFS_FEATURE_DFS              = (1 << 28),
+    SMBC_VFS_FEATURE_CASE_INSENSITIVE = (1 << 29),
+    SMBC_VFS_FEATURE_NO_UNIXCIFS      = (1 << 30)
+} smbc_vfs_feature;
+
 typedef int smbc_bool;
 
 
@@ -259,6 +276,11 @@ typedef struct _SMBCCTX SMBCCTX;
  * Type for the the authentication function called by the library to
  * obtain authentication credentals
  *
+ * For kerberos support the function should just be called without
+ * prompting the user for credentials. Which means a simple 'return'
+ * should work. Take a look at examples/libsmbclient/get_auth_data_fn.h
+ * and examples/libsmbclient/testbrowse.c.
+ *
  * @param srv       Server being authenticated to
  *
  * @param shr       Share being authenticated to
@@ -293,6 +315,11 @@ typedef void (*smbc_get_auth_data_fn)(const char *srv,
  * Type for the the authentication function called by the library to
  * obtain authentication credentals
  *
+ * For kerberos support the function should just be called without
+ * prompting the user for credentials. Which means a simple 'return'
+ * should work. Take a look at examples/libsmbclient/get_auth_data_fn.h
+ * and examples/libsmbclient/testbrowse.c.
+ *
  * @param c         Pointer to the smb context
  *
  * @param srv       Server being authenticated to
@@ -540,6 +567,27 @@ smbc_getOptionSmbEncryptionLevel(SMBCCTX *c);
 void
 smbc_setOptionSmbEncryptionLevel(SMBCCTX *c, smbc_smb_encrypt_level level);
 
+/**
+ * Get whether to treat file names as case-sensitive if we can't determine
+ * when connecting to the remote share whether the file system is case
+ * sensitive. This defaults to FALSE since it's most likely that if we can't
+ * retrieve the file system attributes, it's a very old file system that does
+ * not support case sensitivity.
+ */
+smbc_bool
+smbc_getOptionCaseSensitive(SMBCCTX *c);
+
+/**
+ * Set whether to treat file names as case-sensitive if we can't determine
+ * when connecting to the remote share whether the file system is case
+ * sensitive. This defaults to FALSE since it's most likely that if we can't
+ * retrieve the file system attributes, it's a very old file system that does
+ * not support case sensitivity.
+ */
+void
+smbc_setOptionCaseSensitive(SMBCCTX *c, smbc_bool b);
+
+
 /**
  * Get from how many local master browsers should the list of workgroups be
  * retrieved.  It can take up to 12 minutes or longer after a server becomes a
@@ -786,7 +834,7 @@ void smbc_setFunctionRead(SMBCCTX *c, smbc_read_fn fn);
 
 typedef ssize_t (*smbc_write_fn)(SMBCCTX *c,
                                  SMBCFILE *file,
-                                 void *buf,
+                                 const void *buf,
                                  size_t count);
 smbc_write_fn smbc_getFunctionWrite(SMBCCTX *c);
 void smbc_setFunctionWrite(SMBCCTX *c, smbc_write_fn fn);
@@ -822,6 +870,18 @@ typedef int (*smbc_fstat_fn)(SMBCCTX *c,
 smbc_fstat_fn smbc_getFunctionFstat(SMBCCTX *c);
 void smbc_setFunctionFstat(SMBCCTX *c, smbc_fstat_fn fn);
 
+typedef int (*smbc_statvfs_fn)(SMBCCTX *c,
+                               char *path,
+                               struct statvfs *st);
+smbc_statvfs_fn smbc_getFunctionStatVFS(SMBCCTX *c);
+void smbc_setFunctionStatVFS(SMBCCTX *c, smbc_statvfs_fn fn);
+
+typedef int (*smbc_fstatvfs_fn)(SMBCCTX *c,
+                                SMBCFILE *file,
+                                struct statvfs *st);
+smbc_fstatvfs_fn smbc_getFunctionFstatVFS(SMBCCTX *c);
+void smbc_setFunctionFstatVFS(SMBCCTX *c, smbc_fstatvfs_fn fn);
+
 typedef int (*smbc_ftruncate_fn)(SMBCCTX *c,
                                  SMBCFILE *f,
                                  off_t size);
@@ -1230,7 +1290,7 @@ ssize_t smbc_read(int fd, void *buf, size_t bufsize);
  * @see             smbc_open(), smbc_read()
  *
  */
-ssize_t smbc_write(int fd, void *buf, size_t bufsize);
+ssize_t smbc_write(int fd, const void *buf, size_t bufsize);
 
 
 /**@ingroup file
@@ -1561,11 +1621,12 @@ int smbc_fstat(int fd, struct stat *st);
 
 
 /**@ingroup attribute
- * Truncate a file given a file descriptor
+ * Get file system information for a specified path.
  * 
- * @param fd        Open file handle from smbc_open() or smbc_creat()
+ * @param url       The smb url to get information for
  *
- * @param size      size to truncate the file to
+ * @param st        pointer to a buffer that will be filled with 
+ *                  standard Unix struct statvfs information.
  * 
  * @return          EBADF  filedes is bad.
  *                  - EACCES Permission denied.
@@ -1574,36 +1635,55 @@ int smbc_fstat(int fd, struct stat *st);
  *                   or smbc_init not called.
  *                  - ENOMEM Out of memory
  *
- * @see             , Unix ftruncate()
+ * @see             Unix fstatvfs()
  *
  */
-int smbc_ftruncate(int fd, off_t size);
-
+int
+smbc_statvfs(char *url,
+             struct statvfs *st);
 
-/**@ingroup attribue
- * Change the ownership of a file or directory.
- *
- * @param url       The smb url of the file or directory to change 
- *                  ownership of.
+/**@ingroup attribute
+ * Get file system information via an file descriptor.
+ * 
+ * @param fd        Open file handle from smbc_open(), smbc_creat(),
+ *                  or smbc_opendir()
  *
- * @param owner     I have no idea?
+ * @param st        pointer to a buffer that will be filled with 
+ *                  standard Unix struct statvfs information.
+ * 
+ * @return          EBADF  filedes is bad.
+ *                  - EACCES Permission denied.
+ *                  - EBADF fd is not a valid file descriptor
+ *                  - EINVAL Problems occurred in the underlying routines
+ *                   or smbc_init not called.
+ *                  - ENOMEM Out of memory
  *
- * @param group     I have not idea?
+ * @see             Unix fstatvfs()
  *
- * @return          0 on success, < 0 on error with errno set:
- *                  - EPERM  The effective UID does not match the owner
- *                  of the file, and is not zero; or the owner or group
- *                  were specified incorrectly.
- *                  - ENOENT The file does not exist.
- *                  - ENOMEM Insufficient was available.
- *                  - ENOENT file or directory does not exist
+ */
+int
+smbc_fstatvfs(int fd,
+              struct statvfs *st);
+
+
+/**@ingroup attribute
+ * Truncate a file given a file descriptor
+ * 
+ * @param fd        Open file handle from smbc_open() or smbc_creat()
  *
- * @todo Are we actually going to be able to implement this function
+ * @param size      size to truncate the file to
+ * 
+ * @return          EBADF  filedes is bad.
+ *                  - EACCES Permission denied.
+ *                  - EBADF fd is not a valid file descriptor
+ *                  - EINVAL Problems occurred in the underlying routines
+ *                   or smbc_init not called.
+ *                  - ENOMEM Out of memory
  *
- * @todo How do we abstract owner and group uid and gid?
+ * @see             , Unix ftruncate()
  *
  */
-int smbc_chown(const char *url, uid_t owner, gid_t group);
+int smbc_ftruncate(int fd, off_t size);
 
 
 /**@ingroup attribute
@@ -2577,6 +2657,45 @@ smbc_version(void);
 }
 #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.
+ *
+ * @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"
+ */
+
+void
+smbc_set_credentials(const char *workgroup,
+                     const char *user,
+                     const char *password,
+                     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
+ */
+
+void
+smbc_set_credentials_with_fallback(SMBCCTX *ctx,
+                                  const char *workgroup,
+                                  const char *user,
+                                  const char *password);
+
 /**
  * @ingroup structure
  * Structure that contains a client context information