Proposal: libsmbclient API

Andreas Schneider mail at cynapses.org
Thu Mar 26 17:29:03 GMT 2009


On Thursday 26 March 2009 18:09:56 you wrote:
> If it's going to return a string, then how about just passing a string as
> the parameter? It's easy enough to parse, and that way the interface is
> consistent.
>

I would prefer an interger. It's easier to compare. I've implemented it in 
csync and libssh this way.

https://dev.csync.org/browser/src/csync.h

Take a look at line 40 - 52 for the macros.

Line 136-158 for the documentation and the prototype.

> > if (smbc_version(CSYNC_VERSION_INT(0,0,1) == NULL) {
> >         fprintf(stderr, "Runtime version of libsmbclient too old!\n");
> >   exit(1);
> > }
>
> CSYNC_VERSION_INT looks like a macro from some other package but I don't
> think I've ever seen it before. If the parameter does end up as a single
> integer, I'd think it'd make sense for there to be a SMBC_VERSION_INT
> macro.

Sorry, this was copy and paste from csync. Yes, the name should be SMBC.

The function could look like this.

/* Check if libsmbclient is the required version or get the version string. */
const char *smbc_version(int req_version) {
  if (req_version <= SMBC_VERSION_INT) {
    return SMBC_STRINGIFY(SMBC_VERSION);
  }

  return NULL;
}

You would be able to check the version if you load it with dlopen().


	-- andreas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://lists.samba.org/archive/samba-technical/attachments/20090326/14d2ee5e/attachment.bin


More information about the samba-technical mailing list