|
From: Peter K. <pk...@us...> - 2001-03-26 13:48:44
|
The following files were modified in apps/bluetooth/sdp_server:
Name Old version New version Comment
---- ----------- ----------- -------
sdp_parser.c 1.16 1.17=20=20=20=20=20=20=20=20=20=20=20=20
sdp_server.c 1.21 1.22=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Replaced -=3D 1 and +=3D 1 with -- and ++, and some other minor clean-up.
The diff of the modified file(s):
--- sdp_parser.c 2001/03/26 12:25:24 1.16
+++ sdp_parser.c 2001/03/26 13:48:28 1.17
@@ -304,7 +304,7 @@
service_search_uuid[i] =3D CHAR2INT16(data[cur_pos + 1],
data[cur_pos + 2]);
D_MISC("Found UUID16 0x%04x", service_search_uuid[i]);=20
- i +=3D 1;
+ i++;
tmp_pos +=3D 3;
cur_pos +=3D 3;
}
@@ -314,7 +314,7 @@
service_search_uuid[i] =3D CHAR2INT16(data[cur_pos + 1],
data[cur_pos + 2]);
D_MISC("Found UUID32 0x%08x", service_search_uuid[i]);=20
- i +=3D 1;
+ i++;
tmp_pos +=3D 5;
cur_pos +=3D 3;
}
@@ -324,7 +324,7 @@
service_search_uuid[i] =3D CHAR2INT16(data[cur_pos + 1],
data[cur_pos + 2]);
D_MISC("Got Service class 0x%08x", service_search_uuid[i]);
- i +=3D 1;
+ i++;
tmp_pos +=3D 17;
cur_pos +=3D 15;
}
@@ -341,10 +341,8 @@
max_rec_cnt =3D CHAR2INT16(data[cur_pos], data[cur_pos + 1]);
D_MISC("max_rec_cnt: %d", max_rec_cnt);
cur_pos +=3D 2;
-
- cont_state_len =3D data[cur_pos];
- cur_pos +=3D 1;
=20=20=20
+ cont_state_len =3D data[cur_pos++];
=20
if (len < cur_pos)
{
@@ -451,7 +449,7 @@
attr_list[attr_list_pos] =3D CHAR2INT32(data[cur_pos], data[cur_pos =
+ 1], data[cur_pos + 2], data[cur_pos + 3]);
D_MISC("Found range of attributes: 0x%08x", attr_list[attr_list_pos]=
);=20
cur_pos +=3D 4;
- attr_list_pos +=3D 1;
+ attr_list_pos++;
}
else
{
@@ -461,13 +459,13 @@
attr_list[attr_list_pos] |=3D attr_list[attr_list_pos] << 16;
D_MISC("Found single attributes: 0x%04x", attr_list[attr_list_pos]);=
=20
cur_pos +=3D 2;
- attr_list_pos +=3D 1;
+ attr_list_pos++;
}
des_len -=3D (*new_pos + tmp_len);
}
=20
- cont_state_len =3D data[cur_pos];
- cur_pos +=3D 1 + cont_state_len;
+ cont_state_len =3D data[cur_pos++];
+ cur_pos +=3D cont_state_len;
=20
if (len < cur_pos)
{
@@ -568,7 +566,7 @@
service_search_uuid[i] =3D CHAR2INT16(data[cur_pos + 1],
data[cur_pos + 2]);
D_MISC("Got Service class 0x%04x", service_search_uuid[i]);
- i +=3D 1;
+ i++;
tmp_pos +=3D 3;
cur_pos +=3D 3;
}
@@ -578,7 +576,7 @@
service_search_uuid[i] =3D CHAR2INT16(data[cur_pos + 1],
data[cur_pos + 2]);
D_MISC("Got Service class 0x%08x", service_search_uuid[i]);
- i +=3D 1;
+ i++;
tmp_pos +=3D 5;
cur_pos +=3D 3;
}
@@ -588,7 +586,7 @@
service_search_uuid[i] =3D CHAR2INT16(data[cur_pos + 1],
data[cur_pos + 2]);
D_MISC("Got Service class 0x%08x", service_search_uuid[i]);
- i +=3D 1;
+ i++;
tmp_pos +=3D 17;
cur_pos +=3D 15;
}
@@ -636,7 +634,7 @@
data[cur_pos + 3]);
D_MISC("Found range of attributes: 0x%08x", attr_list[attr_list_pos]=
);=20
cur_pos +=3D 4;
- attr_list_pos +=3D 1;
+ attr_list_pos++;
}
else
{
@@ -647,13 +645,13 @@
D_MISC("Found single attributes: 0x%04x",
(attr_list[attr_list_pos]) & 0xffff);=20
cur_pos +=3D 2;
- attr_list_pos +=3D 1;
+ attr_list_pos++;
}
des_len -=3D (*new_pos + tmp_len);
}
=20
- cont_state_len =3D data[cur_pos];
- cur_pos +=3D 1 + cont_state_len;
+ cont_state_len =3D data[cur_pos++];
+ cur_pos +=3D cont_state_len;
=20
if (len < cur_pos)
{
--- sdp_server.c 2001/03/26 12:58:25 1.21
+++ sdp_server.c 2001/03/26 13:48:28 1.22
@@ -198,8 +198,8 @@
int
get_err(void)
{
- int tmp;
- tmp =3D parse_err;
+ int tmp =3D parse_err;
+
parse_err =3D 0;
return tmp;
}
@@ -208,13 +208,12 @@
start_xml_parser(XML_Parser p, int fd)
{
void *buf;
+ int len;
=20
lseek(fd, 0, SEEK_SET);
=20=20=20=20=20=20=20
- for (;;)
+ do
{
- int len;
-
buf =3D XML_GetBuffer(p, BUFFSIZE);
if (buf =3D=3D NULL)
{
@@ -238,10 +237,8 @@
XML_ErrorString(XML_GetErrorCode(p)));
fprintf(stderr, "len:%d\n",len);
break;
- }
- if (len =3D=3D 0)
- break;
}
+ } while (len);
}
=20
unsigned char*
@@ -579,9 +576,8 @@
/* Lists all attributes registerd in the database */
attr_lst =3D get_all_attributes(fd);
=20=20=20
- return_sequence[0] =3D DES_HDR;
- return_sequence[1] =3D 0;
- pos +=3D 2;
+ return_sequence[pos++] =3D DES_HDR;
+ return_sequence[pos++] =3D 0;
=20=20=20
/* Find the first attribute in the range */
while ((i < attr_lst[0]) && (attr_lst[i] < (attr_id_code >> 16)))
@@ -743,7 +739,7 @@
if (strcmp(el, search_struct->service_class) =3D=3D 0)
{
S_FNC("Found service class %s", el);
- search_struct->service_class_found +=3D 1;
+ search_struct->service_class_found++;
}
if (search_struct->service_class_found)
{
@@ -800,7 +796,7 @@
list */
else if (search_struct->attr2get > 0)
{
- search_struct->attr2get -=3D 1;
+ search_struct->attr2get--;
=20
if (attr[0] && attr[1] &&
(strcmp(attr[0], "type") =3D=3D 0) && (strcmp(attr[1], "DES") =
=3D=3D 0))
@@ -840,7 +836,7 @@
if (strcmp(el, search_hdl->service_class) =3D=3D 0)
{
S_FNC("Found %s", el);
- search_hdl->service_class_found -=3D 1;
+ search_hdl->service_class_found--;
}
/* If we have found the attribute name end tag, there are no more attrib=
utes
to find */
@@ -869,17 +865,19 @@
int i =3D 0;
=20
if (len <=3D 0)
+ {
return;
+ }
=20=20=20
- while (i < len)
+ while (i < len && !FIRST_VALID_CHAR(s[i]))
{
- if (FIRST_VALID_CHAR(s[i]))
- break;
i++;
}
=20
if (i =3D=3D len)
+ {
return;
+ }
=20
if ((search_hdl->service_class_found) && (search_hdl->attribute_name_fou=
nd))
{
@@ -901,11 +899,10 @@
sprintf(search_hdl->attrlist + search_hdl->attrlist_index,
"%01x%01x" , s[i] / 16, s[i] % 16);
search_hdl->attrlist_index +=3D 2;
- search_hdl->des_len[0] +=3D1;
+ search_hdl->des_len[0]++;
}
=20=20=20=20=20
- strncpy(search_hdl->attrlist + search_hdl->attrlist_index, "\0", 1);
- search_hdl->attrlist_index +=3D 1;
+ search_hdl->attrlist[search_hdl->attrlist_index++] =3D '\0';
}
}
=20
@@ -1120,8 +1117,8 @@
memcpy(search_hdl->search_val, &attr_cnt, 4);
for (i =3D 0; attr[i]; i +=3D 2)
{
- unsigned int tmp;
- tmp =3D (unsigned int)strtol(attr[i + 1], NULL, 16);=20
+ unsigned int tmp =3D strtoul(attr[i + 1], NULL, 16);=20
+
memcpy(search_hdl->search_val + 4 +(i * 2), &tmp ,4);
S_FNC("Attribute %d found", tmp);
}=20
@@ -1185,7 +1182,7 @@
=20
if (rec_hdl !=3D NO_REC_HDL)
{
- rec_hdl_cnt +=3D 1;
+ rec_hdl_cnt++;
}
=20
rec_hdl_list =3D get_more_rec_hdl(db_hdl->service_class_list[0], xml_fd);
@@ -1199,7 +1196,7 @@
D_REC("Got Record handle: 0x%08x", rec_hdl_list[i]);
if (rec_hdl =3D=3D rec_hdl_list[i])
{
- rec_hdl_cnt -=3D 1;
+ rec_hdl_cnt--;
rec_hdl =3D NO_REC_HDL;
}
i++;
@@ -1210,33 +1207,29 @@
rsp_pkt_len =3D SDP_HDR_SIZE;=20=20
=20=20=20
/* Set the total service record count */
- rsp_pkt[rsp_pkt_len] =3D SHORT2CHAR_MS(rec_hdl_cnt);
- rsp_pkt[rsp_pkt_len + 1] =3D SHORT2CHAR_LS(rec_hdl_cnt);
- rsp_pkt_len +=3D 2;
+ rsp_pkt[rsp_pkt_len++] =3D SHORT2CHAR_MS(rec_hdl_cnt);
+ rsp_pkt[rsp_pkt_len++] =3D SHORT2CHAR_LS(rec_hdl_cnt);
=20=20=20
/* Set the current service record count */
- rsp_pkt[rsp_pkt_len] =3D SHORT2CHAR_MS(rec_hdl_cnt);
- rsp_pkt[rsp_pkt_len + 1] =3D SHORT2CHAR_LS(rec_hdl_cnt);
- rsp_pkt_len +=3D 2;
+ rsp_pkt[rsp_pkt_len++] =3D SHORT2CHAR_MS(rec_hdl_cnt);
+ rsp_pkt[rsp_pkt_len++] =3D SHORT2CHAR_LS(rec_hdl_cnt);
=20=20=20
if (rec_hdl !=3D NO_REC_HDL)
{
- rsp_pkt[rsp_pkt_len] =3D (rec_hdl >> 24) & 0xff;
- rsp_pkt[rsp_pkt_len + 1] =3D (rec_hdl >> 16) & 0xff;
- rsp_pkt[rsp_pkt_len + 2] =3D (rec_hdl >> 8) & 0xff;
- rsp_pkt[rsp_pkt_len + 3] =3D rec_hdl & 0xff;
- rsp_pkt_len +=3D 4;
+ rsp_pkt[rsp_pkt_len++] =3D (rec_hdl >> 24) & 0xff;
+ rsp_pkt[rsp_pkt_len++] =3D (rec_hdl >> 16) & 0xff;
+ rsp_pkt[rsp_pkt_len++] =3D (rec_hdl >> 8) & 0xff;
+ rsp_pkt[rsp_pkt_len++] =3D rec_hdl & 0xff;
}
=20
if (rec_hdl_list)
{
for (i =3D 0; rec_hdl_list[i] !=3D NO_REC_HDL; i++)
{
- rsp_pkt[rsp_pkt_len] =3D (rec_hdl_list[i] >> 24) & 0xff;
- rsp_pkt[rsp_pkt_len + 1] =3D (rec_hdl_list[i] >> 16) & 0xff;
- rsp_pkt[rsp_pkt_len + 2] =3D (rec_hdl_list[i] >> 8) & 0xff;
- rsp_pkt[rsp_pkt_len + 3] =3D rec_hdl_list[i] & 0xff;
- rsp_pkt_len +=3D 4;
+ rsp_pkt[rsp_pkt_len++] =3D (rec_hdl_list[i] >> 24) & 0xff;
+ rsp_pkt[rsp_pkt_len++] =3D (rec_hdl_list[i] >> 16) & 0xff;
+ rsp_pkt[rsp_pkt_len++] =3D (rec_hdl_list[i] >> 8) & 0xff;
+ rsp_pkt[rsp_pkt_len++] =3D rec_hdl_list[i] & 0xff;
}
D_MEM("<--- free%d 0x%8p", --malloc_dbg, rec_hdl_list);
free(rec_hdl_list);
@@ -1260,9 +1253,9 @@
/* Skip the sdp header and the attribute byte count field */
rsp_pkt_len =3D SDP_HDR_SIZE + 2;
=20
- rsp_pkt[rsp_pkt_len] =3D DES_HDR;
- des_len_pos =3D rsp_pkt_len + 1;
- rsp_pkt_len +=3D 2;
+ rsp_pkt[rsp_pkt_len++] =3D DES_HDR;
+ des_len_pos =3D rsp_pkt_len;
+ rsp_pkt_len++;
=20=20=20
for (i =3D 0; i < db_hdl->attr_cnt; i++)
{
@@ -1348,9 +1341,9 @@
/* Skip the sdp header and the attribute byte count field */
rsp_pkt_len =3D SDP_HDR_SIZE + 2;
=20
- rsp_pkt[rsp_pkt_len] =3D DES_HDR_2B;
- des_len_pos =3D rsp_pkt_len + 1;
- rsp_pkt_len +=3D 3;
+ rsp_pkt[rsp_pkt_len++] =3D DES_HDR_2B;
+ des_len_pos =3D rsp_pkt_len;
+ rsp_pkt_len +=3D 2;
=20
if (!rec_hdl_cnt) {
rec_hdl_cnt =3D 1;
@@ -1421,7 +1414,7 @@
int cur_rec_cnt;
int cnt_len;
=20
- cur_rec_cnt =3D CHAR2INT16(pkt[7], pkt[8]);
+ cur_rec_cnt =3D CHAR2INT16(pkt[SDP_HDR_SIZE+2], pkt[SDP_HDR_SIZE+3]);
=20
if (cur_rec_cnt > max_rec_cnt)
{
@@ -1444,23 +1437,20 @@
cont_state_buf =3D malloc(sizeof(cont_state_struct) + cnt_len);
D_MEM("---> malloc%d %ld bytes at 0x%8p", malloc_dbg++, sizeof(cont_st=
ate_struct) + cnt_len, cont_state_buf);
=20
- cont_state_buf->pdu =3D pkt[0];
- D_MISC("PDU: 0x%02x", pkt[0]);
+ cont_state_buf->pdu =3D pkt[SDP_HDR_TYPE];
+ D_MISC("PDU: 0x%02x", cont_state_buf->pdu);
=20=20=20=20=20
cont_state_buf->len =3D cnt_len;
memcpy(cont_state_buf->data, pkt + len, cnt_len);
=20=20=20=20=20
len =3D SDP_HDR_SIZE + 2 + 2 + (max_rec_cnt * 4);
=20
- pkt[len] =3D 1;
- len +=3D 1;
- pkt[len] =3D 0;
- len +=3D 1;
+ pkt[len++] =3D 1;
+ pkt[len++] =3D 0;
}
else
{
- pkt[len] =3D 0;
- len +=3D 1;
+ pkt[len++] =3D 0;
}
=20=20=20
/* Change the length field */
@@ -1498,8 +1488,8 @@
cont_state_buf =3D malloc(sizeof(cont_state_struct) + cont_len);
D_MEM("---> malloc%d %ld bytes at 0x%8p", malloc_dbg++, sizeof(cont_st=
ate_struct) + cont_len , cont_state_buf);
=20
- cont_state_buf->pdu =3D pkt[0];
- D_MISC("PDU: 0x%02x", pkt[0]);
+ cont_state_buf->pdu =3D pkt[SDP_HDR_TYPE];
+ D_MISC("PDU: 0x%02x", cont_state_buf->pdu);
=20
cont_state_buf->len =3D cont_len;
memcpy(cont_state_buf->data, pkt + len, cont_len);
@@ -1507,16 +1497,13 @@
pkt[SDP_HDR_SIZE] =3D SHORT2CHAR_MS(max_attr_len);
pkt[SDP_HDR_SIZE+1] =3D SHORT2CHAR_LS(max_attr_len);
=20=20=20=20=20
- pkt[len] =3D 1;
- len +=3D 1;
- pkt[len] =3D 0;
- len +=3D 1;
+ pkt[len++] =3D 1;
+ pkt[len++] =3D 0;
}
else
{
S_FNC("No continuation State set");
- pkt[len] =3D 0;
- len +=3D 1;
+ pkt[len++] =3D 0;
}
=20=20=20
/* Change the length field */
@@ -1538,9 +1525,7 @@
if (!cont_state_buf) {
send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_CONTINUATION_STATE);
}
- else
- {
- if ((max_rec_cnt * 4) >=3D cont_state_buf->len)
+ else if ((max_rec_cnt * 4) >=3D cont_state_buf->len)
{
/* Allocate space for the SDP header, the attribute byte count field,
the attributes and the continuation state field */
@@ -1582,7 +1567,6 @@
send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_SDP_VERSION);
}
}
-}
=20
void
send_cont_state_attr_rsp(int len, unsigned char *info, int max_attr_cnt,
|