]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
version: add OpenLDAP version in the output
authorDaniel Stenberg <daniel@haxx.se>
Wed, 12 May 2021 09:09:12 +0000 (11:09 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 13 May 2021 09:51:02 +0000 (11:51 +0200)
Assisted-by: Howard Chu
Closes #7054

lib/version.c

index 4b1e7542cbc0f53037b85f100584be0f431ff559..d18cf0e3f14f5b5862e879c25f725d8c69b9c604 100644 (file)
 #include <gsasl.h>
 #endif
 
+#ifdef USE_OPENLDAP
+#include <ldap.h>
+#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);