Move copy_unix_token() from locking/locking.c to lib/util.c.
[kai/samba.git] / source3 / include / libsmbclient.h
index 869aeb6a032336512c101f528e61f07041cc95c5..61ff6a3b3bdc627ba89cb546eb54fd93cceea39c 100644 (file)
@@ -263,10 +263,13 @@ typedef struct _SMBCCTX SMBCCTX;
  *   smbc_getOptionFallbackAFterKerberos()
  *   smbc_setOptionNoAutoAnonymousLogin()
  *   smbc_getOptionNoAutoAnonymousLogin()
+ *   smbc_setOptionUseCCache()
+ *   smbc_getOptionUseCCache()
  */
 # define SMB_CTX_FLAG_USE_KERBEROS (1 << 0)
 # define SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS (1 << 1)
 # define SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON (1 << 2)
+# define SMB_CTX_FLAG_USE_CCACHE (1 << 3)
 
 
 
@@ -732,6 +735,22 @@ smbc_getOptionNoAutoAnonymousLogin(SMBCCTX *c);
 void
 smbc_setOptionNoAutoAnonymousLogin(SMBCCTX *c, smbc_bool b);
 
+/** Get whether to enable use of the winbind ccache */
+smbc_bool
+smbc_getOptionUseCCache(SMBCCTX *c);
+
+/** Set whether to enable use of the winbind ccache */
+void
+smbc_setOptionUseCCache(SMBCCTX *c, smbc_bool b);
+
+/** Get indication that the password supplied is the NT hash */
+smbc_bool
+smbc_getOptionUseNTHash(SMBCCTX *c);
+
+/** Set indication that the password supplied is the NT hash */
+void
+smbc_setOptionUseNTHash(SMBCCTX *c, smbc_bool b);
+
 
 
 /*************************************
@@ -1252,17 +1271,19 @@ int smbc_creat(const char *furl, mode_t mode);
  *
  * @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
  *
- * @return          Number of bytes read, < 0 on error with errno set:
+ * @return          Number of bytes read;
+ *                  0 upon EOF;
+ *                  < 0 on error, with errno set:
  *                  - EISDIR fd refers to a directory
  *                  - EBADF  fd  is  not  a valid file descriptor or 
- *                  is not open for reading.
+ *                    is not open for reading.
  *                  - EINVAL fd is attached to an object which is 
- *                  unsuitable for reading, or no buffer passed or
- *                 smbc_init not called.
+ *                    unsuitable for reading, or no buffer passed or
+ *                   smbc_init not called.
  *
  * @see             smbc_open(), smbc_write()
  *
@@ -1607,7 +1628,8 @@ int smbc_stat(const char *url, struct stat *st);
  * @param st        pointer to a buffer that will be filled with 
  *                  standard Unix struct stat information.
  * 
- * @return          EBADF  filedes is bad.
+ * @return          0 on success, < 0 on error with errno set:
+ *                  - EBADF  filedes is bad.
  *                  - EACCES Permission denied.
  *                  - EBADF fd is not a valid file descriptor
  *                  - EINVAL Problems occurred in the underlying routines
@@ -1628,7 +1650,8 @@ int smbc_fstat(int fd, struct stat *st);
  * @param st        pointer to a buffer that will be filled with 
  *                  standard Unix struct statvfs information.
  * 
- * @return          EBADF  filedes is bad.
+ * @return          0 on success, < 0 on error with errno set:
+ *                  - EBADF  filedes is bad.
  *                  - EACCES Permission denied.
  *                  - EBADF fd is not a valid file descriptor
  *                  - EINVAL Problems occurred in the underlying routines
@@ -1651,7 +1674,8 @@ smbc_statvfs(char *url,
  * @param st        pointer to a buffer that will be filled with 
  *                  standard Unix struct statvfs information.
  * 
- * @return          EBADF  filedes is bad.
+ * @return          0 on success, < 0 on error with errno set:
+ *                  - EBADF  filedes is bad.
  *                  - EACCES Permission denied.
  *                  - EBADF fd is not a valid file descriptor
  *                  - EINVAL Problems occurred in the underlying routines
@@ -1673,7 +1697,8 @@ smbc_fstatvfs(int fd,
  *
  * @param size      size to truncate the file to
  * 
- * @return          EBADF  filedes is bad.
+ * @return          0 on success, < 0 on error with errno set:
+ *                  - EBADF  filedes is bad.
  *                  - EACCES Permission denied.
  *                  - EBADF fd is not a valid file descriptor
  *                  - EINVAL Problems occurred in the underlying routines
@@ -2696,6 +2721,115 @@ smbc_set_credentials_with_fallback(SMBCCTX *ctx,
                                   const char *user,
                                   const char *password);
 
+
+/**
+ * @ingroup threads
+ *
+ * Initialize for threads using the Posix Threads (pthread)
+ * implementation. This is a built-in implementation, avoiding the need to
+ * implement the component functions of the thread interface. If this function
+ * is used, it is not necessary to call smbc_thread_impl().
+ *
+ * @return {void}
+ */
+void
+smbc_thread_posix(void);
+
+/**
+ * @ingroup threads
+ *
+ * Initialize for an arbitrary thread implementation. The caller should
+ * provide, as parameters, pointers to functions to implement the requisite
+ * low-level thread functionality. A function must be provided for each
+ * parameter; none may be null.
+ *
+ * If the thread implementation is POSIX Threads (pthreads), then the much
+ * simpler smbc_thread_pthread() function may be used instead of this one.
+ *
+ * @param create_mutex
+ *   Create a mutex. This function should expect three parameters: lockname,
+ *   pplock, and location. It should create a unique mutex for each unique
+ *   lockname it is provided, and return the mutex identifier in *pplock. The
+ *   location parameter can be used for debugging, as it contains the
+ *   compiler-provided __location__ of the call.
+ *
+ * @param destroy_mutex
+ *   Destroy a mutex. This function should expect two parameters: plock and
+ *   location. It should destroy the mutex associated with the identifier
+ *   plock. The location parameter can be used for debugging, as it contains
+ *   the compiler-provided __location__ of the call.
+ *
+ * @param lock_mutex
+ *   Lock a mutex. This function should expect three parameters: plock,
+ *   lock_type, and location. The mutex aassociated 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.
+ *
+ * @param create_tls
+ *   Create thread local storage. This function should expect three
+ *   parameters: keyname, ppkey, and location. It should allocate an
+ *   implementation-specific amount of memory and assign the pointer to that
+ *   allocated memory to *ppkey. The location parameter can be used for
+ *   debugging, as it contains the compiler-provided __location__ of the
+ *   call. This function should return 0 upon success, non-zero upon failure.
+ *
+ * @param destroy_tls
+ *   Destroy thread local storage. This function should expect two parameters:
+ *   ppkey and location. The ppkey parameter points to a variable containing a
+ *   thread local storage key previously provided by the create_tls
+ *   function. The location parameter can be used for debugging, as it
+ *   contains the compiler-provided __location__ of the call.
+ *
+ * @param set_tls
+ *   Set a thread local storage variable's value. This function should expect
+ *   three parameters: pkey, pval, and location. The pkey parameter is a
+ *   thread local storage key previously provided by the create_tls
+ *   function. The (void *) pval parameter contains the value to be placed in
+ *   the thread local storage variable identified by pkey. The location
+ *   parameter can be used for debugging, as it contains the compiler-provided
+ *   __location__ of the call. This function should return 0 upon success;
+ *   non-zero otherwise.
+ *
+ * @param get_tls
+ *   Retrieve a thread local storage variable's value. This function should
+ *   expect two parameters: pkey and location. The pkey parameter is a thread
+ *   local storage key previously provided by the create_tls function, and
+ *   which has previously been used in a call to the set_tls function to
+ *   initialize a thread local storage variable. The location parameter can be
+ *   used for debugging, as it contains the compiler-provided __location__ of
+ *   the call. This function should return the (void *) value stored in the
+ *   variable identified by pkey.
+ *
+ * @return {void}
+ */
+void
+smbc_thread_impl(
+        /* Mutex functions. */
+        int (*create_mutex)(const char *lockname,
+                            void **pplock,
+                            const char *location),
+        void (*destroy_mutex)(void *plock,
+                              const char *location),
+        int (*lock_mutex)(void *plock,
+                          int lock_type,
+                          const char *location),
+    
+        /* Thread local storage. */
+        int (*create_tls)(const char *keyname,
+                          void **ppkey,
+                          const char *location),
+        void (*destroy_tls)(void **ppkey,
+                            const char *location),
+        int (*set_tls)(void *pkey,
+                       const void *pval,
+                       const char *location),
+        void *(*get_tls)(void *pkey,
+                         const char *location)
+        );
+
+
+
 /**
  * @ingroup structure
  * Structure that contains a client context information