fix windows platform compile error

This commit is contained in:
lailongwei 2016-09-20 16:51:10 +08:00
parent 8d46a84f08
commit bd36129b83
2 changed files with 12 additions and 4 deletions

View File

@ -267,8 +267,9 @@ int http_get(lua_State* L)
if (code != CURLE_OK)
{
lua_pushnil(L);
char errorBuf[1024];
lua_pushnil(L);
snprintf(errorBuf, sizeof(errorBuf) - 1, "%s\n%s\n", curl_easy_strerror(code), state.errorBuffer);
lua_pushstring(L, errorBuf);
}
@ -297,10 +298,10 @@ int http_post(lua_State* L)
string_init(&state.S);
if (curl)
{
curl_easy_setopt(curl, CURLOPT_POST, 1);
size_t dataSize;
const char* data = luaL_checklstring(L, 2, &dataSize);
curl_easy_setopt(curl, CURLOPT_POST, 1);
if (data && dataSize > 0)
{
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)dataSize);
@ -314,8 +315,9 @@ int http_post(lua_State* L)
if (code != CURLE_OK)
{
lua_pushnil(L);
char errorBuf[1024];
lua_pushnil(L);
snprintf(errorBuf, sizeof(errorBuf) - 1, "%s\n%s\n", curl_easy_strerror(code), state.errorBuffer);
lua_pushstring(L, errorBuf);
}

View File

@ -143,6 +143,12 @@ int http_download(lua_State* L);
int zip_extract(lua_State* L);
#endif
#ifdef _MSC_VER
#ifndef snprintf
#define snprintf _snprintf
#endif
#endif
/* Engine interface */
typedef struct