Index: includes/gnutls/extra.h =================================================================== RCS file: /cvs/gnutls/gnutls/includes/gnutls/extra.h,v retrieving revision 1.7 diff -u -u -r1.7 extra.h --- includes/gnutls/extra.h 1 Sep 2002 18:57:39 -0000 1.7 +++ includes/gnutls/extra.h 5 Oct 2002 07:41:05 -0000 @@ -25,6 +25,8 @@ #include +#define LIBGNUTLS_EXTRA_VERSION LIBGNUTLS_VERSION + /* SRP */ typedef struct DSTRUCT* gnutls_srp_server_credentials; @@ -87,6 +89,10 @@ int gnutls_certificate_set_openpgp_keyring_file( gnutls_certificate_credentials res, const char *name); int gnutls_global_init_extra(void); + +/* returns libgnutls-extra version (call it with a NULL argument) + */ +const char* gnutls_extra_check_version( const char*); /* Defines for compatibility with previous versions. */ Index: libextra/gnutls_extra.c =================================================================== RCS file: /cvs/gnutls/gnutls/libextra/gnutls_extra.c,v retrieving revision 1.5 diff -u -u -r1.5 gnutls_extra.c --- libextra/gnutls_extra.c 17 Sep 2002 17:57:59 -0000 1.5 +++ libextra/gnutls_extra.c 5 Oct 2002 07:41:11 -0000 @@ -138,7 +138,7 @@ return; } -const char* gnutls_check_version( const char*); +extern const char* gnutls_check_version( const char*); static int _gnutls_init_extra = 0; /** @@ -208,3 +208,78 @@ return 0; } + +/* Taken from libgcrypt. Needed to configure scripts. + */ + +static const char* +parse_version_number( const char *s, int *number ) +{ + int val = 0; + + if( *s == '0' && isdigit(s[1]) ) + return NULL; /* leading zeros are not allowed */ + for ( ; isdigit(*s); s++ ) { + val *= 10; + val += *s - '0'; + } + *number = val; + return val < 0? NULL : s; +} + +/* The parse version functions were copied from libgcrypt. + */ +static const char * +parse_version_string( const char *s, int *major, int *minor, int *micro ) +{ + s = parse_version_number( s, major ); + if( !s || *s != '.' ) + return NULL; + s++; + s = parse_version_number( s, minor ); + if( !s || *s != '.' ) + return NULL; + s++; + s = parse_version_number( s, micro ); + if( !s ) + return NULL; + return s; /* patchlevel */ +} + +/**************** + * Check that the the version of the library is at minimum the requested one + * and return the version string; return NULL if the condition is not + * satisfied. If a NULL is passed to this function, no check is done, + * but the version string is simply returned. + */ +const char * +gnutls_extra_check_version( const char *req_version ) +{ + const char *ver = GNUTLS_VERSION; + int my_major, my_minor, my_micro; + int rq_major, rq_minor, rq_micro; + const char *my_plvl, *rq_plvl; + + if ( !req_version ) + return ver; + + my_plvl = parse_version_string( ver, &my_major, &my_minor, &my_micro ); + if ( !my_plvl ) + return NULL; /* very strange our own version is bogus */ + rq_plvl = parse_version_string( req_version, &rq_major, &rq_minor, + &rq_micro ); + if ( !rq_plvl ) + return NULL; /* req version string is invalid */ + + if ( my_major > rq_major + || (my_major == rq_major && my_minor > rq_minor) + || (my_major == rq_major && my_minor == rq_minor + && my_micro > rq_micro) + || (my_major == rq_major && my_minor == rq_minor + && my_micro == rq_micro + && strcmp( my_plvl, rq_plvl ) >= 0) ) { + return ver; + } + return NULL; +} + Index: libextra/libgnutls-extra.m4 =================================================================== RCS file: /cvs/gnutls/gnutls/libextra/libgnutls-extra.m4,v retrieving revision 1.2 diff -u -u -r1.2 libgnutls-extra.m4 --- libextra/libgnutls-extra.m4 12 Jul 2002 17:46:57 -0000 1.2 +++ libextra/libgnutls-extra.m4 5 Oct 2002 07:41:11 -0000 @@ -49,17 +49,17 @@ #include #include #include -#include +#include int main () { system ("touch conf.libgnutlstest"); - if( strcmp( gnutls_check_version(NULL), "$libgnutls_extra_config_version" ) ) + if( strcmp( gnutls_extra_check_version(NULL), "$libgnutls_extra_config_version" ) ) { printf("\n*** 'libgnutls-extra-config --version' returned %s, but LIBGNUTLS_EXTRA (%s)\n", - "$libgnutls_extra_config_version", gnutls_check_version(NULL) ); + "$libgnutls_extra_config_version", gnutls_extra_check_version(NULL) ); printf("*** was found! If libgnutls-extra-config was correct, then it is best\n"); printf("*** to remove the old version of LIBGNUTLS_EXTRA. You may also be able to fix the error\n"); printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n"); @@ -69,21 +69,22 @@ printf("*** to point to the correct copy of libgnutls-extra-config, and remove the file config.cache\n"); printf("*** before re-running configure\n"); } - else if ( strcmp(gnutls_check_version(NULL), LIBGNUTLS_EXTRA_VERSION ) ) + else if ( strcmp(gnutls_extra_check_version(NULL), LIBGNUTLS_EXTRA_VERSION ) ) { printf("\n*** LIBGNUTLS_EXTRA header file (version %s) does not match\n", LIBGNUTLS_EXTRA_VERSION); - printf("*** library (version %s)\n", gnutls_check_version(NULL) ); + printf("*** library (version %s). This is may be due to a different version of gnutls\n", gnutls_extra_check_version(NULL) ); + printf("*** and gnutls-extra.\n"); } else { - if ( gnutls_check_version( "$min_libgnutls_version" ) ) + if ( gnutls_extra_check_version( "$min_libgnutls_version" ) ) { return 0; } else { printf("no\n*** An old version of LIBGNUTLS_EXTRA (%s) was found.\n", - gnutls_check_version(NULL) ); + gnutls_extra_check_version(NULL) ); printf("*** You need a version of LIBGNUTLS_EXTRA newer than %s. The latest version of\n", "$min_libgnutls_version" ); printf("*** LIBGNUTLS_EXTRA is always available from ftp://gnutls.hellug.gr/pub/gnutls.\n"); @@ -129,8 +130,8 @@ #include #include #include -#include -], [ return !!gnutls_check_version(NULL); ], +#include +], [ return !!gnutls_extra_check_version(NULL); ], [ echo "*** The test program compiled, but did not run. This usually means" echo "*** that the run-time linker is not finding LIBGNUTLS_EXTRA or finding the wrong" echo "*** version of LIBGNUTLS_EXTRA. If it is not finding LIBGNUTLS_EXTRA, you'll need to set your"