1
0
mirror of https://github.com/lxsang/ant-http synced 2024-07-01 12:59:47 +02:00

remove warning

This commit is contained in:
lxsang 2018-10-07 15:09:46 +02:00
parent 93e2913184
commit dbda222047
10 changed files with 33 additions and 32 deletions

View File

@ -69,7 +69,7 @@ static int config_handler(void* conf, const char* section, const char* name,
else if(strcmp(section,"AUTOSTART")==0){
// The server section must be added before the autostart section
// auto start plugin
plugin_load(value);
plugin_load((char*)value);
} else {
return 0; /* unknown section/name, error */
}
@ -163,7 +163,7 @@ void* accept_request(void* data)
}
// perform the ssl handshake if enabled
#ifdef USE_OPENSSL
int ret,stat;
int ret=-1,stat;
if(server_config.usessl == 1 && client->status == 0)
{
if (SSL_accept((SSL*)client->ssl) == -1) {
@ -178,7 +178,7 @@ void* accept_request(void* data)
task->priority = HIGH_PRIORITY;
return task;
default:
LOG("Error performing SSL handshake %d %d %d\n", stat, ret, ERR_get_error());
LOG("Error performing SSL handshake %d %d %lu\n", stat, ret, ERR_get_error());
ERR_print_errors_fp(stderr);
return task;
}
@ -244,7 +244,7 @@ void* resolve_request(void* data)
char* url = (char*)dvalue(rq->request, "RESOURCE_PATH");
char* newurl = NULL;
char* rqp = (char*)dvalue(rq->request, "REQUEST_PATH");
sprintf(path, server_config.htdocs);
strcpy(path, server_config.htdocs);
strcat(path, url);
LOG("Path is : %s \n", path);
//if (path[strlen(path) - 1] == '/')
@ -366,7 +366,7 @@ int rule_check(const char*k, const char* v, const char* host, const char* _url,
ret = regex_match(k,url, 10, key_matches);
}
else
target = host;
target = (char*)host;
if(!ret)
{
@ -429,7 +429,6 @@ void* serve_file(void* data)
antd_task_t* task = antd_create_task(NULL,(void*)rq,NULL);
task->priority++;
char* path = (char*)dvalue(rq->request, "ABS_RESOURCE_PATH");
char* newurl = NULL;
char* mime_type = (char*)dvalue(rq->request, "RESOURCE_MIME");
ctype(rq->client,mime_type);
if(is_bin(path))
@ -468,7 +467,6 @@ int startup(unsigned *port)
char* apply_rules(const char* host, char*url)
{
association it;
// rule check
char* query_string = url;
while ((*query_string != '?') && (*query_string != '\0'))
@ -566,7 +564,6 @@ void* decode_request_header(void* data)
void* decode_request(void* data)
{
antd_request_t* rq = (antd_request_t*) data;
dictionary request = dvalue(rq->request, "REQUEST_DATA");
dictionary headers = dvalue(rq->request, "REQUEST_HEADER");
int ws = 0;
char*ws_key = NULL;
@ -640,7 +637,7 @@ void* decode_post_request(void* data)
//printf("Multi part form : %s\n", ctype);
// TODO: split this to multiple task
free(task);
return decode_multi_part_request(rq,ctype,request);
return decode_multi_part_request(rq,ctype);
}
else
{
@ -679,7 +676,7 @@ void ws_confirm_request(void* client, const char* key)
SHA1_Init(&context);
SHA1_Update(&context, rkey, strlen(rkey));
SHA1_Final(sha_d, &context);
SHA1_Final((uint8_t*)sha_d, &context);
Base64encode(base64, sha_d, 20);
//printf("Base 64 '%s'\n", base64);
// send accept to client
@ -728,7 +725,7 @@ dictionary decode_cookie(const char* line)
* Decode the multi-part form data from the POST request
* If it is a file upload, copy the file to tmp dir
*/
void* decode_multi_part_request(void* data,const char* ctype, dictionary dic)
void* decode_multi_part_request(void* data,const char* ctype)
{
char * boundary;
char * line;
@ -738,7 +735,6 @@ void* decode_multi_part_request(void* data,const char* ctype, dictionary dic)
antd_task_t* task = antd_create_task(NULL, (void*)rq, NULL);
task->priority++;
//dictionary dic = NULL;
FILE *fp = NULL;
boundary = strsep(&str_copy,"="); //discard first part
boundary = str_copy;
if(boundary && strlen(boundary)>0)

View File

@ -22,6 +22,7 @@
config_t* config();
void destroy_config();
void load_config(const char* file);
void* accept_request(void*);
void* finish_request(void*);
void cat(void*, FILE *);
@ -40,7 +41,7 @@ void* decode_request_header(void* data);
void* decode_request(void* data);
void* decode_post_request(void* data);
void* resolve_request(void* data);
void* decode_multi_part_request(void*,const char*, dictionary);
void* decode_multi_part_request(void*,const char*);
void* decode_multi_part_request_data(void* data);
dictionary decode_cookie(const char*);
char* post_data_decode(void*,int);

View File

@ -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:"");
}

View File

@ -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");

View File

@ -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)
{

View File

@ -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);

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -114,7 +114,7 @@ void unload_plugin_by_name(const char* name)
}
else
{
for (np; np != NULL; np = np->next)
for (; np != NULL; np = np->next)
if (np->next != NULL && strcmp(name, np->next->pname) == 0)
break;
if(np == NULL) return; // the plugin is is not loaded