Exemplo n.º 1
0
Arquivo: uuid.c Projeto: hadess/bluez
static int bt_string_to_uuid32(bt_uuid_t *uuid, const char *string)
{
    uint32_t u32;
    char *endptr = NULL;

    u32 = strtol(string, &endptr, 16);
    if (endptr && *endptr == '\0') {
        bt_uuid32_create(uuid, u32);
        return 0;
    }

    return -EINVAL;
}
Exemplo n.º 2
0
static bool le_to_uuid(const uint8_t *src, size_t len, bt_uuid_t *uuid)
{
	uint128_t u128;

	if (len == 2) {
		bt_uuid16_create(uuid, get_le16(src));
		return true;
	}

	if (len == 4) {
		bt_uuid32_create(uuid, get_le32(src));
		return true;
	}

	if (len != 16)
		return false;

	bswap_128(src, &u128);
	bt_uuid128_create(uuid, u128);

	return true;
}