vine_gatt_s *gatt = (vine_gatt_s *)user_data;
if (bt_gatt_server_send_response(request_id, BT_GATT_REQUEST_TYPE_WRITE,
- offset, BT_ERROR_NONE, "", 0) != BT_ERROR_NONE) {
+ offset, BT_ERROR_NONE, (char *)"", 0) != BT_ERROR_NONE) {
VINE_LOGE("Failed to send initiation message");
return;
}
{
dns_sd_discovered_service_s *service = new dns_sd_discovered_service_s;
strncpy(service->service_type, service_type, VINE_MAX_SERVICE_TYPE_LEN);
+ service->service_type[VINE_MAX_SERVICE_TYPE_LEN] = '\0';
strncpy(service->service_name, service_name, VINE_MAX_SERVICE_NAME_LEN);
+ service->service_name[VINE_MAX_SERVICE_NAME_LEN] = '\0';
service->dns_sd_handle = dns_sd_handle;
return service;
}
const char *domain = NULL;
strncpy(dns_sd_handle->service_type, service_type, VINE_MAX_SERVICE_TYPE_LEN);
+ dns_sd_handle->service_type[VINE_MAX_SERVICE_TYPE_LEN] = '\0';
char stype[VINE_DNS_SD_SERVICE_TYPE_MAX_LEN + 1];
snprintf(stype, VINE_DNS_SD_SERVICE_TYPE_MAX_LEN,
VINE_DNS_SD_SERVICE_TYPE ",%s", service_type);
int port;
} vine_nan_s;
-static bool __is_nan_enabled = false;
static vine_disc_plugin_callbacks event_callbacks;
static vine_disc_error __convert_nan_error_to_vine_disc_error(int error)
// The length of value is at most (VINE_MAX_ATTRIBUTE_LEN(252) - key length(2) - 1 = 249)
// Therefore, at most five attributes can be added for a topic.
VINE_LOGD("Topic[%s] is added as attributes", mTopic.c_str());
- while (pos < mTopic.size()) {
+ while (pos < (int)mTopic.size()) {
std::string val = mTopic.substr(pos, VINE_MAX_ATTRIBUTE_LEN - 1 - 2);
char key[3];
key[0] = 'T';
vine_service_s *cloned_service = new vine_service_s;
cloned_service->type = origin_service->type;
- strncpy(cloned_service->service_type, origin_service->service_type, VINE_MAX_SERVICE_TYPE_LEN);
- strncpy(cloned_service->service_name, origin_service->service_name, VINE_MAX_SERVICE_NAME_LEN);
- strncpy(cloned_service->host_name, origin_service->host_name, VINE_MAX_HOST_NAME_LEN);
- strncpy(cloned_service->ip, origin_service->ip, VINE_MAX_IP_LEN);
+ memcpy(cloned_service->service_type, origin_service->service_type, VINE_MAX_SERVICE_TYPE_LEN + 1);
+ memcpy(cloned_service->service_name, origin_service->service_name, VINE_MAX_SERVICE_NAME_LEN + 1);
+ memcpy(cloned_service->host_name, origin_service->host_name, VINE_MAX_HOST_NAME_LEN + 1);
+ memcpy(cloned_service->ip, origin_service->ip, VINE_MAX_IP_LEN + 1);
cloned_service->family = origin_service->family;
cloned_service->port = origin_service->port;
cloned_service->attributes = origin_service->attributes;
- strncpy(cloned_service->iface_name, origin_service->iface_name, IF_NAMESIZE);
- strncpy(cloned_service->mac, origin_service->mac, VINE_MAC_LEN);
+ memcpy(cloned_service->iface_name, origin_service->iface_name, IF_NAMESIZE + 1);
+ memcpy(cloned_service->mac, origin_service->mac, VINE_MAC_LEN + 1);
cloned_service->state = origin_service->state;
cloned_service->disc_handle = NULL;
vine_service_s *s = (vine_service_s *)service;
strncpy(s->service_type, service_type, VINE_MAX_SERVICE_TYPE_LEN);
+ s->service_type[VINE_MAX_SERVICE_TYPE_LEN] = '\0';
return VINE_ERROR_NONE;
}
vine_service_s *s = (vine_service_s *)service;
strncpy(s->service_name, service_name, VINE_MAX_SERVICE_TYPE_LEN);
+ s->service_name[VINE_MAX_SERVICE_NAME_LEN] = '\0';
return VINE_ERROR_NONE;
}
static std::list<vine_dp_h> g_datapath_list;
static std::list<vine_service_h> g_service_list;
-static bool test_get_user_string(const char *msg, char *buf, int buf_size)
-{
- if (msg == NULL || buf == NULL || buf_size < 2)
- return false;
-
- int ret;
- printf("%s", msg);
- fflush(stdout);
- memset(buf, 0, buf_size);
- ret = read(0, buf, buf_size - 1);
-
- if (ret < 0 || buf[0] == '\0' || buf[0] == '\n' || buf[0] == '\r') {
- buf[0] = '\0';
- return false;
- }
-
- buf[ret - 1] = '\0';
- return true;
-}
-
static void __quit()
{
PRINT_IF_ERROR(vine_deinitialize(), "vine_initialize()");