libsmbclient
Functions
Miscellaneous Functions
Libsmbclient

Functions

SMBCCTXsmbc_new_context (void)
int smbc_free_context (SMBCCTX *context, int shutdown_ctx)
void smbc_option_set (SMBCCTX *context, char *option_name,...)
SMBCCTXsmbc_init_context (SMBCCTX *context)
int smbc_init (smbc_get_auth_data_fn fn, int debug)
SMBCCTXsmbc_set_context (SMBCCTX *new_context)
void smbc_set_credentials (const char *workgroup, const char *user, const char *password, smbc_bool use_kerberos, const char *signing_state)

Detailed Description

Functions that don't fit in to other categories


Function Documentation

int smbc_free_context ( SMBCCTX context,
int  shutdown_ctx 
)

Delete a SBMCCTX (a context) acquired from smbc_new_context().

The context will be deleted if possible.

Parameters:
contextA pointer to a SMBCCTX obtained from smbc_new_context()
shutdown_ctxIf 1, all connections and files will be closed even if they are busy.
Returns:
Returns 0 on succes. 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
See also:
smbc_new_context()
Note:
It is advised to clean up all the contexts with shutdown_ctx set to 1 just before exit()'ing. When shutdown_ctx is 0, this function can be use in periodical cleanup functions for example.
int smbc_init ( smbc_get_auth_data_fn  fn,
int  debug 
)

Initialize the samba client library.

Must be called before using any of the smbclient API function

Parameters:
fnThe function that will be called to obtaion authentication credentials.
debugAllows caller to set the debug level. Can be changed in smb.conf file. Allows caller to set debugging if no smb.conf.
Returns:
0 on success, < 0 on error with errno set:
  • ENOMEM Out of memory
  • ENOENT The smb.conf file would not load
SMBCCTX* smbc_init_context ( SMBCCTX context)

Initialize a SBMCCTX (a context).

Must be called before using any SMBCCTX API function

Parameters:
contextA pointer to a SMBCCTX obtained from smbc_new_context()
Returns:
A pointer to the given SMBCCTX on success, NULL on error with errno set:
  • EBADF NULL context given
  • ENOMEM Out of memory
  • ENOENT The smb.conf file would not load
See also:
smbc_new_context()
Note:
my_context = smbc_init_context(smbc_new_context()) is perfectly safe, but it might leak memory on smbc_context_init() failure. Avoid this. You'll have to call smbc_free_context() yourself on failure.
SMBCCTX* smbc_new_context ( void  )

Create a new SBMCCTX (a context).

Must be called before the context is passed to smbc_context_init()

Returns:
The given SMBCCTX pointer on success, NULL on error with errno set:
  • ENOMEM Out of memory
See also:
smbc_free_context(), smbc_init_context()
Note:
Do not forget to smbc_init_context() the returned SMBCCTX pointer !
void smbc_option_set ( SMBCCTX context,
char *  option_name,
  ... 
)
Deprecated:
. Use smbc_setOption*() functions instead.
SMBCCTX* smbc_set_context ( SMBCCTX new_context)

Set or retrieve the compatibility library's context pointer

Parameters:
contextNew context to use, or NULL. If a new context is provided, it must have allocated with smbc_new_context() and initialized with smbc_init_context(), followed, optionally, by some manual changes to some of the non-internal fields.
Returns:
The old context.
See also:
smbc_new_context(), smbc_init_context(), smbc_init()
Note:
This function may be called prior to smbc_init() to force use of the next context without any internal calls to smbc_new_context() or smbc_init_context(). It may also be called after smbc_init() has already called those two functions, to replace the existing context with a new one. Care should be taken, in this latter case, to ensure that the server cache and any data allocated by the authentication functions have been freed, if necessary.
void smbc_set_credentials ( const char *  workgroup,
const char *  user,
const char *  password,
smbc_bool  use_kerberos,
const char *  signing_state 
)

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.

Parameters:
workgroupWorkgroup of the user.
userUsername of user.
passwordPassword of user.
use_kerberosWhether to use Kerberos
signing_stateOne of these strings (all equivalents on same line): "off", "no", "false" "on", "yes", "true", "auto" "force", "required", "forced"
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines