From eca7d8ab96aa721d339c145e01cf47885d9231f3 Mon Sep 17 00:00:00 2001 From: Dmitriy Gerasimov <dm@cifercom.com> Date: Fri, 12 Jan 2018 00:48:02 +0700 Subject: [PATCH] [*] Renames and fixes --- client/dap_client_remote.c | 8 ++++---- core/dap_config.c | 5 +++-- core/dap_config.h | 2 +- crypt/dap_enc.c | 1 + crypt/dap_enc_key.h | 3 ++- http/CMakeLists.txt | 2 +- http/dap_http_client.c | 18 +++++++++--------- http/dap_http_header.c | 4 ++-- 8 files changed, 23 insertions(+), 20 deletions(-) diff --git a/client/dap_client_remote.c b/client/dap_client_remote.c index c4c849dac0..1756b06a06 100644 --- a/client/dap_client_remote.c +++ b/client/dap_client_remote.c @@ -159,7 +159,7 @@ void dap_client_remove(dap_client_remote_t *sc, struct dap_server * sh) #ifdef DAP_SERVER pthread_mutex_lock(&sh->mutex_on_hash); - log_it(DEBUG, "Client structure remove"); + log_it(L_DEBUGUG, "Client structure remove"); HASH_DEL(sc->server->clients,sc); if(sc->server->client_delete_callback) @@ -247,7 +247,7 @@ size_t dap_client_read(dap_client_remote_t *sc, void * data, size_t data_size) void dap_client_shrink_buf_in(dap_client_remote_t * cl, size_t shrink_size) { if((shrink_size==0)||(cl->buf_in_size==0) ){ - //log_it(WARNING, "DBG_#003"); + //log_it(L_WARNINGNG, "DBG_#003"); return; }else if(cl->buf_in_size>shrink_size){ size_t buf_size=cl->buf_in_size-shrink_size; @@ -255,10 +255,10 @@ void dap_client_shrink_buf_in(dap_client_remote_t * cl, size_t shrink_size) memcpy(buf,cl->buf_in+ shrink_size,buf_size ); memcpy(cl->buf_in,buf,buf_size); cl->buf_in_size=buf_size; - //log_it(WARNING, "DBG_#004"); + //log_it(L_WARNINGNG, "DBG_#004"); free(buf); }else { - //log_it(WARNING, "DBG_#005"); + //log_it(L_WARNINGNG, "DBG_#005"); cl->buf_in_size=0; } diff --git a/core/dap_config.c b/core/dap_config.c index 444c9fb936..9a3b0a74e2 100644 --- a/core/dap_config.c +++ b/core/dap_config.c @@ -25,9 +25,10 @@ void dap_config_deinit() /** * @brief dap_config_open - * @param a_config + * @param a_name + * @return */ -void dap_config_open(dap_config_t * a_config) +dap_config_t * dap_config_open(const char * a_name) { } diff --git a/core/dap_config.h b/core/dap_config.h index 37da2dfe80..24d5691b87 100644 --- a/core/dap_config.h +++ b/core/dap_config.h @@ -27,7 +27,7 @@ typedef struct dap_config{ int dap_config_init(const char * a_configs_path); void dap_config_deinit(); -void dap_config_open(dap_config_t * a_config); +dap_config_t * dap_config_open(const char * a_name); void dap_config_close(dap_config_t * a_config); int32_t dap_config_get_item_int32(dap_config_t * a_config, const char * a_section_path, const char * a_item_name); diff --git a/crypt/dap_enc.c b/crypt/dap_enc.c index eba2bfd7a6..9ac3ebd3e9 100644 --- a/crypt/dap_enc.c +++ b/crypt/dap_enc.c @@ -20,6 +20,7 @@ #include <arpa/inet.h> +#include <time.h> #include <stdlib.h> #include <stdint.h> #include <string.h> diff --git a/crypt/dap_enc_key.h b/crypt/dap_enc_key.h index 6c01bca5de..739d2a1dd6 100644 --- a/crypt/dap_enc_key.h +++ b/crypt/dap_enc_key.h @@ -22,7 +22,7 @@ #define _DAP_ENC_KEY_H_ #include <stddef.h> - +#include <time.h> typedef enum dap_enc_data_type{DAP_ENC_DATA_TYPE_RAW, DAP_ENC_DATA_TYPE_B64, } dap_enc_data_type_t; @@ -98,6 +98,7 @@ typedef size_t (*dap_enc_callback_dataop_t)(struct dap_enc_key *, const void * , typedef struct dap_enc_key{ size_t data_size; + time_t last_used_timestamp; unsigned char * data; dap_enc_key_type_t type; diff --git a/http/CMakeLists.txt b/http/CMakeLists.txt index f91259352c..caf4e162e2 100644 --- a/http/CMakeLists.txt +++ b/http/CMakeLists.txt @@ -5,8 +5,8 @@ set(HTTP_SRCS dap_http_client.c dap_http_header.c) add_library(${PROJECT_NAME} STATIC ${HTTP_SRCS}) include_directories("${dap_core_INCLUDE_DIRS}") -add_definitions ("${dap_core_DEFINITIONS}") include_directories("${dap_client_INCLUDE_DIRS}") +add_definitions ("${dap_core_DEFINITIONS}") add_definitions ("${dap_client_DEFINITIONS}") set(${PROJECT_NAME}_DEFINITIONS CACHE INTERNAL "${PROJECT_NAME}: Definitions" FORCE) diff --git a/http/dap_http_client.c b/http/dap_http_client.c index 1efed3a91b..96da5a6738 100644 --- a/http/dap_http_client.c +++ b/http/dap_http_client.c @@ -135,7 +135,7 @@ bool dap_http_request_line_parse(dap_http_client_t * cl_ht, char * buf, size_t b (pos-pos_kw_begin) ; memcpy(cl_ht->action, buf+pos_kw_begin,c_size ); cl_ht->action[c_size]='\0'; - //log_it(DEBUG, "Input: action '%s' pos=%lu pos_kw_begin=%lu", cl_ht->action,pos,pos_kw_begin); + //log_it(L_DEBUGUG, "Input: action '%s' pos=%lu pos_kw_begin=%lu", cl_ht->action,pos,pos_kw_begin); p_st=PS_URL; pos_kw_begin=pos+1; }break; @@ -145,7 +145,7 @@ bool dap_http_request_line_parse(dap_http_client_t * cl_ht, char * buf, size_t b (pos-pos_kw_begin) ; memcpy(cl_ht->url_path, buf+pos_kw_begin,c_size ); cl_ht->url_path[c_size]='\0'; - //log_it(DEBUG, "Input: url '%s' pos=%lu pos_kw_begin=%lu", cl_ht->url_path,pos,pos_kw_begin); + //log_it(L_DEBUGUG, "Input: url '%s' pos=%lu pos_kw_begin=%lu", cl_ht->url_path,pos,pos_kw_begin); p_st=PS_TYPE; pos_kw_begin=pos+1; }break; @@ -173,7 +173,7 @@ void dap_http_client_read(dap_client_remote_t * cl,void * arg) (void) arg; dap_http_client_t * cl_ht=DAP_HTTP_CLIENT(cl); char buf_line[4096]; -// log_it(DEBUG,"HTTP client in state read %d taked bytes in input %lu",cl_ht->state_read,cl->buf_in_size); +// log_it(L_DEBUGUG,"HTTP client in state read %d taked bytes in input %lu",cl_ht->state_read,cl->buf_in_size); cnt:switch(cl_ht->state_read){ case DAP_HTTP_CLIENT_STATE_START:{ // Beginning of the session. We try to detect int eol = detect_end_of_line(cl->buf_in,cl->buf_in_size); @@ -223,7 +223,7 @@ cnt:switch(cl_ht->state_read){ cl_ht->state_read=DAP_HTTP_CLIENT_STATE_HEADERS; } else{ - log_it(WARNING, "Input: unprocessed URL request %s is rejected", d_name); + log_it(L_WARNINGNG, "Input: unprocessed URL request %s is rejected", d_name); cl_ht->state_read=DAP_HTTP_CLIENT_STATE_NONE; dap_client_ready_to_read(cl_ht->client,true); dap_client_ready_to_write(cl_ht->client,true); @@ -273,7 +273,7 @@ cnt:switch(cl_ht->state_read){ buf_line[eol-1]='\0'; parse_ret=dap_http_header_parse(cl_ht,buf_line); - // log_it(WARNING, "++ ALL HEADERS TO PARSE [%s]", buf_line); + // log_it(L_WARNINGNG, "++ ALL HEADERS TO PARSE [%s]", buf_line); if(parse_ret<0) log_it(L_WARNING,"Input: not a valid header '%s'",buf_line); else if(parse_ret==1){ @@ -311,7 +311,7 @@ cnt:switch(cl_ht->state_read){ } }break; case DAP_HTTP_CLIENT_STATE_DATA:{//Read the data - // log_it(WARNING, "DBG_#002 [%s] [%s]", cl_ht->in_query_string, cl_ht->url_path); + // log_it(L_WARNINGNG, "DBG_#002 [%s] [%s]", cl_ht->in_query_string, cl_ht->url_path); int read_bytes=0; #ifdef DAP_SERVER if(cl_ht->proc->data_read_callback){ @@ -329,7 +329,7 @@ cnt:switch(cl_ht->state_read){ } if(cl->buf_in_size>0){ - //log_it(DEBUG,"Continue to process to parse input"); + //log_it(L_DEBUGUG,"Continue to process to parse input"); goto cnt; } } @@ -344,7 +344,7 @@ void dap_http_client_write(dap_client_remote_t * cl,void * arg) (void) arg; dap_http_client_t * cl_ht=DAP_HTTP_CLIENT(cl); - // log_it(DEBUG,"HTTP client write callback in state %d",cl_ht->state_write); + // log_it(L_DEBUGUG,"HTTP client write callback in state %d",cl_ht->state_write); switch(cl_ht->state_write){ case DAP_HTTP_CLIENT_STATE_NONE: return; case DAP_HTTP_CLIENT_STATE_START:{ @@ -375,7 +375,7 @@ void dap_http_client_write(dap_client_remote_t * cl,void * arg) } dap_client_ready_to_read(cl,true); }else{ - //log_it(DEBUG,"Output: header %s: %s",hdr->name,hdr->value); + //log_it(L_DEBUGUG,"Output: header %s: %s",hdr->name,hdr->value); dap_client_write_f(cl,"%s: %s\n",hdr->name,hdr->value); dap_http_header_remove(&cl_ht->out_headers, hdr); } diff --git a/http/dap_http_header.c b/http/dap_http_header.c index 29798dab55..083f2478b3 100644 --- a/http/dap_http_header.c +++ b/http/dap_http_header.c @@ -77,14 +77,14 @@ int dap_http_header_parse(struct dap_http_client * cl_ht, const char * str) strncpy(name,str,name_len); name[name_len]='\0'; - // log_it(DEBUG, "Found name '%s'",name); + // log_it(L_DEBUGUG, "Found name '%s'",name); pos+=2; size_t value_len=str_len-pos; if(value_len>(sizeof(value)-1)) value_len=(sizeof(value)-1); strncpy(value,str+pos,value_len); value[value_len]='\0'; - // log_it(DEBUG, "Found value '%s'",value); + // log_it(L_DEBUGUG, "Found value '%s'",value); if(strcmp(name,"Connection")==0){ if(strcmp(value,"Keep-Alive")==0){ -- GitLab