packaging: Add missing quotes in smbprint
[samba.git] / source3 / include / libsmbclient.h
index 426ed3cb6a151d53d4c0eda073bee3a87bc4d67a..619feab63922058b37b336b789001a7896f0aa5b 100644 (file)
@@ -78,6 +78,7 @@ extern "C" {
 #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 */
@@ -224,6 +225,7 @@ typedef enum smbc_share_mode
  */
 typedef enum smbc_smb_encrypt_level
 {
+    SMBC_ENCRYPTLEVEL_DEFAULT   = -1,
     SMBC_ENCRYPTLEVEL_NONE      = 0,
     SMBC_ENCRYPTLEVEL_REQUEST   = 1,
     SMBC_ENCRYPTLEVEL_REQUIRE   = 2
@@ -488,7 +490,7 @@ typedef SMBCSRV * (*smbc_get_cached_srv_fn)   (SMBCCTX * c, const char * server,
                                                const char * username);
 
 /**@ingroup callback
- * Check if a server is still good
+ * Remove a cached server
  *
  * @param c         pointer to smb context
  *
@@ -537,22 +539,22 @@ int
 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 */
@@ -586,7 +588,13 @@ smbc_getPort(SMBCCTX *c);
 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 *
@@ -831,7 +839,24 @@ smbc_getOptionUseNTHash(SMBCCTX *c);
 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 *
@@ -1029,6 +1054,12 @@ typedef const struct libsmb_file_info * (*smbc_readdirplus_fn)(SMBCCTX *c,
 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,
@@ -1198,7 +1229,7 @@ SMBCCTX * smbc_new_context(void);
  * @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
@@ -1255,21 +1286,10 @@ SMBCCTX * smbc_init_context(SMBCCTX * context);
 /**@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
@@ -1414,7 +1434,7 @@ ssize_t smbc_read(int fd, void *buf, size_t bufsize);
  *
  * @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
  *
@@ -1624,7 +1644,7 @@ int smbc_getdents(unsigned int dh, struct smbc_dirent *dirp, int count);
 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()
  *
@@ -1637,6 +1657,25 @@ struct smbc_dirent* smbc_readdir(unsigned int dh);
  */
 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.
@@ -1648,7 +1687,7 @@ const struct libsmb_file_info *smbc_readdirplus(unsigned int dh);
  *
  * @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
@@ -1681,7 +1720,7 @@ off_t smbc_telldir(int dh);
  * @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);
 
@@ -1891,7 +1930,7 @@ int smbc_ftruncate(int fd, off_t size);
  *                  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
@@ -1900,7 +1939,7 @@ int smbc_ftruncate(int fd, off_t size);
  *                  - 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?
  */
@@ -2375,7 +2414,7 @@ int smbc_getxattr(const char *url,
  *                  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
@@ -2664,7 +2703,7 @@ int smbc_listxattr(const char *url,
  *                            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
@@ -2699,7 +2738,7 @@ int smbc_llistxattr(const char *url,
  *                            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
@@ -2735,7 +2774,7 @@ int smbc_print_file(const char *fname, const char *printq);
  * @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
  *
@@ -2777,7 +2816,7 @@ int smbc_unlink_print_job(const char *purl, int id);
  * @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);
 
@@ -2856,24 +2895,12 @@ 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.
+ * @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,
@@ -2881,13 +2908,20 @@ smbc_set_credentials(const char *workgroup,
                      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,
@@ -2934,7 +2968,7 @@ smbc_thread_posix(void);
  *
  * @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.
@@ -3087,6 +3121,7 @@ struct _SMBCCTX
         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;