From: Daniel Stenberg Date: Wed, 12 May 2021 09:09:12 +0000 (+0200) Subject: version: add OpenLDAP version in the output X-Git-Tag: curl-7_77_0~53 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bf0feae7768d9;p=thirdparty%2Fcurl.git version: add OpenLDAP version in the output Assisted-by: Howard Chu Closes #7054 --- diff --git a/lib/version.c b/lib/version.c index 4b1e7542cb..d18cf0e3f1 100644 --- a/lib/version.c +++ b/lib/version.c @@ -70,6 +70,10 @@ #include #endif +#ifdef USE_OPENLDAP +#include +#endif + #ifdef HAVE_BROTLI static size_t brotli_version(char *buf, size_t bufsz) { @@ -104,7 +108,7 @@ static size_t zstd_version(char *buf, size_t bufsz) * zeros in the data. */ -#define VERSION_PARTS 16 /* number of substrings we can concatenate */ +#define VERSION_PARTS 17 /* number of substrings we can concatenate */ char *curl_version(void) { @@ -153,6 +157,9 @@ char *curl_version(void) #endif #ifdef USE_GSASL char gsasl_buf[30]; +#endif +#ifdef USE_OPENLDAP + char ldap_buf[30]; #endif int i = 0; int j; @@ -247,6 +254,22 @@ char *curl_version(void) gsasl_check_version(NULL)); src[i++] = gsasl_buf; #endif +#ifdef USE_OPENLDAP + { + LDAPAPIInfo api; + api.ldapai_info_version = LDAP_API_INFO_VERSION; + + if(ldap_get_option(NULL, LDAP_OPT_API_INFO, &api) == LDAP_OPT_SUCCESS) { + unsigned int patch = api.ldapai_vendor_version % 100; + unsigned int major = api.ldapai_vendor_version / 10000; + unsigned int minor = + ((api.ldapai_vendor_version - major * 10000) - patch) / 100; + msnprintf(ldap_buf, sizeof(ldap_buf), "%s/%u.%u.%u", + api.ldapai_vendor_name, major, minor, patch); + src[i++] = ldap_buf; + } + } +#endif DEBUGASSERT(i <= VERSION_PARTS);