本文整理汇总了C++中sdp_list_free函数的典型用法代码示例。如果您正苦于以下问题:C++ sdp_list_free函数的具体用法?C++ sdp_list_free怎么用?C++ sdp_list_free使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sdp_list_free函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: set_sdp_services_uuid
static int set_sdp_services_uuid(sdp_record_t *rec, uint8_t role)
{
uuid_t source, sink;
sdp_list_t *list = NULL;
sdp_uuid16_create(&sink, HDP_SINK_SVCLASS_ID);
sdp_uuid16_create(&source, HDP_SOURCE_SVCLASS_ID);
sdp_get_service_classes(rec, &list);
switch (role) {
case HAL_HEALTH_MDEP_ROLE_SOURCE:
if (!sdp_list_find(list, &source, sdp_uuid_cmp))
list = sdp_list_append(list, &source);
break;
case HAL_HEALTH_MDEP_ROLE_SINK:
if (!sdp_list_find(list, &sink, sdp_uuid_cmp))
list = sdp_list_append(list, &sink);
break;
}
if (sdp_set_service_classes(rec, list) < 0) {
sdp_list_free(list, NULL);
return -1;
}
sdp_list_free(list, NULL);
return 0;
}
示例2: bt_uuid2string
sdp_record_t *find_record_in_list(sdp_list_t *recs, const char *uuid)
{
sdp_list_t *seq;
for (seq = recs; seq; seq = seq->next) {
sdp_record_t *rec = (sdp_record_t *) seq->data;
sdp_list_t *svcclass = NULL;
char *uuid_str;
if (sdp_get_service_classes(rec, &svcclass) < 0)
continue;
/* Extract the uuid */
uuid_str = bt_uuid2string(svcclass->data);
if (!uuid_str) {
sdp_list_free(svcclass, free);
continue;
}
if (!strcasecmp(uuid_str, uuid)) {
sdp_list_free(svcclass, free);
free(uuid_str);
return rec;
}
sdp_list_free(svcclass, free);
free(uuid_str);
}
return NULL;
}
示例3: set_sdp_services_uuid
static gboolean set_sdp_services_uuid(sdp_record_t *record, HdpRole role)
{
uuid_t svc_uuid_source, svc_uuid_sink;
sdp_list_t *svc_list = NULL;
sdp_uuid16_create(&svc_uuid_sink, HDP_SINK_SVCLASS_ID);
sdp_uuid16_create(&svc_uuid_source, HDP_SOURCE_SVCLASS_ID);
sdp_get_service_classes(record, &svc_list);
if (role == HDP_SOURCE) {
if (!sdp_list_find(svc_list, &svc_uuid_source, sdp_uuid_cmp))
svc_list = sdp_list_append(svc_list, &svc_uuid_source);
} else if (role == HDP_SINK) {
if (!sdp_list_find(svc_list, &svc_uuid_sink, sdp_uuid_cmp))
svc_list = sdp_list_append(svc_list, &svc_uuid_sink);
}
if (sdp_set_service_classes(record, svc_list) < 0) {
sdp_list_free(svc_list, NULL);
return FALSE;
}
sdp_list_free(svc_list, NULL);
return TRUE;
}
示例4: register_features
static gboolean register_features(struct hdp_application *app,
sdp_list_t **sup_features)
{
sdp_list_t *hdp_feature;
hdp_feature = app_to_sdplist(app);
if (hdp_feature == NULL)
goto fail;
if (*sup_features == NULL) {
*sup_features = sdp_list_append(NULL, hdp_feature);
if (*sup_features == NULL)
goto fail;
} else if (sdp_list_append(*sup_features, hdp_feature) == NULL) {
goto fail;
}
return TRUE;
fail:
if (hdp_feature != NULL)
sdp_list_free(hdp_feature, (sdp_free_func_t)sdp_data_free);
if (*sup_features != NULL)
sdp_list_free(*sup_features, free_hdp_list);
return FALSE;
}
示例5: gatt_parse_record
gboolean gatt_parse_record(const sdp_record_t *rec,
uuid_t *prim_uuid, uint16_t *psm,
uint16_t *start, uint16_t *end)
{
sdp_list_t *list;
uuid_t uuid;
gboolean ret;
if (sdp_get_service_classes(rec, &list) < 0)
return FALSE;
memcpy(&uuid, list->data, sizeof(uuid));
sdp_list_free(list, free);
if (sdp_get_access_protos(rec, &list) < 0)
return FALSE;
ret = parse_proto_params(list, psm, start, end);
sdp_list_foreach(list, (sdp_list_func_t) sdp_list_free, NULL);
sdp_list_free(list, NULL);
/* FIXME: replace by bt_uuid_t after uuid_t/sdp code cleanup */
if (ret && prim_uuid)
memcpy(prim_uuid, &uuid, sizeof(uuid_t));
return ret;
}
示例6: sdp_svcdb_reset
/*
* Reset the service repository by deleting its contents
*/
void sdp_svcdb_reset(void)
{
sdp_list_free(service_db, (sdp_free_func_t) sdp_record_free);
service_db = NULL;
sdp_list_free(access_db, access_free);
access_db = NULL;
}
示例7: register_device_id
void register_device_id(const uint16_t vendor, const uint16_t product,
const uint16_t version)
{
const uint16_t spec = 0x0102, source = 0x0002;
const uint8_t primary = 1;
sdp_list_t *class_list, *group_list, *profile_list;
uuid_t class_uuid, group_uuid;
sdp_data_t *sdp_data, *primary_data, *source_data;
sdp_data_t *spec_data, *vendor_data, *product_data, *version_data;
sdp_profile_desc_t profile;
sdp_record_t *record = sdp_record_alloc();
info("Adding device id record for %04x:%04x", vendor, product);
btd_manager_set_did(vendor, product, version);
record->handle = sdp_next_handle();
sdp_record_add(BDADDR_ANY, record);
sdp_data = sdp_data_alloc(SDP_UINT32, &record->handle);
sdp_attr_add(record, SDP_ATTR_RECORD_HANDLE, sdp_data);
sdp_uuid16_create(&class_uuid, PNP_INFO_SVCLASS_ID);
class_list = sdp_list_append(0, &class_uuid);
sdp_set_service_classes(record, class_list);
sdp_list_free(class_list, NULL);
sdp_uuid16_create(&group_uuid, PUBLIC_BROWSE_GROUP);
group_list = sdp_list_append(NULL, &group_uuid);
sdp_set_browse_groups(record, group_list);
sdp_list_free(group_list, NULL);
sdp_uuid16_create(&profile.uuid, PNP_INFO_PROFILE_ID);
profile.version = spec;
profile_list = sdp_list_append(NULL, &profile);
sdp_set_profile_descs(record, profile_list);
sdp_list_free(profile_list, NULL);
spec_data = sdp_data_alloc(SDP_UINT16, &spec);
sdp_attr_add(record, 0x0200, spec_data);
vendor_data = sdp_data_alloc(SDP_UINT16, &vendor);
sdp_attr_add(record, 0x0201, vendor_data);
product_data = sdp_data_alloc(SDP_UINT16, &product);
sdp_attr_add(record, 0x0202, product_data);
version_data = sdp_data_alloc(SDP_UINT16, &version);
sdp_attr_add(record, 0x0203, version_data);
primary_data = sdp_data_alloc(SDP_BOOL, &primary);
sdp_attr_add(record, 0x0204, primary_data);
source_data = sdp_data_alloc(SDP_UINT16, &source);
sdp_attr_add(record, 0x0205, source_data);
update_db_timestamp();
}
示例8: main
int main(int argc, char const *argv[])
{
uint32_t svc_uuid_int[] = {0, 0, 0, 0xABCD};
int status;
bdaddr_t target, source;
uuid_t svc_uuid;
sdp_list_t *response_list, *search_list, *attrid_list;
sdp_session_t *session = 0;
uint32_t range = 0x0000ffff;
uint8_t port = 0;
//connect to the SDP server running on the remote machine
str2ba(dest, &target);
str2ba(src, &source);
session = sdp_connect(&source, &target, 0);
if (session == NULL) {
perror("sdp_connect");
exit(1);
}
sdp_uuid128_create(&svc_uuid, &svc_uuid_int);
search_list = sdp_list_append(0, &svc_uuid);
attrid_list = sdp_list_append(0, &range);
//get a list of service records that have UUID 0xabcd
response_list = NULL;
status = sdp_service_search_attr_req(session, search_list, SDP_ATTR_REQ_RANGE, attrid_list, &response_list);
if (status == 0) {
sdp_list_t *proto_list = NULL;
sdp_list_t *r = response_list;
//go through each of the service records
for (; r; r = r->next) {
sdp_record_t *rec = (sdp_record_t *)r->data;
//get a list of the protocol sequences
if (sdp_get_access_protos(rec, &proto_list) == 0) {
// get the RFCOMM port number
port = sdp_get_proto_port(proto_list, RFCOMM_UUID);
sdp_list_free(proto_list, 0);
}
sdp_record_free(rec);
}
}
sdp_list_free(response_list, 0);
sdp_list_free(search_list, 0);
sdp_list_free(attrid_list, 0);
sdp_close(session);
if (port != 0) {
printf("found service running on RFCOMM Port %d\n", port);
}
return 0;
}
示例9: connect_watch
static gboolean connect_watch(GIOChannel *chan, GIOCondition cond,
gpointer user_data)
{
struct search_context *ctxt = user_data;
sdp_list_t *search, *attrids;
uint32_t range = 0x0000ffff;
socklen_t len;
int sk, err = 0;
sk = g_io_channel_unix_get_fd(chan);
ctxt->io_id = 0;
len = sizeof(err);
if (getsockopt(sk, SOL_SOCKET, SO_ERROR, &err, &len) < 0) {
err = errno;
goto failed;
}
if (err != 0)
goto failed;
if (sdp_set_notify(ctxt->session, search_completed_cb, ctxt) < 0) {
err = EIO;
goto failed;
}
search = sdp_list_append(NULL, &ctxt->uuid);
attrids = sdp_list_append(NULL, &range);
if (sdp_service_search_attr_async(ctxt->session,
search, SDP_ATTR_REQ_RANGE, attrids) < 0) {
sdp_list_free(attrids, NULL);
sdp_list_free(search, NULL);
err = EIO;
goto failed;
}
sdp_list_free(attrids, NULL);
sdp_list_free(search, NULL);
/* Set callback responsible for update the internal SDP transaction */
ctxt->io_id = g_io_add_watch(chan,
G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
search_process_cb, ctxt);
return FALSE;
failed:
sdp_close(ctxt->session);
ctxt->session = NULL;
if (ctxt->cb)
ctxt->cb(NULL, -err, ctxt->user_data);
search_context_cleanup(ctxt);
return FALSE;
}
示例10: service_callback
static gboolean service_callback(GIOChannel *io, GIOCondition cond,
gpointer user_data)
{
struct bluetooth_session *session = user_data;
sdp_list_t *search, *attrid;
uint32_t range = 0x0000ffff;
GError *gerr = NULL;
uuid_t uuid;
if (cond & G_IO_NVAL)
return FALSE;
if (cond & G_IO_ERR)
goto failed;
if (sdp_set_notify(session->sdp, search_callback, session) < 0)
goto failed;
if (bt_string2uuid(&uuid, session->service) < 0)
goto failed;
sdp_uuid128_to_uuid(&uuid);
search = sdp_list_append(NULL, &uuid);
attrid = sdp_list_append(NULL, &range);
if (sdp_service_search_attr_async(session->sdp,
search, SDP_ATTR_REQ_RANGE, attrid) < 0) {
sdp_list_free(attrid, NULL);
sdp_list_free(search, NULL);
goto failed;
}
sdp_list_free(attrid, NULL);
sdp_list_free(search, NULL);
g_io_add_watch(io, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
process_callback, session);
return FALSE;
failed:
g_io_channel_shutdown(session->io, TRUE, NULL);
g_io_channel_unref(session->io);
session->io = NULL;
g_set_error(&gerr, OBC_BT_ERROR, -EIO,
"Unable to find service record");
if (session->func)
session->func(session->io, gerr, session->user_data);
g_clear_error(&gerr);
session_destroy(session);
return FALSE;
}
示例11: sdp_uuid16_create
static sdp_record_t *create_mas_record(uint8_t chan, const char *svc_name)
{
sdp_list_t *seq;
sdp_profile_desc_t profile[1];
uint8_t minst = DEFAULT_MAS_INSTANCE;
uint8_t mtype = DEFAULT_MAS_MSG_TYPE;
sdp_record_t *record;
uuid_t uuid;
sdp_uuid16_create(&uuid, MAP_MSE_SVCLASS_ID);
record = create_rfcomm_record(chan, &uuid, svc_name, true);
if (!record)
return NULL;
sdp_uuid16_create(&profile[0].uuid, MAP_PROFILE_ID);
profile[0].version = 0x0101;
seq = sdp_list_append(NULL, profile);
sdp_set_profile_descs(record, seq);
sdp_attr_add_new(record, SDP_ATTR_MAS_INSTANCE_ID, SDP_UINT8, &minst);
sdp_attr_add_new(record, SDP_ATTR_SUPPORTED_MESSAGE_TYPES, SDP_UINT8,
&mtype);
sdp_list_free(seq, NULL);
return record;
}
示例12: get_record_cb
static void get_record_cb(sdp_list_t *recs, int err, gpointer user_data)
{
struct serial_port *port = user_data;
struct serial_device *device = port->device;
sdp_record_t *record = NULL;
sdp_list_t *protos;
DBusMessage *reply;
GError *gerr = NULL;
if (!port->listener_id) {
reply = NULL;
goto failed;
}
if (err < 0) {
error("Unable to get service record: %s (%d)", strerror(-err),
-err);
reply = failed(port->msg, strerror(-err));
goto failed;
}
if (!recs || !recs->data) {
error("No record found");
reply = failed(port->msg, "No record found");
goto failed;
}
record = recs->data;
if (sdp_get_access_protos(record, &protos) < 0) {
error("Unable to get access protos from port record");
reply = failed(port->msg, "Invalid channel");
goto failed;
}
port->channel = sdp_get_proto_port(protos, RFCOMM_UUID);
sdp_list_foreach(protos, (sdp_list_func_t) sdp_list_free, NULL);
sdp_list_free(protos, NULL);
port->io = bt_io_connect(BT_IO_RFCOMM, rfcomm_connect_cb, port,
NULL, &gerr,
BT_IO_OPT_SOURCE_BDADDR, &device->src,
BT_IO_OPT_DEST_BDADDR, &device->dst,
BT_IO_OPT_CHANNEL, port->channel,
BT_IO_OPT_INVALID);
if (!port->io) {
error("%s", gerr->message);
reply = failed(port->msg, gerr->message);
g_error_free(gerr);
goto failed;
}
return;
failed:
g_dbus_remove_watch(device->conn, port->listener_id);
port->listener_id = 0;
g_dbus_send_message(device->conn, reply);
}
示例13: serial_probe
static int serial_probe(struct btd_device *device, const char *uuid)
{
struct btd_adapter *adapter = device_get_adapter(device);
const gchar *path = device_get_path(device);
sdp_list_t *protos;
int ch;
bdaddr_t src, dst;
const sdp_record_t *rec;
DBG("path %s: %s", path, uuid);
rec = btd_device_get_record(device, uuid);
if (!rec)
return -EINVAL;
if (sdp_get_access_protos(rec, &protos) < 0)
return -EINVAL;
ch = sdp_get_proto_port(protos, RFCOMM_UUID);
sdp_list_foreach(protos, (sdp_list_func_t) sdp_list_free, NULL);
sdp_list_free(protos, NULL);
if (ch < 1 || ch > 30) {
error("Channel out of range: %d", ch);
return -EINVAL;
}
adapter_get_address(adapter, &src);
device_get_address(device, &dst);
return port_register(connection, path, &src, &dst, uuid, ch);
}
示例14: records_cb
static void records_cb(sdp_list_t *recs, int err, gpointer data)
{
struct pending_reply *pr = data;
int len;
sdp_data_t *d;
sdp_record_t *rec = NULL;
char name[MAX_NAME_SIZE], *desc = NULL;
if (err < 0) {
error_connection_attempt_failed(pr->conn, pr->msg, -err);
goto fail;
}
if (!recs || !recs->data) {
error_not_supported(pr->conn, pr->msg);
error("Invalid PAN service record");
goto fail;
}
rec = recs->data;
/* Concat remote name and service name */
memset(name, 0, MAX_NAME_SIZE);
if (read_remote_name(&pr->src, &pr->dst, name, MAX_NAME_SIZE) < 0)
len = 0;
else
len = strlen(name);
d = sdp_data_get(rec, SDP_ATTR_SVCNAME_PRIMARY);
if (d) {
snprintf(name + len, MAX_NAME_SIZE - len,
len ? " (%.*s)" : "%.*s", d->unitSize, d->val.str);
}
/* Extract service description from record */
d = sdp_data_get(rec, SDP_ATTR_SVCDESC_PRIMARY);
if (d) {
desc = g_new0(char, d->unitSize);
snprintf(desc, d->unitSize, "%.*s",
d->unitSize, d->val.str);
}
sdp_list_free(recs, (sdp_free_func_t) sdp_record_free);
if (connection_register(pr->path, &pr->src, &pr->dst, pr->id, name,
desc) < 0) {
error_failed(pr->conn, pr->msg, "D-Bus path registration failed");
goto fail;
}
connection_store(pr->path, FALSE);
connection_paths = g_slist_append(connection_paths, g_strdup(pr->path));
create_path(pr->conn, pr->msg, pr->path, "ConnectionCreated");
fail:
g_free(desc);
pending_reply_free(pr);
}
示例15: search_cb
static void search_cb(sdp_list_t *recs, int err, gpointer data)
{
struct avrcp_device *dev = data;
sdp_list_t *list;
DBG("");
if (err < 0) {
error("Unable to get AV_REMOTE_SVCLASS_ID SDP record: %s",
strerror(-err));
goto fail;
}
if (!recs || !recs->data) {
error("No AVRCP records found");
goto fail;
}
for (list = recs; list; list = list->next) {
sdp_record_t *rec = list->data;
sdp_list_t *l;
sdp_profile_desc_t *desc;
int features;
if (sdp_get_profile_descs(rec, &l) < 0)
continue;
desc = l->data;
dev->version = desc->version;
if (sdp_get_int_attr(rec, SDP_ATTR_SUPPORTED_FEATURES,
&features) == 0)
dev->features = features;
sdp_list_free(l, free);
break;
}
if (dev->io) {
GError *gerr = NULL;
if (!bt_io_accept(dev->io, connect_cb, dev, NULL, &gerr)) {
error("bt_io_accept: %s", gerr->message);
g_error_free(gerr);
goto fail;
}
return;
}
if (!avrcp_device_connect(dev, connect_cb)) {
error("Unable to connect to AVRCP");
goto fail;
}
return;
fail:
avrcp_device_remove(dev);
}