Daniel Stenberg <dan...@haxx.se> writes:

> On Mon, 23 Feb 2009, Simon Josefsson wrote:
>
>> const char *libssh2_check_version (int req_version_num);
>>
>> Which could be used by applications like this:
>>
>> if (!libssh2_check_version (LIBSSH2_VERSION_NUM)) {
>>  fprintf (stderr, "Runtime libssh2 version too old!\n");
>>  exit(1);
>> }
>
> Right, that's a neat approach that I like.
>
>> if (debug) {
>>  printf ("libssh2 %s\n", libssh2_check_version (0));
>> }
>>
>> And the string could look something like:
>>
>> "1.0.1-CVS/gnutls/libz"
>> "1.0.0/openssl"
>> "1.0.0/openssl/libz"
>
> Hm, I'm not entirely happy with that: I want to show the libssh2 version 
> number when used by an app. I'm not so sure I want that app to show or even 
> care about the openssl/libz situation there, even if I can think that in 
> other 
> situations the app or other users of libssh2 might care. Alas, I'd like to 
> get 
> the "1.0.0" separately from "openssl/gnutls/libz"...
>
> So what do you think about this:
>
>    const char *libssh2_version(int req_version_num, const char **extra);
>
> So if 'extra' isn't NULL, it gets set to a pointer with "openssl/libz" style 
> info and the function returns "1.0.1_CVS" ?
>
> It still makes it possible to do things like:
>
>    if (!libssh2_version(LIBSSH2_VERSION_NUM, NULL)) {
>      fprintf (stderr, "Runtime libssh2 version too old!\n");
>      exit(1);
>    }

Yup.  Or just skip the 'extra' parameter completely.  People who care
about that kind of details can run ldd on the application or library,
can't they?

The use-case I see for this function is the snippet above, to catch
runtime-vs-compiletime version mis-matches, and to print the version
number in debug messages.

/Simon

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
libssh2-devel mailing list
libssh2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libssh2-devel

Reply via email to