proposal: libsmbclient functionality addition

Richard Sharpe rsharpe at ns.aus.com
Wed Jun 19 08:32:25 GMT 2002


On Wed, 19 Jun 2002, Tom Jansen wrote:

> 
> > > o Will all smbc_* functions get the handle when called ?
> > 
> > Yes, they have to be given the file handle.
> > 
> > The major issue here is that this will break all existing programs. I
> > have spent some time trying to think of a way to avoid this breakage, but
> > fear that I cannot do it easily.
> 
> Ehm... I've given it some thought too and came up with the following:
> 
> smbc_set_client(struct smbc_handle * handle) 
> {
>   current_handle = handle;
> }
> 
> and make all the functions use current_handle as the handle.
> This way, all functions can stay nearly unmodified (and thus quite well tested).
> smbc_init will set current_handle to the last initialised one. Et Voila, binary
> compatability.
> 
> This makes "new" code using libsmbclient look like:
> 
> handle1 = smbc_init_handle(handle1 arguments);
> handle2 = smbc_init_handle(handle2 arguments);

OK, that looks good. Just make the existing smbc init the current handle 
as well ...
 
> /* open using client 1 */
> smbc_set_client(handle1);
> fd1 = smbc_open("smb://puter/share/file1.txt",mode);
> 
> /* open using client 1 */
> smbc_set_client(handle2);
> fd2 = smbc_open("smb://puter/share/file2.txt",mode);
> 
> /* read some (remember the global filetable) */
> smbc_read(fd1, buf1, 128);
> smbc_read(fd2, buf2, 64);
> 
> smbc_close(fd1); smbc_close(fd2);
> 
> 
> Furthermore, I think it is necessary to introduce another init function like the
> one suggested in the code example. Do you agree?

Yes, I agree ...

> Soem other point ... libsmbclient.c is quite large (2700 lines) am I allowed to
> move cache and connection handling to another file so libsmbclient.c only
> contains the functions that can be called by the "user" of libsmbclient ?

That is fine. Feel free.

> Yours,
>    Tom
> 

-- 
Regards
-----
Richard Sharpe, rsharpe at ns.aus.com, rsharpe at samba.org, 
sharpe at ethereal.com





More information about the samba-technical mailing list