mirror of
https://github.com/lxsang/antd-lua-plugin
synced 2024-12-27 09:58:21 +01:00
remove warning
This commit is contained in:
parent
064f874691
commit
1e89b100ff
@ -7,7 +7,7 @@ static int l_getdb (lua_State *L) {
|
|||||||
// if(db)
|
// if(db)
|
||||||
// dbclose(db);
|
// dbclose(db);
|
||||||
//printf("OPEN: %s\n",s);
|
//printf("OPEN: %s\n",s);
|
||||||
sqldb db = __getdb(s);
|
sqldb db = __getdb((char*)s);
|
||||||
if(db)
|
if(db)
|
||||||
lua_pushlightuserdata(L, db);
|
lua_pushlightuserdata(L, db);
|
||||||
else
|
else
|
||||||
|
@ -76,35 +76,36 @@ static int process_token_array(lua_State* L, jsmntok_t* t, const char* s, int ci
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
static void stackDump (lua_State *L) {
|
static void stackDump (lua_State *L) {
|
||||||
int i;
|
int i;
|
||||||
int top = lua_gettop(L);
|
int top = lua_gettop(L);
|
||||||
for (i = 1; i <= top; i++) { /* repeat for each level */
|
for (i = 1; i <= top; i++) {
|
||||||
int t = lua_type(L, i);
|
int t = lua_type(L, i);
|
||||||
switch (t) {
|
switch (t) {
|
||||||
|
|
||||||
case LUA_TSTRING: /* strings */
|
case LUA_TSTRING:
|
||||||
printf("`%s' \n", lua_tostring(L, i));
|
printf("`%s' \n", lua_tostring(L, i));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LUA_TBOOLEAN: /* booleans */
|
case LUA_TBOOLEAN:
|
||||||
printf(lua_toboolean(L, i) ? "true\n" : "false\n");
|
printf(lua_toboolean(L, i) ? "true\n" : "false\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LUA_TNUMBER: /* numbers */
|
case LUA_TNUMBER:
|
||||||
printf("%g\n", lua_tonumber(L, i));
|
printf("%g\n", lua_tonumber(L, i));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: /* other values */
|
default:
|
||||||
printf("%s\n", lua_typename(L, t));
|
printf("%s\n", lua_typename(L, t));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
printf(" "); /* put a separator */
|
printf(" ");
|
||||||
}
|
}
|
||||||
printf("\n"); /* end the listing */
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
static int process_token_string(lua_State* L, jsmntok_t* t, const char* s, int cid)
|
static int process_token_string(lua_State* L, jsmntok_t* t, const char* s, int cid)
|
||||||
{
|
{
|
||||||
// unescape a string
|
// unescape a string
|
||||||
@ -118,7 +119,7 @@ static int process_token_string(lua_State* L, jsmntok_t* t, const char* s, int c
|
|||||||
if (lua_pcall(L, 1, 1, 0) != 0)
|
if (lua_pcall(L, 1, 1, 0) != 0)
|
||||||
printf("Error running function `unescape': %s\n",lua_tostring(L, -1));
|
printf("Error running function `unescape': %s\n",lua_tostring(L, -1));
|
||||||
if(str) free(str);
|
if(str) free(str);
|
||||||
str = luaL_checkstring(L,-1);
|
str = (char*)luaL_checkstring(L,-1);
|
||||||
lua_settop(L, -3);
|
lua_settop(L, -3);
|
||||||
lua_pushstring(L,str);
|
lua_pushstring(L,str);
|
||||||
//stackDump(L);
|
//stackDump(L);
|
||||||
|
@ -198,7 +198,7 @@ static int l_getuid(lua_State* L)
|
|||||||
LOG("malloc eror \n");
|
LOG("malloc eror \n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (getgrouplist(name, gid, groups, &ngroups) == -1) {
|
if (getgrouplist(name, gid, (int*)groups, &ngroups) == -1) {
|
||||||
free(groups);
|
free(groups);
|
||||||
LOG("getgrouplist() returned -1; ngroups = %d\n", ngroups);
|
LOG("getgrouplist() returned -1; ngroups = %d\n", ngroups);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -61,7 +61,7 @@ send a request
|
|||||||
*/
|
*/
|
||||||
int wurl_request_socket(const char* ip, int port)
|
int wurl_request_socket(const char* ip, int port)
|
||||||
{
|
{
|
||||||
int sockfd, bytes_read;
|
int sockfd;
|
||||||
struct sockaddr_in dest;
|
struct sockaddr_in dest;
|
||||||
|
|
||||||
// time out setting
|
// time out setting
|
||||||
@ -82,7 +82,7 @@ int wurl_request_socket(const char* ip, int port)
|
|||||||
bzero(&dest, sizeof(dest));
|
bzero(&dest, sizeof(dest));
|
||||||
dest.sin_family = AF_INET;
|
dest.sin_family = AF_INET;
|
||||||
dest.sin_port = htons(port);
|
dest.sin_port = htons(port);
|
||||||
if ( inet_aton(ip, &dest.sin_addr.s_addr) == 0 )
|
if ( inet_aton(ip, &dest.sin_addr) == 0 )
|
||||||
{
|
{
|
||||||
perror(ip);
|
perror(ip);
|
||||||
close(sockfd);
|
close(sockfd);
|
||||||
@ -344,14 +344,14 @@ int wurl_read_data(int sock,char** din)
|
|||||||
char* tmp = NULL;
|
char* tmp = NULL;
|
||||||
int CHUNK = 512;
|
int CHUNK = 512;
|
||||||
char buff[MAX_BUFF];
|
char buff[MAX_BUFF];
|
||||||
char * data = (unsigned char*) malloc(CHUNK);
|
char * data = ( char*) malloc(CHUNK);
|
||||||
int cursize = CHUNK;
|
int cursize = CHUNK;
|
||||||
int size = wurl_read_buf(sock,buff,MAX_BUFF);
|
int size = wurl_read_buf(sock,buff,MAX_BUFF);
|
||||||
while(size > 0)
|
while(size > 0)
|
||||||
{
|
{
|
||||||
if(total_length+size > cursize)
|
if(total_length+size > cursize)
|
||||||
{
|
{
|
||||||
tmp = (unsigned char*) realloc(data,total_length + size+ CHUNK );
|
tmp = (char*) realloc(data,total_length + size+ CHUNK );
|
||||||
|
|
||||||
if(!tmp)
|
if(!tmp)
|
||||||
{
|
{
|
||||||
@ -380,7 +380,6 @@ int wurl_read_data(int sock,char** din)
|
|||||||
int wurl_request(const char* hostname, int port, wurl_header_t* header, int lazy)
|
int wurl_request(const char* hostname, int port, wurl_header_t* header, int lazy)
|
||||||
{
|
{
|
||||||
char ip[100];
|
char ip[100];
|
||||||
char buff[MAX_BUFF];
|
|
||||||
wurl_ip_from_hostname(hostname ,ip);
|
wurl_ip_from_hostname(hostname ,ip);
|
||||||
int sock = wurl_request_socket(ip, port);
|
int sock = wurl_request_socket(ip, port);
|
||||||
|
|
||||||
@ -400,8 +399,7 @@ int wurl_request(const char* hostname, int port, wurl_header_t* header, int lazy
|
|||||||
if(lazy)
|
if(lazy)
|
||||||
{
|
{
|
||||||
// read line by line, ignore content length
|
// read line by line, ignore content length
|
||||||
char * d;
|
header->clen = wurl_read_data(sock,(char**)&header->data);
|
||||||
header->clen = wurl_read_data(sock,&header->data);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return sock;
|
return sock;
|
||||||
@ -411,7 +409,7 @@ int wurl_download(const char* hostname, int port, wurl_header_t* h, const char*
|
|||||||
{
|
{
|
||||||
// we will handler the data reading
|
// we will handler the data reading
|
||||||
int sock = wurl_request(hostname, port,h,0);
|
int sock = wurl_request(hostname, port,h,0);
|
||||||
unsigned char buff[MAX_BUFF];
|
char buff[MAX_BUFF];
|
||||||
if(sock < 0) return -1;
|
if(sock < 0) return -1;
|
||||||
|
|
||||||
FILE* fp = fopen(to,"wb");
|
FILE* fp = fopen(to,"wb");
|
||||||
@ -471,7 +469,7 @@ static int l_get(lua_State *L)
|
|||||||
const char* resource = luaL_checkstring(L,3);
|
const char* resource = luaL_checkstring(L,3);
|
||||||
|
|
||||||
wurl_header_t rq;
|
wurl_header_t rq;
|
||||||
rq.resource = resource;
|
rq.resource = (char*)resource;
|
||||||
rq.type = GET;
|
rq.type = GET;
|
||||||
|
|
||||||
if(wurl_request(host,port,&rq,1) == 0)
|
if(wurl_request(host,port,&rq,1) == 0)
|
||||||
@ -492,11 +490,11 @@ static int l_get(lua_State *L)
|
|||||||
{
|
{
|
||||||
//printf("Data is binary, encode as base64 %s\n", rq.ctype);
|
//printf("Data is binary, encode as base64 %s\n", rq.ctype);
|
||||||
char* dst = (char*) malloc(3*rq.clen/2);
|
char* dst = (char*) malloc(3*rq.clen/2);
|
||||||
Base64encode(dst, rq.data,rq.clen);
|
Base64encode(dst, (const char*)rq.data,rq.clen);
|
||||||
lua_pushstring(L,dst);
|
lua_pushstring(L,dst);
|
||||||
free(dst);
|
free(dst);
|
||||||
} else
|
} else
|
||||||
lua_pushstring(L,rq.data);
|
lua_pushstring(L,(const char*)rq.data);
|
||||||
free(rq.data); // be careful
|
free(rq.data); // be careful
|
||||||
lua_settable(L,-3);
|
lua_settable(L,-3);
|
||||||
return 1;
|
return 1;
|
||||||
@ -515,11 +513,11 @@ static int l_post(lua_State *L)
|
|||||||
const char* ctype = luaL_checkstring(L,4); // content type
|
const char* ctype = luaL_checkstring(L,4); // content type
|
||||||
const char* data = luaL_checkstring(L,5); // post data
|
const char* data = luaL_checkstring(L,5); // post data
|
||||||
wurl_header_t rq;
|
wurl_header_t rq;
|
||||||
rq.resource = res;
|
rq.resource = (char*)res;
|
||||||
rq.type = POST;
|
rq.type = POST;
|
||||||
rq.ctype = ctype;
|
rq.ctype = (char*)ctype;
|
||||||
rq.clen = strlen(data);
|
rq.clen = strlen(data);
|
||||||
rq.data = data;
|
rq.data = (unsigned char*)data;
|
||||||
|
|
||||||
if(wurl_request(host,port,&rq,1) == 0)
|
if(wurl_request(host,port,&rq,1) == 0)
|
||||||
{
|
{
|
||||||
@ -540,11 +538,11 @@ static int l_post(lua_State *L)
|
|||||||
{
|
{
|
||||||
//printf("Data is binary, encode as base64 %s\n", rq.ctype);
|
//printf("Data is binary, encode as base64 %s\n", rq.ctype);
|
||||||
char* dst = (char*) malloc(3*rq.clen/2);
|
char* dst = (char*) malloc(3*rq.clen/2);
|
||||||
Base64encode(dst, rq.data,rq.clen);
|
Base64encode(dst, (const char*)rq.data,rq.clen);
|
||||||
lua_pushstring(L,dst);
|
lua_pushstring(L,dst);
|
||||||
free(dst);
|
free(dst);
|
||||||
} else
|
} else
|
||||||
lua_pushstring(L,rq.data);
|
lua_pushstring(L,(const char*)rq.data);
|
||||||
free(rq.data); // be careful
|
free(rq.data); // be careful
|
||||||
lua_settable(L,-3);
|
lua_settable(L,-3);
|
||||||
return 1;
|
return 1;
|
||||||
@ -564,7 +562,7 @@ static int l_download(lua_State* L)
|
|||||||
const char* res = luaL_checkstring(L,3); // resource
|
const char* res = luaL_checkstring(L,3); // resource
|
||||||
const char* file = luaL_checkstring(L,4); // file
|
const char* file = luaL_checkstring(L,4); // file
|
||||||
wurl_header_t rq;
|
wurl_header_t rq;
|
||||||
rq.resource = res;
|
rq.resource = (char*)res;
|
||||||
rq.type = GET;
|
rq.type = GET;
|
||||||
if(wurl_download(host,port,&rq,file) == 0)
|
if(wurl_download(host,port,&rq,file) == 0)
|
||||||
lua_pushboolean(L, true);
|
lua_pushboolean(L, true);
|
||||||
@ -590,21 +588,21 @@ static int l_upload(lua_State* L)
|
|||||||
if(sock <= 0) goto fail;
|
if(sock <= 0) goto fail;
|
||||||
|
|
||||||
char * names[2];
|
char * names[2];
|
||||||
names[0] = name;
|
names[0] = (char*)name;
|
||||||
char* files[2];
|
char* files[2];
|
||||||
//files[0] = "/Users/mrsang/tmp/Archive.zip";
|
//files[0] = "/Users/mrsang/tmp/Archive.zip";
|
||||||
files[0] = file;
|
files[0] = (char*)file;
|
||||||
|
|
||||||
//printf("SENDIND DILE\n");
|
//printf("SENDIND DILE\n");
|
||||||
wurl_send_files(sock, resource,1,names,files);
|
wurl_send_files(sock, (char*)resource,1,names,files);
|
||||||
wurl_header_t header;
|
wurl_header_t header;
|
||||||
//printf("READ HEADER\n");
|
//printf("READ HEADER\n");
|
||||||
wurl_response_header(sock, &header);
|
wurl_response_header(sock, &header);
|
||||||
//printf("read data\n");
|
//printf("read data\n");
|
||||||
wurl_read_data(sock,&header.data);
|
wurl_read_data(sock,(char**)&header.data);
|
||||||
if(header.ctype != NULL && header.data)
|
if(header.ctype != NULL && header.data)
|
||||||
{
|
{
|
||||||
lua_pushstring(L,header.data);
|
lua_pushstring(L,(const char*)header.data);
|
||||||
free(header.data);
|
free(header.data);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ static int l_jpeg (lua_State *L) {
|
|||||||
static int l_octstream (lua_State *L) {
|
static int l_octstream (lua_State *L) {
|
||||||
void* client = lua_touserdata (L, 1);
|
void* client = lua_touserdata (L, 1);
|
||||||
const char* s = luaL_checkstring(L,2);
|
const char* s = luaL_checkstring(L,2);
|
||||||
octstream(client,s);
|
octstream(client,(char*)s);
|
||||||
return 0; /* number of results */
|
return 0; /* number of results */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,7 +224,7 @@ static int l_md5(lua_State* L)
|
|||||||
const char* s = luaL_checkstring(L,1);
|
const char* s = luaL_checkstring(L,1);
|
||||||
int len = strlen(s);
|
int len = strlen(s);
|
||||||
char buff[256];
|
char buff[256];
|
||||||
md5(s,len,buff);
|
md5((uint8_t*)s,len,buff);
|
||||||
lua_pushstring(L,buff);
|
lua_pushstring(L,buff);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -238,20 +238,20 @@ static int l_sha1(lua_State *L )
|
|||||||
}
|
}
|
||||||
static int l_base64_encode(lua_State *L)
|
static int l_base64_encode(lua_State *L)
|
||||||
{
|
{
|
||||||
const char* s;
|
char* s;
|
||||||
int len;
|
int len;
|
||||||
char* dst;
|
char* dst;
|
||||||
byte_array_t *arr = NULL;
|
byte_array_t *arr = NULL;
|
||||||
if(lua_isstring(L,1))
|
if(lua_isstring(L,1))
|
||||||
{
|
{
|
||||||
s= luaL_checkstring(L,1);
|
s= (char*)luaL_checkstring(L,1);
|
||||||
len = strlen(s);
|
len = strlen(s);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// this may be an bytearray
|
// this may be an bytearray
|
||||||
arr = l_check_barray(L,1);
|
arr = l_check_barray(L,1);
|
||||||
s = arr->data;
|
s = (char*)arr->data;
|
||||||
len = arr->size;
|
len = arr->size;
|
||||||
}
|
}
|
||||||
if(len == 0)
|
if(len == 0)
|
||||||
@ -273,7 +273,7 @@ static int l_base64_decode(lua_State *L)
|
|||||||
lua_new_byte_array(L,len);
|
lua_new_byte_array(L,len);
|
||||||
byte_array_t * arr = NULL;
|
byte_array_t * arr = NULL;
|
||||||
arr = l_check_barray(L,2);
|
arr = l_check_barray(L,2);
|
||||||
len = Base64decode(arr->data, s);
|
len = Base64decode((char*)arr->data, s);
|
||||||
arr->size = len;
|
arr->size = len;
|
||||||
//lua_pushstring(L,dst);
|
//lua_pushstring(L,dst);
|
||||||
//free(dst);
|
//free(dst);
|
||||||
@ -425,7 +425,7 @@ static int l_ws_read_header(lua_State *L)
|
|||||||
static int l_ws_t(lua_State*L)
|
static int l_ws_t(lua_State*L)
|
||||||
{
|
{
|
||||||
void* client = lua_touserdata (L, 1);
|
void* client = lua_touserdata (L, 1);
|
||||||
char* str = luaL_checkstring(L,2);
|
char* str = (char*)luaL_checkstring(L,2);
|
||||||
ws_t(client,str);
|
ws_t(client,str);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -443,7 +443,7 @@ static int l_status(lua_State*L)
|
|||||||
static int l_ws_f(lua_State*L)
|
static int l_ws_f(lua_State*L)
|
||||||
{
|
{
|
||||||
void* client = lua_touserdata (L, 1);
|
void* client = lua_touserdata (L, 1);
|
||||||
char* str = luaL_checkstring(L,2);
|
char* str = (char*)luaL_checkstring(L,2);
|
||||||
ws_f(client,str);
|
ws_f(client,str);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -465,7 +465,7 @@ static int l_status(lua_State*L)
|
|||||||
|
|
||||||
static int l_trim(lua_State* L)
|
static int l_trim(lua_State* L)
|
||||||
{
|
{
|
||||||
const char* str = strdup((char*)luaL_checkstring(L,1));
|
char* str = strdup((char*)luaL_checkstring(L,1));
|
||||||
const char* tok = luaL_checkstring(L,2);
|
const char* tok = luaL_checkstring(L,2);
|
||||||
|
|
||||||
trim(str,tok[0]);
|
trim(str,tok[0]);
|
||||||
|
Loading…
Reference in New Issue
Block a user