/
luvi.c
53 lines (51 loc) · 1.48 KB
/
luvi.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
* Copyright 2014 The Luvit Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include "./luvi.h"
LUALIB_API int luaopen_luvi(lua_State *L) {
#ifdef WITH_OPENSSL
char buffer[1024];
#endif
lua_newtable(L);
#ifdef LUVI_VERSION
lua_pushstring(L, ""LUVI_VERSION"");
lua_setfield(L, -2, "version");
#endif
lua_newtable(L);
#ifdef WITH_OPENSSL
snprintf(buffer, sizeof(buffer), "%s, lua-openssl %s",
SSLeay_version(SSLEAY_VERSION), LOPENSSL_VERSION);
lua_pushstring(L, buffer);
lua_setfield(L, -2, "ssl");
#endif
#ifdef WITH_PCRE2
pcre2_config(PCRE2_CONFIG_VERSION, buffer);
lua_pushstring(L, buffer);
lua_setfield(L, -2, "pcre2");
#endif
#ifdef WITH_ZLIB
lua_pushstring(L, zlibVersion());
lua_setfield(L, -2, "zlib");
#endif
#ifdef WITH_WINSVC
lua_pushboolean(L, 1);
lua_setfield(L, -2, "winsvc");
#endif
lua_pushstring(L, uv_version_string());
lua_setfield(L, -2, "libuv");
lua_setfield(L, -2, "options");
return 1;
}