1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-29 21:47:30 +03:00

Continued revamping of libsmbclient.

- James suggested using gcc's "deprecated" attribute to mark the context
  structure fields to generate warnings.  This creates a scenario with the
  best of all worlds.  I'm able to move to an organization that more easily
  allows future enhancements, while avoiding any mandatory changes by
  applications.  Thanks, James!

- Updated WHATSNEW.txt so that it accurately reflects the current state of
  affairs.

Derrell
This commit is contained in:
Derrell Lipman 2008-03-03 18:13:33 -05:00
parent 93580bce83
commit a67f96fbe9
16 changed files with 1217 additions and 1276 deletions

View File

@ -111,16 +111,11 @@ Modified API for libsmbclient
Maintaining ABI compatibility for libsmbclient has become increasingly
difficult to accomplish, while also keeping the code organization such that it
is easily readable. Towards the goal of maintaining ABI compatibility and
also keeping the code easy to maintain and enhance, the API has changed
somewhat. In particular, the fields in the SMBCCTX context structure are no
longer intended to be read/write by the user. The names of the fields have
changed to encourage any recompilations to use the new interface, but for
continued ABI compatibility, the fields are in the same locations in the
context structure as they were previously so any previously-compiled
applications should continue to work with this new version.
An application that previously accessed the members of the SMBCCTX context
structure will encounter errors if recompiled. This is intentional to
also keeping the code easy to maintain and enhance, the API has been enhanced.
In particular, the fields in the SMBCCTX context structure are no longer
intended to be read/write by the user, and are marked as deprecated. An
application that previously accessed the members of the SMBCCTX context
structure will now encounter warnings if recompiled. This is intentional, to
encourage implementation of the small changes required for the new interface.
The number of changes is expected to be quite small for the vast majority of
applications, and no changes need be made for many applications. The changes
@ -141,7 +136,7 @@ under these comment blocks:
Callable functions for directories
Callable functions applicable to both files and directories
Example changes that may be required:
Example changes that may be required to eliminate "deprecated" warnings:
/* Set the debug level */
context->debug = 99;

View File

@ -1,14 +1,14 @@
#
CC = gcc
SAMBA_INCL = ../../source/include
SAMBA_INCL = -I/usr/local/samba/include
EXTLIB_INCL = -I/usr/include/gtk-1.2 \
-I/usr/include/glib-1.2 \
-I/usr/lib/glib/include
EXTLIB_INCL = `gtk-config --cflags`
DEFS = -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
CFLAGS = -O0 -g -I$(SAMBA_INCL) $(EXTLIB_INCL) $(DEFS)
CFLAGS = -O0 -g $(SAMBA_INCL) $(EXTLIB_INCL) $(DEFS)
LDFLAGS = -L/usr/local/samba/lib \
-lldap -lkrb5 -lgssapi_krb5

View File

@ -25,7 +25,7 @@
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <libsmbclient.h>
#include "libsmbclient.h"
#include "get_auth_data_fn.h"
int global_id = 0;

View File

@ -775,6 +775,7 @@ LIBSMBCLIENT_OBJ0 = \
libsmb/libsmb_server.o \
libsmb/libsmb_stat.o \
libsmb/libsmb_xattr.o \
libsmb/libsmb_setget.o \
$(PARAM_OBJ) $(LIB_NONSMBD_OBJ) \
$(LIBSMB_OBJ) $(KRBCLIENT_OBJ) \
$(LIBMSRPC_OBJ) $(LIBMSRPC_GEN_OBJ) $(RPC_PARSE_OBJ) \

View File

@ -113,23 +113,6 @@ struct SMBC_internal_data {
/* True when this handle is initialized */
bool initialized;
#if 0 /* Left in libsmbclient.h for backward compatibility */
/* Netbios name used for making connections */
char * netbios_name;
/* Workgroup used for making connections */
char * workgroup;
/* Username used for making connections */
char * user;
/* Debug level */
int debug;
/* Connection timeout value */
int timeout;
#endif
/* dirent pointer location
*
* Leave room for any urlencoded filename and the comment field.
@ -192,88 +175,7 @@ struct SMBC_internal_data {
*/
smbc_smb_encrypt_level smb_encryption_level;
#if 0 /* Left in libsmbclient.h for backward compatibility */
/*
* 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 local master browser, for
* it to have the entire browse list (the list of
* workgroups/domains) from an entire network. Since a client
* never knows which local master browser will be found first,
* the one which is found first and used to retrieve a browse
* list may have an incomplete or empty browse list. By
* requesting the browse list from multiple local master
* browsers, a more complete list can be generated. For small
* networks (few workgroups), it is recommended that this
* value be set to 0, causing the browse lists from all found
* local master browsers to be retrieved and merged. For
* networks with many workgroups, a suitable value for this
* variable is probably somewhere around 3. (Default: 3).
*/
int browse_max_lmb_count;
/*
* There is a difference in the desired return strings from
* smbc_readdir() depending upon whether the filenames are to
* be displayed to the user, or whether they are to be
* appended to the path name passed to smbc_opendir() to call
* a further smbc_ function (e.g. open the file with
* smbc_open()). In the former case, the filename should be
* in "human readable" form. In the latter case, the smbc_
* functions expect a URL which must be url-encoded. Those
* functions decode the URL. If, for example, smbc_readdir()
* returned a file name of "abc%20def.txt", passing a path
* with this file name attached to smbc_open() would cause
* smbc_open to attempt to open the file "abc def.txt" since
* the %20 is decoded into a space.
*
* Set this option to True if the names returned by
* smbc_readdir() should be url-encoded such that they can be
* passed back to another smbc_ call. Set it to False if the
* names returned by smbc_readdir() are to be presented to the
* user.
*
* For backwards compatibility, this option defaults to False.
*/
bool urlencode_readdir_entries;
/*
* Some Windows versions appear to have a limit to the number
* of concurrent SESSIONs and/or TREE CONNECTions. In
* one-shot programs (i.e. the program runs and then quickly
* ends, thereby shutting down all connections), it is
* probably reasonable to establish a new connection for each
* share. In long-running applications, the limitation can be
* avoided by using only a single connection to each server,
* and issuing a new TREE CONNECT when the share is accessed.
*/
bool one_share_per_server;
/* Kerberos-related flags */
bool use_kerberos;
bool fallback_after_kerberos;
/* Don't try to do automatic anonymous login */
bool no_auto_anonymous_login;
/* Server-related functions */
struct
{
smbc_get_auth_data_fn get_auth_data_fn;
smbc_check_server_fn check_server_fn;
smbc_remove_unused_server_fn remove_unused_server_fn;
} server;
/* Cache-related functions */
struct
{
struct smbc_server_cache * server_cache_data;
smbc_add_cached_srv_fn add_cached_server_fn;
smbc_get_cached_srv_fn get_cached_server_fn;
smbc_remove_cached_srv_fn remove_cached_server_fn;
smbc_purge_cached_srv_fn purge_cached_server_fn;
} cache;
#endif
struct smbc_server_cache * server_cache;
/* POSIX emulation functions */
struct

View File

@ -25,6 +25,13 @@
#ifndef SMBCLIENT_H_INCLUDED
#define SMBCLIENT_H_INCLUDED
#undef _DEPRECATED_
#if ! defined(__LIBSMBCLIENT_INTERNAL__) && defined(__GNUC__)
# define _DEPRECATED_ __attribute__ ((deprecated))
#else
# define _DEPRECATED_
#endif
#ifdef __cplusplus
extern "C" {
#endif
@ -416,7 +423,7 @@ typedef int (*smbc_remove_cached_srv_fn)(SMBCCTX * c, SMBCSRV *srv);
* @return 0 when found and removed. 1 on failure.
*
*/
typedef int (*smbc_purge_cached_srv_fn) (SMBCCTX * c);
typedef int (*smbc_purge_cached_fn) (SMBCCTX * c);
@ -734,14 +741,14 @@ void smbc_setFunctionRemoveCachedServer(SMBCCTX *c,
* Get the function for server cache purging. This function tries to
* remove all cached servers (e.g. on disconnect)
*/
smbc_purge_cached_srv_fn smbc_getFunctionPurgeCachedServers(SMBCCTX *c);
smbc_purge_cached_fn smbc_getFunctionPurgeCachedServers(SMBCCTX *c);
/**
* Set the function for server cache purging. This function tries to
* remove all cached servers (e.g. on disconnect)
*/
void smbc_setFunctionPurgeCachedServers(SMBCCTX *c,
smbc_purge_cached_srv_fn fn);
smbc_purge_cached_fn fn);
/** Get the function to store private data of the server cache */
struct smbc_server_cache * smbc_getServerCacheData(SMBCCTX *c);
@ -1010,7 +1017,7 @@ int smbc_free_context(SMBCCTX * context, int shutdown_ctx);
/**@ingroup misc
*
* @DEPRECATED. Use smbc_setOption*() functions instead.
* @deprecated. Use smbc_setOption*() functions instead.
*/
void
smbc_option_set(SMBCCTX *context,
@ -1018,7 +1025,7 @@ smbc_option_set(SMBCCTX *context,
... /* option_value */);
/*
* @DEPRECATED. Use smbc_getOption*() functions instead.
* @deprecated. Use smbc_getOption*() functions instead.
*/
void *
smbc_option_get(SMBCCTX *context,
@ -2570,7 +2577,6 @@ smbc_version(void);
}
#endif
/**
* @ingroup structure
* Structure that contains a client context information
@ -2586,137 +2592,129 @@ smbc_version(void);
* directly visible to applications. This makes it much easier to maintain
* ABI compatibility.
*/
struct _SMBCCTX {
struct
{
/**
* debug level
*
* Manually setting/retrieving this value is deprecated.
* Use smbc_getDebug() and smbc_setDebug()
*/
int debug;
struct _SMBCCTX
{
/**
* debug level
*
* DEPRECATED:
* Use smbc_getDebug() and smbc_setDebug()
*/
int debug _DEPRECATED_;
/**
* netbios name used for making connections
*
* Manually setting/retrieving this value is deprecated.
* Use smbc_getNetbiosName() and smbc_setNetbiosName()
*/
char * netbios_name;
/**
* netbios name used for making connections
*
* DEPRECATED:
* Use smbc_getNetbiosName() and smbc_setNetbiosName()
*/
char * netbios_name _DEPRECATED_;
/**
* workgroup name used for making connections
*
* Manually setting/retrieving this value is deprecated.
* Use smbc_getWorkgroup() and smbc_setWorkgroup()
*/
char * workgroup;
/**
* workgroup name used for making connections
*
* DEPRECATED:
* Use smbc_getWorkgroup() and smbc_setWorkgroup()
*/
char * workgroup _DEPRECATED_;
/**
* username used for making connections
*
* Manually setting/retrieving this value is deprecated.
* Use smbc_getUser() and smbc_setUser()
*/
char * user;
/**
* username used for making connections
*
* DEPRECATED:
* Use smbc_getUser() and smbc_setUser()
*/
char * user _DEPRECATED_;
/**
* timeout used for waiting on connections / response data (in
* milliseconds)
*
* Manually setting/retrieving this value is deprecated.
* Use smbc_getTimeout() and smbc_setTimeout()
*/
int timeout;
} config;
/**
* timeout used for waiting on connections / response data (in
* milliseconds)
*
* DEPRECATED:
* Use smbc_getTimeout() and smbc_setTimeout()
*/
int timeout _DEPRECATED_;
/**
* callable functions for files:
* For usage and return values see the SMBC_* functions
*
* Manually setting/retrieving these values is deprecated.
* DEPRECATED:
*
* Use smbc_getFunction*() and smbc_setFunction*(), e.g.
* smbc_getFunctionOpen(), smbc_setFunctionUnlink(), etc.
*/
struct
{
smbc_open_fn open_fn;
smbc_creat_fn creat_fn;
smbc_read_fn read_fn;
smbc_write_fn write_fn;
smbc_unlink_fn unlink_fn;
smbc_rename_fn rename_fn;
smbc_lseek_fn lseek_fn;
smbc_stat_fn stat_fn;
smbc_fstat_fn fstat_fn;
smbc_open_fn open _DEPRECATED_;
smbc_creat_fn creat _DEPRECATED_;
smbc_read_fn read _DEPRECATED_;
smbc_write_fn write _DEPRECATED_;
smbc_unlink_fn unlink _DEPRECATED_;
smbc_rename_fn rename _DEPRECATED_;
smbc_lseek_fn lseek _DEPRECATED_;
smbc_stat_fn stat _DEPRECATED_;
smbc_fstat_fn fstat _DEPRECATED_;
#if 0 /* internal */
smbc_ftruncate_fn ftruncate_fn;
smbc_ftruncate_fn ftruncate_fn;
#endif
smbc_close_fn close_fn;
smbc_opendir_fn opendir_fn;
smbc_closedir_fn closedir_fn;
smbc_readdir_fn readdir_fn;
smbc_getdents_fn getdents_fn;
smbc_mkdir_fn mkdir_fn;
smbc_rmdir_fn rmdir_fn;
smbc_telldir_fn telldir_fn;
smbc_lseekdir_fn lseekdir_fn;
smbc_fstatdir_fn fstatdir_fn;
smbc_chmod_fn chmod_fn;
smbc_utimes_fn utimes_fn;
smbc_setxattr_fn setxattr_fn;
smbc_getxattr_fn getxattr_fn;
smbc_removexattr_fn removexattr_fn;
smbc_listxattr_fn listxattr_fn;
} posix_emu;
smbc_close_fn close_fn _DEPRECATED_;
smbc_opendir_fn opendir _DEPRECATED_;
smbc_closedir_fn closedir _DEPRECATED_;
smbc_readdir_fn readdir _DEPRECATED_;
smbc_getdents_fn getdents _DEPRECATED_;
smbc_mkdir_fn mkdir _DEPRECATED_;
smbc_rmdir_fn rmdir _DEPRECATED_;
smbc_telldir_fn telldir _DEPRECATED_;
smbc_lseekdir_fn lseekdir _DEPRECATED_;
smbc_fstatdir_fn fstatdir _DEPRECATED_;
smbc_chmod_fn chmod _DEPRECATED_;
smbc_utimes_fn utimes _DEPRECATED_;
smbc_setxattr_fn setxattr _DEPRECATED_;
smbc_getxattr_fn getxattr _DEPRECATED_;
smbc_removexattr_fn removexattr _DEPRECATED_;
smbc_listxattr_fn listxattr _DEPRECATED_;
/* Printing-related functions */
struct
{
smbc_print_file_fn print_file_fn;
smbc_open_print_job_fn open_print_job_fn;
smbc_list_print_jobs_fn list_print_jobs_fn;
smbc_unlink_print_job_fn unlink_print_job_fn;
} printing;
smbc_print_file_fn print_file _DEPRECATED_;
smbc_open_print_job_fn open_print_job _DEPRECATED_;
smbc_list_print_jobs_fn list_print_jobs _DEPRECATED_;
smbc_unlink_print_job_fn unlink_print_job _DEPRECATED_;
/*
** Callbacks
* These callbacks _always_ have to be initialized because they will
* not be checked at dereference for increased speed.
*
* DEPRECATED:
*
* See the comment above each field, for the getter and setter
* functions that should now be used.
*/
struct
struct _smbc_callbacks
{
/**
* authentication function callback: called upon auth requests
*
* Manually setting/retrieving this value is deprecated.
* DEPRECATED:
* Use smbc_getFunctionAuthData(), smbc_setFunctionAuthData()
*/
smbc_get_auth_data_fn get_auth_data_fn;
smbc_get_auth_data_fn auth_fn _DEPRECATED_;
/**
* check if a server is still good
*
* Manually setting/retrieving this value is deprecated.
* DEPRECATED:
* Use smbc_getFunctionCheckServer(),
* smbc_setFunctionCheckServer()
*/
smbc_check_server_fn check_server_fn;
smbc_check_server_fn check_server_fn _DEPRECATED_;
/**
* remove a server if unused
*
* Manually setting/retrieving this value is deprecated.
* DEPRECATED:
* Use smbc_getFunctionRemoveUnusedServer(),
* smbc_setFunctionCheckServer()
*/
smbc_remove_unused_server_fn remove_unused_server_fn;
} server;
smbc_remove_unused_server_fn remove_unused_server_fn _DEPRECATED_;
struct
{
/** Cache subsystem
*
* For an example cache system see
@ -2728,53 +2726,53 @@ struct _SMBCCTX {
/**
* server cache addition
*
* Manually setting/retrieving this value is deprecated.
* DEPRECATED:
* Use smbc_getFunctionAddCachedServer(),
* smbc_setFunctionAddCachedServer()
*/
smbc_add_cached_srv_fn add_cached_server_fn;
smbc_add_cached_srv_fn add_cached_srv_fn _DEPRECATED_;
/**
* server cache lookup
*
* Manually setting/retrieving this value is deprecated.
* DEPRECATED:
* Use smbc_getFunctionGetCachedServer(),
* smbc_setFunctionGetCachedServer()
*/
smbc_get_cached_srv_fn get_cached_server_fn;
smbc_get_cached_srv_fn get_cached_srv_fn _DEPRECATED_;
/**
* server cache removal
*
* Manually setting/retrieving this value is deprecated.
* DEPRECATED:
* Use smbc_getFunctionRemoveCachedServer(),
* smbc_setFunctionRemoveCachedServer()
*/
smbc_remove_cached_srv_fn remove_cached_server_fn;
smbc_remove_cached_srv_fn remove_cached_srv_fn _DEPRECATED_;
/**
* server cache purging, try to remove all cached servers
* (disconnect)
*
* Manually setting/retrieving this value is deprecated.
* DEPRECATED:
* Use smbc_getFunctionPurgeCachedServers(),
* smbc_setFunctionPurgeCachedServers()
*/
smbc_purge_cached_srv_fn purge_cached_servers_fn;
smbc_purge_cached_fn purge_cached_fn _DEPRECATED_;
} callbacks;
/**
* Space to store private data of the server cache.
*
* Manually setting/retrieving this value is deprecated.
* Use smbc_getServerCacheData(), smbc_setServerCacheData()
*/
struct smbc_server_cache * server_cache_data;
} cache;
/**
* Space where the private data of the server cache used to be
*
* DEPRECATED:
* Use smbc_getServerCacheData(), smbc_setServerCacheData()
*/
void * reserved; /* space where server_cache_data used to be */
/*
* Very old configuration options.
*
* Manually setting/retrieving this value is deprecated.
* DEPRECATED:
* Use one of the following functions instead:
* smbc_setOptionUseKerberos()
* smbc_getOptionUseKerberos()
@ -2783,24 +2781,21 @@ struct _SMBCCTX {
* smbc_setOptionNoAutoAnonymousLogin()
* smbc_getOptionNoAutoAnonymousLogin()
*/
struct
{
int bits;
} flags;
int flags _DEPRECATED_;
/** user options selections that apply to this session
/**
* user options selections that apply to this session
*
* NEW CODE SHOULD NOT DIRECTLY MANIPULATE THE CONTEXT STRUCTURE.
* NEW OPTIONS ARE NOT ADDED HERE!
*
* NEW OPTIONS ARE NOT ADDED HERE!
*
* To set and retrieve options, use the smbc_setOption*() and
* smbc_getOption*() functions.
* DEPRECATED:
* To set and retrieve options, use the smbc_setOption*() and
* smbc_getOption*() functions.
*/
struct _smbc_options {
int browse_max_lmb_count;
int urlencode_readdir_entries;
int one_share_per_server;
int browse_max_lmb_count _DEPRECATED_;
int urlencode_readdir_entries _DEPRECATED_;
int one_share_per_server _DEPRECATED_;
} options;
/** INTERNAL DATA

View File

@ -88,7 +88,7 @@ SMBC_add_cached_server(SMBCCTX * context,
goto failed;
}
DLIST_ADD((context->cache.server_cache_data), srvcache);
DLIST_ADD(context->internal->server_cache, srvcache);
return 0;
failed:
@ -118,7 +118,7 @@ SMBC_get_cached_server(SMBCCTX * context,
struct smbc_server_cache * srv = NULL;
/* Search the cache lines */
for (srv = context->cache.server_cache_data; srv; srv = srv->next) {
for (srv = context->internal->server_cache; srv; srv = srv->next) {
if (strcmp(server,srv->server_name) == 0 &&
strcmp(workgroup,srv->workgroup) == 0 &&
@ -150,7 +150,7 @@ SMBC_get_cached_server(SMBCCTX * context,
* a connection to the server (other than the
* attribute server connection) is cool.
*/
if (context->options.one_share_per_server) {
if (smbc_getOptionOneSharePerServer(context)) {
/*
* The currently connected share name
* doesn't match the requested share, so
@ -160,7 +160,7 @@ SMBC_get_cached_server(SMBCCTX * context,
/* Sigh. Couldn't disconnect. */
cli_shutdown(srv->server->cli);
srv->server->cli = NULL;
context->cache.remove_cached_server_fn(context, srv->server);
smbc_getFunctionRemoveCachedServer(context)(context, srv->server);
continue;
}
@ -175,7 +175,7 @@ SMBC_get_cached_server(SMBCCTX * context,
/* Out of memory. */
cli_shutdown(srv->server->cli);
srv->server->cli = NULL;
context->cache.remove_cached_server_fn(context, srv->server);
smbc_getFunctionRemoveCachedServer(context)(context, srv->server);
continue;
}
@ -200,11 +200,11 @@ SMBC_remove_cached_server(SMBCCTX * context,
{
struct smbc_server_cache * srv = NULL;
for (srv = context->cache.server_cache_data; srv; srv = srv->next) {
for (srv = context->internal->server_cache; srv; srv = srv->next) {
if (server == srv->server) {
/* remove this sucker */
DLIST_REMOVE(context->cache.server_cache_data, srv);
DLIST_REMOVE(context->internal->server_cache, srv);
SAFE_FREE(srv->server_name);
SAFE_FREE(srv->share_name);
SAFE_FREE(srv->workgroup);
@ -229,7 +229,7 @@ SMBC_purge_cached_servers(SMBCCTX * context)
struct smbc_server_cache * next;
int could_not_purge_all = 0;
for (srv = context->cache.server_cache_data,
for (srv = context->internal->server_cache,
next = (srv ? srv->next :NULL);
srv;
srv = next,

File diff suppressed because it is too large Load Diff

View File

@ -404,7 +404,7 @@ SMBC_opendir_ctx(SMBCCTX *context,
}
if (!user || user[0] == (char)0) {
user = talloc_strdup(frame, context->config.user);
user = talloc_strdup(frame, smbc_getUser(context));
if (!user) {
errno = ENOMEM;
TALLOC_FREE(frame);
@ -450,9 +450,9 @@ SMBC_opendir_ctx(SMBCCTX *context,
}
/* Determine how many local master browsers to query */
max_lmb_count = (context->options.browse_max_lmb_count == 0
max_lmb_count = (smbc_getOptionBrowseMaxLmbCount(context) == 0
? INT_MAX
: context->options.browse_max_lmb_count);
: smbc_getOptionBrowseMaxLmbCount(context));
memset(&u_info, '\0', sizeof(u_info));
u_info.username = talloc_strdup(frame,user);
@ -810,11 +810,11 @@ SMBC_opendir_ctx(SMBCCTX *context,
* good any more...
*/
if (cli_is_error(targetcli) &&
(context->server.check_server_fn)(context, srv)) {
smbc_getFunctionCheckServer(context)(context, srv)) {
/* ... then remove it. */
if ((context->server.remove_unused_server_fn)(context,
srv)) {
if (smbc_getFunctionRemoveUnusedServer(context)(context,
srv)) {
/*
* We could not remove the
* server completely, remove
@ -823,7 +823,7 @@ SMBC_opendir_ctx(SMBCCTX *context,
* will be removed when the
* last file/dir is closed.
*/
(context->cache.remove_cached_server_fn)(context, srv);
smbc_getFunctionRemoveCachedServer(context)(context, srv);
}
}
@ -884,7 +884,7 @@ smbc_readdir_internal(SMBCCTX * context,
struct smbc_dirent *src,
int max_namebuf_len)
{
if (context->options.urlencode_readdir_entries) {
if (smbc_getOptionUrlEncodeReaddirEntries(context)) {
/* url-encode the name. get back remaining buffer space */
max_namebuf_len =
@ -1142,7 +1142,7 @@ SMBC_mkdir_ctx(SMBCCTX *context,
}
if (!user || user[0] == (char)0) {
user = talloc_strdup(frame, context->config.user);
user = talloc_strdup(frame, smbc_getUser(context));
if (!user) {
errno = ENOMEM;
TALLOC_FREE(frame);
@ -1249,7 +1249,7 @@ SMBC_rmdir_ctx(SMBCCTX *context,
}
if (!user || user[0] == (char)0) {
user = talloc_strdup(frame, context->config.user);
user = talloc_strdup(frame, smbc_getUser(context));
if (!user) {
errno = ENOMEM;
TALLOC_FREE(frame);
@ -1531,7 +1531,7 @@ SMBC_chmod_ctx(SMBCCTX *context,
}
if (!user || user[0] == (char)0) {
user = talloc_strdup(frame, context->config.user);
user = talloc_strdup(frame, smbc_getUser(context));
if (!user) {
errno = ENOMEM;
TALLOC_FREE(frame);
@ -1637,7 +1637,7 @@ SMBC_utimes_ctx(SMBCCTX *context,
}
if (!user || user[0] == (char)0) {
user = talloc_strdup(frame, context->config.user);
user = talloc_strdup(frame, smbc_getUser(context));
if (!user) {
errno = ENOMEM;
TALLOC_FREE(frame);
@ -1713,7 +1713,7 @@ SMBC_unlink_ctx(SMBCCTX *context,
}
if (!user || user[0] == (char)0) {
user = talloc_strdup(frame, context->config.user);
user = talloc_strdup(frame, smbc_getUser(context));
if (!user) {
errno = ENOMEM;
TALLOC_FREE(frame);
@ -1848,7 +1848,7 @@ SMBC_rename_ctx(SMBCCTX *ocontext,
}
if (!user1 || user1[0] == (char)0) {
user1 = talloc_strdup(frame, ocontext->config.user);
user1 = talloc_strdup(frame, smbc_getUser(ocontext));
if (!user1) {
errno = ENOMEM;
TALLOC_FREE(frame);
@ -1872,7 +1872,7 @@ SMBC_rename_ctx(SMBCCTX *ocontext,
}
if (!user2 || user2[0] == (char)0) {
user2 = talloc_strdup(frame, ncontext->config.user);
user2 = talloc_strdup(frame, smbc_getUser(ncontext));
if (!user2) {
errno = ENOMEM;
TALLOC_FREE(frame);

View File

@ -82,7 +82,7 @@ SMBC_open_ctx(SMBCCTX *context,
}
if (!user || user[0] == (char)0) {
user = talloc_strdup(frame, context->config.user);
user = talloc_strdup(frame, smbc_getUser(context));
if (!user) {
errno = ENOMEM;
TALLOC_FREE(frame);
@ -188,7 +188,7 @@ SMBC_open_ctx(SMBCCTX *context,
int eno = 0;
eno = SMBC_errno(context, srv->cli);
file = (context->posix_emu.opendir_fn)(context, fname);
file = smbc_getFunctionOpendir(context)(context, fname);
if (!file) errno = eno;
TALLOC_FREE(frame);
return file;
@ -439,7 +439,7 @@ SMBC_close_ctx(SMBCCTX *context,
/* IS a dir ... */
if (!file->file) {
TALLOC_FREE(frame);
return (context->posix_emu.closedir_fn)(context, file);
return smbc_getFunctionClosedir(context)(context, file);
}
/*d_printf(">>>close: parsing %s\n", file->fname);*/
@ -478,7 +478,7 @@ SMBC_close_ctx(SMBCCTX *context,
DLIST_REMOVE(context->internal->files, file);
SAFE_FREE(file->fname);
SAFE_FREE(file);
(context->server.remove_unused_server_fn)(context, srv);
smbc_getFunctionRemoveUnusedServer(context)(context, srv);
TALLOC_FREE(frame);
return -1;

View File

@ -253,7 +253,7 @@ SMBC_parse_path(TALLOC_CTX *ctx,
*/
if (pp_workgroup != NULL) {
*pp_workgroup =
talloc_strdup(ctx, context->config.workgroup);
talloc_strdup(ctx, smbc_getWorkgroup(context));
}
if (pp_options) {
@ -297,13 +297,13 @@ SMBC_parse_path(TALLOC_CTX *ctx,
}
if (*p == '/') {
int wl = strlen(context->config.workgroup);
int wl = strlen(smbc_getWorkgroup(context));
if (wl > 16) {
wl = 16;
}
*pp_server = talloc_strdup(ctx, context->config.workgroup);
*pp_server = talloc_strdup(ctx, smbc_getWorkgroup(context));
if (!*pp_server) {
return -1;
}

View File

@ -75,7 +75,7 @@ SMBC_open_print_job_ctx(SMBCCTX *context,
/* What if the path is empty, or the file exists? */
TALLOC_FREE(frame);
return (context->posix_emu.open_fn)(context, fname, O_WRONLY, 666);
return smbc_getFunctionOpen(context)(context, fname, O_WRONLY, 666);
}
/*
@ -222,7 +222,7 @@ SMBC_list_print_jobs_ctx(SMBCCTX *context,
}
if (!user || user[0] == (char)0) {
user = talloc_strdup(frame, context->config.user);
user = talloc_strdup(frame, smbc_getUser(context));
if (!user) {
errno = ENOMEM;
TALLOC_FREE(frame);
@ -300,7 +300,7 @@ SMBC_unlink_print_job_ctx(SMBCCTX *context,
}
if (!user || user[0] == (char)0) {
user = talloc_strdup(frame, context->config.user);
user = talloc_strdup(frame, smbc_getUser(context));
if (!user) {
errno = ENOMEM;
TALLOC_FREE(frame);

View File

@ -80,7 +80,7 @@ SMBC_remove_unused_server(SMBCCTX * context,
DEBUG(3, ("smbc_remove_usused_server: %p removed.\n", srv));
(context->cache.remove_cached_server_fn)(context, srv);
smbc_getFunctionRemoveCachedServer(context)(context, srv);
SAFE_FREE(srv);
return 0;
@ -106,11 +106,10 @@ SMBC_call_auth_fn(TALLOC_CTX *ctx,
strlcpy(username, *pp_username, sizeof(username));
strlcpy(password, *pp_password, sizeof(password));
(context->server.get_auth_data_fn)(
server, share,
workgroup, sizeof(workgroup),
username, sizeof(username),
password, sizeof(password));
smbc_getFunctionAuthData(context)(server, share,
workgroup, sizeof(workgroup),
username, sizeof(username),
password, sizeof(password));
TALLOC_FREE(*pp_workgroup);
TALLOC_FREE(*pp_username);
@ -147,10 +146,10 @@ SMBC_find_server(TALLOC_CTX *ctx,
check_server_cache:
srv = (context->cache.get_cached_server_fn)(context,
server, share,
*pp_workgroup,
*pp_username);
srv = smbc_getFunctionGetCachedServer(context)(context,
server, share,
*pp_workgroup,
*pp_username);
if (!auth_called && !srv && (!*pp_username || !(*pp_username)[0] ||
!*pp_password || !(*pp_password)[0])) {
@ -172,22 +171,22 @@ check_server_cache:
}
if (srv) {
if ((context->server.check_server_fn)(context, srv)) {
if (smbc_getFunctionCheckServer(context)(context, srv)) {
/*
* This server is no good anymore
* Try to remove it and check for more possible
* servers in the cache
*/
if ((context->server.remove_unused_server_fn)(context,
srv)) {
if (smbc_getFunctionRemoveUnusedServer(context)(context,
srv)) {
/*
* We could not remove the server completely,
* remove it from the cache so we will not get
* it again. It will be removed when the last
* file/dir is closed.
*/
(context->cache.remove_cached_server_fn)(context,
srv);
smbc_getFunctionRemoveCachedServer(context)(context,
srv);
}
/*
@ -251,12 +250,14 @@ SMBC_server(TALLOC_CTX *ctx,
* If we found a connection and we're only allowed one share per
* server...
*/
if (srv && *share != '\0' && context->options.one_share_per_server) {
if (srv &&
*share != '\0' &&
smbc_getOptionOneSharePerServer(context)) {
/*
* ... then if there's no current connection to the share,
* connect to it. SMBC_find_server(), or rather the function
* pointed to by context->cache.get_cached_srv_fn which
* pointed to by context->get_cached_srv_fn which
* was called by SMBC_find_server(), will have issued a tree
* disconnect if the requested share is not the same as the
* one that was already connected.
@ -272,8 +273,8 @@ SMBC_server(TALLOC_CTX *ctx,
errno = ENOMEM;
cli_shutdown(srv->cli);
srv->cli = NULL;
(context->cache.remove_cached_server_fn)(context,
srv);
smbc_getFunctionRemoveCachedServer(context)(context,
srv);
return NULL;
}
@ -290,8 +291,8 @@ SMBC_server(TALLOC_CTX *ctx,
errno = SMBC_errno(context, srv->cli);
cli_shutdown(srv->cli);
srv->cli = NULL;
(context->cache.remove_cached_server_fn)(context,
srv);
smbc_getFunctionRemoveCachedServer(context)(context,
srv);
srv = NULL;
}
@ -324,7 +325,7 @@ SMBC_server(TALLOC_CTX *ctx,
return NULL;
}
make_nmb_name(&calling, context->config.netbios_name, 0x0);
make_nmb_name(&calling, smbc_getNetbiosName(context), 0x0);
make_nmb_name(&called , server, 0x20);
DEBUG(4,("SMBC_server: server_n=[%s] server=[%s]\n", server_n, server));
@ -341,14 +342,15 @@ again:
return NULL;
}
if (context->flags.bits & SMB_CTX_FLAG_USE_KERBEROS) {
if (smbc_getOptionUseKerberos(context)) {
c->use_kerberos = True;
}
if (context->flags.bits & SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS) {
if (smbc_getOptionFallbackAfterKerberos(context)) {
c->fallback_after_kerberos = True;
}
c->timeout = context->config.timeout;
c->timeout = smbc_getTimeout(context);
/*
* Force use of port 139 for first try if share is $IPC, empty, or
@ -435,8 +437,7 @@ again:
/* Failed. Try an anonymous login, if allowed by flags. */
username_used = "";
if ((context->flags.bits &
SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON) ||
if (smbc_getOptionNoAutoAnonymousLogin(context) ||
!NT_STATUS_IS_OK(cli_session_setup(c, username_used,
*pp_password, 1,
*pp_password, 0,
@ -504,10 +505,10 @@ again:
/* now add it to the cache (internal or external) */
/* Let the cache function set errno if it wants to */
errno = 0;
if ((context->cache.add_cached_server_fn)(context, srv,
server, share,
*pp_workgroup,
*pp_username)) {
if (smbc_getFunctionAddCachedServer(context)(context, srv,
server, share,
*pp_workgroup,
*pp_username)) {
int saved_errno = errno;
DEBUG(3, (" Failed to add server to cache\n"));
errno = saved_errno;
@ -576,7 +577,7 @@ SMBC_attr_server(TALLOC_CTX *ctx,
}
flags = 0;
if (context->flags.bits & SMB_CTX_FLAG_USE_KERBEROS) {
if (smbc_getOptionUseKerberos(context)) {
flags |= CLI_FULL_CONNECTION_USE_KERBEROS;
}
@ -664,11 +665,11 @@ SMBC_attr_server(TALLOC_CTX *ctx,
/* now add it to the cache (internal or external) */
errno = 0; /* let cache function set errno if it likes */
if ((context->cache.add_cached_server_fn)(context, ipc_srv,
server,
"*IPC$",
*pp_workgroup,
*pp_username)) {
if (smbc_getFunctionAddCachedServer(context)(context, ipc_srv,
server,
"*IPC$",
*pp_workgroup,
*pp_username)) {
DEBUG(3, (" Failed to add server to cache\n"));
if (errno == 0) {
errno = ENOMEM;

View File

@ -0,0 +1,905 @@
/*
Unix SMB/Netbios implementation.
SMB client library implementation
Copyright (C) Andrew Tridgell 1998
Copyright (C) Richard Sharpe 2000, 2002
Copyright (C) John Terpstra 2000
Copyright (C) Tom Jansen (Ninja ISD) 2002
Copyright (C) Derrell Lipman 2003-2008
Copyright (C) Jeremy Allison 2007, 2008
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
#define __LIBSMBCLIENT_INTERNAL__
#include "libsmbclient.h"
#include "libsmb_internal.h"
/** Get the netbios name used for making connections */
char *
smbc_getNetbiosName(SMBCCTX *c)
{
return c->netbios_name;
}
/** Set the netbios name used for making connections */
void
smbc_setNetbiosName(SMBCCTX *c, char * netbios_name)
{
c->netbios_name = netbios_name;
}
/** Get the workgroup used for making connections */
char *
smbc_getWorkgroup(SMBCCTX *c)
{
return c->workgroup;
}
/** Set the workgroup used for making connections */
void
smbc_setWorkgroup(SMBCCTX *c, char * workgroup)
{
c->workgroup = workgroup;
}
/** Get the username used for making connections */
char *
smbc_getUser(SMBCCTX *c)
{
return c->user;
}
/** Set the username used for making connections */
void
smbc_setUser(SMBCCTX *c, char * user)
{
c->user = user;
}
/** Get the debug level */
int
smbc_getDebug(SMBCCTX *c)
{
return c->debug;
}
/** Set the debug level */
void
smbc_setDebug(SMBCCTX *c, int debug)
{
c->debug = debug;
DEBUGLEVEL = debug;
}
/**
* Get the timeout used for waiting on connections and response data
* (in milliseconds)
*/
int
smbc_getTimeout(SMBCCTX *c)
{
return c->timeout;
}
/**
* Set the timeout used for waiting on connections and response data
* (in milliseconds)
*/
void
smbc_setTimeout(SMBCCTX *c, int timeout)
{
c->timeout = timeout;
}
/** Get whether to log to standard error instead of standard output */
smbc_bool
smbc_getOptionDebugToStderr(SMBCCTX *c)
{
return c->internal->debug_stderr;
}
/** Set whether to log to standard error instead of standard output */
void
smbc_setOptionDebugToStderr(SMBCCTX *c, smbc_bool b)
{
c->internal->debug_stderr = b;
}
/**
* Get whether to use new-style time attribute names, e.g. WRITE_TIME rather
* than the old-style names such as M_TIME. This allows also setting/getting
* CREATE_TIME which was previously unimplemented. (Note that the old C_TIME
* was supposed to be CHANGE_TIME but was confused and sometimes referred to
* CREATE_TIME.)
*/
smbc_bool
smbc_getOptionFullTimeNames(SMBCCTX *c)
{
return c->internal->full_time_names;
}
/**
* Set whether to use new-style time attribute names, e.g. WRITE_TIME rather
* than the old-style names such as M_TIME. This allows also setting/getting
* CREATE_TIME which was previously unimplemented. (Note that the old C_TIME
* was supposed to be CHANGE_TIME but was confused and sometimes referred to
* CREATE_TIME.)
*/
void
smbc_setOptionFullTimeNames(SMBCCTX *c, smbc_bool b)
{
c->internal->full_time_names = b;
}
/**
* Get the share mode to use for files opened with SMBC_open_ctx(). The
* default is SMBC_SHAREMODE_DENY_NONE.
*/
smbc_share_mode
smbc_getOptionOpenShareMode(SMBCCTX *c)
{
return c->internal->share_mode;
}
/**
* Set the share mode to use for files opened with SMBC_open_ctx(). The
* default is SMBC_SHAREMODE_DENY_NONE.
*/
void
smbc_setOptionOpenShareMode(SMBCCTX *c, smbc_share_mode share_mode)
{
c->internal->share_mode = share_mode;
}
/** Retrieve a previously set user data handle */
void *
smbc_getOptionUserData(SMBCCTX *c)
{
return c->internal->user_data;
}
/** Save a user data handle */
void
smbc_setOptionUserData(SMBCCTX *c, void *user_data)
{
c->internal->user_data = user_data;
}
/** Get the encoded value for encryption level. */
smbc_smb_encrypt_level
smbc_getOptionSmbEncryptionLevel(SMBCCTX *c)
{
return c->internal->smb_encryption_level;
}
/** Set the encoded value for encryption level. */
void
smbc_setOptionSmbEncryptionLevel(SMBCCTX *c, smbc_smb_encrypt_level level)
{
c->internal->smb_encryption_level = level;
}
/**
* 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
* local master browser, for it to have the entire browse list (the list of
* workgroups/domains) from an entire network. Since a client never knows
* which local master browser will be found first, the one which is found
* first and used to retrieve a browse list may have an incomplete or empty
* browse list. By requesting the browse list from multiple local master
* browsers, a more complete list can be generated. For small networks (few
* workgroups), it is recommended that this value be set to 0, causing the
* browse lists from all found local master browsers to be retrieved and
* merged. For networks with many workgroups, a suitable value for this
* variable is probably somewhere around 3. (Default: 3).
*/
int
smbc_getOptionBrowseMaxLmbCount(SMBCCTX *c)
{
return c->options.browse_max_lmb_count;
}
/**
* Set 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
* local master browser, for it to have the entire browse list (the list of
* workgroups/domains) from an entire network. Since a client never knows
* which local master browser will be found first, the one which is found
* first and used to retrieve a browse list may have an incomplete or empty
* browse list. By requesting the browse list from multiple local master
* browsers, a more complete list can be generated. For small networks (few
* workgroups), it is recommended that this value be set to 0, causing the
* browse lists from all found local master browsers to be retrieved and
* merged. For networks with many workgroups, a suitable value for this
* variable is probably somewhere around 3. (Default: 3).
*/
void
smbc_setOptionBrowseMaxLmbCount(SMBCCTX *c, int count)
{
c->options.browse_max_lmb_count = count;
}
/**
* Get whether to url-encode readdir entries.
*
* There is a difference in the desired return strings from
* smbc_readdir() depending upon whether the filenames are to
* be displayed to the user, or whether they are to be
* appended to the path name passed to smbc_opendir() to call
* a further smbc_ function (e.g. open the file with
* smbc_open()). In the former case, the filename should be
* in "human readable" form. In the latter case, the smbc_
* functions expect a URL which must be url-encoded. Those
* functions decode the URL. If, for example, smbc_readdir()
* returned a file name of "abc%20def.txt", passing a path
* with this file name attached to smbc_open() would cause
* smbc_open to attempt to open the file "abc def.txt" since
* the %20 is decoded into a space.
*
* Set this option to True if the names returned by
* smbc_readdir() should be url-encoded such that they can be
* passed back to another smbc_ call. Set it to False if the
* names returned by smbc_readdir() are to be presented to the
* user.
*
* For backwards compatibility, this option defaults to False.
*/
smbc_bool
smbc_getOptionUrlEncodeReaddirEntries(SMBCCTX *c)
{
return c->options.urlencode_readdir_entries;
}
/**
* Set whether to url-encode readdir entries.
*
* There is a difference in the desired return strings from
* smbc_readdir() depending upon whether the filenames are to
* be displayed to the user, or whether they are to be
* appended to the path name passed to smbc_opendir() to call
* a further smbc_ function (e.g. open the file with
* smbc_open()). In the former case, the filename should be
* in "human readable" form. In the latter case, the smbc_
* functions expect a URL which must be url-encoded. Those
* functions decode the URL. If, for example, smbc_readdir()
* returned a file name of "abc%20def.txt", passing a path
* with this file name attached to smbc_open() would cause
* smbc_open to attempt to open the file "abc def.txt" since
* the %20 is decoded into a space.
*
* Set this option to True if the names returned by
* smbc_readdir() should be url-encoded such that they can be
* passed back to another smbc_ call. Set it to False if the
* names returned by smbc_readdir() are to be presented to the
* user.
*
* For backwards compatibility, this option defaults to False.
*/
void
smbc_setOptionUrlEncodeReaddirEntries(SMBCCTX *c, smbc_bool b)
{
c->options.urlencode_readdir_entries = b;
}
/**
* Get whether to use the same connection for all shares on a server.
*
* Some Windows versions appear to have a limit to the number
* of concurrent SESSIONs and/or TREE CONNECTions. In
* one-shot programs (i.e. the program runs and then quickly
* ends, thereby shutting down all connections), it is
* probably reasonable to establish a new connection for each
* share. In long-running applications, the limitation can be
* avoided by using only a single connection to each server,
* and issuing a new TREE CONNECT when the share is accessed.
*/
smbc_bool
smbc_getOptionOneSharePerServer(SMBCCTX *c)
{
return c->options.one_share_per_server;
}
/**
* Set whether to use the same connection for all shares on a server.
*
* Some Windows versions appear to have a limit to the number
* of concurrent SESSIONs and/or TREE CONNECTions. In
* one-shot programs (i.e. the program runs and then quickly
* ends, thereby shutting down all connections), it is
* probably reasonable to establish a new connection for each
* share. In long-running applications, the limitation can be
* avoided by using only a single connection to each server,
* and issuing a new TREE CONNECT when the share is accessed.
*/
void
smbc_setOptionOneSharePerServer(SMBCCTX *c, smbc_bool b)
{
c->options.one_share_per_server = b;
}
/** Get whether to enable use of kerberos */
smbc_bool
smbc_getOptionUseKerberos(SMBCCTX *c)
{
return c->flags & SMB_CTX_FLAG_USE_KERBEROS ? True : False;
}
/** Set whether to enable use of kerberos */
void
smbc_setOptionUseKerberos(SMBCCTX *c, smbc_bool b)
{
if (b) {
c->flags |= SMB_CTX_FLAG_USE_KERBEROS;
} else {
c->flags &= ~SMB_CTX_FLAG_USE_KERBEROS;
}
}
/** Get whether to fallback after kerberos */
smbc_bool
smbc_getOptionFallbackAfterKerberos(SMBCCTX *c)
{
return c->flags & SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS ? True : False;
}
/** Set whether to fallback after kerberos */
void
smbc_setOptionFallbackAfterKerberos(SMBCCTX *c, smbc_bool b)
{
if (b) {
c->flags |= SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS;
} else {
c->flags &= ~SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS;
}
}
/** Get whether to automatically select anonymous login */
smbc_bool
smbc_getOptionNoAutoAnonymousLogin(SMBCCTX *c)
{
return c->flags & SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON ? True : False;
}
/** Set whether to automatically select anonymous login */
void
smbc_setOptionNoAutoAnonymousLogin(SMBCCTX *c, smbc_bool b)
{
if (b) {
c->flags |= SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON;
} else {
c->flags &= ~SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON;
}
}
/** Get the function for obtaining authentication data */
smbc_get_auth_data_fn
smbc_getFunctionAuthData(SMBCCTX *c)
{
return c->callbacks.auth_fn;
}
/** Set the function for obtaining authentication data */
void
smbc_setFunctionAuthData(SMBCCTX *c, smbc_get_auth_data_fn fn)
{
c->internal->auth_fn_with_context = NULL;
c->callbacks.auth_fn = fn;
}
/** Get the new-style authentication function which includes the context. */
smbc_get_auth_data_with_context_fn
smbc_getFunctionAuthDataWithContext(SMBCCTX *c)
{
return c->internal->auth_fn_with_context;
}
/** Set the new-style authentication function which includes the context. */
void
smbc_setFunctionAuthDataWithContext(SMBCCTX *c,
smbc_get_auth_data_with_context_fn fn)
{
c->callbacks.auth_fn = NULL;
c->internal->auth_fn_with_context = fn;
}
/** Get the function for checking if a server is still good */
smbc_check_server_fn
smbc_getFunctionCheckServer(SMBCCTX *c)
{
return c->callbacks.check_server_fn;
}
/** Set the function for checking if a server is still good */
void
smbc_setFunctionCheckServer(SMBCCTX *c, smbc_check_server_fn fn)
{
c->callbacks.check_server_fn = fn;
}
/** Get the function for removing a server if unused */
smbc_remove_unused_server_fn
smbc_getFunctionRemoveUnusedServer(SMBCCTX *c)
{
return c->callbacks.remove_unused_server_fn;
}
/** Set the function for removing a server if unused */
void
smbc_setFunctionRemoveUnusedServer(SMBCCTX *c,
smbc_remove_unused_server_fn fn)
{
c->callbacks.remove_unused_server_fn = fn;
}
/** Get the function for adding a cached server */
smbc_add_cached_srv_fn
smbc_getFunctionAddCachedServer(SMBCCTX *c)
{
return c->callbacks.add_cached_srv_fn;
}
/** Set the function for adding a cached server */
void
smbc_setFunctionAddCachedServer(SMBCCTX *c, smbc_add_cached_srv_fn fn)
{
c->callbacks.add_cached_srv_fn = fn;
}
/** Get the function for server cache lookup */
smbc_get_cached_srv_fn
smbc_getFunctionGetCachedServer(SMBCCTX *c)
{
return c->callbacks.get_cached_srv_fn;
}
/** Set the function for server cache lookup */
void
smbc_setFunctionGetCachedServer(SMBCCTX *c, smbc_get_cached_srv_fn fn)
{
c->callbacks.get_cached_srv_fn = fn;
}
/** Get the function for server cache removal */
smbc_remove_cached_srv_fn
smbc_getFunctionRemoveCachedServer(SMBCCTX *c)
{
return c->callbacks.remove_cached_srv_fn;
}
/** Set the function for server cache removal */
void
smbc_setFunctionRemoveCachedServer(SMBCCTX *c,
smbc_remove_cached_srv_fn fn)
{
c->callbacks.remove_cached_srv_fn = fn;
}
/**
* Get the function for server cache purging. This function tries to
* remove all cached servers (e.g. on disconnect)
*/
smbc_purge_cached_fn
smbc_getFunctionPurgeCachedServers(SMBCCTX *c)
{
return c->callbacks.purge_cached_fn;
}
/** Set the function to store private data of the server cache */
void smbc_setServerCacheData(SMBCCTX *c, struct smbc_server_cache * cache)
{
c->internal->server_cache = cache;
}
/** Get the function to store private data of the server cache */
struct smbc_server_cache * smbc_getServerCacheData(SMBCCTX *c)
{
return c->internal->server_cache;
}
/**
* Set the function for server cache purging. This function tries to
* remove all cached servers (e.g. on disconnect)
*/
void
smbc_setFunctionPurgeCachedServers(SMBCCTX *c, smbc_purge_cached_fn fn)
{
c->callbacks.purge_cached_fn = fn;
}
/**
* Callable functions for files.
*/
smbc_open_fn
smbc_getFunctionOpen(SMBCCTX *c)
{
return c->open;
}
void
smbc_setFunctionOpen(SMBCCTX *c, smbc_open_fn fn)
{
c->open = fn;
}
smbc_creat_fn
smbc_getFunctionCreat(SMBCCTX *c)
{
return c->creat;
}
void
smbc_setFunctionCreat(SMBCCTX *c, smbc_creat_fn fn)
{
c->creat = fn;
}
smbc_read_fn
smbc_getFunctionRead(SMBCCTX *c)
{
return c->read;
}
void
smbc_setFunctionRead(SMBCCTX *c, smbc_read_fn fn)
{
c->read = fn;
}
smbc_write_fn
smbc_getFunctionWrite(SMBCCTX *c)
{
return c->write;
}
void
smbc_setFunctionWrite(SMBCCTX *c, smbc_write_fn fn)
{
c->write = fn;
}
smbc_unlink_fn
smbc_getFunctionUnlink(SMBCCTX *c)
{
return c->unlink;
}
void
smbc_setFunctionUnlink(SMBCCTX *c, smbc_unlink_fn fn)
{
c->unlink = fn;
}
smbc_rename_fn
smbc_getFunctionRename(SMBCCTX *c)
{
return c->rename;
}
void
smbc_setFunctionRename(SMBCCTX *c, smbc_rename_fn fn)
{
c->rename = fn;
}
smbc_lseek_fn
smbc_getFunctionLseek(SMBCCTX *c)
{
return c->lseek;
}
void
smbc_setFunctionLseek(SMBCCTX *c, smbc_lseek_fn fn)
{
c->lseek = fn;
}
smbc_stat_fn
smbc_getFunctionStat(SMBCCTX *c)
{
return c->stat;
}
void
smbc_setFunctionStat(SMBCCTX *c, smbc_stat_fn fn)
{
c->stat = fn;
}
smbc_fstat_fn
smbc_getFunctionFstat(SMBCCTX *c)
{
return c->fstat;
}
void
smbc_setFunctionFstat(SMBCCTX *c, smbc_fstat_fn fn)
{
c->fstat = fn;
}
smbc_ftruncate_fn
smbc_getFunctionFtruncate(SMBCCTX *c)
{
return c->internal->posix_emu.ftruncate_fn;
}
void
smbc_setFunctionFtruncate(SMBCCTX *c, smbc_ftruncate_fn fn)
{
c->internal->posix_emu.ftruncate_fn = fn;
}
smbc_close_fn
smbc_getFunctionClose(SMBCCTX *c)
{
return c->close_fn;
}
void
smbc_setFunctionClose(SMBCCTX *c, smbc_close_fn fn)
{
c->close_fn = fn;
}
/**
* Callable functions for directories.
*/
smbc_opendir_fn
smbc_getFunctionOpendir(SMBCCTX *c)
{
return c->opendir;
}
void
smbc_setFunctionOpendir(SMBCCTX *c, smbc_opendir_fn fn)
{
c->opendir = fn;
}
smbc_closedir_fn
smbc_getFunctionClosedir(SMBCCTX *c)
{
return c->closedir;
}
void
smbc_setFunctionClosedir(SMBCCTX *c, smbc_closedir_fn fn)
{
c->closedir = fn;
}
smbc_readdir_fn
smbc_getFunctionReaddir(SMBCCTX *c)
{
return c->readdir;
}
void
smbc_setFunctionReaddir(SMBCCTX *c, smbc_readdir_fn fn)
{
c->readdir = fn;
}
smbc_getdents_fn
smbc_getFunctionGetdents(SMBCCTX *c)
{
return c->getdents;
}
void
smbc_setFunctionGetdents(SMBCCTX *c, smbc_getdents_fn fn)
{
c->getdents = fn;
}
smbc_mkdir_fn
smbc_getFunctionMkdir(SMBCCTX *c)
{
return c->mkdir;
}
void
smbc_setFunctionMkdir(SMBCCTX *c, smbc_mkdir_fn fn)
{
c->mkdir = fn;
}
smbc_rmdir_fn
smbc_getFunctionRmdir(SMBCCTX *c)
{
return c->rmdir;
}
void
smbc_setFunctionRmdir(SMBCCTX *c, smbc_rmdir_fn fn)
{
c->rmdir = fn;
}
smbc_telldir_fn
smbc_getFunctionTelldir(SMBCCTX *c)
{
return c->telldir;
}
void
smbc_setFunctionTelldir(SMBCCTX *c, smbc_telldir_fn fn)
{
c->telldir = fn;
}
smbc_lseekdir_fn
smbc_getFunctionLseekdir(SMBCCTX *c)
{
return c->lseekdir;
}
void
smbc_setFunctionLseekdir(SMBCCTX *c, smbc_lseekdir_fn fn)
{
c->lseekdir = fn;
}
smbc_fstatdir_fn
smbc_getFunctionFstatdir(SMBCCTX *c)
{
return c->fstatdir;
}
void
smbc_setFunctionFstatdir(SMBCCTX *c, smbc_fstatdir_fn fn)
{
c->fstatdir = fn;
}
/**
* Callable functions applicable to both files and directories.
*/
smbc_chmod_fn
smbc_getFunctionChmod(SMBCCTX *c)
{
return c->chmod;
}
void
smbc_setFunctionChmod(SMBCCTX *c, smbc_chmod_fn fn)
{
c->chmod = fn;
}
smbc_utimes_fn
smbc_getFunctionUtimes(SMBCCTX *c)
{
return c->utimes;
}
void
smbc_setFunctionUtimes(SMBCCTX *c, smbc_utimes_fn fn)
{
c->utimes = fn;
}
smbc_setxattr_fn
smbc_getFunctionSetxattr(SMBCCTX *c)
{
return c->setxattr;
}
void
smbc_setFunctionSetxattr(SMBCCTX *c, smbc_setxattr_fn fn)
{
c->setxattr = fn;
}
smbc_getxattr_fn
smbc_getFunctionGetxattr(SMBCCTX *c)
{
return c->getxattr;
}
void
smbc_setFunctionGetxattr(SMBCCTX *c, smbc_getxattr_fn fn)
{
c->getxattr = fn;
}
smbc_removexattr_fn
smbc_getFunctionRemovexattr(SMBCCTX *c)
{
return c->removexattr;
}
void
smbc_setFunctionRemovexattr(SMBCCTX *c, smbc_removexattr_fn fn)
{
c->removexattr = fn;
}
smbc_listxattr_fn
smbc_getFunctionListxattr(SMBCCTX *c)
{
return c->listxattr;
}
void
smbc_setFunctionListxattr(SMBCCTX *c, smbc_listxattr_fn fn)
{
c->listxattr = fn;
}
/**
* Callable functions related to printing
*/
smbc_print_file_fn
smbc_getFunctionPrintFile(SMBCCTX *c)
{
return c->print_file;
}
void
smbc_setFunctionPrintFile(SMBCCTX *c, smbc_print_file_fn fn)
{
c->print_file = fn;
}
smbc_open_print_job_fn
smbc_getFunctionOpenPrintJob(SMBCCTX *c)
{
return c->open_print_job;
}
void
smbc_setFunctionOpenPrintJob(SMBCCTX *c,
smbc_open_print_job_fn fn)
{
c->open_print_job = fn;
}
smbc_list_print_jobs_fn
smbc_getFunctionListPrintJobs(SMBCCTX *c)
{
return c->list_print_jobs;
}
void
smbc_setFunctionListPrintJobs(SMBCCTX *c,
smbc_list_print_jobs_fn fn)
{
c->list_print_jobs = fn;
}
smbc_unlink_print_job_fn
smbc_getFunctionUnlinkPrintJob(SMBCCTX *c)
{
return c->unlink_print_job;
}
void
smbc_setFunctionUnlinkPrintJob(SMBCCTX *c,
smbc_unlink_print_job_fn fn)
{
c->unlink_print_job = fn;
}

View File

@ -157,7 +157,7 @@ SMBC_stat_ctx(SMBCCTX *context,
}
if (!user || user[0] == (char)0) {
user = talloc_strdup(frame,context->config.user);
user = talloc_strdup(frame, smbc_getUser(context));
if (!user) {
errno = ENOMEM;
TALLOC_FREE(frame);
@ -237,7 +237,7 @@ SMBC_fstat_ctx(SMBCCTX *context,
if (!file->file) {
TALLOC_FREE(frame);
return (context->posix_emu.fstatdir_fn)(context, file, st);
return smbc_getFunctionFstatdir(context)(context, file, st);
}
/*d_printf(">>>fstat: parsing %s\n", file->fname);*/

View File

@ -1729,7 +1729,7 @@ SMBC_setxattr_ctx(SMBCCTX *context,
}
if (!user || user[0] == (char)0) {
user = talloc_strdup(frame, context->config.user);
user = talloc_strdup(frame, smbc_getUser(context));
if (!user) {
errno = ENOMEM;
TALLOC_FREE(frame);
@ -2023,7 +2023,7 @@ SMBC_getxattr_ctx(SMBCCTX *context,
}
if (!user || user[0] == (char)0) {
user = talloc_strdup(frame, context->config.user);
user = talloc_strdup(frame, smbc_getUser(context));
if (!user) {
errno = ENOMEM;
TALLOC_FREE(frame);
@ -2157,7 +2157,7 @@ SMBC_removexattr_ctx(SMBCCTX *context,
}
if (!user || user[0] == (char)0) {
user = talloc_strdup(frame, context->config.user);
user = talloc_strdup(frame, smbc_getUser(context));
if (!user) {
errno = ENOMEM;
TALLOC_FREE(frame);