diff options
-rw-r--r-- | src/adapter.c | 46 | ||||
-rw-r--r-- | src/storage.c | 47 | ||||
-rw-r--r-- | src/storage.h | 2 |
3 files changed, 48 insertions, 47 deletions
diff --git a/src/adapter.c b/src/adapter.c index f19cc3d3..2a4891c6 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -74,11 +74,6 @@ static DBusConnection *connection = NULL; static GSList *adapter_drivers = NULL; -struct record_list { - sdp_list_t *recs; - const gchar *addr; -}; - struct session_req { struct btd_adapter *adapter; DBusConnection *conn; /* Connection reference */ @@ -2127,47 +2122,6 @@ static int active_conn_append(GSList **list, bdaddr_t *bdaddr, return 0; } -static void create_stored_records_from_keys(char *key, char *value, - void *user_data) -{ - struct record_list *rec_list = user_data; - const gchar *addr = rec_list->addr; - sdp_record_t *rec; - int size, i, len; - uint8_t *pdata; - char tmp[3] = ""; - - if (strncmp(key, addr, 17)) - return; - - size = strlen(value)/2; - pdata = g_malloc0(size); - - for (i = 0; i < size; i++) { - memcpy(tmp, value + (i * 2), 2); - pdata[i] = (uint8_t) strtol(tmp, NULL, 16); - } - - rec = sdp_extract_pdu(pdata, size, &len); - free(pdata); - - rec_list->recs = sdp_list_append(rec_list->recs, rec); -} - -sdp_list_t *read_records(const gchar *src, const gchar *dst) -{ - char filename[PATH_MAX + 1]; - struct record_list rec_list; - - rec_list.addr = dst; - rec_list.recs = NULL; - - create_name(filename, PATH_MAX, STORAGEDIR, src, "sdp"); - textfile_foreach(filename, create_stored_records_from_keys, &rec_list); - - return rec_list.recs; -} - static void create_stored_device_from_profiles(char *key, char *value, void *user_data) { diff --git a/src/storage.c b/src/storage.c index f6d94bd2..5e4e3062 100644 --- a/src/storage.c +++ b/src/storage.c @@ -810,6 +810,53 @@ int delete_record(const gchar *src, const gchar *dst, const uint32_t handle) return textfile_del(filename, key); } +struct record_list { + sdp_list_t *recs; + const gchar *addr; +}; + +static void create_stored_records_from_keys(char *key, char *value, + void *user_data) +{ + struct record_list *rec_list = user_data; + const gchar *addr = rec_list->addr; + sdp_record_t *rec; + int size, i, len; + uint8_t *pdata; + char tmp[3] = ""; + + if (strncmp(key, addr, 17)) + return; + + size = strlen(value)/2; + pdata = g_malloc0(size); + + for (i = 0; i < size; i++) { + memcpy(tmp, value + (i * 2), 2); + pdata[i] = (uint8_t) strtol(tmp, NULL, 16); + } + + rec = sdp_extract_pdu(pdata, size, &len); + free(pdata); + + rec_list->recs = sdp_list_append(rec_list->recs, rec); +} + +sdp_list_t *read_records(const gchar *src, const gchar *dst) +{ + char filename[PATH_MAX + 1]; + struct record_list rec_list; + + rec_list.addr = dst; + rec_list.recs = NULL; + + create_name(filename, PATH_MAX, STORAGEDIR, src, "sdp"); + textfile_foreach(filename, create_stored_records_from_keys, &rec_list); + + return rec_list.recs; +} + + int store_device_id(const gchar *src, const gchar *dst, const uint16_t source, const uint16_t vendor, const uint16_t product, const uint16_t version) diff --git a/src/storage.h b/src/storage.h index 85c9398c..85d1064c 100644 --- a/src/storage.h +++ b/src/storage.h @@ -59,7 +59,7 @@ int delete_entry(bdaddr_t *src, const char *storage, const char *key); int store_record(const gchar *src, const gchar *dst, sdp_record_t *rec); sdp_record_t *fetch_record(const gchar *src, const gchar *dst, const uint32_t handle); int delete_record(const gchar *src, const gchar *dst, const uint32_t handle); - +sdp_list_t *read_records(const gchar *src, const gchar *dst); int store_device_id(const gchar *src, const gchar *dst, const uint16_t source, const uint16_t vendor, const uint16_t product, const uint16_t version); |