diff options
author | Cidorvan Leite <cidorvan.leite@openbossa.org> | 2008-05-15 13:36:26 +0000 |
---|---|---|
committer | Cidorvan Leite <cidorvan.leite@openbossa.org> | 2008-05-15 13:36:26 +0000 |
commit | 624ddeeb67145cdb8cc2b0dc0c7410e76aaa9fa9 (patch) | |
tree | f3d67b0075ffd5830c36b8120daa1c2cc48b2919 /serial/manager.c | |
parent | 497dd72d04902511120a03b0f66333642426be47 (diff) |
str2uuid function moved to common
Diffstat (limited to 'serial/manager.c')
-rw-r--r-- | serial/manager.c | 42 |
1 files 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); |