Separating info out of the libsmbclient.h include file

Tom Jansen tom at ninja.nl
Sun Oct 20 19:15:01 GMT 2002


Hi Richard,

Richard Sharpe wrote:
> A problem has arrisen with libsmbclient in head, in that there is too much
> info exposed in libsmbclient.h.

Hmm... I agree. A little bloated indeed.

> I want to split it into two files, one exposing only the stuff that
> clients need, and the other containing internal stuff that libsmbclient
> needs itself.

That is a good idea but I'm not sure if it helps alot. The internal 
stuff is very limited. The API for libsmbclient is just really large. 
Maybe we can split it into more parts:
	o File IO: open/read/write/seek etc.
	o Dir IO: opendir/readdir/seekdir etc.
	o Printer IO: print_file/open_print_job etc.
	o Internal structures etc.

This would not remove any bloat but it should make it better 
maintainable (if that is a word).


> I have not had time over the last week or so, esp as I am travelling, to
> consider the implications of this. The area that concerns me is the fact
> that there is now a table of pointers in the smbc structure, and that
> clients might need access to this table of pointers.

All clients using the new API should be able to access the pointers as 
this is the new way to access functionality provided by libsmbclient.

Most of the cache handling stuff is already defined internally: 
libsmb_cache.c

There are a few things that could be moved out IMHO:

1) The stuff in the #ifdef _SMBC_INTERNAL

2) The details of the callback list. This can be accomplished by adding 
an interface like this:
smbc_set_callback(int type, void * callback);
with type:
enum type {
	SMBC_GET_AUTH_DATA,
	SMBC_PURGE_CACHE
	etc, etc,
}

Another idea:

Make wrapper functions just like the function pointers in the SMBCCTX 
struct to hide the actual pointers from the viewer. If we declare these 
inline, this will not be a performance hit. Example:

instead of smbcontext->open(smbcontext, filename, flags, mode)
we do: smbc_open_ctx(smbcontext, filename, flags, mode)

When I think of this; libsmbclient.c contains just these functions. 
Except for the fact that they are declared static they should do the 
trick. These functions are the only ones needed for operation of 
libsmbclient and they are in fact pointed to by the pointers in the 
SMBCCTX struct.

I remember someone objecting to making them non-static because of 
namespace polution but I'm not sure who that was. (please speak up if it 
was you, everyone!)


just a few ideas,

Tom

-- 
Tom Jansen -- tom at ninja.nl
Ninja ISD  -- www.ninja.nl




More information about the samba-technical mailing list