From 624ddeeb67145cdb8cc2b0dc0c7410e76aaa9fa9 Mon Sep 17 00:00:00 2001 From: Cidorvan Leite Date: Thu, 15 May 2008 13:36:26 +0000 Subject: str2uuid function moved to common --- serial/manager.c | 42 +++--------------------------------------- 1 file changed, 3 insertions(+), 39 deletions(-) diff --git a/serial/manager.c b/serial/manager.c index f67a6f89..88160021 100644 --- a/serial/manager.c +++ b/serial/manager.c @@ -542,42 +542,6 @@ done: sdp_list_free(recs, (sdp_free_func_t) sdp_record_free); } -static int str2uuid(uuid_t *uuid, const char *string) -{ - uint16_t data1, data2, data3, data5; - uint32_t data0, data4; - - if (strlen(string) == 36 && - string[8] == '-' && - string[13] == '-' && - string[18] == '-' && - string[23] == '-' && - sscanf(string, "%08x-%04hx-%04hx-%04hx-%08x%04hx", - &data0, &data1, &data2, &data3, &data4, &data5) == 6) { - uint8_t val[16]; - - data0 = htonl(data0); - data1 = htons(data1); - data2 = htons(data2); - data3 = htons(data3); - data4 = htonl(data4); - data5 = htons(data5); - - memcpy(&val[0], &data0, 4); - memcpy(&val[4], &data1, 2); - memcpy(&val[6], &data2, 2); - memcpy(&val[8], &data3, 2); - memcpy(&val[10], &data4, 4); - memcpy(&val[14], &data5, 2); - - sdp_uuid128_create(uuid, val); - - return 0; - } - - return -1; -} - static int pattern2uuid(const char *pattern, uuid_t *uuid) { uint16_t cls; @@ -603,7 +567,7 @@ static int pattern2uuid(const char *pattern, uuid_t *uuid) return -EINVAL; } - str2uuid(uuid, pattern); + bt_string2uuid(uuid, pattern); return 0; } @@ -855,7 +819,7 @@ static sdp_record_t *proxy_record_new(const char *uuid128, uint8_t channel) sdp_set_browse_groups(record, root); sdp_list_free(root, NULL); - str2uuid(&uuid, uuid128); + bt_string2uuid(&uuid, uuid128); svclass_id = sdp_list_append(NULL, &uuid); sdp_set_service_classes(record, svclass_id); sdp_list_free(svclass_id, NULL); @@ -1589,7 +1553,7 @@ static DBusHandlerResult create_proxy(DBusConnection *conn, return DBUS_HANDLER_RESULT_HANDLED; } - if (str2uuid(&uuid, uuid128) < 0) + if (bt_string2uuid(&uuid, uuid128) < 0) return error_invalid_arguments(conn, msg, "Invalid UUID"); type = addr2type(address); -- cgit