Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • cellframe/cellframe-sdk
  • MIKA83/cellframe-sdk
2 results
Show changes
Commits on Source (13)
Showing
with 175 additions and 356 deletions
......@@ -123,6 +123,12 @@ if (CELLFRAME_MODULES MATCHES "srv-stake")
set(CELLFRAME_LIBS ${CELLFRAME_LIBS} dap_chain_net_srv_stake )
endif()
# Enable service for dynamic modules
if (CELLFRAME_MODULES MATCHES "modules-dynamic")
message("[+] Module 'dap_modules_dynamic_cdb'")
set(CELLFRAME_LIBS ${CELLFRAME_LIBS} dap_modules_dynamic_cdb )
endif()
if (WIN32)
set(CELLFRAME_LIBS ${CELLFRAME_LIBS} KERNEL32 USER32 SHELL32 WINMM GDI32 ADVAPI32
Ole32 Version Imm32 OleAut32 ws2_32 ntdll psapi
......
......@@ -24,10 +24,16 @@
#pragma once
#include <string.h>
#include "dap_common.h"
#include "dap_list.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef const char *dap_binary_tree_key_t;
#define KEY_LS(a, b) (strcmp(a, b) < 0)
#define KEY_GT(a, b) (strcmp(a, b) > 0)
......@@ -48,3 +54,8 @@ dap_binary_tree_t *dap_binary_tree_insert(dap_binary_tree_t *a_tree_root, dap_bi
dap_binary_tree_t *dap_binary_tree_delete(dap_binary_tree_t *a_tree_root, dap_binary_tree_key_t a_key);
size_t dap_binary_tree_count(dap_binary_tree_t *a_tree_root);
void dap_binary_tree_clear(dap_binary_tree_t *a_tree_root);
#ifdef __cplusplus
}
#endif
......@@ -5,6 +5,12 @@
#ifndef __DAP_LIST_H__
#define __DAP_LIST_H__
#ifdef __cplusplus
extern "C" {
#endif
typedef void (*dap_callback_destroyed_t)(void* data);
typedef void (*dap_callback_t)(void* data, void* user_data);
typedef void* (*dap_callback_copy_t)(const void * src, void* data);
......@@ -60,3 +66,8 @@ void* dap_list_nth_data(dap_list_t *list, unsigned int n);
#define dap_list_next(list) ((list) ? (((dap_list_t *)(list))->next) : NULL)
#endif /* __DAP_LIST_H__ */
#ifdef __cplusplus
}
#endif
......@@ -236,7 +236,7 @@ int dap_common_init( const char *a_console_title, const char *a_log_filename ) {
s_log_file = fopen( a_log_filename , "w" );
if ( s_log_file == NULL ) {
dap_fprintf( stderr, "Can't open log file %s to append\n", a_log_filename );
return -1;
//return -1; //switch off show log in cosole if file not open
}
dap_stpcpy(s_log_file_path, a_log_filename);
}
......
......@@ -523,8 +523,6 @@ static void read_write_cb( dap_client_remote_t *dap_cur, int32_t revents )
log_it( L_ERROR, "epoll_ctl failed..." );
dap_cur->flags |= DAP_SOCK_SIGNAL_CLOSE;
break;
} else {
log_it( L_INFO, "wait for available space in buff..." );
}
} else {
log_it(L_ERROR,"[THREAD %u] Error occured in send() function %s", dap_cur->tn, strerror(errno) );
......
......@@ -345,8 +345,8 @@ void dap_udp_server_loop( dap_server_t *d_server )
sb_payload_ready = false;
struct epoll_event pev;
struct epoll_event events[ 16 ];
struct epoll_event pev = {0, {0}};
struct epoll_event events[ 16 ] = {{0, {0}}};
pev.events = EPOLLIN | EPOLLERR;
pev.data.fd = d_server->socket_listener;
......
......@@ -103,6 +103,7 @@ dap_stream_ch_t* dap_stream_ch_new(dap_stream_t* a_stream, uint8_t id)
pthread_rwlock_unlock(&a_stream->rwlock);
struct dap_stream_ch_table_t *l_new_ch = DAP_NEW_Z(struct dap_stream_ch_table_t);
l_new_ch->ch = ret;
pthread_mutex_lock(&s_ch_table_lock);
HASH_ADD_PTR(s_ch_table, ch, l_new_ch);
pthread_mutex_unlock(&s_ch_table_lock);
......@@ -120,7 +121,7 @@ bool dap_stream_ch_valid(dap_stream_ch_t *a_ch)
if(!a_ch)
return false;
pthread_mutex_lock(&s_ch_table_lock);
HASH_FIND_PTR(s_ch_table, a_ch, l_ret);
HASH_FIND_PTR(s_ch_table, &a_ch, l_ret);
pthread_mutex_unlock(&s_ch_table_lock);
return l_ret;
}
......@@ -132,8 +133,8 @@ bool dap_stream_ch_valid(dap_stream_ch_t *a_ch)
void dap_stream_ch_delete(dap_stream_ch_t *a_ch)
{
pthread_mutex_lock(&s_ch_table_lock);
struct dap_stream_ch_table_t *l_ret;;
HASH_FIND_PTR(s_ch_table, a_ch, l_ret);
struct dap_stream_ch_table_t *l_ret;
HASH_FIND_PTR(s_ch_table, &a_ch, l_ret);
HASH_DEL(s_ch_table, l_ret);
pthread_mutex_unlock(&s_ch_table_lock);
......
......@@ -86,6 +86,11 @@ if (CELLFRAME_MODULES MATCHES "srv-stake")
add_subdirectory(service/stake)
endif()
# Support for dynamic modules
if (CELLFRAME_MODULES MATCHES "modules-dynamic")
add_subdirectory(modules_dynamic)
endif()
# Unit tests
if( BUILD_TESTS)
add_subdirectory(test)
......
add_subdirectory(cdb)
cmake_minimum_required(VERSION 2.8)
project (dap_modules_dynamic_cdb)
file(GLOB DAP_MODULES_DYNAMIC_CDB_SRCS *.c)
file(GLOB DAP_MODULES_DYNAMIC_CDB_HEADERS include/*.h)
add_library(${PROJECT_NAME} STATIC ${DAP_MODULES_DYNAMIC_CDB_SRCS} ${DAP_MODULES_DYNAMIC_CDB_HEADERS})
#target_link_libraries(dap_chain_net_srv dap_core dap_crypto dap_chain dap_chain_net dap_chain_wallet)
target_link_libraries(${PROJECT_NAME} dap_core dap_http_server ${CMAKE_DL_LIBS})
target_include_directories(${PROJECT_NAME} INTERFACE .)
target_include_directories(${PROJECT_NAME} PUBLIC include)
/*
* Authors:
* Aleksei I. Voronin <aleksei.voronin@demlabs.net>
* DeM Labs Inc. https://demlabs.net
* Kelvin Project https://github.com/kelvinblockchain
* Copyright (c) 2017-2019
* All rights reserved.
This file is part of DAP (Deus Applications Prototypes) the open source project
DAP (Deus Applicaions Prototypes) is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DAP is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with any DAP based project. If not, see <http://www.gnu.org/licenses/>.
*/
#include "dap_modules_dynamic_cdb.h"
#include "dap_common.h"
#ifdef DAP_OS_LINUX
#include <dlfcn.h>
#endif
#define LOG_TAG "dap_http"
static const char * s_default_path_modules = "var/modules";
int dap_modules_dynamic_load_cdb(dap_http_t * a_server){
char l_lib_path[MAX_PATH] = {'\0'};
#if defined (DAP_OS_LINUX) && !defined (__ANDROID__)
const char * l_cdb_so_name = "libcellframe-node-cdb.so";
dap_sprintf(l_lib_path, "%s/%s/%s", g_sys_dir_path, s_default_path_modules, l_cdb_so_name);
void* l_cdb_handle = NULL;
l_cdb_handle = dlopen(l_lib_path, RTLD_NOW);
if(!l_cdb_handle){
log_it(L_ERROR,"Can't load %s module: %s", l_cdb_so_name, dlerror());
return -1;
}
int (*dap_chain_net_srv_vpn_cdb_init)(dap_http_t*);
const char * l_init_func_name = "dap_chain_net_srv_vpn_cdb_init";
*(void **) (&dap_chain_net_srv_vpn_cdb_init) = dlsym(l_cdb_handle, l_init_func_name);
char* error;
if (( error = dlerror()) != NULL) {
log_it(L_ERROR,"%s module: %s error loading %s (%s)", l_cdb_so_name, l_init_func_name, error);
return -2;
}
int l_init_res = (*dap_chain_net_srv_vpn_cdb_init)(a_server);
if(l_init_res){
log_it(L_ERROR,"%s: %s returns %d", l_cdb_so_name, l_init_func_name, error);
return -3;
}
return 0;
#else
log_it(L_ERROR,"%s: module is not supported on current platfrom", __PRETTY_FUNCTION__);
return -3;
#endif
}
/*
* Authors:
* Aleksei I. Voronin <aleksei.voronin@demlabs.net>
* DeM Labs Inc. https://demlabs.net
* Kelvin Project https://github.com/kelvinblockchain
* Copyright (c) 2017-2019
* All rights reserved.
This file is part of DAP (Deus Applications Prototypes) the open source project
DAP (Deus Applicaions Prototypes) is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DAP is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with any DAP based project. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "dap_http.h"
int dap_modules_dynamic_load_cdb(dap_http_t * a_server);
/*
* Authors:
* Alexander Lysikov <alexander.lysikov@demlabs.net>
* DeM Labs Inc. https://demlabs.net
* Kelvin Project https://github.com/kelvinblockchain
* Copyright (c) 2020
* All rights reserved.
This file is part of DAP (Deus Applications Prototypes) the open source project
DAP (Deus Applicaions Prototypes) is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DAP is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with any DAP based project. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdint.h>
#include "dap_common.h"
#include "dap_string.h"
#include "dap_strfuncs.h"
#include "dap_file_utils.h"
#include "dap_config.h"
#include "rand/dap_rand.h"
#include "http_status_code.h"
#include "dap_http_simple.h"
#include "dap_enc_http.h"
#include "dap_chain_net_bugreport.h"
#define LOG_TAG "chain_net_bugreport"
#define BUGREPORT_URL "/bugreport"
static int64_t bugreport_write_to_file(byte_t *a_request_byte, size_t a_request_size)
{
int64_t l_report_number = -2;
if(!a_request_byte || !a_request_size)
return -1;
char *l_dir_str = dap_strdup_printf("%s/var/bugreport", g_sys_dir_path);
dap_mkdir_with_parents(l_dir_str);
const time_t l_timer = time(NULL);
struct tm l_tm;
localtime_r(&l_timer, &l_tm);
// create unique number for bugreport
randombytes(&l_report_number, sizeof(int64_t));
if(l_report_number < 0)
l_report_number = -l_report_number;
//l_report_number 5 characters long
l_report_number %= 100000ll;
/*
// l_report_number 20 characters long
l_report_number -= l_report_number%1000000000000ll;
l_report_number+=(int64_t)(l_tm.tm_year - 100)*10000000000;
l_report_number+=(int64_t)(l_tm.tm_mon)*100000000;
l_report_number+=(int64_t)(l_tm.tm_mday)*1000000;
l_report_number+=(int64_t)(l_tm.tm_hour)*10000;
l_report_number+=(int64_t)(l_tm.tm_min)*100;
l_report_number+=(int64_t)(l_tm.tm_sec);
*/
char *l_filename_str = dap_strdup_printf("%s/%02d-%02d-%02d_%02d:%02d:%02d_%05lld.brt", l_dir_str,
l_tm.tm_year - 100, l_tm.tm_mon, l_tm.tm_mday,
l_tm.tm_hour, l_tm.tm_min, l_tm.tm_sec,
l_report_number);
FILE *l_fp;
if((l_fp = fopen(l_filename_str, "wb")) != NULL) {
if(fwrite(a_request_byte, 1, a_request_size, l_fp) != a_request_size)
l_report_number = -3;
fclose(l_fp);
}
DAP_DELETE(l_filename_str);
DAP_DELETE(l_dir_str);
return l_report_number;
}
/**
* @brief bugreport_http_proc
* @param a_http_simple
* @param a_arg
*/
static void bugreport_http_proc(struct dap_http_simple *a_http_simple, void * a_arg)
{
// data:text/html,<form action=http://192.168.100.92:8079/bugreport/ method=post><input name=a></form>
// data:text/html,<form action=http://cdb.klvn.io/bugreport/ method=post><input name=a></form>
log_it(L_DEBUG, "bugreport_http_proc request");
http_status_code_t * return_code = (http_status_code_t*) a_arg;
//if(dap_strcmp(cl_st->http->url_path, BUGREPORT_URL) == 0 )
if(dap_strcmp(a_http_simple->http->action, "GET") == 0) {
size_t l_url_len = dap_strlen(a_http_simple->http->url_path);
if(!l_url_len) {
a_http_simple->reply = dap_strdup_printf("Unique Bug Report number required)");
*return_code = Http_Status_NotFound;
}
else{
*return_code = Http_Status_OK;
}
a_http_simple->reply_size = strlen(a_http_simple->reply);
*return_code = Http_Status_NotFound;
}
if(dap_strcmp(a_http_simple->http->action, "POST") == 0) {
//a_http_simple->request_byte;
//a_http_simple->request_size;
//a_http_simple->http->in_content_length;
int64_t l_bugreport_number = bugreport_write_to_file(a_http_simple->request_byte, a_http_simple->request_size);
if(l_bugreport_number >= 0) {
//l_report_number 5 characters long
a_http_simple->reply = dap_strdup_printf("Bug Report #%05lld saved successfully)", l_bugreport_number);
//l_report_number 20 characters long
//a_http_simple->reply = dap_strdup_printf("Bug Report #%020lld saved successfully)", l_bugreport_number);
}
else {
a_http_simple->reply = dap_strdup_printf("Bug Report not saved( code=%lld", l_bugreport_number);
}
a_http_simple->reply_size = strlen(a_http_simple->reply);
*return_code = Http_Status_OK;
} else {
log_it(L_ERROR, "Wrong action '%s' for the request. Must be 'POST'", a_http_simple->http->action);
a_http_simple->reply = dap_strdup_printf("Wrong action '%s' for the request. Must be 'POST'",
a_http_simple->http->action);
a_http_simple->reply_size = strlen(a_http_simple->reply);
*return_code = Http_Status_NotFound;
}
}
/**
* @brief dap_chain_net_bugreport_add_proc
* @param sh HTTP server instance
*/
void dap_chain_net_bugreport_add_proc(struct dap_http * sh)
{
const char * url = BUGREPORT_URL;
dap_http_simple_proc_add(sh, url, 14096, bugreport_http_proc);
}
/*
* Authors:
* Alexander Lysikov <alexander.lysikov@demlabs.net>
* DeM Labs Inc. https://demlabs.net
* Kelvin Project https://github.com/kelvinblockchain
* Copyright (c) 2020
* All rights reserved.
This file is part of DAP (Deus Applications Prototypes) the open source project
DAP (Deus Applicaions Prototypes) is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DAP is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with any DAP based project. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stddef.h>
#include "dap_common.h"
#include "dap_string.h"
#include "dap_strfuncs.h"
#include "dap_file_utils.h"
#include "dap_config.h"
#include "http_status_code.h"
#include "dap_http_simple.h"
#include "dap_enc_http.h"
//#include "<dap_chain_global_db_driver.h>
#include "dap_chain_global_db.h"
#include "dap_chain_net_news.h"
#define LOG_TAG "chain_net_news"
#define NEWS_URL "/news"
#define GROUP_NEWS "cdb.news"
#define DEFAULT_LANG "en"
/* Set news in the selected language
* a_lang - a language like "en", "ru", "fr"
* a_data_news - news data
* a_data_news_len length of news
*/
int dap_chain_net_news_write(const char *a_lang, char *a_data_news, size_t a_data_news_len)
{
if(!a_data_news || !a_data_news_len)
return -2;
if(!a_lang)
a_lang = DEFAULT_LANG;
if(dap_chain_global_db_gr_set(dap_strdup(a_lang), a_data_news, a_data_news_len, GROUP_NEWS))
return 0;
return -1;
}
/* Get news in the selected language
* a_lang - a language like "en", "ru", "fr"
*/
byte_t* dap_chain_net_news_read(const char *a_lang, size_t *a_news_len)
{
if(!a_lang)
return NULL;
byte_t *l_ret_data = NULL;
size_t l_data_len_num = 0;
dap_store_obj_t *l_obj = dap_chain_global_db_obj_gr_get(a_lang, &l_data_len_num, GROUP_NEWS);
if(l_obj && l_obj->value_len) {
l_ret_data = DAP_NEW_Z_SIZE(byte_t, l_obj->value_len);
memcpy(l_ret_data, l_obj->value, l_obj->value_len);
if(a_news_len)
*a_news_len = l_obj->value_len;
}
dap_store_obj_free(l_obj, l_data_len_num);
return l_ret_data;
}
/**
* @brief news_http_proc
* @param a_http_simple
* @param a_arg
*/
static void news_http_proc(struct dap_http_simple *a_http_simple, void * a_arg)
{
log_it(L_DEBUG, "news_http_proc request");
http_status_code_t * return_code = (http_status_code_t*) a_arg;
const char *l_lang = DEFAULT_LANG;
if(dap_strcmp(a_http_simple->http->url_path, NEWS_URL)) {
l_lang = a_http_simple->http->url_path;
}
if(l_lang)
{
size_t l_news_data_len = 0;
// get news in the selected language
byte_t *l_news_data = dap_chain_net_news_read(l_lang, &l_news_data_len);
// get news in the default language
if(!l_news_data && dap_strcmp(a_http_simple->http->in_query_string, "LocalNewsOnly"))
l_news_data = dap_chain_net_news_read(DEFAULT_LANG, &l_news_data_len);
if( l_news_data){
a_http_simple->reply = l_news_data ;
a_http_simple->reply_size = l_news_data_len;
}else{
a_http_simple->reply = dap_strdup("no news");
a_http_simple->reply_size = dap_strlen((char*) a_http_simple->reply) + 1;
}
*return_code = Http_Status_OK;
}
else {
log_it(L_ERROR, "Wrong request. Must be %s/<lang_code>, example http:/<addr>%s/en", NEWS_URL, NEWS_URL);
a_http_simple->reply = dap_strdup_printf("Wrong request. Must be %s/<lang_code>, example http:/<addr>%s/en",
NEWS_URL, NEWS_URL);
a_http_simple->reply_size = strlen(a_http_simple->reply);
*return_code = Http_Status_NotFound;
}
}
/**
* @brief dap_chain_net_news_add_proc
* @param sh HTTP server instance
*/
void dap_chain_net_news_add_proc(struct dap_http * sh)
{
const char * url = NEWS_URL;
dap_http_simple_proc_add(sh, url, 14096, news_http_proc);
}
......@@ -24,16 +24,4 @@
#include "dap_http.h"
/* Set news in the selected language
* a_lang - a language like "en", "ru", "fr"
* a_data_news - news data
* a_data_news_len length of news
*/
int dap_chain_net_news_write(const char *a_lang, char *a_data_news, size_t a_data_news_len);
/* Get news in the selected language
* a_lang - a language like "en", "ru", "fr"
*/
byte_t* dap_chain_net_news_read(const char *a_lang, size_t *a_news_len);
void dap_chain_net_news_add_proc(struct dap_http * sh);
int dap_chain_net_news_init(dap_http_t * a_http);
......@@ -308,7 +308,10 @@ static void* thread_one_client_func(void *args)
list = dap_list_next(list);
DAP_DELETE(str_cmd_prev);
}
log_it(L_INFO, "execute command=%s", str_cmd);
if(l_cmd->overrides.log_cmd_call)
l_cmd->overrides.log_cmd_call(str_cmd);
else
log_it(L_INFO, "execute command=%s", str_cmd);
// exec command
char **l_argv = dap_strsplit(str_cmd, ";", -1);
......@@ -733,6 +736,12 @@ void dap_chain_node_cli_cmd_item_create(const char * a_name, cmdfunc_t *a_func,
log_it(L_DEBUG,"Added command %s",l_cmd_item->name);
}
void dap_chain_node_cli_cmd_item_apply_overrides(const char * a_name, const dap_chain_node_cmd_item_func_overrides_t * a_overrides){
dap_chain_node_cmd_item_t *l_cmd_item = dap_chain_node_cli_cmd_find(a_name);
if(l_cmd_item)
l_cmd_item->overrides = *a_overrides;
}
/**
* @brief dap_chain_node_cli_command_get_first
* @return
......@@ -960,11 +969,6 @@ int dap_chain_node_cli_init(dap_config_t * g_config)
dap_chain_node_cli_cmd_item_create ("exit", com_exit, NULL, "Stop application and exit",
"exit\n" );
//#ifndef _WIN32
// News
dap_chain_node_cli_cmd_item_create("news", com_news, NULL, "Add News for VPN clients. Language code is a text code like \"en\", \"ru\", \"fr\"",
"news [-text <news text> | -file <filename with news>] -lang <language code> \n");
//#endif
// create thread for waiting of clients
pthread_t l_thread_id;
......
......@@ -3755,47 +3755,3 @@ int com_print_log(int argc, char ** argv, void *arg_func, char **str_reply)
return 0;
}
/**
* Add News for VPN clients
* news [-text <news text> | -file <filename with news>] -lang <language code>
*/
int com_news(int a_argc, char ** a_argv, void *a_arg_func, char **a_str_reply)
{
int arg_index = 1;
const char * l_str_lang = NULL;
const char * l_str_text = NULL;
const char * l_str_file = NULL;
dap_chain_node_cli_find_option_val(a_argv, arg_index, a_argc, "-lang", &l_str_lang);
dap_chain_node_cli_find_option_val(a_argv, arg_index, a_argc, "-text", &l_str_text);
dap_chain_node_cli_find_option_val(a_argv, arg_index, a_argc, "-file", &l_str_file);
if(!l_str_text && !l_str_file) {
dap_chain_node_cli_set_reply_text(a_str_reply, "no source of news, add parameter -text or -file");
return -1;
}
char *l_data_news;
size_t l_data_news_len = 0;
const char *l_from = NULL;
if(l_str_text) {
l_data_news = dap_strdup(l_str_text);
l_data_news_len = dap_strlen(l_str_text);
l_from = "text";
}
else if(l_str_file) {
if(dap_file_get_contents(l_str_file, &l_data_news,&l_data_news_len)) {
l_from = "file";
}
else{
dap_chain_node_cli_set_reply_text(a_str_reply, "Can't read file %s", l_str_file);
return -2;
}
}
int l_res = dap_chain_net_news_write(l_str_lang, l_data_news, l_data_news_len);
if(l_res){
dap_chain_node_cli_set_reply_text(a_str_reply, "Error, News cannot be added from %s", l_from);
return -3;
}
dap_chain_node_cli_set_reply_text(a_str_reply, "News added from %s successfully", l_from);
return 0;
}
......@@ -24,4 +24,4 @@
#include "dap_http.h"
void dap_chain_net_bugreport_add_proc(struct dap_http * sh);
int dap_chain_net_bugreport_init(dap_http_t * a_http);
......@@ -40,12 +40,20 @@ typedef int SOCKET;
typedef int cmdfunc_t(int argc, char ** argv, void *arg_func, char **str_reply);
typedef void cmd_item_func_override_log_cmd_call(const char*);
typedef struct dap_chain_node_cmd_item_func_overrides{
/* use it if you want to prevent logging of some sensetive data */
cmd_item_func_override_log_cmd_call * log_cmd_call;
} dap_chain_node_cmd_item_func_overrides_t;
typedef struct dap_chain_node_cmd_item{
char name[32]; /* User printable name of the function. */
cmdfunc_t *func; /* Function to call to do the job. */
void *arg_func; /* additional argument of function*/
char *doc; /* Documentation for this function. */
char *doc_ex; /* Full documentation for this function. */
dap_chain_node_cmd_item_func_overrides_t overrides; /* Used to change default behaviour */
UT_hash_handle hh;
} dap_chain_node_cmd_item_t;
......@@ -60,6 +68,7 @@ long s_recv(SOCKET sock, unsigned char *buf, size_t bufsize, int timeout);
dap_chain_node_cmd_item_t* dap_chain_node_cli_cmd_get_first();
dap_chain_node_cmd_item_t* dap_chain_node_cli_cmd_find(const char *a_name);
void dap_chain_node_cli_cmd_item_create(const char * a_name, cmdfunc_t *a_func, void *a_arg_func, const char *a_doc, const char *a_doc_ex);
void dap_chain_node_cli_cmd_item_apply_overrides(const char * a_name, const dap_chain_node_cmd_item_func_overrides_t * a_overrides);
void dap_chain_node_cli_set_reply_text(char **str_reply, const char *str, ...);
......
......@@ -133,11 +133,6 @@ int com_stats(int argc, char ** argv, void *arg_func, char **str_reply);
int com_exit(int argc, char ** argv, void *arg_func, char **str_reply);
//#ifndef _WIN32
// Add News for VPN clients
int com_news(int a_argc, char ** a_argv, void *a_arg_func, char **a_str_reply);
//#endif
int com_mempool_delete(int argc, char ** argv, void *arg_func, char ** a_str_reply);
int com_mempool_list(int argc, char ** argv, void *arg_func, char ** a_str_reply);
int com_mempool_proc(int argc, char ** argv, void *arg_func, char ** a_str_reply);
......