component/bt : run astyle handle the code files

This commit is contained in:
Tian Hao
2016-11-25 02:10:15 +08:00
parent d7eb709a9c
commit 19273c7b2d
268 changed files with 29938 additions and 36146 deletions

334
components/bt/bluedroid/stack/sdp/sdp_db.c Executable file → Normal file
View File

@@ -63,43 +63,42 @@ tSDP_RECORD *sdp_db_service_search (tSDP_RECORD *p_rec, tSDP_UUID_SEQ *p_seq)
tSDP_RECORD *p_end = &sdp_cb.server_db.record[sdp_cb.server_db.num_records];
/* If NULL, start at the beginning, else start at the first specified record */
if (!p_rec)
if (!p_rec) {
p_rec = &sdp_cb.server_db.record[0];
else
} else {
p_rec++;
}
/* Look through the records. The spec says that a match occurs if */
/* the record contains all the passed UUIDs in it. */
for ( ; p_rec < p_end; p_rec++)
{
for (yy = 0; yy < p_seq->num_uids; yy++)
{
for ( ; p_rec < p_end; p_rec++) {
for (yy = 0; yy < p_seq->num_uids; yy++) {
p_attr = &p_rec->attribute[0];
for (xx = 0; xx < p_rec->num_attributes; xx++, p_attr++)
{
if (p_attr->type == UUID_DESC_TYPE)
{
for (xx = 0; xx < p_rec->num_attributes; xx++, p_attr++) {
if (p_attr->type == UUID_DESC_TYPE) {
if (sdpu_compare_uuid_arrays (p_attr->value_ptr, p_attr->len,
&p_seq->uuid_entry[yy].value[0],
p_seq->uuid_entry[yy].len))
p_seq->uuid_entry[yy].len)) {
break;
}
else if (p_attr->type == DATA_ELE_SEQ_DESC_TYPE)
{
}
} else if (p_attr->type == DATA_ELE_SEQ_DESC_TYPE) {
if (find_uuid_in_seq (p_attr->value_ptr, p_attr->len,
&p_seq->uuid_entry[yy].value[0],
p_seq->uuid_entry[yy].len, 0))
p_seq->uuid_entry[yy].len, 0)) {
break;
}
}
}
/* If any UUID was not found, on to the next record */
if (xx == p_rec->num_attributes)
if (xx == p_rec->num_attributes) {
break;
}
}
/* If every UUID was found in the record, return the record */
if (yy == p_seq->num_uids)
if (yy == p_seq->num_uids) {
return (p_rec);
}
}
/* If here, no more records found */
@@ -123,23 +122,22 @@ static BOOLEAN find_uuid_in_seq (UINT8 *p , UINT32 seq_len, UINT8 *p_uuid,
UINT32 len;
/* A little safety check to avoid excessive recursion */
if (nest_level > 3)
if (nest_level > 3) {
return (FALSE);
}
while (p < p_end)
{
while (p < p_end) {
type = *p++;
p = sdpu_get_len_from_type (p, type, &len);
type = type >> 3;
if (type == UUID_DESC_TYPE)
{
if (sdpu_compare_uuid_arrays (p, len, p_uuid, uuid_len))
if (type == UUID_DESC_TYPE) {
if (sdpu_compare_uuid_arrays (p, len, p_uuid, uuid_len)) {
return (TRUE);
}
else if (type == DATA_ELE_SEQ_DESC_TYPE)
{
if (find_uuid_in_seq (p, len, p_uuid, uuid_len, nest_level + 1))
}
} else if (type == DATA_ELE_SEQ_DESC_TYPE) {
if (find_uuid_in_seq (p, len, p_uuid, uuid_len, nest_level + 1)) {
return (TRUE);
}
}
p = p + len;
}
@@ -164,10 +162,10 @@ tSDP_RECORD *sdp_db_find_record (UINT32 handle)
tSDP_RECORD *p_end = &sdp_cb.server_db.record[sdp_cb.server_db.num_records];
/* Look through the records for the caller's handle */
for (p_rec = &sdp_cb.server_db.record[0]; p_rec < p_end; p_rec++)
{
if (p_rec->record_handle == handle)
for (p_rec = &sdp_cb.server_db.record[0]; p_rec < p_end; p_rec++) {
if (p_rec->record_handle == handle) {
return (p_rec);
}
}
/* Record with that handle not found. */
@@ -187,17 +185,17 @@ tSDP_RECORD *sdp_db_find_record (UINT32 handle)
**
*******************************************************************************/
tSDP_ATTRIBUTE *sdp_db_find_attr_in_rec (tSDP_RECORD *p_rec, UINT16 start_attr,
UINT16 end_attr)
UINT16 end_attr)
{
tSDP_ATTRIBUTE *p_at;
UINT16 xx;
/* Note that the attributes in a record are assumed to be in sorted order */
for (xx = 0, p_at = &p_rec->attribute[0]; xx < p_rec->num_attributes;
xx++, p_at++)
{
if ((p_at->id >= start_attr) && (p_at->id <= end_attr))
xx++, p_at++) {
if ((p_at->id >= start_attr) && (p_at->id <= end_attr)) {
return (p_at);
}
}
/* No matching attribute found */
@@ -216,7 +214,7 @@ tSDP_ATTRIBUTE *sdp_db_find_attr_in_rec (tSDP_RECORD *p_rec, UINT16 start_attr,
**
*******************************************************************************/
static int sdp_compose_proto_list( UINT8 *p, UINT16 num_elem,
tSDP_PROTOCOL_ELEM *p_elem_list)
tSDP_PROTOCOL_ELEM *p_elem_list)
{
UINT16 xx, yy, len;
BOOLEAN is_rfcomm_scn;
@@ -227,8 +225,7 @@ static int sdp_compose_proto_list( UINT8 *p, UINT16 num_elem,
** sequences, one for each layer. Each layer sequence consists of layer's
** UUID and optional parameters
*/
for (xx = 0; xx < num_elem; xx++, p_elem_list++)
{
for (xx = 0; xx < num_elem; xx++, p_elem_list++) {
len = 3 + (p_elem_list->num_params * 3);
UINT8_TO_BE_STREAM (p, (DATA_ELE_SEQ_DESC_TYPE << 3) | SIZE_IN_NEXT_BYTE);
@@ -238,22 +235,19 @@ static int sdp_compose_proto_list( UINT8 *p, UINT16 num_elem,
UINT8_TO_BE_STREAM (p, (UUID_DESC_TYPE << 3) | SIZE_TWO_BYTES);
UINT16_TO_BE_STREAM (p, p_elem_list->protocol_uuid);
if (p_elem_list->protocol_uuid == UUID_PROTOCOL_RFCOMM)
if (p_elem_list->protocol_uuid == UUID_PROTOCOL_RFCOMM) {
is_rfcomm_scn = TRUE;
else
} else {
is_rfcomm_scn = FALSE;
}
for (yy = 0; yy < p_elem_list->num_params; yy++)
{
if (is_rfcomm_scn)
{
for (yy = 0; yy < p_elem_list->num_params; yy++) {
if (is_rfcomm_scn) {
UINT8_TO_BE_STREAM (p, (UINT_DESC_TYPE << 3) | SIZE_ONE_BYTE);
UINT8_TO_BE_STREAM (p, p_elem_list->params[yy]);
*p_len -= 1;
}
else
{
} else {
UINT8_TO_BE_STREAM (p, (UINT_DESC_TYPE << 3) | SIZE_TWO_BYTES);
UINT16_TO_BE_STREAM (p, p_elem_list->params[yy]);
}
@@ -284,17 +278,17 @@ UINT32 SDP_CreateRecord (void)
tSDP_DB *p_db = &sdp_cb.server_db;
/* First, check if there is a free record */
if (p_db->num_records < SDP_MAX_RECORDS)
{
if (p_db->num_records < SDP_MAX_RECORDS) {
memset (&p_db->record[p_db->num_records], 0,
sizeof (tSDP_RECORD));
/* We will use a handle of the first unreserved handle plus last record
** number + 1 */
if (p_db->num_records)
if (p_db->num_records) {
handle = p_db->record[p_db->num_records - 1].record_handle + 1;
else
} else {
handle = 0x10000;
}
p_db->record[p_db->num_records].record_handle = handle;
@@ -306,10 +300,11 @@ UINT32 SDP_CreateRecord (void)
4, buf);
return (p_db->record[p_db->num_records - 1].record_handle);
} else {
SDP_TRACE_ERROR("SDP_CreateRecord fail, exceed maximum records:%d\n", SDP_MAX_RECORDS);
}
else SDP_TRACE_ERROR("SDP_CreateRecord fail, exceed maximum records:%d\n", SDP_MAX_RECORDS);
#endif
return (0);
return (0);
}
@@ -332,8 +327,7 @@ BOOLEAN SDP_DeleteRecord (UINT32 handle)
UINT16 xx, yy, zz;
tSDP_RECORD *p_rec = &sdp_cb.server_db.record[0];
if (handle == 0 || sdp_cb.server_db.num_records == 0)
{
if (handle == 0 || sdp_cb.server_db.num_records == 0) {
/* Delete all records in the database */
sdp_cb.server_db.num_records = 0;
@@ -341,22 +335,18 @@ BOOLEAN SDP_DeleteRecord (UINT32 handle)
sdp_cb.server_db.di_primary_handle = 0;
return (TRUE);
}
else
{
} else {
/* Find the record in the database */
for (xx = 0; xx < sdp_cb.server_db.num_records; xx++, p_rec++)
{
if (p_rec->record_handle == handle)
{
for (xx = 0; xx < sdp_cb.server_db.num_records; xx++, p_rec++) {
if (p_rec->record_handle == handle) {
/* Found it. Shift everything up one */
for (yy = xx; yy < sdp_cb.server_db.num_records; yy++, p_rec++)
{
for (yy = xx; yy < sdp_cb.server_db.num_records; yy++, p_rec++) {
*p_rec = *(p_rec + 1);
/* Adjust the attribute value pointer for each attribute */
for (zz = 0; zz < p_rec->num_attributes; zz++)
for (zz = 0; zz < p_rec->num_attributes; zz++) {
p_rec->attribute[zz].value_ptr -= sizeof(tSDP_RECORD);
}
}
sdp_cb.server_db.num_records--;
@@ -364,8 +354,7 @@ BOOLEAN SDP_DeleteRecord (UINT32 handle)
SDP_TRACE_DEBUG("SDP_DeleteRecord ok, num_records:%d\n", sdp_cb.server_db.num_records);
/* if we're deleting the primary DI record, clear the */
/* value in the control block */
if( sdp_cb.server_db.di_primary_handle == handle )
{
if ( sdp_cb.server_db.di_primary_handle == handle ) {
sdp_cb.server_db.di_primary_handle = 0;
}
@@ -400,104 +389,90 @@ BOOLEAN SDP_AddAttribute (UINT32 handle, UINT16 attr_id, UINT8 attr_type,
tSDP_RECORD *p_rec = &sdp_cb.server_db.record[0];
#if (BT_TRACE_VERBOSE == TRUE)
if (sdp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)
{
if (sdp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) {
if ((attr_type == UINT_DESC_TYPE) ||
(attr_type == TWO_COMP_INT_DESC_TYPE) ||
(attr_type == UUID_DESC_TYPE) ||
(attr_type == DATA_ELE_SEQ_DESC_TYPE) ||
(attr_type == DATA_ELE_ALT_DESC_TYPE))
{
(attr_type == TWO_COMP_INT_DESC_TYPE) ||
(attr_type == UUID_DESC_TYPE) ||
(attr_type == DATA_ELE_SEQ_DESC_TYPE) ||
(attr_type == DATA_ELE_ALT_DESC_TYPE)) {
UINT8 num_array[400];
UINT32 i;
UINT32 len = (attr_len > 200) ? 200 : attr_len;
num_array[0] ='\0';
for (i = 0; i < len; i++)
{
sprintf((char *)&num_array[i*2],"%02X",(UINT8)(p_val[i]));
num_array[0] = '\0';
for (i = 0; i < len; i++) {
sprintf((char *)&num_array[i * 2], "%02X", (UINT8)(p_val[i]));
}
SDP_TRACE_DEBUG("SDP_AddAttribute: handle:%X, id:%04X, type:%d, len:%d, p_val:%p, *p_val:%s\n",
handle,attr_id,attr_type,attr_len,p_val,num_array);
}
else if (attr_type == BOOLEAN_DESC_TYPE)
{
handle, attr_id, attr_type, attr_len, p_val, num_array);
} else if (attr_type == BOOLEAN_DESC_TYPE) {
SDP_TRACE_DEBUG("SDP_AddAttribute: handle:%X, id:%04X, type:%d, len:%d, p_val:%p, *p_val:%d\n",
handle,attr_id,attr_type,attr_len,p_val,*p_val);
}
else
{
handle, attr_id, attr_type, attr_len, p_val, *p_val);
} else {
SDP_TRACE_DEBUG("SDP_AddAttribute: handle:%X, id:%04X, type:%d, len:%d, p_val:%p, *p_val:%s\n",
handle,attr_id,attr_type,attr_len,p_val,p_val);
handle, attr_id, attr_type, attr_len, p_val, p_val);
}
}
#endif
/* Find the record in the database */
for (zz = 0; zz < sdp_cb.server_db.num_records; zz++, p_rec++)
{
if (p_rec->record_handle == handle)
{
for (zz = 0; zz < sdp_cb.server_db.num_records; zz++, p_rec++) {
if (p_rec->record_handle == handle) {
tSDP_ATTRIBUTE *p_attr = &p_rec->attribute[0];
/* Found the record. Now, see if the attribute already exists */
for (xx = 0; xx < p_rec->num_attributes; xx++, p_attr++)
{
for (xx = 0; xx < p_rec->num_attributes; xx++, p_attr++) {
/* The attribute exists. replace it */
if (p_attr->id == attr_id)
{
if (p_attr->id == attr_id) {
SDP_DeleteAttribute (handle, attr_id);
break;
}
if (p_attr->id > attr_id)
if (p_attr->id > attr_id) {
break;
}
}
if (p_rec->num_attributes == SDP_MAX_REC_ATTR)
if (p_rec->num_attributes == SDP_MAX_REC_ATTR) {
return (FALSE);
}
/* If not found, see if we can allocate a new entry */
if (xx == p_rec->num_attributes)
if (xx == p_rec->num_attributes) {
p_attr = &p_rec->attribute[p_rec->num_attributes];
else
{
} else {
/* Since the attributes are kept in sorted order, insert ours here */
for (yy = p_rec->num_attributes; yy > xx; yy--)
for (yy = p_rec->num_attributes; yy > xx; yy--) {
p_rec->attribute[yy] = p_rec->attribute[yy - 1];
}
}
p_attr->id = attr_id;
p_attr->type = attr_type;
p_attr->len = attr_len;
if (p_rec->free_pad_ptr + attr_len >= SDP_MAX_PAD_LEN)
{
if (p_rec->free_pad_ptr + attr_len >= SDP_MAX_PAD_LEN) {
/* do truncate only for text string type descriptor */
if (attr_type == TEXT_STR_DESC_TYPE)
{
if (attr_type == TEXT_STR_DESC_TYPE) {
SDP_TRACE_WARNING("SDP_AddAttribute: attr_len:%d too long. truncate to (%d)\n",
attr_len, SDP_MAX_PAD_LEN - p_rec->free_pad_ptr );
attr_len, SDP_MAX_PAD_LEN - p_rec->free_pad_ptr );
attr_len = SDP_MAX_PAD_LEN - p_rec->free_pad_ptr;
p_val[SDP_MAX_PAD_LEN - p_rec->free_pad_ptr] = '\0';
p_val[SDP_MAX_PAD_LEN - p_rec->free_pad_ptr+1] = '\0';
}
else
p_val[SDP_MAX_PAD_LEN - p_rec->free_pad_ptr + 1] = '\0';
} else {
attr_len = 0;
}
}
if ((attr_len > 0) && (p_val != 0))
{
if ((attr_len > 0) && (p_val != 0)) {
p_attr->len = attr_len;
memcpy (&p_rec->attr_pad[p_rec->free_pad_ptr], p_val, (size_t)attr_len);
p_attr->value_ptr = &p_rec->attr_pad[p_rec->free_pad_ptr];
p_rec->free_pad_ptr += attr_len;
}
else if ((attr_len == 0 && p_attr->len != 0) || /* if truncate to 0 length, simply don't add */
p_val == 0)
{
} else if ((attr_len == 0 && p_attr->len != 0) || /* if truncate to 0 length, simply don't add */
p_val == 0) {
SDP_TRACE_ERROR("SDP_AddAttribute fail, length exceed maximum: ID %d: attr_len:%d \n",
attr_id, attr_len );
attr_id, attr_len );
p_attr->id = p_attr->type = p_attr->len = 0;
return (FALSE);
}
@@ -534,19 +509,16 @@ BOOLEAN SDP_AddSequence (UINT32 handle, UINT16 attr_id, UINT16 num_elem,
UINT8 *p_head;
BOOLEAN result;
if ((p_buff = (UINT8 *) GKI_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN * 2)) == NULL)
{
if ((p_buff = (UINT8 *) GKI_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN * 2)) == NULL) {
SDP_TRACE_ERROR("SDP_AddSequence cannot get a buffer!\n");
return (FALSE);
}
p = p_buff;
/* First, build the sequence */
for (xx = 0; xx < num_elem; xx++)
{
for (xx = 0; xx < num_elem; xx++) {
p_head = p;
switch (len[xx])
{
switch (len[xx]) {
case 1:
UINT8_TO_BE_STREAM (p, (type[xx] << 3) | SIZE_ONE_BYTE);
break;
@@ -570,23 +542,21 @@ BOOLEAN SDP_AddSequence (UINT32 handle, UINT16 attr_id, UINT16 num_elem,
ARRAY_TO_BE_STREAM (p, p_val[xx], len[xx]);
if (p - p_buff > SDP_MAX_ATTR_LEN)
{
if (p - p_buff > SDP_MAX_ATTR_LEN) {
/* go back to before we add this element */
p = p_head;
if(p_head == p_buff)
{
if (p_head == p_buff) {
/* the first element exceed the max length */
SDP_TRACE_ERROR ("SDP_AddSequence - too long(attribute is not added)!!\n");
GKI_freebuf(p_buff);
return FALSE;
}
else
} else {
SDP_TRACE_ERROR ("SDP_AddSequence - too long, add %d elements of %d\n", xx, num_elem);
}
break;
}
}
result = SDP_AddAttribute (handle, attr_id, DATA_ELE_SEQ_DESC_TYPE,(UINT32) (p - p_buff), p_buff);
result = SDP_AddAttribute (handle, attr_id, DATA_ELE_SEQ_DESC_TYPE, (UINT32) (p - p_buff), p_buff);
GKI_freebuf(p_buff);
return result;
#else /* SDP_SERVER_ENABLED == FALSE */
@@ -614,30 +584,27 @@ BOOLEAN SDP_AddUuidSequence (UINT32 handle, UINT16 attr_id, UINT16 num_uuids,
UINT16 xx;
UINT8 *p_buff;
UINT8 *p;
INT32 max_len = SDP_MAX_ATTR_LEN -3;
INT32 max_len = SDP_MAX_ATTR_LEN - 3;
BOOLEAN result;
if ((p_buff = (UINT8 *) GKI_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN * 2)) == NULL)
{
if ((p_buff = (UINT8 *) GKI_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN * 2)) == NULL) {
SDP_TRACE_ERROR("SDP_AddUuidSequence cannot get a buffer!\n");
return (FALSE);
}
p = p_buff;
/* First, build the sequence */
for (xx = 0; xx < num_uuids ; xx++, p_uuids++)
{
for (xx = 0; xx < num_uuids ; xx++, p_uuids++) {
UINT8_TO_BE_STREAM (p, (UUID_DESC_TYPE << 3) | SIZE_TWO_BYTES);
UINT16_TO_BE_STREAM (p, *p_uuids);
if((p - p_buff) > max_len)
{
if ((p - p_buff) > max_len) {
SDP_TRACE_WARNING ("SDP_AddUuidSequence - too long, add %d uuids of %d\n", xx, num_uuids);
break;
}
}
result = SDP_AddAttribute (handle, attr_id, DATA_ELE_SEQ_DESC_TYPE,(UINT32) (p - p_buff), p_buff);
result = SDP_AddAttribute (handle, attr_id, DATA_ELE_SEQ_DESC_TYPE, (UINT32) (p - p_buff), p_buff);
GKI_freebuf(p_buff);
return result;
#else /* SDP_SERVER_ENABLED == FALSE */
@@ -665,14 +632,13 @@ BOOLEAN SDP_AddProtocolList (UINT32 handle, UINT16 num_elem,
int offset;
BOOLEAN result;
if ((p_buff = (UINT8 *) GKI_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN * 2)) == NULL)
{
if ((p_buff = (UINT8 *) GKI_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN * 2)) == NULL) {
SDP_TRACE_ERROR("SDP_AddProtocolList cannot get a buffer!\n");
return (FALSE);
}
offset = sdp_compose_proto_list(p_buff, num_elem, p_elem_list);
result = SDP_AddAttribute (handle, ATTR_ID_PROTOCOL_DESC_LIST,DATA_ELE_SEQ_DESC_TYPE, (UINT32) offset, p_buff);
result = SDP_AddAttribute (handle, ATTR_ID_PROTOCOL_DESC_LIST, DATA_ELE_SEQ_DESC_TYPE, (UINT32) offset, p_buff);
GKI_freebuf(p_buff);
return result;
#else /* SDP_SERVER_ENABLED == FALSE */
@@ -704,16 +670,14 @@ BOOLEAN SDP_AddAdditionProtoLists (UINT32 handle, UINT16 num_elem,
int offset;
BOOLEAN result;
if ((p_buff = (UINT8 *) GKI_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN * 2)) == NULL)
{
if ((p_buff = (UINT8 *) GKI_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN * 2)) == NULL) {
SDP_TRACE_ERROR("SDP_AddAdditionProtoLists cannot get a buffer!\n");
return (FALSE);
}
p = p_buff;
/* for each ProtocolDescriptorList */
for (xx = 0; xx < num_elem; xx++, p_proto_list++)
{
for (xx = 0; xx < num_elem; xx++, p_proto_list++) {
UINT8_TO_BE_STREAM (p, (DATA_ELE_SEQ_DESC_TYPE << 3) | SIZE_IN_NEXT_BYTE);
p_len = p++;
@@ -723,8 +687,8 @@ BOOLEAN SDP_AddAdditionProtoLists (UINT32 handle, UINT16 num_elem,
*p_len = (UINT8)(p - p_len - 1);
}
result = SDP_AddAttribute (handle, ATTR_ID_ADDITION_PROTO_DESC_LISTS,DATA_ELE_SEQ_DESC_TYPE,
(UINT32) (p - p_buff), p_buff);
result = SDP_AddAttribute (handle, ATTR_ID_ADDITION_PROTO_DESC_LISTS, DATA_ELE_SEQ_DESC_TYPE,
(UINT32) (p - p_buff), p_buff);
GKI_freebuf(p_buff);
return result;
@@ -751,14 +715,13 @@ BOOLEAN SDP_AddProfileDescriptorList (UINT32 handle, UINT16 profile_uuid,
#if SDP_SERVER_ENABLED == TRUE
UINT8 *p_buff;
UINT8 *p;
BOOLEAN result;
BOOLEAN result;
if ((p_buff = (UINT8 *) GKI_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN)) == NULL)
{
if ((p_buff = (UINT8 *) GKI_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN)) == NULL) {
SDP_TRACE_ERROR("SDP_AddProfileDescriptorList cannot get a buffer!\n");
return (FALSE);
}
p = p_buff+2;
p = p_buff + 2;
/* First, build the profile descriptor list. This consists of a data element sequence. */
/* The sequence consists of profile's UUID and version number */
@@ -770,9 +733,9 @@ BOOLEAN SDP_AddProfileDescriptorList (UINT32 handle, UINT16 profile_uuid,
/* Add in type and length fields */
*p_buff = (UINT8) ((DATA_ELE_SEQ_DESC_TYPE << 3) | SIZE_IN_NEXT_BYTE);
*(p_buff+1) = (UINT8) (p - (p_buff+2));
*(p_buff + 1) = (UINT8) (p - (p_buff + 2));
result = SDP_AddAttribute (handle, ATTR_ID_BT_PROFILE_DESC_LIST,DATA_ELE_SEQ_DESC_TYPE, (UINT32) (p - p_buff), p_buff);
result = SDP_AddAttribute (handle, ATTR_ID_BT_PROFILE_DESC_LIST, DATA_ELE_SEQ_DESC_TYPE, (UINT32) (p - p_buff), p_buff);
GKI_freebuf(p_buff);
return result;
@@ -802,8 +765,7 @@ BOOLEAN SDP_AddLanguageBaseAttrIDList (UINT32 handle, UINT16 lang,
UINT8 *p;
BOOLEAN result;
if ((p_buff = (UINT8 *) GKI_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN)) == NULL)
{
if ((p_buff = (UINT8 *) GKI_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN)) == NULL) {
SDP_TRACE_ERROR("SDP_AddLanguageBaseAttrIDList cannot get a buffer!\n");
return (FALSE);
}
@@ -820,8 +782,8 @@ BOOLEAN SDP_AddLanguageBaseAttrIDList (UINT32 handle, UINT16 lang,
UINT8_TO_BE_STREAM (p, (UINT_DESC_TYPE << 3) | SIZE_TWO_BYTES);
UINT16_TO_BE_STREAM (p, base_id);
result = SDP_AddAttribute (handle, ATTR_ID_LANGUAGE_BASE_ATTR_ID_LIST,DATA_ELE_SEQ_DESC_TYPE,
(UINT32) (p - p_buff), p_buff);
result = SDP_AddAttribute (handle, ATTR_ID_LANGUAGE_BASE_ATTR_ID_LIST, DATA_ELE_SEQ_DESC_TYPE,
(UINT32) (p - p_buff), p_buff);
GKI_freebuf(p_buff);
return result;
#else /* SDP_SERVER_ENABLED == FALSE */
@@ -851,21 +813,19 @@ BOOLEAN SDP_AddServiceClassIdList (UINT32 handle, UINT16 num_services,
UINT8 *p;
BOOLEAN result;
if ((p_buff = (UINT8 *) GKI_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN * 2)) == NULL)
{
if ((p_buff = (UINT8 *) GKI_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN * 2)) == NULL) {
SDP_TRACE_ERROR("SDP_AddServiceClassIdList cannot get a buffer!\n");
return (FALSE);
}
p = p_buff;
for (xx = 0; xx < num_services; xx++, p_service_uuids++)
{
for (xx = 0; xx < num_services; xx++, p_service_uuids++) {
UINT8_TO_BE_STREAM (p, (UUID_DESC_TYPE << 3) | SIZE_TWO_BYTES);
UINT16_TO_BE_STREAM (p, *p_service_uuids);
}
result = SDP_AddAttribute (handle, ATTR_ID_SERVICE_CLASS_ID_LIST,DATA_ELE_SEQ_DESC_TYPE,
(UINT32) (p - p_buff), p_buff);
result = SDP_AddAttribute (handle, ATTR_ID_SERVICE_CLASS_ID_LIST, DATA_ELE_SEQ_DESC_TYPE,
(UINT32) (p - p_buff), p_buff);
GKI_freebuf(p_buff);
return result;
#else /* SDP_SERVER_ENABLED == FALSE */
@@ -893,45 +853,39 @@ BOOLEAN SDP_DeleteAttribute (UINT32 handle, UINT16 attr_id)
UINT32 len; /* Number of bytes in the entry */
/* Find the record in the database */
for (xx = 0; xx < sdp_cb.server_db.num_records; xx++, p_rec++)
{
if (p_rec->record_handle == handle)
{
for (xx = 0; xx < sdp_cb.server_db.num_records; xx++, p_rec++) {
if (p_rec->record_handle == handle) {
tSDP_ATTRIBUTE *p_attr = &p_rec->attribute[0];
SDP_TRACE_API("Deleting attr_id 0x%04x for handle 0x%x\n", attr_id, handle);
/* Found it. Now, find the attribute */
for (xx = 0; xx < p_rec->num_attributes; xx++, p_attr++)
{
if (p_attr->id == attr_id)
{
for (xx = 0; xx < p_rec->num_attributes; xx++, p_attr++) {
if (p_attr->id == attr_id) {
pad_ptr = p_attr->value_ptr;
len = p_attr->len;
if (len)
{
for (yy = 0; yy < p_rec->num_attributes; yy++)
{
if( p_rec->attribute[yy].value_ptr > pad_ptr )
if (len) {
for (yy = 0; yy < p_rec->num_attributes; yy++) {
if ( p_rec->attribute[yy].value_ptr > pad_ptr ) {
p_rec->attribute[yy].value_ptr -= len;
}
}
}
/* Found it. Shift everything up one */
p_rec->num_attributes--;
for (yy = xx; yy < p_rec->num_attributes; yy++, p_attr++)
{
for (yy = xx; yy < p_rec->num_attributes; yy++, p_attr++) {
*p_attr = *(p_attr + 1);
}
/* adjust attribute values if needed */
if (len)
{
xx = (p_rec->free_pad_ptr - ((pad_ptr+len) -
&p_rec->attr_pad[0]));
for( yy=0; yy<xx; yy++, pad_ptr++)
*pad_ptr = *(pad_ptr+len);
if (len) {
xx = (p_rec->free_pad_ptr - ((pad_ptr + len) -
&p_rec->attr_pad[0]));
for ( yy = 0; yy < xx; yy++, pad_ptr++) {
*pad_ptr = *(pad_ptr + len);
}
p_rec->free_pad_ptr -= len;
}
return (TRUE);
@@ -972,16 +926,15 @@ INT32 SDP_ReadRecord(UINT32 handle, UINT8 *p_data, INT32 *p_data_len)
/* Find the record in the database */
p_rec = sdp_db_find_record(handle);
if(p_rec && p_data && p_data_len)
{
if (p_rec && p_data && p_data_len) {
p_rsp = &p_data[3];
while ( (p_attr = sdp_db_find_attr_in_rec (p_rec, start, end)) != NULL)
{
while ( (p_attr = sdp_db_find_attr_in_rec (p_rec, start, end)) != NULL) {
/* Check if attribute fits. Assume 3-byte value type/length */
rem_len = *p_data_len - (UINT16) (p_rsp - p_data);
if (p_attr->len > (UINT32)(rem_len - 6))
if (p_attr->len > (UINT32)(rem_len - 6)) {
break;
}
p_rsp = sdpu_build_attrib_entry (p_rsp, p_attr);
@@ -991,15 +944,12 @@ INT32 SDP_ReadRecord(UINT32 handle, UINT8 *p_data, INT32 *p_data_len)
len = (INT32) (p_rsp - p_data);
/* Put in the sequence header (2 or 3 bytes) */
if (len > 255)
{
if (len > 255) {
offset = 0;
p_data[0] = (UINT8) ((DATA_ELE_SEQ_DESC_TYPE << 3) | SIZE_IN_NEXT_WORD);
p_data[1] = (UINT8) ((len - 3) >> 8);
p_data[2] = (UINT8) (len - 3);
}
else
{
} else {
offset = 1;
p_data[1] = (UINT8) ((DATA_ELE_SEQ_DESC_TYPE << 3) | SIZE_IN_NEXT_BYTE);