Skip to content

Commit ddf322e

Browse files
committed
Add. Example for version_info.
1 parent 15c10ad commit ddf322e

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

examples/lcurl/crul_info.lua

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
local curl = require "lcurl"
2+
3+
local function keys(t)
4+
local s = {}
5+
for k in pairs(t) do
6+
s[#s + 1] = k
7+
end
8+
table.sort(s)
9+
return s
10+
end
11+
12+
local function printf(...)
13+
return print(string.format(...))
14+
end
15+
16+
local exclude = {protocols = 1, features = 1, version = 1, version_num = 1}
17+
18+
local info = curl.version_info()
19+
20+
print(curl.version())
21+
22+
for _, key in ipairs(keys(info)) do if not exclude[key] then
23+
printf("%15s: %s", key, info[key])
24+
end end
25+
26+
print('Protocols:')
27+
for _, protocol in ipairs(keys(info.protocols))do
28+
local on = info.protocols[protocol]
29+
printf(' [%s] %s', on and '+' or '-', protocol)
30+
end
31+
32+
print('Features:')
33+
for _, feature in ipairs(keys(info.features))do
34+
local on = info.features[feature]
35+
printf(' [%s] %s', on and '+' or '-', feature)
36+
end

0 commit comments

Comments
 (0)