static int l_easy_getinfo_curl_slist(lua_State *L) { l_easy_private *privatep = luaL_checkudata(L, 1, LUACURL_EASYMETATABLE); CURL *curl = privatep->curl; CURLINFO *infop = LUACURL_INFOP_UPVALUE(L, 1); struct curl_slist *list; struct curl_slist *next; int i; if (curl_easy_getinfo(curl, *infop, &list) != CURLE_OK) luaL_error(L, "%s", privatep->error); i = 1; next = list; lua_newtable(L); while (next) { lua_pushstring(L, (char*) next->data); lua_rawseti(L, -2, i++); next = next->next; } curl_slist_free_all(list); return 1; }
static int l_easy_getinfo_double(lua_State *L) { l_easy_private *privatep = luaL_checkudata(L, 1, LUACURL_EASYMETATABLE); CURL *curl = privatep->curl; CURLINFO *infop = LUACURL_INFOP_UPVALUE(L, 1); double value; if (curl_easy_getinfo(curl, *infop, &value) != CURLE_OK) luaL_error(L, "%s", privatep->error); lua_pushnumber(L, value); return 1; }
static int l_easy_getinfo_long(lua_State *L) { l_easy_private *privatep = luaL_checkudata(L, 1, LUACURL_EASYMETATABLE); CURL *curl = privatep->curl; CURLINFO *infop = LUACURL_INFOP_UPVALUE(L, 1); long value; if (curl_easy_getinfo(curl, *infop, &value) != CURLE_OK) { lua_pushnil(L); lua_pushfstring(L, "%s", privatep->error); return 2; } lua_pushinteger(L, value); return 1; }