proposal: libsmbclient functionality addition

Tom Jansen tom at ninja.nl
Wed Jun 19 04:25:01 GMT 2002


> > 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);

/* 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?

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 ?

Yours,
   Tom





More information about the samba-technical mailing list