diff --git a/dap-sdk/core/include/dap_meta.h b/dap-sdk/core/include/dap_meta.h deleted file mode 100644 index a52e63f1e5f9432092aa03632ad3391405ab8a84..0000000000000000000000000000000000000000 --- a/dap-sdk/core/include/dap_meta.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Authors: -* Dmitriy A. Gearasimov <gerasimov.dmitriy@demlabs.net> -* Demlabs Ltd https://demlabs.net -* DAP SDK https://gitlab.demlabs.net/dap/dap-sdk -* Copyright (c) 2021 -* All rights reserved. - -This file is part of DAP SDK the open source project - - DAP SDK 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 SDK 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_common.h" -typedef struct dap_meta{ - uint32_t value_length; - byte_t name_n_value[]; // Name and value are splitted with terminated 0 -} dap_meta_t; - -dap_meta_t * dap_meta_create(const char * a_name, const void * a_data, size_t a_data_size); -dap_meta_t* dap_meta_find(byte_t * a_data, size_t a_data_size, const char * a_name); -int dap_meta_check(dap_meta_t * a_meta); - -#define dap_meta_create_scalar(name,value) dap_meta_create (name, &value, sizeof(value) ) -#define dap_meta_get_scalar(a,typeconv) *((typeconv*) a->name_n_value + strlen(a->name_n_value)+1) - -// NULL-terminated string -#define dap_meta_create_string(name,str) dap_meta_create (name,str, dap_strlen(str)+1) -#define dap_meta_get_string(a) ( ((char*) a->name_n_value+ strlen((char*) a->name_n_value)+1)[a->value_length-1] == '\0'? (char*) a->name_n_value : "<CORRUPTED STRING>" ) -#define dap_meta_get_string_const(a) ( ((const char*) a->name_n_value + strlen((char*) a->name_n_value)+1 )[a->value_length-1] == '\0'? (const char*) a->name_n_value : "<CORRUPTED STRING>" ) - -#define dap_meta_name(a) ( ((char*) a->name_n_value+ strlen((char*) a->name_n_value)+1)[a->value_length-1] == '\0'? (char*) a->name_n_value : "<CORRUPTED STRING>" ) - -#define dap_meta_size(a) (sizeof(*a)+a->value_length+ strlen((char*) a->name_n_value)+1) diff --git a/dap-sdk/core/include/dap_tsd.h b/dap-sdk/core/include/dap_tsd.h index c2af00d346fa7afef2ac87b84cdaf6d5dba4ea44..4b13991e1c3e1a283de6551bdc1c2e8b7b4cd87a 100644 --- a/dap-sdk/core/include/dap_tsd.h +++ b/dap-sdk/core/include/dap_tsd.h @@ -35,6 +35,7 @@ dap_tsd_t* dap_tsd_find(byte_t * a_data, size_t a_data_size,uint16_t a_type); #define dap_tsd_create_scalar(type,value) dap_tsd_create (type, &value, sizeof(value) ) #define dap_tsd_get_scalar(a,typeconv) ( a->size >= sizeof(typeconv) ? *((typeconv*) a->data) : (typeconv) {0}) +#define dap_tsd_get_object(a,typeconv) ( a->size >= sizeof(typeconv) ? ((typeconv*) a->data) : (typeconv *) {0}) #define DAP_TSD_CORRUPTED_STRING "<CORRUPTED STRING>" // NULL-terminated string diff --git a/dap-sdk/core/libdap.pri b/dap-sdk/core/libdap.pri index 3b73f16fd25bebc2e83ca06bf460d8304ffefd27..6fd88194c8b2fe689bf4de5f0376ecf769c111a5 100755 --- a/dap-sdk/core/libdap.pri +++ b/dap-sdk/core/libdap.pri @@ -63,24 +63,34 @@ HEADERS += $$PWD/include/dap_common.h \ $$PWD/include/dap_config.h \ $$PWD/include/dap_math_ops.h \ $$PWD/include/dap_file_utils.h \ - $$PWD/src/circular_buffer.h \ - $$PWD/include/dap_circular_buffer.h \ + $$PWD/include/dap_cbuf.h \ $$PWD/include/dap_list.h \ $$PWD/include/dap_module.h \ $$PWD/include/dap_strfuncs.h \ $$PWD/include/dap_string.h \ - $$PWD/include/dap_time.h + $$PWD/include/dap_time.h \ + $$PWD/include/dap_tsd.h \ + $$PWD/include/dap_fnmatch.h \ + $$PWD/include/dap_fnmatch_loop.h \ + $$PWD/include/portable_endian.h SOURCES += $$PWD/src/dap_common.c \ $$PWD/src/dap_binary_tree.c \ $$PWD/src/dap_config.c \ $$PWD/src/dap_file_utils.c \ - $$PWD/src/dap_circular_buffer.c \ + $$PWD/src/dap_cbuf.c \ $$PWD/src/dap_list.c \ $$PWD/src/dap_module.c \ $$PWD/src/dap_strfuncs.c \ $$PWD/src/dap_string.c \ - $$PWD/src/dap_time.c + $$PWD/src/dap_time.c \ + $$PWD/src/dap_tsd.c \ + $$PWD/src/dap_fnmatch.c + + + + + INCLUDEPATH += $$PWD/include \ $$PWD/../../3rdparty/uthash/src/ diff --git a/dap-sdk/core/src/core.pri b/dap-sdk/core/src/core.pri deleted file mode 100755 index 167cbf27f0f7516f407f24848e24ee333a2373ff..0000000000000000000000000000000000000000 --- a/dap-sdk/core/src/core.pri +++ /dev/null @@ -1,33 +0,0 @@ -unix { - include(unix/unix.pri) - LIBS += -lrt -} -darwin { - include(darwin/darwin.pri) -} - -HEADERS += $$PWD/dap_common.h \ - $$PWD/dap_config.h \ - $$PWD/dap_math_ops.h \ - $$PWD/uthash.h \ - $$PWD/utlist.h \ - $$PWD/dap_math_ops.h \ - $$PWD/dap_file_utils.h \ - $$PWD/dap_cbuf.h \ - $$PWD/dap_list.h \ - $$PWD/dap_module.h \ - $$PWD/dap_strfuncs.h \ - $$PWD/dap_string.h \ - $$PWD/dap_time.h - -SOURCES += $$PWD/dap_common.c \ - $$PWD/dap_config.c \ - $$PWD/dap_file_utils.c \ - $$PWD/dap_cbuf.c \ - $$PWD/dap_list.c \ - $$PWD/dap_module.c \ - $$PWD/dap_strfuncs.c \ - $$PWD/dap_string.c \ - $$PWD/dap_time.c - -INCLUDEPATH += $$PWD diff --git a/dap-sdk/core/src/dap_meta.c b/dap-sdk/core/src/dap_meta.c deleted file mode 100644 index 830fd8ff9046bcca7ad079a1b4b413e08d3c9b3b..0000000000000000000000000000000000000000 --- a/dap-sdk/core/src/dap_meta.c +++ /dev/null @@ -1,87 +0,0 @@ -/* Authors: -* Dmitriy A. Gearasimov <gerasimov.dmitriy@demlabs.net> -* Demlabs Ltd https://demlabs.net -* DAP SDK https://gitlab.demlabs.net/dap/dap-sdk -* Copyright (c) 2021 -* All rights reserved. - -This file is part of DAP SDK the open source project - - DAP SDK 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 SDK 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_meta.h" - -#define LOG_TAG "dap_meta" - -/** - * @brief dap_meta_create - * @param a_name - * @param a_data - * @param a_data_size - * @return - */ -dap_meta_t * dap_meta_create(const char * a_name, const void * a_data, size_t a_data_size) -{ - if ( !a_name) - return NULL; - size_t a_name_len = strlen(a_name); - - if( ! a_name_len ) - return NULL; - - dap_meta_t * l_ret = DAP_NEW_Z_SIZE(dap_meta_t, sizeof (dap_meta_t)+a_name_len+1+a_data_size ); - if (l_ret){ - memcpy(l_ret->name_n_value,a_name,a_name_len); - if(a_data_size) - memcpy(l_ret->name_n_value+a_name_len+1,a_data,a_data_size); - } - return l_ret; -} - -/** - * @brief dap_meta_find - * @param a_data - * @param a_data_size - * @param a_name - * @return - */ -dap_meta_t* dap_meta_find(byte_t * a_data, size_t a_data_size, const char * a_name) -{ - dap_meta_t * l_ret = NULL; - for(size_t l_offset=0; l_offset<a_data_size; ){ - dap_meta_t * l_meta =(dap_meta_t*) (a_data + l_offset); - size_t l_meta_size = dap_meta_size(l_meta); - if( !l_meta_size || l_meta_size +l_offset > a_data_size){ - break; - } - - if (strcmp( dap_meta_name(l_meta), a_name) == 0 ){ - l_ret = l_meta; - break; - } - - l_offset+=l_meta_size; - } - return l_ret; -} - -/** - * @brief dap_meta_check - * @param a_meta - * @return - */ -int dap_meta_check(dap_meta_t * a_meta) -{ - return -1; -} diff --git a/dap-sdk/net/stream/ch/dap_stream_ch.c b/dap-sdk/net/stream/ch/dap_stream_ch.c index 2e3d6967d9c1ea2d7b9e3e980fbfdf00e845b976..d6873a645720a02ed65830ce2d468acc143c69c6 100644 --- a/dap-sdk/net/stream/ch/dap_stream_ch.c +++ b/dap-sdk/net/stream/ch/dap_stream_ch.c @@ -157,11 +157,10 @@ dap_stream_ch_t *l_ch = NULL; return NULL; } - if ( !a_worker->channels) - return NULL; pthread_rwlock_rdlock(&a_worker->channels_rwlock); - HASH_FIND(hh_worker,a_worker->channels ,&a_ch_uuid, sizeof(a_ch_uuid), l_ch ); + if ( a_worker->channels) + HASH_FIND(hh_worker,a_worker->channels ,&a_ch_uuid, sizeof(a_ch_uuid), l_ch ); pthread_rwlock_unlock(&a_worker->channels_rwlock); return l_ch; @@ -181,11 +180,9 @@ bool dap_stream_ch_check_uuid(dap_stream_worker_t * a_worker, dap_stream_ch_uuid return false; } - if ( !a_worker->channels) - return false; - pthread_rwlock_rdlock(&a_worker->channels_rwlock); - HASH_FIND(hh_worker,a_worker->channels ,&a_ch_uuid, sizeof(a_ch_uuid), l_ch ); + if ( a_worker->channels) + HASH_FIND(hh_worker,a_worker->channels ,&a_ch_uuid, sizeof(a_ch_uuid), l_ch ); pthread_rwlock_unlock(&a_worker->channels_rwlock); return l_ch;