From 04e23e07662555083adf19059732bf9768e28f6e Mon Sep 17 00:00:00 2001 From: "Dmitriy A. Gerasimov" <dmitriy.gerasimov@demlabs.net> Date: Wed, 4 Dec 2019 22:25:33 +0700 Subject: [PATCH] [+] Some callbacks and other fields --- dap_chain_net_srv.c | 6 +++--- dap_chain_net_srv.h | 12 +++++++----- dap_chain_net_srv_client.h | 2 ++ dap_chain_net_srv_common.h | 2 ++ 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/dap_chain_net_srv.c b/dap_chain_net_srv.c index 1e9b4c0..4c730e4 100755 --- a/dap_chain_net_srv.c +++ b/dap_chain_net_srv.c @@ -394,7 +394,7 @@ static int s_cli_net_srv( int argc, char **argv, char **a_str_reply) * @param a_uid * @param a_callback_new */ -int dap_chain_net_srv_add(dap_chain_net_srv_uid_t a_uid,dap_chain_net_srv_callback_request_after_t a_callback_request) +int dap_chain_net_srv_add(dap_chain_net_srv_uid_t a_uid,dap_chain_net_srv_callback_data_t a_callback_request) { int ret=0; service_list_t *l_sdata = NULL; @@ -404,7 +404,7 @@ int dap_chain_net_srv_add(dap_chain_net_srv_uid_t a_uid,dap_chain_net_srv_callba if(l_sdata == NULL) { dap_chain_net_srv_t * l_srv = DAP_NEW_Z(dap_chain_net_srv_t); l_srv->uid.uint64 = a_uid.uint64; - l_srv->callback_request = a_callback_request; + l_srv->callback_requested = a_callback_request; l_sdata = DAP_NEW_Z(service_list_t); memcpy(&l_sdata->uid, &l_uid, sizeof(l_uid)); l_sdata->srv = DAP_NEW(dap_chain_net_srv_t); @@ -455,7 +455,7 @@ void dap_chain_net_srv_del_all(void) * @param a_uid * @return */ -dap_chain_net_srv_t * dap_chain_net_srv_get(dap_chain_net_srv_uid_t *a_uid) +dap_chain_net_srv_t * dap_chain_net_srv_get(dap_chain_net_srv_uid_t a_uid) { service_list_t *l_sdata = NULL; pthread_mutex_lock(&s_srv_list_mutex); diff --git a/dap_chain_net_srv.h b/dap_chain_net_srv.h index 348a4bc..4d2b205 100755 --- a/dap_chain_net_srv.h +++ b/dap_chain_net_srv.h @@ -30,8 +30,8 @@ along with any CellFrame SDK based project. If not, see <http://www.gnu.org/lic typedef struct dap_chain_net_srv dap_chain_net_srv_t; -typedef void (*dap_chain_net_srv_callback_t)(dap_chain_net_srv_t *); -typedef int (*dap_chain_net_srv_callback_request_after_t)(dap_chain_net_srv_t *, dap_chain_net_srv_client_t *, const void *, size_t ); +typedef void (*dap_chain_net_srv_callback_t)(dap_chain_net_srv_t *, dap_chain_net_srv_client_t *); +typedef int (*dap_chain_net_srv_callback_data_t)(dap_chain_net_srv_t *, dap_chain_net_srv_client_t *, const void *, size_t ); typedef struct dap_chain_net_srv { @@ -39,7 +39,9 @@ typedef struct dap_chain_net_srv dap_chain_net_srv_abstract_t srv_common; dap_chain_net_srv_price_t *pricelist; dap_chain_callback_trafic_t callback_trafic; - dap_chain_net_srv_callback_request_after_t callback_request; + dap_chain_net_srv_callback_data_t callback_requested; + dap_chain_net_srv_callback_data_t callback_response_success; + dap_chain_net_srv_callback_data_t callback_response_error; void * _inhertor; } dap_chain_net_srv_t; typedef void (*dap_chain_net_srv_callback_new_t)(dap_chain_net_srv_t *, dap_config_t *); @@ -47,10 +49,10 @@ typedef void (*dap_chain_net_srv_callback_new_t)(dap_chain_net_srv_t *, dap_conf int dap_chain_net_srv_init(void); void dap_chain_net_srv_deinit(void); -int dap_chain_net_srv_add(dap_chain_net_srv_uid_t a_uid,dap_chain_net_srv_callback_request_after_t a_callback_request); +int dap_chain_net_srv_add(dap_chain_net_srv_uid_t a_uid,dap_chain_net_srv_callback_data_t a_callback_request); void dap_chain_net_srv_del(dap_chain_net_srv_t * a_srv); void dap_chain_net_srv_del_all(void); -dap_chain_net_srv_t * dap_chain_net_srv_get(dap_chain_net_srv_uid_t *a_uid); +dap_chain_net_srv_t * dap_chain_net_srv_get(dap_chain_net_srv_uid_t a_uid); size_t dap_chain_net_srv_count(void); const dap_chain_net_srv_uid_t * dap_chain_net_srv_list(void); diff --git a/dap_chain_net_srv_client.h b/dap_chain_net_srv_client.h index 25824f1..d385f29 100644 --- a/dap_chain_net_srv_client.h +++ b/dap_chain_net_srv_client.h @@ -33,4 +33,6 @@ typedef struct dap_chain_net_srv_client dap_chain_net_remote_t *net_remote; // For remotes uint64_t bytes_received; uint64_t bytes_sent; + struct dap_chain_net_srv_client *prev; + struct dap_chain_net_srv_client *next; } dap_chain_net_srv_client_t; diff --git a/dap_chain_net_srv_common.h b/dap_chain_net_srv_common.h index 556a9ec..b210f98 100755 --- a/dap_chain_net_srv_common.h +++ b/dap_chain_net_srv_common.h @@ -83,6 +83,8 @@ typedef struct dap_chain_net_srv_price char token[DAP_CHAIN_TICKER_SIZE_MAX]; uint64_t units; dap_chain_net_srv_price_unit_uid_t units_uid; + struct dap_chain_net_srv_price * next; + struct dap_chain_net_srv_price * prev; } dap_chain_net_srv_price_t; -- GitLab