[Tarantool-patches] [PATCH 2/3] build: enable smtp in libCURL

Roman Khabibov roman.habibov at tarantool.org
Fri Mar 19 17:13:07 MSK 2021


Enable smtp protocol in bundled libCURL.
---
 cmake/BuildLibCURL.cmake         |  2 +-
 test/box-tap/curl-build.test.lua | 38 +++++++++++++++++++++++++++++++-
 2 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/cmake/BuildLibCURL.cmake b/cmake/BuildLibCURL.cmake
index 5f8b15a63..313adfb97 100644
--- a/cmake/BuildLibCURL.cmake
+++ b/cmake/BuildLibCURL.cmake
@@ -124,6 +124,7 @@ macro(curl_build)
                 --enable-http-auth
                 --enable-mime
                 --enable-dateparse
+                --enable-smtp
 
                 ${DISABLED_DNS_OPT}
                 --disable-ftp
@@ -137,7 +138,6 @@ macro(curl_build)
                 --disable-pop3
                 --disable-imap
                 --disable-smb
-                --disable-smtp
                 --disable-gopher
                 --disable-manual
                 --disable-sspi
diff --git a/test/box-tap/curl-build.test.lua b/test/box-tap/curl-build.test.lua
index ab58efffa..e4ec49c19 100755
--- a/test/box-tap/curl-build.test.lua
+++ b/test/box-tap/curl-build.test.lua
@@ -4,10 +4,22 @@ local tap = require('tap')
 local ffi = require('ffi')
 ffi.cdef([[
     void *dlsym(void *handle, const char *symbol);
+    struct curl_version_info_data {
+        int age;                  /* see description below */
+        const char *version;      /* human readable string */
+        unsigned int version_num; /* numeric representation */
+        const char *host;         /* human readable string */
+        int features;             /* bitmask, see below */
+        char *ssl_version;        /* human readable string */
+        long ssl_version_num;     /* not used, always zero */
+        const char *libz_version; /* human readable string */
+        const char * const *protocols; /* protocols */
+    };
+    struct curl_version_info_data *curl_version_info(int age);
 ]])
 
 local test = tap.test('curl-symbols')
-test:plan(1)
+test:plan(2)
 
 local RTLD_DEFAULT
 -- See `man 3 dlsym`:
@@ -121,4 +133,28 @@ test:test('curl_symbols', function(t)
     end
 end)
 
+--
+-- Check if smtp protocol is enabled.
+--
+local function has_smtp()
+    local i = 0
+    -- curl_version_info_data.protocols is a null terminated array
+    -- of pointers to char.
+    -- See curl/lib/version.c:
+    --   static const char * const protocols[]
+    local info = ffi.C.curl_version_info(7)
+    local protocol = info.protocols[i]
+    while protocol ~= nil do
+        if ffi.string(protocol) == 'smtp' then
+            return true
+        end
+        i = i + 1
+        protocol = info.protocols[i]
+    end
+
+    return false
+end
+
+test:ok(has_smtp(), 'smtp protocol is supported')
+
 os.exit(test:check() and 0 or 1)
-- 
2.24.3 (Apple Git-128)



More information about the Tarantool-patches mailing list