summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Woodhouse <David.Woodhouse@intel.com>2008-09-14 11:18:46 -0700
committerDavid Woodhouse <David.Woodhouse@intel.com>2008-09-14 11:20:23 -0700
commit77a980323fc54f94b9f552dde4050a5e9758d5d5 (patch)
tree354e0540c782802e8c066cbacf1f19f7bcbf4f2a /src
parentd55b2b10927a7ac07c82c50be6216c32711d94a6 (diff)
split out read_records() function for reading all SDP records for a device
Diffstat (limited to 'src')
-rw-r--r--src/adapter.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/adapter.c b/src/adapter.c
index c70a4a99..a2dc4ce0 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2154,14 +2154,27 @@ static void create_stored_records_from_keys(char *key, char *value,
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)
{
- char filename[PATH_MAX + 1];
struct btd_adapter *adapter = user_data;
GSList *uuids = bt_string2list(value);
struct btd_device *device;
- struct record_list rec_list;
+ sdp_list_t *records;
bdaddr_t dst;
char srcaddr[18], dstaddr[18];
@@ -2181,16 +2194,12 @@ static void create_stored_device_from_profiles(char *key, char *value,
device_get_address(device, &dst);
ba2str(&dst, dstaddr);
- rec_list.addr = dstaddr;
- rec_list.recs = NULL;
-
- create_name(filename, PATH_MAX, STORAGEDIR, srcaddr, "sdp");
- textfile_foreach(filename, create_stored_records_from_keys, &rec_list);
+ records = read_records(srcaddr, dstaddr);
- device_probe_drivers(device, uuids, rec_list.recs);
+ device_probe_drivers(device, uuids, records);
- if (rec_list.recs != NULL)
- sdp_list_free(rec_list.recs, (sdp_free_func_t) sdp_record_free);
+ if (records)
+ sdp_list_free(records, (sdp_free_func_t) sdp_record_free);
g_slist_free(uuids);
}