diff --git a/libbbfdm-ubus/common.c b/libbbfdm-ubus/common.c index 81df3e62..9666d5dc 100644 --- a/libbbfdm-ubus/common.c +++ b/libbbfdm-ubus/common.c @@ -12,64 +12,6 @@ #include "common.h" #include "get_helper.h" -bool get_boolean_string(char *value) -{ - if (!value) - return false; - - if (strncasecmp(value, "true", 4) == 0 || - value[0] == '1' || - strncasecmp(value, "on", 2) == 0 || - strncasecmp(value, "yes", 3) == 0 || - strncasecmp(value, "enabled", 7) == 0) - return true; - - return false; -} - -bool is_node_instance(char *path) -{ - bool ret = false; - char *rb = NULL; - - BBF_DEBUG("entry |%s|", path); - if (!path) - return false; - - if (path[0] == '[') { - char temp_char[MAX_DM_KEY_LEN] = {'\0'}; - size_t shift; - - rb = strchr(path, ']'); - shift = (size_t) labs(rb - path); - strncpyt(temp_char, path, shift + 1); - if (!match(temp_char, GLOB_EXPR, 0, NULL)) - ret = true; - } else { - if (strtol(path, NULL, 10)) - ret = true; - } - return ret; -} - -// RE utilities -int count_delim(const char *path) -{ - int count = 0; - char *token, *save; - char *pp = strdup(path); - - token = strtok_r(pp, ".", &save); - while (token) { - token = strtok_r(NULL, ".", &save); - count++; - } - free(pp); - - // count is the count of tokens - return (count - 1); -} - bool validate_msglen(bbfdm_data_t *data) { size_t data_len = blob_pad_len(data->bbf_ctx.bb.head); @@ -85,39 +27,6 @@ bool validate_msglen(bbfdm_data_t *data) return true; } -int get_dm_type(char *dm_type) -{ - if (dm_type == NULL) - return DMT_STRING; - - if (DM_STRCMP(dm_type, DMT_TYPE[DMT_STRING]) == 0) - return DMT_STRING; - else if (DM_STRCMP(dm_type, DMT_TYPE[DMT_UNINT]) == 0) - return DMT_UNINT; - else if (DM_STRCMP(dm_type, DMT_TYPE[DMT_INT]) == 0) - return DMT_INT; - else if (DM_STRCMP(dm_type, DMT_TYPE[DMT_UNLONG]) == 0) - return DMT_UNLONG; - else if (DM_STRCMP(dm_type, DMT_TYPE[DMT_LONG]) == 0) - return DMT_LONG; - else if (DM_STRCMP(dm_type, DMT_TYPE[DMT_BOOL]) == 0) - return DMT_BOOL; - else if (DM_STRCMP(dm_type, DMT_TYPE[DMT_TIME]) == 0) - return DMT_TIME; - else if (DM_STRCMP(dm_type, DMT_TYPE[DMT_HEXBIN]) == 0) - return DMT_HEXBIN; - else if (DM_STRCMP(dm_type, DMT_TYPE[DMT_BASE64]) == 0) - return DMT_BASE64; - else if (DM_STRCMP(dm_type, DMT_TYPE[DMT_COMMAND]) == 0) - return DMT_COMMAND; - else if (DM_STRCMP(dm_type, DMT_TYPE[DMT_EVENT]) == 0) - return DMT_EVENT; - else - return DMT_STRING; - - return DMT_STRING; -} - // glibc doesn't guarantee a 0 termianted string on strncpy // strncpy with always 0 terminated string void strncpyt(char *dst, const char *src, size_t n) diff --git a/libbbfdm-ubus/common.h b/libbbfdm-ubus/common.h index be0b47aa..5057f6b7 100644 --- a/libbbfdm-ubus/common.h +++ b/libbbfdm-ubus/common.h @@ -17,17 +17,8 @@ #include #include "bbfdm-ubus.h" -#define STRINGIFY(x) #x -#define TO_STR(x) STRINGIFY(x) - -//#define ROOT_NODE "Device." -#define BBF_EVENT_NAME "event" - -#define MAX_DM_KEY_LEN 256 #define MAX_DM_PATH 1024 #define MAX_DM_VALUE 4096 -#define DM_VALUE_SEP "," -#define DELIM '.' #ifdef BBFDM_MAX_MSG_LEN #define DEF_IPC_DATA_LEN (BBFDM_MAX_MSG_LEN - 128) // Configured Len - 128 bytes @@ -35,20 +26,11 @@ #define DEF_IPC_DATA_LEN (10 * 1024 * 1024 - 128) // 10M - 128 bytes #endif -#define GLOB_CHAR "[[+*]+" -#define GLOB_EXPR "[=><]+" - extern DMOBJ *DEAMON_DM_ROOT_OBJ; extern DM_MAP_OBJ *INTERNAL_ROOT_TREE; -bool is_node_instance(char *path); -int count_delim(const char *path); - -bool get_boolean_string(char *value); bool validate_msglen(bbfdm_data_t *data); -int get_dm_type(char *dm_type); - void strncpyt(char *dst, const char *src, size_t n); #endif /* COMMON_H */ diff --git a/libbbfdm-ubus/events.c b/libbbfdm-ubus/events.c index 7cb391c8..9163bcda 100644 --- a/libbbfdm-ubus/events.c +++ b/libbbfdm-ubus/events.c @@ -106,7 +106,7 @@ static void bbfdm_event_handler(struct ubus_context *ctx, struct ubus_event_hand if (!e_args) goto end; - snprintf(e_args->method_name, sizeof(e_args->method_name), "%s.%s", BBFDM_DEFAULT_UBUS_OBJ, BBF_EVENT_NAME); + snprintf(e_args->method_name, sizeof(e_args->method_name), "%s.event", BBFDM_DEFAULT_UBUS_OBJ); e_args->blob_data = (struct blob_attr *)calloc(1, blob_data_len);