static json_t *rf_listener_del(struct rest_uri_param *param) { int8 *p_id = NULL; int32 listener_id = 0; int8 buff[8] = {0}; result_t rs = RESULT_OK; evt_listener_t listener = {}; p_id = rest_path_value(param, "listener_id"); if (p_id == NULL) { update_response_info(param, HTTP_BAD_REQUEST); HTTPD_ERR("get value fail\n"); return NULL; } listener_id = (int32)str2int(p_id); if (libwrap_del_evt_listener(RF_EVENT_MASK_ALL, listener_id) != RESULT_OK) { update_response_info(param, HTTP_INTERNAL_SERVER_ERROR); HTTPD_ERR("mbp listener info del fail\n"); return NULL; } update_response_info(param, HTTP_NO_CONTENT); return NULL; }
memdb_integer get_asset_node_id(const struct rest_uri_param *param, const int8 *name) { int8 *p_uuid = NULL; uint8 uuid[64] = {0}; memdb_integer node_id; p_uuid = rest_path_value(param, name); if (p_uuid == NULL) { HTTPD_ERR("get value from path fail\n"); return 0; } snprintf((int8 *)uuid, sizeof(uuid), "%s", p_uuid); libwrap_get_node_id_by_uuid(uuid, &node_id); return node_id; }
int32 get_asset_idx(const struct rest_uri_param *param, const int8 *name, int32 type) { int8 *p_id = NULL; int32 index; p_id = rest_path_value(param, name); if (p_id == NULL) { HTTPD_ERR("get value fail\n"); return -1; } if (TRUE == is_str_uuid((const int8 *)p_id)) { if (FALSE == get_index_by_uuid((const int8 *)p_id, type, &index)) { HTTPD_ERR("uuid %s error!\n", p_id); return -1; } } else index = (uint32)str2int(p_id); return index; }
static json_t *rf_listener_get(struct rest_uri_param *param) { int8 *p_id = NULL; int32 listener_id = 0; int8 buff[8] = {0}; result_t rs = RESULT_OK; evt_listener_t listener = {}; json_t *result = NULL; result = json_object(); if (result == NULL) { update_response_info(param, HTTP_INTERNAL_SERVER_ERROR); HTTPD_ERR("json object request fail\n"); return NULL; } p_id = rest_path_value(param, "listener_id"); if (p_id == NULL) { update_response_info(param, HTTP_BAD_REQUEST); HTTPD_ERR("get value fail\n"); return NULL; } listener_id = (int32)str2int(p_id); if (evt_listener_init(&listener, RF_EVENT_MASK_ALL, listener_id, RF_EVENT_ROOT_FMT) != 0) { update_response_info(param, HTTP_RESOURCE_NOT_FOUND); HTTPD_ERR("mbp listener info init fail\n"); return NULL; } if (evt_listener_pack_json(result, &listener) != 0) { update_response_info(param, HTTP_INTERNAL_SERVER_ERROR); HTTPD_ERR("mbp listener pack json fail\n"); return NULL; } update_response_info(param, HTTP_OK); return result; }