| | |
| | | memset(errString, 0x00, sizeof(errString)); |
| | | strncpy(errString, bus_strerror(rv), sizeof(errString)); |
| | | |
| | | return false; |
| | | } |
| | | |
| | | #if defined(PRO_DE_SERIALIZE) |
| | | ::bhome_msg::MsgCommonReply mcr; |
| | | mcr.mutable_errmsg()->set_errcode(::bhome_msg::ErrorCode(rv)); |
| | | mcr.mutable_errmsg()->set_errstring(errString); |
| | | *reply_len = mcr.ByteSizeLong(); |
| | | *reply = malloc(*reply_len); |
| | | mcr.SerializePartialToArray(*reply, *reply_len); |
| | | ::bhome_msg::MsgCommonReply mcr; |
| | | mcr.mutable_errmsg()->set_errcode(::bhome_msg::ErrorCode(rv)); |
| | | mcr.mutable_errmsg()->set_errstring(errString); |
| | | *reply_len = mcr.ByteSizeLong(); |
| | | *reply = malloc(*reply_len); |
| | | mcr.SerializePartialToArray(*reply, *reply_len); |
| | | #else |
| | | min = strlen(errString) + 1; |
| | | buf = malloc(min) ; |
| | | memcpy(buf, errString, strlen(errString)); |
| | | *((char *)buf + min - 1) = '\0'; |
| | | |
| | | *reply = buf; |
| | | *reply_len = min; |
| | | min = strlen(errString) + 1; |
| | | buf = malloc(min) ; |
| | | memcpy(buf, errString, strlen(errString)); |
| | | *((char *)buf + min - 1) = '\0'; |
| | | |
| | | *reply = buf; |
| | | *reply_len = min; |
| | | |
| | | #endif |
| | | |
| | | if (rv == 0) |
| | | return true; |
| | | |
| | | return false; |
| | | return true; |
| | | |
| | | } |
| | | |
| | | int BHUnregister(const void *proc_info, const int proc_info_len, void **reply, int *reply_len, const int timeout_ms) |
| | |
| | | rv = EBUS_RES_BUSY; |
| | | memset(errString, 0x00, sizeof(errString)); |
| | | strncpy(errString, bus_strerror(rv), sizeof(errString)); |
| | | |
| | | return false; |
| | | } |
| | | |
| | | #if defined(PRO_DE_SERIALIZE) |
| | |
| | | *reply_len = min; |
| | | #endif |
| | | |
| | | if (rv == 0) |
| | | return true; |
| | | |
| | | return false; |
| | | return true; |
| | | |
| | | } |
| | | |
| | | int BHRegisterTopics(const void *topics, const int topics_len, void **reply, int *reply_len, const int timeout_ms) |
| | |
| | | rv = EBUS_RES_BUSY; |
| | | memset(errString, 0x00, sizeof(errString)); |
| | | strncpy(errString, bus_strerror(rv), sizeof(errString)); |
| | | |
| | | return false; |
| | | } |
| | | |
| | | #if defined(PRO_DE_SERIALIZE) |
| | |
| | | *reply_len = len; |
| | | #endif |
| | | |
| | | if (rv == 0) |
| | | return true; |
| | | return true; |
| | | |
| | | return false; |
| | | } |
| | | |
| | | int BHQueryTopicAddress(const void *remote, const int remote_len, const void *topic, const int topic_len, void **reply, int *reply_len, const int timeout_ms) |
| | |
| | | rv = EBUS_RES_BUSY; |
| | | memset(errString, 0x00, sizeof(errString)); |
| | | strncpy(errString, bus_strerror(rv), sizeof(errString)); |
| | | |
| | | return false; |
| | | } |
| | | |
| | | #if defined(PRO_DE_SERIALIZE) |
| | |
| | | |
| | | #endif |
| | | |
| | | if (rv == 0) |
| | | return true; |
| | | return true; |
| | | |
| | | return false; |
| | | } |
| | | |
| | | int BHQueryProcs(const void *remote, const int remote_len, const void *query, const int query_len, void **reply, int *reply_len, const int timeout_ms) |
| | |
| | | rv = EBUS_RES_BUSY; |
| | | memset(errString, 0x00, sizeof(errString)); |
| | | strncpy(errString, bus_strerror(rv), sizeof(errString)); |
| | | |
| | | return false; |
| | | } |
| | | |
| | | #if defined(PRO_DE_SERIALIZE) |
| | |
| | | } |
| | | #endif |
| | | |
| | | if (rv == 0) |
| | | return true; |
| | | |
| | | return false; |
| | | return true; |
| | | |
| | | } |
| | | |
| | |
| | | rv = EBUS_RES_BUSY; |
| | | memset(errString, 0x00, sizeof(errString)); |
| | | strncpy(errString, bus_strerror(rv), sizeof(errString)); |
| | | |
| | | return false; |
| | | } |
| | | |
| | | #if defined(PRO_DE_SERIALIZE) |
| | |
| | | *reply_len = len; |
| | | #endif |
| | | |
| | | if (rv == 0) |
| | | return true; |
| | | |
| | | return false; |
| | | return true; |
| | | |
| | | } |
| | | |
| | |
| | | int key; |
| | | int size; |
| | | int sec, nsec; |
| | | char topics_buf[MAX_STR_LEN] = { 0x00 }; |
| | | char data_buf[MAX_STR_LEN * 3] = { 0x00 }; |
| | | char *topics_buf = NULL; |
| | | char *data_buf = NULL; |
| | | |
| | | struct _ReadSubReply |
| | | { |
| | |
| | | if (len > size) { |
| | | len = size; |
| | | } |
| | | strncpy(topics_buf, (char *)buf, len > (sizeof(topics_buf) - 1) ? (sizeof(topics_buf) - 1) : len); |
| | | |
| | | topics_buf = (char *)malloc(len + 10); |
| | | if (topics_buf == NULL) { |
| | | |
| | | rv = EBUS_NO_MEM; |
| | | memset(errString, 0x00, sizeof(errString)); |
| | | strncpy(errString, bus_strerror(rv), sizeof(errString)); |
| | | |
| | | logger->error("in BHRequest: Out of memory!\n"); |
| | | |
| | | pthread_mutex_unlock(&mutex); |
| | | |
| | | return false; |
| | | } |
| | | memset(topics_buf, 0x00, len + 10); |
| | | |
| | | strncpy(topics_buf, (char *)buf, len); |
| | | |
| | | if (len < size) { |
| | | len = strlen(topics_buf) + 1; |
| | | |
| | | data_buf = (char *)malloc(size - len + 10); |
| | | if (data_buf == NULL) { |
| | | |
| | | rv = EBUS_NO_MEM; |
| | | memset(errString, 0x00, sizeof(errString)); |
| | | strncpy(errString, bus_strerror(rv), sizeof(errString)); |
| | | |
| | | logger->error("in BHRequest: Out of memory!\n"); |
| | | |
| | | free(topics_buf); |
| | | pthread_mutex_unlock(&mutex); |
| | | |
| | | return false; |
| | | } |
| | | memset(data_buf, 0x00, size - len + 10); |
| | | |
| | | len = strlen(topics_buf) + 1; |
| | | strncpy(data_buf, (char *)buf + len, size - len); |
| | | } |
| | | |
| | |
| | | *proc_id = malloc(*proc_id_len); |
| | | memcpy(*proc_id, rsr.proc_id.data(), *proc_id_len); |
| | | } |
| | | |
| | | free(topics_buf); |
| | | free(data_buf); |
| | | |
| | | ::bhome_msg::MsgPublish Mp; |
| | | Mp.set_topic(rsr.topic); |
| | |
| | | memcpy(*proc_id, rr.proc_id.c_str(), *proc_id_len); |
| | | } |
| | | |
| | | memset(buf_temp, 0x00, sizeof(buf_temp)); |
| | | memcpy(buf_temp, buf, size); |
| | | rr.data = buf_temp; |
| | | topics_buf = (char *)malloc(size); |
| | | if (topics_buf == NULL) { |
| | | |
| | | rv = EBUS_NO_MEM; |
| | | memset(errString, 0x00, sizeof(errString)); |
| | | strncpy(errString, bus_strerror(rv), sizeof(errString)); |
| | | |
| | | logger->error("in BHRequest: Out of memory!\n"); |
| | | |
| | | pthread_mutex_unlock(&mutex); |
| | | |
| | | return false; |
| | | } |
| | | memset(topics_buf, 0x00, size); |
| | | |
| | | memcpy(topics_buf, buf, size); |
| | | rr.data = topics_buf; |
| | | |
| | | free(buf); |
| | | |
| | | printf("BHRequest finished_7\n"); |
| | | free(topics_buf); |
| | | } |
| | | |
| | | pthread_mutex_unlock(&mutex); |
| | |
| | | strncpy(errString, bus_strerror(rv), sizeof(errString)); |
| | | } |
| | | |
| | | #if defined(PRO_DE_SERIALIZE) |
| | | ::bhome_msg::MsgRequestTopicReply mrt; |
| | | mrt.mutable_errmsg()->set_errcode(::bhome_msg::ErrorCode(rv)); |
| | | mrt.mutable_errmsg()->set_errstring(errString); |
| | | mrt.set_data(rr.data.data()); |
| | | *reply_len = mrt.ByteSizeLong(); |
| | | *reply = malloc(*reply_len); |
| | | mrt.SerializePartialToArray(*reply, *reply_len); |
| | | #if defined(PRO_DE_SERIALIZE) |
| | | if (rv == 0) { |
| | | ::bhome_msg::MsgRequestTopicReply mrt; |
| | | mrt.mutable_errmsg()->set_errcode(::bhome_msg::ErrorCode(rv)); |
| | | mrt.mutable_errmsg()->set_errstring(errString); |
| | | mrt.set_data(rr.data.data()); |
| | | *reply_len = mrt.ByteSizeLong(); |
| | | *reply = malloc(*reply_len); |
| | | mrt.SerializePartialToArray(*reply, *reply_len); |
| | | } |
| | | #else |
| | | if (rv > 0) { |
| | | if (rv == 0) { |
| | | min = strlen(errString) + 1; |
| | | buf = malloc(min); |
| | | memcpy(buf, errString, strlen(errString)); |