Skip to content
Snippets Groups Projects
Commit e842590d authored by alexey.stratulat's avatar alexey.stratulat
Browse files

Merge branch 'develop' into bugfix-6845

parents 71458f3d 91fa1bbc
No related branches found
No related tags found
2 merge requests!897hotfix-6925,!864Bugfix 6845
Pipeline #19362 passed with stage
in 5 minutes and 26 seconds
/* 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)
...@@ -35,6 +35,7 @@ dap_tsd_t* dap_tsd_find(byte_t * a_data, size_t a_data_size,uint16_t a_type); ...@@ -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_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_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>" #define DAP_TSD_CORRUPTED_STRING "<CORRUPTED STRING>"
// NULL-terminated string // NULL-terminated string
......
...@@ -63,24 +63,34 @@ HEADERS += $$PWD/include/dap_common.h \ ...@@ -63,24 +63,34 @@ HEADERS += $$PWD/include/dap_common.h \
$$PWD/include/dap_config.h \ $$PWD/include/dap_config.h \
$$PWD/include/dap_math_ops.h \ $$PWD/include/dap_math_ops.h \
$$PWD/include/dap_file_utils.h \ $$PWD/include/dap_file_utils.h \
$$PWD/src/circular_buffer.h \ $$PWD/include/dap_cbuf.h \
$$PWD/include/dap_circular_buffer.h \
$$PWD/include/dap_list.h \ $$PWD/include/dap_list.h \
$$PWD/include/dap_module.h \ $$PWD/include/dap_module.h \
$$PWD/include/dap_strfuncs.h \ $$PWD/include/dap_strfuncs.h \
$$PWD/include/dap_string.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 \ SOURCES += $$PWD/src/dap_common.c \
$$PWD/src/dap_binary_tree.c \ $$PWD/src/dap_binary_tree.c \
$$PWD/src/dap_config.c \ $$PWD/src/dap_config.c \
$$PWD/src/dap_file_utils.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_list.c \
$$PWD/src/dap_module.c \ $$PWD/src/dap_module.c \
$$PWD/src/dap_strfuncs.c \ $$PWD/src/dap_strfuncs.c \
$$PWD/src/dap_string.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 \ INCLUDEPATH += $$PWD/include \
$$PWD/../../3rdparty/uthash/src/ $$PWD/../../3rdparty/uthash/src/
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
/* 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;
}
...@@ -157,11 +157,10 @@ dap_stream_ch_t *l_ch = NULL; ...@@ -157,11 +157,10 @@ dap_stream_ch_t *l_ch = NULL;
return NULL; return NULL;
} }
if ( !a_worker->channels)
return NULL;
pthread_rwlock_rdlock(&a_worker->channels_rwlock); 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); pthread_rwlock_unlock(&a_worker->channels_rwlock);
return l_ch; return l_ch;
...@@ -181,11 +180,9 @@ bool dap_stream_ch_check_uuid(dap_stream_worker_t * a_worker, dap_stream_ch_uuid ...@@ -181,11 +180,9 @@ bool dap_stream_ch_check_uuid(dap_stream_worker_t * a_worker, dap_stream_ch_uuid
return false; return false;
} }
if ( !a_worker->channels)
return false;
pthread_rwlock_rdlock(&a_worker->channels_rwlock); 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); pthread_rwlock_unlock(&a_worker->channels_rwlock);
return l_ch; return l_ch;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment