mirror of
https://github.com/lxsang/ant-http
synced 2025-07-15 05:19:55 +02:00
remove warning
This commit is contained in:
@ -130,7 +130,7 @@ int dbinsert(sqlite3* db,const char* table, const dbfield fields)
|
||||
}
|
||||
dbrecord dball(sqlite3* db,const char* table)
|
||||
{
|
||||
return dbselect(db,table,"1=%d",1);
|
||||
return dbselect(db,table,"1=%s","1");
|
||||
}
|
||||
dbrecord dbselect(sqlite3* db, const char* table, const char* fname,const char* fstring,...)
|
||||
{
|
||||
@ -160,7 +160,7 @@ dbrecord dbselect(sqlite3* db, const char* table, const char* fname,const char*
|
||||
dbfield fields = __field();
|
||||
for(int col = 0; col < cols; col++)
|
||||
{
|
||||
const char *value = sqlite3_column_text(statement, col);
|
||||
const char *value = (const char*)sqlite3_column_text(statement, col);
|
||||
const char *name = sqlite3_column_name(statement, col);
|
||||
add_field(&fields,name,(value!=0)?value:"");
|
||||
}
|
||||
|
@ -356,7 +356,7 @@ int __fb(void* client, const char* file)
|
||||
}
|
||||
int __f(void* client, const char* file)
|
||||
{
|
||||
unsigned char buf[BUFFLEN];
|
||||
char buf[BUFFLEN];
|
||||
FILE *ptr;
|
||||
int nbytes;
|
||||
ptr = fopen(file,"r");
|
||||
|
@ -81,6 +81,7 @@ int list_remove(list l,int idx)
|
||||
if(np == NULL) return 0;
|
||||
if(np->next == NULL) return 1;
|
||||
np->next = np->next->next;
|
||||
return 1;
|
||||
}
|
||||
int list_size(list l)
|
||||
{
|
||||
|
16
libs/utils.c
16
libs/utils.c
@ -168,7 +168,7 @@ mime_t mime_from_ext(const char* ex)
|
||||
if(IEQU(ex,_mimes[i].ext[j])) return _mimes[i];
|
||||
}
|
||||
|
||||
return (mime_t){"application/octet-stream",(const char *[]){ext,NULL},1};
|
||||
return (mime_t){"application/octet-stream",(const char *[]){(char*)ext,NULL},1};
|
||||
}
|
||||
/*get mime file info from type*/
|
||||
mime_t mime_from_type(const char* type)
|
||||
@ -192,7 +192,7 @@ char* mime(const char* file)
|
||||
mime_t m = mime_from_ext(ex);
|
||||
if(ex)
|
||||
free(ex);
|
||||
return m.type;
|
||||
return (char*)m.type;
|
||||
}
|
||||
|
||||
int is_bin(const char* file)
|
||||
@ -257,7 +257,7 @@ int regex_match(const char* expr,const char* search, int msize, regmatch_t* matc
|
||||
char *url_decode(const char *str) {
|
||||
if(!str)
|
||||
return NULL;
|
||||
char *pstr = str, *buf = malloc(strlen(str) + 1), *pbuf = buf;
|
||||
char *pstr = (char*)str, *buf = malloc(strlen(str) + 1), *pbuf = buf;
|
||||
|
||||
while (*pstr) {
|
||||
if (*pstr == '%') {
|
||||
@ -278,7 +278,7 @@ char *url_decode(const char *str) {
|
||||
}
|
||||
|
||||
char *url_encode(const char *str) {
|
||||
char *pstr = str, *buf = malloc(strlen(str) * 3 + 1), *pbuf = buf;
|
||||
char *pstr = (char*)str, *buf = malloc(strlen(str) * 3 + 1), *pbuf = buf;
|
||||
while (*pstr) {
|
||||
if (isalnum(*pstr) || *pstr == '-' || *pstr == '_' || *pstr == '.' || *pstr == '~')
|
||||
*pbuf++ = *pstr;
|
||||
@ -441,16 +441,16 @@ void md5(uint8_t *initial_msg, size_t initial_len, char* buff) {
|
||||
}
|
||||
uint8_t *p;
|
||||
p=(uint8_t *)&h0;
|
||||
sprintf(tmp,"%02x%02x%02x%02x", p[0], p[1], p[2], p[3], h0);
|
||||
sprintf(tmp,"%02x%02x%02x%02x", p[0], p[1], p[2], p[3]);//, h0
|
||||
strcpy(buff, tmp);
|
||||
p=(uint8_t *)&h1;
|
||||
sprintf(tmp,"%02x%02x%02x%02x", p[0], p[1], p[2], p[3], h1);
|
||||
sprintf(tmp,"%02x%02x%02x%02x", p[0], p[1], p[2], p[3]); //, h1)
|
||||
strcat(buff,tmp);
|
||||
p=(uint8_t *)&h2;
|
||||
sprintf(tmp,"%02x%02x%02x%02x", p[0], p[1], p[2], p[3], h2);
|
||||
sprintf(tmp,"%02x%02x%02x%02x", p[0], p[1], p[2], p[3]); // , h2
|
||||
strcat(buff,tmp);
|
||||
p=(uint8_t *)&h3;
|
||||
sprintf(tmp,"%02x%02x%02x%02x", p[0], p[1], p[2], p[3], h3);
|
||||
sprintf(tmp,"%02x%02x%02x%02x", p[0], p[1], p[2], p[3]); // , h3
|
||||
strcat(buff,tmp);
|
||||
// cleanup
|
||||
free(msg);
|
||||
|
@ -105,4 +105,5 @@ int is_dir(const char* f);
|
||||
int _exist(const char* f);
|
||||
void md5(uint8_t *, size_t , char*);
|
||||
void sha1(const char*, char*);
|
||||
void digest_to_hex(const uint8_t *, char *);
|
||||
#endif
|
||||
|
14
libs/ws.c
14
libs/ws.c
@ -95,7 +95,7 @@ int ws_read_data(void* client, ws_msg_header_t* header, int len, uint8_t* data)
|
||||
{
|
||||
// if len == -1 ==> read all remaining data to 'data';
|
||||
if(header->plen == 0) return 0;
|
||||
int dlen = (len==-1 || len > header->plen)?header->plen:len;
|
||||
int dlen = (len==-1 || len > (int)header->plen)?header->plen:len;
|
||||
if((dlen = antd_recv(client,data, dlen)) <0) return -1;
|
||||
header->plen = header->plen - dlen;
|
||||
// unmask received data
|
||||
@ -158,7 +158,7 @@ void ws_send_frame(void* client, uint8_t* data, ws_msg_header_t header)
|
||||
{
|
||||
ws_gen_mask_key(&header);
|
||||
masked = (uint8_t*) malloc(header.plen);
|
||||
for(int i = 0; i < header.plen; ++i)
|
||||
for(int i = 0; i < (int)header.plen; ++i)
|
||||
masked[i] = data[i]^ header.mask_key[i%4];
|
||||
}
|
||||
_send_header(client, header);
|
||||
@ -181,7 +181,7 @@ void ws_send_text(void* client, const char* data,int mask)
|
||||
header.plen = strlen(data);
|
||||
//_send_header(client,header);
|
||||
//send(client, data, header.plen,0);
|
||||
ws_send_frame(client,data,header);
|
||||
ws_send_frame(client,(uint8_t*)data,header);
|
||||
}
|
||||
/**
|
||||
* send a single binary data fram to client
|
||||
@ -311,7 +311,7 @@ send a request
|
||||
*/
|
||||
int request_socket(const char* ip, int port)
|
||||
{
|
||||
int sockfd, bytes_read;
|
||||
int sockfd;
|
||||
struct sockaddr_in dest;
|
||||
|
||||
// time out setting
|
||||
@ -335,7 +335,7 @@ int request_socket(const char* ip, int port)
|
||||
bzero(&dest, sizeof(dest));
|
||||
dest.sin_family = AF_INET;
|
||||
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);
|
||||
close(sockfd);
|
||||
@ -351,6 +351,8 @@ int request_socket(const char* ip, int port)
|
||||
}
|
||||
|
||||
//TODO: The ping request
|
||||
/*
|
||||
this is for the client side, not use for now
|
||||
int ws_open_hand_shake(const char* host, int port, const char* resource)
|
||||
{
|
||||
char ip[100];
|
||||
@ -405,7 +407,7 @@ int ws_open_hand_shake(const char* host, int port, const char* resource)
|
||||
if(done) return sock;
|
||||
//printf("No server key found \n");
|
||||
return -1;
|
||||
}
|
||||
}*/
|
||||
char* get_ip_address()
|
||||
{
|
||||
struct ifaddrs* addrs;
|
||||
|
@ -50,6 +50,6 @@ int ws_read_data(void* , ws_msg_header_t*, int, uint8_t*);
|
||||
int request_socket(const char* ip, int port);
|
||||
int ip_from_hostname(const char * hostname , char* ip);
|
||||
int sock_read_buf(void* sock, char*buf,int size);
|
||||
int ws_open_hand_shake(const char* host, int port, const char* resource);
|
||||
//int ws_open_hand_shake(const char* host, int port, const char* resource);
|
||||
char* get_ip_address();
|
||||
#endif
|
Reference in New Issue
Block a user