Add. version/version_info function
This commit is contained in:
parent
916d815764
commit
3d204d7d24
49
src/lcurl.c
49
src/lcurl.c
@ -26,10 +26,59 @@ static int lcurl_hpost_new(lua_State *L){
|
||||
return lcurl_hpost_create(L, LCURL_ERROR_RAISE);
|
||||
}
|
||||
|
||||
static int lcurl_version(lua_State *L){
|
||||
lua_pushstring(L, curl_version());
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lcurl_version_info(lua_State *L){
|
||||
const char **p;
|
||||
curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
|
||||
|
||||
lua_newtable(L);
|
||||
lua_pushstring(L, data->version); lua_setfield(L, -2, "version"); /* LIBCURL_VERSION */
|
||||
lua_pushnumber(L, data->version_num); lua_setfield(L, -2, "version_num"); /* LIBCURL_VERSION_NUM */
|
||||
lua_pushstring(L, data->host); lua_setfield(L, -2, "host"); /* OS/host/cpu/machine when configured */
|
||||
lua_pushnumber(L, data->features); lua_setfield(L, -2, "features"); /* bitmask, see defines below */
|
||||
lua_pushstring(L, data->ssl_version); lua_setfield(L, -2, "ssl_version"); /* human readable string */
|
||||
lua_pushnumber(L, data->ssl_version_num); lua_setfield(L, -2, "ssl_version_num"); /* not used anymore, always 0 */
|
||||
lua_pushstring(L, data->libz_version); lua_setfield(L, -2, "libz_version"); /* human readable string */
|
||||
|
||||
/* protocols is terminated by an entry with a NULL protoname */
|
||||
lua_newtable(L);
|
||||
for(p = data->protocols; *p; ++p){
|
||||
lua_pushstring(L, *p); lua_pushboolean(L, 1); lua_rawset(L, -3);
|
||||
}
|
||||
lua_setfield(L, -2, "protocols");
|
||||
|
||||
/* The fields below this were added in CURLVERSION_SECOND */
|
||||
// const char *ares;
|
||||
// int ares_num;
|
||||
|
||||
/* This field was added in CURLVERSION_THIRD */
|
||||
// const char *libidn;
|
||||
|
||||
/* These field were added in CURLVERSION_FOURTH */
|
||||
|
||||
/* Same as '_libiconv_version' if built with HAVE_ICONV */
|
||||
// int iconv_ver_num;
|
||||
|
||||
// const char *libssh_version; /* human readable string */
|
||||
|
||||
if(lua_isstring(L, 1)){
|
||||
lua_pushvalue(L, 1); lua_rawget(L, -2);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static const struct luaL_Reg lcurl_functions[] = {
|
||||
{"error", lcurl_error_new },
|
||||
{"httppost", lcurl_hpost_new },
|
||||
{"easy", lcurl_easy_new },
|
||||
{"version", lcurl_version },
|
||||
{"version_info", lcurl_version_info },
|
||||
|
||||
{NULL,NULL}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user